Skip to content

Instantly share code, notes, and snippets.

@johnivanoff
Created December 10, 2012 00:30
Show Gist options
  • Select an option

  • Save johnivanoff/4247669 to your computer and use it in GitHub Desktop.

Select an option

Save johnivanoff/4247669 to your computer and use it in GitHub Desktop.
require 'sinatra'
require 'nokogiri'
def parse feed
doc = Nokogiri::XML feed
doc.search('item').map do |doc_item|
item = {}
item[:link] = doc_item.at('link').text
item[:thumbnail] = doc_item.at('media|thumbnail').attr('url')
item[:title] = doc_item.at('title').text
item
end
end
get '/' do
erb :index
end
__END__
@@index
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="user-scalable=yes, width=device-width" />
<title>Lovely Sunsets</title>
</head>
<body>
<h1>Feed Aggregator</h1>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment