Google Book Covers for WebVoyáge

Disclaimer

Code and instructions for implementing Google Book Cover features for WebVoyáge. No warranties or guarantees of any kind are implied or assumed.
Version 1.0
Scripts by Jim Robinson
Tarrant County College
828 W. Harwood Rd.
Hurst, TX 76054-3299
(817) 515-6116
Email
Copyright © 2024, Tarrant County College ("TCC"). All rights reserved.

For use with the WebVoyáge product by Ex Libris™ LTD.
"WebVoyáge" is a trademark of Ex Libris™ LTD.

jQuery GPL License

jQuery plugin for the Google Book Search Viewability API by Matt Mitchell Copyright © 2008 Rector and Visitors of the University of Virginia

Purpose: Javascripts use Google Books Services to download images of book covers.

No warranties or guarantees of any kind or implied. use at your own risk. It works for us, so we thought we'd share... ;-)

By using this software the USER indicates that he or she has read, understood and and will comply with the following:

TCC hereby grants USER permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee, provided that:
  1. the above copyright notice appears in all copies of the software and its documentation, or portions thereof, and
  2. a full copy of this notice is included with the software and its documentation, or portions thereof.
  3. This software and any associated documentation are provided "as is," and TCC MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESSED OR IMPLIED, INCLUDING THOSE OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, OR THAT USE OF THE SOFTWARE, MODIFICATIONS, OR ASSOCIATED DOCUMENTATION WILL NOT INFRINGE ANY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER INTELLECTUAL PROPERTY RIGHTS OF A THIRD PARTY. TCC, Tarrant County College, its Regents, officers, and employees shall not be liable under any circumstances for any direct, indirect, special, incidental, or consequential damages with respect to any claim by USER or any third party on account of or arising from the use, or inability to use, this software or its associated documentation, even if TCC has been advised of the possibility of those damages.
This code is meant to be used with the WebVoyáge product by Ex Libris™ LTD. Displays book covers from Google Books Services in the results list.

You can see these scripts in action at http://library.tccd.edu. Perform a search. If an image is available from Google Book Services, it will be shown in the results list and in the record view.
    Requirements:
  • WebVoyáge 7
  • Displaying book covers from Google Books uses JavaScript. Browsers with JavaScript disabled will not be able to take advantage of this code, but it will not prevent them from using WebVoyáge normally.
These scripts were not written by Jim Robinson. The scripts have been modified to work with WebVoyáge 7.

Instructions

  • Remember to replace {xxxdb} and {skin} with the path to your skin.
  • You may already have the necessary files (steps 1-3) if you've installed Michael Doran's New Books List.
  1. Download the current release of jQuery (Minified) and put it in your jscripts directory.
    (/m1/voyager/{xxxdb}/tomcat/vwebv/context/vwebv/ui/{skin}/jscripts/)
  2. Download the Google Books jQuery plugin and put it in your jscripts directory.
    (/m1/voyager/{xxxdb}/tomcat/vwebv/context/vwebv/ui/{skin}/jscripts/)
    The original, unmodified JavaScript by Matt Mitchell is available from RubyForge.
  3. Download this tiny GIF image and put it in your images directory. (Credit for the image to Michael Doran?)
    (/m1/voyager/{xxxdb}/tomcat/vwebv/context/vwebv/ui/{skin}/images/)
  4. Backup and edit /m1/voyager/{xxxdb}/tomcat/vwebv/context/vwebv/ui/{skin}/xsl/pageFacets/resultsFacets.xsl:
    1. In the buildResultsList template, find the two instances of <xsl:with-param name="tagType" select="'page.searchResults.item.type.isbn'"/>.
      Underneath each one add
      <xsl:with-param name="tcc_URL" select="page:option/page:element[@nameId='page.searchResults.contents.line1']/page:URL"/>
      Why? This will allow us to hyperlink the image to the record.
    2. In the buildResultsCoverImage template, find <xsl:param name="tagType"/>
      Underneath it add
      <xsl:param name="tcc_URL"/>
      Why? This will allow us to hyperlink the image to the record.
    3. Directly underneath <xsl:param name="tcc_URL"/>, change it too look like this (items in red were added, including commenting out some existing lines):
      <!--<xsl:for-each select="$Configs/pageConfigs/resultsCoverTag[@nameIdMatch=$tagType]">-->
         <div class="resultListCoverImageCell">
            <!--<img src="{@linkPRE_TEXT}{$tag}{@linkPOST_TEXT}" class="resultListCoverImage" alt="{@altText}" onload="checkImage(this)"/>-->
            <a href="{$tcc_URL}" class='gbsv' title='ISBN:{$tag}'><img src='/vwebv/ui/en_US/images/one-transparent.gif' class='gbsv' alt='ISBN:{$tag}' border='0' /></a>
         </div>
      <!--</xsl:for-each>-->
      
      Why? This is the image that will be replaced by a book cover if all goes well.
  5. Backup and edit /m1/voyager/{xxxdb}/tomcat/vwebv/context/vwebv/ui/{skin}/xsl/pageTools/frameWork.xsl:
    1. Find
      <!-- ################################### -->
      <!-- ## WebVoyage Javascript Includes ## -->
      <!-- ################################### -->
      
    2. Above or below this, add the following:
      <!-- ## keep javascript to a minimum ## -->
      <xsl:variable name="searchResultsTitles" select="'page.searchResults.titles' "/>
      <xsl:if test="contains($searchResultsTitles,/page:page/@nameId)">
         <script type="text/javascript" src="{$jscript-loc}jquery-1.x.x.min.js"></script>
         <script type="text/javascript" src="{$jscript-loc}gbsv-jquery.js"></script>
         <script type="text/javascript">
            function loadBookCovers() {
               $.GBSV.init();	
            }
         </script>
      </xsl:if>
      
      Note that the jquery-1.x.x.min.js file should be the same name/version as the one downloaded and installed in step 1 of these instructions.
      Why? This loads all the necessary JavaScripts and creates a function to load the book covers. In other examples of the jQuery plugin you may have seen, the GBSV.init() function is not wrapped in the loadBookCovers() function. It is done this way because the function to load the bookcovers must be called after the function to highlight search terms or it won't work in Internet Explorer and Safari browsers.
    3. In the same file (frameWork.xsl), find
      <body class="frameWorkUI" onLoad="setFocus('{/page:page/@nameId}'){$highlightNodes};timedMsg({$timeout}, {$grace}, '{$timeoutMessage}')">
      and add loadBookCovers(); near the end of this line so it looks like this (additions in red):
      <body class="frameWorkUI" onLoad="setFocus('{/page:page/@nameId}'){$highlightNodes};timedMsg({$timeout}, {$grace}, '{$timeoutMessage}');loadBookCovers();">
      Why? This calls the function to load the book covers AFTER the function call to highlight the search terms in the text so it will work in Internet Exporer and Safari browsers.

How It Works

  1. When results list is loaded, the javascript finds elements in the page with a class='gbsv'.
  2. The isbn associated with that element, either in the image alt tag or the anchor title tag, is sent to google.
  3. If a book cover based on the ISBN is returned from Google, one-transparent.gif is replaced with the book cover.
  4. If no image is found or if an error occurs, nothing is returned, so the user is not affected.

Troubleshooting

    Some hints about debugging javascripts:
  • Download a Firefox browser (http://www.mozilla.org) and install the FireBug extension.
  • Download an Opera browser (http://www.opera.com) and turn on "Report JavaScript Errors".
  • Use object detection instead of browser detection and element IDs instead of names or array positions!

Questions and comments can be sent to Jim Robinson at Tarrant County College.

Last modified: April 14 2010.