Skip to content

Commit

Permalink
Added parser for digitalia
Browse files Browse the repository at this point in the history
  • Loading branch information
Karen Coombs committed Sep 15, 2023
1 parent 22af125 commit 4935450
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 0 deletions.
13 changes: 13 additions & 0 deletions dgt/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"longname": "Digitalia",
"name": "dgt",
"describe": "Recognizes the accesses to the platform Digitalia",
"contact": "Ghislaine Crespy-Faure, Sean Duffy",
"pkb": false,
"docurl": "http://analyses.ezpaarse.org/platforms/565d715d74bd5ac15be36ab8",
"domains": [
"www.digitaliapublishing.com"
],
"version": "2023-09-15",
"status": "beta"
}
46 changes: 46 additions & 0 deletions dgt/parser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/usr/bin/env node

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

/**
* Recognizes the accesses to the platform Digitalia
* @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 = /^\/a\/([0-9]+)\/([a-z0-9-]+)$/i.exec(path)) !== null) {
// https://www.digitaliapublishing.com/a/85727/la-hendidura-de-la-roca
// https://www.digitaliapublishing.com/a/54993/agronomia-costarricense--volumen-40--numero-1
result.rtype = 'RECORD';
result.mime = 'HTML';
result.title_id = match[1];
result.unitid = match[1];

} else if (/^\/viewepub\/$/i.test(path)) {
// https://www.digitaliapublishing.com/viewepub/?id=85727
// https://www.digitaliapublishing.com/viewepub/?id=125550
result.rtype = 'BOOK';
result.mime = 'HTML';
result.title_id = param.id;
result.unitid = param.id;
} else if (/^\/fulltext$/i.test(path)) {
// https://www.digitaliapublishing.com/fulltext
result.rtype = 'SEARCH';
result.mime = 'HTML';
}

return result;
});
6 changes: 6 additions & 0 deletions dgt/test/dgt.2023-09-15.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
out-title_id;out-unitid;out-rtype;out-mime;in-url
85727;85727;RECORD;HTML;https://www.digitaliapublishing.com/a/85727/la-hendidura-de-la-roca
85727;85727;BOOK;HTML;https://www.digitaliapublishing.com/viewepub/?id=85727
125550;125550;BOOK;HTML;https://www.digitaliapublishing.com/viewepub/?id=125550
54993;54993;RECORD;HTML;https://www.digitaliapublishing.com/a/54993/agronomia-costarricense--volumen-40--numero-1
;;SEARCH;HTML;https://www.digitaliapublishing.com/fulltext

0 comments on commit 4935450

Please sign in to comment.