Tech Blog

Search provider browser plugins for MetaLib quicksets

  • Description
    Recent versions of Firefox and Internet Explorer have the facility for users to add “search providers” to the browser’s search box.  This development allows users to add MetaLib quicksets as browser search providers, including “My Sets” they have assembled themselves using the features of MetaLib’s My Space.
  • Author: Matthew Phillips
  • University of Dundee
  • Year: 2008
  • License: GNU General Public Licence v.3 or later
  • Link to terms: GNU General Public License
  • Skill required for using this code: Intermediate.

State

Stable

Programming language

Perl and Javascript

Software requirements

This has been tested on MetaLib version 4.  The Perl DBI and DBD::Oracle modules must be installed: you will probably find they are already present.

Author(s) homepage

http://www.dundee.ac.uk/library/

Download

This contains the two Perl CGI scripts to be installed, and the Javascript required to be added to the public MetaLib interface.

Working example

See the link to “Install search providers” at the bottom of the QuickSearch screen.

Using the following Ex Libris open interfaces

None: uses Perl DBI access to underlying Oracle tables

Installation instructions

Transfer the attached files to your MetaLib server and place in the following locations:
  • search-plugin and sets-plugin should go in $http_root/cgi-bin
  • dun-quick-1-help and quick-1-tail are examples to be used later.  See below.
Make sure that search-plugin and sets-plugin are world readable and world executable:

chmod a+rx sets-plugin search-plugin

You may need to edit the first line of each script to point to your Perl interpreter. Do “which perl” to find location if required.

Customise the two scripts to suit your institution.

The sets-plugin script will want altering to change references to “CrossSearch” in the script (that’s what we have renamed MetaLib to):

<h1>Install browser search providers</h1>
<p>You can install any of the CrossSearch QuickSets as search providers in Internet Explorer 7 or
Firefox.  If you have created your own sets of resources using My CrossSearch then these may
also be installed in your browser's search box.  Simply find the set in the list below, and
click to install!</p>

You will probably need to alter the code which looks up the list of QuickSets. This depends on knowing the z122_bor_id, which in our case was PATRON3. Find the following line and adjust as necessary:

if ($query && $query->execute('PATRON3     ')) {

Note that the patron ID must be padded out with spaces to exactly 12 characters long. To find the correct patron ID, use the following SQL:

s+ vir00
select Z312_REC_KEY from z312 where Z312_NAME=’DUNDEE-ENG’;
quit

(replace DUNDEE-ENG with the username used for your quickset configuration.).  Alternatively go to the list of users in the /M interface and find the quicksets user.  Click on Update and you will find the patron ID as the user_id parameter in the URL of the resulting page.

The search-plugin script will need editing in the following section:
        print <<EOS;
Content-Type: application/xml
<?xml version="1.0" encoding="UTF-8"?>
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
<ShortName>CrossSearch: $name</ShortName>
<LongName>CrossSearch: $name</LongName>
<Description>Performs a keyword search on the CrossSearch service from University of Dundee</Description>
<InputEncoding>UTF-8</InputEncoding>
<Url type="text/html" template="http://cross-search.dundee.ac.uk:80/V/?func=QUICK-1-CHECK1&amp;MODE=simple&amp;FIND_REQUEST_1={searchTerms}&amp;GROUP_NUMBER=$quickset&amp;FORCE_LOGIN=y&amp;dunsid=IE7search"/>
<Tags>university dundee cross-search crosssearch</Tags>
<Image height="16" width="16" type="image/x-icon">http://www.dundee.ac.uk/library/graphics/dundee-shield-16.ico</Image>
<Developer>IT Support, University Library, Dundee</Developer>
</OpenSearchDescription>
EOS

You will need to modify the URLs to point to your own MetaLib server (the template attribute of the Url tag) and to point to your own 16 x 16 pixel graphic to be displayed in the browser (the contents of the Image tag). You can now test the scripts by going to the following URL (modify this to reflect the address of your MetaLib server).
You should see the list of your QuickSets. If not check the patron ID etc.

Next you need to decide where to provide the link to this screen in MetaLib.  We have placed it in the quick-1-tail section of the QuickSearch screen, along with some user help.  The screen is opened using Javascript.  This is unfortunately necessary because we need to capture the user’s session ID so that we can look up their session and find their “My Sets”.  The difficulty is capturing the session ID, so the code relies on the server plus session appearing in the simplifiedTop element of the page.

The code we use is supplied in the file dun-quick-1-help.  As you see, we have included that whole file in quick-1-tail, but you could write it into that file direct if you prefer.

The following is what a cut-down bare minimum version would look like.  Note that you will need to edit the URL to the CGI script.  I guess this could be generalised by obtaining the server host and port from the href attribute also.  Never mind…

<!-- Obtains session details by reading HTML link.  Not possible to use window.location
     because it might end ?RN=nnnnnn rather than a proper session ID. -->
<script language="JavaScript" type="text/javascript">
  function searchInstaller() {
    var w = '';
    var x = document.getElementById("simplifiedTop");
    var y = x.getElementsByTagName('a');
    if (y.length>0) {
      var z = y[0];
      w = z.getAttribute('href');
      w = w.replace(/\?.*/,'');
    }    winPop('','http://cross-search.dundee.ac.uk/cgi-bin/sets-plugin?server='+w,'yes',420,330);
    return false;
  }
</script>
<div class="dun-help">
<p>
You can add any of the above sets to your browser's search provider menu if you use Internet Explorer 7 or Firefox: <a
href="http://www.exlibrisgroup.org/pages/createpage-entervariables.action#" onclick="searchInstaller(); return false;">Install search providers</a> (requires Javascript).</p>

</div>
That’s all.

Known issues

Does not support users with no Javascript.

Page attachments

dun-search-providers.zip

Leave a Reply