From a2cc7e065abd8024392a60b00110073b11e019f1 Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Mon, 30 Dec 2019 05:48:56 -0500 Subject: Do-over... --- elvi/repology | 41 ------------ elvi/sbo | 88 ------------------------- elvi/slack | 205 --------------------------------------------------------- elvi/wikiquote | 48 -------------- repology | 41 ++++++++++++ sbo | 88 +++++++++++++++++++++++++ slack | 205 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ wikiquote | 48 ++++++++++++++ 8 files changed, 382 insertions(+), 382 deletions(-) delete mode 100755 elvi/repology delete mode 100755 elvi/sbo delete mode 100755 elvi/slack delete mode 100755 elvi/wikiquote create mode 100755 repology create mode 100755 sbo create mode 100755 slack create mode 100755 wikiquote diff --git a/elvi/repology b/elvi/repology deleted file mode 100755 index 7e78c26..0000000 --- a/elvi/repology +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/sh - -# elvis: repology -- Search Linux distro package metadata with repology.org - -. surfraw || exit 1 - -w3_usage_hook() { - cat <]*>\([0-9][^"]*\),\1 ,g' \ - -e 's,[[:space:]]*.*,,' - )" - - # if we can't get the local version *or* the list of versions - # from the site, just take a wild guess. - if [ -z "$sitevers" ]; then - echo "${ver:-14.2}" - return - fi - - for i in $sitevers; do - topver="$i" - if [ "$i" = "$ver" ]; then - echo "$ver" - return - fi - done - - # fall back to the highest-numbered version on the site - echo "$topver" - return -} - -w3_config_hook() { - def SURFRAW_slack_version "$( get_slack_ver )" -} - -w3_usage_hook() { - cat < Slackware version (default $SURFRAW_slack_ver). - For .0 releases, include the .0 (eg 14.0, not 14). - -C, -cur Same as -v=current - -32/-i586, -64/-x86_64 Architecture (default -$defarch) - -pa, -pkg, -P Package search (default) - -d, -desc Description search - -l, -label Label search - -c, -content Content search - -s= Search sets, may consist of: - e = extra - P = pasture - p = patches - s = slackware - S = source - t = testing - Default: $SURFRAW_slack_sets - -S, -src Search source (same as -c -sS) - -a, -all Search all sets (same as -s=ePpsSt) -Notes: - - Default version and architecture read from the OS (/etc/slackware-version - and uname -m). You can hardcode them in ~/.config/surfraw/conf (see below). - - Search modes: "package" looks at package names, "description" - looks at the .txt files named after the packages (created from the - slack-desc), "label" looks at the first line of .txt file, and "content" - looks at the contents of packages. - - "content" searches are for finding out which package a file belongs to. - Be aware that symlinks aren't found by this, although if the symlink - exists on the local system, its target will be used instead. - - The source search is basically useless without "content" mode. Actually - it's pretty useless anyway. - - Defaults can be set in the config file "~/.config/surfraw/conf". Example: -SURFRAW_slack_ver=14.2 -SURFRAW_slack_arch=64 -SURFRAW_slack_mode=package -SURFRAW_slack_sets=eps - For 32-bit architecture (i586), use: -SURFRAW_slack_arch="" - In other words do NOT set it to 32, the only valid values - are "64" and "". -EOF - w3_global_usage -} - -# have to use -pa/-pkg/-P for "package", not -p as it conflicts with -# the global -p/-print -# -v= does NOT conflict with global -version -w3_parse_option_hook() { - opt="$1" - optarg="$2" - case "$opt" in - -v*=*) SURFRAW_slack_ver="$optarg" ;; - -C*|-cur*) SURFRAW_slack_ver="current" ;; - -32|-i?86) SURFRAW_slack_arch="" ;; - -64|x86_64) SURFRAW_slack_arch="64" ;; - -pa*|-pk*|-P) SURFRAW_slack_mode="package" ;; - -d*) SURFRAW_slack_mode="description" ;; - -l*) SURFRAW_slack_mode="label" ;; - -c*) SURFRAW_slack_mode="content" ;; - -s*=*) SURFRAW_slack_sets="$optarg" ;; - -S*|-src*) SURFRAW_slack_sets="S" - SURFRAW_slack_mode="content" ;; - -a*) SURFRAW_slack_sets="ePpsSt" ;; - *) return 1 ;; - esac - return 0 -} - -w3_config -w3_parse_args "$@" - -url="https://packages.slackware.com/" - -# try to make content search more user-friendlier. -if [ "$SURFRAW_slack_mode" = "content" ]; then - if echo "$w3_args" | grep -q ^/; then - # resolve symlink, if possible - w3_args_new="$( readlink -e "$w3_args" )" - [ -n "$w3_args_new" ] && w3_args="$w3_args_new" - # remove leading /'s since the form fails with them - w3_args="$( echo "$w3_args" | sed 's,^/*,,' )" - fi -fi - -postdata="search=$( w3_url_of_arg $w3_args )" -postdata="${postdata}&release=slackware${SURFRAW_slack_arch}-${SURFRAW_slack_ver}" -postdata="${postdata}&mode=${SURFRAW_slack_mode}" - -# Pick apart sets. Might be a cleaner way to do this. -sets="$( echo "$SURFRAW_slack_sets" | sed 's,\(.\),\1 ,g' )" -for i in $sets; do - case "$i" in - e) postdata="${postdata}&extra=on" ;; - P) postdata="${postdata}&pasture=on" ;; - p) postdata="${postdata}&patches=on" ;; - s) postdata="${postdata}&slackware=on" ;; - S) postdata="${postdata}&source=on" ;; - t) postdata="${postdata}&testing=on" ;; - *) err "invalid -s arg '$i'." ;; - esac -done - -# hardcode number of results, more is always better, right? -postdata="${postdata}&result=1000" - -# wget should be quiet unless -print is enabled. -[ "$SURFRAW_print" = "yes" ] || Q="-q" - -# do the post, show the results. -# all the image, css, js URLs are absolute paths so they'll load OK. -# the "Packages" and form target URLs are relative, so fix them with sed. - -dir="$( mktemp -td sr.slack.XXXXXX )" -[ -d $dir ] || exit 1 -wget $Q -O $dir/slack.html --post-data="$postdata" $url -sed -i "s,= *\"[./]\",=\"$url\",g" $dir/slack.html -w3_browse_url "file://$dir/slack.html" -[ "$SURFRAW_print" = "yes" ] && echo "POST data: $postdata" -rm -rf $dir diff --git a/elvi/wikiquote b/elvi/wikiquote deleted file mode 100755 index 6e91ffb..0000000 --- a/elvi/wikiquote +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/sh - -# elvis: wikiquote -- Search literary/film quotations on wikiquote.org - -. surfraw || exit 1 - -default_lang="en" - -w3_config_hook() { - def SURFRAW_wikiquote_language "$SURFRAW_lang" -} - -w3_usage_hook() { - cat <]*>\([0-9][^"]*\),\1 ,g' \ + -e 's,[[:space:]]*.*,,' + )" + + # if we can't get the local version *or* the list of versions + # from the site, just take a wild guess. + if [ -z "$sitevers" ]; then + echo "${ver:-14.2}" + return + fi + + for i in $sitevers; do + topver="$i" + if [ "$i" = "$ver" ]; then + echo "$ver" + return + fi + done + + # fall back to the highest-numbered version on the site + echo "$topver" + return +} + +w3_config_hook() { + def SURFRAW_slack_version "$( get_slack_ver )" +} + +w3_usage_hook() { + cat < Slackware version (default $SURFRAW_slack_ver). + For .0 releases, include the .0 (eg 14.0, not 14). + -C, -cur Same as -v=current + -32/-i586, -64/-x86_64 Architecture (default -$defarch) + -pa, -pkg, -P Package search (default) + -d, -desc Description search + -l, -label Label search + -c, -content Content search + -s= Search sets, may consist of: + e = extra + P = pasture + p = patches + s = slackware + S = source + t = testing + Default: $SURFRAW_slack_sets + -S, -src Search source (same as -c -sS) + -a, -all Search all sets (same as -s=ePpsSt) +Notes: + - Default version and architecture read from the OS (/etc/slackware-version + and uname -m). You can hardcode them in ~/.config/surfraw/conf (see below). + - Search modes: "package" looks at package names, "description" + looks at the .txt files named after the packages (created from the + slack-desc), "label" looks at the first line of .txt file, and "content" + looks at the contents of packages. + - "content" searches are for finding out which package a file belongs to. + Be aware that symlinks aren't found by this, although if the symlink + exists on the local system, its target will be used instead. + - The source search is basically useless without "content" mode. Actually + it's pretty useless anyway. + - Defaults can be set in the config file "~/.config/surfraw/conf". Example: +SURFRAW_slack_ver=14.2 +SURFRAW_slack_arch=64 +SURFRAW_slack_mode=package +SURFRAW_slack_sets=eps + For 32-bit architecture (i586), use: +SURFRAW_slack_arch="" + In other words do NOT set it to 32, the only valid values + are "64" and "". +EOF + w3_global_usage +} + +# have to use -pa/-pkg/-P for "package", not -p as it conflicts with +# the global -p/-print +# -v= does NOT conflict with global -version +w3_parse_option_hook() { + opt="$1" + optarg="$2" + case "$opt" in + -v*=*) SURFRAW_slack_ver="$optarg" ;; + -C*|-cur*) SURFRAW_slack_ver="current" ;; + -32|-i?86) SURFRAW_slack_arch="" ;; + -64|x86_64) SURFRAW_slack_arch="64" ;; + -pa*|-pk*|-P) SURFRAW_slack_mode="package" ;; + -d*) SURFRAW_slack_mode="description" ;; + -l*) SURFRAW_slack_mode="label" ;; + -c*) SURFRAW_slack_mode="content" ;; + -s*=*) SURFRAW_slack_sets="$optarg" ;; + -S*|-src*) SURFRAW_slack_sets="S" + SURFRAW_slack_mode="content" ;; + -a*) SURFRAW_slack_sets="ePpsSt" ;; + *) return 1 ;; + esac + return 0 +} + +w3_config +w3_parse_args "$@" + +url="https://packages.slackware.com/" + +# try to make content search more user-friendlier. +if [ "$SURFRAW_slack_mode" = "content" ]; then + if echo "$w3_args" | grep -q ^/; then + # resolve symlink, if possible + w3_args_new="$( readlink -e "$w3_args" )" + [ -n "$w3_args_new" ] && w3_args="$w3_args_new" + # remove leading /'s since the form fails with them + w3_args="$( echo "$w3_args" | sed 's,^/*,,' )" + fi +fi + +postdata="search=$( w3_url_of_arg $w3_args )" +postdata="${postdata}&release=slackware${SURFRAW_slack_arch}-${SURFRAW_slack_ver}" +postdata="${postdata}&mode=${SURFRAW_slack_mode}" + +# Pick apart sets. Might be a cleaner way to do this. +sets="$( echo "$SURFRAW_slack_sets" | sed 's,\(.\),\1 ,g' )" +for i in $sets; do + case "$i" in + e) postdata="${postdata}&extra=on" ;; + P) postdata="${postdata}&pasture=on" ;; + p) postdata="${postdata}&patches=on" ;; + s) postdata="${postdata}&slackware=on" ;; + S) postdata="${postdata}&source=on" ;; + t) postdata="${postdata}&testing=on" ;; + *) err "invalid -s arg '$i'." ;; + esac +done + +# hardcode number of results, more is always better, right? +postdata="${postdata}&result=1000" + +# wget should be quiet unless -print is enabled. +[ "$SURFRAW_print" = "yes" ] || Q="-q" + +# do the post, show the results. +# all the image, css, js URLs are absolute paths so they'll load OK. +# the "Packages" and form target URLs are relative, so fix them with sed. + +dir="$( mktemp -td sr.slack.XXXXXX )" +[ -d $dir ] || exit 1 +wget $Q -O $dir/slack.html --post-data="$postdata" $url +sed -i "s,= *\"[./]\",=\"$url\",g" $dir/slack.html +w3_browse_url "file://$dir/slack.html" +[ "$SURFRAW_print" = "yes" ] && echo "POST data: $postdata" +rm -rf $dir diff --git a/wikiquote b/wikiquote new file mode 100755 index 0000000..6e91ffb --- /dev/null +++ b/wikiquote @@ -0,0 +1,48 @@ +#!/bin/sh + +# elvis: wikiquote -- Search literary/film quotations on wikiquote.org + +. surfraw || exit 1 + +default_lang="en" + +w3_config_hook() { + def SURFRAW_wikiquote_language "$SURFRAW_lang" +} + +w3_usage_hook() { + cat <