So, one of the things that I've always wanted from Flickr (but never
got) was an RSS feed for sets, rather than images. In this vein, I
decided to create a plugin to display Flickr sets:
http://cubanlinks.org/svn/mephisto/plugins/flickrsets
In order to go easy on the Flickr servers (and my users) I had to
implement a caching solution. I decided to make this into a plugin also
(or should it have been a gem? can anyone explain when to use one or
the other?)
http://cubanlinks.org/svn/mephisto/plugins/requestcache/
FlickrSets piggy-backs on the flickr.rb library that comes with
Mephisto (vendor/plugins/filtered_column_flickr_macro/lib/flickr.rb)
and this file must be hacked to make use of the RequestCache. Here's
the diff:
Index: vendor/plugins/filtered_column_flickr_macro/lib/flickr.rb
===================================================================
--- vendor/plugins/filtered_column_flickr_macro/lib/flickr.rb
(revision 2578)
+++ vendor/plugins/filtered_column_flickr_macro/lib/flickr.rb
(working copy)
@@ -47,6 +47,7 @@
require 'cgi'
require 'net/http'
require 'xmlsimple' unless Object.const_defined?(:XmlSimple)
+require 'requestcache'
# Flickr client class. Requires an API key, and optionally takes an
email and password for authentication
class Flickr
@@ -58,6 +59,7 @@
@api_key = api_key
@host = 'http://flickr.com'
@api = '/services/rest'
+ @rc = RequestCache.new('/home/crabasa/var/tmp/requestcache')
login(email, password) if email and password
end
@@ -79,7 +81,8 @@
# Does an HTTP GET on a given URL and returns the response body
def http_get(url)
- Net::HTTP.get_response(URI.parse(url)).body.to_s
+ #Net::HTTP.get_response(URI.parse(url)).body.to_s
+ @rc.getResponse(url)
end
===================================================================
You'll find usage info in the source of the plugins. You'll need to
edit the diff above to store the response files in the directory of
your choice.
Hope someone finds this stuff useful!
--Carter Rabasa
http://cubanlinks.org