Skip to content

Instantly share code, notes, and snippets.

@chrislloyd
Forked from rhysforyou/rssreader.rb
Created November 5, 2010 12:15
Show Gist options
  • Save chrislloyd/664049 to your computer and use it in GitHub Desktop.
Save chrislloyd/664049 to your computer and use it in GitHub Desktop.
<!doctype html>
<html>
<head>
<title>RSS Feed Viewer</title>
</head>
<body>
<h2>Hi there!</h2>
<p><%= open_rss.channel.title %></p>
</body>
</html>
require 'sinatra'
require 'erb'
require 'rss/1.0'
require 'rss/2.0'
require 'open-uri'
helpers do
def open_rss
source = "http://daringfireball.net/feeds/articles"
content = ""
open(source) do |s| content = s.read end
rss = RSS::Parser.parse(content, false)
return rss
end
end
get '/feed' do
erb :index
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment