Skip to content

Commit

Permalink
Events index now has /year/month style routes.
Browse files Browse the repository at this point in the history
* Updated the previous/next month links to use new URL format.
* Added tr.node.level-2 td.page span.title classes, which hook into
* existing styles.
  • Loading branch information
nelstrom committed Jun 4, 2009
1 parent ac2226b commit b4edff4
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 14 deletions.
25 changes: 15 additions & 10 deletions app/controllers/page_events_controller.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
class PageEventsController < ApplicationController

def index
@date = (params[:date] || Time.now).to_time

@last_month = @date.last_month.to_date
@next_month = @date.next_month.to_date
@last_month_count = Page.event_count_by_month(@date.last_month)
@next_month_count = Page.event_count_by_month(@date.next_month)

@current_events = Page.events_by_month(@date)
end
def index

if !params[:year].blank? and !params[:month].blank?
@date = Time.local(params[:year], params[:month])
else
@date = (params[:date] || Time.now).to_time
end

@last_month = @date.last_month.to_date
@next_month = @date.next_month.to_date
@last_month_count = Page.event_count_by_month(@date.last_month)
@next_month_count = Page.event_count_by_month(@date.next_month)

@current_events = Page.events_by_month(@date)
end
end
8 changes: 4 additions & 4 deletions app/views/page_events/index.rhtml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ span.event_date {

<h1>Events for <%= month_with_year(@date) %></h1>

<%= link_to("#{@last_month.strftime("%B")}(#{@last_month_count})",:date => @last_month.to_s(:db))%> |
<%= link_to("#{@next_month.strftime("%B")}(#{@next_month_count})",:date => @next_month.to_s(:db))%>
<%= link_to("#{@last_month.strftime("%B")}(#{@last_month_count})", :year => @last_month.year, :month => @last_month.month )%> |
<%= link_to("#{@next_month.strftime("%B")}(#{@next_month_count})", :year => @next_month.year, :month => @next_month.month )%>
<table id="site-map" class="index" summary="Page hierarchy of the current site">
<thead>
<tr>
Expand All @@ -43,8 +43,8 @@ span.event_date {
<tbody>
<% unless @current_events.empty?
@current_events.each do |event| -%>
<tr>
<td><a href="<%= page_edit_url(:id => event) %>" title="<%= event.url %>"><%= event.title %></a></td>
<tr class="node level-2">
<td class="page"><a href="<%= page_edit_url(:id => event) %>" title="<%= event.url %>"><span class="title"><%= event.title %></span></a></td>
<td><%= event.status.name %></td>
<td>
<%= event.event_datetime_start.strftime("%m/%d/%Y %I:%M %p") %>
Expand Down
4 changes: 4 additions & 0 deletions page_event_extension.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ class PageEventExtension < Radiant::Extension

define_routes do |map|
map.connect 'admin/page_events/:action', :controller => 'page_events'
map.events 'admin/page_events/:year/:month',
:controller => 'page_events',
:action => "index",
:requirements => { :year => /\d{4}/, :month => /\d{1,2}/ }
end

def activate
Expand Down

0 comments on commit b4edff4

Please sign in to comment.