![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
Creating OpenSearch plugins for Firefox - MDC:
OpenSearch description file
The XML file describing a search engine is actually quite simple, following the basic template below. Sections in bold need to be customized based on the needs of the specific search engine plugin you're writing.<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/" xmlns:moz="http://www.mozilla.org/2006/browser/search/"> <ShortName>engineName</ShortName> <Description>engineDescription</Description> <InputEncoding>inputEncoding</InputEncoding> <Image width="16" height="16" type="image/x-icon">data:image/x-icon;base64,imageData</Image> <Url type="text/html" method="method" template="searchURL"> <Param name="paramName1" value="paramValue1"/> ... <Param name="paramNameN" value="paramValueN"/> </Url> <Url type="application/x-suggestions+json" template="suggestionURL"/> <moz:SearchForm>searchFormURL</moz:SearchForm> </OpenSearchDescription>
Search and web feeds go together pretty naturally, as anyone who has set up some kind of vanity search feed knows. You go to your favorite Web 2.0 search engine and set up a query like http://web20.example.com/search=john+doe&ouptut=atom and search for "john doe," but rather than getting back results as the usual HTML web page, you get it back in Atom format. You can subscribe to this URL in your favorite feed reader, and you have all the useful features of web feeds attached to this search query. Most notably, rather than having to poll the search engine yourself and having to remember which results you have seen, your reader will simply alert you when there are new results. This simple but very useful concept is the core idea behind the OpenSearch specification.Facebook's simple example:
OpenSearch was originally developed at Amazon.com's A9 incubator. It's a specification under the Creative Commons Attribution-ShareAlike License, covering discovery and description documents for search engines, expression of queries, and the convention of RSS 2.0 or Atom Web feed results. It is very RESTful in nature and complementary to the Atom Publishing Protocol (APP). In fact, many have called for OpenSearch to serve as the query aspect of APP, which provides a way to access identified or located results, but no mechanism for ad hoc query. With all this affinity to Atom and REST, OpenSearch is a natural topic for this Agile Web column. OpenSearch 1.0 is still the latest full version; it has been around since 2005. Version 1.1 is in beta, but has some important improvements and is thus the version I'll be discussing.
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/" xmlns:moz="http://www.mozilla.org/2006/browser/search/"> <ShortName>Facebook</ShortName> <Description>Search Facebook.com</Description> <Image height="16" width="16" type="image/x-icon">http://www.facebook.com/favicon.ico</Image> <Url type="text/html" method="get" template="http://www.facebook.com/s.php?src=os&q={searchTerms}"/> <!--<Url type="application/x-suggestions+json" template="suggestionURL"/>--> <moz:SearchForm>http://www.facebook.com/s.php</moz:SearchForm> </OpenSearchDescription>