Del.icio.us plugin for Thoth.
Gets recent del.icio.us bookmarks for the specified username. The return value of this method is cached to improve performance and to avoid pounding del.icio.us with excess traffic.
Available options:
Number of bookmarks to return (default is 5)
Array of tags to filter by. Only bookmarks with the specified tags will be returned.
# File lib/thoth/plugin/thoth_delicious.rb, line 66 def recent_bookmarks(username, options = {}) cache = Ramaze::Cache.value_cache options = {:count => 5}.merge(options) request = "#{FEED_URL}/#{::CGI.escape(username)}" << (options[:tags] ? '/' << ::CGI.escape(options[:tags].join(' ')) : '') << "?raw&count=#{options[:count]}" if value = cache[request] return value end response = [] Timeout.timeout(Config.delicious.request_timeout, StandardError) do response = JSON.parse(open(request).read) end # Parse the response into a more friendly format. data = [] response.each do |item| data << { :url => item['u'], :desc => item['d'], :note => item['n'] ? item['n'] : '', :tags => item['t'] ? item['t'] : [] } end return cache.store(request, data, :ttl => Config.delicious.cache_ttl) rescue => e return [] end
Generated with the Darkfish Rdoc Generator 2.