Google Books and Syndetics Integration
Tags: aleph, syndetics, gbs, google_books, elympics, opac, javascript
Last Updated: Jan 20, 2010 11:13
Description
We wanted to be able to integrate Google book covers with syndetics in our Aleph OPAC. To do this, we created the following scenario:
- When we have a syndetics image, display link (no covers) to Google.
- When we have no syndetic image, display Google cover. If we have no Google cover, display just a link to google books.
- If neither Google nor syndetics has a cover or link, then display nothing.
- Author: Mark Watmough
- Additional author(s):
- Institution: Napier University
- Year: 2010
- License: BSD style
- Short description: Use, modification and distribution of the code are permitted provided the copyright notice, list of conditions and disclaimer appear in all related material.
- Link to terms: [Detailed license terms]
- Skill required for using this code:
basic/intermediate
State
Stable - we've been running this without issues well over a year.
Programming language
Javascript
Download
Attach the code file(s) to this page and link to them here.
Page attachments management can be reached from the top-right menu - 'attachments' after page save.
Working example
Google link and syndetics cover available. Example here
Google cover/link available, no syndetics cover available. Example here
Google image/link and syndetics cover both unavailable. Example here
Using the following Ex Libris open interfaces
N/A
Installation instructions
First we need to place javascript to recognise whether our syndetic cover is on the current full view page.
This can be done in the full-999-body by entering the following javascript code:
<Code sample>
<script>
//Look for Syndetics
var entry = '$0100';
if (entry == "More? Click cover") {
var syndet = 'yes' }
</script>
</Code sample>
In our full-999-body we use the standard $0100 and $0200 that was created by ExLibris. Here we are looking at the $0100 entry, which is our headings, for ‘More? Click cover” which is displayed with all our syndetic covers. If an entry is found anywhere on the page, we create a variable ‘syndet’ with the value of ‘yes’.
Next, we get to the main part of the code. In the file full-set-tail, we are looking (in Javascript again) for the syndet value and then looking at the google return and displaying as we want to.
<Code sample>
<script>
// Function to process GBS info and update the dom.
function ProcessGBSBookInfo(booksInfo) {
// Force the use of ISBN only - no OCLC numbers.
var idgoogle = "$0800";
if (idgoogle.indexOf("ISBN")!=0)
{
return;
}
for (isbn in booksInfo) {
var url_elem = document.getElementById(isbn);
var pic_elem = document.getElementById("google_book");
var mytable = document.getElementById('GBS') ;
var bookInfo = booksInfo[isbn];
if (bookInfo) {
url_elem.href = bookInfo.info_url;
url_elem.style.display = '';
// Display link by making table visible if google matches ISBN.
mytable.style.visibility = 'visible' ;
//Get JSON Response for GBS link text, according to the type of availability on the item (more information on the google books api page)
if(bookInfo.preview == "full") {
GBSlink = "Full View";
}
if(bookInfo.preview == "partial") {
GBSlink = "Partial View";
}
if(bookInfo.preview == "noview") {
GBSlink = "Limited Preview";
}
if (bookInfo.thumbnail_url)
{
pic_elem.src = bookInfo.thumbnail_url;
pic_elem.style.display = '';
}
}
}
}
</script>
<script type="text/javascript">
// link to google when no syndetics cover exists. Variables split to enable GBSlink text variable to be included.
if (syndet != "yes")
{
//Here we can see that I have created a ‘<thead>’ style with it’s visibility hidden. The ID of GBS matches the variable for mytable stated
earlier, which sets the ‘<thead>’ to visible, as we want our GBS image to appear at the top of the page.
document.write (" <thead style=\"visibility:hidden\" id=\"GBS\"><tr><td class=\"td1\" id=\"bold\" valign=\"top\" width=\"15%\" nowrap=\"nowrap\">Google Book Search</td><td class=\"td1\"><a id=\"$0800\" target=\"_blank\" style=\"display:none\;\"> <img style=\"display:none\;\" alt=\"Google Book Search - Click for more information\" vspace=\"2\" hspace=\"2\" align=\"middle\" border=\"0\" id=\"google_book\"/>");
document.write (GBSlink);
document.write ("</a></thead></tr></td>");
}
else
{
//link to google when syndetics cover exists. Variables split to enable GBSlink text variable to be included.
//This time we have a ‘<tr>’ set with hidden, here we want the GBS link to display at the bottom of our page.
document.write(" <tr style=\"visibility:hidden\" id=\"GBS\"><td class=\"td1\" id=\"bold\" valign=\"top\" width=\"15%\" nowrap=\"nowrap\">Google Book Search</td><td class=\"td1\"> <a id=\"$0800\" target=\"_blank\" style=\"display:none\;\">");
document.write(GBSlink);
document.write ('</a></tr></td>');
}
</script>
<script src="$0700"></script>
<script>document.write(GBSlink);</script>
</Code sample>
 | I've included attachments, but the code above includes more notes. |
 | Make sure your variables ($####) are the same on your system. This can be done by adding the <include>placeholders line to the relevant file. |
TO DO list
N/A
Known issues
GBS not displaying in the direct files - this is because we have not got a variable ($0700 in the full-set-tail) to query GBS with ISBNs in the direct files as we have in the full set tail....i'm sure it could be done.
Comments
I've attached the relevant files to this page so it's easier to copy and paste. If you have any questions, please leave a comment or email me at m.watmough@napier.ac.uk.
Comments (1)
May 10
Massimiliano Cilurzo says:
Hi Mark, Nice job, I tried to do the same but in the "full-set-tai...Hi Mark,
Nice job, I tried to do the same but in the "full-set-tail" page I haven't a variable for the ISBN, What I can do?
Thx
Massimiliano