r72093 - in /trunk/libgravatar-url-perl: Build.PL Changes MANIFEST META.yml SIGNATURE debian/changelog debian/control debian/copyright lib/Gravatar/URL.pm lib/Libravatar/URL.pm lib/Unicornify/URL.pm t/libravatar.t
angelabad-guest at users.alioth.debian.org
angelabad-guest at users.alioth.debian.org
Thu Mar 31 11:21:31 UTC 2011
Author: angelabad-guest
Date: Thu Mar 31 11:21:15 2011
New Revision: 72093
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=72093
Log:
* New upstream release
* debian/copyright: Update copyright information
* Add myself to Uploaders
Added:
trunk/libgravatar-url-perl/SIGNATURE
- copied unchanged from r72091, branches/upstream/libgravatar-url-perl/current/SIGNATURE
Modified:
trunk/libgravatar-url-perl/Build.PL
trunk/libgravatar-url-perl/Changes
trunk/libgravatar-url-perl/MANIFEST
trunk/libgravatar-url-perl/META.yml
trunk/libgravatar-url-perl/debian/changelog
trunk/libgravatar-url-perl/debian/control
trunk/libgravatar-url-perl/debian/copyright
trunk/libgravatar-url-perl/lib/Gravatar/URL.pm
trunk/libgravatar-url-perl/lib/Libravatar/URL.pm
trunk/libgravatar-url-perl/lib/Unicornify/URL.pm
trunk/libgravatar-url-perl/t/libravatar.t
Modified: trunk/libgravatar-url-perl/Build.PL
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libgravatar-url-perl/Build.PL?rev=72093&op=diff
==============================================================================
--- trunk/libgravatar-url-perl/Build.PL (original)
+++ trunk/libgravatar-url-perl/Build.PL Thu Mar 31 11:21:15 2011
@@ -33,6 +33,7 @@
'Net::DNS::Resolver' => 0,
'URI::Escape' => 0,
'Digest::MD5' => 0,
+ 'Digest::SHA' => 0,
'Carp' => 0,
perl => '5.6.0',
'parent' => 0,
Modified: trunk/libgravatar-url-perl/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libgravatar-url-perl/Changes?rev=72093&op=diff
==============================================================================
--- trunk/libgravatar-url-perl/Changes (original)
+++ trunk/libgravatar-url-perl/Changes Thu Mar 31 11:21:15 2011
@@ -1,3 +1,7 @@
+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
Modified: trunk/libgravatar-url-perl/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libgravatar-url-perl/MANIFEST?rev=72093&op=diff
==============================================================================
--- trunk/libgravatar-url-perl/MANIFEST (original)
+++ trunk/libgravatar-url-perl/MANIFEST Thu Mar 31 11:21:15 2011
@@ -12,3 +12,4 @@
t/libravatar.t
t/unicornify.t
t/url.t
+SIGNATURE Added here by Module::Build
Modified: trunk/libgravatar-url-perl/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libgravatar-url-perl/META.yml?rev=72093&op=diff
==============================================================================
--- trunk/libgravatar-url-perl/META.yml (original)
+++ trunk/libgravatar-url-perl/META.yml Thu Mar 31 11:21:15 2011
@@ -1,6 +1,6 @@
---
name: Gravatar-URL
-version: 1.03
+version: 1.04
author: []
abstract: Make URLs for Gravatars from an email address
license: perl
@@ -14,6 +14,7 @@
requires:
Carp: 0
Digest::MD5: 0
+ Digest::SHA: 0
Net::DNS::Resolver: 0
URI::Escape: 0
parent: 0
@@ -23,13 +24,13 @@
provides:
Gravatar::URL:
file: lib/Gravatar/URL.pm
- version: 1.03
+ version: 1.04
Libravatar::URL:
file: lib/Libravatar/URL.pm
- version: 1.03
+ version: 1.04
Unicornify::URL:
file: lib/Unicornify/URL.pm
- version: 1.03
+ version: 1.04
generated_by: Module::Build version 0.340201
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
Modified: trunk/libgravatar-url-perl/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libgravatar-url-perl/debian/changelog?rev=72093&op=diff
==============================================================================
--- trunk/libgravatar-url-perl/debian/changelog (original)
+++ trunk/libgravatar-url-perl/debian/changelog Thu Mar 31 11:21:15 2011
@@ -1,3 +1,11 @@
+libgravatar-url-perl (1.04-1) unstable; urgency=low
+
+ * New upstream release
+ * debian/copyright: Update copyright information
+ * Add myself to Uploaders
+
+ -- Angel Abad <angelabad at gmail.com> Thu, 31 Mar 2011 13:20:58 +0200
+
libgravatar-url-perl (1.03-1) unstable; urgency=low
* New upstream release.
Modified: trunk/libgravatar-url-perl/debian/control
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libgravatar-url-perl/debian/control?rev=72093&op=diff
==============================================================================
--- trunk/libgravatar-url-perl/debian/control (original)
+++ trunk/libgravatar-url-perl/debian/control Thu Mar 31 11:21:15 2011
@@ -1,10 +1,15 @@
Source: libgravatar-url-perl
Section: perl
Priority: optional
-Build-Depends: debhelper (>= 7), perl
-Build-Depends-Indep: libnet-dns-perl, libtest-warn-perl (>= 0.11), liburi-perl
+Build-Depends: debhelper (>= 7),
+ perl
+Build-Depends-Indep: libnet-dns-perl,
+ libtest-warn-perl (>= 0.11),
+ liburi-perl
Maintainer: Debian Perl Group <pkg-perl-maintainers at lists.alioth.debian.org>
-Uploaders: Ryan Niebur <ryan at debian.org>, Ansgar Burchardt <ansgar at debian.org>
+Uploaders: Ryan Niebur <ryan at debian.org>,
+ Ansgar Burchardt <ansgar at debian.org>,
+ Angel Abad <angelabad at gmail.com>
Standards-Version: 3.9.1
Homepage: http://search.cpan.org/dist/Gravatar-URL/
Vcs-Svn: svn://svn.debian.org/pkg-perl/trunk/libgravatar-url-perl/
@@ -12,7 +17,9 @@
Package: libgravatar-url-perl
Architecture: all
-Depends: ${misc:Depends}, ${perl:Depends}, libnet-dns-perl, liburi-perl
+Depends: ${misc:Depends}, ${perl:Depends},
+ libnet-dns-perl,
+ liburi-perl
Description: Perl interface to make URLs for Gravatars from an email address
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
Modified: trunk/libgravatar-url-perl/debian/copyright
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libgravatar-url-perl/debian/copyright?rev=72093&op=diff
==============================================================================
--- trunk/libgravatar-url-perl/debian/copyright (original)
+++ trunk/libgravatar-url-perl/debian/copyright Thu Mar 31 11:21:15 2011
@@ -3,13 +3,14 @@
Source: http://search.cpan.org/dist/Gravatar-URL/
Name: Gravatar-URL
-Copyright:
- 2007-2009, Michael G Schwern <schwern at pobox.com>
- 2011, Francois Marier <fmarier at gmail.com>
+Copyright: 2007-2009, Michael G Schwern <schwern at pobox.com>
+ 2011, Francois Marier <fmarier at gmail.com>
License: Artistic or GPL-1+
Files: debian/*
-Copyright: 2009, Ryan Niebur <ryan at debian.org>
+Copyright: 2009, Ryan Niebur <ryanryan52 at gmail.com>
+ 2011, Angel Abad <angelabad at gmail.com>
+ 2010-2011, Ansgar Burchardt <ansgar at debian.org>
License: Artistic or GPL-1+
License: Artistic
@@ -17,7 +18,7 @@
it under the terms of the Artistic License, which comes with Perl.
.
On Debian systems, the complete text of the Artistic License can be
- found in `/usr/share/common-licenses/Artistic'
+ found in `/usr/share/common-licenses/Artistic'.
License: GPL-1+
This program is free software; you can redistribute it and/or modify
Modified: trunk/libgravatar-url-perl/lib/Gravatar/URL.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libgravatar-url-perl/lib/Gravatar/URL.pm?rev=72093&op=diff
==============================================================================
--- trunk/libgravatar-url-perl/lib/Gravatar/URL.pm (original)
+++ trunk/libgravatar-url-perl/lib/Gravatar/URL.pm Thu Mar 31 11:21:15 2011
@@ -7,7 +7,7 @@
use Digest::MD5 qw(md5_hex);
use Carp;
-our $VERSION = '1.03';
+our $VERSION = '1.04';
use parent 'Exporter';
our @EXPORT = qw(
Modified: trunk/libgravatar-url-perl/lib/Libravatar/URL.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libgravatar-url-perl/lib/Libravatar/URL.pm?rev=72093&op=diff
==============================================================================
--- trunk/libgravatar-url-perl/lib/Libravatar/URL.pm (original)
+++ trunk/libgravatar-url-perl/lib/Libravatar/URL.pm Thu Mar 31 11:21:15 2011
@@ -3,9 +3,11 @@
use strict;
use warnings;
-our $VERSION = '1.03';
-
use Gravatar::URL qw(gravatar_url);
+use Digest::SHA qw(sha256_hex);
+use Carp;
+
+our $VERSION = '1.04';
use parent 'Exporter';
our @EXPORT = qw(
@@ -33,9 +35,13 @@
=head3 B<libravatar_url>
+ # By email
my $url = libravatar_url( email => $email, %options );
-Constructs a URL to fetch the Libravatar for the given $email address.
+ # 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<libravatar_url> will accept all the
options of L<Gravatar::URL/gravatar_url> except for C<rating> and C<border>.
@@ -97,13 +103,24 @@
short_keys => 1,
);
-# Extra the domain component of an email address
+# 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;
}
@@ -181,37 +198,66 @@
}
sub federated_url {
- my ( $email, $https ) = @_;
- my $domain = email_domain($email);
+ 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 = $https ? '_avatars-sec' : '_avatars';
+ 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 ) = srv_hostname($packet->answer);
- return build_url($target, $port, $https);
+ 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{email}, $args{https});
+ 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);
}
Modified: trunk/libgravatar-url-perl/lib/Unicornify/URL.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libgravatar-url-perl/lib/Unicornify/URL.pm?rev=72093&op=diff
==============================================================================
--- trunk/libgravatar-url-perl/lib/Unicornify/URL.pm (original)
+++ trunk/libgravatar-url-perl/lib/Unicornify/URL.pm Thu Mar 31 11:21:15 2011
@@ -3,7 +3,7 @@
use strict;
use warnings;
-our $VERSION = '1.03';
+our $VERSION = '1.04';
use Gravatar::URL qw(gravatar_url);
Modified: trunk/libgravatar-url-perl/t/libravatar.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libgravatar-url-perl/t/libravatar.t?rev=72093&op=diff
==============================================================================
--- trunk/libgravatar-url-perl/t/libravatar.t (original)
+++ trunk/libgravatar-url-perl/t/libravatar.t Thu Mar 31 11:21:15 2011
@@ -6,7 +6,7 @@
use_ok 'Libravatar::URL'; }
{
- my @domain_tests = (
+ my @email_domain_tests = (
['',
undef,
],
@@ -32,9 +32,79 @@
],
);
- for my $test (@domain_tests) {
+ 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 = (
@@ -143,6 +213,6 @@
is_deeply \@result, $pair;
}
- $test_count = @domain_tests + @url_tests + @srv_tests + 2;
+ $test_count = @email_domain_tests + @openid_domain_tests + @lowercase_openid + @url_tests + @srv_tests + 2;
done_testing($test_count);
}
More information about the Pkg-perl-cvs-commits
mailing list