Wednesday, December 17, 2008

Search Engine Plugin

Firefox was one of the first browsers to have this neat feature of incorporating a textbox in which u enter search terms to look for instead of visiting the search engine site and typing ur keywords in the site's search area, this feature saves alot of inconvenience and little time...


The basis for this feature is that there is a folder in firefox called "searchplugins" which contains a plethora of xml files which dictate which search form is selected and how keywords are submitted, and whether suggestions for keywords should appear in case user was writing into search plugin's textbox.
Below is an example of a typical xml search plugin file,

<SearchPlugin xmlns="http://www.mozilla.org/2006/browser/search/">
<ShortName>BlahBlah search</ShortName>
<Description>BlahBlah Search Engine Plugin</Description>
<InputEncoding>UTF-8</InputEncoding>
<Image width="16" height="16">data:image/x-icon;base64,R0lGODlhEAAQAJECAP8AAAAAAP///wAAACH5BAEAAAIALAAAAAAQABAAAAIplI+py+0NogQuyBDEnEd2kHkfFWUamEzmpZSfmaIHPHrRguUm/fT+UwAAOw==</Image>
<Url type="text/html" method="GET" template="http://search.balhblah.com/search">
<Param name="p" value="{searchTerms}"/>
<Param name="ei" value="UTF-8"/>
<MozParam name="fr" condition="pref" pref="Blah-fr" />
</Url>
<SearchForm>http://search.blahblah.com/</SearchForm>
</SearchPlugin>

As u can see the First line (<SearchPlugin...>)is a tag for the file, the 2nd line (<ShortName>)is the name u c inside the search box when its empty and is not selected for writing, and when u click on the list of search plugins available for ur browser.
<Description> tag is the description info about the plugin that is usually seen when the plugin is inspected further by browser.
<InputEncoding> tag tells the plugin how to treat the keywords enterd, UTF-8 is the most widely used encoding, however, some plugins might use others, so choose according to ur search keywords and language.
the next part (<Image ..../Image>) tells the browser which image should appear next to the search box, and wat kind of image, in addition to its dimensions, in this case (which is the most widely used method) tje image is 16x16 pixels and is of PNG type icon, the next few lines represent image data encoded in the mentioned base64 format.
the following tag (<Url.../Url>) states how to treat the keywords entered and whether or not to show suggestions related to keywords entered, in the previous example no suggestions will be presented as focus is mainly on how to submit search request.
The Last line (<SearchForm>) states which form to submit the written keywords to for the search engine to process.
A number of situations can arise in day to day use of browsers, for example u might like ur search plugin to search images section of search engine instead of web or vice versa, and u might want to remove the suggestions feature or u might want to decrease the amount of info ur search plugin submits to the search engine and limit it to the keywords only....
To change search of google from web search to image search change the template to http://www.images.google.com" and save it into a different name so as to keep both, remember to change the Short name at least, so that u would be able to tell which is which when u search!

<Url type="text/html" method="GET" template="http://www.google.com/search">
<Param name="q" value="{searchTerms}"/>
</Url>

One last issue can arise, the icon, in order to change the icon u have either to modify the existing icon, in which case u have to decode the base 64 encryption and revert it to the icon and then modify it and re-encode it, then paste it into the search plugin...or most commonly, create, or obtain the image from other sources, ie, web pages, when encode it to base 64 format, by using many of the availabe programs in the web, for example B64Dcode to encode ur image, open the b64 file, copy the base 64 encryted data and paste it over the template search plugin data, but make sure that ur source is a 16x16 PNG icon....

have fun!

Labels: ,

Smilar pages

0 Comments:

Post a Comment

<< Home