2005-09-11 20:02:56 +02:00
|
|
|
class RevisionSweeper < ActionController::Caching::Sweeper
|
|
|
|
observe Revision, Page
|
|
|
|
|
|
|
|
def after_save(record)
|
|
|
|
if record.is_a?(Revision)
|
|
|
|
expire_caches(record.page)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def after_delete(record)
|
|
|
|
if record.is_a?(Page)
|
|
|
|
expire_caches(record)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def expire_caches(page)
|
2005-09-12 03:12:00 +02:00
|
|
|
web = page.web
|
|
|
|
expire_action :controller => 'wiki', :web => web.address,
|
2005-09-11 20:02:56 +02:00
|
|
|
:action => %w(show published), :id => page.name
|
2005-09-12 03:12:00 +02:00
|
|
|
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)
|
2005-09-11 20:02:56 +02:00
|
|
|
end
|
|
|
|
end
|