Skip to content

Instantly share code, notes, and snippets.

@facerip
Created December 2, 2013 19:41
Show Gist options
  • Save facerip/7756469 to your computer and use it in GitHub Desktop.
Save facerip/7756469 to your computer and use it in GitHub Desktop.
Simple RSS Feed in Sinatra
require 'sinatra'
require 'data_mapper'
require 'builder'
class ExitStatusOne < Sinatra::Base
get '/rss' do
@post = Post.all :order => :id.desc
builder :rss
end
end
xml.instruct! :xml, :version => '1.0'
xml.rss :version => "2.0" do
xml.channel do
xml.title "Title of Feed"
xml.description "Description of Site"
xml.link "web-site-url.com"
@post.each do |feed|
xml.item do
xml.title feed.title
xml.link "web-site-url.com/path/to/rss/feed/#{feed.id}"
xml.description feed.summary
xml.pubDate feed.created_at
xml.guid "web-site-url.com/path/to/rss/feed/#{feed.id}"
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment