I've made a bit of progress in writing a MediaWiki bundle, the goal of which would be to allow one to use TextMate as an external editor on Wikipedia and other sites using the MediaWiki software. I've written an alpha version of a Ruby library to machine-read/screen- scrape wiki pages -- for example:
page = new MediaWiki::Page('TextMate') page.contents.gsub!(/Textmate/, 'TextMate') page.save('Corrected capitalization')
I've also built a few proof-of-concept TextMate commands -- fetch selection from Wikipedia, etc., and have done a very small amount of work on a MediaWiki syntax grammar (though the one described here <http://lists.macromates.com/pipermail/textmate/2006-January/ 007623.html> might be further along).
In short, I'm trying to replicate as much as possible of the functionality of mwjed http://www.djini.de/software/mwjed/, a jEdit plugin with the same purpose. This would include being able to configure multiple wikis independently, log in, etc., so the bundle will have to keep track of a bit of configuration info.
If anyone is interested in contributing to this project in any way, or has any ideas on how I can more elegantly keep track of a wiki "instance" across individual pages, please let me know. I'm decent enough in Ruby to get by (though my code could definitely benefit from another pair of eyes), but if you've got specific expertise in Objective-C I'd love your assistance in writing some dialogs like the ones in the Subversion bundle.
The bundle is in no way ready for inclusion in the bundle repository, but I can share what I've got with anyone who's interested. I invite questions, comments, and general ridicule.
Cheers, Andrew Dupont http://andrewdupont.net
Well I'm actually interested for another reason, I was trying to figure out how to have a text box sent to TextMate from a browser and Allan pointed out the MediaWiki external editor spec page. Would be interested to see how you tackled the issue.
Haven't tackled it yet. Explicit communication between the browser and TextMate isn't the crucial part, at least for me, plus I know at the very least it'd be pretty easy to set up an AppleScript (invoked via a Quicksilver trigger or something) to do the legwork. TextMate would still have to do a bunch of work, including logging in, so most of the communication would have to be done with the server directly rather than through the browser.
I've read the external editor spec <http://en.wikipedia.org/wiki/ Help:External_editors/Tech> and the sample Perl implementation <http://cvs.sourceforge.net/viewcvs.py/wikipedia/extensions/ee/ee.pl? view=markup>; the part I don't get about it is that the external editor still has to do all the work of screen-scraping the damned page. You can fetch the raw wikitext of a page with ?action=raw, eliminating the need for screen-scraping, in theory.
But to me it seems like the point of grabbing the wikitext is to edit it -- and if you want to submit an edit you *have* to grab the ? action=edit version of the page anyway. Why? Because there are POST values you must submit that you can't get without scraping that page -- two timestamps and an edit token. Even their own Perl implementation resorts to regexes to grab these values from the HTML.
Hopefully the preceding paragraphs convey what it took me hours to conclude: MediaWiki's efforts to facilitate external editors are somewhat promising, but ultimately half-baked. There's a great spec for a protocol called WTTP <http://meta.wikimedia.org/wiki/ WikiText_Transfer_Protocol> which would solve all these problems quite elegantly, in my opinion, but it doesn't seem to have much momentum, from what I can tell.
At any rate, I think MediaWiki's idea of delivering a custom MIME type (so that the browser can associate the content with a specific application) is excellent. (When you request a page with ? action=raw, in fact, it's served with a Content-Type of text/x-wiki.) And the best part about the external editor spec is that it's a really quick, terse way to grab some configuration values that the user would otherwise have to enter.
But when it comes to MIME types, Safari is hardly an A-student (it ignores the MIME type if it thinks it knows better <http:// diveintomark.org/archives/2004/08/13/safari-content-sniffing>), so frankly I'm glad there's more than one way to do it.
(This is what happens when you spend your weekend reading about wiki software instead of going outside.)
Andrew
On Mar 5, 2006, at 7:54 PM, Michael Sheets wrote:
Well I'm actually interested for another reason, I was trying to figure out how to have a text box sent to TextMate from a browser and Allan pointed out the MediaWiki external editor spec page. Would be interested to see how you tackled the issue.
For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate