Skip to content

Instantly share code, notes, and snippets.

@sangyye
Created June 12, 2012 10:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sangyye/2916860 to your computer and use it in GitHub Desktop.
Save sangyye/2916860 to your computer and use it in GitHub Desktop.
Atom to rss converter with ruby and sinatra
require 'sinatra'
require 'simple-rss'
require 'builder'
require 'open-uri'
get '/*' do
rss = SimpleRSS.parse open('http://' + params[:splat][0].to_s)
builder do |xml|
xml.instruct! :xml, :version => '1.0'
xml.rss :version => "2.0" do
xml.channel do
xml.title rss.channel.title
#xml.description
xml.link rss.channel.link
rss.channel.entries.each do |post|
xml.item do
xml.title post.title
xml.link post.link
xml.description post.content
xml.pubDate Time.parse(post.updated.to_s).rfc822()
xml.guid post.link
end
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment