summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhukl <contact@smyck.org>2009-11-14 13:51:27 +0100
committerhukl <contact@smyck.org>2009-11-14 13:51:27 +0100
commit713f8f76e2ae1635bb938de6d8c74587d842790f (patch)
treea66a3418004ef511fc6987fe9852a2dd34c3835e
parentf671d3c3976c1b641fe2274668ecca82bf9b16cc (diff)
Resolved issue of changing rss feed ids when changing the slugs of nodes
Closes #35
-rw-r--r--app/models/node.rb8
-rw-r--r--app/views/rss/updates.xml.builder4
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
165 head_id 165 head_id
166 end 166 end
167 167
168 # Returns immutable node id for all new nodes so that the atom feed entry ids
169 # stay the same eventhough the slug or positions changes.
170 # Can be removed after a year or so ;)
171 def feed_id
172 new_id_format_date = "2009-11-14".to_time
173 self.created_at < new_id_format_date ? unique_path : id
174 end
175
168 protected 176 protected
169 def lock_for! current_user 177 def lock_for! current_user
170 self.lock_owner = current_user 178 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
14 xml.entry do 14 xml.entry do
15 xml.title(item.title) 15 xml.title(item.title)
16 xml.link( 16 xml.link(
17 :href => "#{@host}/de/#{item.node.unique_name}", 17 :href => content_url(:page_path => item.node.unique_path),
18 :rel => "alternate", 18 :rel => "alternate",
19 :type => "text/html" 19 :type => "text/html"
20 ) 20 )
21 xml.id("#{@host}/de/#{item.node.unique_name}") 21 xml.id(content_url(:page_path => item.node.feed_id))
22 xml.updated(item.published_at.xmlschema) 22 xml.updated(item.published_at.xmlschema)
23 xml.content(:type => "xhtml") do 23 xml.content(:type => "xhtml") do
24 xml.div(item.body, :xmlns => "http://www.w3.org/1999/xhtml") 24 xml.div(item.body, :xmlns => "http://www.w3.org/1999/xhtml")