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)
|
def expire_caches(page)
|
||||||
web = page.web
|
web = page.web
|
||||||
|
|
||||||
|
([page.name] + WikiReference.pages_that_reference(page.name)).uniq.each do |page_name|
|
||||||
expire_action :controller => 'wiki', :web => web.address,
|
expire_action :controller => 'wiki', :web => web.address,
|
||||||
:action => %w(show published), :id => page.name
|
:action => %w(show published), :id => page_name
|
||||||
|
end
|
||||||
|
|
||||||
expire_action :controller => 'wiki', :web => web.address,
|
expire_action :controller => 'wiki', :web => web.address,
|
||||||
:action => %w(authors recently_revised list)
|
:action => %w(authors recently_revised list)
|
||||||
expire_fragment :controller => 'wiki', :web => web.address,
|
expire_fragment :controller => 'wiki', :web => web.address,
|
||||||
:action => %w(rss_with_headlines rss_with_content)
|
: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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -77,10 +77,15 @@ module ApplicationHelper
|
||||||
h(text).gsub(/\n/, '<br/>')
|
h(text).gsub(/\n/, '<br/>')
|
||||||
end
|
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
|
# 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_time = DateTime.new(date.year, date.mon, date.day, date.hour, date.min,
|
||||||
date.sec).strftime("%B %e, %Y %H:%M:%S")
|
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
|
end
|
||||||
|
|
||||||
def rendered_content(page)
|
def rendered_content(page)
|
||||||
|
|
|
@ -4,13 +4,13 @@
|
||||||
|
|
||||||
<% unless @pages_by_revision.empty? %>
|
<% unless @pages_by_revision.empty? %>
|
||||||
<% revision_date = @pages_by_revision.first.revised_at %>
|
<% 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>
|
<ul>
|
||||||
<% for page in @pages_by_revision %>
|
<% for page in @pages_by_revision %>
|
||||||
<% if page.revised_at < revision_date %>
|
<% if page.revised_at < revision_date %>
|
||||||
<% revision_date = page.revised_at %>
|
<% revision_date = page.revised_at %>
|
||||||
</ul>
|
</ul>
|
||||||
<h3><%= revision_date.strftime('%B %e, %Y') %></h3>
|
<h3><%= format_date(revision_date, include_time = false) %></h3>
|
||||||
<ul>
|
<ul>
|
||||||
<% end %>
|
<% end %>
|
||||||
<li>
|
<li>
|
||||||
|
|
Loading…
Reference in a new issue