From 7238b6b1fa550dc72e9438dc9796f7d7bee1ca96 Mon Sep 17 00:00:00 2001 From: Jessica Yu Date: Tue, 21 Aug 2012 15:45:28 -0700 Subject: [PATCH 1/8] working Gravatar plugin --- lib/DDG/Goodie/Gravatar.pm | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 lib/DDG/Goodie/Gravatar.pm diff --git a/lib/DDG/Goodie/Gravatar.pm b/lib/DDG/Goodie/Gravatar.pm new file mode 100644 index 000000000..6ac2c68ee --- /dev/null +++ b/lib/DDG/Goodie/Gravatar.pm @@ -0,0 +1,23 @@ +package DDG::Goodie::Gravatar; +# ABSTRACT: Return Gravatar image given an email address + +use CGI qw/img/; +use DDG::Goodie; +use Email::Valid; +use Gravatar::URL; + +triggers start => 'gravatar'; + +handle remainder => sub { + if(Email::Valid->address($_)){ + return img({src=>gravatar_url(email => $_, default => "mm")}); + } else { + return; + } +}; + +zci is_cached => 1; + +1; + + From 192c4dc70748f2fb30f6eb9ab4d1b9ad5924caab Mon Sep 17 00:00:00 2001 From: Jessica Yu Date: Tue, 21 Aug 2012 21:59:32 -0700 Subject: [PATCH 2/8] added new dependencies to dist.ini, new test file --- dist.ini | 3 +++ lib/DDG/Goodie/Gravatar.pm | 2 +- t/Gravatar.t | 17 +++++++++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 t/Gravatar.t diff --git a/dist.ini b/dist.ini index 7686d585f..08e1d680c 100644 --- a/dist.ini +++ b/dist.ini @@ -24,6 +24,9 @@ Locale::SubCountry = 1.47 Unicode::Char = 0.02 Number::UN = 0.002 Locale::Language = 3.21 +Gravatar::URL = 1.06 +CGI = 3.60 +Email::Valid = 0.190 ; ParseCron Schedule::Cron::Events = 0 Convert::Color = 0.08 diff --git a/lib/DDG/Goodie/Gravatar.pm b/lib/DDG/Goodie/Gravatar.pm index 6ac2c68ee..3a10cf82d 100644 --- a/lib/DDG/Goodie/Gravatar.pm +++ b/lib/DDG/Goodie/Gravatar.pm @@ -1,8 +1,8 @@ package DDG::Goodie::Gravatar; # ABSTRACT: Return Gravatar image given an email address -use CGI qw/img/; use DDG::Goodie; +use CGI qw/img/; use Email::Valid; use Gravatar::URL; diff --git a/t/Gravatar.t b/t/Gravatar.t new file mode 100644 index 000000000..fe4fb9be1 --- /dev/null +++ b/t/Gravatar.t @@ -0,0 +1,17 @@ +#!/usr/bin/env perl + +use strict; +use warnings; +use Test::More; +use DDG::Test::Goodie; + +zci answer_type => 'gravatar'; +zci is_cached => 1; +ddg_goodie_test( + [qw( + DDG::Goodie::Gravatar + )], + 'gravatar kumimoko.yo@gmail.com' => test_zci(''), +); + +done_testing; From 0491a00a78deed49a3dd093ae5036faf18d9326f Mon Sep 17 00:00:00 2001 From: Jessica Yu Date: Wed, 22 Aug 2012 00:10:11 -0700 Subject: [PATCH 3/8] OMG UNICORNS --- lib/DDG/Goodie/Unicornify.pm | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 lib/DDG/Goodie/Unicornify.pm diff --git a/lib/DDG/Goodie/Unicornify.pm b/lib/DDG/Goodie/Unicornify.pm new file mode 100644 index 000000000..d2e9abf75 --- /dev/null +++ b/lib/DDG/Goodie/Unicornify.pm @@ -0,0 +1,19 @@ +package DDG::Goodie::Unicornify; +# ABSTRACT: Return Gravatar image given an email address + +use DDG::Goodie; +use CGI qw/img/; +use Email::Valid; +use Unicornify::URL; + +triggers start => 'unicornify'; + +handle remainder => sub { + return img({src=>unicornify_url(email => $_, size => "100")}) if (Email::Valid->address($_)); + return; +}; + +zci is_cached => 1; + +1; + From 816c74cd9408f45e2c0577506447001843339bd2 Mon Sep 17 00:00:00 2001 From: Jessica Yu Date: Thu, 6 Sep 2012 15:34:16 -0700 Subject: [PATCH 4/8] Fixed html output --- lib/DDG/Goodie/Unicornify.pm | 12 +++++++++++- t/Unicornify.t | 24 ++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 t/Unicornify.t diff --git a/lib/DDG/Goodie/Unicornify.pm b/lib/DDG/Goodie/Unicornify.pm index d2e9abf75..184adc0fa 100644 --- a/lib/DDG/Goodie/Unicornify.pm +++ b/lib/DDG/Goodie/Unicornify.pm @@ -8,8 +8,18 @@ use Unicornify::URL; triggers start => 'unicornify'; + handle remainder => sub { - return img({src=>unicornify_url(email => $_, size => "100")}) if (Email::Valid->address($_)); + my $link = 'http://unicornify.appspot.com/'; + if (Email::Valid->address($_)) { + s/[\s\t]+//g; # strip whitespace from the remainder, we just need the email address. + + return $_ . '\'s unicorn:', + html => '

Learn more at unicornify.appspot.com'; + } return; }; diff --git a/t/Unicornify.t b/t/Unicornify.t new file mode 100644 index 000000000..6ac661dc8 --- /dev/null +++ b/t/Unicornify.t @@ -0,0 +1,24 @@ +#!/usr/bin/env perl + +use strict; +use warnings; +use Test::More; +use DDG::Test::Goodie; +use Unicornify::URL; + + +zci answer_type => 'unicornify'; +zci is_cached => 1; +ddg_goodie_test( + [qw( + DDG::Goodie::Unicornify + )], + 'unicornify bob@bob.com' => + test_zci('bob@bob.com\'s unicorn:', + html => '

Learn more at unicornify.appspot.com')); + +done_testing; From 4555f7c0d6e6e4f94ad0f68fb6f611be193643fa Mon Sep 17 00:00:00 2001 From: Jessica Yu Date: Thu, 6 Sep 2012 15:50:31 -0700 Subject: [PATCH 5/8] fixed format and fixed wrong email in test file --- lib/DDG/Goodie/Unicornify.pm | 8 ++++---- t/Unicornify.t | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/DDG/Goodie/Unicornify.pm b/lib/DDG/Goodie/Unicornify.pm index 184adc0fa..983a32167 100644 --- a/lib/DDG/Goodie/Unicornify.pm +++ b/lib/DDG/Goodie/Unicornify.pm @@ -15,10 +15,10 @@ handle remainder => sub { s/[\s\t]+//g; # strip whitespace from the remainder, we just need the email address. return $_ . '\'s unicorn:', - html => '

Learn more at unicornify.appspot.com'; + html => $_.'\'s unicorn:' + .'
' + .'' + .'
Learn more at unicornify.appspot.com'; } return; }; diff --git a/t/Unicornify.t b/t/Unicornify.t index 6ac661dc8..3a7ea1071 100644 --- a/t/Unicornify.t +++ b/t/Unicornify.t @@ -15,10 +15,10 @@ ddg_goodie_test( )], 'unicornify bob@bob.com' => test_zci('bob@bob.com\'s unicorn:', - html => '
'bob@bob.com', size => 128) .'">
Learn more at unicornify.appspot.com')); done_testing; From d3e9c29e162d006f005527107561abbf32b0f1a1 Mon Sep 17 00:00:00 2001 From: Jessica Yu Date: Thu, 6 Sep 2012 16:24:11 -0700 Subject: [PATCH 6/8] centered the avatar, moved link --- lib/DDG/Goodie/Unicornify.pm | 6 ++---- t/Unicornify.t | 8 +++----- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/lib/DDG/Goodie/Unicornify.pm b/lib/DDG/Goodie/Unicornify.pm index 983a32167..4cdf0f405 100644 --- a/lib/DDG/Goodie/Unicornify.pm +++ b/lib/DDG/Goodie/Unicornify.pm @@ -13,12 +13,10 @@ handle remainder => sub { my $link = 'http://unicornify.appspot.com/'; if (Email::Valid->address($_)) { s/[\s\t]+//g; # strip whitespace from the remainder, we just need the email address. - return $_ . '\'s unicorn:', - html => $_.'\'s unicorn:' + html => $_ . '\'s unicorn (Learn more at unicornify.appspot.com):' .'
' - .'' - .'
Learn more at unicornify.appspot.com'; + .''; } return; }; diff --git a/t/Unicornify.t b/t/Unicornify.t index 3a7ea1071..65df4eeb4 100644 --- a/t/Unicornify.t +++ b/t/Unicornify.t @@ -15,10 +15,8 @@ ddg_goodie_test( )], 'unicornify bob@bob.com' => test_zci('bob@bob.com\'s unicorn:', - html => 'bob@bob.com\'s unicorn:'.'

Learn more at unicornify.appspot.com')); + html => 'bob@bob.com\'s unicorn (Learn more at unicornify.appspot.com):
' + .'' + .'')); done_testing; From 8109b523375c43fd939856be6f1465b2752e0737 Mon Sep 17 00:00:00 2001 From: Jessica Yu Date: Thu, 6 Sep 2012 21:01:04 -0700 Subject: [PATCH 7/8] added rounded borders on the avatar --- lib/DDG/Goodie/Unicornify.pm | 2 +- t/Unicornify.t | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/DDG/Goodie/Unicornify.pm b/lib/DDG/Goodie/Unicornify.pm index 4cdf0f405..958102826 100644 --- a/lib/DDG/Goodie/Unicornify.pm +++ b/lib/DDG/Goodie/Unicornify.pm @@ -16,7 +16,7 @@ handle remainder => sub { return $_ . '\'s unicorn:', html => $_ . '\'s unicorn (Learn more at unicornify.appspot.com):' .'
' - .''; + .''; } return; }; diff --git a/t/Unicornify.t b/t/Unicornify.t index 65df4eeb4..f0a7fa331 100644 --- a/t/Unicornify.t +++ b/t/Unicornify.t @@ -17,6 +17,6 @@ ddg_goodie_test( test_zci('bob@bob.com\'s unicorn:', html => 'bob@bob.com\'s unicorn (Learn more at unicornify.appspot.com):
' .'' - .'')); + .'')); done_testing; From 7e78154ef43087d06480866905c0b307876228cd Mon Sep 17 00:00:00 2001 From: Jessica Yu Date: Thu, 6 Sep 2012 21:09:30 -0700 Subject: [PATCH 8/8] added border-radius, changed margins --- lib/DDG/Goodie/Gravatar.pm | 23 ----------------------- lib/DDG/Goodie/Unicornify.pm | 4 ++-- t/Unicornify.t | 4 ++-- 3 files changed, 4 insertions(+), 27 deletions(-) delete mode 100644 lib/DDG/Goodie/Gravatar.pm diff --git a/lib/DDG/Goodie/Gravatar.pm b/lib/DDG/Goodie/Gravatar.pm deleted file mode 100644 index 3a10cf82d..000000000 --- a/lib/DDG/Goodie/Gravatar.pm +++ /dev/null @@ -1,23 +0,0 @@ -package DDG::Goodie::Gravatar; -# ABSTRACT: Return Gravatar image given an email address - -use DDG::Goodie; -use CGI qw/img/; -use Email::Valid; -use Gravatar::URL; - -triggers start => 'gravatar'; - -handle remainder => sub { - if(Email::Valid->address($_)){ - return img({src=>gravatar_url(email => $_, default => "mm")}); - } else { - return; - } -}; - -zci is_cached => 1; - -1; - - diff --git a/lib/DDG/Goodie/Unicornify.pm b/lib/DDG/Goodie/Unicornify.pm index 958102826..a2e1b062b 100644 --- a/lib/DDG/Goodie/Unicornify.pm +++ b/lib/DDG/Goodie/Unicornify.pm @@ -14,9 +14,9 @@ handle remainder => sub { if (Email::Valid->address($_)) { s/[\s\t]+//g; # strip whitespace from the remainder, we just need the email address. return $_ . '\'s unicorn:', - html => $_ . '\'s unicorn (Learn more at unicornify.appspot.com):' + html => $_ . '\'s unicorn (Learn more at unicornify.appspot.com):' .'
' - .''; + .''; } return; }; diff --git a/t/Unicornify.t b/t/Unicornify.t index f0a7fa331..2438b6243 100644 --- a/t/Unicornify.t +++ b/t/Unicornify.t @@ -15,8 +15,8 @@ ddg_goodie_test( )], 'unicornify bob@bob.com' => test_zci('bob@bob.com\'s unicorn:', - html => 'bob@bob.com\'s unicorn (Learn more at unicornify.appspot.com):
' + html => 'bob@bob.com\'s unicorn (Learn more at unicornify.appspot.com):
' .'' - .'')); + .'')); done_testing;