- if params[:day] - date = Date.new(params[:year], params[:month], params[:mday]) - elsif params[:month] - date = Date.new(params[:year], params[:month], 1) - else - date ||= Date.today - month = date.month - month_events = Droom::Event.coincident_with(date.beginning_of_month, date.end_of_month) - first_shown = date.beginning_of_month.beginning_of_week - last_shown = date.end_of_month.end_of_week - before = date.beginning_of_month - 1.day - after = date.end_of_month + 1.day %table.minimonth{:data => {:month => date.month, :year => date.year}} %thead %tr %td.m = link_to '<', url_for_month(before), :title => (I18n.l before, :format => :minicalendar_title), :class => 'previous', :data => {:month => before.month, :year => before.year} %td{:colspan => 5} %h3 = link_to I18n.l(date, :format => :minicalendar_title), url_for_month(date), :class => "month" %td.m = link_to '>', url_for_month(after), :title => (I18n.l after, :format => :minicalendar_title), :class => 'next', :data => {:month => after.month, :year => after.year} %tr - day_names.each do |d| %th.day_name{:scope => 'col'} = d.first %tbody - weeks = {} - first_shown.upto(last_shown) do |day| - new_events_today = month_events.select{ |e| e.start_date == day } - continuing_events = month_events.select{ |e| e.start_date <= day && e.finish_date && e.finish_date >= day } - cell_class = "d" - cell_class += " o" if day.month != date.month - cell_class += " t" if day == Date.today - if new_events_today.any? - cell_class += " e" - date_label = link_to day.mday, url_for_date(day), :class => "day" - elsif continuing_events.any? - cell_class += " c" - date_label = link_to day.mday, url_for_date(day) - else - cell_class += " u" - date_label = day.mday - weeks[day.cweek] ||= [] - weeks[day.cweek].push({:class => cell_class, :label => date_label}) - weeks.sort.each do |week, weekdays| %tr - weekdays.each do |d| %td{:class => d[:class]} = d[:label]