OaDOI Link

Developer

Jeremy McWilliams (Lewis and Clark College)

Description

Provides link to Open Access content for articles, when available. This is similar to the Unpaywall feature added in the 2019 November Primo release. Documentation explaining the differences between this customization and the Unpaywall feature can be found here: Unpaywall in Alma, OADOI Customization in Primo (and Other Open Access)

The Open Access link in a Primo full record.

System Components

Alma Discovery (VE), Customization Package

Skillset Requirements

Alma Discovery Customization Package, JavaScript

Accessibility

Not tested for accessibility.

Browser Support

Tested on Chrome, Firefox, Edge, IE11, and Safari.

Mobile Support

Tested on iPhone & Android.

Implementation Steps

Overview

  • Add ‘oadoi’ to your app variable in custom.js
  • Add base code to anonymous function in custom.js
  • Add and customize code snippet for local email and icon
  • Load icon to img directory
  • Note: this customization does not require the central package to be enabled

Steps

  1. In your local custom.js file, add ‘oadoi’ to your app variable near the top:

    var app = angular.module('viewCustom', ['oadoi']);

    If you are using other angular modules, include them in your app definition as well. For example:

    var app = angular.module('viewCustom', ['oadoi', 'customAction']);
  2. Below the “app” declaration (but before the  })(); at the end of the file), add the following code:

    /******** begin oadoi **********/
    angular
    .module('oadoi', [])
    .component('prmFullViewServiceContainerAfter', {
    bindings: { parentCtrl: '<' },
    controller: function controller($scope, $http, $element, oadoiService, oadoiOptions) {
    this.$onInit = function() {
    $scope.oaDisplay=false; /* default hides template */
    $scope.imagePath=oadoiOptions.imagePath;
    var email=oadoiOptions.email;
    var section=$scope.$parent.$ctrl.service.scrollId;
    var obj=$scope.$ctrl.parentCtrl.item.pnx.addata;
    var debug=oadoiOptions.debug;
    if (obj.hasOwnProperty("doi")){
    var doi=obj.doi[0];
    if(debug){ console.log("doi:"+doi); }
    if (doi && section=="getit_link1_0"){
    var url="https://api.oadoi.org/v2/"+doi+"?email="+email;
                var response=oadoiService.getOaiData(url).then(function(response){
              if(debug){
    console.log("response from oadoiService received:");
                  console.log(response);
    }
               var oalink=response.data.best_oa_location.url;
                if(oalink===null){
               $scope.oaDisplay=false;
                 if(debug){ console.log("oaDisplay set to false (no link returned)"); }
                $scope.oaClass="ng-hide";
                }
                else{
                 if(debug){
    console.log("oalink from response: " + oalink); }
                    $scope.oalink=oalink;
                    $scope.oaDisplay=true;
                    $element.children().removeClass("ng-hide"); /* initially set by $scope.oaDisplay=false */
                    $scope.oaClass="ng-show";
                  }
                });
              }
              else{
    $scope.oaDisplay=false;
    }
            }
            else{
             $scope.oaClass="ng-hide";
            }
          };
        },
        template: '<div style="height:50px;background-color:white;padding:15px;" ng-show="{{oaDisplay}}" class="{{oaClass}}"><img src="{{imagePath}}" style="float:left;height:22px;width:22px;margin-right:10px"><p>Full text available via: <a href="{{oalink}}" target="_blank" style="font-weight:600;font-size:15px;color;#2c85d4;">Open Access</a></p></div>'
      })
    .factory('oadoiService', ['$http',function($http){
       return{
         getOaiData: function (url) {
           return $http({
             method: 'GET',
              url: url,
              cache: true
            })
          }
        }
      }]);
    /****** end oadoi *********/

  3. Be sure to edit the constant variables for the image path and email in this section of code.

    /******* begin oadoi local options ***********/ 
       app.constant('oadoiOptions', {
          "imagePath": "custom/INSTITUTIONID/img/oa_50.png",
          "email": "me@myschool.edu"
        });
    /******** end oadoi local options ***************/

  4. Modify the imagePath and email fields as follows:
    1. imagePath: this points to an image in your customization package. Make sure you edit the view name so it corresponds to your view, and the file name.
    2. email: enter an email address specific to your institution. There is no need to register it with Unpaywall.
  5. Add your icon image to the ‘img’ directory of your customization package. Make sure it matches the file name you entered in step 3 for imagePath. Sample image: oa50_t.png

    Lock on document icon
  6. Zip your customization package, load it to Alma Discovery, and save your view.