Skip to content

Commit

Permalink
Merge pull request #752 from OCLC-Developer-Network/hapi
Browse files Browse the repository at this point in the history
Added parser for Hispanic American Periodicals
  • Loading branch information
felixleo22 authored Sep 18, 2023
2 parents bc21661 + c515825 commit 8592665
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 0 deletions.
13 changes: 13 additions & 0 deletions hapi/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"longname": "Hispanic American Periodicals",
"name": "hapi",
"describe": "Recognizes the accesses to the platform Hispanic American Periodicals",
"contact": "Violita Kovchegov",
"pkb": false,
"docurl": "http://analyses.ezpaarse.org/platforms/64f8b318d77a71c949527f9b",
"domains": [
"hapi.ucla.edu"
],
"version": "2023-09-15",
"status": "beta"
}
42 changes: 42 additions & 0 deletions hapi/parser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env node

'use strict';
const Parser = require('../.lib/parser.js');

/**
* Recognizes the accesses to the platform Hispanic American Periodicals
* @param {Object} parsedUrl an object representing the URL to analyze
* main attributes: pathname, query, hostname
* @param {Object} ec an object representing the EC whose URL is being analyzed
* @return {Object} the result
*/
module.exports = new Parser(function analyseEC(parsedUrl, ec) {
let result = {};
let path = parsedUrl.pathname;
// uncomment this line if you need parameters
// let param = parsedUrl.query || {};

// use console.error for debuging
// console.error(parsedUrl);

let match;

if ((match = /^\/article\/citation\/([0-9]+)$/i.exec(path)) !== null) {
// https://hapi.ucla.edu/article/citation/378232
result.rtype = 'RECORD_VIEW';
result.mime = 'HTML';
result.unitid = match[1];

} else if ((match = /^\/article\/frame\/([0-9]+)\/([0-9]+)$/i.exec(path)) !== null) {
// https://hapi.ucla.edu/article/frame/378288/1315
result.rtype = 'TOC';
result.mime = 'HTML';
result.unitid = match[2];
} else if (/^\/search\/advanced$/i.test(path)) {
// https://hapi.ucla.edu/search/advanced
result.rtype = 'SEARCH';
result.mime = 'HTML';
}

return result;
});
4 changes: 4 additions & 0 deletions hapi/test/hapi.2023-09-15.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
out-unitid;out-rtype;out-mime;in-url
378232;RECORD_VIEW;HTML;https://hapi.ucla.edu/article/citation/378232
1315;TOC;HTML;https://hapi.ucla.edu/article/frame/378288/1315
;SEARCH;HTML;https://hapi.ucla.edu/search/advanced

0 comments on commit 8592665

Please sign in to comment.