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

Ivy Foster joyfulgirl at archlinux.us
Thu Jun 28 18:30:11 UTC 2012


The following commit has been merged in the master branch:
commit 7c5c68267eda316b392bfa4aa8a28b4e71cb199c
Author: Ivy Foster <joyfulgirl at archlinux.us>
Date:   Thu Jun 28 14:04:37 2012 -0400

    Actually add examples/hooks.lua

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