NAME

Mojolicious::Plugin::Libravatar - Access the Libravatar API in Mojolicious.

SYNOPSIS

# Mojolicious
$self->plugin(
      'Libravatar',
      {
          size       => 30,
          https      => 1,
          mojo_cache => 1, # optional to enable cacheing
      }
      );

# Mojolicious::Lite
plugin 'Libravatar';

% my $url = libravatar_url 'user@info.com', size => 80;

DESCRIPTION

Mojolicious::Plugin::Libravatar provides access to the open source Libravatar API http://www.libravatar.org. It utilizes the Libravatar::URL library internally and configuration and options to the helper method libravatar_url are passed to it directly.

METHODS

Mojolicious::Plugin::Libravatar inherits all methods from Mojolicious::Plugin and implements the following new ones.

register

$plugin->register(Mojolicious->new);

Register plugin in Mojolicious application.

CONFIG

Mojolicious::Plugin::Libravatar accepts the same options as Libravatar::URL, including size, https, base, and short_keys. However, one additional parameter has been added:

mojo_cache

This is a boolean parameter (0|1) which, when true, tells the plugin to store urls in a cache. For now, this is done with Mojo::Cache.

cached_email

Default email to use for cached_avatar helper.

HELPERS

libravatar_url

Given an email, returns a url for the corresponding avatar. Options override configuration.

# In code
my $url = $app->libravatar('email',%options);

# Template
% my $url = libravatar_url 'user@info.com', size => 80,...;

cached_avatar

If libravatar url for specific email not already cached, return a precached default. This might be handy if you don't want to query for avatars at certain times

% my $url = cached_avatar 'xyz@abc.com', https => 1, size => 80 ..;

SEE ALSO

Mojolicious, Mojolicious::Guides, http://mojolicio.us, Libravatar::URL, http://www.libravatar.org.

SOURCE

git://github.com/heytrav/mpl.git