{
"translatorID": "b28d0d42-8549-4c6d-83fc-8382874a5cb9",
"label": "DOI Content Negotiation",
"creator": "Sebastian Karcher",
"target": "",
"minVersion": "4.0.29.11",
"maxVersion": "",
"priority": 100,
"inRepository": true,
"translatorType": 8,
"browserSupport": "gcs",
"lastUpdated": "2020-04-20 20:04:00"
}
/*
***** BEGIN LICENSE BLOCK *****
Copyright © 2019 Sebastian Karcher
This file is part of Zotero.
Zotero is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Zotero is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Zotero. If not, see .
***** END LICENSE BLOCK *****
*/
function detectSearch(items) {
return (filterQuery(items).length > 0);
}
// return an array of DOIs from the query (items or text)
function filterQuery(items) {
if (!items) return [];
if (typeof items == 'string' || !items.length) items = [items];
// filter out invalid queries
var dois = [], doi;
for (var i = 0, n = items.length; i < n; i++) {
if (items[i].DOI && (doi = ZU.cleanDOI(items[i].DOI))) {
dois.push(doi);
}
else if (typeof items[i] == 'string' && (doi = ZU.cleanDOI(items[i]))) {
dois.push(doi);
}
}
return dois;
}
function doSearch(items) {
var dois = filterQuery(items);
if (!dois.length) return;
processDOIs(dois);
}
function processDOIs(dois) {
var doi = dois.pop();
// by content negotiation we asked for datacite or crossref format, or CSL JSON
ZU.doGet('https://doi.org/' + encodeURIComponent(doi), function (text) {
if (!text) {
return;
}
Z.debug(text);
var trans = Zotero.loadTranslator('import');
trans.setString(text);
if (text.includes("Other\nLe code est accompagné de commentaires de F. A. Vogel, qui signe l'épitre dédicatoireOther
\nReliure 18è siècleOther
\nEx-libris manuscrit \"Ex libris Dufour\""
]
}]
},
{
"type": "search",
"input": {
"DOI": "10.7336/academicus.2014.09.05"
},
"items": [{
"itemType": "journalArticle",
"url": "http://academicus.edu.al/?subpage=volumes&nr=9",
"volume": "9",
"pages": "69-78",
"publicationTitle": "Academicus International Scientific Journal",
"ISSN": "20793715",
"date": "01/2014",
"DOI": "10.7336/academicus.2014.09.05",
"accessDate": "2019-02-02T03:28:48Z",
"libraryCatalog": "DOI.org (Crossref)",
"title": "Second world war, communism and post-communism in Albania, an equilateral triangle of a tragic trans-Adriatic story. The Eftimiadi’s Saga",
"creators": [{
"firstName": "Muner",
"lastName": "Paolo",
"creatorType": "author"
}],
"tags": [],
"relations": [],
"attachments": [],
"notes": []
}]
}
]
/** END TEST CASES **/