[Surfraw-commits] [SCM] surfraw - a fast unix command line interface to WWW branch, master, updated. surfraw_2-2-5_1-170-g22e7041
Ian Beckwith
ianb at erislabs.net
Thu Mar 3 05:22:10 UTC 2011
The following commit has been merged in the master branch:
commit 5587a416cae26e3277e2b5a23388bd3451908542
Author: Ian Beckwith <ianb at erislabs.net>
Date: Thu Mar 3 01:48:49 2011 +0000
wikipedia: -d: use redirector at http://erislabs.net/ianb/webtools/wpdp/ to search wikipedia and deletionpedia
diff --git a/ChangeLog b/ChangeLog
index 7534856..f94a5e6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,14 @@
instead of calling opensearch-discover and
opensearch-genquery. -r is selected automatically
if those tools are not installed.
+ * wikipedia: new options:
+ + -d, uses a redirector at http://erislabs.net/ianb/webtools/wpdp/
+ This redirector searches for a page with that name at wikipedia.
+ If not found, it searches deletionpedia, if not found there
+ it falls back to a normal wikipedia search.
+ + -f=w|d, -fallback=wikipedia|deletionpedia
+ Implies -d. If page not found at either wikipedia or deletionpedia,
+ whether to fallback to wikipedia search or deletionpedia search.
2011-02-20 Ian Beckwith <ianb at erislabs.net>
diff --git a/elvi/wikipedia b/elvi/wikipedia
index a13ee88..850d7e6 100755
--- a/elvi/wikipedia
+++ b/elvi/wikipedia
@@ -8,6 +8,8 @@ w3_config_hook () {
def SURFRAW_wikipedia_language "$SURFRAW_lang"
# default to off until we know the ssl site is going to stick around
defyn SURFRAW_wikipedia_ssl no
+defyn SURFRAW_wikipedia_deletionpedia no
+def SURFRAW_wikipedia_fallback wikipedia
}
w3_usage_hook () {
@@ -21,6 +23,10 @@ Local options:
-language=ISOCODE | -l=ISOCODE Two letter language code (resembles ISO country codes)
Default: en
Environment: SURFRAW_wikipedia_language, SURFRAW_lang
+ -d If page doesn't exist, also search Deletionpedia
+ -f=w|d, -fallback= If page not found in wikipedia OR deletionpedia,
+ wikipedia | fallback to searching which site
+ deletionpedia Default: wikipedia. Implies -d.
Examples:
$w3_argv0 -language=de Richard Stallman
@@ -32,9 +38,12 @@ w3_parse_option_hook () {
opt="$1"
optarg="$2"
case "$opt" in
- -language=*) setopt SURFRAW_wikipedia_language $optarg ;;
- -l=*) setopt SURFRAW_wikipedia_language $optarg ;;
- -s*) setoptyn SURFRAW_wikipedia_ssl yes ;;
+ -language=*) setopt SURFRAW_wikipedia_language $optarg ;;
+ -l=*) setopt SURFRAW_wikipedia_language $optarg ;;
+ -s*) setoptyn SURFRAW_wikipedia_ssl yes ;;
+ -d) setoptyn SURFRAW_wikipedia_deletionpedia yes ;;
+ -f*=*) setopt SURFRAW_wikipedia_fallback $optarg ; \
+ setoptyn SURFRAW_wikipedia_deletionpedia yes ;;
*) return 1 ;;
esac
return 0
@@ -61,9 +70,28 @@ if null "$w3_args"; then
fi
else
escaped_args=`w3_url_of_arg $w3_args`
- if ifyes SURFRAW_wikipedia_ssl ; then
- w3_browse_url "${prefixs}${escaped_args}"
+
+ if ifyes SURFRAW_wikipedia_deletionpedia
+ then
+ if [ "$SURFRAW_wikipedia_language" != "en" ]
+ then
+ err "Deletionpedia only archives from the english (en) wikipedia, other languages are not supported"
+ fi
+
+ url="http://erislabs.net/ianb/webtools/wpdp/"
+ url="${url}?q=${escaped_args}"
+ case "$SURFRAW_wikipedia_fallback" in
+ w*) url="${url}&f=wp" ;;
+ d*) url="${url}&f=dp" ;;
+ esac
+ w3_browse_url "$url"
else
- w3_browse_url "${prefix}${escaped_args}${suffix}"
+
+ if ifyes SURFRAW_wikipedia_ssl ; then
+ w3_browse_url "${prefixs}${escaped_args}"
+ else
+ w3_browse_url "${prefix}${escaped_args}${suffix}"
+ fi
fi
fi
+
--
surfraw - a fast unix command line interface to WWW
More information about the Surfraw-commits
mailing list