Feed on Posts or Comments 06 January 2009

Extensions & MediaWiki robchurch on 30 Mar 2007 11:50 am

Extension output handlers

While quite flexible, our existing parser hook mechanism is a bit limited for developers wanting to affect the OutputPage object representing the actual rendered page; things like adding links to stylesheets or attaching JavaScript aren’t easy to do, mainly due to caching.

I’ve been messing about in a branch, preparing a mergeable version of a not-too-ancient patch Brion put together which adds a neat mechanism for working around this; extension output handlers.

An extension output handler is basically an object which is attached to the ParserOutput, and so is serialised and stored in the parser cache along with everything else (page text, metadata, etc.). The idea I had for implementation, prior to inspecting Brion’s code and deciding it was a better solution, was to provide a couple of simple accessors and mutators in ParserOutput and use these, combined with hooks executed when the page is put together, to make the changes.

However, the output handler mechanism is a lot nicer, especially from the developer’s perspective, since it takes a lot of the hook hassle away. By avoiding the hook mechanism, it’s probably more efficient, although I don’t pretend to have any benchmarks to back up that guess at all.

The great news is I barely had to write any code at all…Brion’s patch was easily adaptable to the branch, and all I really did was write my own little test extension to make sure it actually worked…and it does, well. I’ve written up (hopefully) thorough documentation and put a prettified copy of it on the MediaWiki.org web site.

Now I’m waiting for the aforementioned to review and approve it for merging. Once this, or something offering the same capabilities, goes live, then we have much greater flexibility in the quality of parser hook extensions we can write, and for my mind, I’ve got my eye on the idea of a nice little slideshow extension…

2 Responses to “Extension output handlers”

  1. on 12 Aug 2007 at 8:05 pm 1.Dean said …

    Please hurry up with a slideshow extension. I’ve been playing with a rudimentary one that works OK, and even imbedding a mp3 player extension into each slideshow page for an audio description when viewing.
    However, a fully featured, easy to implement extension would be a real treat, IMO.

  2. on 12 Aug 2007 at 8:27 pm 2.robchurch said …

    In fact, there’s a more or less working Slideshow extension in the works, as I’ve mentioned in later posts on this blog…

Trackback This Post | Subscribe to the comments through RSS Feed

Leave a Reply

You must be logged in to post a comment.