From f82ebe2f3fbebadcb950fe85b1cf7d97c8e80f6e Mon Sep 17 00:00:00 2001 From: Dan Scott Date: Fri, 25 Sep 2020 11:53:47 -0400 Subject: [PATCH] HathiTrust ETAS integration For any item that has no electronic resource links, find out if HathiTrust has a copy, and then provide a link to it under the "Available holdings" section. Signed-off-by: Dan Scott --- Open-ILS/web/js/ui/default/opac/hathitrust.js | 74 ++++++ test_hathitrust.html | 346 ++++++++++++++++++++++++++ 2 files changed, 420 insertions(+) create mode 100644 Open-ILS/web/js/ui/default/opac/hathitrust.js create mode 100644 test_hathitrust.html diff --git a/Open-ILS/web/js/ui/default/opac/hathitrust.js b/Open-ILS/web/js/ui/default/opac/hathitrust.js new file mode 100644 index 0000000000..ebb91188e7 --- /dev/null +++ b/Open-ILS/web/js/ui/default/opac/hathitrust.js @@ -0,0 +1,74 @@ +;(function () { + /** + * Check for HathiTrust holding and display a link + * + * Copyright 2020 Dan Scott (dan@coffeecode.net), Laurentian University + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 2 of the License, or (at your + * option) any later version. + * + * HathiTrust ETAS offers electronic versions of materials for print-only + * items held by member institutions. They match their collection to member + * institution collections via OCLC numbers, so we can perform a lookup + * just by OCLC number. + * + * Current limitations: + * * Hard-coded for English + * + * To use this in your catalogue, you will need to modify a few of the CSS + * queries to find the OCLC numbers, identify appropriate locations for + * inserting the link to HathiTrust. You will also have to provide your + * Shibboleth IdP so that users will be prompted to log in via your + * institution; otherwise they will see no available full text in the initial + * search results and will have to manually log in before they can see the + * available temporary access. This latter path is not likely to lead to + * success. + */ + + /* Path for determining if online is already offered; if so, then just stop */ + var online_path = 'link[property="availability"][href="http://schema.org/OnlineOnly"]'; + + /* Path for the OCLC number declaration */ + var oclc_path = 'link[property="sameAs"][href^="http://www.worldcat.org/oclc/"]'; + + /* Path to place the HathiTrust link */ + var copies_path = '#rdetail_copy_counts ul'; + + var htrust_api = 'https://catalog.hathitrust.org/api/volumes/brief/json/oclc:'; + + /* Holds the value of the HathiTrust catalogue URL /* + var htrust_record; + + /* Ensure there are no online versions availabl3 */ + if (!document.querySelector(online_path)) { + /* Do we have an OCLC number? */ + var oclc_node = document.querySelectorAll(oclc_path); + + /* Find out if HathiTrust holds it */ + if (oclc_node) { + var oclc_num = oclc_node[0].href.substring(oclc_node[0].href.lastIndexOf('/') + 1); + htrust_api = htrust_api + oclc_num; + var req = new window.XMLHttpRequest(); + req.open('GET', htrust_api); + req.onload = function (evt) { + if (req.response) { + var key = 'oclc:' + oclc_num; + var records = JSON.parse(req.responseText)[key].records; + for (var r in records) { + htrust_record = (records[r].recordURL); + var copy_node = document.querySelectorAll(copies_path); + if (copy_node) { + var hathilink = document.createElement('a'); + hathilink.href = htrust_record + '?signon=' + 'swle:https://connect.laurentian.ca/idp'; + hathilink.innerText = 'HathiTrust'; + copy_node[0].parentElement.insertBefore(hathilink, copy_node[0]); + } + } + } + } + req.send(); + } + } +})() diff --git a/test_hathitrust.html b/test_hathitrust.html new file mode 100644 index 0000000000..b4393d2d6f --- /dev/null +++ b/test_hathitrust.html @@ -0,0 +1,346 @@ + + + + + + + + + The 1985 Juno Awards collection - Laurentian University + + + + + + + + + + + +

Catalog

+ + +
+ +
+ + + +

Record Details

+

Catalog Search

+ +
+ +
+ +
+ + + + + + +
+ +
+
+

The 1985 Juno Awards collection

+ +
Adams, Bryan (Singer). Hart, Corey (Singer). Silver, Liberty (Singer). McLauchlan, Murray (Singer). Thompson, Don (Instrumentalist). Luba (Singer). Janz, Paul (Singer). lang, k.d. (Kathryn Dawn), 1961- (Singer). Idle Eyes (Performer). The Family Brown (Performer). Parachute Club (Performer). Oxford String Quartet (Performer). +
+ + + +
+ +
+ Image of item + +
+
+
+ + + + Phonograph music recording + Phonograph music recording + + +
+
+ +
+
+ Print / Email Actions Image + Print / + Email +
+ + + +
+
+
+ +
+

Available copies

+
    +
  • + 1 of 1 copy available at Conifer. + (Show) +
  • +
  • + 1 of 1 copy available at Laurentian University. +
  • +
+
+ + +

Current holds

+

+ 0 current holds with 1 total copy. +

+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
LocationCall Number / Copy NotesBarcodeShelving LocationStatusDue Date
J.N. Desmarais Library + + + LP 3689 + 30007006013980 Long-play records (3rd floor)Available-
+
+
+ + +
+ +

Record details

+
    +
  • + Physical Description: + 1 sound disc : 33 1/3 rpm, stereo +
  • +
  • + Publisher: + + Montréal, Qué. : + Radio Canada International, + + 1986.
  • +
+ + +

Content descriptions

+ + + + + + +
Formatted Contents Note: Heaven / Adams -- Never surrender / Hart -- Lost somewhere inside your love / Silver -- Railroad man / McLauchlan -- Tokyo Rose / Idle Eyes -- I've never been in love before / Thompson -- Let it go / Luba -- Go to pieces / Janz -- Wouldn't you love us together again / The Family Brown -- At the feet of the moon / Parachute Club -- Pine and stew / lang -- Minuetto from Quartet in B flat major / Mozart.
+ + + + + + + + + + + + +
Subject: Popular music > Canada.
String quartets.
Country music > Canada.
+ + + +
+
+ +
+
+ +
+
+ + + + +
+ +
+ +
+
+ +
+
+ +
+ +
+
+ +
+
+ +
+ +
+
+ + + +
+ +
+
+
+
+

Additional Resources

+ + + + + + + + -- 2.11.0