/lib/DDG/Spice/Bitly.pm
Perl | 35 lines | 28 code | 6 blank | 1 comment | 3 complexity | 7bce790fe3be9b50a4c80335f7e1b80a MD5 | raw file
- package DDG::Spice::Bitly;
- # ABSTRACT: Return a shortened version of a URL using the bitly API.
- use DDG::Spice;
- primary_example_queries "bitly http://www.duckduckgo.com/about.html";
- secondary_example_queries "shorten http://www.duckduckgo.com/goodies", "url shorten www.github.com/explore";
- description "Shorten URLs using the bitly API";
- name "Bitly";
- icon_url "/i/bitly.com.ico";
- source "Bitly";
- code_url "https://github.com/duckduckgo/zeroclickinfo-spice/blob/master/lib/DDG/Spice/Bitly.pm";
- topics "social";
- category "computing_tools";
- attribution github => ['https://github.com/danjarvis','Dan Jarvis'],
- twitter => ['http://twitter.com/danjarvis','danjarvis'];
- spice to => 'http://api.bitly.com/v3/shorten?login=duckduckhack&apiKey={{ENV{DDG_SPICE_BITLY_APIKEY}}}&longUrl=$1://$2&callback={{callback}}';
- spice from => '(?:([^/]+)/(.+))';
- triggers any => 'bitly', 'bit.ly', 'shorten', 'shorten url', 'short url', 'url shorten';
- handle remainder => sub {
- my ($longUri) = shift;
- if ($longUri) {
- if($longUri =~ /(.+):\/\/(.+)/) {
- return $1, $2;
- } else {
- return 'http', $longUri;
- }
- }
- return;
- };
- 1;