Caching and sweeping pages. RSS feeds behave funny
This commit is contained in:
parent
c4f593151e
commit
cc99790a4a
24
app/controllers/revision_sweeper.rb
Normal file
24
app/controllers/revision_sweeper.rb
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
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)
|
||||||
|
expire_page :controller => 'wiki', :web => page.web.address,
|
||||||
|
:action => %w(show published), :id => page.name
|
||||||
|
expire_page :controller => 'wiki', :web => page.web.address,
|
||||||
|
:action => %w(authors recently_revised list rss_with_content rss_with_headlines)
|
||||||
|
end
|
||||||
|
end
|
|
@ -6,7 +6,8 @@ require 'zip/zip'
|
||||||
class WikiController < ApplicationController
|
class WikiController < ApplicationController
|
||||||
|
|
||||||
# TODO implement cache sweeping
|
# TODO implement cache sweeping
|
||||||
caches_page :show, :published
|
caches_page :show, :published, :authors, :recently_revised, :list, :rss_with_content, :rss_with_headlines
|
||||||
|
cache_sweeper :revision_sweeper
|
||||||
|
|
||||||
layout 'default', :except => [:rss_feed, :rss_with_content, :rss_with_headlines, :tex, :export_tex, :export_html]
|
layout 'default', :except => [:rss_feed, :rss_with_content, :rss_with_headlines, :tex, :export_tex, :export_html]
|
||||||
|
|
||||||
|
@ -194,6 +195,7 @@ class WikiController < ApplicationController
|
||||||
redirect_to_page @page_name
|
redirect_to_page @page_name
|
||||||
rescue => e
|
rescue => e
|
||||||
flash[:error] = e
|
flash[:error] = e
|
||||||
|
logger.error e
|
||||||
flash[:content] = @params['content']
|
flash[:content] = @params['content']
|
||||||
if @page
|
if @page
|
||||||
@page.unlock
|
@page.unlock
|
||||||
|
|
Loading…
Reference in a new issue