go (webrowse-2.0.0.tgz) | : | go (webrowse-2.0.3.tgz) | ||
---|---|---|---|---|
#!/bin/sh - | #!/bin/sh - | |||
urlbrowser='webrowse -uw' | urlbrowser='webrowse -uw' | |||
altenv='export WB_BROWSER=chrome' | ||||
quote= | quote= | |||
case "$USER,$HOST" in | case "$USER,$HOST" in | |||
kinzler,?*) | kinzler,?*) | |||
case "$HOST,$REMOTEHOST" in | case "$HOST,$REMOTEHOST" in | |||
?$USER*|*,) # as above | ?$USER*|*,) # as above | |||
# works remotely via X protocol and X display server | # works remotely via X protocol and X display server | |||
;; | ;; | |||
*) | *) | |||
# works remotely via [rs]sh protocol, faster, .[rs]hosts not xhost auth | # works remotely via [rs]sh protocol, faster, .[rs]hosts not xhost auth | |||
skipping to change at line 27 | skipping to change at line 28 | |||
;; | ;; | |||
esac;; | esac;; | |||
esac | esac | |||
searchurl='https://www.google.com/search?q=' | searchurl='https://www.google.com/search?q=' | |||
# startpage.com and lxquick.com may be alternatives: | # startpage.com and lxquick.com may be alternatives: | |||
privurl='https://duckduckgo.com/html/?q=' | privurl='https://duckduckgo.com/html/?q=' | |||
imageurl='https://www.google.com/search?tbm=isch&q=' | imageurl='https://www.google.com/search?tbm=isch&q=' | |||
videourl='https://www.google.com/search?tbm=vid&q=' | videourl='https://www.google.com/search?tbm=vid&q=' | |||
indexurl="$searchurl-inurl%3ahtm+-inurl%3ahtml+intitle%3a%22index+of%22+" | indexurl="$searchurl-inurl%3ahtm+-inurl%3ahtml+intitle%3a%22index+of%22+" | |||
mapurl='https://maps.google.com/?q=' | #mapurl='https://maps.google.com/?q=' | |||
dirurl='https://maps.google.com/?q='`echo -n "from $MAPADDR to "| sed 's/ /+/g'` | #dirurl="$mapurl"`echo -n "from $MAPADDR to "| sed 's/ /+/g'` | |||
mapurl='https://www.google.com/maps/place/' | ||||
dirurl="https://www.google.com/maps/dir/"`echo -n "$MAPADDR" | sed 's/ /+/g'`/ | ||||
groupurl='https://groups.google.com/group/' | groupurl='https://groups.google.com/group/' | |||
newsurl='https://groups.google.com/groups?q=' | newsurl='https://groups.google.com/groups?q=' | |||
#askurl='http://www.askjeeves.com/main/askjeeves.asp?ads=no&ask=' | #askurl='http://www.askjeeves.com/main/askjeeves.asp?ads=no&ask=' | |||
#askurl='http://a9.com/?q=' | #askurl='http://a9.com/?q=' | |||
askurl='http://www.ask.com/web?q=' | askurl='http://www.ask.com/web?q=' | |||
topicurl='http://search.yahoo.com/bin/search?p=' | topicurl='http://search.yahoo.com/bin/search?p=' | |||
encycurl='https://en.wikipedia.org/w/wiki.phtml?search=' | encycurl='https://en.wikipedia.org/w/wiki.phtml?search=' | |||
#wordurl='https://www.google.com/search?q=define:' | #wordurl='https://www.google.com/search?q=define:' | |||
wordurl='http://dictionary.com/browse/' | wordurl='http://dictionary.com/browse/' | |||
thesurl='http://thesaurus.com/browse/' | thesurl='http://thesaurus.com/browse/' | |||
enurl='https://translate.google.com/#auto|en|' | enurl='https://translate.google.com/#auto|en|' | |||
esurl='https://translate.google.com/#auto|es|' | esurl='https://translate.google.com/#auto|es|' | |||
#perlfurl='http://www.perldoc.com/f?' | #perlfurl='http://www.perldoc.com/f?' | |||
#perlmurl='http://www.perldoc.com/m?' | #perlmurl='http://www.perldoc.com/m?' | |||
perlfurl='http://perldoc.perl.org/search.html?q=' | perlfurl='https://perldoc.perl.org/search.html?q=' | |||
perlmurl='http://search.cpan.org/search?query=' | perlmurl='https://search.cpan.org/search?query=' | |||
#cpanurl='http://cpan.uwinnipeg.ca/search?mode=dist&query=' | ||||
cpanurl='https://metacpan.org/search?q=' | cpanurl='https://metacpan.org/search?q=' | |||
userurl='https://mcommunity.umich.edu/#search:NOPLUS' | userurl='https://mcommunity.umich.edu/#search:<NOPLUS>' | |||
phoneurl='https://www.google.com/search?q=phonebook:' | phoneurl='https://www.google.com/search?q=phonebook:' | |||
linkurl='https://www.linkedin.com/vsearch/f?keywords=' | linkurl='https://www.linkedin.com/vsearch/f?keywords=' | |||
umjoburl='http://umjobs.org/search?keyword=' | ||||
#cityurl='http://www.mapquest.com/maps/map.adp?city= &state=' | #cityurl='http://www.mapquest.com/maps/map.adp?city= &state=' | |||
cityurl='http://www.city-data.com/cityname.php?NM=' | cityurl='http://www.city-data.com/cityname.php?NM=' | |||
bookurl='https://www.amazon.com/exec/obidos/external-search' | bookurl='https://www.amazon.com/exec/obidos/external-search' | |||
bookurl="$bookurl?mode=blended&keyword=" | bookurl="$bookurl?mode=blended&keyword=" | |||
#movieurl='http://www.imdb.com/Find?select=All&for=' | #movieurl='http://www.imdb.com/Find?select=All&for=' | |||
#movieurl='http://www.imdb.com/find?q=' | #movieurl='http://www.imdb.com/find?q=' | |||
movieurl='https://movies.netflix.com/WiSearch?v1=' | movieurl='https://movies.netflix.com/WiSearch?v1=' | |||
coverurl='http://www.albumart.org/?searchindex=Music&searchk=' | coverurl='http://www.albumart.org/?searchindex=Music&searchkk=' | |||
softurl='http://freecode.com/search/?section=projects&q=' | softurl='http://freecode.com/search/?section=projects&q=' | |||
appurl='https://market.android.com/search?q=' | andurl='https://market.android.com/search?q=' | |||
produrl='https://www.google.com/products?q=' | produrl='https://www.google.com/products?q=' | |||
aucturl='http://shop.ebay.com/?_nkw=' | aucturl='http://shop.ebay.com/?_nkw=' | |||
fedexurl='http://www.fedex.com/Tracking?action=track&tracknumbers=' | fedexurl='http://www.fedex.com/Tracking?action=track&tracknumbers=' | |||
piconurl='http://kinzler.com/cgi/piconsearch.cgi?type=patt&show=on&limit=50' | ||||
piconurl="$piconurl&db=users+usenix+misc+domains+unknown" | ||||
piconuurl="$piconurl&host=.*&user=<DOTSTAR>" | ||||
piconhurl="$piconurl&user=.*&host=<DOTSTAR>" | ||||
appurl='https://med.umich.edu/i/platserv/apps.html#' | ||||
yuburl='http://www.yubnub.org/parser/parse?command=' | yuburl='http://www.yubnub.org/parser/parse?command=' | |||
#proxyurl='https://translate.google.com/translate?sl=ja&tl=en&u=' | #proxyurl='https://translate.google.com/translate?sl=ja&tl=en&u=' | |||
proxyurl='http://www.gmodules.com/ig/proxy?url=' | proxyurl='http://www.gmodules.com/ig/proxy?url=' | |||
cacheurl='https://www.google.com/search?q=cache:' | cacheurl='https://www.google.com/search?q=cache:' | |||
infourl='https://www.google.com/search?q=info:' | infourl='https://www.google.com/search?q=info:' | |||
arcurl='http://web.archive.org/archive_request_ng?collection=web&url=' | arcurl='http://web.archive.org/archive_request_ng?collection=web&url=' | |||
randomurl='http://www.uroulette.com/visit' | randomurl='http://www.uroulette.com/visit' | |||
# go - web browse the given URL, fragmented URL, or web query | # go - web browse the given URL, fragmented URL, or web query | |||
# Steve Kinzler, steve@kinzler.com, Apr 00/Oct 00/Jul 01 | # Steve Kinzler, steve@kinzler.com, Apr 00/Oct 00/Jul 01 | |||
# see website http://kinzler.com/me/webrowse/ | # see website http://kinzler.com/me/webrowse/ | |||
# http://kinzler.com/me/home.html#web | # http://kinzler.com/me/home.html#web | |||
opts=; bad= | prot=http; opts=; bad= | |||
while : | while : | |||
do | do | |||
case $# in | case $# in | |||
0) break;; | 0) break;; | |||
*) case "$1" in | *) case "$1" in | |||
-[nv]*) opts="$opts$1";; | -a) $altenv;; | |||
-s) prot=https;; | ||||
-[nv]) opts="$opts$1";; | ||||
--) shift; break;; | --) shift; break;; | |||
-h) bad=t; break;; | -h) bad=t; break;; | |||
-*) bad=t; echo "$0: unknown option ($1)" 1>&2;; | -*) bad=t; echo "$0: unknown option ($1)" 1>&2;; | |||
*) break;; | *) break;; | |||
esac | esac | |||
shift;; | shift;; | |||
esac | esac | |||
done | done | |||
case "$bad" in | case "$bad" in | |||
?*) cat << EOF 1>&2 | ?*) cat << EOF 1>&2 | |||
usage: $0 [ -nv ] [ url_piece [ url_tail ] | | usage: $0 [ -s ] [ -a ] [ -n ] [ -v ] [ url_piece [ url_tail ] | | |||
{search|/}:search query | {priv|\}:ate search query | | {login|@}:site query | {search|/}:search query | | |||
image:picture query | video:clip query | index:listing query | | {priv|\}:ate search query | image:picture query | video:clip query | | |||
map:location query | dir:ections query | group:newsgroup | | index:listing query | map:location query | dir:ections query | | |||
news:usenet query | {ask|?}:question sentence | topic:subject query | | group:newsgroup | news:usenet query | {ask|?}:question sentence | | |||
encyc:lopedia query | word:dictionary query | thes:aurus query | | topic:subject query | encyc:lopedia query | word:dictionary query | | |||
en:translation text | es:translation text | perl:documentation query | | thes:aurus query | en:translation text | es:translation text | | |||
cpan:module query | user:person query | phone:book query | | perl:documentation query | cpan:module query | user:person query | | |||
link:edin query | city:place query | book:store query | | phone:book query | link:edin query | umjob: query | city:place query | | |||
movie:film query | cover:art query | soft:ware query | | book:store query | movie:film query | cover:art query | | |||
app:android query | prod:uct query | auct:ion query | fedex:num track | | soft:ware query | and:roid query | prod:uct query | auct:ion query | | |||
fedex:num track | piconu:icon query : piconh:icon query | app:lication | | ||||
yub:nub command | proxy: url | cache: url | info:rmation url | | yub:nub command | proxy: url | cache: url | info:rmation url | | |||
arc:hive url | random site | url:url ] | arc:hive url | random site | url:url ] | |||
-s assume missing protocol is https instead of http | ||||
-a use alternate environment ($altenv) | ||||
-n nodo mode, don't actually run the browser command | -n nodo mode, don't actually run the browser command | |||
-v verbose mode, print the browser command to be run | -v verbose mode, print the browser command to be run | |||
A url_piece is appended with ".com" if it doesn't contain a dot. | A url_piece is appended with ".com" if it doesn't contain a dot. | |||
If needed, it is prepended with "www." unless it begins with a "/". It is | If needed, it is prepended with "www." unless it begins with a "/". It is | |||
also prepended with "http://" unless the protocol is already specified. | also prepended with "http://", or "https://" with -s, unless the protocol | |||
The final URL is then the concatenation of this url_piece and the url_tail. | is already specified. The final URL is then the concatenation of this | |||
Queries are executed with the following URLs: | url_piece and the url_tail. Queries are executed with the following URLs: | |||
search: $searchurl | search: $searchurl | |||
priv: $privurl | priv: $privurl | |||
image: $imageurl | image: $imageurl | |||
video: $videourl | video: $videourl | |||
index: $indexurl | index: $indexurl | |||
map: $mapurl | map: $mapurl | |||
dir: $dirurl | dir: $dirurl | |||
group: $groupurl | group: $groupurl | |||
news: $newsurl | news: $newsurl | |||
ask: $askurl | ask: $askurl | |||
skipping to change at line 138 | skipping to change at line 151 | |||
word: $wordurl | word: $wordurl | |||
thes: $thesurl | thes: $thesurl | |||
en: $enurl | en: $enurl | |||
es: $esurl | es: $esurl | |||
perl: $perlfurl | perl: $perlfurl | |||
or $perlmurl | or $perlmurl | |||
cpan: $cpanurl | cpan: $cpanurl | |||
user: $userurl | user: $userurl | |||
phone: $phoneurl | phone: $phoneurl | |||
link: $linkurl | link: $linkurl | |||
umjob: $umjoburl | ||||
city: $cityurl | city: $cityurl | |||
book: $bookurl | book: $bookurl | |||
movie: $movieurl | movie: $movieurl | |||
cover: $coverurl | cover: $coverurl | |||
soft: $softurl | soft: $softurl | |||
app: $appurl | and: $andurl | |||
prod: $produrl | prod: $produrl | |||
auct: $aucturl | auct: $aucturl | |||
fedex: $fedexurl | fedex: $fedexurl | |||
piconu: $piconuurl | ||||
piconh: $piconhurl | ||||
app: $appurl | ||||
yub: $yuburl | yub: $yuburl | |||
proxy: $proxyurl | proxy: $proxyurl | |||
cache: $cacheurl | cache: $cacheurl | |||
info: $infourl | info: $infourl | |||
arc: $arcurl | arc: $arcurl | |||
random $randomurl | random $randomurl | |||
EOF | EOF | |||
exit 1;; | exit 1;; | |||
esac | esac | |||
case "$#" in | case "$#" in | |||
0) set x `sed 1q`; shift;; | 0) set x `sed 1q`; shift;; | |||
esac | esac | |||
case "$1" in | case "$1" in | |||
[/\\?e]:*|search:*|priv:*|image:*|video:*|index:*|map:*|dir:*|group:*|news:*|\ | [/\\?e]:*|search:*|priv:*|image:*|video:*|index:*|map:*|dir:*|group:*|news:*|\ | |||
ask:*|topic:*|encyc:*|word:*|thes:*|en:*|es:*|perl:*|cpan:*|user:*|phone:*|\ | ask:*|topic:*|encyc:*|word:*|thes:*|en:*|es:*|perl:*|cpan:*|user:*|phone:*|\ | |||
link:*|book:*|movie:*|cover:*|soft:*|app:*|prod:*|auct:*|fedex:*|yub:*|\ | link:*|umjob:*|book:*|movie:*|cover:*|soft:*|and:*|prod:*|auct:*|fedex:*|\ | |||
proxy:*|cache:*|info:*|arc:*) | picon:*|picon[uh]:*|app:*|yub:*|proxy:*|cache:*|info:*|arc:*) | |||
case "$1" in | case "$1" in | |||
/:*) url="$searchurl";; | /:*) url="$searchurl";; | |||
\\:*) url="$privurl";; | \\:*) url="$privurl";; | |||
\?:*) url="$askurl";; | \?:*) url="$askurl";; | |||
e:*) url="$encycurl";; | e:*) url="$encycurl";; | |||
picon:*)url="$piconhurl";; | ||||
perl:*) case "$*" in | perl:*) case "$*" in | |||
perl:perl*|perl:*::*) url="$perlmurl";; | perl:perl*|perl:*::*) url="$perlmurl";; | |||
*) url="$perlfurl";; | *) url="$perlfurl";; | |||
esac;; | esac;; | |||
*) key=`echo "$1" | sed 's/:.*//'` | *) key=`echo "$1" | sed 's/:.*//'` | |||
eval 'url="$'"$key"'url"';; | eval 'url="$'"$key"'url"';; | |||
esac | esac | |||
dotstar=0; noplus=0 | ||||
case "$url" in | case "$url" in | |||
*NOPLUS) noplus=1; url=`echo "$url" | sed 's/NOPLUS$//'`;; | *\<DOTSTAR\>) dotstar=1; url=`echo "$url" | sed 's/<DOTSTAR>$//'`;; | |||
*) noplus=0;; | *\<NOPLUS\>) noplus=1; url=`echo "$url" | sed 's/<NOPLUS>$//'`;; | |||
esac | esac | |||
url="$url`echo "$@" | perl -pe 'chomp; s/^[^:]*://; | url="$url`echo "$@" | perl -pe 'chomp; s/^[^:]*://; | |||
s/[^ \w!\$\047()*,\-.:]/sprintf("%%%02x", ord $&)/ge; | s/[^ \w!\$\047()*,\-.:]/sprintf("%%%02x", ord $&)/ge; | |||
s/ /+/g unless '$noplus`";; | s/^/.*/, s/$/.*/ if '$dotstar'; | |||
s/ /+/g if ! '$noplus`";; | ||||
city:*) arg=`echo "$@" | perl -pe 'chomp; s/^[^:]*://; | city:*) arg=`echo "$@" | perl -pe 'chomp; s/^[^:]*://; | |||
s/[^ \w!\$\047()*,\-.:]/sprintf("%%%02x", ord $&)/ge; | s/[^ \w!\$\047()*,\-.:]/sprintf("%%%02x", ord $&)/ge; | |||
s/ /+/g'` | s/ /+/g'` | |||
case "$cityurl" in | case "$cityurl" in | |||
*\ *) case "$arg" in | *\ *) case "$arg" in | |||
*,*) cty=`echo "$arg" | sed 's/,[^,]*$//'` | *,*) cty=`echo "$arg" | sed 's/,[^,]*$//'` | |||
sta=`echo "$arg" | sed 's/.*,//'` | sta=`echo "$arg" | sed 's/.*,//'` | |||
url=`echo "$cityurl" | sed "s/ */$cty/"`"$sta";; | url=`echo "$cityurl" | sed "s/ */$cty/"`"$sta";; | |||
*) url=`echo "$cityurl" | sed "s/ .*/$arg/"`;; | *) url=`echo "$cityurl" | sed "s/ .*/$arg/"`;; | |||
esac;; | esac;; | |||
*) url="$cityurl$arg";; | *) url="$cityurl$arg";; | |||
esac;; | esac;; | |||
random) url="$randomurl";; | random) url="$randomurl";; | |||
url:*) url=`echo "$@" | perl -pe 'chomp; s/^[^:]*://'`;; | url:*) url=`echo "$@" | perl -pe 'chomp; s/^[^:]*://'`;; | |||
*) url=`echo "$1" | perl -pe 's:/+$::'`; tail="$2" | *) case "$1" in | |||
login:*|@:*) site=`echo "$1" | sed 's/^[^:]*://'` | ||||
set x `auth -o "$site" | head -1`; shift;; | ||||
esac | ||||
url=`echo "$1" | perl -pe 's:/+$::'`; tail="$2" | ||||
case "$url" in | case "$url" in | |||
'') echo "$0: empty url piece" 1>&2; exit 2;; | '') echo "$0: empty url piece" 1>&2; exit 2;; | |||
esac | esac | |||
case "$url" in | case "$url" in | |||
*.*) ;; | *.*) ;; | |||
*) url="$url.com";; | *) url="$url.com";; | |||
esac | esac | |||
case "$url" in | case "$url" in | |||
*:/*) ;; | *:/*) ;; | |||
www*|my.*|ftp*|[0-9]*.[0-9]*.[0-9]*.[0-9]*) | www*|my.*|ftp*|[0-9]*.[0-9]*.[0-9]*.[0-9]*) | |||
url="http://$url";; | url="$prot://$url";; | |||
/*) url="http://`echo "$url" | sed s/.//`";; | /*) url="$prot://`echo "$url" | sed s/.//`";; | |||
*) url="http://www.$url";; | *) url="$prot://www.$url";; | |||
esac | esac | |||
case "$tail" in | case "$tail" in | |||
/*) url="$url$tail";; | /*) url="$url$tail";; | |||
*) url="$url/$tail";; | *) url="$url/$tail";; | |||
esac;; | esac;; | |||
esac | esac | |||
case "$quote" in | case "$quote" in | |||
?*) url="'$url'";; | ?*) url="'$url'";; | |||
esac | esac | |||
case "$opts" in | case "$opts" in | |||
*v*) echo "$urlbrowser $url";; | *v*) echo "$urlbrowser $url";; | |||
esac | esac | |||
End of changes. 26 change blocks. | ||||
39 lines changed or deleted | 64 lines changed or added |