Tuesday, October 2, 2007

OpenSearch for OpenGrok

To speed up my searches on OpenGrok, I wrote a little OpenSearch descriptor. You know, that little technology that allows you to put any search engine in that little search box on IE7 and Firefox 2+. Just put the following XML on a file called opengrok.xml, on the root of the OpenGrok context of your servlet container:

<?xml version="1.0" encoding="UTF-8"?>
<opensearchdescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
<shortname>OpenGrok</shortname>
<description>Search in OpenGrok</description>
<tags></tags>
<contact></contact>
<url template="http://YOUR_SERVER_HERE/source/search?q={searchTerms}&amp;start={startPage?}" type="text/html">
</opensearchdescription>

Change YOUR_SERVER_HERE to your actual OpenGrok server.

Then declare the descriptor in index.jsp's head (that's also on the root of the context), so it can be auto-discovered:

<link rel="search" href="opengrok.xml" type="application/opensearchdescription+xml" title="OpenGrok Search" />

And that's it, now Firefox and IE7 will offer you to add the new search plugin.

Have fun grokking your code ;-)

Oh, I should mention that there is also a specific Firefox toolbar extension for OpenGrok, but apparently it's incompatible with Firefox 2+...

EDIT 9/6/2009: This feature is now in OpenGrok's trunk so it will be part of the next release.