A bit of background
So, years ago when I first started this site, it was always intended to be more of a geek exercise than anything. I wanted to have my own blog software - which I now do - which had a native client on the Mac. As it happens, I actually accomplished all that in a relatively short time. The Mac client, largely due to the ease of native development on the Mac (go Applescript studio!) was surprisingly easy, being that it was my first GUI application. I was pleased with my work, and began to use the blog (somewhat sporadically, I admit).
Fast forward three years and three macs later.. Due to a messy incident involving a tattooed developer, the main backup of my original Mac client code base disappeared (you'd think a sysadmin like me would be better about keeping backups.. I may have one around here somewhere, now that I mention it). Thus: I've lost that original client.
A new old objective
Naturally, now that I've done all these great enhancements to the server code, it got me thinking about having a proper Mac editor to save me having to use a crappy web browser text entry interface. Thus, I decided to have another try at a Mac client. This time, though, I wanted to get back to my original idea: What I wanted, years ago, was to be able to author a document in a basic text editor - say.. TextEdit.app, which ships with Mac OSX - and run a quick script to upload the saved document as a new blog entry. No sexy features, no editing, no bullshit, just a simple way to upload text from a simple text editor to my site as a blog entry. Unfortunately, at that time, my Applescript chops weren't quite up to the task of scripting TextEdit to do the 'blog dance (not to mention the XMLRPC support in AppleScript wasn't too crash hot either). Also, although I wrote my server, the actual API calls to create entries and such were a little needlessly tangly (due to the fact that I didn't bother to learn much about XML-RPC, I just used libraries to get the job done. Sue me
). Thus, at the time, funnily enough, it was actually easier to write the full-fledged application for blog entries.
We say yes to standards
Of course, being that I wrote that original client 3 years ago or more, I had absolutely no memory of what was involved to get it up and running.. So, back to the web. Luckily, Apple's support for XML-RPC has grown in the intervening months and years. In fact, now all that is required to perform XML-RPC calls is a few native AppleScript calls. Apple seem to have fully adopted XML-RPC and SOAP, and even included native functions to support both (something few, if any, other, supposedly superior, languages can boast currently).
Awesome.
It turns out that Apple aren't the only ones lately who have warmed to XML-RPC as a standard. In the last few years, virtually every major "community" site on the 'net has begun to integrate with blogger, TypePad, and WordPress. I wanted to tap into this.. Badly. The short answer, of course, would have been to download an existing blog server (like WordPress) and run my blog that way. But, that's not really my style - obviously. Thus, I decided to tack a standard API on to the side of my blog. The big advantage to doing things this way is that I actually had to do very little work, and I didn't have to change much. The existing blog functions still work, as they haven't been touched. In the space of one new file I was able to give the world access to my blog. Now, I can easily click on "blog this" links on several sites (including, of course, my current faves, flickr and digg) and.. bam! A new blog entry. Dead sexy, and quite useful. A nice combination. All thanks to my, and the community's, willingness to adopt a standard programming interface.
Documentation is for pussies.
The really great thing about standards, is that there are so many of them..
Whoever said that was a pretty smart guy. I'm not going to spend a lot of time beating a horse that has been well and truly bashed to death all over the 'net.. But, just let me say.. FUCK!
Of course, saying that I just "tacked on" a blogger interface is putting it far too simply. I originally started out trying to implement the MetaWeblog API (MWA). This turned out to be almost too much for my little brain, let me tell you. The only "real" documentation I could find, turned out to be a custom implementation (read: Lots of little changes that make a really, really big difference). So, that quickly died. I initially wanted a very "robust" API - something that would allow me to start using multimedia content, and storing it alongside entries, for use in different areas of the site. MWA promises all this, but apparently at the expense of your sanity (not to mention any semblance of a social life, as I spent the better part of a week of evenings getting absolutely NO WHERE with the fucking thing). At least with the blogger API, there was a very, very nice page describing the entire "conversation" between server and client in detail.
So, I changed tack. I opted for the smaller, simpler and, probably most importantly, slightly older Blogger API. In standard "IT" terms, this was probably not a great decision on paper. The API is aging, and formal support for it is bound to be dropped by it's originators, who have moved on to Atom (a topic I'm not touching just now - let's just say it's 10x as frustrating as MWA). Those two points alone are enough to send your standard IT management weenie running for the hills. That thought occurred to me, shortly before a couple of other points occurred to me: a) Aging API = Legacy (also usually a bad IT thing) = Well tested and accepted. and b) fuck IT management weenies and the gantt chart they rode in on. Using the blogger api didn't offer a hell of a lot of sex factor, but it sure got me up and running. The night I decided to switch to the blogger API, I was posting from flickr to my blog in the space of several hours. Much better.
It's worth mentioning at this point that I could never have gotten there without a trial version of the fantastic, full-featured Mac-based blog editor ecto. In particular, the "console" feature allowed me to see the exact conversation going on between my test server and the client itself. Armed with that, and the aforementioned excellent documentation for the blogger API, and I was bound to get there in no time.
Full Circle
So, once I had blogger support working (plus blogger2 support, which I had to add for digg to work - yay standards) I cruised along.. Happily posting pic after pic from my collection at flickr, and happily clicking "blog this" over and over at digg. That's been a couple of weeks now, and I've been very happy.. But, back in my brain, where the real work goes on, I still had that nagging sensation that I was missing something.. Every time I had to go into my online blog editor to create a new entry, I felt a little pang.. The time had come.
That brings us up-to-date to a few days ago. I sat down and had a quick look at the current state of AppleScript XML-RPC support. I also fleshed out the basics of how to grab the text of a document in TextEdit along with a document's name to be used as the title. That part turned out to be disgustingly easy. I don't know if I've just gotten that much better at AppleScript since the last time I looked at this silly idea or what, but that part, which once seemed so daunting, took mere minutes. All that was now required was to glue the two pieces together: Grab the text content of a TextEdit document, along with it's name ,and send the two off to a blogger.newPost call on my server. Sounded easy. Was easy. In fact, the whole thing is taken care of in just under 60 lines of code (see here).
The code is, of course, a dirty hack. In particular, it doesn't address the problem of multiple users, and setting up and saving passwords in an easy gui. But, hey, give me a break here. This was five minutes worth of code. Five minutes for fuck's sake. Total jackpot. Three years into my great adventure of writing the blog software and wanting a quick, easy client based on TextEdit has finally come back around. I could not be more stoked.
the long and the short of it
Actually, this is the short of it. Every thing above this is the long.
I'm so amazed at how easy this was, after having been such a long journey. I love that things have gotten to a nice "lowest common denominator" with regards to blog software, and that I was able to pick it all up in a relatively short amount of time. In particular, I love that my blog server is now "standards compliant" and ready to have other pieces of software easily talk to it.
What next?
Next. I'm thinking a lot about it, without having actually moved anywhere (give me a break.. in the last few months, I've managed to learn ajax, blogger api and a whole lot more about XML-RPC internals. Not too bad for a guy who doesn't make his living as a developer). I think I will probably break down and add a more "modern" interface to the server. People aren't going to keep supporting the blogger API forever. In particular, the built-in blog client in my new favorite browser Flock only supports Atom or MWA. That alone would probably be enough reason for me to go ahead with it. I've just got to find some decent god damned ape-raping cock-sucking documentation on either one of them (fat chance. sigh).
I'm glad I got that all out. I'm getting ready to hit the "upload" button, and transform this article from it's lowly beginnings as a TextEdit document into my next 'blog entry.. Wish me luck.