mirror of
https://github.com/standardebooks/web.git
synced 2025-07-19 12:54:48 -04:00
Remove now-redundant PD placeholders code
This commit is contained in:
parent
ee14ff30ea
commit
bcba5c2192
6 changed files with 7 additions and 143 deletions
|
@ -6,6 +6,8 @@ use function Safe\define;
|
||||||
const NOW = new DateTimeImmutable();
|
const NOW = new DateTimeImmutable();
|
||||||
const LATEST_CONTINENTAL_US_TZ = new DateTimeZone('America/Juneau');
|
const LATEST_CONTINENTAL_US_TZ = new DateTimeZone('America/Juneau');
|
||||||
const PD_NOW = new DateTimeImmutable('now', LATEST_CONTINENTAL_US_TZ); // This timestamp should be used for Public Domain Day calculations.
|
const PD_NOW = new DateTimeImmutable('now', LATEST_CONTINENTAL_US_TZ); // This timestamp should be used for Public Domain Day calculations.
|
||||||
|
define('PD_YEAR', intval(PD_NOW->format('Y')) - 96);
|
||||||
|
define('PD_STRING', 'January 1, ' . (PD_YEAR + 1));
|
||||||
|
|
||||||
const SITE_STATUS_LIVE = 'live';
|
const SITE_STATUS_LIVE = 'live';
|
||||||
const SITE_STATUS_DEV = 'dev';
|
const SITE_STATUS_DEV = 'dev';
|
||||||
|
@ -83,8 +85,6 @@ const DONATIONS_LOG_FILE_PATH = '/var/log/local/donations.log'; // Must be writ
|
||||||
const ARTWORK_UPLOADS_LOG_FILE_PATH = '/var/log/local/artwork-uploads.log'; // Must be writable by `www-data` Unix user.
|
const ARTWORK_UPLOADS_LOG_FILE_PATH = '/var/log/local/artwork-uploads.log'; // Must be writable by `www-data` Unix user.
|
||||||
const EMAIL_LOG_FILE_PATH = '/var/log/local/standardebooks.org-email.log'; // Must be writable by `www-data` Unix user.
|
const EMAIL_LOG_FILE_PATH = '/var/log/local/standardebooks.org-email.log'; // Must be writable by `www-data` Unix user.
|
||||||
|
|
||||||
define('PD_YEAR', intval(PD_NOW->format('Y')) - 96);
|
|
||||||
define('PD_STRING', 'January 1, ' . (PD_YEAR + 1));
|
|
||||||
|
|
||||||
// Controls the progress bar donation dialog.
|
// Controls the progress bar donation dialog.
|
||||||
const DONATION_DRIVES_ENABLED = true; // **`TRUE`** to enable automatic donation drives; **`FALSE`** to disable all donation drives.
|
const DONATION_DRIVES_ENABLED = true; // **`TRUE`** to enable automatic donation drives; **`FALSE`** to disable all donation drives.
|
||||||
|
@ -109,25 +109,3 @@ const DONATION_DRIVE_DATES = [
|
||||||
const DONATION_DRIVE_COUNTER_ENABLED = false;
|
const DONATION_DRIVE_COUNTER_ENABLED = false;
|
||||||
const DONATION_DRIVE_COUNTER_START = new DateTimeImmutable('May 2, 2022 00:00:00', new DateTimeZone('America/New_York'));
|
const DONATION_DRIVE_COUNTER_START = new DateTimeImmutable('May 2, 2022 00:00:00', new DateTimeZone('America/New_York'));
|
||||||
const DONATION_DRIVE_COUNTER_END = new DateTimeImmutable('May 8, 2022 23:59:00', new DateTimeZone('America/New_York'));
|
const DONATION_DRIVE_COUNTER_END = new DateTimeImmutable('May 8, 2022 23:59:00', new DateTimeZone('America/New_York'));
|
||||||
|
|
||||||
const PD_DAY_YEAR = 2025;
|
|
||||||
const PD_DAY_DRAFT_PATH = '/standardebooks.org/drafts/' . PD_DAY_YEAR;
|
|
||||||
// These books will have placeholder URLs enabled, which are useful for things like the PDR Public Domain Advent Calendar.
|
|
||||||
const PD_DAY_EBOOKS = [
|
|
||||||
EBOOKS_IDENTIFIER_PREFIX . 'graham-greene/the-man-within' => ['author' => 'Graham Greene', 'title' => 'The Man Within'],
|
|
||||||
EBOOKS_IDENTIFIER_PREFIX . 'c-s-forester/brown-on-resolution' => ['author' => 'C. S. Forester', 'title' => 'Brown on Resolution'],
|
|
||||||
EBOOKS_IDENTIFIER_PREFIX . 'dashiell-hammett/red-harvest' => ['author' => 'Dashiell Hammett', 'title' => 'Red Harvest'],
|
|
||||||
EBOOKS_IDENTIFIER_PREFIX . 'dashiell-hammett/the-dain-curse' => ['author' => 'Dashiell Hammett', 'title' => 'The Dain Curse'],
|
|
||||||
EBOOKS_IDENTIFIER_PREFIX . 'erich-maria-remarque/all-quiet-on-the-western-front/a-w-wheen' => ['author' => 'Erich Maria Remarque', 'title' => 'All Quiet on the Western Front', 'translator' => 'A. W. Wheen'],
|
|
||||||
EBOOKS_IDENTIFIER_PREFIX . 'ernest-hemingway/a-farewell-to-arms' => ['author' => 'Ernest Heminway', 'title' => 'A Farewell to Arms'],
|
|
||||||
EBOOKS_IDENTIFIER_PREFIX . 'j-b-priestley/the-good-companions' => ['author' => 'J. B. Priestley', 'title' => 'The Good Companions'],
|
|
||||||
EBOOKS_IDENTIFIER_PREFIX . 'john-steinbeck/cup-of-gold' => ['author' => 'John Steinbeck', 'title' => 'Cup of Gold'],
|
|
||||||
EBOOKS_IDENTIFIER_PREFIX . 'oliver-la-farge/laughing-boy' => ['author' => 'Oliver La Farge', 'title' => 'Laughing Boy'],
|
|
||||||
EBOOKS_IDENTIFIER_PREFIX . 'william-faulkner/the-sound-and-the-fury' => ['author' => 'William Faulkner', 'title' => 'The Sound and the Fury'],
|
|
||||||
EBOOKS_IDENTIFIER_PREFIX . 'mahatma-gandhi/the-story-of-my-experiments-with-truth/mahadev-desai' => ['author' => 'Mahatma Gandhi', 'title' => 'The Story of My Experiments with Truth'],
|
|
||||||
EBOOKS_IDENTIFIER_PREFIX . 'arthur-conan-doyle/the-maracot-deep' => ['author' => 'Arthur Conan Doyle', 'title' => 'The Maracot Deep'],
|
|
||||||
EBOOKS_IDENTIFIER_PREFIX . 'sinclair-lewis/dodsworth' => ['author' => 'Sinclair Lewis', 'title' => 'Dodsworth'],
|
|
||||||
EBOOKS_IDENTIFIER_PREFIX . 'thomas-wolfe/look-homeward-angel' => ['author' => 'Thomas Wolfe', 'title' => 'Look Homeward, Angel'],
|
|
||||||
EBOOKS_IDENTIFIER_PREFIX . 'lloyd-c-douglas/magnificent-obsession' => ['author' => 'Lloyd C. Dougals', 'title' => 'Magnificent Obsession'],
|
|
||||||
EBOOKS_IDENTIFIER_PREFIX . 'edith-wharton/hudson-river-bracketed' => ['author' => 'Edith Wharton', 'title' => 'Hudson River Bracketed'],
|
|
||||||
];
|
|
||||||
|
|
|
@ -110,7 +110,7 @@ if(!$isXslt){
|
||||||
<div class="confetti"></div>
|
<div class="confetti"></div>
|
||||||
<div class="confetti"></div>
|
<div class="confetti"></div>
|
||||||
</div>
|
</div>
|
||||||
<a href="/blog/public-domain-day-<?= PD_DAY_YEAR ?>"><strong>Happy Public Domain Day <?= PD_DAY_YEAR ?>!</strong> See what’s free to read on January 1.</a>
|
<a href="/blog/public-domain-day-<?= PD_NOW->format('Y') ?>"><strong>Happy Public Domain Day <?= PD_NOW->format('Y') ?>!</strong> See what’s free to read on January 1.</a>
|
||||||
<form action="/settings" method="<?= Enums\HttpMethod::Post->value ?>">
|
<form action="/settings" method="<?= Enums\HttpMethod::Post->value ?>">
|
||||||
<input type="hidden" name="_method" value="<?= Enums\HttpMethod::Patch->value ?>" />
|
<input type="hidden" name="_method" value="<?= Enums\HttpMethod::Patch->value ?>" />
|
||||||
<input type="hidden" name="hide-public-domain-day-banner" value="true" />
|
<input type="hidden" name="hide-public-domain-day-banner" value="true" />
|
||||||
|
|
|
@ -108,8 +108,10 @@ ksort($ebooksWithDescriptions);
|
||||||
<h1>Public Domain Day in Literature</h1>
|
<h1>Public Domain Day in Literature</h1>
|
||||||
<p>Read <?= number_format(sizeof($identifiers)) ?> of the best books entering the public domain in 2025</p>
|
<p>Read <?= number_format(sizeof($identifiers)) ?> of the best books entering the public domain in 2025</p>
|
||||||
</hgroup>
|
</hgroup>
|
||||||
<?= Template::DonationCounter() ?>
|
<? if(false){ ?>
|
||||||
<?= Template::DonationProgress() ?>
|
<?= Template::DonationCounter() ?>
|
||||||
|
<?= Template::DonationProgress() ?>
|
||||||
|
<? } ?>
|
||||||
<picture data-caption="The Reader. Harold Knight, circa 1910">
|
<picture data-caption="The Reader. Harold Knight, circa 1910">
|
||||||
<source srcset="/images/the-reader@2x.avif 2x, /images/the-reader.avif 1x" type="image/avif"/>
|
<source srcset="/images/the-reader@2x.avif 2x, /images/the-reader.avif 1x" type="image/avif"/>
|
||||||
<source srcset="/images/the-reader@2x.jpg 2x, /images/the-reader.jpg 1x" type="image/jpg"/>
|
<source srcset="/images/the-reader@2x.jpg 2x, /images/the-reader.jpg 1x" type="image/jpg"/>
|
||||||
|
|
|
@ -3080,11 +3080,6 @@ figure.realistic-ebook::before{ /* shadow */
|
||||||
transition: transform .5s;
|
transition: transform .5s;
|
||||||
}
|
}
|
||||||
|
|
||||||
article.ebook.public-domain-day-placeholder #read-free p{
|
|
||||||
text-align: center;
|
|
||||||
font-style: italic;
|
|
||||||
}
|
|
||||||
|
|
||||||
article.ebook section#read-online ul li p.has-size{
|
article.ebook section#read-online ul li p.has-size{
|
||||||
display: flex;
|
display: flex;
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,12 +69,6 @@ catch(Exceptions\EbookNotFoundException){
|
||||||
// Still not found, continue.
|
// Still not found, continue.
|
||||||
}
|
}
|
||||||
|
|
||||||
// Are we accessing a placeholder for a Public Domain Day book that is not yet released?
|
|
||||||
if(array_key_exists($identifier, PD_DAY_EBOOKS)){
|
|
||||||
require(WEB_ROOT . '/ebooks/public-domain-day-placeholder.php');
|
|
||||||
exit();
|
|
||||||
}
|
|
||||||
|
|
||||||
Template::ExitWithCode(Enums\HttpCode::NotFound);
|
Template::ExitWithCode(Enums\HttpCode::NotFound);
|
||||||
}
|
}
|
||||||
?><?= Template::Header(['title' => strip_tags($ebook->TitleWithCreditsHtml) . ' - Free ebook download', 'ogType' => 'book', 'coverUrl' => $ebook->DistCoverUrl, 'highlight' => 'ebooks', 'description' => 'Free epub ebook download of the Standard Ebooks edition of ' . $ebook->Title . ': ' . $ebook->Description, 'canonicalUrl' => SITE_URL . $ebook->Url]) ?>
|
?><?= Template::Header(['title' => strip_tags($ebook->TitleWithCreditsHtml) . ' - Free ebook download', 'ogType' => 'book', 'coverUrl' => $ebook->DistCoverUrl, 'highlight' => 'ebooks', 'description' => 'Free epub ebook download of the Standard Ebooks edition of ' . $ebook->Title . ': ' . $ebook->Description, 'canonicalUrl' => SITE_URL . $ebook->Url]) ?>
|
||||||
|
|
|
@ -1,105 +0,0 @@
|
||||||
<?
|
|
||||||
use function Safe\preg_replace;
|
|
||||||
|
|
||||||
/** @var string $identifier Passed from script this is included from. */
|
|
||||||
$ebook = null;
|
|
||||||
|
|
||||||
try{
|
|
||||||
try{
|
|
||||||
// Attempt to read a draft ebook repo from the filesystem.
|
|
||||||
// **Important:** The `deploy` script *does not tranfer `.git` folders,* which `Ebook::FromFilesystem()` needs to have. Therefore, use `rsync` to sync Public Domain Day ebooks including their `.git` folders.
|
|
||||||
$ebook = Ebook::FromFilesystem(PD_DAY_DRAFT_PATH . '/' . str_replace('/', '_', preg_replace('|^' . EBOOKS_IDENTIFIER_PREFIX . '|', '', $identifier)));
|
|
||||||
}
|
|
||||||
catch(Exceptions\EbookNotFoundException $ex){
|
|
||||||
// We may have ebooks listed as in progress, but no actual draft repos yet.
|
|
||||||
// In that case, fill in the details from `PD_DAY_EBOOKS`.
|
|
||||||
if(array_key_exists($identifier, PD_DAY_EBOOKS)){
|
|
||||||
$ebook = new Ebook();
|
|
||||||
$ebook->EbookId = 0;
|
|
||||||
$ebook->Description = '';
|
|
||||||
$ebook->LongDescription = '';
|
|
||||||
|
|
||||||
$c = new Contributor();
|
|
||||||
$c->Name = PD_DAY_EBOOKS[$identifier]['author'];
|
|
||||||
$ebook->Authors = [$c];
|
|
||||||
|
|
||||||
if(isset(PD_DAY_EBOOKS[$identifier]['translator'])){
|
|
||||||
$c = new Contributor();
|
|
||||||
$c->Name = PD_DAY_EBOOKS[$identifier]['translator'];
|
|
||||||
$ebook->Translators = [$c];
|
|
||||||
}
|
|
||||||
|
|
||||||
$ebook->Title = PD_DAY_EBOOKS[$identifier]['title'];
|
|
||||||
$ebook->WwwFilesystemPath = '';
|
|
||||||
$ebook->Identifier = 'url:https://standardebooks.org/ebooks/' . $identifier;
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
throw $ex;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch(Exceptions\EbookNotFoundException){
|
|
||||||
Template::ExitWithCode(Enums\HttpCode::NotFound);
|
|
||||||
}
|
|
||||||
?><?= Template::Header(['title' => strip_tags($ebook->TitleWithCreditsHtml) . ' - Free ebook download', 'highlight' => 'ebooks', 'description' => 'Free epub ebook download of the Standard Ebooks edition of ' . $ebook->Title . ': ' . $ebook->Description, 'canonicalUrl' => SITE_URL . $ebook->Url]) ?>
|
|
||||||
<main>
|
|
||||||
<article class="ebook public-domain-day-placeholder">
|
|
||||||
<header>
|
|
||||||
<hgroup>
|
|
||||||
<h1><?= Formatter::EscapeHtml($ebook->Title) ?></h1>
|
|
||||||
<? foreach($ebook->Authors as $author){ ?>
|
|
||||||
<? if($author->Name != 'Anonymous'){ ?>
|
|
||||||
<p>
|
|
||||||
<a href="<?= Formatter::EscapeHtml($ebook->AuthorsUrl) ?>"><?= Formatter::EscapeHtml($author->Name) ?></a>
|
|
||||||
</p>
|
|
||||||
<? } ?>
|
|
||||||
<? } ?>
|
|
||||||
</hgroup>
|
|
||||||
<picture>
|
|
||||||
<source srcset="/images/public-domain-day-placeholder-cover-hero@2x.jpg 2x, /images/public-domain-day-placeholder-cover-hero.jpg 1x" type="image/jpg"/>
|
|
||||||
<img src="/images/public-domain-day-placeholder-cover-hero@2x.jpg" alt="" height="439" width="1318" />
|
|
||||||
</picture>
|
|
||||||
</header>
|
|
||||||
|
|
||||||
<? if(sizeof($ebook->Tags) > 0){ ?>
|
|
||||||
<aside id="reading-ease">
|
|
||||||
<? if($ebook->ContributorsHtml != ''){ ?>
|
|
||||||
<p><?= $ebook->ContributorsHtml ?></p>
|
|
||||||
<? } ?>
|
|
||||||
<? if(sizeof($ebook->CollectionMemberships) > 0){ ?>
|
|
||||||
<? foreach($ebook->CollectionMemberships as $collectionMembership){ ?>
|
|
||||||
<p>
|
|
||||||
<?= Template::CollectionDescriptor(['collectionMembership' => $collectionMembership]) ?>.
|
|
||||||
</p>
|
|
||||||
<? } ?>
|
|
||||||
<? } ?>
|
|
||||||
<ul class="tags">
|
|
||||||
<? foreach($ebook->Tags as $tag){ ?>
|
|
||||||
<li>
|
|
||||||
<a href="<?= $tag->Url ?>"><?= Formatter::EscapeHtml($tag->Name) ?></a>
|
|
||||||
</li>
|
|
||||||
<? } ?>
|
|
||||||
</ul>
|
|
||||||
</aside>
|
|
||||||
<? } ?>
|
|
||||||
|
|
||||||
<section id="description">
|
|
||||||
<h2>Description</h2>
|
|
||||||
<?= Template::DonationCounter() ?>
|
|
||||||
<?= Template::DonationProgress() ?>
|
|
||||||
|
|
||||||
<?= Template::DonationAlert() ?>
|
|
||||||
|
|
||||||
<? if($ebook->LongDescription !== null){ ?>
|
|
||||||
<?= $ebook->LongDescription ?>
|
|
||||||
<? } ?>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<section id="read-free">
|
|
||||||
<h2>Read free</h2>
|
|
||||||
<p>This book will enter the public domain in the U.S. on <b>January 1, <?= PD_DAY_YEAR ?></b>.</p>
|
|
||||||
<p>We’ve been working hard, and have this ebook prepared and ready for you to download free on January 1. Bookmark this page and come back then to read this ebook for free!</p>
|
|
||||||
</section>
|
|
||||||
</article>
|
|
||||||
</main>
|
|
||||||
<?= Template::Footer() ?>
|
|
Loading…
Add table
Add a link
Reference in a new issue