Template-Plugin-Gravatar-0.10/000755 000765 000024 00000000000 12765254055 016152 5ustar00apvstaff000000 000000 Template-Plugin-Gravatar-0.10/.travis.yml000644 000765 000024 00000000065 12437427060 020256 0ustar00apvstaff000000 000000 language: perl perl: - "5.20" - "5.10" - "5.8" Template-Plugin-Gravatar-0.10/Changes000644 000765 000024 00000004336 12765254023 017446 0ustar00apvstaff000000 000000 Revision history for Template-Plugin-Gravatar 0.10 Sun Sep 11 08:52:46 EDT 2016 - [rt.cpan.org #117779] nhorne@cpan.org - https is a better default scheme. 0.09 Tue Dec 2 08:25:04 PST 2014 - Patch from Cyclenerd to correctly setup email before hashing with trim and lc. 0.08 Tue Oct 14 08:36:52 PDT 2014 - Oriol Soriano Vila patch for Base problem; RT#99482. 0.07 Thu Apr 3 12:57:04 PDT 2014 - Moved to github. - https://rt.cpan.org/Public/Bug/Display.html?id=93542 - up size limit and take the border out of the tests. 0.06 Thu Oct 15 16:20:42 PDT 2009 - Downcased a couple of \Zs. - I was looking to base this on Gravatar::URL this time but I'm not quite ready. I'd like to get Schwern to expose the base URI and maybe do one or two things first. - Deprecated borders. They won't be in the URIs at all and carp when you use them. - Fixed broken URIs from Gravatar changing them without redirects. - Yes, the date is accurate. I forgot to release it but figure I may as well before I do 0.07 for a bug fix. Uploading 20140403. 0.05 Sat Sep 8 20:12:24 PDT 2007 - Fixed a misspelling. - Fixed 404/broken Gravatar site links. - See also for the new standalone module, Gravatar::URL. 0.04 Sun Jun 17 16:38:26 PDT 2007 - Fixed a pre-req moment of madness, Template wasn't required and caused failures for builds without it. - POD updates about absolute URIs for "default" images. 0.03 Sat Mar 25 13:45:15 PST 2006 - Couple of POD tweaks. 0.02 Sun Mar 19 10:25:55 PST 2006 - Um... considered "beta" I meant (that's what the other docs said). - Changed the paramter joiner from "&" to "&" -- wisely suggested by Darren Chamberlain. Doc changes to reflect it too. - Added tests to check GRAVATAR settings in config and realized I wasn't getting them. Fixed it. - Added tests to check fatals. - Expanded POD quite a bit about settings. - Validating border now too (was already doing rating and size). 0.01 Sat Mar 18 13:22:15 2006 - First stab. Considered alpha till I get some feedback and use testing in. Template-Plugin-Gravatar-0.10/inc/000755 000765 000024 00000000000 12765254055 016723 5ustar00apvstaff000000 000000 Template-Plugin-Gravatar-0.10/lib/000755 000765 000024 00000000000 12765254055 016720 5ustar00apvstaff000000 000000 Template-Plugin-Gravatar-0.10/Makefile.PL000644 000765 000024 00000000512 12317337225 020114 0ustar00apvstaff000000 000000 use inc::Module::Install; name "Template-Plugin-Gravatar"; all_from "lib/Template/Plugin/Gravatar.pm"; repository "git://github.com/pangyre/p5-template-plugin-gravatar"; requires "Test::More"; requires "Template" => 2; requires "Carp"; requires "Digest::MD5" => 2.25; requires "URI::Escape"; auto_install; WriteAll; Template-Plugin-Gravatar-0.10/MANIFEST000644 000765 000024 00000001025 12765254055 017301 0ustar00apvstaff000000 000000 .travis.yml Changes inc/Module/AutoInstall.pm inc/Module/Install.pm inc/Module/Install/AutoInstall.pm inc/Module/Install/Base.pm inc/Module/Install/Can.pm inc/Module/Install/Fetch.pm inc/Module/Install/Include.pm inc/Module/Install/Makefile.pm inc/Module/Install/Metadata.pm inc/Module/Install/Win32.pm inc/Module/Install/WriteAll.pm lib/Template/Plugin/Gravatar.pm Makefile.PL MANIFEST This list of files META.yml README t/00.load.t t/gravatar-config.t t/gravatar-error.t t/gravatar.t t/perlcritic-hold xt/pod-coverage.t xt/pod.t Template-Plugin-Gravatar-0.10/META.yml000644 000765 000024 00000001333 12765254053 017421 0ustar00apvstaff000000 000000 --- abstract: 'Configurable TT2-based generation of Gravatar URLs from email addresses.' author: - 'Ashley Pond V, C<< >>.' build_requires: ExtUtils::MakeMaker: 6.36 configure_requires: ExtUtils::MakeMaker: 6.36 distribution_type: module dynamic_config: 1 generated_by: 'Module::Install version 1.14' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 name: Template-Plugin-Gravatar no_index: directory: - inc - t - xt requires: Carp: 0 Digest::MD5: 2.25 Template: 2 Test::More: 0 URI::Escape: 0 resources: license: http://dev.perl.org/licenses/ repository: git://github.com/pangyre/p5-template-plugin-gravatar version: '0.10' Template-Plugin-Gravatar-0.10/README000644 000765 000024 00000000345 12317334710 017022 0ustar00apvstaff000000 000000 Template-Plugin-Gravatar Easy and fully configurable Gravatars from user emails in your templates. INSTALLATION To install this module, run the following commands: perl Makefile.PL make make test make install Template-Plugin-Gravatar-0.10/t/000755 000765 000024 00000000000 12765254055 016415 5ustar00apvstaff000000 000000 Template-Plugin-Gravatar-0.10/xt/000755 000765 000024 00000000000 12765254055 016605 5ustar00apvstaff000000 000000 Template-Plugin-Gravatar-0.10/xt/pod-coverage.t000644 000765 000024 00000000254 12317334710 021334 0ustar00apvstaff000000 000000 #!perl -T use Test::More; eval "use Test::Pod::Coverage 1.04"; plan skip_all => "Test::Pod::Coverage 1.04 required for testing POD coverage" if $@; all_pod_coverage_ok(); Template-Plugin-Gravatar-0.10/xt/pod.t000644 000765 000024 00000000214 12317334710 017537 0ustar00apvstaff000000 000000 #!perl -T use Test::More; eval "use Test::Pod 1.14"; plan skip_all => "Test::Pod 1.14 required for testing POD" if $@; all_pod_files_ok(); Template-Plugin-Gravatar-0.10/t/00.load.t000644 000765 000024 00000000242 12317334710 017723 0ustar00apvstaff000000 000000 use Test::More tests => 1; BEGIN { use_ok( 'Template::Plugin::Gravatar' ); } diag( "Testing Template::Plugin::Gravatar $Template::Plugin::Gravatar::VERSION" ); Template-Plugin-Gravatar-0.10/t/gravatar-config.t000644 000765 000024 00000003672 12765253623 021664 0ustar00apvstaff000000 000000 #!perl use Template::Test; $Template::Test::DEBUG = 1; my $template_cfg = { GRAVATAR => { default => "/avatar.jpg", rating => "R", size => 50, } }; my $template_obj = Template->new($template_cfg); test_expect( \*DATA, $template_obj ); __DATA__ -- test -- [% USE Gravatar -%] loaded -- expect -- loaded -- test -- [% USE Gravatar -%] [% Gravatar( email => 'whatever@wherever.whichever' ) %] -- expect -- https://gravatar.com/avatar/?gravatar_id=a60fc0828e808b9a6a9d50f1792240c8&rating=R&size=50&default=%2Favatar.jpg -- test -- [% USE Gravatar( base => "ftp://moo.cow/go/go") -%] [% Gravatar( email => 'whatever@wherever.whichever' ) %] -- expect -- ftp://moo.cow/go/go?gravatar_id=a60fc0828e808b9a6a9d50f1792240c8&rating=R&size=50&default=%2Favatar.jpg -- test -- [% USE Gravatar(default => "/local.png") -%] [% Gravatar( email => 'whatever@wherever.whichever' ) | html %] -- expect -- https://gravatar.com/avatar/?gravatar_id=a60fc0828e808b9a6a9d50f1792240c8&rating=R&size=50&default=%2Flocal.png -- test -- [% USE Gravatar(default => "/local.png", rating => 'X') -%] [% Gravatar( email => 'whatever@wherever.whichever' ) %] -- expect -- https://gravatar.com/avatar/?gravatar_id=a60fc0828e808b9a6a9d50f1792240c8&rating=X&size=50&default=%2Flocal.png -- test -- [% USE Gravatar(default => "/local.png") -%] [% Gravatar( email => 'whatever@wherever.whichever', rating => 'R', size => 80 ) | html %] -- expect -- https://gravatar.com/avatar/?gravatar_id=a60fc0828e808b9a6a9d50f1792240c8&rating=R&size=80&default=%2Flocal.png -- test -- [% USE Gravatar(default => "/local.png", border => 'AAB', rating => 'PG', size => 45 ) -%] [% Gravatar( email => 'whatever@wherever.whichever' ) | html %] -- expect -- https://gravatar.com/avatar/?gravatar_id=a60fc0828e808b9a6a9d50f1792240c8&rating=PG&size=45&default=%2Flocal.png Template-Plugin-Gravatar-0.10/t/gravatar-error.t000644 000765 000024 00000001334 12317337653 021540 0ustar00apvstaff000000 000000 #!perl use Template::Test; $Template::Test::DEBUG = 1; test_expect( \*DATA ); __DATA__ -- test -- [% USE Gravatar -%] loaded -- expect -- loaded -- test -- [% USE Gravatar -%] [% TRY %][% Gravatar %][% CATCH %][% error.info.replace('\s+at\s.+','') %][% END %] -- expect -- Cannot generate a Gravatar URI without an email address -- test -- [% USE Gravatar -%] [% TRY %][% Gravatar(email => 'x', rating => 'NC-17') %][% CATCH %][% error.info.replace('\s+at\s.+','') %][% END %] -- expect -- Gravatar rating can only be G, PG, R, or X -- test -- [% USE Gravatar( size => 2049 ) -%] [% TRY %][% Gravatar(email => 'x') %][% CATCH %][% error.info.replace('\s+at\s.+','') %][% END %] -- expect -- Gravatar size must be 1 .. 2048 Template-Plugin-Gravatar-0.10/t/gravatar.t000644 000765 000024 00000003272 12765253670 020417 0ustar00apvstaff000000 000000 #!perl use Template::Test; $Template::Test::DEBUG = 1; test_expect(\*DATA); __DATA__ -- test -- [% USE Gravatar -%] loaded -- expect -- loaded -- test -- [%- USE Gravatar -%] [% Gravatar( email => 'whatever@wherever.whichever' ) %] -- expect -- https://gravatar.com/avatar/?gravatar_id=a60fc0828e808b9a6a9d50f1792240c8 -- test -- [%- USE Gravatar(default => "/local.png") -%] [% Gravatar( email => 'whatever@wherever.whichever' ) | html %] -- expect -- https://gravatar.com/avatar/?gravatar_id=a60fc0828e808b9a6a9d50f1792240c8&default=%2Flocal.png -- test -- [%- USE Gravatar(default => "/local.png") -%] [% Gravatar( email => ' wHatever@WHEREVER.whichever ' ) | html %] -- expect -- https://gravatar.com/avatar/?gravatar_id=a60fc0828e808b9a6a9d50f1792240c8&default=%2Flocal.png -- test -- [%- USE Gravatar(default => "/local.png", rating => 'X') -%] [% Gravatar( email => 'whatever@wherever.whichever' ) %] -- expect -- https://gravatar.com/avatar/?gravatar_id=a60fc0828e808b9a6a9d50f1792240c8&rating=X&default=%2Flocal.png -- test -- [%- USE Gravatar(default => "/local.png") -%] [% Gravatar( email => 'whatever@wherever.whichever', rating => 'R', size => 80 ) | html %] -- expect -- https://gravatar.com/avatar/?gravatar_id=a60fc0828e808b9a6a9d50f1792240c8&rating=R&size=80&default=%2Flocal.png -- test -- [%- USE Gravatar(default => "/local.png", border => 'AAB', rating => 'PG', size => 45 ) -%] [% Gravatar( email => 'whatever@wherever.whichever' ) | html %] -- expect -- https://gravatar.com/avatar/?gravatar_id=a60fc0828e808b9a6a9d50f1792240c8&rating=PG&size=45&default=%2Flocal.png Template-Plugin-Gravatar-0.10/t/perlcritic-hold000644 000765 000024 00000000466 12317334710 021420 0ustar00apvstaff000000 000000 # This is not working right(?). It's registering errors inside itself # (Test::Perl::Critic), not in the tested module. #!perl if (!require Test::Perl::Critic) { Test::More::plan( skip_all => "Test::Perl::Critic required for testing PBP compliance" ); } Test::Perl::Critic::all_critic_ok(); Template-Plugin-Gravatar-0.10/lib/Template/000755 000765 000024 00000000000 12765254055 020473 5ustar00apvstaff000000 000000 Template-Plugin-Gravatar-0.10/lib/Template/Plugin/000755 000765 000024 00000000000 12765254055 021731 5ustar00apvstaff000000 000000 Template-Plugin-Gravatar-0.10/lib/Template/Plugin/Gravatar.pm000644 000765 000024 00000017452 12765253750 024050 0ustar00apvstaff000000 000000 package Template::Plugin::Gravatar; use warnings; use strict; use base "Template::Plugin"; use Carp qw( carp croak ); use URI (); use Digest::MD5 (); our $VERSION = "0.10"; our $AUTHORITY = "cpan:ASHLEY"; our $Gravatar_Base = "https://gravatar.com/avatar/"; sub new { my ( $class, $context, $instance_args ) = @_; $instance_args ||= {}; # the USE'd object. my $config = $context->{CONFIG}{GRAVATAR} || {}; # from TT config. my %args; $args{default} = $instance_args->{default} || $config->{default}; $args{rating} = $instance_args->{rating} || $config->{rating}; $args{border} = $instance_args->{border} || $config->{border}; $args{size} = $instance_args->{size} || $config->{size}; # Overriding the base might be nice for some developers. $args{base} = $instance_args->{base} || $config->{base} || $Gravatar_Base; return sub { my $args = shift || {}; $args = { %args, %{$args} }; $args->{email} || croak "Cannot generate a Gravatar URI without an email address"; if ( $args->{size} ) { $args->{size} >= 1 and $args->{size} <= 2048 or croak "Gravatar size must be 1 .. 2048"; } if ( $args->{rating} ) { $args->{rating} =~ /\A(?:G|PG|R|X)\z/ or croak "Gravatar rating can only be G, PG, R, or X"; } if ( $args->{border} ) { carp "Border is deprecated! Dropping it."; } my $email = $args->{email}; s/\A\s+//, s/\s+\z// for $email; $email = lc $email; # Might need to consider charset here or document consideration... $args->{gravatar_id} = Digest::MD5::md5_hex($email); my $uri = URI->new( $args->{base} || $Gravatar_Base ); my @ordered = map { $_, $args->{$_} } grep $args->{$_}, qw( gravatar_id rating size default ); $uri->query_form(@ordered); $uri; } } 1; __END__ =head1 Name Template::Plugin::Gravatar - Configurable TT2-based generation of Gravatar URLs from email addresses. =head1 Synopsis [% USE Gravatar %] [% FOR user IN user_list %] [% user.name | html %] [% END %] # OR a mini CGI example use strict; use CGI qw( header start_html end_html ); use Template; my %config = ( # ... your other config stuff GRAVATAR => { default => "http://myhost.moo/local/image.png", size => 80, rating => "R" }, ); # note the "default" must be an absolute URI to work correctly my $tt2 = Template->new(\%config); my $user = { email => 'whatever@wherever.whichever', rating => "PG", name => "Manamana", size => 75 }; print header(), start_html(); $tt2->process(\*DATA, { user => $user }) or warn $Template::ERROR; print end_html(); __DATA__ [% USE Gravatar %] [% FILTER html %] [% user.name | html %] [% END %] =head1 Description Please see L for more on the service interface and L for information about Gravatars (globally recognized avatars) in general. All of the options supported in GravatarsEdefault, rating, and sizeEcan be used here. The C is generated from a given email. =head1 Interface/Settings =head2 new Not called directly. Called when you C the plugin. Takes defaults from the template config hash and mixes them with any per template defaults. E.g.E [% USE Gravatar %] Use config arguments if any. [% USE Gravatar(default => 'http://mysite.moo/local/default-image.gif') %] Mix config arguments, if any, with new instance arguments. =head2 Arguments =over 4 =item email (required) The key to using Gravatars is a hex hash of the user's email. This is generated automatically and sent to gravatar.com as the C. =item default (optional) The local (any valid absolute image URI) image to use if there is no Gravatar corresponding to the given email. =item size (optional) Gravatars are square. Size is 1 through 80 (pixels) and sets the width and the height. =item rating (optional) G|PG|R|X. The B rating of Gravatar you wish returned. If you have a family friendly forum, for example, you might set it to "G." =item border (DEPRECATED) A hex color, e.g. FF00FF or F0F. Gravatar no longer does anything with these so we don't even pass them along. If included they will give a warning. =item base (developer override) This is provided as a courtesy for the one or two developers who might need it. More below. =item gravatar_id (not allowed) This is B an option but a generated variable. It is an MD5 hex hash of the email address. The reason is it not supported as an optional variable is it would allow avatar hijacking. =back The only argument that must be given when you call the C plugin is the email. Everything elseErating, default image, border, and sizeEcan be set in three different places: the config, the C call, or the C call. All three of the following produce the same Gravatar URL. =head2 Settings via config Used if the entire "site" should rely on one set of defaults. use Template; my %config = ( GRAVATAR => { default => "http://mysite.moo/img/avatar.png", rating => "PG", size => 80, } ); my $template = <<; [% USE Gravatar %] [% Gravatar(email => 'me@myself.ego') | html %] my $tt2 = Template->new(\%config); $tt2->process(\$template); =head2 Settings via instance Used if a particular template needs its own defaults. use Template; my $template = <<; [% USE Gravatar( rating => "PG", size => 80 ) %] [% Gravatar(email => 'me@myself.ego') | html %] my $tt2 = Template->new(); $tt2->process(\$template); Any other calls with different emails will share the defaults in this template. =head2 Settings in the Gravatar call Used for per URL control. use Template; my $template = <<; [% USE Gravatar %] [% Gravatar(email => 'me@myself.ego', default => "http://mysite.moo/img/avatar.png", rating => "PG", size => 80 ) | html %] my $tt2 = Template->new(); $tt2->process(\$template); =head2 Base URL (for developers only) You may also override the base URL for retrieving the Gravatars. It's set to use the service from L. It can be overridden in the config or the C. =head1 Diagnostics Email is the only required argument. Croaks without it. Rating and size are also validated on each call. Croaks if an invalid size (like 0 or 100) or rating (like MA or NC-17). =head1 Configuration AND ENVIRONMENT No configuration is necessary. You may use the configuration hash of your new template to pass default information like the default image location for those without Gravatars. You can also set it in the C call per template if needed. =head1 Dependencies (see also) L