Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Flickr plugin to Jekyll (blog-aware, static site generator)
---
layout: post
title: A blog post with photos from flickr
flickr:
- http://www.flickr.com/photos/himynameisjonas/6167152072
- http://www.flickr.com/photos/himynameisjonas/6167152448
- http://www.flickr.com/photos/himynameisjonas/6167153574
---
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
require 'liquid'
require 'fleakr'
Fleakr.api_key = "XXX"
Fleakr.shared_secret = "YYY"
Fleakr.auth_token = "ZZZ"
CACHED_IMAGES = {}
module Flickr
def flickr_image(url)
"<img alt='#{image_object(url).title}' src='#{image_object(url).large.url}'>"
end
def flickr_medium_image(url)
"<img alt='#{image_object(url).title}' src='#{image_object(url).medium.url}'>"
end
private
def image_object(url)
CACHED_IMAGES[url] ||= Fleakr.resource_from_url(url)
end
end
Liquid::Template.register_filter(Flickr)
source :rubygems
gem 'RedCloth'
gem 'jekyll'
gem 'fleakr'
<article>
<h1>{{ post.title }}</h1>
{% for flickr_url in post.flickr %}
<a href="{{ flickr_url }}">{{ flickr_url | flickr_image }}</a>
{% endfor %}
{{ post.content }}
<footer>
{{ post.date || date:"%Y-%m-%d" }}</br>
</footer>
</article>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment