PageRenderTime 40ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/lib/DDG/Spice/Shorten.pm

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