From 9816c395c5b6e27d3b2bb772af919a5a2bcbffed Mon Sep 17 00:00:00 2001 From: Alexey Verkhovsky Date: Tue, 27 Sep 2005 03:53:29 +0000 Subject: [PATCH] Expire caches for referencing pages on saves and deletes; fixed date formatting in recently_revised --- app/controllers/revision_sweeper.rb | 13 +++++++------ app/helpers/application_helper.rb | 11 ++++++++--- app/views/wiki/recently_revised.rhtml | 4 ++-- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/app/controllers/revision_sweeper.rb b/app/controllers/revision_sweeper.rb index 879274e3..28284ce6 100644 --- a/app/controllers/revision_sweeper.rb +++ b/app/controllers/revision_sweeper.rb @@ -17,15 +17,16 @@ class RevisionSweeper < ActionController::Caching::Sweeper def expire_caches(page) web = page.web - expire_action :controller => 'wiki', :web => web.address, - :action => %w(show published), :id => page.name + + ([page.name] + WikiReference.pages_that_reference(page.name)).uniq.each do |page_name| + expire_action :controller => 'wiki', :web => web.address, + :action => %w(show published), :id => page_name + end + expire_action :controller => 'wiki', :web => web.address, :action => %w(authors recently_revised list) expire_fragment :controller => 'wiki', :web => web.address, :action => %w(rss_with_headlines rss_with_content) - WikiReference.pages_that_reference(page.name).each do |ref| - expire_action :controller => 'wiki', :web => web.address, - :action => %w(show published), :id => ref.page.name - end end + end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index f72c572d..3056541e 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -77,10 +77,15 @@ module ApplicationHelper h(text).gsub(/\n/, '
') end - def format_date(date) + def format_date(date, include_time = true) # Must use DateTime because Time doesn't support %e on at least some platforms - DateTime.new(date.year, date.mon, date.day, date.hour, date.min, - date.sec).strftime("%B %e, %Y %H:%M:%S") + date_time = DateTime.new(date.year, date.mon, date.day, date.hour, date.min, + date.sec) + if include_time + return date_time.strftime("%B %e, %Y %H:%M:%S") + else + return date_time.strftime("%B %e, %Y") + end end def rendered_content(page) diff --git a/app/views/wiki/recently_revised.rhtml b/app/views/wiki/recently_revised.rhtml index 0460c7b7..f4ca669c 100644 --- a/app/views/wiki/recently_revised.rhtml +++ b/app/views/wiki/recently_revised.rhtml @@ -4,13 +4,13 @@ <% unless @pages_by_revision.empty? %> <% revision_date = @pages_by_revision.first.revised_at %> -

<%= revision_date.strftime('%B %e, %Y') %>

+

<%= format_date(revision_date, include_time = false) %>

-

<%= revision_date.strftime('%B %e, %Y') %>

+

<%= format_date(revision_date, include_time = false) %>