Audience of One is the weblog of Matthew Weston, a UK student, Christian, technophile and musician.

Posting with TextMate

So the wireless connection in my room drops out just as I want to write a blog entry, and my trial period for MarsEdit ran out last week. So I open up TextMate to write an entry, and suddenly think “Didn’t I read somewhere that you can post blog entries directly with TextMate using one of the bundles?” Turns out I did. So then I got thinking.

The way the blogging bundle is currently implemented isn’t ideal for my needs. Firstly, the template includes an “extended entry” separator by default. Still, that’s easy to remedy.

Secondly, Allan (TextMate creator) demonstrated uploading an image to your website just by dragging the image onto the entry. While doing this inserts the correct code well enough, I can’t get it to upload mine. That needs a play with then. A related issue is that I store my images in a different place depending on what they are. A desktop background goes in images/desktops/, whereas normal blog images go in images/blog/ – and sometimes even in sub-categories. So either I change my mind as to how I organise images (which, for the sake of consistency, means editing past entries. Maybe come September – to do this simply and accurately would require exporting a MySQL database from this site, importing it on my localhost, and writing a PHP script to automate URL changing, followed by re-importing the database on this site and rebuilding all the static files), or once I’ve got this feature working, I hack it to do what I want.

Thirdly, there’s the new release of Movable Type 3.3, which includes various new ways of doing things which would require a new version of this plugin. Hopefully one will be short-coming so I can have a play, but seeing as the final release hasn’t even been reached yet (though it’s any day now) I doubt it’ll be quite yet. Still, no rush.

Fourthly, there’s the issue of posting photos from Flickr. Once I’ve got the whole drag-and-drop image thing working (which I’m sure I’ll sort eventually, just not before my hectic summer and certainly not before I come home from Japan), there’ll still be the issue of Flickr photos. There’s no point in hosting all the photos I want to post here locally – I want to use Flickr. So, I need to write a command that allows me to input a Flickr URL (or possibly just picture ID), and it automatically creates the right code to insert a Flickr image into the page with a link to the photo page on Flickr (as per their terms and conditions).

One other TextMate thing to mention, though this time it’s not related to the blogging bundle. Snipplr (you can tell it’s cool because it ends with an “er” without the “e”) allows you to post little snippets of code, which can be tagged, and then inserted at the touch of a button (or two). So if I save the following text as a Snipplr snippet:

if (!is_object($db)) {
    global $db, $vars;
    $db = new DB($vars['db_host'], $vars['db_user'], $vars['db_pass']);
    $db->connect($vars['db_name']);
}

I can simply press ⌃⌥⌘S, type in “db” (one of the tags I saved it with) and select it from the list to insert it. It’s basically like TextMate snippets, only you can easily add other people’s – plus it’s slightly easier to add them than adding TextMate snippets. I’ve yet to decide whether it’s useful enough to me to start adding things to it, instead of just adding TextMate snippets (which can be searched in a similar and equally simple way). The main advantage is adding other people’s – but because everyone has a unique way of coding, and TextMate’s own snippets are so useful, it’s probably even better just to copy and paste as a TextMate snippet.

So, to round the entry off, TextMate rocks supremely. Seriously, if I had to use Windows to use TextMate, I’d do it – and people who’ve talked to me about anything technical for more than five minutes know Windows drives me mad. (Vista does look better though, if they sort out the whole security concept and make IE 7 support web standards as well as Safari.) This is what this entry looks like in Textmate, and if you wanted to know what the entry I wanted to write was, then tough – you’ll have to wait. (Possibly indefinitely too – I think I’ve changed my mind about posting it. As often happens when I listen to advice involving photos of me from friends.)

Matthew @ 07:59, July 3, 2006 to Geek | Comments (0)


Post a comment:

Most XHTML auto-generated via Markdown. Email addresses are required but will never be displayed. If you have a website (or want to link to someone else's) please enter it in the URL field. Otherwise, leave this blank.

If you have a TypeKey identity, you can sign in to use it here.


Remember information?