The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
Building a del.ico.us and flickr sidebar in 5 minutes

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Matthias Georgi

Posts: 54
Nickname: georgi
Registered: Apr, 2007

Matthias Georgi is a Ruby on Rails freelancer.
Building a del.ico.us and flickr sidebar in 5 minutes Posted: Apr 8, 2007 5:43 AM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Matthias Georgi.
Original Post: Building a del.ico.us and flickr sidebar in 5 minutes
Feed Title: Matthias Georgi
Feed URL: http://feeds.feedburner.com/matthias-georgi?format=xml
Feed Description: Webdev, Gamedev and Interaction Design.
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Matthias Georgi
Latest Posts From Matthias Georgi

Advertisement
You need a del.icio.us sidebar which shows recent bookmarks or one of these nice flickr badges? This is really is easy as the Typo weblog already includes an flickr and del.icio.us aggregator. Download the files delicous.rb and flickr.rb and drop them into your rails lib folder. Now add these two little helpers to your application_helper.rb:
require 'delicious'
require 'flickr'

def delicious(tag)
 Delicious.new("http://del.icio.us/rss/tag/#{tag}")
end

def flickr(tag)
 FlickrAggregation.new("http://api.flickr.com/services/feeds/photos_public.gne?tags=#{tag}&format=rss_200")
end
We are now able to fetch the feeds for our desired tags with a simple method call. Next step is to render a list of links for our sidebar. I use Markaby for rendering my Rails views. It is easy to type and has a clean syntax. So for rendering the del.icio.us sidebar, you need something like this:
ul {
 delicious(:ruby).items[0,10].each { |item|
   li { a(:href => item.link) { item.title } }
 }
}
This is pretty self-explanatory. We take the first ten items of the del.icio.us feed and for each item we output a list element containing a link to the item. The view for the flickr badge is similar:
ul {
 flickr(:ruby).pics[0,10].each { |pic|
   image_tag pic.square, :size => '48x48'
 }
}
We take the first ten items of the flickr feed and for each item we render an image tag which shows a square thumbnail of the size 48x48. Congratulations, you have just written a del.icio.us and flickr sidebar in 5 minutes using only 18 lines of code. Now you can spend the rest of the day pimping up your sidebar with all kinds of feeds using one of these plugins of the typo weblog.

Read: Building a del.ico.us and flickr sidebar in 5 minutes

Topic: What comes after "NG"? Previous Topic   Next Topic Topic: How To Use Rails With Rewritten URLs

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use