Created
June 12, 2012 10:50
-
-
Save sangyye/2916860 to your computer and use it in GitHub Desktop.
Atom to rss converter with ruby and sinatra
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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