Add Faded Page as a source with an icon

This commit is contained in:
Alex Cabal 2021-01-04 12:53:45 -06:00
parent a586291062
commit 2bfcb41ec3
3 changed files with 9 additions and 4 deletions

View file

@ -31,6 +31,7 @@ const SOURCE_DP_OLS = 5;
const SOURCE_OTHER = 6;
const SOURCE_PROJECT_GUTENBERG_CANADA = 7;
const SOURCE_PROJECT_GUTENBERG_AUSTRALIA = 8;
const SOURCE_FADED_PAGE = 9;
const AVERAGE_READING_WORDS_PER_MINUTE = 275;

View file

@ -378,16 +378,16 @@ class Ebook{
// Next the page scan source URLs.
foreach($xml->xpath('/package/metadata/dc:source') ?: [] as $element){
$e = (string)$element;
if(mb_stripos($e, '//www.gutenberg.org') !== false){
if(mb_stripos($e, 'gutenberg.org/') !== false){
$this->Sources[] = new EbookSource(SOURCE_PROJECT_GUTENBERG, $e);
}
elseif(mb_stripos($e, '//gutenberg.net.au') !== false){
elseif(mb_stripos($e, 'gutenberg.net.au/') !== false){
$this->Sources[] = new EbookSource(SOURCE_PROJECT_GUTENBERG_AUSTRALIA, $e);
}
elseif(mb_stripos($e, '//gutenberg.ca') !== false){
elseif(mb_stripos($e, 'gutenberg.ca/') !== false){
$this->Sources[] = new EbookSource(SOURCE_PROJECT_GUTENBERG_CANADA, $e);
}
elseif(mb_stripos($e, '//archive.org/') !== false){
elseif(mb_stripos($e, 'archive.org/') !== false){
$this->Sources[] = new EbookSource(SOURCE_INTERNET_ARCHIVE, $e);
}
elseif(mb_stripos($e, 'hathitrust.org/') !== false){
@ -402,6 +402,9 @@ class Ebook{
elseif(mb_stripos($e, 'www.pgdp.org/ols/') !== false){
$this->Sources[] = new EbookSource(SOURCE_DP_OLS, $e);
}
elseif(mb_stripos($e, 'www.fadedpage.com') !== false){
$this->Sources[] = new EbookSource(SOURCE_FADED_PAGE, $e);
}
else{
$this->Sources[] = new EbookSource(SOURCE_OTHER, $e);
}

View file

@ -252,6 +252,7 @@ catch(\Exception $ex){
<? if($source->Type == SOURCE_HATHI_TRUST){ ?><a href="<?= Formatter::ToPlainText($source->Url) ?>" class="hathitrust">Page scans at HathiTrust</a><? } ?>
<? if($source->Type == SOURCE_GOOGLE_BOOKS){ ?><a href="<?= Formatter::ToPlainText($source->Url) ?>" class="google">Page scans at Google Books</a><? } ?>
<? if($source->Type == SOURCE_DP_OLS){ ?><a href="<?= Formatter::ToPlainText($source->Url) ?>" class="distributed-proofreaders">Page scans at Distributed Proofreaders Open Library System</a><? } ?>
<? if($source->Type == SOURCE_FADED_PAGE){ ?><a href="<?= Formatter::ToPlainText($source->Url) ?>" class="globe">Transcription at Faded Page</a><? } ?>
<? if($source->Type == SOURCE_OTHER){ ?><a href="<?= Formatter::ToPlainText($source->Url) ?>" class="globe"><?= Formatter::ToPlainText(preg_replace(['|https?://(en\.)?|', '|/.+$|'], '', (string)$source->Url) ?? '') /* force type to (string) to satisfy PHPStan */ ?></a><? } ?>
</p>
</li>