Quite a few applications sport a Scripts menu, from which you can call AppleScript scripts. I never really cared much for it, but extending it to allow other scripting languages made it a lot more intriguing. The latest build of ecto for MacOSX has this new feature and it will be in the official version soon. Still in the works is the ability to call a script automatically before posting an entry, for example. In the meantime, feel free to play with it. I have included sample scripts in the archive, but first here's how it works.
ecto looks for scripts inside ~/Library/Application Support/ecto/scripts/ and loads them in its Scripts menu (see picture). Choose one of them from the menu and they will be called to work on your current draft. For example, select a word and choose “Google” from the Scripts menu. You will be directed to the browser where the Google search results are shown. “Posted with ecto” appends an attribution at the end of the draft (see below). These two scripts are AppleScript scripts. How about shell scripts? “Uptime Stats” gives us this info:
Averages: 0.12 0.07 0.05
Uptime: 5 days 22:02
That's silly, of course, but it gives you the idea what is possible. Let's take it up a notch. “Validate HTML” is a Perl script which takes your selected text or the full contents of your draft and submits it to validator.w3.org (51929) to check its validity. It lectured me on a missing 'p' element, which I obediently fixed.
My personal favorite is “Technorati”, which is also a Perl script, but it takes your text, extracts the URLs, finds the number of inbound links or Technorati Cosmos (30068) for them and inserts that back in the text (like in this entry).
Can you feel the power?
Here's the specifics if you want to write scripts:
The following script languages are allowed:
Filenames for the scripts must have the corresponding extensions:
AppleScript scripts should use ecto's scripting dictionary to obtain an entry's (selected) text and whatever other information it needs. The other scripts are called with a parameter that points to a UTF8 encoded text file containing either the selected text or the entire contents of the front most draft's edit area. Any changes the script makes must be written back to the same file (UTF8 encoded). These scripts can also use STDOUT to channel HTML-formatted messages to ecto, which will then be displayed in an HTML window (see the validator for an example).
Users are encouraged to share their scripts. I will make a scripts page on this website to accomodate them.