Module: Thoth::Plugin::Flickr
- Defined in:
- lib/thoth/plugin/thoth_flickr.rb
Overview
Flickr plugin for Thoth.
Class Method Summary collapse
-
.recent_photos(username, limit = 4) ⇒ Object
Gets recent Flickr photos (up to limit) for the specified username.
Class Method Details
.recent_photos(username, limit = 4) ⇒ Object
Gets recent Flickr photos (up to limit) for the specified username. The return value of this method is cached to improve performance and to avoid abusing the Flickr API.
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/thoth/plugin/thoth_flickr.rb', line 60 def recent_photos(username, limit = 4) cache = Ramaze::Cache.plugin key = "recent_photos_#{username}_#{limit}" if value = cache[key] return value end @flickr ||= Net::Flickr.new(Config.flickr['api_key']) begin Timeout.timeout(Config.flickr['request_timeout'].to_i, StandardError) do value = cache.store(key, @flickr.people.find_by_username(username). photos(:per_page => limit), :ttl => Config.flickr['cache_ttl']) end rescue => e Ramaze::Log.error "Thoth::Plugin::Flickr: #{e.}" return [] else value end end |