data/strelka-cms/apps/content-feeds in strelka-cms-0.0.1.pre.15 vs data/strelka-cms/apps/content-feeds in strelka-cms-0.0.1.pre.19

- old
+ new

@@ -16,15 +16,19 @@ require 'strelka/cms/page' # The Feed applet -- generate RSS and Atom feeds for various things. class Strelka::CMS::ContentFeeds < Strelka::App - extend Configurability, + extend Loggability, + Configurability, Strelka::MethodUtilities include UUIDTools + # Loggability API -- log to Strelka::CMS's logger + log_to :strelka_cms + # Configurability API -- configure this app with the 'feeds' section of the # config. config_key :content_feeds @@ -85,10 +89,11 @@ plugin :routing get 'rss' do |req| feedpath = req.app_path[ %r{/rss/(.*)}, 1 ] newest_pages = self.find_newest_pages( feedpath, req ) + newest_page = newest_pages.first baseuri = req.uri baseuri.path = '' # Generate the feed out of the newest 10 pages @@ -110,11 +115,11 @@ end res = req.response # Set the cache header and set the mimetype - res.headers.last_modified = newest_pages.first.date.httpdate + res.headers.last_modified = newest_page.date.httpdate res.content_type = 'application/rss+xml' res.body = feed.to_s return res end @@ -134,10 +139,10 @@ feed.links << Atom::Link.new( :href => baseuri ) feed.updated = newest_page.date feed.authors << Atom::Person.new( :name => 'Michael Granger' ) feed.id = @site_uuid.to_uri - newest_pages.each do |page| + newest_pages.sort_by {|page| page.modified }.reverse.each do |page| 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