[Surfraw-commits] [surfraw] 01/02: New elvis: searx

jason ryan jasonwryan-guest at moszumanska.debian.org
Sat Aug 22 23:56:22 UTC 2015


This is an automated email from the git hooks/post-receive script.

jasonwryan-guest pushed a commit to branch master
in repository surfraw.

commit 6658ccf894875bb7dac2e7b440f50dff78dbc5af
Author: Jason Ryan <jasonwryan at gmail.com>
Date:   Sun Aug 23 11:54:32 2015 +1200

    New elvis: searx
---
 AUTHORS          |  3 ++
 ChangeLog        |  4 +++
 README           |  1 +
 elvi/Makefile.am |  1 +
 elvi/searx       | 87 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 links.IN         |  1 +
 test/searx.test  |  7 +++++
 7 files changed, 104 insertions(+)

diff --git a/AUTHORS b/AUTHORS
index f25b9fe..bd2636b 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -144,6 +144,9 @@ Jon Yamokoski <jon at jonyamo.net>
 Lucas Hoffmann <l-m-h at web.de>
         elvi: commandlinefu
 
+Nils <krosos at autistici.org>
+        elvi: searx
+
 THANKS TO
 
 Brian Nelson           <bnelson at bloodclot.net>
diff --git a/ChangeLog b/ChangeLog
index 2b19208..a0cacce 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2015-08-23  Jason Ryan <jasonwryan at gmail.com>
+
+	* new elvi: searx
+
 2014-09-20  Lucas Hoffmann <l-m-h at web.de>
 
 	* new elvi: commandlinefu
diff --git a/README b/README
index ac4f0bc..f6ac9a7 100644
--- a/README
+++ b/README
@@ -271,6 +271,7 @@ scholar         -- Search Google Scholar (scholar.google.com)
 scicom          -- Search Scientific Commons
 scirus          -- Search for science using Scirus (scirus.com)
 scpan           -- Search the Comprehensive Perl Archive Network (search.cpan.org)
+searx           -- Search using searx metasearch engine instances (searx.me)
 slashdot        -- Search stories on Slashdot (www.slashdot.org)
 slinuxdoc       -- Search entries in LDP (www.linuxdoc.org)
 sourceforge     -- Search SourceForge (www.sourceforge.net)
diff --git a/elvi/Makefile.am b/elvi/Makefile.am
index 6dec47e..44527e2 100644
--- a/elvi/Makefile.am
+++ b/elvi/Makefile.am
@@ -101,6 +101,7 @@ dist_elvi_SCRIPTS	= \
 		  scicom \
 		  scirus \
 		  scpan \
+		  searx \
 		  slashdot \
 		  slinuxdoc \
 		  sourceforge \
diff --git a/elvi/searx b/elvi/searx
new file mode 100755
index 0000000..d8c5010
--- /dev/null
+++ b/elvi/searx
@@ -0,0 +1,87 @@
+#!/bin/sh
+# elvis: searx           -- Search using searx metasearch engine instances (https://searx.me and others)
+# author: krosos         -- contact: krosos.sdf.org
+# 2015-08-04
+
+. surfraw || exit 1
+
+w3_config_hook () {
+    def SURFRAW_searx_categories  "$SURFRAW_categories"
+    def SURFRAW_searx_base_url    "$SURFRAW_url"
+}
+
+w3_usage_hook () {
+    cat <<EOF
+
+Usage: $w3_argv0 [options] [search words]...
+Description:
+  Use the searx metasearch engine
+
+ -category,c=CATEGORIES
+
+  Local options:
+    default   | search category "general" (default)
+    vid       | search category "videos"
+    socialm   | search category "social+media"
+    news      | search category "news"
+    music     | search category "music"
+    map       | search category "map"
+    it        | search category "it"
+    img       | search category "images"
+    files     | search category "files"
+                 Default: general
+
+ -url,u=URL
+
+  Local options:
+    1       | https://searx.me
+    2       | https://searx.laquadrature.net
+    3       | https://www.privatesearch.io
+    o1      | http://searchb5a7tmimez.onion (laquadrature)
+    o2      | http://ulrn6sryqaifefld.onion (searx.me)
+    cjdns   | fc00:59dd:3bb2:d592:4083:c138:5489:560a
+                  Default: https://searx.me
+
+EOF
+    w3_global_usage
+}
+
+w3_parse_option_hook () {
+    opt="$1"
+    optarg="$2"
+    case "$opt" in
+    -c*=*)   setopt   SURFRAW_searx_categories   $optarg ;;
+    -u*=*)   setopt   SURFRAW_searx_base_url     $optarg ;;
+    *) return 1 ;;
+    esac
+    return 0
+}
+
+w3_config
+w3_parse_args "$@"
+
+case "$SURFRAW_searx_categories" in
+    default*)   category="general"        ;;
+    vid*)       category="videos"         ;;
+    socialm*)   category="social+media"   ;;
+    news*)      category="news"           ;;
+    music*)     category="music"          ;;
+    map*)       category="map"            ;;
+    it*)        category="it"             ;;
+    img*)       category="images"         ;;
+    files*)     category="files"          ;;
+    *)          category="general"        ;;
+esac
+case "$SURFRAW_searx_base_url" in
+    1*)   searx_url="https://searx.me"         ;;
+    2*)         searx_url="https://searx.laquadrature.net" ;;
+    3*)         searx_url="https://www.privatesearch.io" ;;
+    o1*)        searx_url="http://searchb5a7tmimez.onion" ;;
+    o2*)        searx_url="http://ulrn6sryqaifefld.onion" ;;
+    cjdns*)     searx_url="fc00:59dd:3bb2:d592:4083:c138:5489:560a" ;;
+    *)          searx_url="https://searx.me" ;;
+esac
+# w3_args now contains a list of arguments
+escaped_args=$(w3_url_of_arg $w3_args)
+
+w3_browse_url "${searx_url}/?q=${escaped_args}&categories=${category}"
diff --git a/links.IN b/links.IN
index 80db370..bd9170a 100644
--- a/links.IN
+++ b/links.IN
@@ -92,6 +92,7 @@ elvi.1sr.gz @mandir@/man1/scholar.1sr.gz
 elvi.1sr.gz @mandir@/man1/scicom.1sr.gz
 elvi.1sr.gz @mandir@/man1/scirus.1sr.gz
 elvi.1sr.gz @mandir@/man1/scpan.1sr.gz
+elvi.1sr.gz @mandir@/man1/searx.1sr.gz
 elvi.1sr.gz @mandir@/man1/slashdot.1sr.gz
 elvi.1sr.gz @mandir@/man1/slinuxdoc.1sr.gz
 elvi.1sr.gz @mandir@/man1/sourceforge.1sr.gz
diff --git a/test/searx.test b/test/searx.test
new file mode 100644
index 0000000..df64dfe
--- /dev/null
+++ b/test/searx.test
@@ -0,0 +1,7 @@
+searx surfraw
+Shell Users Revolutionary Front Rage Against the Web
+searx -c=music john coltrane
+Giant Steps
+searx -u=3 -c=vid rick astley
+Never Gonna Give You Up
+

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/surfraw/surfraw.git



More information about the Surfraw-commits mailing list