diff --git a/app/controllers/application.rb b/app/controllers/application.rb index 05fb89ce..a4133850 100644 --- a/app/controllers/application.rb +++ b/app/controllers/application.rb @@ -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 diff --git a/app/controllers/revision_sweeper.rb b/app/controllers/revision_sweeper.rb index 21421c7b..1ab4676b 100644 --- a/app/controllers/revision_sweeper.rb +++ b/app/controllers/revision_sweeper.rb @@ -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 diff --git a/app/controllers/wiki_controller.rb b/app/controllers/wiki_controller.rb index bd66c960..fdd83d21 100644 --- a/app/controllers/wiki_controller.rb +++ b/app/controllers/wiki_controller.rb @@ -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'] diff --git a/app/views/wiki/rss_feed.rhtml b/app/views/wiki/rss_feed.rhtml deleted file mode 100644 index 47815c49..00000000 --- a/app/views/wiki/rss_feed.rhtml +++ /dev/null @@ -1,22 +0,0 @@ - - - - <%= @web.name %> - <%= url_for :only_path => false, :web => @web_name, :action => @link_action, :id => 'HomePage' %> - An Instiki wiki - en-us - 40 - <% for page in @pages_by_revision %> - - <%= h page.plain_name %> - <% unless @hide_description %> - <%= h rendered_content(page) %> - <% end %> - <%= page.revised_at.getgm.strftime "%a, %d %b %Y %H:%M:%S Z" %> - <%= url_for :only_path => false, :web => @web_name, :action => @link_action, :id => page.name %> - <%= url_for :only_path => false, :web => @web_name, :action => @link_action, :id => page.name %> - <%= WikiWords.separate(page.author) %> - - <% end %> - - diff --git a/app/views/wiki/rss_feed.rxml b/app/views/wiki/rss_feed.rxml new file mode 100644 index 00000000..4b52f7d2 --- /dev/null +++ b/app/views/wiki/rss_feed.rxml @@ -0,0 +1,21 @@ +xml.rss('version' => '2.0') do + xml.channel do + xml.title(@web.name) + xml.link(url_for(:only_path => false, :web => @web_name, :action => @link_action, :id => 'HomePage')) + xml.description('An Instiki wiki') + xml.language('en-us') + xml.ttl('40') + + for page in @pages_by_revision + xml.item do + xml.title(page.plain_name) + unless @hide_description + xml.description(rendered_content(page)) + end + xml.pubDate(page.revised_at.getgm.strftime('%a, %d %b %Y %H:%M:%S Z')) + xml.guid(url_for(:only_path => false, :web => @web_name, :action => @link_action, :id => page.name)) + xml.link(url_for(:only_path => false, :web => @web_name, :action => @link_action, :id => page.name)) + end + end + end +end diff --git a/test/functional/wiki_controller_test.rb b/test/functional/wiki_controller_test.rb index 54c541b3..8be34cb4 100755 --- a/test/functional/wiki_controller_test.rb +++ b/test/functional/wiki_controller_test.rb @@ -485,7 +485,7 @@ class WikiControllerTest < Test::Unit::TestCase end def test_rss_title_with_ampersand - # was ticket:143 + # was ticket:143 @wiki.write_page('wiki1', 'Title&With&Ampersands', 'About spaces', 1.hour.ago, Author.new('NitPicker', '127.0.0.3'), test_renderer)