Gravatar-URL-1.07000755000765000024 012752745571 13624 5ustar00schwernstaff000000000000Gravatar-URL-1.07/.travis.yml000444000765000024 15412752745571 16052 0ustar00schwernstaff000000000000language: perl perl: - "5.22" - "5.20" - "5.18" - "5.16" - "5.14" - "5.12" - "5.10" - "5.8" Gravatar-URL-1.07/Build.PL000444000765000024 223412752745571 15256 0ustar00schwernstaff000000000000#!/usr/bin/perl -w use 5.006; use strict; use Module::Build; my $builder = Module::Build->new( module_name => 'Gravatar::URL', license => 'perl', meta_merge => { resources => { bugtracker => 'http://rt.cpan.org/Public/Dist/Display.html?Name=Gravatar-URL', repository => 'http://github.com/schwern/gravatar-url/tree/master', }, keywords => [ 'Gravatar' ], configure_requires => { 'Module::Build' => 0.2808 }, }, build_requires => { 'Test::More' => 0.40, 'Test::Warn' => 0.11, 'Test::MockRandom' => 1.01, }, requires => { 'Net::DNS' => 1.01, 'URI::Escape' => 0, 'Digest::MD5' => 0, 'Digest::SHA' => 0, 'Carp' => 0, perl => '5.6.0', 'parent' => 0, }, dist_version_from => 'lib/Gravatar/URL.pm', create_readme => 1, create_license => 1, dist_author => 'Michael G. Schwern ' ); $builder->create_build_script(); Gravatar-URL-1.07/Changes000444000765000024 521612752745571 15260 0ustar00schwernstaff0000000000001.07 Wed Aug 10 17:47:19 PDT 2016 Bug Fixes * Require an updated version of Net::DNS to avoid "resolver->dnssec(1) without Net::DNS::SEC installed" (Schwern) [github #4] Test Fixes * Fix our fake random number generator to avoid cross platform issues. [rt.cpan.org 71064] [github #7] (Lisa Hare) Distribution * Kwalitee fixups (BooK) (Lisa Hare) * Added a LICENSE file (Lisa Hare) * Now using Travis CI for Unix testing (Schwern) * Now using AppVeyor for Windows testing (Schwern) 1.06 Tue Mar 27 12:55:30 BST 2012 Bug fixes * Fixed some undef warnings during sanitization. Test fixes * Adapt to changes in Carp 1.25 [rt.cpan.org 75523] 1.05 Wed Jul 6 22:40:06 NZST 2011 Security fix * Sanitize DNS results in Libravatar::URL 1.04 Tue Mar 29 17:47:34 NZDT 2011 New features * Added OpenID support in Libravatar::URL 1.03 Sat Mar 12 18:17:03 NZDT 2011 New Features * Added Libravatar::URL for federated avatar hosting with a Gravatar fallback. (http://www.libravatar.org) * Add new optional 'https' parameter to deliver avatars over HTTPS. New Docs * Updated the defaults with the new "retro" and mystery man values. * Document the https base URL now available. New Co-Maintainer (Francois Marier) 1.02 Thu Apr 1 15:36:52 PDT 2010 New Features * Added Unicornify::URL for generated unicorn avatars, OMG!!! http://unicornify.appspot.com/whats-this Incompatible Changes * short_keys is now the default, as per Gravatar protocol documentation Protocol Updates * Document that Gravatar has a new default option, 404. 1.01 Thu Apr 9 13:11:32 PDT 2009 Protocol Updates (The Gravatar protocol changed, so we're changing with it) * Gravatar expanded the max size to 512. [rt.cpan.org 41244] (CHISEL) * Base URL changed to http://www.gravatar.com/avatar/ * Ratings are now lower cased. Upper cased ratings still accepted, but will be lower cased. * Using new http://base/id?key=value style. * The border key has been removed from the protocol, so its use throws a deprecation warning. New Features * The short_keys flag uses short keys in the URL ("s" instead of "size", for example). 1.00 Sun Apr 27 14:12:24 PDT 2008 Bug Fixes * Gravatar IDs are insensitive to the case of the email address. Doc Fixes * Clarified how relative default URLs will be handled Dist Fixes * Added a configure_requires on Module::Build and a requires on perl 5.6. 0.01 Sat Sep 8 00:59:04 PDT 2007 First release, stealing liberally from Template::Plugin::Gravatar Gravatar-URL-1.07/LICENSE000444000765000024 4377312752745571 15024 0ustar00schwernstaff000000000000This software is copyright (c) 2016 by Michael G. Schwern . This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Terms of the Perl programming language system itself a) the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or b) the "Artistic License" --- The GNU General Public License, Version 1, February 1989 --- This software is Copyright (c) 2016 by Michael G. Schwern . This is free software, licensed under: The GNU General Public License, Version 1, February 1989 GNU GENERAL PUBLIC LICENSE Version 1, February 1989 Copyright (C) 1989 Free Software Foundation, Inc. 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The license agreements of most software companies try to keep users at the mercy of those companies. By contrast, our General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. The General Public License applies to the Free Software Foundation's software and to any other program whose authors commit to using it. You can use it for your programs, too. When we speak of free software, we are referring to freedom, not price. Specifically, the General Public License is designed to make sure that you have the freedom to give away or sell copies of free software, that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of a such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must tell them their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any work containing the Program or a portion of it, either verbatim or with modifications. Each licensee is addressed as "you". 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this General Public License and to the absence of any warranty; and give any other recipients of the Program a copy of this General Public License along with the Program. You may charge a fee for the physical act of transferring a copy. 2. You may modify your copy or copies of the Program or any portion of it, and copy and distribute such modifications under the terms of Paragraph 1 above, provided that you also do the following: a) cause the modified files to carry prominent notices stating that you changed the files and the date of any change; and b) cause the whole of any work that you distribute or publish, that in whole or in part contains the Program or any part thereof, either with or without modifications, to be licensed at no charge to all third parties under the terms of this General Public License (except that you may choose to grant warranty protection to some or all third parties, at your option). c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the simplest and most usual way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this General Public License. d) You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. Mere aggregation of another independent work with the Program (or its derivative) on a volume of a storage or distribution medium does not bring the other work under the scope of these terms. 3. You may copy and distribute the Program (or a portion or derivative of it, under Paragraph 2) in object code or executable form under the terms of Paragraphs 1 and 2 above provided that you also do one of the following: a) accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Paragraphs 1 and 2 above; or, b) accompany it with a written offer, valid for at least three years, to give any third party free (except for a nominal charge for the cost of distribution) a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Paragraphs 1 and 2 above; or, c) accompany it with the information you received as to where the corresponding source code may be obtained. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form alone.) Source code for a work means the preferred form of the work for making modifications to it. For an executable file, complete source code means all the source code for all modules it contains; but, as a special exception, it need not include source code for modules which are standard libraries that accompany the operating system on which the executable file runs, or for standard header files or definitions files that accompany that operating system. 4. You may not copy, modify, sublicense, distribute or transfer the Program except as expressly provided under this General Public License. Any attempt otherwise to copy, modify, sublicense, distribute or transfer the Program is void, and will automatically terminate your rights to use the Program under this License. However, parties who have received copies, or rights to use copies, from you under this General Public License will not have their licenses terminated so long as such parties remain in full compliance. 5. By copying, distributing or modifying the Program (or any work based on the Program) you indicate your acceptance of this license to do so, and all its terms and conditions. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. 7. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of the license which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the license, you may choose any version ever published by the Free Software Foundation. 8. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to humanity, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19xx name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (a program to direct compilers to make passes at assemblers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice That's all there is to it! --- The Artistic License 1.0 --- This software is Copyright (c) 2016 by Michael G. Schwern . This is free software, licensed under: The Artistic License 1.0 The Artistic License Preamble The intent of this document is to state the conditions under which a Package may be copied, such that the Copyright Holder maintains some semblance of artistic control over the development of the package, while giving the users of the package the right to use and distribute the Package in a more-or-less customary fashion, plus the right to make reasonable modifications. Definitions: - "Package" refers to the collection of files distributed by the Copyright Holder, and derivatives of that collection of files created through textual modification. - "Standard Version" refers to such a Package if it has not been modified, or has been modified in accordance with the wishes of the Copyright Holder. - "Copyright Holder" is whoever is named in the copyright or copyrights for the package. - "You" is you, if you're thinking about copying or distributing this Package. - "Reasonable copying fee" is whatever you can justify on the basis of media cost, duplication charges, time of people involved, and so on. (You will not be required to justify it to the Copyright Holder, but only to the computing community at large as a market that must bear the fee.) - "Freely Available" means that no fee is charged for the item itself, though there may be fees involved in handling the item. It also means that recipients of the item may redistribute it under the same conditions they received it. 1. You may make and give away verbatim copies of the source form of the Standard Version of this Package without restriction, provided that you duplicate all of the original copyright notices and associated disclaimers. 2. You may apply bug fixes, portability fixes and other modifications derived from the Public Domain or from the Copyright Holder. A Package modified in such a way shall still be considered the Standard Version. 3. You may otherwise modify your copy of this Package in any way, provided that you insert a prominent notice in each changed file stating how and when you changed that file, and provided that you do at least ONE of the following: a) place your modifications in the Public Domain or otherwise make them Freely Available, such as by posting said modifications to Usenet or an equivalent medium, or placing the modifications on a major archive site such as ftp.uu.net, or by allowing the Copyright Holder to include your modifications in the Standard Version of the Package. b) use the modified Package only within your corporation or organization. c) rename any non-standard executables so the names do not conflict with standard executables, which must also be provided, and provide a separate manual page for each non-standard executable that clearly documents how it differs from the Standard Version. d) make other distribution arrangements with the Copyright Holder. 4. You may distribute the programs of this Package in object code or executable form, provided that you do at least ONE of the following: a) distribute a Standard Version of the executables and library files, together with instructions (in the manual page or equivalent) on where to get the Standard Version. b) accompany the distribution with the machine-readable source of the Package with your modifications. c) accompany any non-standard executables with their corresponding Standard Version executables, giving the non-standard executables non-standard names, and clearly documenting the differences in manual pages (or equivalent), together with instructions on where to get the Standard Version. d) make other distribution arrangements with the Copyright Holder. 5. You may charge a reasonable copying fee for any distribution of this Package. You may charge any fee you choose for support of this Package. You may not charge a fee for this Package itself. However, you may distribute this Package in aggregate with other (possibly commercial) programs as part of a larger (possibly commercial) software distribution provided that you do not advertise this Package as a product of your own. 6. The scripts and library files supplied as input to or produced as output from the programs of this Package do not automatically fall under the copyright of this Package, but belong to whomever generated them, and may be sold commercially, and may be aggregated with this Package. 7. C or perl subroutines supplied by you and linked into this Package shall not be considered part of this Package. 8. The name of the Copyright Holder may not be used to endorse or promote products derived from this software without specific prior written permission. 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. The End Gravatar-URL-1.07/MANIFEST000444000765000024 36112752745571 15072 0ustar00schwernstaff000000000000.travis.yml Build.PL Changes lib/Gravatar/URL.pm lib/Libravatar/URL.pm lib/Unicornify/URL.pm MANIFEST This list of files MANIFEST.SKIP META.json META.yml README t/deprecated.t t/error.t t/id.t t/libravatar.t t/unicornify.t t/url.t LICENSE Gravatar-URL-1.07/MANIFEST.SKIP000444000765000024 200112752745571 15650 0ustar00schwernstaff000000000000 #!start included /Users/schwern/perl5/perlbrew/perls/perl-v5.12.2/lib/5.12.2/ExtUtils/MANIFEST.SKIP # Avoid version control files. \bRCS\b \bCVS\b \bSCCS\b ,v$ \B\.svn\b \B\.git\b \B\.gitignore\b \b_darcs\b \B\.cvsignore$ # Avoid VMS specific MakeMaker generated files \bDescrip.MMS$ \bDESCRIP.MMS$ \bdescrip.mms$ # Avoid Makemaker generated and utility files. \bMANIFEST\.bak \bMakefile$ \bblib/ \bMakeMaker-\d \bpm_to_blib\.ts$ \bpm_to_blib$ \bblibdirs\.ts$ # 6.18 through 6.25 generated this # Avoid Module::Build generated and utility files. \bBuild$ \b_build/ \bBuild.bat$ \bBuild.COM$ \bBUILD.COM$ \bbuild.com$ # Avoid temp and backup files. ~$ \.old$ \#$ \b\.# \.bak$ \.tmp$ \.# \.rej$ # Avoid OS-specific files/dirs # Mac OSX metadata \B\.DS_Store # Mac OSX SMB mount metadata files \B\._ # Avoid Devel::Cover and Devel::CoverX::Covered files. \bcover_db\b \bcovered\b # Avoid MYMETA files ^MYMETA\. #!end included /Users/schwern/perl5/perlbrew/perls/perl-v5.12.2/lib/5.12.2/ExtUtils/MANIFEST.SKIP Gravatar-URL-1.07/META.json000444000765000024 335712752745571 15412 0ustar00schwernstaff000000000000{ "abstract" : "Make URLs for Gravatars from an email address", "author" : [ "Michael G. Schwern " ], "dynamic_config" : 1, "generated_by" : "Module::Build version 0.4218", "keywords" : [ "Gravatar" ], "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "Gravatar-URL", "prereqs" : { "build" : { "requires" : { "Test::MockRandom" : "1.01", "Test::More" : "0.4", "Test::Warn" : "0.11" } }, "configure" : { "requires" : { "Module::Build" : "0.42" } }, "runtime" : { "requires" : { "Carp" : "0", "Digest::MD5" : "0", "Digest::SHA" : "0", "Net::DNS" : "1.01", "URI::Escape" : "0", "parent" : "0", "perl" : "v5.6.0" } } }, "provides" : { "Gravatar::URL" : { "file" : "lib/Gravatar/URL.pm", "version" : "1.07" }, "Libravatar::URL" : { "file" : "lib/Libravatar/URL.pm", "version" : "1.07" }, "Unicornify::URL" : { "file" : "lib/Unicornify/URL.pm", "version" : "1.07" } }, "release_status" : "stable", "resources" : { "bugtracker" : { "web" : "http://rt.cpan.org/Public/Dist/Display.html?Name=Gravatar-URL" }, "license" : [ "http://dev.perl.org/licenses/" ], "repository" : { "url" : "http://github.com/schwern/gravatar-url/tree/master" } }, "version" : "1.07", "x_serialization_backend" : "JSON::PP version 2.27400" } Gravatar-URL-1.07/META.yml000444000765000024 212212752745571 15227 0ustar00schwernstaff000000000000--- abstract: 'Make URLs for Gravatars from an email address' author: - 'Michael G. Schwern ' build_requires: Test::MockRandom: '1.01' Test::More: '0.4' Test::Warn: '0.11' configure_requires: Module::Build: '0.42' dynamic_config: 1 generated_by: 'Module::Build version 0.4218, CPAN::Meta::Converter version 2.150005' keywords: - Gravatar license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: Gravatar-URL provides: Gravatar::URL: file: lib/Gravatar/URL.pm version: '1.07' Libravatar::URL: file: lib/Libravatar/URL.pm version: '1.07' Unicornify::URL: file: lib/Unicornify/URL.pm version: '1.07' requires: Carp: '0' Digest::MD5: '0' Digest::SHA: '0' Net::DNS: '1.01' URI::Escape: '0' parent: '0' perl: v5.6.0 resources: bugtracker: http://rt.cpan.org/Public/Dist/Display.html?Name=Gravatar-URL license: http://dev.perl.org/licenses/ repository: http://github.com/schwern/gravatar-url/tree/master version: '1.07' x_serialization_backend: 'CPAN::Meta::YAML version 0.012' Gravatar-URL-1.07/README000444000765000024 1012312752745571 14656 0ustar00schwernstaff000000000000NAME Gravatar::URL - Make URLs for Gravatars from an email address SYNOPSIS use Gravatar::URL; my $gravatar_id = gravatar_id($email); my $gravatar_url = gravatar_url(email => $email); DESCRIPTION A Gravatar is a Globally Recognized Avatar for a given email address. This allows you to have a global picture associated with your email address. You can look up the Gravatar for any email address by constructing a URL to get the image from gravatar.com. This module does that. Examples of use include the author faces on http://search.cpan.org. See http://gravatar.com for more info. Functions gravatar_url # By email my $url = gravatar_url( email => $email, %options ); # By gravatar ID my $url = gravatar_url( id => $id, %options ); Constructs a URL to fetch the gravatar for a given $email or $id. $id is a gravatar ID. See "gravatar_id" for more information. %options are optional and are... rating A user can rate how offensive the content of their gravatar is, like a movie. The ratings are g, pg, r and x. If you specify a rating it is the highest rating that will be given. rating => "r" # includes g, pg and r size Specifies the desired width and height of the gravatar (gravatars are square). Valid values are from 1 to 512 inclusive. Any size other than 80 may cause the original gravatar image to be downsampled using bicubic resampling before output. size => 40, # 40 x 40 image default The url to use if the user has no gravatar or has none that fits your rating requirements. default => "https://secure.wikimedia.org/wikipedia/en/wiki/File:Mad30.jpg" Relative URLs will be relative to the base (ie. gravatar.com), not your web site. Gravatar defines special values that you may use as a default to produce dynamic default images. These are "identicon", "monsterid", "wavatar" and "retro". "404" will cause the URL to return an HTTP 404 "Not Found" error instead whereas "mm" will display the same "mystery man" image for all missing people. See http://en.gravatar.com/site/implement/url for more info. If omitted, Gravatar will serve up their default image, the blue G. border DEPRECATED! This key has been removed from the Gravatar protocol. It will be removed from future versions of Gravatar::URL. Gravatars can be requested to have a 1 pixel colored border. If you'd like that, pass in the color to border as a 3 or 6 digit hex string. border => "000000", # a black border, like my soul border => "000", # black, but in 3 digits base This is the URL of the location of the Gravatar server you wish to grab Gravatars from. Defaults to http://www.gravatar.com/avatar/" for HTTP and https://secure.gravatar.com/avatar/ for HTTPS. short_keys If true, use short key names when constructing the URL. "s" instead of "size", "r" instead of "ratings" and so on. short_keys defaults to true. https If true, serve avatars over HTTPS instead of HTTP. You should select this option if your site is served over HTTPS to avoid browser warnings about the presence of insecure content. https defaults to false. gravatar_id my $id = gravatar_id($email); Converts an $email address into its Gravatar $id. THANKS Thanks to gravatar.com for coming up with the whole idea and Ashley Pond V from whose Template::Plugin::Gravatar I took most of the original code. LICENSE Copyright 2007 - 2009, Michael G Schwern . Copyright 2011, Francois Marier . This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See http://dev.perl.org/licenses/artistic.html SEE ALSO Template::Plugin::Gravatar - a Gravatar plugin for Template Toolkit http://www.gravatar.com - The Gravatar web site http://en.gravatar.com/site/implement/url - The Gravatar URL implementor's guide Gravatar-URL-1.07/lib000755000765000024 012752745571 14372 5ustar00schwernstaff000000000000Gravatar-URL-1.07/lib/Gravatar000755000765000024 012752745571 16141 5ustar00schwernstaff000000000000Gravatar-URL-1.07/lib/Gravatar/URL.pm000444000765000024 1464212752745571 17325 0ustar00schwernstaff000000000000package Gravatar::URL; use strict; use warnings; use URI::Escape qw(uri_escape); use Digest::MD5 qw(md5_hex); use Carp; our $VERSION = '1.07'; use parent 'Exporter'; our @EXPORT = qw( gravatar_id gravatar_url ); my $Gravatar_Http_Base = "http://www.gravatar.com/avatar/"; my $Gravatar_Https_Base = "https://secure.gravatar.com/avatar/"; =head1 NAME Gravatar::URL - Make URLs for Gravatars from an email address =head1 SYNOPSIS use Gravatar::URL; my $gravatar_id = gravatar_id($email); my $gravatar_url = gravatar_url(email => $email); =head1 DESCRIPTION A Gravatar is a Globally Recognized Avatar for a given email address. This allows you to have a global picture associated with your email address. You can look up the Gravatar for any email address by constructing a URL to get the image from L. This module does that. Examples of use include the author faces on L. See L for more info. =head1 Functions =head3 B # By email my $url = gravatar_url( email => $email, %options ); # By gravatar ID my $url = gravatar_url( id => $id, %options ); Constructs a URL to fetch the gravatar for a given C<$email> or C<$id>. C<$id> is a gravatar ID. See L for more information. C<%options> are optional and are... =head4 rating A user can rate how offensive the content of their gravatar is, like a movie. The ratings are g, pg, r and x. If you specify a rating it is the highest rating that will be given. rating => "r" # includes g, pg and r =head4 size Specifies the desired width and height of the gravatar (gravatars are square). Valid values are from 1 to 512 inclusive. Any size other than 80 may cause the original gravatar image to be downsampled using bicubic resampling before output. size => 40, # 40 x 40 image =head4 default The url to use if the user has no gravatar or has none that fits your rating requirements. default => "https://secure.wikimedia.org/wikipedia/en/wiki/File:Mad30.jpg" Relative URLs will be relative to the base (ie. gravatar.com), not your web site. Gravatar defines special values that you may use as a default to produce dynamic default images. These are "identicon", "monsterid", "wavatar" and "retro". "404" will cause the URL to return an HTTP 404 "Not Found" error instead whereas "mm" will display the same "mystery man" image for all missing people. See L for more info. If omitted, Gravatar will serve up their default image, the blue G. =head4 border B This key has been removed from the Gravatar protocol. It will be removed from future versions of Gravatar::URL. Gravatars can be requested to have a 1 pixel colored border. If you'd like that, pass in the color to border as a 3 or 6 digit hex string. border => "000000", # a black border, like my soul border => "000", # black, but in 3 digits =head4 base This is the URL of the location of the Gravatar server you wish to grab Gravatars from. Defaults to L for HTTP and L for HTTPS. =head4 short_keys If true, use short key names when constructing the URL. "s" instead of "size", "r" instead of "ratings" and so on. short_keys defaults to true. =head4 https If true, serve avatars over HTTPS instead of HTTP. You should select this option if your site is served over HTTPS to avoid browser warnings about the presence of insecure content. https defaults to false. =cut my %defaults = ( short_keys => 1, base_http => $Gravatar_Http_Base, base_https => $Gravatar_Https_Base, https => 0, ); sub gravatar_url { my %args = @_; exists $args{id} or exists $args{email} or croak "Cannot generate a Gravatar URI without an email address or gravatar id"; exists $args{id} xor exists $args{email} or croak "Both an id and an email were given. gravatar_url() only takes one"; _apply_defaults(\%args, \%defaults); if ( exists $args{size} ) { $args{size} >= 1 and $args{size} <= 512 or croak "Gravatar size must be 1 .. 512"; } if ( exists $args{rating} ) { $args{rating} =~ /\A(?:g|pg|r|x)\Z/i or croak "Gravatar rating can only be g, pg, r, or x"; $args{rating} = lc $args{rating}; } if ( exists $args{border} ) { carp "The border key is deprecated"; $args{border} =~ /\A[0-9A-F]{3}(?:[0-9A-F]{3})?\Z/ or croak "Border must be a 3 or 6 digit hex number in caps"; } $args{gravatar_id} = $args{id} || gravatar_id($args{email}); $args{default} = uri_escape($args{default}) if $args{default}; # Use a fixed order to make testing easier my @pairs; for my $arg ( qw( rating size default border ) ) { next unless exists $args{$arg}; my $key = $arg; $key = substr($key, 0, 1) if $args{short_keys}; push @pairs, join("=", $key, $args{$arg}); } my $uri = $args{base}; $uri .= "/" unless $uri =~ m{/$}; $uri .= $args{gravatar_id}; $uri .= "?".join("&",@pairs) if @pairs; return $uri; } sub _apply_defaults { my($hash, $defaults) = @_; for my $key (keys %$defaults) { next if 'base_http' eq $key or 'base_https' eq $key; next if exists $hash->{$key}; $hash->{$key} = $defaults->{$key}; } if (not exists $hash->{'base'}) { $hash->{'base'} = $hash->{'https'} ? $defaults->{base_https} : $defaults->{base_http}; } return; } =head3 B my $id = gravatar_id($email); Converts an C<$email> address into its Gravatar C<$id>. =cut sub gravatar_id { my $email = shift; return md5_hex(lc $email); } =head1 THANKS Thanks to L for coming up with the whole idea and Ashley Pond V from whose L I took most of the original code. =head1 LICENSE Copyright 2007 - 2009, Michael G Schwern . Copyright 2011, Francois Marier . This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See F =head1 SEE ALSO L - a Gravatar plugin for Template Toolkit L - The Gravatar web site L - The Gravatar URL implementor's guide =cut 1; Gravatar-URL-1.07/lib/Libravatar000755000765000024 012752745571 16461 5ustar00schwernstaff000000000000Gravatar-URL-1.07/lib/Libravatar/URL.pm000444000765000024 1731012752745571 17640 0ustar00schwernstaff000000000000package Libravatar::URL; use strict; use warnings; use Gravatar::URL qw(gravatar_url); use Digest::SHA qw(sha256_hex); use Carp; our $VERSION = '1.07'; use parent 'Exporter'; our @EXPORT = qw( libravatar_url ); my $Libravatar_Http_Base = "http://cdn.libravatar.org/avatar"; my $Libravatar_Https_Base = "https://seccdn.libravatar.org/avatar"; =head1 NAME Libravatar::URL - Make URLs for Libravatars from an email address =head1 SYNOPSIS use Libravatar::URL; my $url = libravatar_url( email => 'larry@example.org' ); =head1 DESCRIPTION See L for more information. =head1 Functions =head3 B # By email my $url = libravatar_url( email => $email, %options ); # By OpenID my $url = libravatar_url( openid => $openid, %options ); Constructs a URL to fetch the Libravatar for the given $email address or $openid URL. C<%options> are optional. C will accept all the options of L except for C and C. The available options are... =head4 size Specifies the desired width and height of the avatar (they are square). Valid values are from 1 to 512 inclusive. Any size other than 80 may cause the original image to be downsampled using bicubic resampling before output. size => 40, # 40 x 40 image =head4 default The url to use if the user has no avatar. default => "http://www.example.org/nobody.jpg" Relative URLs will be relative to the base (ie. libravatar.org), not your web site. Libravatar defines special values that you may use as a default to produce dynamic default images. These are "identicon", "monsterid", "wavatar" and "retro". "404" will cause the URL to return an HTTP 404 "Not Found" error instead and "mm" will display the same "mystery man" image for everybody. See L for more info. If omitted, Libravatar will serve up their default image, the orange butterfly. =head4 base This is the URL of the location of the Libravatar server you wish to grab avatars from. Defaults to L for HTTP and L for HTTPS. =head4 short_keys If true, use short key names when constructing the URL. "s" instead of "size", "d" instead of "default" and so on. short_keys defaults to true. =head4 https If true, serve avatars over HTTPS instead of HTTP. You should select this option if your site is served over HTTPS to avoid browser warnings about the presence of insecure content. https defaults to false. =cut my %defaults = ( short_keys => 1, ); # Extract the domain component of an email address sub email_domain { my ( $email ) = @_; return undef unless $email; if ( $email =~ m/@([^@]+)$/ ) { return $1; } return undef; } # Extract the domain component of an OpenID URI sub openid_domain { my ( $openid ) = @_; return undef unless $openid; if ( $openid =~ m@^(http|https)://([^/]+)@i ) { return $2; } return undef; } # Return the right (target, port) pair from a list of SRV records sub srv_hostname { my @records = @_; return ( undef, undef ) unless scalar(@records) > 0; if ( 1 == scalar(@records) ) { my $rr = shift @records; return ( $rr->target, $rr->port ); } # Keep only the servers in the top priority my @priority_records; my $total_weight = 0; my $top_priority = $records[0]->priority; # highest priority = lowest number foreach my $rr (@records) { if ( $rr->priority > $top_priority ) { # ignore the record ($rr has lower priority) next; } elsif ( $rr->priority < $top_priority ) { # reset the array ($rr has higher priority) $top_priority = $rr->priority; $total_weight = 0; @priority_records = (); } $total_weight += $rr->weight; if ( $rr->weight > 0 ) { push @priority_records, [ $total_weight, $rr ]; } else { # Zero-weigth elements must come first unshift @priority_records, [ 0, $rr ]; } } if ( 1 == scalar(@priority_records) ) { my $record = shift @priority_records; my ( $weighted_index, $rr ) = @$record; return ( $rr->target, $rr->port ); } # Select first record according to RFC2782 weight ordering algorithm (page 3) my $random_number = int(rand($total_weight + 1)); foreach my $record (@priority_records) { my ( $weighted_index, $rr ) = @$record; if ( $weighted_index >= $random_number ) { return ( $rr->target, $rr->port ); } } die 'There is something wrong with our SRV weight ordering algorithm'; } # Convert (target, port) to a full avatar base URL sub build_url { my ( $target, $port, $https ) = @_; return undef unless $target; my $url = $https ? 'https' : 'http' . '://' . $target; if ( $port && !$https && ($port != 80) or $port && $https && ($port != 443) ) { $url .= ':' . $port; } $url .= '/avatar'; return $url; } sub sanitize_target { my ( $target, $port ) = @_; unless ( defined $target && $target =~ m/^[0-9a-zA-Z\-.]+$/ ) { return ( undef, undef ); } unless ( defined $port && $port =~ m/^[0-9]{1,5}$/ ) { return ( undef, undef ); } return ( $target, $port ) } sub federated_url { my %args = @_; my $domain; if ( exists $args{email} ) { $domain = email_domain($args{email}); } elsif ( exists $args{openid} ) { $domain = openid_domain($args{openid}); } return undef unless $domain; require Net::DNS::Resolver; my $fast_resolver = Net::DNS::Resolver->new(retry => 1, tcp_timeout => 1, udp_timeout => 1, dnssec => 1); my $srv_prefix = $args{https} ? '_avatars-sec' : '_avatars'; my $packet = $fast_resolver->query($srv_prefix . '._tcp.' . $domain, 'SRV'); if ( $packet and $packet->answer ) { my ( $target, $port ) = sanitize_target(srv_hostname($packet->answer)); return build_url($target, $port, $args{https}); } return undef; } sub lowercase_openid { my $openid = shift; if ( $openid =~ m@^([^:]+://[^/]+)(.*)@ ) { $openid = (lc $1) . $2; } return $openid; } sub libravatar_url { my %args = @_; my $custom_base = defined $args{base}; exists $args{email} or exists $args{openid} or exists $args{id} or croak "Cannot generate a Libravatar URI without an email address, an OpenID or a gravatar id"; if ( exists $args{email} and (exists $args{openid} or exists $args{id}) or exists $args{openid} and (exists $args{email} or exists $args{id}) or exists $args{id} and (exists $args{email} or exists $args{openid}) ) { croak "Two or more identifiers (email, OpenID or gravatar id) were given. libravatar_url() only takes one"; } $defaults{base_http} = $Libravatar_Http_Base; $defaults{base_https} = $Libravatar_Https_Base; Gravatar::URL::_apply_defaults(\%args, \%defaults); if ( !$custom_base ) { my $federated_url = federated_url(%args); if ( $federated_url ) { $args{base} = $federated_url; } } if ( exists $args{openid} ) { $args{id} = sha256_hex(lowercase_openid($args{openid})); undef $args{openid}; } return gravatar_url(%args); } =head1 LICENSE Copyright 2011, Francois Marier . This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See F =head1 SEE ALSO L - The Libravatar web site L - The Libravatar API documentation =cut 1; Gravatar-URL-1.07/lib/Unicornify000755000765000024 012752745571 16517 5ustar00schwernstaff000000000000Gravatar-URL-1.07/lib/Unicornify/URL.pm000444000765000024 253412752745571 17660 0ustar00schwernstaff000000000000package Unicornify::URL; use strict; use warnings; our $VERSION = '1.07'; use Gravatar::URL qw(gravatar_url); use parent 'Exporter'; our @EXPORT = qw( unicornify_url ); my $Unicornify_Base = "http://unicornify.appspot.com/avatar/"; =head1 NAME Unicornify::URL - OMG UNICORN AVATAR! =head1 SYNOPSIS use Unicornify::URL; my $url = unicornify_url( email => 'larry@wall.org' ); =head1 DESCRIPTION Now you can have your very own generated Unicorn avatar! OMG! SQUEE! See L for more information. *heart* =head1 Functions =head3 B my $url = unicornify_url( email => $email, %options ); Constructs a URL to fetch the unicorn avatar for the given $email address. C<%options> are optional. C will accept all the options of L but as of this time only C has any effect. =head4 size Specifies the desired width and height of the avatar (they are square) in pixels. As of this writing, valid values are from 32 to 128. The default is 32. =head1 SEE ALSO L L "The Last Unicorn" =cut my %defaults = ( base => $Unicornify_Base, short_keys => 1, ); sub unicornify_url { my %args = @_; Gravatar::URL::_apply_defaults(\%args, \%defaults); return gravatar_url(%args); } "OMG! UNICORNS!"; Gravatar-URL-1.07/t000755000765000024 012752745571 14067 5ustar00schwernstaff000000000000Gravatar-URL-1.07/t/deprecated.t000444000765000024 76212752745571 16476 0ustar00schwernstaff000000000000#!/usr/bin/perl -w # Test that deprecated keys warn. use strict; use Test::More 'no_plan'; use Test::Warn; use Gravatar::URL; my $id = 'a60fc0828e808b9a6a9d50f1792240c8'; my $email = 'whatever@wherever.whichever'; my $base = 'http://www.gravatar.com/avatar'; warning_is { is gravatar_url( id => '12345', base => 'http://www.example.com/gravatar', border => "FFF" ), "http://www.example.com/gravatar/12345?b=FFF"; } {carped => "The border key is deprecated"}; Gravatar-URL-1.07/t/error.t000444000765000024 214712752745571 15546 0ustar00schwernstaff000000000000#!/usr/bin/perl -w # Test argument error handling. use strict; use Test::More 'no_plan'; BEGIN { use_ok 'Gravatar::URL' } my @tests = ( [ {}, "Cannot generate a Gravatar URI without an email address or gravatar id" ], [ { email => 'foo@bar.com', id => '12345' }, "Both an id and an email were given. gravatar_url() only takes one" ], [ { email => 'foo@bar.com', rating => 'Q' }, "Gravatar rating can only be g, pg, r, or x" ], [ { email => 'foo@bar.com', size => 0 }, "Gravatar size must be 1 .. 512" ], [ { email => 'foo@bar.com', size => 1 } ], [ { email => 'foo@bar.com', size => 512 } ], [ { email => 'foo@bar.com', size => 513 }, "Gravatar size must be 1 .. 512" ], ); for my $test (@tests) { my($args, $want) = @$test; eval { gravatar_url( %$args ) }; my $error = $@; $error =~ s/\.\n/\n/; $want = !$want ? "" : sprintf "%s at %s line %d\n", $want, $0, __LINE__ - 5; my $name = join ", ", map { "$_ => '$args->{$_}'" } keys %$args; is $error, $want, "gravatar_url($name)"; } Gravatar-URL-1.07/t/id.t000444000765000024 135112752745571 15005 0ustar00schwernstaff000000000000#!/usr/bin/perl -w use strict; use Test::More 'no_plan'; BEGIN { use_ok "Gravatar::URL" } my %email2id = ( 'alfred@example.com' => '6ffc501bf3b215384ea3abd3b6026735', 'whatever@wherever.whichever' => 'a60fc0828e808b9a6a9d50f1792240c8', 'PHRED@cpan.org' => 'c18b1af66a7f62015ecc26707a1321b9', 'iHaveAn@email.com', => '3b3be63a4c2a439b013787725dfce802', ); for my $email (keys %email2id) { my $id = $email2id{$email}; is gravatar_id( $email ) => $id, "$email"; is gravatar_id( lc $email ) => $id, "lc $email"; is gravatar_id( uc $email ) => $id, "uc $email"; is gravatar_id( ucfirst $email ) => $id, "ucfirst $email"; } Gravatar-URL-1.07/t/libravatar.t000555000765000024 1437312752745571 16573 0ustar00schwernstaff000000000000#!/usr/bin/perl -w use Test::More; use Test::MockRandom 'Libravatar::URL'; BEGIN { use_ok 'Net::DNS'; use_ok 'Libravatar::URL'; } { my @email_domain_tests = ( ['', undef, ], ['notanemail', undef, ], ['larry@example.com', 'example.com', ], ['larry@example.com@example.org', 'example.org', ], ['@example.org', 'example.org', ], ['larry@@example.com', 'example.com', ], ); for my $test (@email_domain_tests) { my ($email, $domain) = @$test; is Libravatar::URL::email_domain($email), $domain; } my @openid_domain_tests = ( ['', undef, ], ['notanopenid', undef, ], ['http://example.com', 'example.com', ], ['https://a.example.com', 'a.example.com', ], ['http://b.example.com/', 'b.example.com', ], ['http://example.org/id/larry', 'example.org', ], ['https://a.example.org/~larry/openid.html', 'a.example.org', ], ); for my $test (@openid_domain_tests) { my ($openid, $domain) = @$test; is Libravatar::URL::openid_domain($openid), $domain; } my @lowercase_openid = ( ['', '', ], ['notanopenid', 'notanopenid', ], ['http://Example.Com', 'http://example.com', ], ['HTTPS://a.example.com', 'https://a.example.com', ], ['http://b.eXample.com/', 'http://b.example.com/', ], ['http://example.ORG/ID/Larry', 'http://example.org/ID/Larry', ], ['Https://A.example.org/~Larry/OpenID.html', 'https://a.example.org/~Larry/OpenID.html', ], ); for my $test (@lowercase_openid) { my ($openid, $lc_openid) = @$test; is Libravatar::URL::lowercase_openid($openid), $lc_openid; } my @url_tests = ( [undef, undef, undef, ], ['example.com', undef, 'http://example.com/avatar', ], ['example.com', 80, 'http://example.com/avatar', ], ['example.com', 81, 'http://example.com:81/avatar', ], ); for my $test (@url_tests) { my ($target, $port, $url) = @$test; is Libravatar::URL::build_url($target, $port), $url; } my @sanitization_tests = ( [undef, undef, [undef, undef], ], ['example.com', undef, [undef, undef], ], ['example.com', 80, ['example.com', 80], ], ['example.org', 81, ['example.org', 81], ], ); for my $test (@sanitization_tests) { my ($target, $port, $pair) = @$test; my @result = Libravatar::URL::sanitize_target($target, $port); is_deeply \@result, $pair; } my @srv_tests = ( [[ ], [undef, undef], ], [['_avatars._tcp.example.com. IN SRV 0 0 80 avatars.example.com', ], ['avatars.example.com', 80], ], [['_avatars._tcp.example.com. IN SRV 10 0 81 avatars2.example.com', '_avatars._tcp.example.com. IN SRV 0 0 80 avatars.example.com', ], ['avatars.example.com', 80], ], [['_avatars._tcp.example.com. IN SRV 10 0 83 avatars4.example.com', '_avatars._tcp.example.com. IN SRV 10 0 82 avatars3.example.com', '_avatars._tcp.example.com. IN SRV 1 0 81 avatars21.example.com', '_avatars._tcp.example.com. IN SRV 10 0 80 avatars.example.com', ], ['avatars21.example.com', 81], ], # The following ones are randomly selected which is why we # have to initialize the random number to a canned value # random_number = 49 [['_avatars._tcp.example.com. IN SRV 10 1 83 avatars4.example.com', '_avatars._tcp.example.com. IN SRV 10 5 82 avatars3.example.com', '_avatars._tcp.example.com. IN SRV 10 10 8100 avatars2.example.com', '_avatars._tcp.example.com. IN SRV 10 50 800 avatars1.example.com', '_avatars._tcp.example.com. IN SRV 20 0 80 avatars.example.com', ], ['avatars1.example.com', 800], ], # random_number = 0 [['_avatars._tcp.example.com. IN SRV 10 1 83 avatars4.example.com', '_avatars._tcp.example.com. IN SRV 10 0 82 avatars3.example.com', '_avatars._tcp.example.com. IN SRV 20 0 81 avatars2.example.com', '_avatars._tcp.example.com. IN SRV 20 0 80 avatars.example.com', ], ['avatars3.example.com', 82], ], # random_number = 1 [['_avatars._tcp.example.com. IN SRV 10 0 83 avatars4.example.com', '_avatars._tcp.example.com. IN SRV 10 0 82 avatars3.example.com', '_avatars._tcp.example.com. IN SRV 10 10 601 avatars20.example.com', '_avatars._tcp.example.com. IN SRV 20 0 80 avatars.example.com', ], ['avatars20.example.com', 601], ], # random_number = 40 [['_avatars._tcp.example.com. IN SRV 10 1 83 avatars4.example.com', '_avatars._tcp.example.com. IN SRV 10 5 82 avatars3.example.com', '_avatars._tcp.example.com. IN SRV 10 10 8100 avatars2.example.com', '_avatars._tcp.example.com. IN SRV 10 30 8 avatars10.example.com', '_avatars._tcp.example.com. IN SRV 10 50 800 avatars1.example.com', '_avatars._tcp.example.com. IN SRV 20 0 80 avatars.example.com', ], ['avatars10.example.com', 8], ], ); srand(0.74,0,0.1,0.42); # to make these tests predictable for my $test (@srv_tests) { my ($srv_strings, $pair) = @$test; my @srv_records = (); for $str (@$srv_strings) { my $record = Net::DNS::RR->new($str); push @srv_records, $record; } my @result = Libravatar::URL::srv_hostname(@srv_records); is_deeply \@result, $pair; } $test_count = @email_domain_tests + @openid_domain_tests + @lowercase_openid + @url_tests + @sanitization_tests + @srv_tests + 2; done_testing($test_count); } Gravatar-URL-1.07/t/unicornify.t000444000765000024 55312752745571 16561 0ustar00schwernstaff000000000000#!/usr/bin/perl use strict; use warnings; use Test::More tests => 2; use Unicornify::URL; is unicornify_url( email => 'yarrow@hock.com' ), 'http://unicornify.appspot.com/avatar/c5cf0e825e9757a09c43f08650f46a5f'; is unicornify_url( email => 'yarrow@hock.com', size => 128 ), 'http://unicornify.appspot.com/avatar/c5cf0e825e9757a09c43f08650f46a5f?s=128'; Gravatar-URL-1.07/t/url.t000555000765000024 660312752745571 15223 0ustar00schwernstaff000000000000#!/usr/bin/perl -w use Test::More 'no_plan'; BEGIN { use_ok 'Gravatar::URL'; use_ok 'Libravatar::URL'; } my %interfaces = ( libravatar => { func => \&libravatar_url, base => 'http://cdn.libravatar.org/avatar', https_base => 'https://seccdn.libravatar.org/avatar', }, gravatar => { func => \&gravatar_url, base => 'http://www.gravatar.com/avatar', https_base => 'https://secure.gravatar.com/avatar', }, ); for my $interface_name (keys %interfaces) { my $interface = $interfaces{$interface_name}; my $base = $interface->{base}; my $https_base = $interface->{https_base}; my $func = $interface->{func}; my $id = 'a60fc0828e808b9a6a9d50f1792240c8'; my $email = 'whatever@wherever.whichever'; my @tests = ( [{ email => $email }, "$base/$id", ], [{ id => $id }, "$base/$id", ], [{ email => $email, https => 1 }, "$https_base/$id", ], [{ email => $email, https => 0 }, "$base/$id", ], [{ email => $email, base => 'http://example.com/gravatar' }, "http://example.com/gravatar/$id", ], [{ email => $email, base => 'http://example.com/gravatar', https => 1 }, "http://example.com/gravatar/$id", ], # Make sure we don't get a double slash after the base. [{ email => $email, base => 'http://example.com/gravatar/' }, "http://example.com/gravatar/$id", ], [{ default => "/local.png", email => $email }, "$base/$id?d=%2Flocal.png", ], [{ default => "/local.png", rating => 'X', email => $email, }, "$base/$id?r=x&d=%2Flocal.png", ], [{ default => "/local.png", email => $email, rating => 'R', size => 80 }, "$base/$id?r=r&s=80&d=%2Flocal.png" ], [{ default => "/local.png", rating => 'PG', size => 45, email => $email, }, "$base/$id?r=pg&s=45&d=%2Flocal.png" ], [{ default => "/local.png", rating => 'PG', size => 45, email => $email, }, "$base/$id?r=pg&s=45&d=%2Flocal.png" ], [{ default => "/local.png", rating => 'PG', size => 45, email => $email, short_keys => 1, }, "$base/$id?r=pg&s=45&d=%2Flocal.png" ], [{ default => "/local.png", rating => 'PG', size => 45, email => $email, short_keys => 0, }, "$base/$id?rating=pg&size=45&default=%2Flocal.png" ], ); # Add tests for the special defaults. for my $special ("identicon", "mm", "monsterid", "retro", "wavatar") { my $test = [{ default => $special, email => $email, }, "$base/$id?d=$special", ]; push @tests, $test; } for my $test (@tests) { my($args, $url) = @$test; is &$func( %$args ), $url, join ", ", keys %$args; } }