Skip to content

Instantly share code, notes, and snippets.

@jmcveigh
Created January 24, 2013 14:40
Show Gist options
  • Save jmcveigh/4622427 to your computer and use it in GitHub Desktop.
Save jmcveigh/4622427 to your computer and use it in GitHub Desktop.
This is an example of a sinatra request.
get '/news/nin' do
rss_feed = "http://feeds.nin.com/ninNews"
rss_content = ""
open(rss_feed) do |fh|
rss_content = fh.read
end
rss = RSS::Parser.parse(rss_content,false)
html = '<div id="content" data-stack="ruby" data-appname="' + settings.appname + '">Metallicide: News - Nine Inch Nails<br>'
html += "(#{rss.items.size} items<br>"
rss.items.each do |item|
html += "<dl><dt><a href='#{item.link}' title='#{item.title}'>#{item.date} : #{item.title}</a></dt><dd><span>#{item.description}</span></dd></dl><br style='clear:both;'>"
end
html += '</div>'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment