Another Quick Note: Shared Items
On the right, below the twitter stream, there’s now my five most recently shared items from my Google Reader stream. Building this was really easy with nokogiri.
In application_controller.rb, I have the following before_filter:
def load_feed @feed_url = 'http://www.google.com/reader/public/atom/user%2F08744346161133327961%2Fstate%2Fcom.google%2Fbroadcast' @feed = Nokogiri::XML open(@feed_url) end
Which allows working with the @feed document later:
- @feed.css('entry').first(5).each do |entry|
%li
#title= link_to entry.css('title').first.content, entry.css('link[rel=alternate]').first['href']
#source== (via #{link_to entry.css('source title').first.content, entry.css('source link').first['href']})I’m not sure if this is particularly efficient use of nokogiri, but the time spent parsing is likely vanishingly small compared to the time loading the feed from Google.
All told, a nice addition to this site and a convenient excuse / practice problem for XML parsing.