[Surfraw-commits] [SCM] surfraw - a fast unix command line interface to WWW branch, master, updated. surfraw_2-2-5_1-214-g977c5e8
Ian Beckwith
ianb at erislabs.net
Mon Oct 10 02:24:38 UTC 2011
The following commit has been merged in the master branch:
commit 73c550f5843ddc44cd3fc125a2231486d8377308
Author: Ian Beckwith <ianb at erislabs.net>
Date: Mon Oct 10 02:43:20 2011 +0100
new elvi: pin by Jason Ryan
diff --git a/AUTHORS b/AUTHORS
index 5846c06..896097d 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -118,7 +118,7 @@ Kyle Isom <coder at kyleisom.net>
plus fixes.
Jason Ryan <jasonwryan at gmail.com>
- elvi: archwiki, deli, stack
+ elvi: archwiki, deli, stack, pin
Sara Fauzia <sara at archlinux.us>
archpkg fix.
diff --git a/ChangeLog b/ChangeLog
index 9703f10..58e4a4a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,9 @@
-2011-09-09 Kyle Isom
+2011-10-10 Jason Ryan <jasonwryan at gmail.com>
+
+ * New elvi: pin (search pinboard.in).
+
+2011-09-09 Kyle Isom <coder at kyleisom.net>
+
* New elvi: wolfram - query Wolfram Alpha
* Author: Kyle Isom <coder at kyleisom.net>
* Added test for wolfram.
diff --git a/README b/README
index feca23a..0d0125a 100644
--- a/README
+++ b/README
@@ -229,6 +229,7 @@ openports -- search openports for OpenBSD packages
opensearch -- Search an OpenSearch-enabled website
pasearch -- Search the unofficial Penny Arcade archives (pipefour.org/pa)
pgpkeys -- Search the PGP key database
+pin -- Search Pinboard bookmarks (http://pinboard.in)
piratebay -- Search thepiratebay.org for torrents
priberam -- Look up word in Priberam online dictionary (www.priberam.pt/dlpo)
pubmed -- Search medical/molbio databases (www.ncbi.nlm.nih.gov)
diff --git a/elvi/Makefile.am b/elvi/Makefile.am
index f79c20c..717ce53 100644
--- a/elvi/Makefile.am
+++ b/elvi/Makefile.am
@@ -76,6 +76,7 @@ dist_elvi_SCRIPTS = \
openports \
opensearch \
pasearch \
+ pin \
piratebay \
pgpkeys \
priberam \
diff --git a/elvi/pin b/elvi/pin
new file mode 100755
index 0000000..28edd90
--- /dev/null
+++ b/elvi/pin
@@ -0,0 +1,93 @@
+#!/bin/sh
+# elvis: pin -- Search Pinboard bookmarks (http://pinboard.in)
+# author: jason ryan • http://jasonwryan.com
+
+. surfraw || exit 1
+
+w3_config_hook () {
+def SURFRAW_pinboard_tags "$SURFRAW_tags"
+def SURFRAW_pinboard_user "$SURFRAW_user"
+def SURFRAW_pinboard_new 0
+def SURFRAW_pinboard_popular 0
+}
+
+w3_usage_hook () {
+ cat <<EOF
+Usage: $w3_argv0 [options] [search words]...
+Description:
+ Surfraw search Pinboard bookmarks (http://pinboard.in)
+
+ Local options:
+ Default search (without any options) includes tags, titles and descriptions
+ and is not limited to a specific number of search terms.
+
+ -popular | -p Search popular tags
+ -recent | -r Search recent tags
+
+ -tags=TAGS | -t=TAGS Only search tags (separate a maximum of 3 TAGS with
+ a "+" eg., unix+linux)
+ -user=NAME | -u=NAME Search a user's bookmarks
+
+
+EOF
+ w3_global_usage
+}
+
+w3_parse_option_hook () {
+ opt="$1"
+ optarg="$2"
+ case "$opt" in
+ -p* ) setoptyn SURFRAW_pinboard_popular 1 ;;
+ -r* ) setoptyn SURFRAW_pinboard_new 1 ;;
+ -t=*) setopt SURFRAW_pinboard_tags $optarg ;;
+ -u=*) setopt SURFRAW_pinboard_user $optarg ;;
+ *) return 1 ;;
+ esac
+ return 0
+}
+
+# create tag string
+tags () {
+ local IFS=+
+
+ for tag in $SURFRAW_pinboard_tags; do
+ printf "%s" "t:$tag/"
+ done
+}
+
+
+w3_config
+w3_parse_args "$@"
+
+# w3_args now contains a list of arguments
+escaped_args=$(w3_url_of_arg $w3_args)
+base_url="https://pinboard.in/"
+
+# check for recent & popular
+if [ "$SURFRAW_pinboard_new" = 1 ]; then
+ suffix="recent/"
+elif [ "$SURFRAW_pinboard_popular" = 1 ]; then
+ suffix="popular"
+fi
+
+# Run through the other possibilities...
+if [ -z "$w3_args" ]; then
+
+ if [ -n "$SURFRAW_pinboard_user" ] && [ -n "$SURFRAW_pinboard_tags" ]; then
+ w3_browse_url "${base_url}u:$SURFRAW_pinboard_user/$(tags)"
+
+ elif [ -n "$SURFRAW_pinboard_tags" ]; then
+ w3_browse_url "${base_url}$(tags)"
+
+ elif [ -n "$SURFRAW_pinboard_user" ]; then
+ w3_browse_url "${base_url}u:$SURFRAW_pinboard_user"
+
+ else w3_browse_url "$base_url${suffix}"
+ fi
+
+elif [ -n "$w3_args" ]; then
+ w3_browse_url "${base_url}search/?query=${escaped_args}&all=Search+All"
+
+else
+ w3_browse_url "${base_url}"
+fi
diff --git a/elvi/wolfram b/elvi/wolfram
index eef6290..09f7d7b 100755
--- a/elvi/wolfram
+++ b/elvi/wolfram
@@ -1,5 +1,5 @@
#!/bin/sh
-# elvis: wolfram -- Ask questions of the computational knowledge engine
+# elvis: wolfram -- Ask questions of the computational knowledge engine
# coder at kyleisom.net 20110105
. surfraw || exit 1
diff --git a/links.IN b/links.IN
index 3409fa7..4da7ab2 100644
--- a/links.IN
+++ b/links.IN
@@ -72,6 +72,7 @@ elvi.1sr.gz @mandir@/man1/openbsd.1sr.gz
elvi.1sr.gz @mandir@/man1/openports.1sr.gz
elvi.1sr.gz @mandir@/man1/opensearch.1sr.gz
elvi.1sr.gz @mandir@/man1/pasearch.1sr.gz
+elvi.1sr.gz @mandir@/man1/pin.1sr.gz
elvi.1sr.gz @mandir@/man1/piratebay.1sr.gz
elvi.1sr.gz @mandir@/man1/pgpkeys.1sr.gz
elvi.1sr.gz @mandir@/man1/priberam.1sr.gz
diff --git a/test/pin.test b/test/pin.test
new file mode 100644
index 0000000..fd72006
--- /dev/null
+++ b/test/pin.test
@@ -0,0 +1,2 @@
+pin surfraw
+fast unix command line interface
--
surfraw - a fast unix command line interface to WWW
More information about the Surfraw-commits
mailing list