iBlog AppleScripts


One of the best new features of iBlog 1.3.1, IMHO, is the ability to embed HTML code in blog entries through the use of iBlog's HTMLCode tags. The only problem with iBlog's implementation is that it actually increases the amount of HTML code that you have to write to achieve even simple formatting like multiple, indented paragraphs, and numbered or bulleted lists. For instance, the HTMLCode tags ignore carriage returns, so if you want paragraph breaks between blockquoted paragraphs, then you'll need to end each paragraph with one or more <br> (break) tags. As I found myself writing the same types of HTMLCode over-and-over again, I finally decided to do something about it. I automated it!

There are three types of HTMLCode formatting that I use a lot in my blog entries:
  1. <blockquotes> for indented paragraphs.
  2. <ul> for bulleted lists.
  3. <ol> for numbered lists.

So I wrote three AppleScripts that perform the formatting on a copied block of text, and then leave the formatted text on the clipboard so that you can paste it into your blog entry. I also wrote a fourth AppleScript that I used to convert most of the entries on my site containing HTML code listings. As I detailed in an earlier blog entry, if you use an "a href" tag in a blog entry, even if it's not enclosed within HTMLCode tags, iBlog still tries to make it a live hyper-link. That's why I can't include the < and > characters around the "a href" here, because iBlog will attempt to convert it to a hyper-link. I can't even use the HTML entity encoding &lt; and &gt; because iBlog interprets them as < and > characters and still makes a hyper-link. So I wrote the "iBlog-Safe Code Listing" script to get around this problem. The script goes through a block of copied HTML and replaces all < and > characters with references to JPEG representations of those characters. There may be no one in the world who wants to use this script except for me, but I thought I'd include it just in case.

Using the Scripts
iBlog itself is not scriptable, so to use the scripts you must first copy the text you want formatted to the clipboard. Then you choose the formatting script you want from the AppleScript Menu, and after you see the dialog letting you know that formatting is complete, you can paste the HTML-formatted selection back into your blog entry.

These scripts are meant to be invoked from the AppleScript Menu located in the /Applications/AppleScript/ folder. If you're using Jaguar, you can install the AppleScript Menu by double-clicking Script Menu.menu, and if you're using Panther, you can install it by double-clicking Install Script Menu. Both programs place a small script icon on the menubar system-wide. Click the icon to access the script menu. Scripts shown in the menu are stored at ~/Library/Scripts (where ~ is your Home directory).

Downloading and Installing the Scripts
You can download a disk image containing these scripts from the file sharing section of my web site (link below...). After you've downloaded and mounted the disk image, double-click the Install Scripts icon to install the iBlog submenu and scripts in the AppleScript Menu. Also note that there's a manual piece to the installation if you intend to use the "iBlog-Safe Code Listing" script. On the disk image, there's a folder called "Copy to iDisk/Sites/." Within this folder are the two JPEG's that represent the < and > characters. Simply mount your iDisk and copy these images to the top-level of the Sites folder. If you don't do this before you use the "iBlog-Safe Code Listing" script, then your code listing will be filled with broken image links when you publish your blog.

I'm providing these scripts as freeware, and as with most freeware, you are using them at your own risk. I'm providing no warranty and cannot be held responsible in the unlikely event that you suffer data loss, dizziness, cramps, nausea, vomiting, or any of the other blah, blah, blah's the lawyers like to throw into these disclaimers. If you agree to these terms, click I Agree to download the scripts.

Posted: Tue - October 21, 2003 at 10:09 AM          


©