Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ This project uses Node.js on a non-Primo server to query BrowZine's APIs and ret
To implement:

1. Set up the Node.js scripts on a local server. Third Iron can provide assistance with this step. I tested using Amazon's Lambda service and an API gateway. For production, St. Olaf is using a local server and ColdFusion component. I've included that code if you happen to be a CF shop.
1. stoKey and stoID refer to your Browzine API key and customer number. They should be updated to reflect your institution's keys. Contact Third Iron support at support@thirdiron.com to obtain credentials.
1. browzineAPIKey and browzineLibraryID refer to your Browzine API key and customer number. They should be updated to reflect your institution's keys. Contact Third Iron support at support@thirdiron.com to obtain credentials.
1. Add the browzine.js code to the custom.js file in your [Customization Package](https://knowledge.exlibrisgroup.com/Primo/Product_Documentation/New_Primo_User_Interface/New_UI_Customization_-_Best_Practices#Using_the_UI_Customization_Package_Manager). You will need to update the "nodeserver" constant with the URI for the server running the Node scripts.
1. Add the browzine.css lines to custom1.css file in your [Customization Package](https://knowledge.exlibrisgroup.com/Primo/Product_Documentation/New_Primo_User_Interface/New_UI_Customization_-_Best_Practices#Using_the_UI_Customization_Package_Manager).
1. Add the browzine.png image to the img directory in your [Customization Package](https://knowledge.exlibrisgroup.com/Primo/Product_Documentation/New_Primo_User_Interface/New_UI_Customization_-_Best_Practices#Using_the_UI_Customization_Package_Manager).
Expand Down
12 changes: 6 additions & 6 deletions coldfusion/browzine.cfc
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<cfcomponent>
<cffunction name="journalLookup" access="remote" returnType="any" returnFormat="plain" output="true">
<!--- Add credentials from Browzine --->
<cfSet var stoKey = "" />
<cfSet var stoID = "" />
<cfSet var browzineAPIKey = "" />
<cfSet var browzineLibraryID = "" />
<!--- Setup local variables --->
<cfset var ISSN = "" />
<cfset var cb = "" />
Expand All @@ -11,7 +11,7 @@
<!--- Get URL parameters --->
<cfset ISSN = ToString(url.ISSN) />
<cfset cb = url.callback />
<cfset browzinePath = "https://api.thirdiron.com/public/v1/libraries/" & stoID & "/search?issns=" & ISSN & "&access_token=" & stoKey>
<cfset browzinePath = "https://api.thirdiron.com/public/v1/libraries/" & browzineLibraryID & "/search?issns=" & ISSN & "&access_token=" & browzineAPIKey>

<!--- Submit api request --->
<cfhttp url="#browzinePath#" port="443" method="get">
Expand All @@ -24,8 +24,8 @@

<cffunction name="articleLookup" access="remote" returnType="any" returnFormat="plain" output="true">
<!--- Add credentials from Browzine --->
<cfSet var stoKey = "" />
<cfSet var stoID = "" />
<cfSet var browzineAPIKey = "" />
<cfSet var browzineLibraryID = "" />
<!--- Setup local variables --->
<cfset var DOI = "" />
<cfset var cb = "" />
Expand All @@ -34,7 +34,7 @@
<!--- Get URL parameters --->
<cfset DOI = ToString(url.DOI) />
<cfset cb = url.callback />
<cfset browzinePath = "https://api.thirdiron.com/public/v1/libraries/" & stoID & "/articles/doi/" & DOI & "?access_token=" & stoKey>
<cfset browzinePath = "https://api.thirdiron.com/public/v1/libraries/" & browzineLibraryID & "/articles/doi/" & DOI & "?access_token=" & browzineAPIKey>

<!--- Submit api request --->
<cfhttp url="#browzinePath#" port="443" method="get">
Expand Down
24 changes: 12 additions & 12 deletions js/browzine.js
Original file line number Diff line number Diff line change
@@ -1,48 +1,48 @@
// Define Angular module and whitelist URL of server with Node.js script
var app = angular.module('viewCustom', ['angularLoad'])
var app = angular.module('viewCustom', ['angularLoad'])
.constant('nodeserver', "https://yourserver.edu")
.config(['$sceDelegateProvider', 'nodeserver', ($sceDelegateProvider, nodeserver) => {
let urlWhitelist = $sceDelegateProvider.resourceUrlWhitelist();
urlWhitelist.push(`${nodeserver}**`);
urlWhitelist.push(`${nodeserver}**`);
$sceDelegateProvider.resourceUrlWhitelist(urlWhitelist);
}]);

// Add Article In Context & BrowZine Links
app.controller('prmSearchResultAvailabilityLineAfterController', function($scope, $http, nodeserver) {
app.controller('prmSearchResultAvailabilityLineAfterController', function($scope, $http, nodeserver) {
var vm = this;
if (vm.parentCtrl.result.pnx.addata.doi && vm.parentCtrl.result.pnx.display.type[0] == 'article') {
vm.doi = vm.parentCtrl.result.pnx.addata.doi[0] || '';
var articleURL = nodeserver + "/primo/browzine/browzineArticleInContext?DOI=" + vm.doi;
var articleURL = nodeserver + "/primo/browzine/articles?DOI=" + vm.doi;
$http.jsonp(articleURL, {jsonpCallbackParam: 'callback'}).then(function(response) {
$scope.article = response.data;
}, function(error){
console.log(error);
});
}
if (vm.parentCtrl.result.pnx.addata.issn && vm.parentCtrl.result.pnx.display.type[0] == 'journal') {
if (vm.parentCtrl.result.pnx.addata.issn && vm.parentCtrl.result.pnx.display.type[0] == 'journal') {
vm.issn = vm.parentCtrl.result.pnx.addata.issn[0].replace("-", "") || '';
var journalURL = nodeserver + "/primo/browzine/browzineJournals?ISSN=" + vm.issn;
var journalURL = nodeserver + "/primo/browzine/journals?ISSN=" + vm.issn;
$http.jsonp(journalURL, {jsonpCallbackParam: 'callback'}).then(function(response) {
$scope.journal = response.data;
}, function(error){
console.log(error);
});
}

});
});

// Below is where you can customize the wording that is displayed (as well as the hover over text) for the BrowZine links.
// St Olaf has chosen "View Journal Contents" for the "Journal Availability Link" but other great options include things such as "View Journal" or "View this Journal"
// St Olaf is using "View Issue Contents" for the "Article in Context" link but another great option is "View Complete Issue" or "View Article in Context".
// St Olaf also has added a hover over link that says "Via BrowZine" to emphasize the interaction being used.

app.component('prmSearchResultAvailabilityLineAfter', {
bindings: { parentCtrl: '<' },
app.component('prmSearchResultAvailabilityLineAfter', {
bindings: { parentCtrl: '<' },
controller: 'prmSearchResultAvailabilityLineAfterController',
template: `
<div ng-if="article.data.browzineWebLink"><a href="{{ article.data.browzineWebLink }}" target="_blank" title="Via BrowZine"><img src="custom/01BRC_SOC/img/browzine.png" class="browzine-icon"> View Issue Contents <md-icon md-svg-icon="primo-ui:open-in-new" aria-label="icon-open-in-new" role="img" class="browzine-external-link"><svg id="open-in-new_cache29" width="100%" height="100%" viewBox="0 0 24 24" y="504" xmlns="http://www.w3.org/2000/svg" fit="" preserveAspectRatio="xMidYMid meet" focusable="false"></svg></md-icon></a></div>
<div ng-if="journal.data[0].browzineWebLink"><a href="{{ journal.data[0].browzineWebLink }}" target="_blank" title="Via BrowZine"><img src="custom/01BRC_SOC/img/browzine.png" class="browzine-icon"> View Journal Contents <md-icon md-svg-icon="primo-ui:open-in-new" aria-label="icon-open-in-new" role="img" class="browzine-external-link"><svg id="open-in-new_cache29" width="100%" height="100%" viewBox="0 0 24 24" y="504" xmlns="http://www.w3.org/2000/svg" fit="" preserveAspectRatio="xMidYMid meet" focusable="false"></svg></md-icon></a></div>
`
`
});

// Add Journal Cover Images from BrowZine
Expand All @@ -51,7 +51,7 @@
var newThumbnail = '';
if (vm.parentCtrl.item.pnx.addata.issn) {
vm.issn = vm.parentCtrl.item.pnx.addata.issn[0].replace("-", "") || '';
var journalURL = nodeserver + "/primo/browzine/browzineJournals?ISSN=" + vm.issn;
var journalURL = nodeserver + "/primo/browzine/journals?ISSN=" + vm.issn;
$http.jsonp(journalURL, {jsonpCallbackParam: 'callback'}).then(function(response) {
newThumbnail = response.data.data["0"].coverImageUrl;
}, function(error){
Expand All @@ -61,7 +61,7 @@
vm.$doCheck = function(changes) {
if (vm.parentCtrl.selectedThumbnailLink) {
if (newThumbnail != '' && (vm.parentCtrl.selectedThumbnailLink.linkURL.indexOf("icon_journal.png") != -1 || vm.parentCtrl.selectedThumbnailLink.linkURL.indexOf("img/icon_article.png") != -1) ) {
vm.parentCtrl.selectedThumbnailLink.linkURL = newThumbnail;
vm.parentCtrl.selectedThumbnailLink.linkURL = newThumbnail;
}
}
};
Expand Down
24 changes: 12 additions & 12 deletions nodejs/browzineArticleInContext,js → nodejs/articles.js
Original file line number Diff line number Diff line change
@@ -1,48 +1,48 @@
var https = require('https');

exports.ArticleLookup = function (event, context, callback) {
// parse URL query from Primo
var query = require('querystring').parse(event.querystring);
// initialize options values
var DOI = (query.DOI === undefined ? 'noDOI' : query.DOI);
var cb = (query.callback === undefined ? '' : query.callback);

// API key from Browzine
var stoKey = process.env['stoKey'];
var browzineAPIKey = process.env['browzineAPIKey'];
// Customer ID from Browzine
var stoID = process.env['stoID'];
var browzineLibraryID = process.env['browzineLibraryID'];
var options = {
host : 'api.thirdiron.com',
port : 443,
path : '/public/v1/libraries/' + stoID + '/articles/doi/' + DOI + '?access_token=' + stoKey,
path : '/public/v1/libraries/' + browzineLibraryID + '/articles/doi/' + DOI + '?access_token=' + browzineAPIKey,
method : 'GET'
};

// make the https get call to Browzine and pass the callback data to Primo
var getReq = https.request(options, function(res) {

var data = '';
res.on('data', function(chunk) {
data += chunk.toString();
});

res.on('end', function(){
if (res.statusCode == 200) {
callback(null,
callback(null,
cb + '(' + data + ')'
);
} else {
// Browzine's API returns a 404 if data isn't found, so send an empty response if call is unsuccessful
callback(null,
cb + '({"data":[]})'
);
);
}
});
});

//end the request
getReq.end();
getReq.on('error', function(err){
console.log("Error: ", err);
});
});
};
6 changes: 3 additions & 3 deletions nodejs/browzineJournals.js → nodejs/journals.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ exports.JournalLookup = function (event, context, callback) {
var cb = (query.callback === undefined ? '' : query.callback);

// API key from Browzine
var stoKey = process.env['stoKey'];
var browzineAPIKey = process.env['browzineAPIKey'];
// Customer ID from Browzine
var stoID = process.env['stoID'];
var browzineLibraryID = process.env['browzineLibraryID'];
var options = {
host : 'api.thirdiron.com',
port : 443,
path : '/public/v1/libraries/' + stoID + '/search?issns=' + ISSN + '&access_token=' + stoKey,
path : '/public/v1/libraries/' + browzineLibraryID + '/search?issns=' + ISSN + '&access_token=' + browzineAPIKey,
method : 'GET'
};

Expand Down