Tuesday, January 31, 2006

Goo URLs? Yes, please.

Hypertext is the original system for traversing associations between Things.

In a previous blog entry (Goo URLs? No Thanks) I mentioned that I didn't want to encumber The Goo with having to address Things using http://really_long_unambiguous_urls/that/are/a/pain/to/type. But The Goo sticks Things together by association and hypertext offers the path of least resistance!

For example, ideally I want to browse my Perl code in hypertext and then jump straight to an editor and then jump back again as quickly as possible (to minimise context switching). A recent patch by Jonas Fonseca to the Elinks browser unfortunately didn't quite do what I needed but he suggested an even better solution: Goo URLs!

To enable your own protocol in Elinks all you need to do is add this to ~/.elinks/elinks.conf:
set protocol.user.goo.unix = "/home/search/dev/goo %u"
set protocol.user.goo.unix-xwin = "/home/search/dev/goo %u"
I now have Goo URLs! This means if I want to edit a given method I can use a URL like this:
goo://?method=someMethodDeepInTheModule&filename=/tmp/MyModule.pm
Clicking on this URL launches an external text editor (e.g., nano, vi, emacs etc), starting at the appropriate line and means I can edit the file in place and jump back out again - quick!

It turns out the same method works in Firefox too. If you search on Trexy you will find my search trails for "firefox registered protocol". But here is a summary of what I found. To add a new protocol to Firefox do the following:
  1. Type "about:config" in the location bar.
  2. Right click, select New --> String.
  3. Name of string should be: "network.protocol-handler.app.goo"
  4. Value should be the path to your executable: "/home/search/dev/goo.sh"
This activates goo:// URLs in Firefox. I use KDE on Linux so I need to launch a window to wrap the application with a shell script (e.g., /home/search/dev/goo.sh):
#!/bin/bash
# launch the editor in a new window
/usr/bin/konsole -e /home/search/dev/goo "$1"
This means the Goo can be fully integrated with a graphical browser (Firefox) and a console based browser (Elinks) too.

There is now no technical impasse to traversing from high level tasks and ideas all the way down to editing, compiling and testing a small Perl script buried in the file system. Cool! ;-)

0 comments: