Created
November 5, 2010 12:14
-
-
Save rhysforyou/664047 to your computer and use it in GitHub Desktop.
The base RSS reader program
This file contains hidden or 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
<!doctype html> | |
<html> | |
<head> | |
<title>RSS Feed Viewer</title> | |
</head> | |
<body> | |
<h2>Hi there!</h2> | |
<p><%= @rss.channel.title %></p> | |
</body> | |
</html> |
This file contains hidden or 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 '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 | |
@rss = open_rss | |
erb :index | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment