Wordpress, Tagging and TextMate
I use TextMate Blogging bundle to post my blogs - it's very cool, check out the screencast.
My blog is running off Wordpress (version 2), which was incredible simple to install.
However, it doesn't come with 'tag' support.
But help was at hand...
Job number 1: get tags working in Wordpress. Job number 2: get tags recognised in the blogging TextMate bundle.
Tag Support
This was pretty simple after a bit of trial and error. After hunting around, installing plugins I didn't want/need/understand, I found: Ultimate Tag Warrior 3.
The install is straight forward and you can start tagging pretty quickly from the web interface.
Luckily the theme that I had chosen† supported UTW out of the box.
Yes, I know, I should really design my own blog layout, but I wanted something quick and dirty running, and this theme, I thought, is actually not bad.
Admittedly I did edit my theme files so that the tags would appear on all the pages, rather than just the single page. I did that by searching for 'Filed' and below was the tag code, then I removed the 'is_single' check.
Tag Support for TextMate
By default Wordpress isn't supposed to support tagging, so there's a bit of fiddle that has to be done.
First stop: xmlrpc.
XMLRPC
This is the script that handles the posting on the server side. Basically, it needs to be hacked to support tags.
Updated: Jan 2007
On Dan's suggestion, I am offering my own xmlrpc.php file for you to use.
Please, please make sure you backup your own copy before you overwrite it. I'm not taking responsibility for any problems you might experience, but I will be happy to help where I can.
Note that I am running WordPress 2.0.4 - and Dan has suggested this isn't compatible with 2.1 (I'll get round to it if there's requests) - so again: BACKUP!!!
Rather than explain it myself, a chap called Robin Lu has already written it up.
Step 1: How to make ecto work with Ultimate Tag Warrior.
Step 2: How to make ecto work with Ultimate Tag Warrior - Part II
Ignore the 'ecto' part - it's a blogging software product, but it'll do for our purposes.
The key change you need is mt_keywords to mt_tags.
Tweaking the Blogging Bundle
You'll need to edit the blogging.rb file in the /Applications/TextMate.app/Contents/SharedSupport/Bundles/Blogging.tmbundle/Support/lib/ directory.
Find the following line:
@post['mt_tags'] = @headers['tags'] if @headers['tags']
Then copy it below the
elsif self.mode == 'wp'
This means it will read the tags if the blogging software is Wordpress.
That should be it. You should be able to see my tags working on my Wordpress blog right now.
You should follow me on Twitter here I'll tweet about JavaScript, HTML 5 and other such gems (amongst usual tweet-splurges)
[...] Another benefit with this switch is I can post from TextMate and thanks to Remy Sharp’s trick, I can use Ultimate Tag Warrior’s tags from TM too. Excellent. [...]
Edit (2007-01-06): I seemed to have completely messed up the pasting of this patch, so I'm removing it in favour of a download file. Sorry!
Download the blogging.rb patch and run the patch command:
patch -p0 < blogging.rb.patchThanks so much for the tutorial. I got it up and running no problem. No if only I could get TextMate to send excerpts to Wordpress, I would be in business. I'm still not sold on switching from Ecto, but I really want to.
Should I see the tags on already written articles when fetching posts? How should I implement tags after hacking the files? Last question: should I replace all the mt_keywords from the hacked xmlrpc.php hacked by Robin Lu?
Thanks!
Hi Rude,
I hope that helps - if not, I can drop you an email to help you a little further along.
Hi again, after replacing all the mt_keywords from the hacked xmlrpc.php (there are 4) and copying the line from the blogging.rb, I can't see the tags from my previous posts... am I doing something wrong?
Could you please drop me that e-mail, I'm really interested in make this thing work
Thanks!
I sent you an email earlier this morning to your 'info' account. I'll send it again just in case.
If you still don't get it, drop me an email at remy + my domain name (in the name of avoiding printing my email address and getting spammed!) and I'll reply to that.
I really just need to look at your blogging.rb file.
Cheers.
[...] Este post está escrito con TextMate, y la verdad es que la experiencia me está gustando más, dispone, al igual que ecto, de corrección de errores ortográficos, y también es compatible con UTW con un pequeño hack (que además está basado en el anterior). Al final el la publicación del post es mucho más rápida, que es lo que interesa. Lo que es una lástima, en ambos casos, es que aun no haya soporte para campos personalizados (aunque solo me afecta a la hora de poner miniposts). [...]
I am having the same issue as above: the combination of hacks works to let me post tags, but if I try to fetch a post, TextMate doesn't show the tags I've added. (And posting the entry back without adding any tags wipes out the existing tags on the server.)
Did you resolve RUDE's problems? If RUDE's still reading... what'd you do?
@Dan - the problem with RUDE's changes were that in the xmlrpc.php (around line 800) file:
'mt_tags' => ecto_get_keywords($entry['ID'])line was corrupted - instead of quotes around the ID they were some other quote, like a "smart quote".
I've just checked Robin Lu's web site and it looks like the character surround the ID aren't straight ascii quotes.
It's simple to fix, just type the line in manually rather than pasting in from the browser.
Let me know how you get on.
Dude, you are GOOD.
Time to tell Robin to patch things up?
Or maybe offer a WP 2.03 xmlrpc.php here, that's got these configuration changes already made? (Kind of a waste now that they've offered 2.1, but I know I won't be upgrading, since I finally got tags working in TM...)
Thanks! I'm so impressed! Thanks!
[...] En Comando+Q he encontrado el enlace a un manual bastante completo del programa y también la referencia a blogmate, un plug-in para bloggear con más facilidad. Por si no es suficiente, también hay un hack para poder publicar tags con UTW. [...]
[...] Dan’s suggestion, I am offering my own xmlrpc.php file for you to [...]
I see the tags on already written articles when fetching posts? How should I implement tags after hacking the files