/lib/DDG/Spice/Xkcd/Display.pm

https://github.com/pardocz/zeroclickinfo-spice · Perl · 33 lines · 25 code · 8 blank · 0 comment · 3 complexity · 20a33096795e8c63fb06355fc281ee01 MD5 · raw file

  1. package DDG::Spice::Xkcd::Display;
  2. use DDG::Spice;
  3. name "xkcd";
  4. description "Get the latest xkcd comic";
  5. source "xkcd";
  6. primary_example_queries "xkcd";
  7. secondary_example_queries "xkcd 102";
  8. category "special";
  9. topics "entertainment", "geek", "special_interest";
  10. icon_url "/i/xkcd.com.ico";
  11. code_url "https://github.com/duckduckgo/zeroclickinfo-spice/blob/master/lib/DDG/Spice/Xkcd.pm";
  12. attribution github => ["https://github.com/sdball", "Stephen Ball"],
  13. twitter => ["https://twitter.com/StephenBallNC", "StephenBallNC"];
  14. triggers startend => "xkcd";
  15. spice to => 'http://xkcd.com/$1/info.0.json';
  16. spice wrap_jsonp_callback => 1;
  17. handle remainder => sub {
  18. if ($_ =~ /^(\d+|r(?:andom)?)$/) {
  19. return int rand 1122 if $1 =~ /r/;
  20. return $1;
  21. }
  22. return '' if $_ eq '';
  23. return;
  24. };
  25. 1;