aboutsummaryrefslogtreecommitdiff
path: root/config.dot/surfraw.link/elvi/wiktionary
diff options
context:
space:
mode:
Diffstat (limited to 'config.dot/surfraw.link/elvi/wiktionary')
-rwxr-xr-xconfig.dot/surfraw.link/elvi/wiktionary58
1 files changed, 58 insertions, 0 deletions
diff --git a/config.dot/surfraw.link/elvi/wiktionary b/config.dot/surfraw.link/elvi/wiktionary
new file mode 100755
index 0000000..5827d30
--- /dev/null
+++ b/config.dot/surfraw.link/elvi/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
+