Fixed caching of RSS feeds; changed from caches_page to caches_action to make authentication and other filters work

This commit is contained in:
Alexey Verkhovsky 2005-09-12 01:12:00 +00:00
parent cc99790a4a
commit 4c14f07100
6 changed files with 38 additions and 33 deletions

View file

@ -2,7 +2,7 @@
# Likewise will all the methods added be available for all controllers.
class ApplicationController < ActionController::Base
before_filter :set_utf8_http_header, :connect_to_model, :setup_url_generator
before_filter :connect_to_model, :setup_url_generator, :set_content_type_header
after_filter :remember_location, :teardown_url_generator
observer :page_observer
@ -144,8 +144,12 @@ class ApplicationController < ActionController::Base
end
end
def set_utf8_http_header
@response.headers['Content-Type'] = 'text/html; charset=UTF-8'
def set_content_type_header
if %w(rss_with_content rss_with_headlines).include?(action_name)
@response.headers['Content-Type'] = 'text/xml; charset=UTF-8'
else
@response.headers['Content-Type'] = 'text/html; charset=UTF-8'
end
end
def setup_url_generator

View file

@ -16,9 +16,12 @@ class RevisionSweeper < ActionController::Caching::Sweeper
private
def expire_caches(page)
expire_page :controller => 'wiki', :web => page.web.address,
web = page.web
expire_action :controller => 'wiki', :web => 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)
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)
end
end

View file

@ -6,7 +6,7 @@ require 'zip/zip'
class WikiController < ApplicationController
# TODO implement cache sweeping
caches_page :show, :published, :authors, :recently_revised, :list, :rss_with_content, :rss_with_headlines
caches_action :show, :published, :authors, :recently_revised, :list
cache_sweeper :revision_sweeper
layout 'default', :except => [:rss_feed, :rss_with_content, :rss_with_headlines, :tex, :export_tex, :export_html]
@ -330,10 +330,9 @@ class WikiController < ApplicationController
end
@hide_description = hide_description
@response.headers['Content-Type'] = 'text/xml'
@link_action = @web.password ? 'published' : 'show'
render 'wiki/rss_feed'
render :action => 'rss_feed'
end
def render_tex_web
@ -346,7 +345,7 @@ class WikiController < ApplicationController
def render_to_string(template_name, with_layout = false)
add_variables_to_assigns
self.assigns['content_for_layout'] = @template.render_file(template_name)
if with_layout
if with_layout
@template.render_file('layouts/default')
else
self.assigns['content_for_layout']