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 plugin/thoth_delicious.rb, line 66 def recent_bookmarks(username, options = {}) @cache ||= {} options = {:count => 5}.merge(options) request = "#{FEED_URL}/#{::CGI.escape(username)}" + (options[:tags] ? '/' + ::CGI.escape(options[:tags].join(' ')) : '') + "?raw&count=#{options[:count]}" if cached = @cache[request] return cached[:value] if cached[:expires] > Time.now end r = [] Timeout.timeout(Config.delicious.request_timeout, StandardError) do r = JSON.parse(open(request).read) end # Parse the response into a more friendly format. data = [] r.each do |item| data << { :url => item['u'], :desc => item['d'], :note => item['n'] ? item['n'] : '', :tags => item['t'] ? item['t'] : [] } end @cache[request] = { :expires => Time.now + Config.delicious.cache_ttl, :value => data } return data rescue => e return [] end
Generated with the Darkfish Rdoc Generator 2.