Blogging from TextMate
I don’t blog very often so I often don’t look at applications’ Metaweblog API implementations unless a user reports a problem. Well, ever since TextMate’s Blogging Bundle was released, a very small trickle of users mentioned wanting to get it to work with ExpressionEngine. My quick experience was that it could post to ExpressionEngine without any problem, but could not fetch posts. Here’s why, along with a fix.
The first thing is to understand how the Blogging Bundle assigns a Weblog ID. In your Blogging Bundles blog setup file, you simply need to add #<weblog_id> to the end of the URL to assign the right weblog. For instance, if your Weblog ID is ‘7’:
Example Blog http://www.example.com/index.php?ACT=20&id=3#7
With that, you can easily start blogging from Textmate using the bundle. Make sure you set the “Content” and “More” fields, as those are the two that the Blogging Bundle will post to.
But fetching posts is another problem, and one that involves Ruby’s standard libraries, at least the one that comes out of the box in OS X (1.8.2 on my Macbook). If you compiled your own, you may not have this problem, as the 1.8.5 standard library contains the fix.
The problem is that Ruby that comes with 10.4.x does not properly parse ISO8601 formatted date strings, specifically, the regular expression doesn’t even look for offset, nor does it allow for dash separated year, month, and date.
if str =~ /^(-?dddd)(dd)(dd)T(dd):(dd):(dd)$/ then
To fix the problem, you first need to open /usr/lib/ruby/1.8/xmlrpc/parser.rb
mate /usr/lib/ruby/1.8/xmlrpc/parser.rb
Then find the dateTime method. Simply replace it with this one (click ”[Source]” for the dateTime method). As you can see, the new regular expression matches two separate cases, which properly handles ISO8601 date strings.
when /^(-?dddd)-?(dd)-?(dd)T(dd):(dd):(dd)(?:Z|([+-])(dd):?(dd))?$/ ... when /^(-?dd)-?(dd)-?(dd)T(dd):(dd):(dd)(Z|([+-]dd):(dd))?$/
Save the file (you’ll need to authenticate as an administrator), and you’re done. Blog away!