PageRenderTime 0ms CodeModel.GetById 1ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/lib/DDG/Spice/Shorten.pm

https://github.com/eladab/zeroclickinfo-spice
Perl | 28 lines | 22 code | 5 blank | 1 comment | 1 complexity | 63e6e4f425eface371525e40dcea1efd MD5 | raw file
 1package DDG::Spice::Shorten;
 2# ABSTRACT: Return a shortened version of a URL using the bitly API.
 3
 4use DDG::Spice;
 5
 6primary_example_queries "shorten http://www.duckduckgo.com/about.html";
 7secondary_example_queries "url shorten www.github.com/explore";
 8description "Shorten URLs using the is.gd API";
 9name "Shorten";
10icon_url "/i/is.gd.ico";
11source "Shorten";
12code_url "https://github.com/duckduckgo/zeroclickinfo-spice/blob/master/lib/DDG/Spice/Shorten.pm";
13topics "social";
14category "computing_tools";
15attribution github => ['https://github.com/danjarvis','Dan Jarvis'],
16            twitter => ['http://twitter.com/danjarvis','danjarvis'];
17
18spice from => '([^/]+)/(.*)';
19spice to => 'http://is.gd/create.php?format=json&url=$1%3A%2F%2F$2&callback={{callback}}';
20triggers any => 'shorten', 'shorten url', 'short url', 'url shorten';
21
22handle remainder => sub {
23    m|(https?)?(?:://)?(.+)| =~ shift;
24    return (defined $1 ? $1 : 'http'), $2 if defined $2;
25    return;
26};
27
281;