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
          cached_email => 'abc@xyz.com',    # optional "pre-cached" avatar
      }
  );

# 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 the libravatar url for a specific email has not already been cached, return a pre-cached default. This might be handy if you want to avoid making a lot of queries to libravatar/gravatar servers on a single page load. The default is to use user@info.com, but you can set whatever you like using the cached_email parameter above.

% 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