PageRenderTime 46ms CodeModel.GetById 21ms RepoModel.GetById 1ms app.codeStats 0ms

/lib/DDG/Spice/BrainyQuote.pm

https://github.com/robertbrook/zeroclickinfo-spice
Perl | 33 lines | 23 code | 7 blank | 3 comment | 2 complexity | 9c6625834938cec594f1fc08606f7ea5 MD5 | raw file
  1. package DDG::Spice::BrainyQuote;
  2. # ABSTRACT: Return famous quotations
  3. use DDG::Spice;
  4. primary_example_queries "John Kennedy quotes", "Brad Pitt quotations";
  5. secondary_example_queries "quotes about motivation";
  6. description "Provides quotations on and about given topics";
  7. name "Quotations";
  8. code_url "https://github.com/duckduckgo/zeroclickinfo-spice/blob/master/lib/DDG/Spice/BrainyQuote.pm";
  9. icon_url "http://brainyquote.com/favicon.ico";
  10. topics "everyday", "trivia";
  11. category "reference";
  12. source "BrainyQuote.com";
  13. attribution web => ['http://www.brainyquote.com','BrainyQuote.com'];
  14. triggers startend => 'quote', 'quotes', 'quotation', 'quotations';
  15. spice to => 'http://www.brainyquote.com/api/ddg?q=$1';
  16. spice wrap_jsonp_callback => 1;
  17. handle remainder => sub {
  18. # Convert queries such as J.R.R. Tolkien to J. R. R. Tolkien.
  19. # We're doing this because the first one is rejected by BrainyQuote.
  20. if(/^\w\.\w/) {
  21. s/\./\. /g;
  22. }
  23. return $_ if $_;
  24. return;
  25. };
  26. 1;