New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PLOS Search ported to Spice2 #265

Merged
merged 60 commits into from Nov 4, 2013

Conversation

Projects
None yet
3 participants
@nelas
Contributor

nelas commented Oct 19, 2013

Updated version of PLOS Search plugin originally submitted in #153 (see link for description).

No major changes in the code. Just did a cleanup, removed css file since it was not being used, and reduced the handlebars template to a function call that builds the reference list. Let me know if it is better to iterate within the template (I would think that it would be slower then processing everything in the .js).

Also, I have removed the top attribution line Data Provided by PLOS as discussed, so the latest snapshot looks like this:

screenshot from 2013-10-19 11 25 05

However, I have contacted PLOS through their API developer's group so that they can give an official position about the display policy.

Other than that I need to fill in the metadata in the plugin file, but I didn't find the Metadata README file mentioned on https://github.com/duckduckgo/zeroclickinfo-spice/blob/master/CONTRIBUTING.md

nelas added some commits Apr 16, 2013

Parse query for using in the out link
Also formats items to best readability.
Increment authors' font size to 0.9em
With the linkified title the second line of the citation does not
need to be so small. Easier to read now.
Requests exact fields to PLOS API
Get only necessary fields. Added a few extras as counter and abstract,
as well as important ones such as volume and issue.
Show outdated Hide outdated lib/DDG/Spice/Plos.pm
@jagtalon

This comment has been minimized.

Show comment
Hide comment
@jagtalon

jagtalon Oct 22, 2013

Member

@nelas Awesome, I will take a look at it. :)

Member

jagtalon commented Oct 22, 2013

@nelas Awesome, I will take a look at it. :)

@jagtalon

This comment has been minimized.

Show comment
Hide comment
@jagtalon

jagtalon Oct 23, 2013

Member

@nelas Ah, if you add spice_name: 'plos' it would work:

screen shot 2013-10-23 at 2 26 33 pm

    Spice.render({         
        data: api_result.response.docs,
        force_big_header: true,         
        force_no_fold: true,
        header1: query + ' (PLOS)',
        source_name: 'PLOS',
        source_url: 'http://www.plosone.org/search/advanced?unform...',
        template_frame: 'list',         
        spice_name: 'plos',
        ...
    });

Edit: We'll try to make this clearer in the docs. Also, don't worry about this--it happened to me once or twice before (old habits). :)

Member

jagtalon commented Oct 23, 2013

@nelas Ah, if you add spice_name: 'plos' it would work:

screen shot 2013-10-23 at 2 26 33 pm

    Spice.render({         
        data: api_result.response.docs,
        force_big_header: true,         
        force_no_fold: true,
        header1: query + ' (PLOS)',
        source_name: 'PLOS',
        source_url: 'http://www.plosone.org/search/advanced?unform...',
        template_frame: 'list',         
        spice_name: 'plos',
        ...
    });

Edit: We'll try to make this clearer in the docs. Also, don't worry about this--it happened to me once or twice before (old habits). :)

@nelas

This comment has been minimized.

Show comment
Hide comment
@nelas

nelas Oct 23, 2013

Contributor

@jagtalon looks promising, but it seems that I ran into a duckpan error after the upgrade to 0.127.

127.0.0.1 - - [23/Oct/2013:23:15:54 +0200] "GET /share/spice/plos/plos.js HTTP/1.1" 200 2709 "http://localhost:5000/?q=plos+dinosaurs" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:24.0) Gecko/20100101 Firefox/24.0"
When calling p() without prototypes, please pass arguments as references at /home/nelas/perl5/lib/perl5/App/DuckPAN/Web.pm line 143.
 at /home/nelas/perl5/lib/perl5/Carp.pm line 100
    Carp::croak('When calling p() without prototypes, please pass arguments as references') called at /home/nelas/perl5/lib/perl5/Data/Printer.pm line 198
    Data::Printer::_data_printer('', 'http://api.plos.org/search?q=dinosaurs&rows=5&wt=json&fl=id,title_display,author_display,journal,volume,issue,publication_date&api_key=qHfrhSSeNDPeeVc8Fabw') called at /home/nelas/perl5/lib/perl5/Data/Printer.pm line 145
    Data::Printer::p('http://api.plos.org/search?q=dinosaurs&rows=5&wt=json&fl=id,title_display,author_display,journal,volume,issue,publication_date&api_key=qHfrhSSeNDPeeVc8Fabw') called at /home/nelas/perl5/lib/perl5/App/DuckPAN/Web.pm line 143
    App::DuckPAN::Web::request('App::DuckPAN::Web=HASH(0x522b8c0)', 'Plack::Request=HASH(0x57b4dd8)') called at /home/nelas/perl5/lib/perl5/App/DuckPAN/Web.pm line 84
    App::DuckPAN::Web::run_psgi('App::DuckPAN::Web=HASH(0x522b8c0)', 'HASH(0x57b4928)') called at /home/nelas/perl5/lib/perl5/App/DuckPAN/Cmd/Server.pm line 100
    App::DuckPAN::Cmd::Server::__ANON__('HASH(0x57b4928)') called at /home/nelas/perl5/lib/perl5/Plack/Middleware/Lint.pm line 24
    Plack::Middleware::Lint::call('Plack::Middleware::Lint=HASH(0x56b4be0)', 'HASH(0x57b4928)') called at /home/nelas/perl5/lib/perl5/Plack/Component.pm line 50
    Plack::Middleware::StackTrace::__ANON__ at /home/nelas/perl5/lib/perl5/Try/Tiny.pm line 71
    eval {...} at /home/nelas/perl5/lib/perl5/Try/Tiny.pm line 67
    Plack::Middleware::StackTrace::call('Plack::Middleware::StackTrace=HASH(0x563f298)', 'HASH(0x57b4928)') called at /home/nelas/perl5/lib/perl5/Plack/Component.pm line 50
    Plack::Component::__ANON__('HASH(0x57b4928)') called at /home/nelas/perl5/lib/perl5/Plack/Middleware/AccessLog.pm line 24
    Plack::Middleware::AccessLog::call('Plack::Middleware::AccessLog=HASH(0x563f448)', 'HASH(0x57b4928)') called at /home/nelas/perl5/lib/perl5/Plack/Component.pm line 50
    Plack::Component::__ANON__('HASH(0x57b4928)') called at /home/nelas/perl5/lib/perl5/Plack/Middleware/ContentLength.pm line 10
    Plack::Middleware::ContentLength::call('Plack::Middleware::ContentLength=HASH(0x578e980)', 'HASH(0x57b4928)') called at /home/nelas/perl5/lib/perl5/Plack/Component.pm line 50
    Plack::Component::__ANON__('HASH(0x57b4928)') called at /home/nelas/perl5/lib/perl5/Plack/Util.pm line 142
    eval {...} at /home/nelas/perl5/lib/perl5/Plack/Util.pm line 142
    Plack::Util::run_app('CODE(0x56e2470)', 'HASH(0x57b4928)') called at /home/nelas/perl5/lib/perl5/HTTP/Server/PSGI.pm line 170
    HTTP::Server::PSGI::handle_connection('HTTP::Server::PSGI=HASH(0x56e22d8)', 'HASH(0x57b4928)', 'IO::Socket::INET=GLOB(0x56e2500)', 'CODE(0x56e2470)') called at /home/nelas/perl5/lib/perl5/HTTP/Server/PSGI.pm line 129
    HTTP::Server::PSGI::accept_loop('HTTP::Server::PSGI=HASH(0x56e22d8)', 'CODE(0x563f9e8)') called at /home/nelas/perl5/lib/perl5/HTTP/Server/PSGI.pm line 55
    HTTP::Server::PSGI::run('HTTP::Server::PSGI=HASH(0x56e22d8)', 'CODE(0x563f9e8)') called at /home/nelas/perl5/lib/perl5/Plack/Handler/HTTP/Server/PSGI.pm line 14
    Plack::Handler::HTTP::Server::PSGI::run('Plack::Handler::Standalone=HASH(0x56e26f8)', 'CODE(0x563f9e8)') called at /home/nelas/perl5/lib/perl5/Plack/Loader.pm line 84
    Plack::Loader::run('Plack::Loader=HASH(0x56d3530)', 'Plack::Handler::Standalone=HASH(0x56e26f8)') called at /home/nelas/perl5/lib/perl5/Plack/Runner.pm line 277
    Plack::Runner::run('Plack::Runner=HASH(0x57bf3d8)') called at /home/nelas/perl5/lib/perl5/App/DuckPAN/Cmd/Server.pm line 103
    App::DuckPAN::Cmd::Server::run('App::DuckPAN::Cmd::Server=HASH(0x363c1a0)') called at /home/nelas/perl5/lib/perl5/App/DuckPAN/Cmd.pm line 22
    App::DuckPAN::Cmd::execute('App::DuckPAN::Cmd::Server=HASH(0x363c1a0)', 'ARRAY(0x18a1a00)', 'ARRAY(0x31d9ad0)') called at /home/nelas/perl5/lib/perl5/MooX/Cmd.pm line 118
    MooX::Cmd::__ANON__('App::DuckPAN') called at /home/nelas/perl5/bin/duckpan line 17
127.0.0.1 - - [23/Oct/2013:23:15:56 +0200] "GET /js/spice/plos/dinosaurs HTTP/1.1" 500 4051 "http://localhost:5000/?q=plos+dinosaurs" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:24.0) Gecko/20100101 Firefox/24.0"
Contributor

nelas commented Oct 23, 2013

@jagtalon looks promising, but it seems that I ran into a duckpan error after the upgrade to 0.127.

127.0.0.1 - - [23/Oct/2013:23:15:54 +0200] "GET /share/spice/plos/plos.js HTTP/1.1" 200 2709 "http://localhost:5000/?q=plos+dinosaurs" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:24.0) Gecko/20100101 Firefox/24.0"
When calling p() without prototypes, please pass arguments as references at /home/nelas/perl5/lib/perl5/App/DuckPAN/Web.pm line 143.
 at /home/nelas/perl5/lib/perl5/Carp.pm line 100
    Carp::croak('When calling p() without prototypes, please pass arguments as references') called at /home/nelas/perl5/lib/perl5/Data/Printer.pm line 198
    Data::Printer::_data_printer('', 'http://api.plos.org/search?q=dinosaurs&rows=5&wt=json&fl=id,title_display,author_display,journal,volume,issue,publication_date&api_key=qHfrhSSeNDPeeVc8Fabw') called at /home/nelas/perl5/lib/perl5/Data/Printer.pm line 145
    Data::Printer::p('http://api.plos.org/search?q=dinosaurs&rows=5&wt=json&fl=id,title_display,author_display,journal,volume,issue,publication_date&api_key=qHfrhSSeNDPeeVc8Fabw') called at /home/nelas/perl5/lib/perl5/App/DuckPAN/Web.pm line 143
    App::DuckPAN::Web::request('App::DuckPAN::Web=HASH(0x522b8c0)', 'Plack::Request=HASH(0x57b4dd8)') called at /home/nelas/perl5/lib/perl5/App/DuckPAN/Web.pm line 84
    App::DuckPAN::Web::run_psgi('App::DuckPAN::Web=HASH(0x522b8c0)', 'HASH(0x57b4928)') called at /home/nelas/perl5/lib/perl5/App/DuckPAN/Cmd/Server.pm line 100
    App::DuckPAN::Cmd::Server::__ANON__('HASH(0x57b4928)') called at /home/nelas/perl5/lib/perl5/Plack/Middleware/Lint.pm line 24
    Plack::Middleware::Lint::call('Plack::Middleware::Lint=HASH(0x56b4be0)', 'HASH(0x57b4928)') called at /home/nelas/perl5/lib/perl5/Plack/Component.pm line 50
    Plack::Middleware::StackTrace::__ANON__ at /home/nelas/perl5/lib/perl5/Try/Tiny.pm line 71
    eval {...} at /home/nelas/perl5/lib/perl5/Try/Tiny.pm line 67
    Plack::Middleware::StackTrace::call('Plack::Middleware::StackTrace=HASH(0x563f298)', 'HASH(0x57b4928)') called at /home/nelas/perl5/lib/perl5/Plack/Component.pm line 50
    Plack::Component::__ANON__('HASH(0x57b4928)') called at /home/nelas/perl5/lib/perl5/Plack/Middleware/AccessLog.pm line 24
    Plack::Middleware::AccessLog::call('Plack::Middleware::AccessLog=HASH(0x563f448)', 'HASH(0x57b4928)') called at /home/nelas/perl5/lib/perl5/Plack/Component.pm line 50
    Plack::Component::__ANON__('HASH(0x57b4928)') called at /home/nelas/perl5/lib/perl5/Plack/Middleware/ContentLength.pm line 10
    Plack::Middleware::ContentLength::call('Plack::Middleware::ContentLength=HASH(0x578e980)', 'HASH(0x57b4928)') called at /home/nelas/perl5/lib/perl5/Plack/Component.pm line 50
    Plack::Component::__ANON__('HASH(0x57b4928)') called at /home/nelas/perl5/lib/perl5/Plack/Util.pm line 142
    eval {...} at /home/nelas/perl5/lib/perl5/Plack/Util.pm line 142
    Plack::Util::run_app('CODE(0x56e2470)', 'HASH(0x57b4928)') called at /home/nelas/perl5/lib/perl5/HTTP/Server/PSGI.pm line 170
    HTTP::Server::PSGI::handle_connection('HTTP::Server::PSGI=HASH(0x56e22d8)', 'HASH(0x57b4928)', 'IO::Socket::INET=GLOB(0x56e2500)', 'CODE(0x56e2470)') called at /home/nelas/perl5/lib/perl5/HTTP/Server/PSGI.pm line 129
    HTTP::Server::PSGI::accept_loop('HTTP::Server::PSGI=HASH(0x56e22d8)', 'CODE(0x563f9e8)') called at /home/nelas/perl5/lib/perl5/HTTP/Server/PSGI.pm line 55
    HTTP::Server::PSGI::run('HTTP::Server::PSGI=HASH(0x56e22d8)', 'CODE(0x563f9e8)') called at /home/nelas/perl5/lib/perl5/Plack/Handler/HTTP/Server/PSGI.pm line 14
    Plack::Handler::HTTP::Server::PSGI::run('Plack::Handler::Standalone=HASH(0x56e26f8)', 'CODE(0x563f9e8)') called at /home/nelas/perl5/lib/perl5/Plack/Loader.pm line 84
    Plack::Loader::run('Plack::Loader=HASH(0x56d3530)', 'Plack::Handler::Standalone=HASH(0x56e26f8)') called at /home/nelas/perl5/lib/perl5/Plack/Runner.pm line 277
    Plack::Runner::run('Plack::Runner=HASH(0x57bf3d8)') called at /home/nelas/perl5/lib/perl5/App/DuckPAN/Cmd/Server.pm line 103
    App::DuckPAN::Cmd::Server::run('App::DuckPAN::Cmd::Server=HASH(0x363c1a0)') called at /home/nelas/perl5/lib/perl5/App/DuckPAN/Cmd.pm line 22
    App::DuckPAN::Cmd::execute('App::DuckPAN::Cmd::Server=HASH(0x363c1a0)', 'ARRAY(0x18a1a00)', 'ARRAY(0x31d9ad0)') called at /home/nelas/perl5/lib/perl5/MooX/Cmd.pm line 118
    MooX::Cmd::__ANON__('App::DuckPAN') called at /home/nelas/perl5/bin/duckpan line 17
127.0.0.1 - - [23/Oct/2013:23:15:56 +0200] "GET /js/spice/plos/dinosaurs HTTP/1.1" 500 4051 "http://localhost:5000/?q=plos+dinosaurs" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:24.0) Gecko/20100101 Firefox/24.0"
@moollaza

This comment has been minimized.

Show comment
Hide comment
@moollaza

moollaza Oct 23, 2013

Member

@nelas apologies -- this is related to the PR I merged earlier. Releasing an updated DuckPAN asap. Thanks for reporting this!

Member

moollaza commented Oct 23, 2013

@nelas apologies -- this is related to the PR I merged earlier. Releasing an updated DuckPAN asap. Thanks for reporting this!

@jagtalon

This comment has been minimized.

Show comment
Hide comment
@jagtalon

jagtalon Oct 23, 2013

Member

@moollaza PLOS works for me now--good job! @nelas Should work for you too. Just tell us if you run into any more problems. :)

Member

jagtalon commented Oct 23, 2013

@moollaza PLOS works for me now--good job! @nelas Should work for you too. Just tell us if you run into any more problems. :)

@nelas

This comment has been minimized.

Show comment
Hide comment
@nelas

nelas Oct 26, 2013

Contributor

@jagtalon @moollaza Yes it works!

A couple of questions.

  1. I set the show and max options for the list template, but it doesn't show the "5 more" item as in reddit's spice.
  2. Since I want to display the year after the title and in the hover I'm calling twice the handlebar function that parses the publication_date (end of line 2 and 3). Is that bad?
Contributor

nelas commented Oct 26, 2013

@jagtalon @moollaza Yes it works!

A couple of questions.

  1. I set the show and max options for the list template, but it doesn't show the "5 more" item as in reddit's spice.
  2. Since I want to display the year after the title and in the hover I'm calling twice the handlebar function that parses the publication_date (end of line 2 and 3). Is that bad?
@jagtalon

This comment has been minimized.

Show comment
Hide comment
@jagtalon

jagtalon Oct 28, 2013

Member

@nelas Everything looks good!

Answers:

  1. It's because show is set to 5, and the API was only set to return 5.
  2. That's not bad at all. I think it's more intuitive that way. :)
Member

jagtalon commented Oct 28, 2013

@nelas Everything looks good!

Answers:

  1. It's because show is set to 5, and the API was only set to return 5.
  2. That's not bad at all. I think it's more intuitive that way. :)
@nelas

This comment has been minimized.

Show comment
Hide comment
@nelas

nelas Nov 1, 2013

Contributor

I'm filling up metadata. So, which category fits best with this instant answer?

Contributor

nelas commented Nov 1, 2013

I'm filling up metadata. So, which category fits best with this instant answer?

@jagtalon

This comment has been minimized.

Show comment
Hide comment
@jagtalon

jagtalon Nov 1, 2013

Member

@nelas I'd say reference or special, but it's up to you to decide where it fits best. :)

Member

jagtalon commented Nov 1, 2013

@nelas I'd say reference or special, but it's up to you to decide where it fits best. :)

@nelas

This comment has been minimized.

Show comment
Hide comment
@nelas

nelas Nov 1, 2013

Contributor

@jagtalon Special it is then.

Contributor

nelas commented Nov 1, 2013

@jagtalon Special it is then.

@jagtalon

This comment has been minimized.

Show comment
Hide comment
@jagtalon

jagtalon Nov 4, 2013

Member

Looks good! One question, though: Why is is_cached set to 0?

Member

jagtalon commented Nov 4, 2013

Looks good! One question, though: Why is is_cached set to 0?

jagtalon added a commit that referenced this pull request Nov 4, 2013

Merge pull request #265 from nelas/plos
PLOS Search ported to Spice2

@jagtalon jagtalon merged commit a6df648 into duckduckgo:master Nov 4, 2013

1 check failed

default The Travis CI build failed
Details
@nelas

This comment has been minimized.

Show comment
Hide comment
@nelas

nelas Nov 4, 2013

Contributor

To be honest, I don't remember! But I cannot think of any good reason to be disabled.

Contributor

nelas commented Nov 4, 2013

To be honest, I don't remember! But I cannot think of any good reason to be disabled.

@jagtalon

This comment has been minimized.

Show comment
Hide comment
@jagtalon

jagtalon Nov 4, 2013

Member

It's totally fine! It gets cached for one day when is_cached is set to

  1. I'll take care of it. :)

On Mon, Nov 4, 2013, at 02:47 PM, Bruno C. Vellutini wrote:

To be honest, I don't remember! But I cannot think of any good reason to
be disabled.


Reply to this email directly or view it on GitHub:
#265 (comment)

Member

jagtalon commented Nov 4, 2013

It's totally fine! It gets cached for one day when is_cached is set to

  1. I'll take care of it. :)

On Mon, Nov 4, 2013, at 02:47 PM, Bruno C. Vellutini wrote:

To be honest, I don't remember! But I cannot think of any good reason to
be disabled.


Reply to this email directly or view it on GitHub:
#265 (comment)

@nelas nelas deleted the nelas:plos branch Nov 17, 2013

@jagtalon

This comment has been minimized.

Show comment
Hide comment
@jagtalon

jagtalon Jan 10, 2014

Member

@nelas I'm sure you've seen this but:

New instant answer by @nelas makes finding @PLOS journals a breeze! https://t.co/eReizEf1VA

— DuckDuckHack (@DuckDuckHack) January 9, 2014
Member

jagtalon commented Jan 10, 2014

@nelas I'm sure you've seen this but:

New instant answer by @nelas makes finding @PLOS journals a breeze! https://t.co/eReizEf1VA

— DuckDuckHack (@DuckDuckHack) January 9, 2014
@nelas

This comment has been minimized.

Show comment
Hide comment
@nelas

nelas Jan 11, 2014

Contributor

@jagtalon yes, I saw it! Cool!

Contributor

nelas commented Jan 11, 2014

@jagtalon yes, I saw it! Cool!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment