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:
the above copyright notice appears in all copies of the
software and its documentation, or portions thereof, and
a full copy of this notice is included with the software
and its documentation, or portions thereof.
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.
Download the current release of jQuery (Minified) and put it in your jscripts directory. (/m1/voyager/{xxxdb}/tomcat/vwebv/context/vwebv/ui/{skin}/jscripts/)
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.
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/)
Backup and edit /m1/voyager/{xxxdb}/tomcat/vwebv/context/vwebv/ui/{skin}/xsl/pageFacets/resultsFacets.xsl:
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.
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.
Directly underneath <xsl:param name="tcc_URL"/>, change it too look like this (items in red were added, including commenting out some existing lines):
<!-- ## 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.
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
When results list is loaded, the javascript finds elements in the page with a class='gbsv'.
The isbn associated with that element, either in the image alt tag or the anchor title tag, is sent to google.
If a book cover based on the ISBN is returned from Google, one-transparent.gif is replaced with the book cover.
If no image is found or if an error occurs, nothing is returned, so the user is not affected.