[Surfraw-commits] [SCM] surfraw - a fast unix command line interface to WWW branch, master, updated. surfraw_2-2-5_1-31-gb1acf69

Ian Beckwith ianb at erislabs.net
Tue Oct 27 03:03:57 UTC 2009


The following commit has been merged in the master branch:
commit 9b86a007373ba198d62e24fe673e35d1539ce866
Author: Ian Beckwith <ianb at erislabs.net>
Date:   Tue Oct 27 02:47:01 2009 +0000

    Added examples/uzbl-load-url-from-surfraw, thanks to Sumant Oemrawsingh.

diff --git a/ChangeLog b/ChangeLog
index 6c3f556..d5f1f2e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,12 +1,14 @@
 2009-10-27  Ian Beckwith  <ianb at erislabs.net>
 
-	* Fix debsec (Thanks to Moritz Muehlenhoff, for this
+	* Added examples/uzbl-load-url-from-surfraw,
+	  thanks to Sumant Oemrawsingh.
+	* Fixed debsec (Thanks to Moritz Muehlenhoff, for this
 	  and all his other work).
+	* Fixed cia.
+	* Fixed tests: aur, debpts, lastfm.
 	* test/Makefile.am: add debvcsbrowse.test to EXTRA_DIST
 	* Makefile.am: install-data-hook: remove execute flag
 	  from generated files surfraw.conf, elvi.1sr & surfraw.1.
-	* Fixed elvi: cia.
-	* Fixed tests: aur, debpts, lastfm.
 
 2009-10-20  Ian Beckwith  <ianb at erislabs.net>
 
diff --git a/Makefile.am b/Makefile.am
index 480b13a..d18f63c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -6,6 +6,7 @@ if OPENSEARCH
 dist_bin_SCRIPTS = opensearch-discover opensearch-genquery
 endif
 devel_extra	= banner prebuild
+examples_extra  = examples/README examples/uzbl-load-url-from-surfraw
 noinst_DATA	= surfraw-bash-completion
 man_MANS = surfraw-update-path.1 surfraw.1 elvi.1sr
 if OPENSEARCH
@@ -14,7 +15,8 @@ endif
 EXTRA_DIST	= surfraw.lsm.in surfraw.IN surfraw-update-path.IN\
                   surfraw.spec.in aclocal.m4 HACKING Makefile.include \
 		  surfraw.1.IN elvi.1sr.IN surfraw.bookmarks links.IN \
-		  $(devel_extra) surfraw-bash-completion.IN surfraw.conf.IN
+		  surfraw-bash-completion.IN surfraw.conf.IN \
+		  $(devel_extra) $(examples_extra)
 
 CLEANFILES = surfraw surfraw-update-path surfraw-update-path.1 surfraw.spec surfraw.lsm \
 		surfraw.1 elvi.1sr links surfraw-bash-completion surfraw.conf surfraw.1 \
diff --git a/Makefile.in b/Makefile.in
index f682eb5..7320287 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -216,12 +216,14 @@ SUBDIRS = elvi test
 bin_SCRIPTS = surfraw surfraw-update-path
 @OPENSEARCH_TRUE at dist_bin_SCRIPTS = opensearch-discover opensearch-genquery
 devel_extra = banner prebuild
+examples_extra = examples/README examples/uzbl-load-url-from-surfraw
 noinst_DATA = surfraw-bash-completion
 man_MANS = surfraw-update-path.1 surfraw.1 elvi.1sr $(am__append_1)
 EXTRA_DIST = surfraw.lsm.in surfraw.IN surfraw-update-path.IN\
                   surfraw.spec.in aclocal.m4 HACKING Makefile.include \
 		  surfraw.1.IN elvi.1sr.IN surfraw.bookmarks links.IN \
-		  $(devel_extra) surfraw-bash-completion.IN surfraw.conf.IN
+		  surfraw-bash-completion.IN surfraw.conf.IN \
+		  $(devel_extra) $(examples_extra)
 
 CLEANFILES = surfraw surfraw-update-path surfraw-update-path.1 surfraw.spec surfraw.lsm \
 		surfraw.1 elvi.1sr links surfraw-bash-completion surfraw.conf surfraw.1 \
diff --git a/debian/changelog b/debian/changelog
index b945abf..ecd1ec6 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -4,11 +4,12 @@ surfraw (2.2.6-1) unstable; urgency=low
     + Only use first matching bookmark (Closes: #530786).
     + Fix debsec (patch from Moritz Muehlenhoff) (Closes: #550741).
   * Remove Moritz from Uploaders (per #550741), thanks for your work!.
+  * debian/rules: call dh_installexamples to install examples/ dir.
   * debian/control:
     + update vcs- fields to point to new git repo.
     + Standards-Version: 3.8.3 (No changes).
 
- -- Ian Beckwith <ianb at debian.org>  Tue, 27 Oct 2009 00:21:33 +0000
+ -- Ian Beckwith <ianb at debian.org>  Tue, 27 Oct 2009 02:38:17 +0000
 
 surfraw (2.2.5-1) unstable; urgency=low
 
diff --git a/debian/rules b/debian/rules
index 34bfc65..5aa0412 100755
--- a/debian/rules
+++ b/debian/rules
@@ -66,6 +66,7 @@ binary-indep: build install
 	install -m 644 surfraw-bash-completion debian/surfraw/etc/bash_completion.d/surfraw
 	dh_installdocs
 	dh_installchangelogs ChangeLog
+	dh_installexamples examples/*
 	# copy shared doc files
 	dh_install   --sourcedir=debian/surfraw  -psurfraw-extra
 	# move files that are in surfraw-extra
diff --git a/examples/README b/examples/README
new file mode 100644
index 0000000..7be981a
--- /dev/null
+++ b/examples/README
@@ -0,0 +1,5 @@
+Useful example code.
+
+* uzbl-load-url-from-surfraw
+  Integrates surfraw with uzbl (see www.uzbl.org).
+  Contributed by Sumant Oemrawsingh.
diff --git a/examples/uzbl_load_url_from_surfraw b/examples/uzbl_load_url_from_surfraw
new file mode 100644
index 0000000..4aae147
--- /dev/null
+++ b/examples/uzbl_load_url_from_surfraw
@@ -0,0 +1,81 @@
+#!/bin/bash
+#
+#
+# This script attempts to be the ultimate url opening script for UZBL. It
+# hopes to do this in the following way. It presents all surfraw bookmarks
+# and elvi in a dmenu, and uses surfraw to obtain a valid URL. If the first
+# word entered by the user (and thus returned by dmenu) contains a colon (:)
+# or a period (.), it assumes that the user entered a valid URL and just
+# immediately prints that, bypassing surfraw.
+#
+# As such, the script itself is stupid, and the awesomeness comes from dmenu
+# and surfraw.
+#
+# Example UZBL configuration:
+#
+# To open any url in the current UZBL instance:
+# bind    o         = sh 'uri=`$XDG_DATA_HOME/uzbl/scripts/load_url_from_surfraw.sh` && echo "uri $uri" > $4'
+# To open any url in a new UZBL instance:
+# bind    t         = sh 'uri=`$XDG_DATA_HOME/uzbl/scripts/load_url_from_surfraw.sh` && uzbl --uri $uri'
+#
+#
+# October 2009, Sumant Oemrawsingh
+#
+# TODO: Do we also want history? Titles of webpages and urls? Tags for bookmarks?
+
+# Default search engine. If we really are at a loss, use this
+DEFAULT_SEARCH=google
+
+# The location of the surfraw bookmark file
+BOOKMARKS="$HOME/.surfraw.bookmarks"
+
+# Colors for dmenu
+COLORS=" -nb #303030 -nf khaki -sb #CCFFAA -sf #303030"
+
+# Prompt for dmenu
+PROMPT="Open"
+
+# Use surfraw to search for the words
+function search()
+{
+  # Does surfraw know what to do with it?
+  url=`surfraw -print $@`
+
+  # If not, then use the default search engine
+  if [ $? -ne 0 ]
+  then
+    url=`surfraw -print $DEFAULT_SEARCH $@`
+  fi
+
+  echo $url
+
+}
+
+# We assume that this is a URL
+function goto()
+{
+  case "$1" in
+    *:*) echo $1 ;;
+    *) echo "http://$1" ;;
+  esac
+}
+
+# Use dmenu to navigate through possible choices
+function present_menu()
+{
+  elvi=`surfraw -elvi | cut -f 1 | tail --lines=+2`
+  if [ -r "$BOOKMARKS" ]
+  then
+    bookmarks=" `cut -f 1 -d ' ' "$BOOKMARKS" 2>/dev/null`"
+  else
+    bookmarks=""
+  fi
+
+  echo "${elvi}${bookmarks}" | tr ' ' '\n' | sort | dmenu -p "$PROMPT" -i $COLORS
+}
+
+present_menu | \
+  ( read car cdr
+    test -z "$car" && exit 1
+    ( test -z "$cdr" && echo $car | fgrep -c '.
+:' > /dev/null && goto $car ) || search "$car $cdr" )

-- 
surfraw -  a fast unix command line interface to WWW



More information about the Surfraw-commits mailing list