From 47944aeae214f2cf9eaa7850fb76ea46287bf028 Mon Sep 17 00:00:00 2001 From: hukl Date: Thu, 10 Sep 2009 16:38:50 +0200 Subject: more rss feed enhancements --- app/controllers/rss_controller.rb | 1 + app/helpers/link_helper.rb | 9 +++++++++ app/views/rss/updates.xml.builder | 11 +++++------ 3 files changed, 15 insertions(+), 6 deletions(-) (limited to 'app') diff --git a/app/controllers/rss_controller.rb b/app/controllers/rss_controller.rb index d2540d0..4c2a2e8 100644 --- a/app/controllers/rss_controller.rb +++ b/app/controllers/rss_controller.rb @@ -1,6 +1,7 @@ class RssController < ApplicationController def updates + @host = request.protocol + request.host_with_port @items = Page.heads.find_tagged_with( "update", diff --git a/app/helpers/link_helper.rb b/app/helpers/link_helper.rb index b40aa4b..2d31230 100644 --- a/app/helpers/link_helper.rb +++ b/app/helpers/link_helper.rb @@ -1,5 +1,14 @@ module LinkHelper + def content_path_helper path_array + url_for( + :controller => :content, + :action => :render_page, + :locale => params[:locale] || I18n.locale, + :page_path => path_array + ) + end + def link_to_path title, path, html_options = {} if params[:page_path] active = (params[:page_path].join("/") == path.sub(/^\//, "")) diff --git a/app/views/rss/updates.xml.builder b/app/views/rss/updates.xml.builder index 8d873c0..57a0f42 100644 --- a/app/views/rss/updates.xml.builder +++ b/app/views/rss/updates.xml.builder @@ -1,8 +1,9 @@ xml.instruct! -xml.feed(:xmlns => "http://www.w3.org/2005/Atom") do + +xml.feed(:xmlns => "http://www.w3.org/2005/Atom", "xml:base" => @host) do xml.title("Chaos Computer Club Updates") xml.link(:href => "http://www.ccc.de/") - xml.link(:rel => "self", :href => "/updates.xml") + xml.link(:rel => "self", :href => "/rss/updates.xml") xml.updated(@items.first.published_at.xmlschema) xml.author do xml.name("Chaos Computer Club e.V.") @@ -12,13 +13,11 @@ xml.feed(:xmlns => "http://www.w3.org/2005/Atom") do @items.each do |item| xml.entry do xml.title(item.title) - port = (request.port != 80) ? port = ":#{request.port}" : "" xml.link( - :href => "#{request.protocol}#{request.host}#{port}/#{I18n.locale.to_s}" \ - "#{item.public_link}", + :href => content_path_helper(item.node.unique_path), :rel => "alternate" ) - xml.id(request.protocol + request.host + port + item.public_link) + xml.id(content_path_helper(item.node.unique_path)) xml.updated(item.updated_at.xmlschema) xml.content(:type => "xhtml") do xml.div(item.body, :xmlns => "http://www.w3.org/1999/xhtml") -- cgit v1.3