HiI'mJaanus.Blog,Works.

A Movable Type plugin

I was supposed to do a bunch of stuff tonight, but skipped it and instead did my first Movable Type plugin from scratch. Harder than I expected, since it’s Perl which has its own funny conventions. Also I found the documentation on the MT site quite lacking. I could find a lot of useful examples with Google, however, such as this.

So the whole experience consisted of googling for MT plugin examples in both Google and Six Apart site, opening them up, trying things out and going back again. There’s a simple rule of thumb that always helps: start with simple and once you get it working and are sure of what it does, move on to more complex stuff.

I wanted to do something that parses entry and comment text and replaces some strings with other strings based on the plugin configuration. I went for doing a global pre-save hook. Doing a text filter would also have worked and left the texts in the database into a nicer state, but I can’t see how it would have worked without adding another text filter in the filter selector in the editor, and I didn’t want to do that, as the usage had to be really really transparent.

It all kind of makes sense once you figure it out and manage to get around all the funny errors. Also having done regexes for years helps a lot, as they’re the “Swiss army knife” or Perl, but can be quite intimidating initially.

And what does the plugin do, to start with? Hmmm… (wasntme)

Comments