Because I spun the Buzzword Roulette Wheel and landed on “Ruby” and “Wikipedia” on consecutive spins, I am finding myself writing a Ruby interface to MediaWiki. At work I use a great plugin for jEdit called mwjed that makes it about fifty times less annoying to edit wiki pages, and since I’m using MediaWiki for an internal documentation project, I find myself writing scads and scads of wiki pages.
There’s also a MediaWiki plugin for Eclipse, so I started wondering why there isn’t one for TextMate, the world’s greatest text editor. TextMate isn’t open‐source, but its ‘bundles’ — syntax highlighting rules, snippets, commands, macros, and templates all associated with a particular language — are user‐contributed, so I’ve convinced myself I’m going to write a Wikipedia bundle. We’ll see if I’m lying.
Wikipedia is surprisingly tricky for machines to read. The easiest part is getting the raw text of a page — just add ?action=raw
to any URL. For more complex tasks, though — like getting a machine‐readable edit history, or a list of all the pages a particular page links to, or submitting an edit to a particular page — you have to hack your way around.
This might soon change, though. There’s a fantastic specification on the MediaWiki site for a proposed WikiText Transfer Protocol. It’s probably the most refreshing API spec I’ve ever read. (The fact that I’ve just implied I have experience reading API specs should give you an idea of my dork quotient.)
First of all, it does not mention XML a single time! Second, it demonstrates its author’s obvious understanding of HTTP, since it doesn’t try to reinvent stuff that HTTP does quite well. Why haven’t more APIs embraced communication though HTTP headers? It wouldn’t work for complex data, but there’s no reason to pollute the response body with metadata that could more easily be placed in response headers.
The best thing about this spec from my perspective is that, were I building a Ruby interface for WTTP, I would need no XML parsing libraries, no screen‐scraping libraries, no external libraries whatsoever; Ruby’s Net::HTTP
and URI
modules would suffice. Since Ruby comes with every copy of OS X, and since these modules are included in the core distribution, my TextMate bundle would be dependency‐free.
So here’s the tricky part: whom do I have to talk to if I want to turn this spec into an implementation? I know I can submit patches to the WikiMedia project just like anyone else, but I’d rather someone smarter than me do this, or at least someone better at PHP. The frustrating thing about the MediaWiki project — and, I think, with many other open‐source projects — is that there’s almost a disdain for the idea of software management. Being able to write good PHP is a valuable talent; being able to herd cats is even more valuable, I think, because demand is high and supply is low. There aren’t enough great managers in the for‐profit realm, as evidenced by the fact that nearly all software ever made is awful, so the subset of those who would donate their spare time is even scarcer.
Still, this is what I love about open‐source software: MediaWiki is the best wiki software on earth, and I have both incentive and means to make it even better. For now, I’ll be keeping my ear to the ground; though there’s a formal process in place for feature requests, what I really want is to get in the room where the decisions are being made. We’ll see.
Comments
Andrew,
Have you made any progress on the TextMate bundle for editing wiki pages? I’ve tried the Twiki bundle but didn’t find it too useful.
Mostly I’d love it for writing in WikiFormatting for Trac. That way I can create and edit pages locally (with preview, snippets, etc).
I haven’t worked on it in a while, mostly because I have been spending time on other silly projects, and because I got a little annoyed at the kludges I had to engineer to get around the fact that there’s no machine interface to Wikipedia.
I’ll pick it back up at some point, but keep in mind that this is a bundle for Mediawiki, and in my experience Trac’s wiki syntax is somewhat different. You’re more than welcome to take a look at the code I’ve written, though — just shoot me an e-mail.