Show Navigation

gravatar

Grails plugin for displaying avatars from Gravatar

Owner: rpalcolea | 1.0.2 | Sep 4, 2016 | Package | Issues | Source | License: Apache-2.0


dependencies {
    compile 'rpalcolea.gravatar:gravatar:1.0.2'
}

            

Grails Gravatar Plugin

Build Status Download Slack Signup

This plugin provides a taglib for displaying gravatars.

Gravatars allow users to configure an avatar to go with their email address at a central location: gravatar.com. Gravatar-aware websites can then look up and display each user‘s preferred avatar, without having to handle avatar management. The user gets the benefit of not having to set up an avatar for each site that they post on.

Installation

Add the following dependencies in build.gradle

dependencies {
...
    compile 'rpalcolea.gravatar:gravatar:1.0.2'
...
}

Configuration

You can modify the default rating and defaultImage in your application.yml as follows

gravatar:
    defaultRating: g #Optional (default is g)
    defaultGravatarUrl: http://docs.grails.org/latest/img/grails.png #optional

Usage

###TagLib Using the taglib is simple:

<gravatar:image email="[email protected]"/>

This will output

<img id="" name="" alt="Gravatar" class="gravatar" height="80" width="80" src="https://www.gravatar.com/avatar/ae03f5244dfbbd216864590baacfd130?s=80&r=g" title="gravatar"/>

You can provide the following arguments to the TagLib:

 /**
     * @attr email    REQUIRED	the startDate for styling
     * @attr size          the disired dimensions in pixels for the gravatar image (from 1 up to 512)
     * @attr alt          alt-attribute for the resulting img-element
     * @attr cssClass        class-attribute for the resulting img-element
     * @attr title          title-attribute for the resulting img-element
     * @attr id            id-attribute for the resulting img-element
     * @attr name          name-attribute for the resulting img-element
     * @attr defaultGravatarUrl    the default image to display if no gravatar is found; may be a URL or one of the following (defaults to the official Gravatar logo):
     * 								<li>404: do not load any image if none is associated with the email hash, instead return an HTTP 404 (File Not Found) response
     * 								<li>mm: (mystery-man) a simple, cartoon-style silhouetted outline of a person (does not vary by email hash)
     * 								<li>identicon: a geometric pattern based on an email hash
     * 								<li>monsterid: a generated 'monster' with different colors, faces, etc
     * 								<li>wavatar: generated faces with differing features and backgrounds
     * 								<li>retro: awesome generated, 8-bit arcade-style pixelated faces
     * @attr gravatarRating      desired image rating censor-level; may be one of the following:
     * 								<li>g (default): suitable for display on all websites with any audience type.
     * 								<li>pg: may contain rude gestures, provocatively dressed individuals, the lesser swear words, or mild violence.
     * 								<li>r: may contain such things as harsh profanity, intense violence, nudity, or hard drug use.
     * 								<li>x: may contain hardcore sexual imagery or extremely disturbing violence.
     */

###GravatarUrlGenerator If you want to generate links without the use of the taglib, you can accomplish it by using GravatarUrlGenerator as follows:

GravatarUrlGenerator.generateUrl('[email protected]')

This will output

https://www.gravatar.com/avatar/ae03f5244dfbbd216864590baacfd130?s=80&r=g

You can provide the following arguments:

  GravatarRating rating
  Integer size
  String defaultImage

Acknowledgements

This plugin contains original code and the ideas from the Avatar Plugin for Grails 1.x by Domingo Suarez Torres (@domix)

License

Apache 2

Sponsors

Alt text

YourKit supports open source projects with its full-featured Java Profiler. YourKit, LLC is the creator of YourKit Java Profiler and YourKit .NET Profiler, innovative and intelligent tools for profiling Java and .NET applications.