Permalink
Browse files

[Zenodo] Prevent mis-importing software as report (#1578)

Also switch fieldMode to true for creators without a firstName
  • Loading branch information...
katrinleinweber authored and zuphilip committed Mar 9, 2018
1 parent ef29321 commit 5fa9a68fdc31351e308cec77d87a962eabeb8eff
Showing with 71 additions and 15 deletions.
  1. +71 −15 Zenodo.js
View
@@ -9,7 +9,7 @@
"inRepository": true,
"translatorType": 4,
"browserSupport": "gcsibv",
"lastUpdated": "2018-01-22 21:59:40"
"lastUpdated": "2018-03-08 08:11:55"
}
/*
@@ -130,7 +130,6 @@ function scrape(doc, url) {
ZU.processDocuments(cslURL, function(newDoc){
var text = ZU.xpathText(newDoc, '//h3/following-sibling::pre');
//Z.debug(text)
var type = text.match(/"type": "(.+?)"/)[1];
text = text.replace(/publisher_place/, "publisher-place");
text = text.replace(/container_title/, "container-title");
@@ -172,9 +171,13 @@ function scrape(doc, url) {
//something is odd with zenodo's author parsing to CSL on some pages; fix it
//e.g. https://zenodo.org/record/569323
for (var i = 0; i< item.creators.length; i++) {
if (!item.creators[i].firstName && item.creators[i].lastName.indexOf(",")!=-1) {
item.creators[i].firstName = item.creators[i].lastName.replace(/.+?,\s*/, "");
item.creators[i].lastName = item.creators[i].lastName.replace(/,.+/, "");
if (!item.creators[i].firstName) {
if (item.creators[i].lastName.indexOf(",")!=-1) {
item.creators[i].firstName = item.creators[i].lastName.replace(/.+?,\s*/, "");
item.creators[i].lastName = item.creators[i].lastName.replace(/,.+/, "");
} else {
item.creators[i].fieldMode = true;
}
}
delete item.creators[i].creatorTypeID;
}
@@ -187,21 +190,14 @@ function scrape(doc, url) {
item.url = url;
if (abstract) item.abstractNote = abstract;
//Zenodo uses some non-existent CSL types we're fixing.
var zoteroType = {
"figure": "artwork",
"article": "report"
};
if (item.itemType == "document" && zoteroType[type]) {
item.itemType = zoteroType[type];
}
item.itemType = detectWeb(doc, url);
item.itemID = "";
item.complete();
});
trans.translate();
});
}/** BEGIN TEST CASES **/
}
/** BEGIN TEST CASES **/
var testCases = [
{
"type": "web",
@@ -469,6 +465,66 @@ var testCases = [
"seeAlso": []
}
]
},
{
"type": "web",
"url": "https://zenodo.org/record/1048320",
"items": [
{
"itemType": "computerProgram",
"creators": [
{
"lastName": "Carl Boettiger",
"firstName": "",
"creatorType": "author",
"fieldMode": true
},
{
"lastName": "Maëlle Salmon",
"firstName": "",
"creatorType": "author",
"fieldMode": true
},
{
"lastName": "Noam Ross",
"firstName": "",
"creatorType": "author",
"fieldMode": true
},
{
"lastName": "Arfon Smith",
"firstName": "",
"creatorType": "author",
"fieldMode": true
},
{
"lastName": "Anna Krystalli",
"firstName": "",
"creatorType": "author",
"fieldMode": true
}
],
"notes": [],
"tags": [],
"seeAlso": [],
"attachments": [
{
"title": "Zenodo Snapshot",
"mimeType": "text/html"
}
],
"title": "ropensci/codemetar: codemetar: Generate CodeMeta Metadata for R Packages",
"publisher": "Zenodo",
"abstractNote": "an R package for generating and working with codemeta",
"date": "2017-11-13",
"extra": "DOI: 10.5281/zenodo.1048320",
"url": "https://zenodo.org/record/1048320",
"libraryCatalog": "Zenodo",
"accessDate": "2018-03-07T13:45:35Z",
"shortTitle": "ropensci/codemetar",
"company": "Zenodo"
}
]
}
]
/** END TEST CASES **/

0 comments on commit 5fa9a68

Please sign in to comment.