[Surfraw-devel] New elvis: Arch Wiki

Jason Ryan jasonwryan at gmail.com
Fri Apr 15 01:56:49 UTC 2011


Hi,

I have hacked together an elvis to search the Arch Linux Wiki (and the other
language wikis). I'm not in possession of any significant bash skills, so this
elvis -like it's eponym- is probably somewhat bloated...

I've attached it. If it gets stripped, you can find it here:

http://beta.intuxication.org/jasonwryan/longbow/file/tip/scripts/archwiki

Regards,

-- 

Jason Ryan
http://jasonwryan.com/
-------------- next part --------------
#!/bin/sh
# elvis: archwiki	-- Search the Arch Linux Wiki
# Author: http://jasonwryan.com

. surfraw || exit 1

w3_config_hook () {
def   SURFRAW_archwiki_language	"$SURFRAW_lang"
}

w3_usage_hook () {
    cat <<EOF
Usage: $w3_argv0 [options] [search-string]
Description:
  Search the Arch Linux Wiki (wiki.archlinux.org)

Local options
 -language=ISOCODE | -l=ISOCODE  Two letter language code (resembles ISO country codes)
           en	|   Main Arch Wiki site (default)
           fr	|   French
           de	|   German
           he	|   Hebrew
           pl	|   Polish
           pt	|   Portugese
           ro	|   Romanian
           es	|   Spanish
           sv	|   Swedish
           uk	|   Ukranian

		Environment: SURFRAW_archwiki_language, SURFRAW_lang
		Default: en

EOF
    w3_global_usage
}

w3_parse_option_hook () {
    opt="$1"
    optarg="$2"
    case "$opt" in
	-language=*)	setopt	SURFRAW_archwiki_language	$optarg	;;
	-l=*)			setopt	SURFRAW_archwiki_language	$optarg	;;
	*) return 1 ;;
    esac
    return 0
}
w3_config
w3_parse_args "$@"
# w3_args now contains list of arguments

case "$SURFRAW_archwiki_language" in
    en) domain=".org"		;;
    fr) domain=".fr"		;;
    de) domain=".de"		;;
    he) domain=".il"		;;
    pl) domain=".pl"		;;
    pt) domain="-br.org"	;;
    ro) domain=".ro"		;;
    es) domain=".cl"		;;
    sv) domain=".sv"		;;
    uk) domain=".ua"		;;
     *) domain=".org"		;;
esac

# handle ssl
if [ $domain = ".org" -o $domain = ".de" ]; then
	protocol="https://";
  else	
	protocol="http://";
fi

if [ -z "$w3_args" ]; then
    w3_browse_url "${protocol}wiki.archlinux${domain}/"
else
    escaped_args=$(w3_url_of_arg $w3_args)
    w3_browse_url "${protocol}wiki.archlinux${domain}/index.php?search=${escaped_args}"
fi

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/surfraw-devel/attachments/20110415/298c94d3/attachment.pgp>


More information about the Surfraw-devel mailing list