2012-08-22 00:10:11 -07:00
|
|
|
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';
|
2012-11-06 13:22:27 -08:00
|
|
|
attribution github => ['https://github.com/flaming-toast', 'flaming-toast'];
|
2012-09-06 15:34:16 -07:00
|
|
|
|
2012-08-22 00:10:11 -07:00
|
|
|
handle remainder => sub {
|
2012-09-06 15:34:16 -07:00
|
|
|
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.
|
2012-09-09 23:56:39 -07:00
|
|
|
my $answer = 'This is a unique unicorn for ' . $_ . ':' . "\nLearn more at unicornify.appspot.com";
|
2012-09-10 01:14:42 -07:00
|
|
|
my $heading = $_ . ' (Unicornify)';
|
2012-09-09 23:56:39 -07:00
|
|
|
my $html = 'This is a unique unicorn for ' . $_ . ':'
|
2012-09-06 15:50:31 -07:00
|
|
|
.'<br /><a href="' . unicornify_url(email => $_, size => 128) .'">'
|
2012-09-09 23:56:39 -07:00
|
|
|
.'<img src="'.unicornify_url(email => $_, size => "100").'" style="margin: 10px 0px 10px 20px; border-radius: 8px;" /></a>'
|
2012-09-10 01:14:42 -07:00
|
|
|
. 'Learn more at <a href="'.$link.'">unicornify.appspot.com</a>';
|
2012-09-09 23:56:39 -07:00
|
|
|
|
2012-09-10 01:14:42 -07:00
|
|
|
return $answer, heading => $heading, html => $html;
|
2012-09-06 15:34:16 -07:00
|
|
|
}
|
2012-08-22 00:10:11 -07:00
|
|
|
return;
|
|
|
|
};
|
|
|
|
|
|
|
|
zci is_cached => 1;
|
|
|
|
|
|
|
|
1;
|
|
|
|
|