[Surfraw-commits] [SCM] surfraw - a fast unix command line interface to WWW branch, master, updated. surfraw_2-2-5_1-242-g846275f
Kyle Isom
coder at kyleisom.net
Tue Oct 16 21:19:08 UTC 2012
The following commit has been merged in the master branch:
commit a8edc0b4c892011a7247e1f50ce0ebd3c637f161
Author: Kyle Isom <coder at kyleisom.net>
Date: Tue Oct 16 14:58:43 2012 -0600
Add lua hooks for surfraw integration with elinks.
diff --git a/AUTHORS b/AUTHORS
index 39871dd..f4e19c7 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -132,6 +132,9 @@ Paulo Almeida <paulo at diasalmeida.com>
Shain Singh <shain.singh at gmail.com>
elvi: cisco, f5
+Manolo Martínez <manolo at austrohungaro.com>
+ examples: elinks integration (hooks.lua)
+
THANKS TO
Brian Nelson <bnelson at bloodclot.net>
diff --git a/examples/Makefile.am b/examples/Makefile.am
index c9aafaa..ec6f6b6 100644
--- a/examples/Makefile.am
+++ b/examples/Makefile.am
@@ -1,5 +1,5 @@
noinst_SCRIPTS = uzbl_load_url_from_surfraw
-EXTRA_DIST = README uzbl_load_url_from_surfraw.IN
+EXTRA_DIST = README uzbl_load_url_from_surfraw.IN hooks.lua
CLEANFILES = uzbl_load_url_from_surfraw
uzbl_load_url_from_surfraw: uzbl_load_url_from_surfraw.IN
diff --git a/examples/README b/examples/README
index 497e926..2a1e632 100644
--- a/examples/README
+++ b/examples/README
@@ -1,5 +1,9 @@
Useful example code.
+* hooks.lua
+ Integrates surfraw with elinks (see elinks.cz).
+ Contributed by Manolo Martínez
+
* uzbl_load_url_from_surfraw
Integrates surfraw with uzbl (see www.uzbl.org).
Contributed by Sumant Oemrawsingh.
diff --git a/examples/hooks.lua b/examples/hooks.lua
new file mode 100644
index 0000000..b14fde5
--- /dev/null
+++ b/examples/hooks.lua
@@ -0,0 +1,29 @@
+-- Using surfraw from elinks. To search using an elvi from
+-- the Go to URL dialog box, use the syntax "!elvis your
+-- search terms". E.g., to search for
+-- Wargames torrents in piratebay, type "!piratebay
+-- wargames" in the Go to URL dialog box.
+--
+-- You need to have surfraw installed, obviously, and your
+-- lua install should have io.popen.
+
+function match (prefix, url)
+ return string.sub (url, 1, string.len (prefix)) == prefix
+end
+
+function tosurfraw (str)
+ return "surfraw -p " .. str .. " 2>/dev/null"
+end
+
+function goto_url_hook (url, current_url)
+ if match ("!", url) then
+ sr = tosurfraw (string.sub (url, 2))
+ urlfile = io.popen (sr)
+ finalurl = urlfile:read('*all')
+ urlfile:close()
+ return finalurl
+
+ else
+ return url
+ end
+end
--
surfraw - a fast unix command line interface to WWW
More information about the Surfraw-commits
mailing list