Following up on my previous post about the Christchurch Digital NZ hackfest, I did find the bug in my search plugin script, it was just one of those minor typos that takes ages to find because the error message you got when you tried to use it was completely uninformative. Sigh. However, since I spent most of my time on this during “Mozilla Service Week” I chalked up a few hours there to add to their total. Kudos to Mozilla for organising that and I’ll be sure to take part in a more serious way should they do it again.
Digital NZ has created a Custom Search Builder, and it seems to me that they could add Search Plugin generation to this reasonably easily. All they need to do is take a copy of my sample and use it to create a template the swaps out the content of the ShortName and Description tag, and also the template attribute in the <url> tag – everything else can stay the same. Then they need to add a javascript install link to the search result pages similar to the one here.
Heres what my sample search plugin file looks like (NB: First bit of code I can recall posting in this blog. I promise not to make it a habit.)
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/"
xmlns:moz="http://www.mozilla.org/2006/browser/search/">
<ShortName>Digital NZ</ShortName>
<Description>Digital NZ Archive Search</Description>
<InputEncoding>UTF-8</InputEncoding>
<Image width="16" height="16" type="image/x-icon">data:image/x-icon;base64,[data string goes here]</Image>
<Url type="text/html" method="get" template="http://search.digitalnz.org/en/search">
<Param name="search_text" value="{searchTerms}"/>
</Url>
</OpenSearchDescription>
The Webserver has to serve up that XML file with a MIME type of application/opensearchdescription+xml
eg using apache, in a directory where .xml isn’t reserved for anything else, one could put this in a .htaccess file:
AddType application/opensearchdescription+xml .xml
It’s also relatively trivial to add something to the headers of a webpage to enable autodiscovery of one or more search plugins. I’ve done that on my example page. Once you’ve done so it’ll appear in the search plugin manager for the browser, like this:
For more details, and how to do other cool things like enabling search completion, see:
OpenSearch Specification
Mozilla article on creating OpenSearch Plugins for Firefox



0 comments ↓
There are no comments yet...Kick things off by filling out the form below.
Leave a Comment