From 93e0c4641a526f7ce1d831c5dfd9bd4b3ab3d956 Mon Sep 17 00:00:00 2001 From: GlazerMann Date: Thu, 26 Dec 2024 13:13:23 -0600 Subject: [PATCH 1/7] Update bad_data.php --- constants/bad_data.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/constants/bad_data.php b/constants/bad_data.php index 37074a6a66..6d826186ab 100644 --- a/constants/bad_data.php +++ b/constants/bad_data.php @@ -643,6 +643,12 @@ 'doi.library.ubc.ca', ]; +const JOURNAL_ARCHIVES_SITES = [ + 'zaguan.unizar.es', + 'hal.science', + 'shs.cairn.info', + ]: + const PROXY_HOSTS_TO_ALWAYS_DROP = [ 'proxy.libraries', 'proxy.lib.', From 1fc0a8d527da3bfbb76956723471dd6f6825cf39 Mon Sep 17 00:00:00 2001 From: GlazerMann Date: Thu, 26 Dec 2024 13:14:23 -0600 Subject: [PATCH 2/7] Update Zotero.php --- Zotero.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Zotero.php b/Zotero.php index c8c47dad2c..3d9fb00709 100644 --- a/Zotero.php +++ b/Zotero.php @@ -945,7 +945,7 @@ public static function process_zotero_response(string $zotero_response, Template (stripos((string) $result->publicationTitle, ' edition') === false)) { // Do not add if "journal" includes "edition" if (str_replace(NON_JOURNALS, '', (string) $result->publicationTitle) === (string) $result->publicationTitle) { if (str_ireplace(NON_JOURNAL_WEBSITES, '', $url) === $url || $template->wikiname() === 'cite journal') { - if (str_ireplace(CANONICAL_PUBLISHER_URLS, '', $url) === $url) { + if (str_ireplace(CANONICAL_PUBLISHER_URLS, '', $url) === $url && str_ireplace(JOURNAL_ARCHIVES_SITES, '', $url) === $url) { bot_debug_log('Possible journal URL: ' . $url); $template->add_if_new('work', (string) $result->publicationTitle); } else { From fa57f8ede3647493c1d8adab9da2036b591ffbc5 Mon Sep 17 00:00:00 2001 From: GlazerMann Date: Thu, 26 Dec 2024 13:16:48 -0600 Subject: [PATCH 3/7] Update constantsTest.php --- tests/phpunit/constantsTest.php | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tests/phpunit/constantsTest.php b/tests/phpunit/constantsTest.php index 1f90e3f2ef..8a067cac64 100644 --- a/tests/phpunit/constantsTest.php +++ b/tests/phpunit/constantsTest.php @@ -422,10 +422,37 @@ public function testNonJournalListIsNotBad() { echo "\n\n CANONICAL_PUBLISHER_URLS damaged by NON_JOURNAL_WEBSITES: " . $journal . ' ' . $check . "\n\n"; $this->flush(); } + $check = $journal; + foreach (JOURNAL_ARCHIVES_SITES as $bad) { + $check = str_ireplace($bad, '', $check); + } + if ($check !== $journal) { + $failed = true; + $this->flush(); + echo "\n\n JOURNAL_ARCHIVES_SITES damaged by NON_JOURNAL_WEBSITES: " . $journal . ' ' . $check . "\n\n"; + $this->flush(); + } + } + foreach (NON_JOURNAL_WEBSITES as $journal) { + $journal = $journal . '/'; + $check = $journal; + foreach (JOURNAL_ARCHIVES_SITES as $bad) { + $check = str_ireplace($bad, '', $check); + } + if ($check !== $journal) { + $failed = true; + $this->flush(); + echo "\n\n NON_JOURNAL_WEBSITES damaged by JOURNAL_ARCHIVES_SITES: " . $journal . ' ' . $check . "\n\n"; + $this->flush(); + } } $this->assertFalse($failed); } + + + JOURNAL_ARCHIVES_SITES + public function testItalicsOrder(): void { $in_order = true; $spaces_at = 99999999; From 3a68dfc833d51dbdad7caf822d2c8c84bfc03f87 Mon Sep 17 00:00:00 2001 From: GlazerMann Date: Thu, 26 Dec 2024 13:21:10 -0600 Subject: [PATCH 4/7] Update bad_data.php --- constants/bad_data.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/constants/bad_data.php b/constants/bad_data.php index 6d826186ab..4f39b2111a 100644 --- a/constants/bad_data.php +++ b/constants/bad_data.php @@ -647,7 +647,7 @@ 'zaguan.unizar.es', 'hal.science', 'shs.cairn.info', - ]: +]; const PROXY_HOSTS_TO_ALWAYS_DROP = [ 'proxy.libraries', From d0bbe701342f53f11226aa5640f6b3afdf7ef48b Mon Sep 17 00:00:00 2001 From: GlazerMann Date: Thu, 26 Dec 2024 13:21:35 -0600 Subject: [PATCH 5/7] Update constantsTest.php --- tests/phpunit/constantsTest.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tests/phpunit/constantsTest.php b/tests/phpunit/constantsTest.php index 8a067cac64..e8a40d34de 100644 --- a/tests/phpunit/constantsTest.php +++ b/tests/phpunit/constantsTest.php @@ -449,10 +449,6 @@ public function testNonJournalListIsNotBad() { $this->assertFalse($failed); } - - - JOURNAL_ARCHIVES_SITES - public function testItalicsOrder(): void { $in_order = true; $spaces_at = 99999999; From 7617ff8ff2adc710b2e55da294d64ff9f20f3a86 Mon Sep 17 00:00:00 2001 From: GlazerMann Date: Thu, 26 Dec 2024 18:48:39 -0600 Subject: [PATCH 6/7] Update zoteroTest.php --- tests/phpunit/zoteroTest.php | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/tests/phpunit/zoteroTest.php b/tests/phpunit/zoteroTest.php index 3701f2c154..7e5766dd85 100644 --- a/tests/phpunit/zoteroTest.php +++ b/tests/phpunit/zoteroTest.php @@ -615,16 +615,38 @@ public function testZoteroResponse35(): void { } public function testZoteroResponse36(): void { - $text = '{{cite web|id=}}'; - $template = $this->make_citation($text); - $access_date = 0; - $url = ''; $zotero_data[0] = (object) ['title' => 'Billy', 'itemType' => 'journalArticle', 'publicationTitle' => "X"]; $zotero_response = json_encode($zotero_data); + $access_date = 0; + $text = '{{cite web|id=}}'; + + $template = $this->make_citation($text); + $url = 'zaguan.unizar.es'; + Zotero::process_zotero_response($zotero_response, $template, $url, $access_date); + $this->assertSame('cite journal', $template->wikiname()); + $this->assertSame('Billy', $template->get2('title')); + $this->assertSame('X', $template->get2('journal')); + + $template = $this->make_citation($text); + $url = 'bmj.com/cgi/pmidlookup'; Zotero::process_zotero_response($zotero_response, $template, $url, $access_date); $this->assertSame('cite journal', $template->wikiname()); $this->assertSame('Billy', $template->get2('title')); $this->assertSame('X', $template->get2('journal')); + + $template = $this->make_citation($text); + $url = 'www.nsw.gov.au/; + Zotero::process_zotero_response($zotero_response, $template, $url, $access_date); + $this->assertSame('cite journal', $template->wikiname()); + $this->assertSame('Billy', $template->get2('title')); + $this->assertSame('X', $template->get2('work')); + + $template = $this->make_citation($text); + $url = 'NotOnAnyList'; + Zotero::process_zotero_response($zotero_response, $template, $url, $access_date); + $this->assertSame('cite journal', $template->wikiname()); + $this->assertSame('Billy', $template->get2('title')); + $this->assertSame('X', $template->get2('work')); } public function testZoteroResponse37(): void { From cf93aeaac3c9fb0803a783ec02f9c910533bb78e Mon Sep 17 00:00:00 2001 From: GlazerMann Date: Thu, 26 Dec 2024 18:51:55 -0600 Subject: [PATCH 7/7] Update zoteroTest.php --- tests/phpunit/zoteroTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/phpunit/zoteroTest.php b/tests/phpunit/zoteroTest.php index 7e5766dd85..48d248dc90 100644 --- a/tests/phpunit/zoteroTest.php +++ b/tests/phpunit/zoteroTest.php @@ -635,7 +635,7 @@ public function testZoteroResponse36(): void { $this->assertSame('X', $template->get2('journal')); $template = $this->make_citation($text); - $url = 'www.nsw.gov.au/; + $url = 'www.nsw.gov.au/sss'; Zotero::process_zotero_response($zotero_response, $template, $url, $access_date); $this->assertSame('cite journal', $template->wikiname()); $this->assertSame('Billy', $template->get2('title'));