Creating A Search Plugin - Opensearch and FireFox Addon


NotAsCoolAsItSeems's picture
6 points

 

 You can install my addon here Mozzilla Firefox add-ons. It is just a search addon, but how to make it and other uses for xml files are listed below

 

Someone asked in the Drupal forums about search and FireFox plugin creation, so I thought I would make a post about it. If anyone notices anything around the site that they find interesting or would like more info on some part of the sites development  leave a comment here or at the forum and when I have time I will write something up.

As I mentioned in earlier this site is is primarily for people to search for issues and defects other users have submitted so that they can see if a product is suitable for them. To allow this I have so far done three things.

  • Installed a modified fuzzy search module. I did this because the default Drupal search is unforgiving and more often than not will return no results or exclude relevant results. It isn't tolerant of user mistakes such as mis-spelled words or bad phrasing. The Fuzzy search in contrast is too sensitive but yields very usable, input tolerant results. Ideally I would like to use a facet search , or a more robust search technology , but the current server wouldn't handle the load.
  • I created an OpenSearch plug-in, this is a site search that is supported by most modern browsers and is very simple to set up. It is basically an XML file. When a visitor comes to your site the search bar will highlight that there is an OpenSearch available (look up at your search box). Visitors can add your search by using the drop-down link in their search bar or you can provide a link that says "Hey install my really cool sites search" or even an image like below.

 

Wow look at my rockin' photoshop SkiLlz

Add Our Site Search To Your Browser

 

  • The last thing I did was to use this XML file to promote my site, there are actually quite a few things you can do with this XML file. You can submit it to various search engines and it will become a feed , A9 does this.(I found this out because of bot activity) Search results from your site get listed in the feed. I haven't done this due to privacy concerns and the constant ping-backs would add more load to the already groaning shared host I am on. You can also add it to sites that list OpenSearch plug-ins and you can create a Mozzilla Firefox add-on. <-- Go take a look, install it, give me a nice rating please.

 

 

Creating an Opensearch XML file and a FireFox add-on.

The opensearch file is very simple here is what mine looks like:

<?xml version="1.0" encoding="UTF-8"?>
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
<ShortName>Not As Cool As It Seems</ShortName>
<Description>Search Not As Cool As It Seems</Description>
<Tags>gadgets product review problems issues tech</Tags>
<Image height="16" width="16" type="image/x-icon">http://www.notascoolasitseems.com/favicon.ico</Image>
<Url type="text/html" method="GET" template="http://www.notascoolasitseems.com/fuzzysearch/results/{searchTerms}"/>
<InputEncoding>UTF-8</InputEncoding>
<AdultContent>false</AdultContent>
</OpenSearchDescription>

It only has a few required parts, mostly descriptions, and it must be well formatted XML or IE will not install it.

Most of the above is very straight forward. If you want to create your own just copy mine to a text editor, replace my descriptors with your own sites details and save it as opensearch.xml. Don't forget to create your own favicon image, it is what shows up in the search bar.

The only tricky part is the search string: the second blue line.

In most cases you can just do a search on your own site. Copy the resulting URL from your browser and use that string, you will need to replace whatever you searched for with "{searchTerms}".

Place the opensearch.xml file in the root folder of your site. So on my site it is http://www.notascoolasitseems.com/opensearch.xml

The final step, you need to tell the visitors browser it is available. You do this by placing some code in the <head> of your sites pages.

Auto-discovery of search plug-ins

A web site that offers a search plug-in can advertise it so that users can easily download and install the plug-in.To support discovery, you simply need to add one line to the &lt;head&gt; section of your web page:

<link rel="search" type="application/opensearchdescription+xml" title="searchTitle" href="pluginURL">

So mine is :

<link rel="search" type="application/opensearchdescription+xml" title="Search Not As Cool As It Seems" href="http://www.notascoolasitseems.com/opensearch.xml">

In Drupal you can add this to the head section of your template in  "page.tpl.php"

If you have done everything else and the search isn't working properly it may be bad XML formatting.

You can go here and use a service to create an xml search file , it is free. Don't forget to add your search to the list.

 

Creating a FireFox Add-on for your search

You have already done it - how easy was that?

Actually you might need to embed the favicon into the XML, I can't remember if this was required, The link above will do that, just fill in your search details on the form save the search and then look at the source when you are finished.

Unless you have a service to offer, something of value, or a specific target audience, then I would skip doing this. If it is just your personal site it isn't really appropriate.

 

To make the add-on go to the FireFox Addons home page sign up for a developers account.

Select "search" as the type of plug-in when you are filling out the details. Choose your target areas and categories carefully. Upload your XML file and place it in the sand box.

 

It won't become active straight away, you will need to try installing it after marking it as experimental.

Once you are happy with the details someone needs to rate and review your plug-in, this is required for it to become "public"

Once you get two or more reviews you can request that the plug-in be made public. It is then reviewed by Mozzilla volunteers and if accepted you will receive an e-mail. You can then set your Plug-in to public.

 

Here is a tip: submit a working plug-in for review on a Tuesday or Wednesday, it should be ready by Friday. On the Friday it will be at the top of the "newest plug-ins" list. Most users download what they see first if it is interesting. Friday and Saturday my search is downloaded about 30% more than any other day. I make the assumption most people install a search to test, then a large proportion uninstall it if it isn't useful to them, so don't be discouraged if it doesn't boost your sites visibility.

 

 

If you have found this info useful show me some love, add a link to my front page, download my plug-in, rate it, post about my site on twitter, facebook, delicious, stumble upon, reddit, myspace, e-mail your friends, phone your politicians and send me some money...... or you could just leave a comment and vote up this blog post 

 

If you are new to web development like me you might want to read the blog from the beginning, see some of the mistakes I have made and learn from them.

As always feedback and ideas are welcome - I love e-mail.

 

 

 

 

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
An Unregistered User's picture
An Unregistered User
good plugin
-1 points

Good plugin that nicely fits into my Firefox browser, good job.

tags:alliance leveling

An Unregistered User's picture
An Unregistered User
Good Post
4 points

Nice post , thanks for the info. I am just setting all this stuff up myself at the moment.

An Unregistered User's picture
An Unregistered User
I didn't know you could do this
4 points

I didn't know about the open search, thank you for posting this.
Took me a little longer than five minute though :) good stuff.

I read the rest of the blog, good luck it seems you are doing OK so far.

Post new comment

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <p> <span> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <br> <quote> <blockquote> <b> <u> <i> <strong>
  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <drupal6>, <java>, <javascript>, <php>. The supported tag styles are: <foo>, [foo].

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.