Skip to content

Commit

Permalink
Added an example RSS generation.
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Schneider <chris@christopher-schneider.com>
  • Loading branch information
csiszarattila authored and cschneid committed Dec 28, 2008
1 parent 37bbb48 commit 45fc989
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions book/Views.markdown 100755 → 100644
Expand Up @@ -49,6 +49,32 @@ This will render the xml inline, directly from the handler.
#### Atom Feed

#### RSS Feed
Assume that your site url is http://liftoff.msfc.nasa.gov/.

get '/rss.xml' do
builder do |xml|
xml.instruct! :xml, :version => '1.0'
xml.rss :version => "2.0" do
xml.channel do
xml.title "Liftoff News"
xml.description "Liftoff to Space Exploration."
xml.link "http://liftoff.msfc.nasa.gov/"
@posts.each do |post|
xml.item do
xml.title post.title
xml.link "http://liftoff.msfc.nasa.gov/posts/#{post.id}"
xml.description post.body
xml.pubDate Time.parse(post.created_at.to_s).rfc822()
xml.guid "http://liftoff.msfc.nasa.gov/posts/#{post.id}"
end
end
end
end
end
end

This will render the rss inline, directly from the handler.

Layouts
-------
Expand Down

0 comments on commit 45fc989

Please sign in to comment.