Today on Lifehacker there was a post with a Mozilla search plugin just for lifehacker.com. Coolness.
But, instead of giving folks a super simple link to auto-install the plugin, they provided the two files (source and icon) in a zip file. So I was kind and offered adivce on creating the super simple auto-install link:
<a href="javascript:window.sidebar.addSearchEngine('http://url/to/lh.src', 'http://url/to/lh.gif', 'Lifehacker', 'Reference');">Install the LH Search Plugin</a>
Cool, huh?
Then I got to thinking about people who downloaded the zip and wanted to install the plugin without having to restart Firefox. And what if they don't run their own webserver… got me to thinking about netcat…
A couple of commands at a bash prompt… one for the source and one for the icon… then a javascript call in Firefox…
(echo "HTTP/1.1 200 OK" ; echo "Content-Length: "`wc -c lh.src | awk '{print $1}'` ; echo "Connection: close" ; echo "Content-Type: application/x-wais-source" ; echo ; cat lh.src) | nc -l -p 1500 >/dev/null
(echo "HTTP/1.1 200 OK" ; echo "Content-Length: "`wc -c lh.gif | awk '{print $1}'` ; echo "Connection: close" ; echo "Content-Type: image/gif" ; echo ; cat lh.gif) | nc -l -p 1501 >/dev/null
<a href="javascript:window.sidebar.addSearchEngine('http://localhost:1500/lh.src', 'http://localhost:1501/lh.gif', 'Lifehacker', 'Reference');">Install the LH Search Plugin</a>
And, yes, it would be easier to just install Apache. Update: OK, it would actually be easier to install XAMPP, "an easy to install Apache distribution containing MySQL, PHP and Perl. XAMPP is really very easy to install and to use - just download, extract and start."
Oh, and if you're wondering, I couldn't remember which headers MUST be returned in a web request, so I just included a few that I knew would be a good idea to have in there… works well enough, it seems.