/lib/DDG/Spice/Plos.pm

https://github.com/pardocz/zeroclickinfo-spice · Perl · 35 lines · 25 code · 7 blank · 3 comment · 2 complexity · 98dd03680c6c7232948417f3fa1b8782 MD5 · raw file

  1. package DDG::Spice::Plos;
  2. use DDG::Spice;
  3. name 'PLOS Search';
  4. description 'Search research articles of PLOS journals';
  5. primary_example_queries 'plos dinosaurs', 'plos echinoderm evolution';
  6. secondary_example_queries 'plos dinosaurs title:metabolism';
  7. source 'PLOS';
  8. category 'special';
  9. topics 'science';
  10. icon_url 'http://www.plosone.org/images/favicon.ico';
  11. code_url 'https://github.com/duckduckgo/zeroclickinfo-spice/blob/master/lib/DDG/Spice/Plos.pm';
  12. attribution twitter => 'nelas',
  13. github => ['nelas', 'Bruno C. Vellutini'],
  14. web => ['http://organelas.com/', 'organelas.com'];
  15. triggers startend => 'plos', 'plos one', 'plosone', 'public library of science', 'plos journal', 'plos publications';
  16. spice to => 'http://api.plos.org/search?q=$1&rows=10&wt=json'
  17. . '&fl=id,title_display,author_display,journal,volume,issue,publication_date'
  18. . '&api_key={{ENV{DDG_SPICE_PLOS_APIKEY}}}';
  19. spice wrap_jsonp_callback => 1;
  20. # Skip these queries.
  21. # We don't want this instant answer to trigger with "plos one api" and the like.
  22. my %skip = map {$_ => 1} ('blog', 'blogs', 'website', 'api');
  23. handle remainder => sub {
  24. # Only trigger if the remainder does not exist in the skip hash.
  25. return $_ if $_ && !exists $skip{lc $_};
  26. return;
  27. };
  28. 1;