« 29 | Main| XIDED 00.02.00 Released »

Creating OpenSearch plugins in Domino

Category show-n-tell thursday

Firefox 2 and IE7 both support the OpenSearch description format for search plugins. These plugins allow users to customize how they search the web - typically enabling the user to search a given website directly from the browser's search bar. In addition to being able to browse directories of existing search engine plugins (Firefox, IE), if you're browsing a page that provides one or more search plugins, an option to add their search engine(s) will display in the search bar drop-down. On a side note, this is one of the few items that I think IE7 handles better than Firefox; if the page you're viewing offers a search plugin you're not using, the drop-down is highlighted (similar to both browsers' RSS awareness), whereas in Firefox there's no indication that a search engine is offered until after you click the drop-down. Try it now...

For your searching pleasure, I've added two plugins to my site - one which allows you to search my blog without actually being at my blog; and a much more useful one, which allows you to search Richard Schwartz's Show-and-Tell Thursday aggregator directly from your browser bar.

These are easy to set up. Here's how:

1. Create your plugin XML.
The OpenSearch format supports all manner of tags for describing the plugin you're offering, but you can get by with including just a few. Here's what the XML looks like for the search plugin for this site:

<?xml version="1.0" encoding="UTF-8"?>
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
<ShortName>TimTripcony.com</ShortName>
<Description>Search TimTripcony.com.</Description>
<Image width="16" height="16">data:image/x-icon;base64,AAABAAEAEBAQAA........</Image>
<Url type="text/html"
template="http://www.timtripcony.com/blog.nsf/BlogSearch?SearchView
&Query=Field%20SearchText%20contains%20{searchTerms}&Start=1&Count=-1"/>
</OpenSearchDescription>

Most of the above is fairly self explanatory, but there are two items that bear mentioning:

  • The messiness under the Description tag is an optional Image tag, which allows you to associate a .ico (like our old friend, favicon) with your search engine. IE will ignore these, but in Firefox it indicates at a glance which engine is currently selected in the search bar. There's an online utility that allows you to upload (or specify the URL of) the .ico you'd like to use and churns out a representation of that file in the syntax that the Image tag requires.
  • The template attribute of the Url tag may require some experimentation at first to ensure the XML is valid... for example, ampersands must be encoded, but equals signs do not. The key portion of this is inclusion of the {searchTerms} placeholder in the correct spot. Basically this URL is the address your users are taken to when they perform a search directly within the site, but with the placeholder inserted where appropriate.


2. Post the XML file anywhere that your site visitors can get to it.
Since my site uses the Blogsphere template, I attached mine as download resources in the blog database. But the file can sit anywhere on the server (or another server, for that matter), as long as the location is accessible to site visitors.

3. Reference the file location in a link tag within the head portion of your site markup.
The syntax is as follows:

<link title="pluginname" href="pluginlocation" type="application/opensearchdescription+xml" rel="search"/>

Just replace the italicized attributes with the title and path of the XML file.

Easy as that. Happy searching.

Next up: Domino authentication via AJAX - one strategy for allowing users to log in when the root directory of a site differs from the root directory of the server.

Comments

Gravatar Image1 - I have already created search add-ins for Lotus site in Firefox and am glad to hear that they will work in IE7 also. I will have to test them on the home laptop and see if the work without being modified.

Sean---

Contact Me

Hire Me

Elsewhere

What the Quote?

"You make funny coding noises."

Laura Tripcony

"With a big enough lever, I could lift the world."

Steven Rodgers

"No, she's all four-cylinder ugly on the inside."

Laura Tripcony

"The best thing about Boolean is, even if you're wrong, you're only off by a bit."

John Jaeckle

"...and Jed has dysentery."

Tim Tripcony

Apparel

Lotus Rocks

I write the code that makes the young girls cry

Current Terror Alert Level

Assorted Linkage

ClustrMap