Bespin trepanation
From Trephine
| « Aspect Oriented JavaScript | Understanding JavaScript's this keyword » |
[subscribe] Recent blog entries
- Simple prototypal inheritance new!
- Adventures in Rhino - setters and getters
- Site improvements - fighting with Disqus
- JavaScript task chaining
- JavaScript string building benchmarks
- Efficient JavaScript string building
- Alternative JavaScript worker thread API
- Implementing JavaScript worker threads
- Thread safe DOM manipulation
- Site improvements - CSS sprites
- Trephine worker threads made easy
- Pitfalls of multithreaded browser development
- Site improvements - reducing dependencies
- The unsplittability of XML
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.
- Drag the bookmarklet into your bookmarks/favorites
- Go to https://bespin.mozilla.com and Log In if you haven't already
- Select a file to edit, and bring up the editor
- 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
execwhich 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)