Frontier, BBEdit, guest databases, and Radio
Skip to the last few paragraphs to see why I am so chuffed this evening...
In the summer of '99 I extensively reworked the old Frontier bbsite suite and converted it into a guest database - akin to a tool in Radio parlance. Like the old bbsite suite, the new framework used the BBEdit app verbs - see system.verbs.apps.BBEdit.changeNotes for historical interest ;-) - to integrate BBEdit into a workflow not totally unlike that used in Radio today. Since '99 was a time when Frontier guest databases were all the rage I decided that reworking the BBSite suite for GDB deployment would be an excellent way to come up to speed on this new feature of Frontier.
To cut a long story short, the text files of my static websites reside in the filesystem as normal. Associated with each (sub-)site is a .root file that contains all of the site-specific details such as glossaries, images, preferences, etc. For example, my work website is contained in #dunc.root in the top-level directory that contains the files and sub-folders of all my work-related pages. The new guest database version of the bbsite suite - called, unimaginatively, bbsite.root - contains the site independent data, macros, etc.
Until BBEdit 6.5 (or was it 6.1?) came along, pages that I edited in BBEdit could be rendered through the Frontier/gdbbsite combo by invoking the relevant script - normally renderFrontWindow() - using a shared-menu, single keystoke invoked, command. The latest version of BBEdit broke that so I was able to replicate most of the functionality with AppleScripts (or was it UserTalk) in BBEdit's Script folder.
I found this to be a highly productive way to work - edit in BBEdit, render and preview. The render/preview cycle took just a few seconds. Once happy with the rendering the files were FTPed to their final destination. Imagine my disappointment when I found out that Frontier running in Classic mode under Mac OS X crashed and burned Mac IE 5.1 In my changeover to Mac OS X a couple of weeks ago, I had resigned myself to the fact that I might have to reboot into Mac OS 9.2.2 in order to use my beloved Frontier/BBEdit combo. I had even begun to think the unthinkable - abandon this way of working altogether!
So, now that I found myself with a few(!) hours to spare I thought that I might as well investigate the feasibility of using Radio instead of Frontier. I expected that I'd be in for a mammoth debugging session but, hey, nothing ventured nothing gained right?
[Prior to the following steps, BBEdit was open and a text files was open in the frontmost window]:
- Duplicated the Radio folder so I could back out of any disaster.
- Copied bbsite.root into the RU Tools folder
- Launched Radio - which opened up bbsite.root along with the other 'tools'
- Made bbsite.root visible and opened the gdbbbsite.renderFrontWindow() script
- Manually ran gdbbbsite.renderFrontWindow()
- Was totally gob-smacked when the file was rendered properly and previewed in Mac IE 5.1
Eureka! Was I delighted? "You bet your sweet bippy!" I was. It had worked first time. I must have made a better job of the conversion than I thought considering it was now running in a different location to the original file!!
Alas, none of the scripts that used to work in BBEdit 6.5 under Mac OS 9.2.2 worked in Mac OS X. I think they may have originally been UserTalk rather than AppleScript but UserTalk is not (currently) recognised as a valid option in the drop-down 'dialect' menu in the Script Editor window. So, next task was to write an Applescript to do the deed from the BBEdit script menu. Now, I know enough AppleScript to be dangerous but not enough to work out why things go wrong when they do. Or at least I thought I didn't.
My first attempt at the AppleScript was simply:
tell application "Radio UserLand™"
Do Script "gdbbbsite.renderFrontWindow()"
end tell
This looked promising when it was run from the Script Editor and actually worked. However, when invoked from the BBEdit script menu, BBEdit went deaf and eventually timed out with some sort of appleevent timeout. So, it was not looking good. Then in the dim recesses of my memory I seemed to recall that the call should be wrapped in a thread.easycall. I tried the obvious incantation but of course this didn't work. So if all else fails read 'the source' or RTFM ;-) So a quick jump to thread.easycall in Radio revealed all and would you believe the script:
tell application "Radio UserLand™"
Do Script "thread.easycall(\"gdbbbsite.renderFrontWindow\",{})"
end tell
actually works!
So, there you have it! BBEdit invoking an AppleScript which in turn invokes a Radio script to render the frontmost window though the new and improved bbsite suite framework. Tomorrow the world!
The original version of this posting is over at http://duncan.smeed.org/2171 so feel free to drop by and ask questions over there. At the moment this is a bit(!?) of a hack and since I based my tool on bbsite, as well as the fact it's hacked to my requirements, it's more useful as a proof of the concept of integrating BBEdit with RU. I'm considering ways of developing this further.
11:56:40 PM
|