diff options
| -rw-r--r-- | app/controllers/rss_controller.rb | 28 | ||||
| -rw-r--r-- | app/views/rss/recent_changes.xml.builder | 29 |
2 files changed, 54 insertions, 3 deletions
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 @@ | |||
| 1 | class RssController < ApplicationController | 1 | class RssController < ApplicationController |
| 2 | 2 | ||
| 3 | def updates | 3 | before_filter :authenticate, :only => :recent_changes |
| 4 | @host = request.protocol + request.host_with_port | 4 | before_filter :get_host |
| 5 | 5 | ||
| 6 | def updates | ||
| 6 | @items = Page.heads.find_tagged_with( | 7 | @items = Page.heads.find_tagged_with( |
| 7 | "update", | 8 | "update", |
| 8 | :order => "published_at DESC", | 9 | :order => "published_at DESC", |
| @@ -14,4 +15,25 @@ class RssController < ApplicationController | |||
| 14 | end | 15 | end |
| 15 | end | 16 | end |
| 16 | 17 | ||
| 18 | def recent_changes | ||
| 19 | @items = Page.all( | ||
| 20 | :limit => 20, | ||
| 21 | :order => "updated_at desc", | ||
| 22 | :conditions => [ | ||
| 23 | "updated_at < ? AND updated_at > ?", Time.now, Time.now-14.days | ||
| 24 | ] | ||
| 25 | ) | ||
| 26 | end | ||
| 27 | |||
| 28 | protected | ||
| 29 | def authenticate | ||
| 30 | authenticate_or_request_with_http_basic do |username, password| | ||
| 31 | username == "recent" && password == "d@t3N+kLAu-23" | ||
| 32 | end | ||
| 33 | end | ||
| 34 | |||
| 35 | def get_host | ||
| 36 | @host = request.protocol + request.host_with_port | ||
| 37 | end | ||
| 38 | |||
| 17 | end | 39 | 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 @@ | |||
| 1 | xml.instruct! | ||
| 2 | |||
| 3 | xml.feed(:xmlns => "http://www.w3.org/2005/Atom", "xml:base" => @host) do | ||
| 4 | xml.title("CCC.de Recent Change") | ||
| 5 | xml.link(:href => "http://www.ccc.de/") | ||
| 6 | xml.link(:rel => "self", :href => "/rss/updates.xml") | ||
| 7 | xml.updated(@items.first.published_at.xmlschema) | ||
| 8 | xml.author do | ||
| 9 | xml.name("Chaos Computer Club e.V.") | ||
| 10 | end | ||
| 11 | xml.id("http://www.ccc.de/") | ||
| 12 | |||
| 13 | @items.each do |item| | ||
| 14 | xml.entry do | ||
| 15 | xml.title(item.title) | ||
| 16 | xml.link( | ||
| 17 | :href => content_path_helper(item.node.unique_path), | ||
| 18 | :rel => "alternate" | ||
| 19 | ) | ||
| 20 | xml.id(content_url_helper(item.node.unique_path)) | ||
| 21 | xml.updated(item.updated_at.xmlschema) | ||
| 22 | xml.content(:type => "text") do | ||
| 23 | xml.div("changed by #{item.user.login}") | ||
| 24 | end | ||
| 25 | end | ||
| 26 | |||
| 27 | end | ||
| 28 | |||
| 29 | end \ No newline at end of file | ||
