[Surfraw-devel] Elvis: Delicious bookmarks

Jason Ryan jasonwryan at gmail.com
Sat Apr 30 07:56:03 UTC 2011


...and seeing that del.icio.us has been rescued from the hapless Yahoo, here is
an elvis for that once great bookmarking service.

-- 

http://jasonwryan.com/


-------------- next part --------------
#!/bin/sh
# elvis: deli	-- Search Delicious bookmarks
# Author: jason ryan ? http://jasonwryan.com

. surfraw || exit 1

w3_config_hook () {
def   SURFRAW_delicious_results $SURFRAW_results
def   SURFRAW_delicious_tags $SURFRAW_tags
def   SURFRAW_delicious_user $SURFRAW_user
}

w3_usage_hook () {
    cat <<EOF
Usage: $w3_argv0 [options] [search-string]
Description: Search Delicious bookmarks (www.delicious.com)

Local options
-tags=TAG  | -t=TAG	Refine your search with tags 
			 [Separate multiple tags with "+"]
-user=USER | -u=USER	Search a particular user's bookmarks

EOF
    w3_global_usage
}

w3_parse_option_hook () {
    opt="$1"
    optarg="$2"
    case "$opt" in
	-tags=*)  setopt	SURFRAW_delicious_tags	$optarg  ;;
	-t=*)     setopt	SURFRAW_delicious_tags	$optarg  ;;
	-u=*)     setopt	SURFRAW_delicious_user	$optarg  ;;
	-user=*)  setopt	SURFRAW_delicious_user	$optarg  ;;
	*) return 1 ;;
    esac
    return 0
}
w3_config
w3_parse_args "$@"
# w3_args now contains list of arguments

# standard topic seach
if [ -z "$w3_args" ]; then
	w3_browse_url "http://www.delicious.com/search?p=${SURFRAW_delicious_results}&chk=&context=all&fr=del_icio_us&lc=1"
else
	escaped_args=$(w3_url_of_arg $w3_args)

	# search for topic and tag(s) in a user's bookmarks
	if [ -n "${SURFRAW_delicious_user}" -a "${SURFRAW_delicious_tags}" ]; then
	w3_browse_url "http://www.delicious.com/search?p=${escaped_args}&chk=&fr=del_icio_us&lc=1&atags=${SURFRAW_delicious_tags}&rtags=&context=userposts%7C${SURFRAW_delicious_user}%7C"
	
	# search for topic in a user's bookmarks
	elif [ -n "${SURFRAW_delicious_user}" ]; then
	w3_browse_url "http://www.delicious.com/search?p=${escaped_args}&chk=&context=userposts%7C${SURFRAW_delicious_user}&fr=del_icio_us&lc=1"
	
	# search for topic with tag(s)
	else
	w3_browse_url "http://www.delicious.com/search?p=${escaped_args}&chk=&fr=del_icio_us&lc=1&atags=${SURFRAW_delicious_tags}&rtags=&context=userposts=all"
	fi
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/20110430/ab14e51f/attachment.pgp>


More information about the Surfraw-devel mailing list