Thursday, November 22, 2007

My first OpenSearch plugin

Well, yesterday I crawed out of my cave and discovered OpenSearch, the XML-based description format for search engines. Both Firefox 2 and IE 7 can import search engine settings from OpenSearch description files and add the search engine to their respective search bars. In fact, there are already description files for just about every search engine you can think of.

There is a great guide to writing your own OpenSearch description and how to link to the description file such that Firefox or IE automatically discover it. The specification is relatively straightforward so, excited, I decided to whip up an OpenSearch plugin for Kelly & Cristin's Wine Reviews.

I only encountered two obstacles:
  1. Getting an icon for my search plugin. I didn't already have a shortcut icon for my site that I could simply re-use, so I had to first make an icon.
  2. I typed the XML document by hand; I left out the final slash in the OpenSearch XML namespace declaration. Firefox will not recognize the file as an OpenSearch document unless the namespace is exactly right. This should have been quick to diagnose except that Firefox gives you no error message to aid in debugging - it simply refuses to load the file.

The text of my OpenSearch description is here. But if you visit the web site using Firefox 2.0 or later, you'll notice that icon next to your search bar gets a blue highlight; if you click on the icon, you'll see an option to add my Wine Review search to your search bar.

Anyway, without the half hour it took to figure out why Firefox wouldn't recognize my OpenSearch plugin, it would have only taken a few minutes to add a search plugin and plugin auto-detection code (one link tag in the HTML head) to my web site. I don't seriously expect anyone to want to be able to search my silly wine review site from their browser search bar, but certainly was neat to be able to add it.

No comments: