Cache Sweeping

Expire cached revisions of deleted pages.
Tweak the appearance of "history" page a bit.
This commit is contained in:
Jacques Distler 2009-03-31 23:37:21 -05:00
parent 69bfc1028b
commit 98918954e0
4 changed files with 16 additions and 1 deletions

View file

@ -4,7 +4,7 @@ module CacheSweepingHelper
expire_action :controller => 'wiki', :web => web.address, expire_action :controller => 'wiki', :web => web.address,
:action => %w(show published s5 tex print history), :id => page_name :action => %w(show published s5 tex print history), :id => page_name
expire_action :controller => 'wiki', :web => web.address, expire_action :controller => 'wiki', :web => web.address,
:action => %w(show published), :id => page_name, :mode => 'diff' :action => 'show', :id => page_name, :mode => 'diff'
end end
def expire_cached_summary_pages(web) def expire_cached_summary_pages(web)
@ -25,4 +25,14 @@ module CacheSweepingHelper
end end
end end
def expire_cached_revisions(page)
page.revisions.length.times do |i|
revno = i+1
expire_action :controller => 'wiki', :web => page.web.address,
:action => 'revision', :id => page.name, :rev => revno
expire_action :controller => 'wiki', :web => page.web.address,
:action => 'revision', :id => page.name, :rev => revno, :mode => 'diff'
end
end
end end

View file

@ -25,6 +25,7 @@ class WebSweeper < ActionController::Caching::Sweeper
elsif record.is_a?(Page) elsif record.is_a?(Page)
expire_cached_page(record.web, record.name) expire_cached_page(record.web, record.name)
expire_cached_summary_pages(record.web) expire_cached_summary_pages(record.web)
expire_cached_revisions(record)
else else
expire_cached_summary_pages(record.web) expire_cached_summary_pages(record.web)
end end

View file

@ -12,8 +12,10 @@
"Revision #{@revision_numbers[rev.id]}" ) "Revision #{@revision_numbers[rev.id]}" )
) %> ) %>
<%- if @revision_numbers[rev.id] > 1 -%> <%- if @revision_numbers[rev.id] > 1 -%>
<span class="views">
(<%= link_to_revision(rev.page, @revision_numbers[rev.id], (<%= link_to_revision(rev.page, @revision_numbers[rev.id],
text="diff", mode='diff') %>) text="diff", mode='diff') %>)
</span>
<%- end -%> <%- end -%>
<div class="byline" style="margin-bottom: 0px"> <div class="byline" style="margin-bottom: 0px">
by <%= link_to_page(rev.author) %> by <%= link_to_page(rev.author) %>

View file

@ -9,9 +9,11 @@
<li> <li>
<%= link_to_existing_page page %> <%= link_to_existing_page page %>
<%- if page.revisions.length > 1 %> <%- if page.revisions.length > 1 %>
<span class="views">
(<%= link_to_revision(page, page.revisions.length, text='diff', (<%= link_to_revision(page, page.revisions.length, text='diff',
mode='diff') %>) mode='diff') %>)
(<%= link_to_history(page, text='history') %>) (<%= link_to_history(page, text='history') %>)
</span>
<%- end -%> <%- end -%>
<div class="byline" style="margin-bottom: 0px"> <div class="byline" style="margin-bottom: 0px">
by <%= link_to_page(page.author) %> by <%= link_to_page(page.author) %>