Expire caches for referencing pages on saves and deletes; fixed date formatting in recently_revised
This commit is contained in:
parent
5b1778a7f1
commit
9816c395c5
|
@ -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
|
||||
|
|
|
@ -77,10 +77,15 @@ module ApplicationHelper
|
|||
h(text).gsub(/\n/, '<br/>')
|
||||
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)
|
||||
|
|
|
@ -4,13 +4,13 @@
|
|||
|
||||
<% unless @pages_by_revision.empty? %>
|
||||
<% revision_date = @pages_by_revision.first.revised_at %>
|
||||
<h3><%= revision_date.strftime('%B %e, %Y') %></h3>
|
||||
<h3><%= format_date(revision_date, include_time = false) %></h3>
|
||||
<ul>
|
||||
<% for page in @pages_by_revision %>
|
||||
<% if page.revised_at < revision_date %>
|
||||
<% revision_date = page.revised_at %>
|
||||
</ul>
|
||||
<h3><%= revision_date.strftime('%B %e, %Y') %></h3>
|
||||
<h3><%= format_date(revision_date, include_time = false) %></h3>
|
||||
<ul>
|
||||
<% end %>
|
||||
<li>
|
||||
|
|
Loading…
Reference in a new issue