Update PD day banner and tweak blog post wording

This commit is contained in:
Alex Cabal 2024-11-27 14:45:08 -06:00
parent c65035630f
commit 5270891eb4
6 changed files with 60 additions and 15 deletions

View file

@ -5,6 +5,7 @@ use function Safe\define;
const NOW = new DateTimeImmutable();
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 SITE_STATUS_LIVE = 'live';
const SITE_STATUS_DEV = 'dev';
@ -77,7 +78,7 @@ const ZOHO_WEBHOOK_LOG_FILE_PATH = '/var/log/local/webhooks-zoho.log'; // Must b
const DONATIONS_LOG_FILE_PATH = '/var/log/local/donations.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.
define('PD_YEAR', intval((new DateTimeImmutable('now', LATEST_CONTINENTAL_US_TZ))->format('Y')) - 96);
define('PD_YEAR', intval(PD_NOW->format('Y')) - 96);
define('PD_STRING', 'January 1, ' . (PD_YEAR + 1));
// Controls the progress bar donation dialog.

View file

@ -22,7 +22,7 @@ class HttpInput{
}
if($httpMethod == Enums\HttpMethod::Post){
// If we're a HTTP POST, then we got here from a POST request initially, so just continue
// If we're a HTTP POST, then we got here from a POST request initially, so just continue.
return;
}
@ -44,6 +44,7 @@ class HttpInput{
/**
* Check that the request's HTTP method is in a list of allowed HTTP methods.
*
* @param ?array<Enums\HttpMethod> $allowedHttpMethods An array containing a list of allowed HTTP methods, or null if any valid HTTP method is allowed.
* @param bool $throwException If the request HTTP method isn't allowed, then throw an exception; otherwise, output HTTP 405 and exit the script immediately.
* @throws Exceptions\InvalidHttpMethodException If the HTTP method is not recognized, and `$throwException` is `true`.
@ -229,7 +230,7 @@ class HttpInput{
* @return array<string>|array<int>|array<float>|array<bool>|string|int|float|bool|DateTimeImmutable|null
*/
private static function GetHttpVar(string $variable, Enums\HttpVariableType $type, Enums\HttpVariableSource $set): mixed{
// Note that in Core.php we parse the request body of DELETE, PATCH, and PUT into $_POST.
// Note that in `Core.php` we parse the request body of DELETE, PATCH, and PUT into `$_POST`.
$vars = [];
@ -250,15 +251,15 @@ class HttpInput{
if(isset($vars[$variable])){
if($type == Enums\HttpVariableType::Array && is_array($vars[$variable])){
// We asked for an array, and we got one
// We asked for an array, and we got one.
return $vars[$variable];
}
elseif($type !== Enums\HttpVariableType::Array && is_array($vars[$variable])){
// We asked for not an array, but we got an array
// We asked for not an array, but we got an array.
return null;
}
elseif(is_string($vars[$variable])){
// HTML `<textarea>`s encode newlines as `\r\n`, i.e. TWO characters, when submitting form data. However jQuery's `.val()` and HTML's `@maxlength` treat newlines as ONE character. So, strip `\r` here so that character lengths align between what the browser reports, and what it actually sends. This also solves column length issues when storing in the DB.
// HTML `<textarea>`s encode newlines as `\r\n`, i.e. *two* characters, when submitting form data. However jQuery's `.val()` and HTML's `@maxlength` treat newlines as *one* character. So, strip `\r` here so that character lengths align between what the browser reports, and what it actually sends. This also solves column length issues when storing in the DB.
$var = trim(str_replace("\r", "", $vars[$variable]));
}
else{
@ -276,7 +277,7 @@ class HttpInput{
return '';
}
case Enums\HttpVariableType::Integer:
// Can't use ctype_digit because we may want negative integers
// Can't use `ctype_digit()` because we may want negative integers.
if(is_numeric($var) && mb_strpos((string)$var, '.') === false){
try{
return intval($var);

View file

@ -14,7 +14,7 @@ $isErrorPage = $isErrorPage ?? false;
$downloadUrl = $downloadUrl ?? null;
$canonicalUrl = $canonicalUrl ?? null;
$css = $css ?? [];
$showPublicDomainDayBanner = new DateTimeImmutable('now', LATEST_CONTINENTAL_US_TZ) < new DateTimeImmutable('January 14', LATEST_CONTINENTAL_US_TZ) && !(HttpInput::Bool(COOKIE, 'hide-public-domain-day-banner') ?? false);
$showPublicDomainDayBanner = PD_NOW < new DateTimeImmutable('January 14', LATEST_CONTINENTAL_US_TZ) && !(HttpInput::Bool(COOKIE, 'hide-public-domain-day-banner') ?? false);
// As of Sep. 2022, all versions of Safari have a bug where if the page is served as XHTML, then `<picture>` elements download all `<source>`s instead of the first supported match.
// So, we try to detect Safari here, and don't use multiple `<source>` if we find Safari.
@ -110,7 +110,7 @@ if(!$isXslt){
<div class="confetti"></div>
<div class="confetti"></div>
</div>
<strong>Happy Public Domain Day <?= PD_DAY_YEAR ?>!</strong> <a href="/blog/public-domain-day-<?= PD_DAY_YEAR ?>">See what new literature is free to read starting January 1.</a>
<a href="/blog/public-domain-day-<?= PD_DAY_YEAR ?>"><strong>Happy Public Domain Day <?= PD_DAY_YEAR ?>!</strong> See whats free to read starting January 1.</a>
<form action="/settings" method="<?= Enums\HttpMethod::Post->value ?>">
<input type="hidden" name="_method" value="<?= Enums\HttpMethod::Patch->value ?>" />
<input type="hidden" name="hide-public-domain-day-banner" value="true" />

View file

@ -92,17 +92,17 @@ ksort($ebooksWithDescriptions);
<?= Template::DonationProgress() ?>
<p>Happy Public Domain Day!</p>
<p>Around the world, people celebrate Public Domain Day on January 1, the day in which copyright expires on some older works, putting them in the public domain in many different countries.</p>
<p>Some countries have a copyright term of the life of the author plus seventy years. These countries have been celebrating public domain day for some time now.</p>
<p>In the U.S. Constitution, copyright terms were limited to up to twenty-eight years, in order to “promote the Progress of Science and useful Arts. But since the Constitution was drafted, powerful corporations have continuously extended the length of copyright so they could continue to profit. The result is that today in the U.S., work only enters the public domain ninety-five years after publication. This has locked <em>all</em> of our cultural output away from us for <em>nearly a century</em>.</p>
<p>Some countries have a copyright term of the life of the author plus seventy years. These countries have been celebrating Public Domain Day for some time now.</p>
<p>In the U.S. Constitution, copyright terms were meant to be very limited in order to “promote the Progress of Science and useful Arts. The first copyright act, written by the founding fathers themselves in 1790, set the term to be up to twenty-eight years. But since then, powerful corporations have continuously extended the length of copyright to promote not the progress of society, but their profit. The result is that today in the U.S., work only enters the public domain ninety-five years after publication. Our cultural output is locked away from us for <em>nearly a century</em>.</p>
<p>2019 was the year in which the first works from almost a hundred years ago were finally scheduled to enter the public domain, ending this long, corporate-dictated cultural winter. As that year approached, we had every reason to assume that these powerful corporations would once again lobby to extend copyright even further.</p>
<p>But as 2019 grew closer, it became clear that these corporations <em>wouldnt</em> work to extend copyright yet again—making 2019 the first year in almost a century in which a significant amount of art and literature once again entered the public domain in the U.S., free for anyone in the U.S. to read, use, and share.</p>
<p>But as 2019 drew closer, it became clear that these corporations <em>wouldnt</em> try to extend copyright yet again—making 2019 the first year in almost a century in which a significant amount of art and literature once again entered the U.S. public domain, free for anyone in the U.S. to read, use, share, remix, build upon, and enjoy.</p>
<p>Ever since then, each year weve been joining our international friends in celebrating Public Domain Day by preparing some of the biggest literary hits of the year for you to read on January 1.</p>
<hr/>
<p><strong>In 2025, books published in 1929 enter the U.S. public domain.</strong></p>
<p>And 1929 was a literary doozy!</p>
<p>Books by William Faulkner, Ernest Hemingway, Mahatma Gandhi, and John Steinbeck enter the U.S. public domain. Joining these esteemed names is the first novel featuring the Continental Op, the nameless hard-boiled noir detective who created the archetype for every hard-drinking, fedora-wearing private eye to grace page and screen since; the English translation of <i>All Quiet on the Western Front</i>; and much more.</p>
<p>Books by <a href="/ebooks/william-faulkner">William Faulkner</a>, <a href="/ebooks/ernest-hemingway">Ernest Hemingway</a>, <a href="/ebooks/mahatma-gandhi">Mahatma Gandhi</a>, and <a href="/ebooks/john-steinbeck">John Steinbeck</a> enter the U.S. public domain. Joining these esteemed names is the English translation of <i><a href="/ebooks/erich-maria-remarque/all-quiet-on-the-western-front/a-w-wheen">All Quiet on the Western Front</a></i>; <i><a href="/ebooks/dashiell-hammet/red-harvest">Red Harvest</a></i>, the first novel featuring the <a href="/collections/continental-op">Continental Op</a>, the nameless hard-boiled noir detective who created the archetype for every hard-drinking, fedora-wearing private eye to grace page and screen since; and much more.</p>
<p>Our friends at Public Domain Review have written about some <a href="">other things that enter the public domain this year, too</a>.</p>
<p>At Standard Ebooks, our volunteers have been working hard for the past few months to prepare the following ebooks to be ready for Public Domain Day. Join us in celebrating the freeing of our cultural heritage by downloading these ebooks and reading them for free:</p>
<p>At Standard Ebooks, our volunteers have been working hard for the past few months to prepare the following ebooks to be ready for Public Domain Day, and now were excited to finally be able to share them with you. Join us in celebrating the liberation of our cultural heritage by downloading these ebooks and reading them for free:</p>
<? if(sizeof($ebooksWithDescriptions) == 0){ ?>
<p class="empty">Were still preparing these free ebooks for Public Domain Day. Check back after January 1!</p>
<? }else{ ?>

View file

@ -3075,7 +3075,7 @@ hr + p{
width: 100%;
text-align: center;
padding: 1rem;
background: #d37a71;
background: radial-gradient(circle, rgba(255, 255, 255, 0) 50%, rgba(0, 0, 0, .1) 100%), #d37a71;
margin-bottom: 1.5rem;
color: #fff;
text-shadow: 1px 1px 0px rgba(0, 0, 0, .75);
@ -3091,6 +3091,27 @@ hr + p{
right: 2px;
}
.public-domain-day-banner button.close:focus{
outline-color: var(--dark-input-outline);
}
.public-domain-day-banner strong::before{
content: '';
background: url('/images/confetti.svg') center center no-repeat;
background-size: contain;
display: inline-block;
height: 2rem;
width: 2rem;
vertical-align: middle;
margin-top: -.5rem;
margin-right: .5rem;
}
.public-domain-day-banner a:any-link:hover{
color: #4c6f98;
text-shadow: 1px 1px 0px rgba(255, 255, 255, .5);
}
body > header:has(.public-domain-day-banner){
flex-wrap: wrap;
padding-top: 0;
@ -3299,6 +3320,7 @@ form[action="/settings"] label{
.public-domain-day-banner strong{
display: block;
margin-left: -2rem;
}
}

21
www/images/confetti.svg Normal file
View file

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<svg xmlns="http://www.w3.org/2000/svg" height="800px" version="1.1" width="800px" viewBox="0 0 366.636 366.636">
<g>
<polygon points="7.261,366.636 230.796,262.472 109.313,142.129" style="fill:#FFB819;"/>
<circle cx="139.46" cy="232.5" r="27.121" style="fill:#FFD26C;"/>
<path d="M64.791,240.073c7.507,0.439,15.158-2.219,20.866-7.982c10.454-10.552,10.455-27.525,0.076-38.087 L64.791,240.073z" style="fill:#FFD26C;"/>
<path d="M34.985,337.966c-5.319,5.371-7.93,12.403-7.847,19.408l44.797-20.876 C61.238,327.277,45.076,327.78,34.985,337.966z" style="fill:#FFD26C;"/>
<path d="M142.845,283.129c-6.434,6.495-8.903,15.423-7.436,23.792l47.484-22.127 c-0.534-0.634-1.093-1.252-1.693-1.846C170.559,272.407,153.387,272.488,142.845,283.129z" style="fill:#FFD26C;"/>
<circle cx="77.177" cy="286.451" r="27.121" style="fill:#FFD26C;"/>
<polygon points="96.306,170.743 202.305,275.748 230.796,262.472 109.313,142.129" style="fill:#004D7A;"/>
</g>
<circle cx="135" cy="86.679" r="18.497" style="fill:#00BCB4;"/>
<circle cx="276.53" cy="235.558" r="18.497" style="fill:#00BCB4;"/>
<circle cx="316.74" cy="153.038" r="18.497" style="fill:#FFB819;"/>
<circle cx="176.102" cy="18.497" r="18.497" style="fill:#FFB819;"/>
<circle cx="228.315" cy="181.419" r="18.497" style="fill:#D85C72;"/>
<circle cx="239.536" cy="74.687" r="18.497" style="fill:#D85C72;"/>
<circle cx="334.385" cy="83.179" r="18.497" style="fill:#D85C72;"/>
<path d="M133.624,143.693c-3.767,0-6.819-3.053-6.819-6.819c0-3.766,3.052-6.819,6.819-6.819 c25.377,0,46.024-20.646,46.024-46.024c0-32.898,26.764-59.662,59.662-59.662c32.897,0,59.661,26.764,59.661,59.662 c0,3.766-3.053,6.818-6.818,6.818c-3.765,0-6.818-3.052-6.818-6.818c0-25.378-20.647-46.024-46.024-46.024 c-25.378,0-46.024,20.646-46.024,46.024C193.285,116.929,166.52,143.693,133.624,143.693z" style="fill:#00BCB4;"/>
<path d="M312.259,210.037c-25.978,0-47.115-21.136-47.115-47.115c0-18.459-15.019-33.479-33.478-33.479 c-18.46,0-33.479,15.019-33.479,33.479c0,3.766-3.053,6.818-6.817,6.818c-3.767,0-6.819-3.052-6.819-6.818 c0-25.979,21.136-47.115,47.115-47.115c25.979,0,47.115,21.136,47.115,47.115c0,18.46,15.018,33.478,33.478,33.478 s33.478-15.018,33.478-33.478c0-3.766,3.054-6.818,6.82-6.818c3.764,0,6.817,3.052,6.817,6.818 C359.375,188.901,338.239,210.037,312.259,210.037z" style="fill:#FFB819;"/>
</svg>

After

Width:  |  Height:  |  Size: 2.3 KiB