nikhgupta / middleman-flickr

Import Photo/sets from Flickr in your Middleman website.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Middleman Flickr

middleman-flickr is an extension for the Middleman static site generator that adds some helper functions to allow embedding images from Flickr into your pages.

NOTE: Fetches a maximum of 500 photos in a set.

Installation

If you're just getting started, install the middleman gem and generate a new project:

gem install middleman
middleman init MY_PROJECT

If you already have a Middleman project: Add gem "middleman-flickr" to your Gemfile and run bundle install.

Environment Variables

For this extension to work, it expects 4 environment variables setup:

  • FLICKR_KEY: Flickr API key
  • FLICKR_SECRET: Flickr API secret
  • FLICKR_TOKEN: Flickr OAuth token for the user
  • FLICKR_TOKEN_SECREET: Flickr OAuth token secret for the user

An error WILL be raised if authentication with Flickr fails.

Helper Methods

All helper methods added by this extension accepts configuration options for this extension, as well as any additional options for the Flickr API, if required, e.g.:

display_flickr_photoset: 'ID1', show_on_empty: false, per_page: 20

Here, show_on_empty is a config option for this extension, while per_page is an option for the Flickr API call being made. In this example, a maximum of 20 images will be returned, and HTML will not be added if no photos are returned.

This extension adds the following helper methods for you:

get_flickr_images

get_flickr_images data: { photo: ['PID1', 'PID2'], photoset: ['PSID3'] }, options

Get a list of image URLs from Flickr for the given Photos and Photosets. This helper method can be used in your layouts etc. and can be styled anyway you like.

display_flickr

display_flickr data: { photo: ['PID1', 'PID2'], photoset: ['PSID3'] }, options

Add HTML markup for image URLs from Flickr for the given Photos and Photosets. Thumbnails will be used for the image, while a lightbox link is added for the large size image. Each image is wrapped in a div.grid-item CSS for ease of styling, which are further wrapped in a div.grid container. (Think: masonry)

display_flickr_photo

display_flickr_photo 'PID1', 'PID2', options

Add HTML for the given photos.

display_flickr_photoset

display_flickr_photoset 'PsID1', 'PsID2', options

Add HTML for the given photosets. A maximum of 500 photos per photoset can be returned, at the moment.

Configuration

activate :flickr do |conf|
  conf.html_class = 'flickr-images'
  conf.show_on_empty = true
  conf.suppress_errors = -> (err) { puts err.message }
end

Options

html_class option defines HTML class for div element that wraps the HTML generated by this extension. This may be useful for styling your gallery.

show_on_empty option can be set to false to not output any HTML when no images could be found. You can, also, set this option to a Proc that generates the HTML in this case.

suppress_errors option (default: false) can be used to suppress errors generated when querying Flickr API, e.g. when a Photo/set ID could not be found on Flickr. You can set this option to a Proc that consumes the error generated to do something more meaningful. By default, errors are raised/bubbled up.

Community

The official community forum is available at: http://forum.middlemanapp.com

Bug Reports

Github Issues are used for managing bug reports and feature requests. If you run into issues, please search the issues and submit new problems: https://github.com/middleman/middleman-blog/issues

The best way to get quick responses to your issues and swift fixes to your bugs is to submit detailed bug reports, include test cases and respond to developer questions in a timely manner. Even better, if you know Ruby, you can submit Pull Requests containing Cucumber Features which describe how your feature should work or exploit the bug you are submitting.

Tests / Build Status?

Coming up soon.

Donate

Click here to lend your support to Middleman

License

Copyright (c) 2018 Nikhil Gupta. MIT Licensed, see LICENSE for details.

About

Import Photo/sets from Flickr in your Middleman website.


Languages

Language:Ruby 100.0%