Skip to content
Permalink
Browse files

Translator fixes B (zotero#1138)

* Fix error when volumes is not present in Cairn.info.js

* Fix tests in Beobachter.js

* Fix tests in Biblio.com.js

* Update tests in BioMed Central.js

* Rewrite Bloomberg.js, skip empty authors in EM

 * Similar to highwire code in EM also empty are now skiped
 * Update test cases
 * Note that the multiple test in Bloomberg.js does not work
in the test pane, but the test website for multiples works
when called separately.

* Update tests in BOFiP-Impots.js

* Update tests in Boston Review.js

* Fixes and update tests in Business Standard.js

* BusinessWeek.js --> Bloomberg.js

The acquisition was in late 2009:
https://en.wikipedia.org/wiki/Bloomberg_Businessweek#Bloomberg_L.P._acquisition

* Update Beobachter.js

* Fix and update beck-online.js
  • Loading branch information...
zuphilip authored and adam3smith committed Sep 9, 2016
1 parent e102b02 commit 1eaf0132f158a0b037be50f1e9dbc8e86d821490
Showing with 345 additions and 476 deletions.
  1. +26 −26 BOFiP-Impots.js
  2. +4 −4 Beobachter.js
  3. +27 −17 Biblio.com.js
  4. +48 −52 BioMed Central.js
  5. +142 −81 Bloomberg.js
  6. +3 −5 Boston Review.js
  7. +56 −70 Business Standard.js
  8. +0 −119 BusinessWeek.js
  9. +16 −13 Cairn.info.js
  10. +9 −80 Embedded Metadata.js
  11. +12 −8 beck-online.js
  12. +2 −1 deleted.txt
@@ -69,57 +69,57 @@ var testCases = [
"items": [
{
"itemType": "newspaperArticle",
"title": "IS - Charges financières afférentes à l'acquisition de certains titres de participation",
"creators": [],
"notes": [],
"tags": [],
"seeAlso": [],
"date": "2012-11-30",
"ISSN": "2262-1954",
"libraryCatalog": "BOFiP-Impôts",
"publicationTitle": "Bulletin Officiel des Finances Publiques-Impôts",
"rights": "public",
"url": "http://bofip.impots.gouv.fr/bofip/8000-PGP?branch=2",
"attachments": [
{
"url": false,
"title": "BOFiP PDF",
"type": "application/pdf"
"mimeType": "application/pdf"
}
],
"url": "http://bofip.impots.gouv.fr/bofip/8000-PGP?branch=2",
"date": "2012-11-30",
"ISSN": "2262-1954",
"publicationTitle": "Bulletin Officiel des Finances Publiques-Impôts",
"rights": "public",
"title": "IS - Charges financières afférentes à l'acquisition de certains titres de participation",
"libraryCatalog": "BOFiP-Impôts",
"accessDate": "CURRENT_TIMESTAMP"
"tags": [],
"notes": [],
"seeAlso": []
}
]
},
{
"type": "web",
"url": "http://bofip.impots.gouv.fr/bofip/7999-PGP/version/15",
"url": "http://bofip.impots.gouv.fr/bofip/7999-PGP.html?identifiant=BOI-IS-BASE-30-50-20121130",
"items": [
{
"itemType": "journalArticle",
"title": "IS – Base d'imposition – Charges financières afférentes à l'acquisition de certains titres de participation",
"creators": [
{
"lastName": "Ministère de l'Économie et des Finances",
"creatorType": "author"
}
],
"notes": [],
"tags": [],
"seeAlso": [],
"date": "2012-11-30",
"ISSN": "2262-1954",
"callNumber": "BOI-IS-BASE-30-50-20121130",
"libraryCatalog": "BOFiP-Impôts",
"publicationTitle": "Bulletin Officiel des Finances Publiques-Impôts",
"rights": "public",
"url": "http://bofip.impots.gouv.fr/bofip/7999-PGP.html?identifiant=BOI-IS-BASE-30-50-20121130",
"attachments": [
{
"url": false,
"title": "BOFiP PDF",
"type": "application/pdf"
"mimeType": "application/pdf"
}
],
"url": "http://bofip.impots.gouv.fr/bofip/7999-PGP.html?identifiant=BOI-IS-BASE-30-50-20121130",
"callNumber": "BOI-IS-BASE-30-50-20121130",
"date": "2012-11-30",
"ISSN": "2262-1954",
"publicationTitle": "Bulletin Officiel des Finances Publiques-Impôts",
"rights": "public",
"title": "IS – Base d'imposition – Charges financières afférentes à l'acquisition de certains titres de participation",
"libraryCatalog": "BOFiP-Impôts",
"accessDate": "CURRENT_TIMESTAMP"
"tags": [],
"notes": [],
"seeAlso": []
}
]
},
@@ -9,7 +9,7 @@
"inRepository": true,
"translatorType": 4,
"browserSupport": "gcsibv",
"lastUpdated": "2014-04-03 16:37:44"
"lastUpdated": "2016-09-07 21:24:35"
}

/*
@@ -97,7 +97,7 @@ function scrape(doc) {

newItem.ISSN = "1661-7444";

var authorline = ZU.xpath(doc, '//div[' + containingClass('mediaarticleSingleView') + ']//dl/dt[. = "Text:"]');
var authorline = ZU.xpath(doc, '//div[' + containingClass('mediaarticleSingleView') + ']//dl/dt[. = "Autor:"]');
if (authorline.length > 0) {
authorline = ZU.trimInternal(authorline[0].nextSibling.textContent);
// Assumption of authorline: "name1[, name2] [und Name3]"
@@ -163,7 +163,7 @@ function fetchMeta(doc) {
*/
function associateMeta(newItem, metaTags, name, zoteroField) {
if (metaTags[name]) {
newItem[zoteroField] = ZU.trimInternal(metaTags[name]);
newItem[zoteroField] = ZU.trimInternal(ZU.unescapeHTML(metaTags[name]));
}
}

@@ -224,4 +224,4 @@ var testCases = [
]
}
]
/** END TEST CASES **/
/** END TEST CASES **/
@@ -3,13 +3,13 @@
"label": "Biblio.com",
"creator": "Adam Crymble, Michael Berkowitz, and Sebastian Karcher",
"target": "^https?://www\\.biblio\\.com/",
"minVersion": "1.0.0b4.r5",
"minVersion": "3.0",
"maxVersion": "",
"priority": 100,
"inRepository": true,
"translatorType": 4,
"browserSupport": "gcsibv",
"lastUpdated": "2015-06-02 08:32:10"
"lastUpdated": "2016-09-08 06:09:28"
}

function detectWeb(doc, url) {
@@ -45,9 +45,10 @@ function scrape(doc, url) {

for (var i=0; i<xPathCount.numberValue; i++) {
contents = content.iterateNext().textContent.split(": ");
if (contents.length>1){
fieldTitle = contents[0].replace(/\s*/g, '');
dataTags[fieldTitle] = contents[1].replace(/^\s*|\s*$/g, '');}
if (contents.length>1) {
fieldTitle = contents[0].replace(/\s*/g, '');
dataTags[fieldTitle] = contents[1].replace(/^\s*|\s*$/g, '');
}
}

//Authors
@@ -76,30 +77,39 @@ function scrape(doc, url) {
associateData (newItem, dataTags, "Pages", "pages");
associateData (newItem, dataTags, "Edition", "edition");

newItem.title = doc.evaluate('//h1', doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent.replace(/^\s*|\s&+/g, '');
newItem.title = ZU.xpathText(doc, '//h1').replace(/^\s*|\.\s*$/g, '');
newItem.url = doc.location.href;
newItem.complete();
}


function getSearchResults(doc, checkOnly) {
var items = {};
var found = false;
var rows = ZU.xpath(doc, '//div[@class="row"]//a[@class="sr-title-text"]');
for (var i=0; i<rows.length; i++) {
var href = rows[i].href;
var title = ZU.trimInternal(rows[i].textContent);
if (!href || !title) continue;
if (checkOnly) return true;
found = true;
items[href] = title;
}
return found ? items : false;
}


function doWeb(doc, url) {
if (detectWeb(doc, url) == "multiple") {
var items = new Object();
var articles = new Array();
var titles = doc.evaluate('//div[@class="search-result"]//a[@class="sr-title-text"]', doc, null, XPathResult.ANY_TYPE, null);
var next_title;
while (next_title = titles.iterateNext()) {
if (next_title.textContent.match(/\w/)) {
items[next_title.href] = next_title.textContent;
}
}
Zotero.selectItems(items, function (items) {
Zotero.selectItems(getSearchResults(doc, false), function (items) {
if (!items) {
return true;
}
var articles = [];
for (var i in items) {
articles.push(i);
}
Zotero.Utilities.processDocuments(articles, scrape);
ZU.processDocuments(articles, scrape);
});
} else {
scrape(doc, url);
@@ -9,71 +9,71 @@
"inRepository": true,
"translatorType": 4,
"browserSupport": "gcsibv",
"lastUpdated": "2015-12-30 13:26:44"
"lastUpdated": "2016-09-08 06:17:39"
}

/*
***** BEGIN LICENSE BLOCK *****
***** BEGIN LICENSE BLOCK *****
Copyright © 2015 Philipp Zumstein
Copyright © 2015 Philipp Zumstein
This file is part of Zotero.
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 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.
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 <http://www.gnu.org/licenses/>.
You should have received a copy of the GNU Affero General Public License
along with Zotero. If not, see <http://www.gnu.org/licenses/>.
***** END LICENSE BLOCK *****
***** END LICENSE BLOCK *****
*/

function detectWeb(doc, url) {
if (url.indexOf('biomedcentral.com/articles/10.1186/')>-1) {
return "journalArticle";
} else if (getSearchResults(doc, true)) {
return "multiple";
}
if (url.indexOf('biomedcentral.com/articles/10.1186/')>-1) {
return "journalArticle";
} else if (getSearchResults(doc, true)) {
return "multiple";
}
}

function getSearchResults(doc, checkOnly) {
var items = {};
var found = false;
var rows = ZU.xpath(doc, '//div[@id="search-container"]//article//h3[contains(@class,"ResultsList_title")]/a');
for (var i=0; i<rows.length; i++) {
var href = rows[i].href;
var title = ZU.trimInternal(rows[i].textContent);
if (!href || !title) continue;
if (checkOnly) return true;
found = true;
items[href] = title;
}
return found ? items : false;
var items = {};
var found = false;
var rows = ZU.xpath(doc, '//div[@id="search-container"]//article//h3[contains(@class,"ResultsList_title")]/a');
for (var i=0; i<rows.length; i++) {
var href = rows[i].href;
var title = ZU.trimInternal(rows[i].textContent);
if (!href || !title) continue;
if (checkOnly) return true;
found = true;
items[href] = title;
}
return found ? items : false;
}


function doWeb(doc, url) {
if (detectWeb(doc, url) == "multiple") {
Zotero.selectItems(getSearchResults(doc, false), function (items) {
if (!items) {
return true;
}
var articles = new Array();
for (var i in items) {
articles.push(i);
}
ZU.processDocuments(articles, scrape);
});
} else {
scrape(doc, url);
}
if (detectWeb(doc, url) == "multiple") {
Zotero.selectItems(getSearchResults(doc, false), function (items) {
if (!items) {
return true;
}
var articles = new Array();
for (var i in items) {
articles.push(i);
}
ZU.processDocuments(articles, scrape);
});
} else {
scrape(doc, url);
}
}

function scrape(doc, url) {
@@ -234,7 +234,7 @@ var testCases = [
"issue": "1",
"journalAbbreviation": "Parasites & Vectors",
"libraryCatalog": "BioMed Central",
"pages": "S1",
"pages": "1-8",
"publicationTitle": "Parasites & Vectors",
"url": "http://dx.doi.org/10.1186/1756-3305-2-S1-S1",
"volume": "2",
@@ -248,11 +248,7 @@ var testCases = [
}
],
"tags": [],
"notes": [
{
"note": "Pages 1-8 in PDF"
}
],
"notes": [],
"seeAlso": []
}
]

0 comments on commit 1eaf013

Please sign in to comment.
You can’t perform that action at this time.