This is hardly a new idea and it may not interest a wider audience, but I’ll post it here just the same (if I don’t write this down somewhere I’ll have to start from scratch again next time I want to add a new search engine link).
For the past two or three weeks I’ve been moving gradually to Firefox 2 (away from Camino which I still find faster, lighter and better looking) so I can use and test and try developing for the Zotero plugin my friends over in Mason’s Center for History and New Media have developed. Today I just got really tired of not being able to search our catalog from the Firefox search box. Thanks to the way google exposes the work of others, it didn’t take long to implement. I found several ways to accomplish the task and combined and collapsed a couple of them into this really simple method.
Full details on crafting search engine plugins are available on the Mycroft Project site, but if you’re just looking to implement a Voyager search box, here’s a quick cookbook entry. The focus here is on creating an installable link so users can add the Voyager searchbox to their browsers. The link I provide at the end of this post just installs Mason’s catalog search—if you want to develop one for your Voyager site, you’ll have to modify the two code examples I offer below.
1. Create the plugin code. The name you give this file is optional (I called it MasonCatalog.src) but you need to make sure you pay attention to whatever name you use—you’ll reference it by name in both this file and in the file you create in step 2.
If you run a Voyager site, you’ll see the parts that you need to modify (name=, description=, action=, and update=). You can place this file (and the others) in any web-accessible directory on your server but keep them together (or use complete paths where necessary). The “name=” value is what displays in the empty search box when it is awaiting input.
# Mason Library Catalog Firefox Search Plugin
<search
name="Mason Library"
description="Mason Library Catalog Search"
method="GET"
action="http://magik.gmu.edu/cgi-bin/Pwebrecon.cgi"
update="MasonCatalog.src"
updateCheckDays=5
queryEncoding="utf-8"
queryCharset="utf-8"
>
<input name="Search_Arg" user>
<input name="Search_Code" value="FT*">
<input name="CNT" value="25">
<interpret
browserResultType="result"
resultListStart="PostSearchSortBy1"
resultListEnd="PostSearchSortBy2"
resultItemStart="<TD ALIGN=LEFT VALIGN=TOP>"
resultItemEnd="<TD ALIGN=LEFT>"
>
<browser
update="http://lso.gmu.edu/FFXplugins/MasonCatalog.src"
updateCheckDays=5
>
</search>
2. Next, create an html file. This file is where you’ll put your link for anyone interested in installing the search engine plugin and where you’ll store the javascript necessary to pull off the installation. I named this one AddMasonSearch.html
<html>
<head>
<title>Get Mason Catalog Search Plugin</title>
</head>
<body>
<script
type="text/javascript">
<!--
function errorMsg()
{
alert("Need Netscape 6 or Firefox");
}
function addEngine(name,ext,cat,type)
{
if ((typeof window.sidebar == "object") &&
(typeof window.sidebar.addSearchEngine == "function"))
{
window.sidebar.addSearchEngine(
"http://lso.gmu.edu/FFXplugins/"+name+".src",
"http://lso.gmu.edu/FFXplugins/"+name+"."+ext,
name,cat );
}
else
{
errorMsg();
}
}
//-->
</script>
<a xhref="javascript:addEngine('MasonCatalog','png','Reference',0)" mce_href="javascript:addEngine('MasonCatalog','png','Reference',0)" >Mason Catalog Firefox Plugin</a>
/body>
</html>
3. Figure out what you want to use for an icon and create a .png file. I did that with PhotoShop but there are many other alternatives. Put the png file in the same directory you reference in the window.sidebar.addSearchEngine() function during step 2.
The minimalist outcome of this coding can be seen here: