Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
def delicious_links(limit ="20", aclass="grey") begin unless read_fragment(:action => 'delicious_links') logger.info "Getting new delicious_links" require "open-uri" require 'json' @delicious_links = "" link = "http://del.icio.us/feeds/json/YOUR_USERNAME_HERE?raw=true&count="+limit @jsonObject = "" open(link) {|f| f.each_line {|line| @jsonObject += line } } @urls = parse(@jsonObject) for i in 0...@urls.length @url_obj = @urls.fetch(i) url ="" title ="" tags ="" @url_obj.each {|key, value| url = value if key == "u" title = value if key == "d" tags = value if key == "t" } @delicious_links += "<div class=\"blogSideBarLink\">" + "<a href= \""+url+"\" target=\"blank_\" class=\""+aclass+"\">"+ title+"</a></div>" end end rescue @delicious_links = "Not available @ this time" end logger.info "delicious_links finished" render_without_layout end
This paste will be private.
From the Design Piracy series on my blog: