Primo VE HathiTrust Add-On

Back to the Primo VE Customization Package: Shared CSS and JavaScript Solutions page

Posted: December 17, 2020 -- Revised: August 25, 2022

Objective: When available, insert a clickable link to freely-available, full-text HathiTrust electronic version of the resource that will display in results lists and on full record pages.

Before After
pvehathitrust3.png pvehathitrust1.png

How to accomplish: Please review the steps for working with the customization package and its files on the main Shared CSS and JavaScript Solutions page.  This is an advanced customization that requires custom JavaScript be added to the /VIEW_CODE/js/custom.js file and custom CSS be added to the /VIEW_CODE/css/custom1.css file.

  1. Navigate to the /VIEW_CODE/css/custom1.css file and open it with a plain text editor. 
  2. Insert the HathiTrust Add-On custom code into the custom1.css file and save the file.
  3. Navigate to the /VIEW_CODE/js/custom.js file and open it with a plain text editor.
  4. Edit the preexisting text in the custom.js file:
    • Edit the following line:
      var app = angular.module('viewCustom', ['angularLoad']);

      to read:

      var app = angular.module('viewCustom', ['angularLoad', 'hathiTrustAvailability']);
  5. Insert the HathiTrust Add-On custom code block into the custom.js file.
  6. Decide if you would like to apply any of the optional configurations described in the section below. If so, add those attributes between the "hathi-trust-availability" tags in that section of the JavaScript code that you inserted in step 3 just above. For example:
app.component('prmSearchResultAvailabilityLineAfter', {
  template: '<hathi-trust-availability hide-online="true" msg="Set this text to your preferred message">
</hathi-trust-availability>'
});

7. Save the changes to the custom.js file.  Here is an example of the custom.js file with complete HathiTrust Add-On code without any optional configurations added.
8. Zip the Customization Package back up and Upload it in Alma Configuration. For more details, see Working with the Customization Package.

Configuration Options

There are some optional configurations for the Primo VE HathiTrust Add-On that may be set within the JavaScript code. The downloadable text files do not have these configuration options set but they are listed in the comments section as well as described below. To include any of these options, insert the attributes desired into the app.component prmSearchResultAvailabilityLineAfter template line between the "hathi-trust-availability" tags (see example in step 6 above).

Customizing the Availability Message - The default availability message that displays in the Brief Results list and the Full Record page is "Full Text Available at HathiTrust". You can override this by setting the msg attribute:

<hathi-trust-availability msg="Set this text to your preferred message"></hathi-trust-availability>

Selectively Suppress Full-text Links - By default, the component will display full-text links for any resource.

  • If you want it avoid looking for full-text availability on records for which you already have online access, add the hide-online attribute to the component:
<hathi-trust-availability hide-online="true"></hathi-trust-availability>
  • You can also suppress full-text links for journals, if desired, with hide-if-journal option:
<hathi-trust-availability hide-if-journal="true"></hathi-trust-availability>

Copyright Status - By default, the component will display only when the item is out of copyright and should therefore be accessible.

  • If you want to display full-text links to any HathiTrust record, regardless of copyright status, use the ignore-copyright attribute:
<hathi-trust-availability ignore-copyright="true"></hathi-trust-availability>
  • If your institution is a HathiTrust partner institution and you want the availability links in Primo VE to use HathiTrust's automatic login process, add your SAML IdP's entity ID:
<hathi-trust-availability entity-id="https://shibboleth.inst.edu/idp/shibboleth"></hathi-trust-availability>

Download the CSS and JS

Download a text file with this custom JavaScript code for easy copying and pasting into your local custom.js file.

Download a text file with this custom CSS code for easy copying and pasting into your local custom1.css file.

 

This Primo VE HathiTrust Add-On and the documentation above was adapted for CARLI I-Share from the UMNLibraries/primo-explore-hathitrust-availability project available through GitHub.