Bespin trepanation

From Trephine

Jump to: navigation, search
« Aspect Oriented JavaScript Understanding JavaScript's this keyword »

[subscribe] Recent blog entries

Live Demos

Bespin trepanation

The official extension sharing mechanism for Bespin has yet to be released, but it is already possible to share code via bookmarklets. This article announces a trephine bookmarklet called trepanation, which provides a Java-based Copy/Paste implementation as well as dynamic script evaluation.

trepanation(drag into your bookmarks)
To see this in action,
  1. Drag the bookmarklet into your bookmarks/favorites
  2. Go to https://bespin.mozilla.com and Log In if you haven't already
  3. Select a file to edit, and bring up the editor
  4. Click the trepanation bookmarklet

The bookmarklet takes care of the rest, dynamically loading the following JavaScript file into the DOM for evaluation:

http://trephine.s3.amazonaws.com/trepanation.js (tip: the code is MIT licensed)

Why would you want to do all this? I'm glad you asked! Trepanation provides:

  • Replacement handlers for Ctrl+C, Ctrl+V and Ctrl+X (Cmd+* in Mac) which use Java for clipboard access
  • New command line command exec which evaluates the current document or selection in the privileged trephine Rhino context

With this in place, your bespin editor becomes a powerful shell, able to perform all the tasks which a desktop application could (including reading and writing from the filesystem and spawning native processes, among other things).

This bookmarklet has been tested and confirmed working on the following platforms:

  • Ubuntu 8.10 + Firefox 3.0 + Sun Java 1.6
  • Mac OS X 10.4 + Firefox 3.0 + Apple's Java 1.5
  • Windows XP + Firefox 3.0 + Sun Java 1.6
  • Windows XP + Safari 4.0 beta + Sun Java 1.6

I don't have physical access to a Mac OS X 10.5 machine, so if anyone is able to test this and confirm whether it's working, I'd be much obliged. Enjoy

--Jim R. Wilson (jimbojw) 07:36, 17 March 2009 (UTC)
Personal tools