From ba221a5c15e6b2d818df6cf0a8d9c5c62906d213 Mon Sep 17 00:00:00 2001 From: hukl Date: Fri, 11 Sep 2009 22:32:25 +0200 Subject: first steps for recent changes rss feed --- app/controllers/rss_controller.rb | 28 +++++++++++++++++++++++++--- app/views/rss/recent_changes.xml.builder | 29 +++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 3 deletions(-) create mode 100644 app/views/rss/recent_changes.xml.builder diff --git a/app/controllers/rss_controller.rb b/app/controllers/rss_controller.rb index 4c2a2e8..e749449 100644 --- a/app/controllers/rss_controller.rb +++ b/app/controllers/rss_controller.rb @@ -1,8 +1,9 @@ class RssController < ApplicationController - def updates - @host = request.protocol + request.host_with_port - + before_filter :authenticate, :only => :recent_changes + before_filter :get_host + + def updates @items = Page.heads.find_tagged_with( "update", :order => "published_at DESC", @@ -14,4 +15,25 @@ class RssController < ApplicationController end end + def recent_changes + @items = Page.all( + :limit => 20, + :order => "updated_at desc", + :conditions => [ + "updated_at < ? AND updated_at > ?", Time.now, Time.now-14.days + ] + ) + end + + protected + def authenticate + authenticate_or_request_with_http_basic do |username, password| + username == "recent" && password == "d@t3N+kLAu-23" + end + end + + def get_host + @host = request.protocol + request.host_with_port + end + end diff --git a/app/views/rss/recent_changes.xml.builder b/app/views/rss/recent_changes.xml.builder new file mode 100644 index 0000000..390fbdf --- /dev/null +++ b/app/views/rss/recent_changes.xml.builder @@ -0,0 +1,29 @@ +xml.instruct! + +xml.feed(:xmlns => "http://www.w3.org/2005/Atom", "xml:base" => @host) do + xml.title("CCC.de Recent Change") + xml.link(:href => "http://www.ccc.de/") + 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.") + end + xml.id("http://www.ccc.de/") + + @items.each do |item| + xml.entry do + xml.title(item.title) + xml.link( + :href => content_path_helper(item.node.unique_path), + :rel => "alternate" + ) + xml.id(content_url_helper(item.node.unique_path)) + xml.updated(item.updated_at.xmlschema) + xml.content(:type => "text") do + xml.div("changed by #{item.user.login}") + end + end + + end + +end \ No newline at end of file -- cgit v1.3