Amazon Book Covers for WebVóyage

Disclaimer

Code and instructions for implementing Amazon Book Cover features for WebVóyage. Inspired by Jackie Wrosch's WebVoyáge Interface Improvements presentation at EndUser2007. Use at your own risk. TCC is not responsible for damage or problems caused by the use of this code. No warranties or guarantees of any kind are implied or assumed.
Version 1.0
Scripts by Jim Robinson
Tarrant County College
828 Harwood Rd.
Hurst, TX 76054-3299
(817) 515-4310
Email
Copyright © 2024, Tarrant County College ("TCC"). All rights reserved.

For use with the WebVóyage product by Endeavor Systems, Inc. Ex Libris™ LTD.
"WebVóyage" is a trademark of Endeavor Information Systems, Inc. Ex Libris™ LTD.

PHP Copyright© 2001-2005 The PHP Group All rights reserved.

Purpose: Javascript and PHP scripts use Amazon Web Services to download an image of a book cover.

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, and
  3. neither the software nor its documentation, nor portions thereof, is sold for profit. Any commercial sale or license of this software, copies of the software, its associated documentation and/or modifications of either is strictly prohibited without the prior consent of TCC.
  4. Title to copyright to this software and its associated documentation shall at all times remain with TCC. No right is granted to use in advertising, publicity or otherwise any trademark, service mark, or the name of TCC.
  5. 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 WebVóyage product by Endeavor Systems, Inc.™ Ex Libris™ LTD. Displays book covers from Amazon Web Services in the record views.

The javascripts, php source, and instructions are available in bookcovers.zip.

You can see these scripts in action at http://library.tccd.edu. Search for a title and view it in record view. If an image is available from Amazon Web Services, it will be shown in any record view.

Requirements:
  • PHP must be installed on the WebVóyage server. If you do not have PHP installed and don't wish to install it, feel free to rewrite this for Perl (which is installed on your WebVóyage server) or ColdFusion or any other server-side processor you have available to you. Also check out Jackie Wrosch's perl code. Due to JavaScript security issues, the server-side processing must be done on the same server unless you have a signed security certificate installed, which I haven't done and can't help with... ;-)
  • Displaying Amazon book covers uses JavaScript. Browsers with JavaScript disabled will not be able to take advantage of this code, but it will not prevent them from using WebVóyage normally.

Instructions

  1. Get an Amazon Web Services Developer Key (It's free!)
  2. Download the php and javascript sources from bookcovers.zip and unzip it.
  3. Add the folder called "js" to your html folder (located by default at /m1/voyager/xxxdb/webvoyage/html). If a "js" directory already exists, simply copy bookcovers.js to the "js" directory. If you're using one of my spellchecker javascripts, you can copy the spell.js file over instead, which contains code for the spellchecker and for the bookcovers, but only requires the browser to download a single javascript file for both.
  4. Add the folder called "bookcovers" to your html folder (located by default at /m1/voyager/xxxdb/webvoyage/html)
  5. Inside the "bookcovers" directory, edit the "getCover.php" file: Where is says $key='Your Amazon Web Services Developer Key Goes Here', add your Amazon Web Services Developer Key.
  6. At the top of /m1/voyager/xxxdb/etc/webvoyage/local/display1.cfg, add HTML:020||a:</td></tr></table><img src='/images/load.gif' width='1' height='1' onload="getBookCover('{a}')" /><div name='bookcover' id='bookcover' style='float:right;margin-right:100px'></div><table>
  7. Do the same for display2.cfg, display3.cfg, etc. where you would like the bookcover images to appear.
  8. Add code to your header.htm. (Located by default at /m1/voyager/xxxdb/etc/webvoyage/)
    • Add this line between the <CENTER></CENTER> tags: <script type="text/javascript" src="/js/bookcover.js" /></script>

    The following is the default WebVoyage header.htm with the changes above in boldface type:
    (you can copy and paste this into your header.htm file)
    <!-- Start of HTML body portion -->
    <CENTER>
    <script type="text/javascript" src="/js/bookcover.js" /></script>
    </CENTER>
  9. If you're using one of my spellchecker scripts, and you replaced spell.js in the "js" directory, and <script type="text/javascript" src="/js/spell.js" /></script> already appears in header.htm, skip the previous step.

How It Works

When displayx.cfg is accessed, the getBookCover(isbn) javascript function is called, passing the isbn number. getBookCover(isbn) is found in bookcover.js (or spell.js).

In bookcover.js (or spell.js), an XMLHttpRequest object is created and the isbn is sent to bookcovers/getCover.php.

In getCover.php, a URL containing your Amazon Web Services Developer Key and the ISBN is sent to Amazon.com Amazon.com returns an xml file containing information about your request.

getCover.php then parses the xml file looking for error codes or image URLs. If a URL for an image is found, this is returned to the calling JavaScript. The JavaScript prints the image to the page.

If no image is found or if an error occurs, nothing is returned, so the user is not affected. Voila!

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: May 07 2007.