Skip to content
This repository

Adding ! redirect for duckduckgo #269

Closed
wants to merge 1 commit into from

7 participants

Torsten Raudssus Florian Ragwitz japh woldrich Moritz Onken Olaf Alders Ævar Arnfjörð Bjarmason Clinton Gormley
Torsten Raudssus

This patch enables on metacpan that a query starting with ! will go to duckduckgo. If the query starts with "! " then the "! " will be removed before redirect, so "! test" will search for test on duckduckgo (that could be probably later replaced with a DIRECT integration of the ZeroClickInfo), and everything else untouched. This way people have all the redirect bangs that are available via DuckDuckGo also in metacpan. This feature is for people who mostly search on metacpan but still want access to all other search engines via their default search engine, which could be metacpan then.

Florian Ragwitz
Owner
rafl commented August 28, 2011

The point of not doing it is to not have more code for no clear gain.

Besides that, there's also the point of not being opinionated. While we all love, support, and sometimes even use duckduckgo, I can't see much of a reason why it should be featured as prominently on MetaCPAN, while other search engines aren't. That is, if I would see the point of this change in the first place - I'm not recommending adding support for other search engines as well.

Torsten Raudssus

DuckDuckGo is the only search engine with offers the bang paths to be able to redirect to ALL search engines. If another search engine has this option i would consider it, but i think this is the most political correct way.

japh woldrich

I love DuckDuckGo and I use it all the time.
But I have to agree with @rafl here; I don't think people would go to metacpan to search for things unrelated to cpan. And if I'm browsing metacpan and I have to make a duckduckgo query I simply do:

:o query

Likewise, if I need to make a metacpan query while I am somewhere else, I simply do:

:o c metacpan query

The magic of keyword searches.
I have never found a use for the bang syntax over at duckduckgo either, but perhaps 'the masses' do. :-)

Torsten Raudssus

@trapd00r most people use duckduckgo as default search engine to be totally independet of the browser. So if you set it for example in chrome as default search engine and then say duckduckgo "remove the header" then you have like a search engine that is "your browser" you should try that feeling, and then the bang syntax makes sense. its exactly the same you said, actually its the question here: what you want as default? i would like that if i give "Just a word" that word is searched on metacpan, if i want something else i use a bang path. That technical requires this feature. And i think other people also would like to have it this way. The point here still is: what is the disadvantage of doing it (beside one regexp less wow).

Torsten Raudssus

alternative i code my own default search engine ;) but i think we agree that most people arent able todo so. Think about the perl coders who are not "pro", they will love then to use metacpan as default, and encourage them to use metacpan as default, so that they come more often to the right CPAN module then to the right "solution that is written in the web". I think this is also part of the mission of metacpan, or not? ;)

Moritz Onken
Owner

People shouldn't expect metacpan to do anything besides searching the CPAN. As soon as we start integrating stuff like this, people will send in more patches that change metacpan to their personal expectations. I don't want that to happen.

It would be quite trivial to write a greasemonkey script that implements that functionality on the client.

Torsten Raudssus

a greasemonkey script again excludes huge amount of users. I just say its a quality gain. Also a promotional gain. I dont see a personalization here. not only perl starter can have use of this feature, also the extreme powerusers (and i know minimum 2 people who want this feature too for themself) like it to have metacpan as "default world" and just bang out to everything else. CPAN is my world.

Olaf Alders
Owner

This patch seems benign to me. It doesn't introduce much extra logic (9 lines of code?) and it adds some interesting functionality. I don't use duckduckgo myself, but I certainly wouldn't be bothered by having this in the app.

Ævar Arnfjörð Bjarmason
avar commented August 28, 2011

FWIW I was going to submit a patch at some point to make:

! foo

Find "foo", and then go to the first result on metacpan.

That way on DDG you could search for:

!mcpan ! foo

And not have to click on the first result.

But I agree that making metacpan redirect to DDG on ! makes no sense.

Torsten Raudssus

avar: you can still make it with any other char, also you can set the "luckily" parameter and get the same effect ;)

BTW: on duckduckgo we use \ for this, so \ is like i feel ducky so direct to first hit

Clinton Gormley clintongormley closed this August 28, 2011
Clinton Gormley

We're trying to do one thing well, not be everything to everybody, so sorry, but I think this is out of the scope of metacpan, and I'm closing this request.

Michiel Beijen mbeijen referenced this pull request from a commit in mbeijen/metacpan-web August 28, 2011
Ævar Arnfjörð Bjarmason Implement DuckDuckGo-like ! (or \\) syntax for IFL
Instead of having to pass lucky=1 as a GET parameter you can now enter
a search term beginning with "!" or "\" to have MetaCPAN return the
first result to you.

E.g. searching for "!Plack" or "\Plack" will redirect you to
/module/Plack.

This is an alternative to pressing Shift+Enter on the site to go to
the first result, but the real value is being able to use
e.g. DuckDuckGo to search for "!cpan !Plack" to go to the first
MetaCPAN result.

See-Also: CPAN-API#269
fe27944
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Aug 28, 2011
Torsten Raudssus Queries starting with ! will go to duckduckgo 98b71ad
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 10 additions and 1 deletion. Show diff stats Hide diff stats

  1. 11  lib/MetaCPAN/Web/Controller/Search.pm
11  lib/MetaCPAN/Web/Controller/Search.pm
@@ -3,6 +3,8 @@ use strict;
3 3
 use warnings;
4 4
 use base 'MetaCPAN::Web::Controller';
5 5
 use Plack::Response;
  6
+use URI;
  7
+use URI::QueryParam;
6 8
 
7 9
 sub index : Path {
8 10
     my ( $self, $c ) = @_;
@@ -19,7 +21,14 @@ sub index : Path {
19 21
 
20 22
     my $model = $c->model('API::Module');
21 23
     my $from  = ( $req->page - 1 ) * 20;
22  
-    if ( $req->parameters->{lucky} ) {
  24
+    if ( $query =~ m/^!/ ) {
  25
+        $query =~ s/^! //;
  26
+        my $ddg_uri = URI->new("http://duckduckgo.com/");
  27
+        $ddg_uri->query_param( q => $query );
  28
+        $c->res->redirect($ddg_uri->as_string);
  29
+        $c->detach;
  30
+    }
  31
+    elsif ( $req->parameters->{lucky} ) {
23 32
         my $module = $model->first($query)->recv;
24 33
         $c->detach('/not_found') unless ($module);
25 34
         $c->res->redirect("/module/$module");
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.