diff options
| author | hukl <contact@smyck.org> | 2009-09-10 16:01:41 +0200 |
|---|---|---|
| committer | hukl <contact@smyck.org> | 2009-09-10 16:01:41 +0200 |
| commit | d7ec763c7ce069824aad24a6bd0d845ee74ed10d (patch) | |
| tree | 5def39dc36d468d190a072db2a089b7e8f12bd6a /app | |
| parent | 304ba222fb85178763746ded4c1d252124c9ddfd (diff) | |
added public rss controller plus template to render the latest 20 updates into a neat little atom feed
Diffstat (limited to 'app')
| -rw-r--r-- | app/controllers/rss_controller.rb | 16 | ||||
| -rw-r--r-- | app/helpers/rss_helper.rb | 2 | ||||
| -rw-r--r-- | app/views/rss/updates.xml.builder | 23 |
3 files changed, 41 insertions, 0 deletions
diff --git a/app/controllers/rss_controller.rb b/app/controllers/rss_controller.rb new file mode 100644 index 0000000..d2540d0 --- /dev/null +++ b/app/controllers/rss_controller.rb | |||
| @@ -0,0 +1,16 @@ | |||
| 1 | class RssController < ApplicationController | ||
| 2 | |||
| 3 | def updates | ||
| 4 | |||
| 5 | @items = Page.heads.find_tagged_with( | ||
| 6 | "update", | ||
| 7 | :order => "published_at DESC", | ||
| 8 | :limit => 20 | ||
| 9 | ) | ||
| 10 | |||
| 11 | respond_to do |format| | ||
| 12 | format.xml {} | ||
| 13 | end | ||
| 14 | end | ||
| 15 | |||
| 16 | end | ||
diff --git a/app/helpers/rss_helper.rb b/app/helpers/rss_helper.rb new file mode 100644 index 0000000..9031e55 --- /dev/null +++ b/app/helpers/rss_helper.rb | |||
| @@ -0,0 +1,2 @@ | |||
| 1 | module RssHelper | ||
| 2 | end | ||
diff --git a/app/views/rss/updates.xml.builder b/app/views/rss/updates.xml.builder new file mode 100644 index 0000000..541ad4e --- /dev/null +++ b/app/views/rss/updates.xml.builder | |||
| @@ -0,0 +1,23 @@ | |||
| 1 | xml.instruct! | ||
| 2 | xml.feed(:xmlns => "http://www.w3.org/2005/Atom") do | ||
| 3 | xml.title("Chaos Computer Club Updates") | ||
| 4 | xml.link(:href => "http://www.ccc.de/") | ||
| 5 | xml.updated(@items.first.published_at) | ||
| 6 | xml.author("Chaos Computer Club e.V.") | ||
| 7 | xml.id("http://www.ccc.de/") | ||
| 8 | |||
| 9 | @items.each do |item| | ||
| 10 | xml.entry do | ||
| 11 | xml.title(item.title) | ||
| 12 | port = (request.port != 80) ? port = ":#{request.port}" : "" | ||
| 13 | xml.link(request.protocol + request.host + port + item.public_link) | ||
| 14 | xml.id(request.protocol + request.host + port + item.public_link) | ||
| 15 | xml.updated(item.updated_at) | ||
| 16 | xml.content(:type => "xhtml") do | ||
| 17 | xml.div(item.body, :xmlns => "http://www.w3.org/1999/xhtml") | ||
| 18 | end | ||
| 19 | end | ||
| 20 | |||
| 21 | end | ||
| 22 | |||
| 23 | end \ No newline at end of file | ||
