15 Posts Tagged "code"

Blog Pile

How to Put Anything in Your MediaWiki Pages

Well, “anything” is loosely termed. I run about 6 different MediaWiki sites for the NMC, and I have to remind myself alot that the software is a huge black box (it works super) and I am pretty sure the things I have done tap maybe 8% of what it is capable of doing.

One of the limits is the kind of content you can put in the editing pane. Sure you can add additional tags you want to allow, but even a security lazy bum like me is not interesting in allowing any person to add <script> tags in there. Danger, Danger, MediaWiki Robinson!

So in prepping some new things for the wiki that we have reset for the 2009 NMC Horizon Project— we don’t delete the old stuff or hide them in edits; each year I migrate content to its own namespace, e.g. http://horizon.nmc.org/wiki/Horizon2007:Main_Page and http://horizon.nmc.org/wiki/Horizon2008:Main_Page. I’d like to know if I can have different Sidebars for these, but that’s another tinkering.

I was thinking a nice feature would be to add the Google Custom Search Engine I toyed with last year- a CSE is an incredible free tool where you can make your own search site, that rather than searching all 12 trillion Google pages, confines the search to a set of web sites that you pick. That is an amazing tool! Where is yours?

It was easy peasy to put it on the NMC web site, as the page I made is completely custom PHP- it’s not even drupal, just mocked the style of the main site, and to add a drupal block with the form that pushes searches there as a block on the right sidebar at http://horizon.nmc.org/:

But getting that functionality inside MediaWiki? Hmmmm. There is embed code provided with the GoogleCSE, but it is merely (well not so merely) a Javascript tag linked to a remote source file, and you cannot just slap JavaScript into your wiki text.

Then a light bulb went off- I bet it could be done by writing a custom MediaWiki Extension- I had done some mods of an RSS embedding extension almost 2 years ago (and still use it extensively!). You just need to know the syntax and have it spit out web content.