Upgrade to simple calendar V2
This commit is contained in:
parent
e8082e7610
commit
78b9d36d69
14
Gemfile.lock
14
Gemfile.lock
@ -152,7 +152,7 @@ GEM
|
||||
formtastic (3.1.3)
|
||||
actionpack (>= 3.2.13)
|
||||
formtastic_i18n (0.4.1)
|
||||
geocoder (1.2.9)
|
||||
geocoder (1.2.11)
|
||||
globalid (0.3.6)
|
||||
activesupport (>= 4.1.0)
|
||||
guard (2.13.0)
|
||||
@ -208,7 +208,7 @@ GEM
|
||||
haml (~> 4.0.0)
|
||||
nokogiri (~> 1.6.0)
|
||||
ruby_parser (~> 3.5)
|
||||
http (0.9.4)
|
||||
http (0.9.6)
|
||||
addressable (~> 2.3)
|
||||
http-cookie (~> 1.0)
|
||||
http-form_data (~> 1.0.1)
|
||||
@ -263,8 +263,8 @@ GEM
|
||||
modernizr-rails (2.7.1)
|
||||
multi_json (1.11.2)
|
||||
multipart-post (2.0.0)
|
||||
mysql2 (0.3.20)
|
||||
naught (1.0.0)
|
||||
mysql2 (0.4.0)
|
||||
naught (1.1.0)
|
||||
nenv (0.2.0)
|
||||
nokogiri (1.6.6.2)
|
||||
mini_portile (~> 0.6.0)
|
||||
@ -335,7 +335,7 @@ GEM
|
||||
request_store (1.2.0)
|
||||
responders (2.1.0)
|
||||
railties (>= 4.2.0, < 5)
|
||||
rubocop (0.34.0)
|
||||
rubocop (0.34.1)
|
||||
astrolabe (~> 1.3)
|
||||
parser (>= 2.2.2.5, < 3.0)
|
||||
powerpack (~> 0.1)
|
||||
@ -361,7 +361,7 @@ GEM
|
||||
thor (~> 0.14)
|
||||
sexp_processor (4.6.0)
|
||||
shellany (0.0.1)
|
||||
simple_calendar (1.1.10)
|
||||
simple_calendar (2.0.0)
|
||||
rails (>= 3.0)
|
||||
simple_oauth (0.3.1)
|
||||
simplecov (0.10.0)
|
||||
@ -379,7 +379,7 @@ GEM
|
||||
multi_json (~> 1.0)
|
||||
rack (~> 1.0)
|
||||
tilt (~> 1.1, != 1.3.0)
|
||||
sprockets-rails (2.3.2)
|
||||
sprockets-rails (2.3.3)
|
||||
actionpack (>= 3.0)
|
||||
activesupport (>= 3.0)
|
||||
sprockets (>= 2.8, < 4.0)
|
||||
|
@ -14,14 +14,27 @@
|
||||
- (1..12).each do |i|
|
||||
- params[:start_date] = "#{params[:year]}-#{i}-01"
|
||||
|
||||
= month_calendar day_names: 'date.day_names', events: @events,
|
||||
previous_link: nil, next_link: nil,
|
||||
title: ->(start_date) { raw link_to l(start_date, format: :month),
|
||||
root_path(start_date: start_date),
|
||||
class: 'month_selector' } do |date, events|
|
||||
= month_calendar do |date|
|
||||
- capture_haml do
|
||||
.day_number= date.day
|
||||
%ul.events.fa-ul
|
||||
- @events.select { |e| (e.start_time.to_date..e.end_time.to_date).cover? date }
|
||||
- .sort_by { |e| e.city }.each do |event|
|
||||
%li.event{ title: display_date(event) }
|
||||
- if event.locality?
|
||||
%em.locality.fa.fa-globe
|
||||
= link_to event do
|
||||
%strong.city{ title: event.address }= event.city
|
||||
= event.title
|
||||
|
||||
- else
|
||||
-# One month calendar
|
||||
- @events = @events.month params[:start_date].try :to_date
|
||||
= month_calendar do |date|
|
||||
- capture_haml do
|
||||
.day_number= date.day
|
||||
%ul.events.fa-ul
|
||||
- events.select { |e| (e.start_time.to_date..e.end_time.to_date).cover? date }
|
||||
- @events.select { |e| (e.start_time.to_date..e.end_time.to_date).cover? date }
|
||||
- .sort_by { |e| e.city }.each do |event|
|
||||
%li.event{ title: display_date(event) }
|
||||
- if event.locality?
|
||||
@ -30,36 +43,12 @@
|
||||
%strong.city{ title: event.address }= event.city
|
||||
= event.title
|
||||
|
||||
- else
|
||||
-# One month calendar
|
||||
- @events = @events.month params[:start_date].try :to_date
|
||||
= month_calendar day_names: 'date.day_names', events: @events,
|
||||
title: ->(start_date) { raw "#{I18n.t('date.month_names')[start_date.month]} #{link_to start_date.year,
|
||||
root_path(year: start_date.year)}" },
|
||||
previous_link: ->(param, date_range) { link_to '<<',
|
||||
{ param => (date_range.first - 1.day).beginning_of_month,
|
||||
tag: params[:tag], region: params[:region] } },
|
||||
next_link: ->(param, date_range) { link_to '>>',
|
||||
{ param => (date_range.last + 1.day).beginning_of_month,
|
||||
tag: params[:tag], region: params[:region] } } do |date, events|
|
||||
.day_number= date.day
|
||||
%ul.events.fa-ul
|
||||
- events.select { |e| (e.start_time.to_date..e.end_time.to_date).cover? date }
|
||||
- .sort_by { |e| e.city }.each do |event|
|
||||
%li.event{ title: display_date(event) }
|
||||
- if event.locality?
|
||||
%em.locality.fa.fa-globe
|
||||
= link_to event do
|
||||
%strong.city{ title: event.address }= event.city
|
||||
= event.title
|
||||
|
||||
.formats
|
||||
%em.fa.fa-rss
|
||||
= raw t '.calendar_in',
|
||||
rss: link_to('RSS', events_path(:rss,
|
||||
tag: params[:tag], region: params[:region])),
|
||||
webcal: link_to('webcal', events_path(:rss,
|
||||
tag: params[:tag], protocol: 'webcal', format: :ics, tag: params[:tag],
|
||||
webcal: link_to('webcal', events_path(tag: params[:tag], protocol: 'webcal', format: :ics, tag: params[:tag],
|
||||
region: params[:region])),
|
||||
ical: link_to('iCal', events_path(:rss,
|
||||
tag: params[:tag], format: :ics, tag: params[:tag],
|
||||
|
26
app/views/simple_calendar/_month_calendar.html.haml
Normal file
26
app/views/simple_calendar/_month_calendar.html.haml
Normal file
@ -0,0 +1,26 @@
|
||||
%header.calendar-header
|
||||
- if params[:year]
|
||||
= link_to start_date: start_date.beginning_of_month,
|
||||
tag: params[:tag], region: params[:region] do
|
||||
= I18n.t('date.month_names')[start_date.month]
|
||||
= start_date.year
|
||||
- else
|
||||
= link_to '<<', start_date: (date_range.first - 1.day).beginning_of_month,
|
||||
tag: params[:tag], region: params[:region]
|
||||
= I18n.t('date.month_names')[start_date.month]
|
||||
= link_to root_path(year: start_date.year) do
|
||||
= start_date.year
|
||||
= link_to '>>', start_date: (date_range.last + 1.day).beginning_of_month,
|
||||
tag: params[:tag], region: params[:region]
|
||||
|
||||
%table.table.table-striped
|
||||
%thead
|
||||
%tr
|
||||
- date_range.slice(0, 7).each do |day|
|
||||
%th= I18n.t('date.day_names')[day.wday]
|
||||
%tbody
|
||||
- date_range.each_slice(7) do |week|
|
||||
%tr
|
||||
- week.each do |day|
|
||||
= content_tag :td, class: calendar.td_classes_for(day) do
|
||||
= block.call day, sorted_events.fetch(day, [])
|
Loading…
Reference in New Issue
Block a user