Skip to content
Permalink
Browse files

Cleanup some old code (#1537)

* Update Archeion.js

* Update CiteULike.js

* Rewrite National Library of Australia (new catalog).js

* Update Code4Lib Journal.js

* Update jmlr.js

* Update Journal of Electronic Publishing.js

* Update Max Planck Institute for the History of Science Virtual Laboratory Library.js

* Update FreePatentsOnline.js

* Delete KOBV.js old portal

See http://vs13.kobv.de/V/?func=file&file_name=kobv-news#
for announcement of coming shutdown and link to new
portal.

* Rewrite Musee du Louvre.js

* Rewrite National Bureau of Economic Research.js
  • Loading branch information...
zuphilip authored and adam3smith committed Mar 15, 2018
1 parent 9084a97 commit 5bb111a53a95edae7c65d434493ed2c4e771286b
@@ -9,7 +9,7 @@
"inRepository": true,
"translatorType": 4,
"browserSupport": "gcsibv",
"lastUpdated": "2016-09-03 12:04:29"
"lastUpdated": "2018-03-05 07:08:54"
}

/*
@@ -34,41 +34,81 @@
***** END LICENSE BLOCK *****
*/


// attr()/text() v2
function attr(docOrElem,selector,attr,index){var elem=index?docOrElem.querySelectorAll(selector).item(index):docOrElem.querySelector(selector);return elem?elem.getAttribute(attr):null;}function text(docOrElem,selector,index){var elem=index?docOrElem.querySelectorAll(selector).item(index):docOrElem.querySelector(selector);return elem?elem.textContent:null;}


function detectWeb(doc, url) {
if (url.match(/;search\?/)) {
if (url.includes('/informationobject/browse?') && getSearchResults(doc, true)) {
return "multiple";
} else if (url.match(/;rad$/)|| ZU.xpathText(doc, '//section[@id="action-icons"]//a[contains(@href, ";dc?sf_format=xml")]/@href')) {
return "book";
}
}


function getSearchResults(doc, checkOnly) {
var items = {};
var found = false;
var rows = doc.querySelectorAll('.search-result-description .title a');
for (let i=0; i<rows.length; i++) {
let href = rows[i].href;
let 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 = [];
for (var i in items) {
articles.push(i);
}
ZU.processDocuments(articles, scrape);
});
} else {
scrape(doc, url);
}
}


function scrape(doc, url) {
var dcUrl = url.replace(/;rad$/, "") + ";dc?sf_format=xml";
Zotero.Utilities.doGet(dcUrl, function (text) {
//Z.debug(text)
text = text.replace(/\&([^a])/, "&amp;$1")
text = text.replace(/xsi:type=\"dcterms:ISO639-3\"/, "")
text = text.replace(/\&([^a])/, "&amp;$1");
text = text.replace(/xsi:type=\"dcterms:ISO639-3\"/, "");
var translator = Zotero.loadTranslator("import");
translator.setTranslator("5e3ad958-ac79-463d-812b-a86a9235c28f");
translator.setString(text);
translator.setHandler("itemDone", function (obj, item) {
//the DC doesn't distinguish between personal and institutional authors - get them from the page and parse
var authors = ZU.xpath(doc, '//div[@id="archivalDescriptionArea"]//div[@class="field"]/h3[contains(text(), "Name of creator")]/following-sibling::div/a');
for (var i in authors) {
for (let i=0; i<authors.length; i++) {
//remove location (in parentheses) from creators, since it often contains a comma that messes with author parsing
item.creators[i] = ZU.cleanAuthor(authors[i].textContent.replace(/\(.+\)\s*$/, ""), "author", true);
if (!item.creators[i].firstName) item.creators[i].fieldMode = 1;
}
//The Archive gets mapped to the relations tag - we want its name, not the description in archeion
for (var i in item.seeAlso) {
for (let i=0; i<item.seeAlso.length; i++) {
if (item.seeAlso[i].indexOf("http://") == -1) {
item.archive = item.seeAlso[i];
}
}
item.seeAlso = [];
//the RDF translator doesn't get the full identifier - get it from the page
var loc = ZU.xpathText(doc, '//section[@id="titleAndStatementOfResponsibilityArea"]//div[@class="field"]/h3[contains(text(), "Reference code")]/following-sibling::div');
Z.debug(loc)
//Z.debug(loc)
item.archiveLocation = loc;
item.libraryCatalog = "Archeion - MemoryBC - Aberta on Record";
if (item.extra) item.notes.push(item.extra);
@@ -79,39 +119,15 @@ function scrape(doc, url) {
translator.getTranslatorObject(function(trans) {
trans.defaultUnknownType = 'book';
trans.doImport();
});
});
});
}

function doWeb(doc, url) {
if (detectWeb(doc, url) == "multiple") {
var articles = new Array();
var items = new Object();
var titles = ZU.xpath(doc, '//div[contains(@class, "search-results")]/h2/a|//div[contains(@class, "search-result")]/p[@class="title"]/a');
for (var i in titles) {
items[titles[i].href] = titles[i].textContent;
}
Zotero.selectItems(items, function (items) {
if (!items) {
return true;
}
for (var i in items) {
articles.push(i);
}
Zotero.Utilities.processDocuments(articles, scrape, function () {
Zotero.done();
});
Zotero.wait();
});
} else {
scrape(doc, url);
}
}
/** BEGIN TEST CASES **/
var testCases = [
{
"type": "web",
"url": "http://www.archeion.ca/;search?query=montreal",
"url": "https://www.archeion.ca/informationobject/browse?topLod=0&query=montreal&repos=",
"items": "multiple"
},
{
@@ -178,7 +194,7 @@ var testCases = [
},
{
"type": "web",
"url": "http://www.albertaonrecord.ca/;search?query=alphabet",
"url": "https://albertaonrecord.ca/informationobject/browse?topLod=0&query=alphabet&repos=",
"items": "multiple"
},
{
@@ -223,6 +239,11 @@ var testCases = [
"seeAlso": []
}
]
},
{
"type": "web",
"url": "https://www.archeion.ca/informationobject/browse?topLod=0&names=73890",
"items": "multiple"
}
]
/** END TEST CASES **/
/** END TEST CASES **/
@@ -1,62 +1,97 @@
{
"translatorID": "8917b41c-8527-4ee7-b2dd-bcbc3fa5eabd",
"label": "CiteULike",
"creator": "Sean Takats",
"creator": "Philipp Zumstein",
"target": "^https?://(www\\.)?citeulike\\.org(.*/tag/[^/]*$|/search/|/journal/|/user/|/group/[0-9]+/library$|/\\?page=[0-9]+$|/.*article/[0-9]+$|/$)",
"minVersion": "1.0.0b4.r5",
"minVersion": "3.0",
"maxVersion": "",
"priority": 100,
"inRepository": true,
"translatorType": 4,
"browserSupport": "gcsibv",
"lastUpdated": "2017-01-01 16:51:21"
"lastUpdated": "2018-01-28 22:54:12"
}

function detectWeb(doc, url){
var articleRe = /\/article\/[0-9]+$/;
var m = url.match(articleRe);
var newUris = new Array();
/*
***** BEGIN LICENSE BLOCK *****
Copyright © 2018 Philipp Zumstein
if (m){
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 <http://www.gnu.org/licenses/>.
***** END LICENSE BLOCK *****
*/


// attr()/text() v2
function attr(docOrElem,selector,attr,index){var elem=index?docOrElem.querySelectorAll(selector).item(index):docOrElem.querySelector(selector);return elem?elem.getAttribute(attr):null;}function text(docOrElem,selector,index){var elem=index?docOrElem.querySelectorAll(selector).item(index):docOrElem.querySelector(selector);return elem?elem.textContent:null;}


function detectWeb(doc, url) {
if (url.includes('/article/')) {
return "journalArticle";
} else {
} else if (getSearchResults(doc, true)) {
return "multiple";
}
}

function doWeb(doc, url){
var articleRe = /\/article\/[0-9]+$/;
var m = url.match(articleRe);
var newUris = new Array();

if (m){
newUris.push(url.replace(/citeulike\.org\//, "citeulike.org/endnote/"));

function getSearchResults(doc, checkOnly) {
var items = {};
var found = false;
var rows = doc.querySelectorAll('a.title');
for (let i=0; i<rows.length; i++) {
let href = rows[i].href;
let 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 = [];
for (let i in items) {
scrape(i.replace(/citeulike\.org\//, "citeulike.org/endnote/"));
}
});
} else {
var namespace = doc.documentElement.namespaceURI;
var nsResolver = namespace ? function(prefix) {
if (prefix == 'x') return namespace; else return null;
} : null;
var elmt;
var elmts = doc.evaluate('//a[@class="title"]', doc, nsResolver, XPathResult.ANY_TYPE, null);
var items = new Object();
while(elmt = elmts.iterateNext()) {
items[elmt.href] = Zotero.Utilities.trimInternal(elmt.textContent);
}
items = Zotero.selectItems(items);
if(!items) return true;
for(var uri in items) {
newUris.push(uri.replace(/citeulike\.org\//, "citeulike.org/endnote/"));
}
var endnoteUrl = url.replace(/citeulike\.org\//, "citeulike.org/endnote/");
scrape(endnoteUrl);
}
Zotero.Utilities.HTTP.doGet(newUris, function(text) {
}


function scrape(url) {
ZU.doGet(url, function(text) {
var translator = Zotero.loadTranslator("import");
translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7");
translator.setString(text);
translator.translate();
Zotero.done();
});
Zotero.wait();
}

/** BEGIN TEST CASES **/
var testCases = [
{
@@ -65,6 +100,7 @@ var testCases = [
"items": [
{
"itemType": "journalArticle",
"title": "Automatic test generation: a use case driven approach",
"creators": [
{
"lastName": "Nebut",
@@ -87,35 +123,48 @@ var testCases = [
"creatorType": "author"
}
],
"date": "March 2006",
"DOI": "10.1109/tse.2006.22",
"ISSN": "0098-5589",
"abstractNote": "Use cases are believed to be a good basis for system testing. Yet, to automate the test generation process, there is a large gap to bridge between high-level use cases and concrete test cases. We propose a new approach for automating the generation of system test scenarios in the context of object-oriented embedded software, taking into account traceability problems between high-level views and concrete test case execution. Starting from a formalization of the requirements based on use cases extended with contracts, we automatically build a transition system from which we synthesize test cases. Our objective is to cover the system in terms of statement coverage with those generated tests: an empirical evaluation of our approach is given based on this objective and several case studies. We briefly discuss the experimental deployment of our approach in the field at Thales Airborne Systems.",
"issue": "3",
"libraryCatalog": "CiteULike",
"pages": "140-155",
"publicationTitle": "IEEE Transactions on Software Engineering",
"shortTitle": "Automatic test generation",
"url": "http://dx.doi.org/10.1109/tse.2006.22",
"volume": "32",
"attachments": [],
"tags": [
{
"tag": "automation"
},
{
"tag": "test"
},
{
"tag": "test_case_generation"
},
{
"tag": "testing"
},
{
"tag": "use_case"
}
],
"notes": [
{
"note": "<p>This paper introduces a new approach to automatically generating test cases from requirements which are described by use cases and contracts. With the aid of sequence diagrams, test scenarios can be generated from test objectives. The authors also provide a simulator to correct requirements by doing simulation and model checking. When applying the approach to real life cases, requirement formalization still poses great challenges to business analysts.</p>"
}
],
"tags": [
"automation",
"test",
"test_case_generation",
"testing",
"use_case"
],
"seeAlso": [],
"attachments": [],
"title": "Automatic test generation: a use case driven approach",
"publicationTitle": "IEEE Transactions on Software Engineering",
"volume": "32",
"issue": "3",
"pages": "140-155",
"ISSN": "0098-5589",
"abstractNote": "Use cases are believed to be a good basis for system testing. Yet, to automate the test generation process, there is a large gap to bridge between high-level use cases and concrete test cases. We propose a new approach for automating the generation of system test scenarios in the context of object-oriented embedded software, taking into account traceability problems between high-level views and concrete test case execution. Starting from a formalization of the requirements based on use cases extended with contracts, we automatically build a transition system from which we synthesize test cases. Our objective is to cover the system in terms of statement coverage with those generated tests: an empirical evaluation of our approach is given based on this objective and several case studies. We briefly discuss the experimental deployment of our approach in the field at Thales Airborne Systems.",
"url": "http://dx.doi.org/10.1109/tse.2006.22",
"DOI": "10.1109/tse.2006.22",
"date": "March 2006",
"libraryCatalog": "CiteULike",
"accessDate": "CURRENT_TIMESTAMP",
"shortTitle": "Automatic test generation"
"seeAlso": []
}
]
},
{
"type": "web",
"url": "http://www.citeulike.org/user/kevin3stone/tag/test",
"items": "multiple"
}
]
/** END TEST CASES **/
/** END TEST CASES **/
Oops, something went wrong.

0 comments on commit 5bb111a

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