[Surfraw-commits] [surfraw] 01/01: Added new elvis: wiktionary

jason ryan jasonwryan-guest at moszumanska.debian.org
Fri Jul 7 02:47:39 UTC 2017


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

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

commit 2e0ef038979ccb64b3700d583de94265c8e87b30
Author: Jason Ryan <jasonwryan at gmail.com>
Date:   Fri Jul 7 14:47:02 2017 +1200

    Added new elvis: wiktionary
---
 ChangeLog            |  4 ++++
 README               |  1 +
 elvi/Makefile.am     |  1 +
 elvi/wiktionary      | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 links.IN             |  1 +
 test/wiktionary.test |  4 ++++
 6 files changed, 65 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index f5bd63a..133c678 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2017-06-07  Jason Ryan <jasonwryan at gmail.com>
+
+	* new elvi: wiktionary
+
 2015-09-13  Kyle Isom <kyle at imap.cc>
 
 	* use awk instead of sed for listing elvi
diff --git a/README b/README
index da8cef4..89e47f3 100644
--- a/README
+++ b/README
@@ -289,6 +289,7 @@ wayback         -- Search The Internet Archive's Wayback Machine for a URL (arch
 webster         -- Look up word in Merriam-Webster's Dictionary (www.m-w.com)
 wetandwild      -- Real time weather information (many sources)
 wikipedia       -- Search the free encyclopedia wikipedia
+wiktionary      -- Search the free multilingual dictionary (wiktionary.org)
 woffle          -- Search the web using Woffle (localhost:8080)
 wolfram         -- Ask questions of the computational knowledge engine
 worldwidescience -- Search for science with www.worldwidescience.org
diff --git a/elvi/Makefile.am b/elvi/Makefile.am
index 44527e2..325bea7 100644
--- a/elvi/Makefile.am
+++ b/elvi/Makefile.am
@@ -119,6 +119,7 @@ dist_elvi_SCRIPTS	= \
 		  webster \
 		  wetandwild \
 		  wikipedia \
+		  wiktionary \
 		  woffle \
 		  wolfram \
 		  worldwidescience \
diff --git a/elvi/wiktionary b/elvi/wiktionary
new file mode 100755
index 0000000..64716a4
--- /dev/null
+++ b/elvi/wiktionary
@@ -0,0 +1,54 @@
+#!/bin/sh
+# elvis: wiktionary	-- Search the free dictionary wiktionary
+# $Id$
+# Author: jason ryan • http://jasonwryan.com
+
+. surfraw || exit 1
+
+w3_config_hook () {
+def   SURFRAW_wiktionary_language	"$SURFRAW_lang"
+}
+
+w3_usage_hook () {
+    cat <<EOF
+Usage: $w3_argv0 [options] [search-string]
+Description:
+  Search the Wiktionary online dictionary
+  -language=ISOCODE | -l=ISOCODE  Two letter language code (resembles ISO country codes)
+				  Default: en
+				  Environment: SURFRAW_wiktionary_language, SURFRAW_lang
+Examples:
+  $w3_argv0 -language=de synecdoche
+EOF
+    w3_global_usage
+}
+
+w3_parse_option_hook () {
+    opt="$1"
+    optarg="$2"
+    case "$opt" in
+	-language=*)	setopt	SURFRAW_wiktionary_language  $optarg	;;
+	-l=*)       	setopt	SURFRAW_wiktionary_language  $optarg	;;
+	*) return 1 ;;
+    esac
+    return 0
+}
+
+w3_config
+# disable requoting, doesn't work with this elvi.
+#SURFRAW_quote_ifs=0
+w3_parse_args "$@"
+
+if [ -z "$SURFRAW_wiktionary_language" ]; then
+    SURFRAW_wiktionary_language="en"
+fi
+
+prefix="${SURFRAW_wiktionary_language}"
+
+if null "$w3_args"; then
+	w3_browse_url "https://${SURFRAW_wiktionary_language}.wiktionary.org"
+else
+    escaped_args=`w3_url_of_arg $w3_args`
+    w3_browse_url "https://${prefix}.wiktionary.org/wiki/${escaped_args}"
+fi
+
diff --git a/links.IN b/links.IN
index bd9170a..14f1f88 100644
--- a/links.IN
+++ b/links.IN
@@ -110,6 +110,7 @@ elvi.1sr.gz @mandir@/man1/wayback.1sr.gz
 elvi.1sr.gz @mandir@/man1/webster.1sr.gz
 elvi.1sr.gz @mandir@/man1/wetandwild.1sr.gz
 elvi.1sr.gz @mandir@/man1/wikipedia.1sr.gz
+elvi.1sr.gz @mandir@/man1/wiktionary.1sr.gz
 elvi.1sr.gz @mandir@/man1/woffle.1sr.gz
 elvi.1sr.gz @mandir@/man1/wolfram.1sr.gz
 elvi.1sr.gz @mandir@/man1/worldwidescience.1sr.gz
diff --git a/test/wiktionary.test b/test/wiktionary.test
new file mode 100644
index 0000000..a61cc9c
--- /dev/null
+++ b/test/wiktionary.test
@@ -0,0 +1,4 @@
+wiktionary synecdoche
+the name of a part of something to represent the whole
+wiktionary -l=fr croix
+Sorte de gibet

-- 
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