Skip to content

Commit b4f787b

Browse files
authored
Merge pull request #8 from karlbecker/feature/shorter-nodeserver-resource-names
Shorter nodeserver resource names
2 parents c021b50 + 19152e2 commit b4f787b

5 files changed

Lines changed: 34 additions & 34 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ This project uses Node.js on a non-Primo server to query BrowZine's APIs and ret
1313
To implement:
1414

1515
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.
16-
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.
16+
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.
1717
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.
1818
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).
1919
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).

coldfusion/browzine.cfc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<cfcomponent>
22
<cffunction name="journalLookup" access="remote" returnType="any" returnFormat="plain" output="true">
33
<!--- Add credentials from Browzine --->
4-
<cfSet var stoKey = "" />
5-
<cfSet var stoID = "" />
4+
<cfSet var browzineAPIKey = "" />
5+
<cfSet var browzineLibraryID = "" />
66
<!--- Setup local variables --->
77
<cfset var ISSN = "" />
88
<cfset var cb = "" />
@@ -11,7 +11,7 @@
1111
<!--- Get URL parameters --->
1212
<cfset ISSN = ToString(url.ISSN) />
1313
<cfset cb = url.callback />
14-
<cfset browzinePath = "https://api.thirdiron.com/public/v1/libraries/" & stoID & "/search?issns=" & ISSN & "&access_token=" & stoKey>
14+
<cfset browzinePath = "https://api.thirdiron.com/public/v1/libraries/" & browzineLibraryID & "/search?issns=" & ISSN & "&access_token=" & browzineAPIKey>
1515

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

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

3939
<!--- Submit api request --->
4040
<cfhttp url="#browzinePath#" port="443" method="get">

js/browzine.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,48 @@
11
// Define Angular module and whitelist URL of server with Node.js script
2-
var app = angular.module('viewCustom', ['angularLoad'])
2+
var app = angular.module('viewCustom', ['angularLoad'])
33
.constant('nodeserver', "https://yourserver.edu")
44
.config(['$sceDelegateProvider', 'nodeserver', ($sceDelegateProvider, nodeserver) => {
55
let urlWhitelist = $sceDelegateProvider.resourceUrlWhitelist();
6-
urlWhitelist.push(`${nodeserver}**`);
6+
urlWhitelist.push(`${nodeserver}**`);
77
$sceDelegateProvider.resourceUrlWhitelist(urlWhitelist);
88
}]);
99

1010
// Add Article In Context & BrowZine Links
11-
app.controller('prmSearchResultAvailabilityLineAfterController', function($scope, $http, nodeserver) {
11+
app.controller('prmSearchResultAvailabilityLineAfterController', function($scope, $http, nodeserver) {
1212
var vm = this;
1313
if (vm.parentCtrl.result.pnx.addata.doi && vm.parentCtrl.result.pnx.display.type[0] == 'article') {
1414
vm.doi = vm.parentCtrl.result.pnx.addata.doi[0] || '';
15-
var articleURL = nodeserver + "/primo/browzine/browzineArticleInContext?DOI=" + vm.doi;
15+
var articleURL = nodeserver + "/primo/browzine/articles?DOI=" + vm.doi;
1616
$http.jsonp(articleURL, {jsonpCallbackParam: 'callback'}).then(function(response) {
1717
$scope.article = response.data;
1818
}, function(error){
1919
console.log(error);
2020
});
2121
}
22-
if (vm.parentCtrl.result.pnx.addata.issn && vm.parentCtrl.result.pnx.display.type[0] == 'journal') {
22+
if (vm.parentCtrl.result.pnx.addata.issn && vm.parentCtrl.result.pnx.display.type[0] == 'journal') {
2323
vm.issn = vm.parentCtrl.result.pnx.addata.issn[0].replace("-", "") || '';
24-
var journalURL = nodeserver + "/primo/browzine/browzineJournals?ISSN=" + vm.issn;
24+
var journalURL = nodeserver + "/primo/browzine/journals?ISSN=" + vm.issn;
2525
$http.jsonp(journalURL, {jsonpCallbackParam: 'callback'}).then(function(response) {
2626
$scope.journal = response.data;
2727
}, function(error){
2828
console.log(error);
2929
});
3030
}
3131

32-
});
32+
});
3333

3434
// Below is where you can customize the wording that is displayed (as well as the hover over text) for the BrowZine links.
3535
// 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"
3636
// 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".
3737
// St Olaf also has added a hover over link that says "Via BrowZine" to emphasize the interaction being used.
3838

39-
app.component('prmSearchResultAvailabilityLineAfter', {
40-
bindings: { parentCtrl: '<' },
39+
app.component('prmSearchResultAvailabilityLineAfter', {
40+
bindings: { parentCtrl: '<' },
4141
controller: 'prmSearchResultAvailabilityLineAfterController',
4242
template: `
4343
<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>
4444
<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>
45-
`
45+
`
4646
});
4747

4848
// Add Journal Cover Images from BrowZine
@@ -51,7 +51,7 @@
5151
var newThumbnail = '';
5252
if (vm.parentCtrl.item.pnx.addata.issn) {
5353
vm.issn = vm.parentCtrl.item.pnx.addata.issn[0].replace("-", "") || '';
54-
var journalURL = nodeserver + "/primo/browzine/browzineJournals?ISSN=" + vm.issn;
54+
var journalURL = nodeserver + "/primo/browzine/journals?ISSN=" + vm.issn;
5555
$http.jsonp(journalURL, {jsonpCallbackParam: 'callback'}).then(function(response) {
5656
newThumbnail = response.data.data["0"].coverImageUrl;
5757
}, function(error){
@@ -61,7 +61,7 @@
6161
vm.$doCheck = function(changes) {
6262
if (vm.parentCtrl.selectedThumbnailLink) {
6363
if (newThumbnail != '' && (vm.parentCtrl.selectedThumbnailLink.linkURL.indexOf("icon_journal.png") != -1 || vm.parentCtrl.selectedThumbnailLink.linkURL.indexOf("img/icon_article.png") != -1) ) {
64-
vm.parentCtrl.selectedThumbnailLink.linkURL = newThumbnail;
64+
vm.parentCtrl.selectedThumbnailLink.linkURL = newThumbnail;
6565
}
6666
}
6767
};
Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,48 @@
11
var https = require('https');
2-
2+
33
exports.ArticleLookup = function (event, context, callback) {
44
// parse URL query from Primo
55
var query = require('querystring').parse(event.querystring);
66
// initialize options values
77
var DOI = (query.DOI === undefined ? 'noDOI' : query.DOI);
88
var cb = (query.callback === undefined ? '' : query.callback);
9-
9+
1010
// API key from Browzine
11-
var stoKey = process.env['stoKey'];
11+
var browzineAPIKey = process.env['browzineAPIKey'];
1212
// Customer ID from Browzine
13-
var stoID = process.env['stoID'];
13+
var browzineLibraryID = process.env['browzineLibraryID'];
1414
var options = {
1515
host : 'api.thirdiron.com',
1616
port : 443,
17-
path : '/public/v1/libraries/' + stoID + '/articles/doi/' + DOI + '?access_token=' + stoKey,
17+
path : '/public/v1/libraries/' + browzineLibraryID + '/articles/doi/' + DOI + '?access_token=' + browzineAPIKey,
1818
method : 'GET'
1919
};
20-
20+
2121
// make the https get call to Browzine and pass the callback data to Primo
2222
var getReq = https.request(options, function(res) {
23-
23+
2424
var data = '';
2525
res.on('data', function(chunk) {
2626
data += chunk.toString();
2727
});
28-
28+
2929
res.on('end', function(){
3030
if (res.statusCode == 200) {
31-
callback(null,
31+
callback(null,
3232
cb + '(' + data + ')'
3333
);
3434
} else {
3535
// Browzine's API returns a 404 if data isn't found, so send an empty response if call is unsuccessful
3636
callback(null,
3737
cb + '({"data":[]})'
38-
);
38+
);
3939
}
4040
});
4141
});
42-
42+
4343
//end the request
4444
getReq.end();
4545
getReq.on('error', function(err){
4646
console.log("Error: ", err);
47-
});
47+
});
4848
};
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ exports.JournalLookup = function (event, context, callback) {
88
var cb = (query.callback === undefined ? '' : query.callback);
99

1010
// API key from Browzine
11-
var stoKey = process.env['stoKey'];
11+
var browzineAPIKey = process.env['browzineAPIKey'];
1212
// Customer ID from Browzine
13-
var stoID = process.env['stoID'];
13+
var browzineLibraryID = process.env['browzineLibraryID'];
1414
var options = {
1515
host : 'api.thirdiron.com',
1616
port : 443,
17-
path : '/public/v1/libraries/' + stoID + '/search?issns=' + ISSN + '&access_token=' + stoKey,
17+
path : '/public/v1/libraries/' + browzineLibraryID + '/search?issns=' + ISSN + '&access_token=' + browzineAPIKey,
1818
method : 'GET'
1919
};
2020

0 commit comments

Comments
 (0)