diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2017-08-19 13:20:45 -0300 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2017-08-19 13:20:45 -0300 |
commit | 2abab054c46c4d80216da882b6befa16d6af06c5 (patch) | |
tree | 57b618438d53784a209a8ebbf11280550677da9e | |
parent | 02b0c254bf959153bce608d4682e6c8686289b17 (diff) | |
download | surfraw-2abab054c46c4d80216da882b6befa16d6af06c5.tar.gz surfraw-2abab054c46c4d80216da882b6befa16d6af06c5.tar.bz2 |
Adds wiktionary elvi
-rwxr-xr-x | config.dot/surfraw/elvi.link/wiktionary | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/config.dot/surfraw/elvi.link/wiktionary b/config.dot/surfraw/elvi.link/wiktionary new file mode 100755 index 0000000..5827d30 --- /dev/null +++ b/config.dot/surfraw/elvi.link/wiktionary @@ -0,0 +1,58 @@ +#!/bin/sh +# elvis: wiktionary -- Search the free dictionary wiktionary +# $Id$ +# Author: Silvio Rhatto <rhatto@riseup.net> +# Original Author: Moritz Muehlenhoff <jmm@informatik.uni-bremen.de> +# Based on wikipedia elvi +. 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 Wikipedia online encyclopedia +Local options: + -language=ISOCODE | -l=ISOCODE Two letter language code (resembles ISO country codes) + Default: en + Environment: SURFRAW_wiktionary_language, SURFRAW_lang + +Examples: + $w3_argv0 -language=en anything +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="https://${SURFRAW_wiktionary_language}.wiktionary.org/w/index.php?search=" + +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 "${prefix}${escaped_args}" +fi + |