Firefox Search Plugins

I have been following the progress of bug 123315 for Firefox/Mozilla. This bug is a request for search plugins to be installed in the user profile directory. They have finally made a patch for this bug so in future versions of Firefox (hopefully 1.1 too) plugins should be installed to the users directory.

Why is this important? Well, if you run under a limited user you cannot add search engines to Firefox without write access to the Firefox folder. Users who try to are not given an error message when they try to add one, it simply is not added. Also at the moment, search engines are added for all users, which may not be desirable (some users may want different search engines to others).

If you want to know how to do a basic search plugin, here is a mini tutorial:

Search plugins are actually very easy to do. If you look in the <Firefox Install>\searchplugins\ folder (by default C:\Program Files\Mozilla Firefox\searchplugins\) you will see all the search plugins used by Firefox. All search plugins comprise of two files - myplugin.src and myplugin.gif (myplugin can be anything as long as it does not conflict with any other files). The .src file contains the details for Firefox to know what website to search and the .gif file (which can also be a png) is the image that is displayed in the Firefox search box and is 16x16 in size.

To create you own, first create a blank text file called mysearch.src in the searchplugins folder. Then add the following:

<search 
   name="My Search"
   description="Search My Website"
   method="GET"
   action="http://www.mysite.com/search.php"
>

name refers to the text you want to see when you click the icon in the search box, description is the description of the search (not used in Firefox at the moment, but may be used by extensions or Firefox in future releases). method is what HTTP method to use (GET is normally used - i.e. when you post any input is passed to the query string). action refers to the page that will do the actual search.

You then need to tell the browser what parameter to pass the query on to (so if you use 'q' and search for 'firefox plugin' then resulting URL will be http://www.mysite.com/search.php?q=firefox+plugin and the user will be directed to it):

<input name="q" user>

You can also pass any other parameters you want to the page:

<input name="sourceid" value="mozilla-search">

You then close of the search tag:

</search>

Finally you provide any information for the browser to update the plugin:

<browser
    update="http://www.mysite.com/plugins/mysearch.src"
    updateIcon="http://www.mysite.com/plugins/mysearch.gif"
    updateCheckDays="7"
>

update is the location of where you will store this plugin on your site, updateIcon is the icon to use and updateCheckDays tells the browser how often to check for any updates.

The resulting contents of mysearch.src should then end up as:

<search 
   name="My Search"
   description="Search My Website"
   method="GET"
   action="http://www.mysite.com/search.php"
>
<input name="q" user>
<input name="sourceid" value="mozilla-search">
</search>
<browser
    update="http://www.mysite.com/plugins/mysearch.src"
    updateIcon="http://www.mysite.com/plugins/mysearch.gif"
    updateCheckDays="7"
>

Then create the image to go along with mysearch.src (i.e. mysearch.gif).


Tags: , ,

Comments

Popular posts from this blog

Select box manipulation with jQuery

Basic Excel Spreadsheet Generation (ASP/ASP.NET)

Link: HTML Agility Pack (.NET)