Flickr extension to Sphinx

I use Sphinx to generate web sites like this one you are reading now. The problem is, to get everything to work correctly there shouldn’t be any hardcoded stuff in the source files. And the second problem is that I wanted the photostream to update automatically in the page when I add new photos to flickr.

To get both requirements I needed to create extension to Sphinx which generates needed javascript to show the photos.

User photostream

This shows 10 latest photos from users photostream:

.. flickr-user:: 22188092%40N00

The argument is user id whose photostream you want to show.


And this one shows photos in one set:

.. flickr-set:: 72157622474093596
  :user: derega

The argument is the photoset id. And we also need to give the user id as parameter named ‘user’. The user id can be in either formats. As you can see here we are using the human-readable version and in the first one we used the numerical version.

One photo

And last directive can be used to show one photo:

.. flickr-image:: derega 4864901105

This is little bit tricky. It could be optimized more as now it needs user id and photo id as arguments (in that order). And the actual image url which is shown on the page as parameter named ‘image’.

Here is the code

The code for the extension can be found in bitbucket