diff --git a/app/helpers/calendars_helper.rb b/app/helpers/calendars_helper.rb index 0f98c29..08e84af 100644 --- a/app/helpers/calendars_helper.rb +++ b/app/helpers/calendars_helper.rb @@ -44,18 +44,8 @@ def make_calendar(this_month, rjs = false) block << %Q{
} block << calendar(calendar_options) do |d| if days_with_events.has_key?(d) - event_list = %Q{
\n
\n} eod = d + 1.day - 1.second - # Sort events by start time, with full-day events being placed - # at the end, followed by a secondary sort on the event name. - days_with_events[d].sort_by{|e| [e.start_time||eod,e.name]}.each do |event| - event_list << %Q{
#{h event.name}
\n} - event_list << %Q{
#{h event.location}
\n} if event.location - event_list << %Q{
#{h event.time(:format => '%l:%M %p')}
\n} if event.time - event_list << %Q{
#{h(event.description) || ' '}
\n} - end - event_list << %Q{
\n\n
\n} - events << event_list + events << ActionView::Base.new(ActionController::Base.view_paths).render(:partial => 'calendars/events', :locals => { :id => d.jd, :events => days_with_events[d], :end_of_day => eod }) [ %Q{#{d.mday}}, { :class => 'eventDay', :id => "day-#{d.jd}" } ] end diff --git a/app/views/calendars/_events.html.haml b/app/views/calendars/_events.html.haml new file mode 100644 index 0000000..7eb6728 --- /dev/null +++ b/app/views/calendars/_events.html.haml @@ -0,0 +1,10 @@ +.calendar-data.tooltip{ :id => "events-#{id}" } + %dl.events + - events.sort_by{|e| [e.start_time||end_of_day, e.name]}.each do |event| + %dt= h event.name + - if event.location + %dd.location= h event.location + - if event.time + %dd.time= h event.time(:format => '%l:%M %p') + %dd.description= h(event.description) || ' ' + %p.footer Click date for more details diff --git a/spec/models/events_calendar_spec.rb b/spec/models/events_calendar_spec.rb index 9bff5d5..dc96303 100644 --- a/spec/models/events_calendar_spec.rb +++ b/spec/models/events_calendar_spec.rb @@ -9,7 +9,7 @@ tag = %{} today = Date.today - expected = %r{\A
.*]*>#{Date::MONTHNAMES[today.month]}\n?.*]*>#{today.mday}.*
\Z}m + expected = %r{\A
.*]*>#{Date::MONTHNAMES[today.month]}\n?.*]*>#{today.mday}.*
\n?\n?
\Z}m pages(:home).should render(tag).matching(expected) end @@ -17,7 +17,7 @@ it 'should render a calendar for the specified month and year' do tag = %{} - expected = %r{\A
.*]*>#{Date::MONTHNAMES[1]}\n?.*
\Z}m + expected = %r{\A
.*]*>#{Date::MONTHNAMES[1]}\n?.*
\n?\n?\Z}m pages(:home).should render(tag).matching(expected) end