User:Nihiltres/Click-to-ImageMap

From Wikipedia, the free encyclopedia

ImageMap is a useful MediaWiki extension that allows images to be clickable using nice, clean code. Since this extension hasn't always been active on the Wikimedia servers, we have a workaround template widely in use, {{click}}, which uses a nifty little hack to superimpose an invisible link over an image. This workaround doesn't work right in all contexts, making it a usability problem. It is still useful in some cases, however, since ImageMap does not support templates or template parameters. We should therefore convert all instances of {{click}} that can be converted.


I wrote a couple of scripts in AppleScript that take {{click}} input and output some virtually equivalent ImageMap code. They require three things to work: A computer running Mac OS X, the included application TextEdit, and a third-party scripting extension called TextCommands, freely available online. The scripts follow. The older, deprecated script is in a very messy state - I coded it and debugged it very quickly, more as a proof-of-concept than anything else, though it is functional. The second script is vastly preferable.

I recently decided to recode the tool to let it parse a whole page for all the {{click}}s at once. This version is somewhat cleaner, but it runs quite slowly - a limitation of the simplicity of AppleScript, though improved somewhat by simplification of some of the more inefficient commands. Feel free to suggest improvements to me. It also could use a better interface - pasting an entire page worth of wikicode into a single short line in a dialog box is unwieldy for all that it is workable. I may write a bot framework and get it to make edits semi-automatically, though for now it works fine just as an easy method, or a shortcut for pages with dozens of {{click}}s.