Mojolicious::Plugin::Libravatar - Access the Libravatar API in Mojolicious.
# 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;
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.
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.
Mojolicious::Plugin::Libravatar accepts the same options as Libravatar::URL, including size, https, base, and short_keys. In addition, Mojolicious::Plugin::Libravatar accepts the following:
size
https
base
short_keys
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.
Default email to use for cached_avatar helper.
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,...;
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.
user@info.com
% my $url = cached_avatar 'xyz@abc.com', https => 1, size => 80 ..;
Mojolicious, Mojolicious::Guides, http://mojolicio.us, Libravatar::URL, http://www.libravatar.org.
git://github.com/heytrav/mpl.git
To install Mojolicious::Plugin::Libravatar, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Mojolicious::Plugin::Libravatar
CPAN shell
perl -MCPAN -e shell install Mojolicious::Plugin::Libravatar
For more information on module installation, please visit the detailed CPAN module installation guide.