From 713f8f76e2ae1635bb938de6d8c74587d842790f Mon Sep 17 00:00:00 2001 From: hukl Date: Sat, 14 Nov 2009 13:51:27 +0100 Subject: Resolved issue of changing rss feed ids when changing the slugs of nodes Closes #35 --- app/models/node.rb | 8 ++++++++ app/views/rss/updates.xml.builder | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/models/node.rb b/app/models/node.rb index 9bfea52..7e64fdd 100644 --- a/app/models/node.rb +++ b/app/models/node.rb @@ -165,6 +165,14 @@ class Node < ActiveRecord::Base head_id end + # Returns immutable node id for all new nodes so that the atom feed entry ids + # stay the same eventhough the slug or positions changes. + # Can be removed after a year or so ;) + def feed_id + new_id_format_date = "2009-11-14".to_time + self.created_at < new_id_format_date ? unique_path : id + end + protected def lock_for! current_user self.lock_owner = current_user diff --git a/app/views/rss/updates.xml.builder b/app/views/rss/updates.xml.builder index 451e724..cc9c859 100644 --- a/app/views/rss/updates.xml.builder +++ b/app/views/rss/updates.xml.builder @@ -14,11 +14,11 @@ xml.feed(:xmlns => "http://www.w3.org/2005/Atom", "xml:base" => @host) do xml.entry do xml.title(item.title) xml.link( - :href => "#{@host}/de/#{item.node.unique_name}", + :href => content_url(:page_path => item.node.unique_path), :rel => "alternate", :type => "text/html" ) - xml.id("#{@host}/de/#{item.node.unique_name}") + xml.id(content_url(:page_path => item.node.feed_id)) xml.updated(item.published_at.xmlschema) xml.content(:type => "xhtml") do xml.div(item.body, :xmlns => "http://www.w3.org/1999/xhtml") -- cgit v1.3