Flickr Plugin

  • Tags : /
  • Latest : 0.2
  • Last Updated: 02 December 2011
  • Grails version : 1.3.7 > *
  • Authors : null
  • Organization : SynergyJ
2 votes
Dependency :
compile ":flickr:0.2"

Documentation Source Issues

Summary

This plugin is intended to show some flickr photos based in a tag…

Installation

Installation

  • In the command prompt under your project
    grails install-plugin flickr

Description

This plugin only use the REST Flickr API to search some photos and show through a taglib or even you can use the FlickrService to generate the URL's with a simple DSL

Usage

This plugin is easily installed from the Grails plugin repository.

Confirguration

Only add your API key to the grails-app/Config.groovy

grails.plugins.flickr.apiKey="YOUR_FLICKR_API_KEY"

Use the tag library

  • The plugin brings you the tag: <flickr:search tags="grailsmx" />, and you can put the parameters as the API documentations says:
    • => tags - A comma-delimited list of tags. Photos with one or more of the tags listed will be returned. You can exclude results that match a term by prepending it with a - character.
    • => text - A free text search. Photos who's title, description or tags contain the text will be returned. You can exclude results that match a term by prepending it with a - character.
    • => sort - The order in which to sort returned photos. Deafults to date-posted-desc (unless you are doing a radial geo query, in which case the default sorting is by ascending distance from the point specified). The possible values are: date-posted-asc, date-posted-desc, date-taken-asc, date-taken-desc, interestingness-desc, interestingness-asc, and relevance.
    • => perPage - Number of photos to return per page. If this argument is omitted, it defaults to 100. The maximum allowed value is 500.
    • => page - The page of results to return. If this argument is omitted, it defaults to 1.
    • Many as you can find in: Flickr API search methos
    • Important: All the attributes where the name contains '_'(ex. machine_tag_mode) must be used in the taglib as camelCase(ex. machineTagMode)
Examples:
<flickr:search tags='grailsmx' perPage="12"/>

<flickr:search tags='grailsmx' page="3" perPage="8"/>

<flickr:search tags='grailsmx,springhispano' animated='true' perPage="30"/>

Use the service

  • Also you can inject the FlickrService into your controller and use the method search using the DSL; the notation is based on the same as taglib and of course as the Flickr API search methos; you must consider the same note like the taglib on the debrief of DSL
Example:
class ExampleController {

def flickrService

def index = { def data = flickrService.search{ tags 'grailsmx,springhispano' page 3 perPage 14 // Look ma! } // [urls:data.urls,page:data.page,pages:data.pages] // not more [photos:data.photos,page:data.page,pages:data.pages] // Hey look a list of objects FlickrImage } }

    • This map has three keys:
      • => photos - are the list of images objects
      • => page - is the current page
      • => pages - are the pages available for this search

Working with FlickrImage to obtain URL's

flickrImage.getURL() // Obtain an standard size image
flickrImage.url // The groovy way, standard size anyway
flickrImage.getURL(SizeSuffix.SMALL_SQUARE) // 75x75
flickrImage.getURL(SizeSuffix.THUMBNAIL) // 100 in the largest side
flickrImage.getURL(SizeSuffix.SMALL) // 240 in the largset side
flickrImage.getURL(SizeSuffix.LARGE) // 1024 in the largset side
//SizeSuffix is mx.org.grails.SizeSuffix

Exists one extra attribute in the taglib, you maybe want to use the attribute animate and set to 'true', but before you need to install the jquery and jquery-ui plugins...^_^

Changes

0.2

  • Adding FlickrImage domain class
  • Now the service retrieves a list of FlickrImage types
  • An enum to obtain the image in preferred size