Created
January 11, 2009 04:31
-
-
Save jraines/45637 to your computer and use it in GitHub Desktop.
Feed summarizer
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
# All code in this gist is public domain and freely available for use and alteration without attribution | |
require 'rubygems' | |
require 'simple-rss' | |
require 'rss' | |
require 'open-uri' | |
feed = 'http://www.tweetlinkmonster.com/feed/jraines.atom' | |
rss = SimpleRSS.parse(open(feed)) | |
content = [] | |
10.times do |i| | |
item = rss.items[i] | |
content << { :link =>"<a href='#{item.link}'>#{item.title}</a>", | |
:date => "Published on: #{item.updated || item.pubDate}", # atom || rss | |
:description => "#{item.summary || item.description}", | |
:author => "#{item.author || "Link"}" } | |
end | |
destination = "output.xml" | |
new_feed = RSS::Maker.make("2.0") do |feed| | |
feed.channel.title = "Twitter links via TLM" | |
feed.channel.link = "http://jeremyraines.com" | |
feed.channel.description = "Links from Twits" | |
output = "" | |
content.each do |item| | |
output = output + "#{item[:author]}: #{item[:link]}<br /> \n\n #{item[:description]} \n\n<br /> #{item[:date]} \n\n <br /><br />" | |
end | |
item = feed.items.new_item | |
item.title = "Last 10 Feed Items" | |
item.date = Time.now | |
item.description = output | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment