miscoranda: by Sean B. Palmer

JimPUT

Jim Ley is an SVG and JavaScript maven, and constantly comes up with surprising solutions to problems you never even thought you had. If you've been following the Shortest Wiki Contest, you'll know that the code has been getting towards five lines these days, and Jim set out to beat it. This is what he came up with:


<b><textarea onchange="x=new XMLHttpRequest();x.open('PUT',location);
x.send(this.value.replace(/(([A-Z][a-z]+){2,})/g,
'<a href=\u0022$1\u0022>$1</a>')+this.parentNode.innerHTML);
setTimeout('location.reload()',999)"></textarea></b>

It's an HTTP PUT wiki using JavaScript. Scary, no? It works, for some value of works, and you can test it out at the JimPUT site I've set up. The source code for the PUT handler in Python is available too. Note the duplication bug caused by parentNode not behaving quite as expected; there may be a fix.

But just imagine setting the HTML as your 404 handler, and then having a directory wide PUT handler... Backlinks don't work, but perhaps the handler could be made to do that—though then the code would be distributed, so either way it doesn't really count for the Shortest Wiki Contest. It may, however, deserve an honourable mention!

I must also just note that QuickPut, an old Python HTTP PUT command line tool that I used to debug the new PUT handler, rocks.

by Sean B. Palmer, at 2004-02-11 02:12:42. Comment?

Porphyria's Lover · Wikke

Sean B. Palmer