Skip to content

Commit

Permalink
Merge branch 'master' into xargs
Browse files Browse the repository at this point in the history
  • Loading branch information
saschanaz committed Jan 10, 2024
2 parents eea6ab4 + 6b4a4dc commit 2eae97e
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 50 deletions.
17 changes: 3 additions & 14 deletions .ci/pull-request-check/selenium-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const translatorServer = require('./translator-server');

const chromeExtensionDir = path.join(__dirname, 'connectors', 'build', 'chrome');
const KEEP_BROWSER_OPEN = 'KEEP_BROWSER_OPEN' in process.env;
const ZOTERO_CONNECTOR_EXTENSION_ID = 'ekhagklcjbdpajgpjgmbionohlpdbjgc';

async function getTranslatorsToTest() {
const translatorFilenames = process.argv[2].split('\n').filter(filename => filename.trim().length > 0);
Expand Down Expand Up @@ -111,21 +112,9 @@ var allPassed = false;
.setChromeOptions(options)
.build();

// No API to retrieve extension ID. Hacks, sigh.
await driver.get("chrome://system/");
await driver.wait(until.elementLocated({id: 'btn-extensions-value'}), 60*1000);
// Chrome 89+ has the extension list expanded by default
try {
let extBtn = await driver.findElement({css: '#btn-extensions-value'});
await extBtn.click();
} catch (e) {}
let contentElem = await driver.findElement({css: '#content'});
let text = await contentElem.getText();
let extId = text.match(/([^\s]*) : Zotero Connector/)[1];

// We got the extension ID and test URL, let's test
// We got the test URL, let's test
const translatorsToTest = await getTranslatorsToTest();
let testUrl = `chrome-extension://${extId}/tools/testTranslators/testTranslators.html#translators=${translatorsToTest.join(',')}`;
let testUrl = `chrome-extension://${ZOTERO_CONNECTOR_EXTENSION_ID}/tools/testTranslators/testTranslators.html#translators=${translatorsToTest.join(',')}`;
await new Promise((resolve) => setTimeout(() => resolve(driver.get(testUrl)), 500));
await driver.wait(until.elementLocated({id: 'translator-tests-complete'}), 30*60*1000);
testResults = await driver.executeScript('return window.seleniumOutput');
Expand Down
47 changes: 24 additions & 23 deletions Bibliotheque nationale de France.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,31 @@
"inRepository": true,
"translatorType": 4,
"browserSupport": "gcsibv",
"lastUpdated": "2021-07-28 15:50:57"
"lastUpdated": "2024-01-09 03:40:58"
}

/*
* Bibliothèque nationale de France Translator
* Copyright (C) 2010 Florian Ziche, ziche@noos.fr
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
***** BEGIN LICENSE BLOCK *****
Copyright © 2010-2024 Florian Ziche, Sylvain Machefert
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 *****
*/


/* Bnf namespace. */
Expand Down Expand Up @@ -472,12 +477,8 @@ var BnfClass = function () {
for (var i = 0; i < rows.length; i++) {
var title = "";
var href = attr(rows[i], 'div[class="notice-synthese"] a', "href");
try {
title = ZU.trim(text(rows[i], 'div[class="notice-synthese"] a h2'));
}
catch (x) {
title = ZU.trim(text(rows[i], 'div[class="notice-synthese"] a'));
}
title = ZU.trim(text(rows[i], 'div[class="notice-synthese"] a'));

var documentYear = text(rows[i], 'span[class="notice-ordre"]');
if (documentYear.length == 6) {
title += " / " + documentYear;
Expand Down
20 changes: 10 additions & 10 deletions Rechtspraak.nl.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"inRepository": true,
"translatorType": 4,
"browserSupport": "gcsibv",
"lastUpdated": "2023-01-18 18:21:16"
"lastUpdated": "2024-01-09 03:25:57"
}

/*
Expand Down Expand Up @@ -75,13 +75,13 @@ function cleanTags(x) {
}

function detectWeb(doc, url) {
if (url.includes('/#!/details') || url.includes('/front/portal/document-viewer')) {
if (url.includes('.nl/details') || url.includes('/front/portal/document-viewer')) {
return "case";
}
else if (getSearchResults(doc, true)) {
return "multiple";
}
else if (url.includes('/#!/resultaat') && doc.querySelector('app-results')) {
else if (url.includes('/resultaat') && doc.querySelector('app-results')) {
Z.monitorDOMChanges(doc.querySelector('app-results'), { childList: true, subtree: true });
}
return false;
Expand All @@ -90,7 +90,7 @@ function detectWeb(doc, url) {
function getSearchResults(doc, checkOnly) {
var items = {};
var found = false;
var rows = doc.querySelectorAll('.rnl-listresults-item-title > a[href*="#!/details"]');
var rows = doc.querySelectorAll('.rnl-listresults-item-title > a[href*="/details"]');
for (let row of rows) {
let href = row.href;
let title = ZU.trimInternal(row.textContent);
Expand All @@ -117,8 +117,8 @@ async function doWeb(doc, url) {
}

async function scrape(url) {
let apiURL = url.includes('#!/details')
? url.replace('#!/details', 'api/document/')
let apiURL = url.includes('/details')
? url.replace('/details', '/api/document/')
: `https://uitspraken.rechtspraak.nl/api/document/?id=${url.match(/ext-id=([^&#]+)/)[1]}`;
let json = await requestJSON(apiURL);
let item = new Zotero.Item("case");
Expand Down Expand Up @@ -163,7 +163,7 @@ async function scrape(url) {
var testCases = [
{
"type": "web",
"url": "https://uitspraken.rechtspraak.nl/#!/details?id=ECLI:NL:GHDHA:2018:2591",
"url": "https://uitspraken.rechtspraak.nl/details?id=ECLI:NL:GHDHA:2018:2591",
"items": [
{
"itemType": "case",
Expand Down Expand Up @@ -194,7 +194,7 @@ var testCases = [
},
{
"type": "web",
"url": "https://uitspraken.rechtspraak.nl/#!/details?id=ECLI:NL:PHR:2019:1016",
"url": "https://uitspraken.rechtspraak.nl/details?id=ECLI:NL:PHR:2019:1016",
"items": [
{
"itemType": "case",
Expand Down Expand Up @@ -225,7 +225,7 @@ var testCases = [
},
{
"type": "web",
"url": "https://uitspraken.rechtspraak.nl/#!/details?id=ECLI:NL:ORBAACM:2020:30&showbutton=true",
"url": "https://uitspraken.rechtspraak.nl/details?id=ECLI:NL:ORBAACM:2020:30&showbutton=true",
"items": [
{
"itemType": "case",
Expand Down Expand Up @@ -258,7 +258,7 @@ var testCases = [
},
{
"type": "web",
"url": "https://uitspraken.rechtspraak.nl/#!/resultaat?zoekterm=test&inhoudsindicatie=zt0&publicatiestatus=ps1&sort=Relevance",
"url": "https://uitspraken.rechtspraak.nl/resultaat?zoekterm=test&inhoudsindicatie=zt0&publicatiestatus=ps1&sort=Relevance",
"items": "multiple"
},
{
Expand Down
6 changes: 3 additions & 3 deletions arXiv.org.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"inRepository": true,
"translatorType": 12,
"browserSupport": "gcsibv",
"lastUpdated": "2022-05-12 01:25:32"
"lastUpdated": "2024-01-05 12:21:40"
}

/*
Expand Down Expand Up @@ -111,7 +111,7 @@ function doWeb(doc, url) {

var urls = [];
for (var id in items) {
urls.push('http://export.arxiv.org/oai2'
urls.push('https://export.arxiv.org/oai2'
+ '?verb=GetRecord&metadataPrefix=oai_dc'
+ '&identifier=oai%3AarXiv.org%3A' + encodeURIComponent(id)
);
Expand All @@ -137,7 +137,7 @@ function doWeb(doc, url) {
}
if (!id) throw new Error('Could not find arXiv ID on page.');
id = id.trim().replace(/^arxiv:\s*|v\d+|\s+.*$/ig, '');
var apiurl = 'http://export.arxiv.org/oai2?verb=GetRecord&metadataPrefix=oai_dc'
var apiurl = 'https://export.arxiv.org/oai2?verb=GetRecord&metadataPrefix=oai_dc'
+ '&identifier=oai%3AarXiv.org%3A' + encodeURIComponent(id);
ZU.doGet(apiurl, parseXML);
}
Expand Down

0 comments on commit 2eae97e

Please sign in to comment.