Commits

Michael Granger committed ea1d6e8

Fix the feeds app.

- Update to reflect changes in the Page and PageCatalog classes.

  • Participants
  • Parent commits 066a603

Comments (0)

Files changed (2)

data/strelka-cms/apps/content-feeds

 			feed.items.do_sort       = true # sort items by date
 
 			newest_pages.each do |page|
+				entry_url = baseuri.dup
+				entry_url.path = '/' + File.join( feedpath, page.relative_html_path )
+
 				item = feed.items.new_item
 				item.title = page.title
-				item.link  = baseuri + page.relative_path.sub(/\.page$/, '.html')
+				item.link  = entry_url
 				item.date  = page.date
 			end
 		end
 		res = req.response
 
 		# Set the cache header and set the mimetype
-		res.headers.last_modified = newest_page.date.httpdate
+		res.headers.last_modified = newest_pages.first.date.httpdate
 		res.content_type = 'application/rss+xml'
 		res.body = feed.to_s
 
 	### Action: Return an ATOM feed for the pages under the path made up of +pathparts+.
 	get 'atom' do |req|
 		feedpath = req.app_path[ %r{/atom/(.*)}, 1 ]
-		newest_pages = self.find_newest_pages( req )
+		newest_pages = self.find_newest_pages( feedpath, req )
 		newest_page = newest_pages.first
 
 		baseuri = req.uri
 			feed.id      = @site_uuid.to_uri
 
 			newest_pages.each do |page|
-				entry_url = baseuri + page.relative_path.sub(/\.page$/, '.html')
+				entry_url = baseuri.dup
+				entry_url.path = '/' + File.join( feedpath, page.relative_html_path )
 
 				feed.entries << Atom::Entry.new do |entry|
 					entry.title   = page.title
-					entry.links   << Atom::Link.new( :href => entry_url )
-					entry.id      = UUID.sha1_create( UUID_URL_NAMESPACE, entry_url ).to_uri
+					entry.id      = UUID.sha1_create( UUID_URL_NAMESPACE, entry_url.to_s ).to_uri
 					entry.updated = page.date
 					entry.summary = page.summary
+
+					entry.links << Atom::Link.new( :href => entry_url )
 				end
 			end
 		end
 
 	### Find the newest pages for the path of the +request+ and return them.
 	def find_newest_pages( feedpath, req )
+		self.log.debug "Looking for newest pages in feed path: %p" % [ feedpath ]
 		finish_with HTTP::NOT_FOUND unless self.class.paths.include?( feedpath )
 		feedpath.untaint
 

lib/strelka/cms/page.rb

 			return self.created
 		end
 	end
+	alias_method :date, :modified
 
 
 	### Return a summary of the page.