Skip to content

Commit

Permalink
Create JOURNAL_ARCHIVES_SITES
Browse files Browse the repository at this point in the history
  • Loading branch information
GlazerMann authored Dec 27, 2024
2 parents 5b8ded1 + cf93aea commit 8bc221a
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Zotero.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 6 additions & 0 deletions constants/bad_data.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.',
Expand Down
23 changes: 23 additions & 0 deletions tests/phpunit/constantsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,29 @@ 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);
}
Expand Down
30 changes: 26 additions & 4 deletions tests/phpunit/zoteroTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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/sss';
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 {
Expand Down

0 comments on commit 8bc221a

Please sign in to comment.