Add grant giveaway donation dialog

This commit is contained in:
Alex Cabal 2022-05-01 17:36:59 -05:00
parent 5985939cd5
commit e5c2e0d5fc
10 changed files with 172 additions and 20 deletions

View file

@ -77,6 +77,7 @@ define('PD_YEAR', intval(gmdate('Y')) - 96);
define('DONATION_HOLIDAY_ALERT_ON', time() > strtotime('November 15, ' . gmdate('Y')) || time() < strtotime('January 7, ' . gmdate('Y')));
define('DONATION_ALERT_ON', DONATION_HOLIDAY_ALERT_ON || rand(1, 4) == 2);
define('DONATION_DRIVE_ON', false);
define('DONATION_DRIVE_COUNTER_ON', false);
const GITHUB_SECRET_FILE_PATH = SITE_ROOT . '/config/secrets/se-vcs-bot@github.com'; // Set in the GitHub organization global webhook settings.
const GITHUB_WEBHOOK_LOG_FILE_PATH = '/var/log/local/webhooks-github.log'; // Must be writable by `www-data` Unix user.

View file

@ -0,0 +1,66 @@
<?
// Hide the alert if the user has closed it
if(!DONATION_DRIVE_COUNTER_ON || ($autoHide ?? $_COOKIE['hide-donation-alert'] ?? false)){
return;
}
$autoHide = $autoHide ?? true;
$showDonateButton = $showDonateButton ?? true;
$current = 0;
$start = new DateTime('May 2, 2022 00:00:00 America/New_York');
$end = new DateTime('May 8, 2022 23:59:00 America/New_York');
$now = new DateTime();
if($now < $start || $now > $end){
return;
}
$deadline = $end->format('F j');
$timeLeft = $now->diff($end);
$timeString = '';
if($timeLeft->d < 1 && $timeLeft->h < 20){
$timeString = 'Just hours';
}
elseif($timeLeft->d >= 1 && $timeLeft->h <= 12){
$timeString = $timeLeft->d . ' day';
if($timeLeft->d > 1){
$timeString .= 's';
}
else{
$timeString = 'Only ' . $timeString;
}
}
else{
$timeString = ($timeLeft->d + 1) . ' day';
if($timeLeft->d + 1 > 1){
$timeString .= 's';
}
else{
$timeString = 'Only ' . $timeString;
}
}
$digits = str_split(str_pad($current, 3, "0", STR_PAD_LEFT))
?>
<aside class="donation counter">
<? if($autoHide){ ?>
<form action="/settings" method="post">
<input type="hidden" name="hide-donation-alert" value="1" />
<button class="close">Close this alert</button>
</form>
<? } ?>
<header>
<p><?= $timeString ?> left to help us win $1,000</p>
</header>
<div class="flipboard">
<? foreach($digits as $digit){ ?><span><?= $digit ?></span><? } ?>
entries
</div>
<p>Our fiscal sponsor, <a href="https://www.fracturedatlas.org">Fractured Atlas</a>, is celebrating the twenty-year anniversary of their fiscal sponsorship program by <a href="https://media.fracturedatlas.org/what-would-you-do-with-an-extra-1000">distributing $1,000 to twenty different projects</a>.</p>
<p><strong>Each one-time donation of any amount to Standard Ebooks through <?= $deadline ?> gives us one entry in this $1,000 giveaway.</strong> The more donations we receive through <?= $deadline ?>, the more chances we have to win!</p>
<p><strong>This is a great time to <a href="/donate#patrons-circle">join our Patrons Circle</a> with a one-time donation of $100.</strong> Not only will your donation support us directly, but itll give us one more entry in this big giveaway.</p>
<p>Will you show your support for free, beautiful digital literature?</p>
<? if($showDonateButton){ ?><p class="donate-button"><a class="button" href="/donate">Make a one-time donation!</a></p><? } ?>
</aside>

View file

@ -1,11 +1,12 @@
<?
// Hide the alert if the user has closed it
if($autoHide ?? $_COOKIE['hide-donation-alert'] ?? false){
if(!DONATION_DRIVE_ON || ($autoHide ?? $_COOKIE['hide-donation-alert'] ?? false)){
return;
}
$autoHide = $autoHide ?? true;
$showDonateButton = $showDonateButton ?? true;
$current = 0;
$target = 50;
$stretchCurrent = 0;
@ -57,5 +58,5 @@ if($stretchTarget > 0 && $current >= $target){
<p>We want to make Standard Ebooks a sustainable project that can support the huge amount of work it takes to maintain and operate. Welcoming <?= number_format($target) ?> new Patrons Circle members by <?= $deadline ?> will help put us on the stable financial footing we need to continue producing beautiful ebooks as we enter the new year.</p>
<p>Will you help us reach that goal, and support free and unrestricted digital literature?</p>
<? } ?>
<p><a class="button" href="/donate#patrons-circle">Join the patrons circle</a></p>
<? if($showDonateButton){ ?><p class="donate-button"><a class="button" href="/donate#patrons-circle">Join the patrons circle</a></p><? } ?>
</aside>

View file

@ -4,9 +4,8 @@ require_once('Core.php');
<main>
<article>
<h1>About Standard Ebooks</h1>
<? if(DONATION_DRIVE_ON){ ?>
<?= Template::DonationCounter() ?>
<?= Template::DonationProgress() ?>
<? } ?>
<p>Standard Ebooks is a volunteer-driven effort to produce a collection of high quality, carefully formatted, accessible, open source, and free public domain ebooks that meet or exceed the quality of commercially produced ebooks. The text and cover art in our ebooks is already believed to be in the U.S. public domain, and Standard Ebooks dedicates its own work to the public domain, thus releasing the entirety of each ebook file into the public domain. All the ebooks we produce are distributed free of cost and free of U.S. copyright restrictions.</p>
<p>Standard Ebooks is organized as a <a href="https://en.wikipedia.org/wiki/Low-profit_limited_liability_company">low-profit L.L.C.</a>, or “L<sup>3</sup>C, a kind of legal entity that blends the charitable focus of a traditional not-for-profit with the ease of organization and maintenance of a regular L.L.C. Our only source of income is <a href="/donate">donations from readers like you</a>.</p>
<section id="more-information">

View file

@ -4,9 +4,8 @@ require_once('Core.php');
<main>
<article>
<h1>Get Involved</h1>
<? if(DONATION_DRIVE_ON){ ?>
<?= Template::DonationCounter() ?>
<?= Template::DonationProgress() ?>
<? } ?>
<section id="intro">
<h2>Help create ebooks that are a pleasure to read</h2>
<p>Standard Ebooks is a volunteer-driven project, and theres room for people of all skill levels to contribute.</p>

View file

@ -51,6 +51,14 @@
font-display: swap;
}
@font-face{
font-family: "Bebas Neue";
src: url("/fonts/bebas-neue-subset.woff2") format("woff2");
font-weight: normal;
font-style: normal;
font-display: swap;
}
:root{
--light-body-bg: #e9e7e0;
--light-body-text: #222;
@ -2112,6 +2120,63 @@ aside header{
font-style: normal;
}
.donation.counter > p:not(.donate-button){
text-align: justify;
max-width: 80ch;
margin: 1rem auto;
hyphens: auto;
}
.flipboard{
font-style: normal;
font-size: 2rem;
margin: 2rem auto;
line-height: 1;
font-family: "League Spartan";
text-transform: uppercase;
}
.flipboard span{
background: #222;
border: 1px solid #222;
box-shadow: 1px 1px 0px rgba(255,255,255,.5) inset;
border-radius: 5px;
color: #fff;
padding: .25rem 1rem 0 1rem;
line-height: 1;
position: relative;
text-shadow: 2px 2px 0px #000;
width: 1em;
padding: .5em .25em;
display: inline-block;
}
.flipboard span + span{
margin-left: .1em;
}
.flipboard span::before{
position: absolute;
content: "";
top: calc(50% - 5px);
left: 0;
height: 10px;
width: calc(100% - 4px);
border-left: 2px solid #aaa;
border-right: 2px solid #aaa;
}
.flipboard span::after{
position: absolute;
content: "";
top: 50%;
left: 0;
height: 50%;
background: linear-gradient(180deg, rgb(255, 255, 255, .3) 0%, rgba(0,0,0,0) 75%);
width: 100%;
border-top: 1px solid #000;
}
.progress + p{
margin-top: 2rem;
hyphens: auto;
@ -2225,18 +2290,23 @@ progress.stretch::-moz-progress-bar{
}
aside button.close{
display: block;
font-size: 0;
border: none;
box-shadow: none;
padding: 0;
position: absolute;
top: 1rem;
right: 1rem;
top: 0;
right: 0;
background: url('/images/close.svg') transparent;
background-size: cover;
height: 1rem;
width: 1rem;
background-size: 1rem 1rem;
background-position: center;
background-repeat: no-repeat;
height: 3rem;
width: 3rem;
padding: 1rem;
opacity: .75;
margin: 0;
}
aside button.close:hover{
@ -2245,8 +2315,8 @@ aside button.close:hover{
aside button.close:active{
left: auto;
top: calc(1rem + 1px);
right: calc(1rem - 1px);
top: 1px;
right: -1px;
}
@keyframes progress{
@ -2705,6 +2775,14 @@ aside button.close:active{
text-align: justify;
}
aside.donation .flipboard{
text-align: center;
}
aside.donation .flipboard span{
margin-bottom: 1rem;
}
aside.donation p:last-child,
article.ebook section aside.donation p:last-child,
aside.donation header p{
@ -2899,6 +2977,10 @@ aside button.close:active{
main.ebooks > ol{
grid-gap: 2rem;
}
aside.donation .flipboard{
font-size: 1rem;
}
}
@media(max-width: 420px){

View file

@ -84,3 +84,8 @@ h1,h2,h3,h4,h5,h6{
aside button.close{
filter: invert(1);
}
aside.donation .flipboard span{
border-color: rgba(255,255,255,.5);
box-shadow: none;
}

View file

@ -7,9 +7,8 @@ require_once('Core.php');
<h1>Donate to Standard Ebooks</h1>
<h2>and help bring the beauty of literature to the digital age</h2>
</hgroup>
<? if(DONATION_DRIVE_ON){ ?>
<?= Template::DonationProgress(['autoHide' => false]) ?>
<? } ?>
<?= Template::DonationCounter(['autoHide' => false, 'showDonateButton' => false]) ?>
<?= Template::DonationProgress(['autoHide' => false, 'showDonateButton' => false]) ?>
<picture>
<source srcset="/images/the-quiet-hour@2x.avif 2x, /images/the-quiet-hour.avif 1x" type="image/avif"/>
<source srcset="/images/the-quiet-hour@2x.jpg 2x, /images/the-quiet-hour.jpg 1x" type="image/jpg"/>

View file

@ -138,9 +138,9 @@ catch(Exceptions\InvalidEbookException $ex){
<section id="description">
<h2>Description</h2>
<? if(DONATION_DRIVE_ON){ ?>
<?= Template::DonationCounter() ?>
<?= Template::DonationProgress() ?>
<? }elseif(DONATION_ALERT_ON){ ?>
<? if(!DONATION_DRIVE_ON && !DONATION_DRIVE_COUNTER_ON && DONATION_ALERT_ON){ ?>
<?= Template::DonationAlert() ?>
<? } ?>
<? if($ebook->LongDescription === null){ ?>

View file

@ -135,9 +135,9 @@ catch(Exceptions\InvalidCollectionException $ex){
?><?= Template::Header(['title' => $pageTitle, 'highlight' => 'ebooks', 'description' => $pageDescription]) ?>
<main class="ebooks">
<h1><?= $pageHeader ?></h1>
<? if(DONATION_DRIVE_ON){ ?>
<?= Template::DonationCounter() ?>
<?= Template::DonationProgress() ?>
<? }elseif(DONATION_HOLIDAY_ALERT_ON){ ?>
<? if(!DONATION_DRIVE_ON && !DONATION_DRIVE_COUNTER_ON && DONATION_HOLIDAY_ALERT_ON){ ?>
<?= Template::DonationAlert() ?>
<? } ?>
<? if($collection === null){ ?>