Show donation alert 25% of the time on ebook detail pages

This commit is contained in:
Alex Cabal 2021-01-13 16:13:58 -06:00
parent 153de5d450
commit faad55ed1f
5 changed files with 20 additions and 9 deletions

View file

@ -26,6 +26,5 @@ parameters:
- %rootDir%/../../../www
- %rootDir%/../../../scripts
dynamicConstantNames:
- DONATION_HOLIDAY_ALERT_ON
- DONATION_ALERT_ON
- DONATION_ALERT_ALWAYS_ON
- DONATION_ALERT_ON_DURING_HOLIDAYS

View file

@ -36,9 +36,10 @@ const SOURCE_FADED_PAGE = 9;
const AVERAGE_READING_WORDS_PER_MINUTE = 275;
define('PD_YEAR', intval(gmdate('Y')) - 96);
const DONATION_ALERT_ALWAYS_ON = false;
const DONATION_ALERT_ON_DURING_HOLIDAYS = true;
define('DONATION_ALERT_ON', DONATION_ALERT_ALWAYS_ON | (DONATION_ALERT_ON_DURING_HOLIDAYS && (time() > strtotime('December 1, ' . gmdate('Y')) || time() < strtotime('January 7, ' . gmdate('Y')))));
define('DONATION_HOLIDAY_ALERT_ON', time() > strtotime('December 1, ' . gmdate('Y')) || time() < strtotime('January 7, ' . gmdate('Y')));
define('DONATION_ALERT_ON', rand(1, 4) == 2);
// No trailing slash on any of the below constants.
const SITE_URL = 'https://standardebooks.org';
const SITE_ROOT = '/standardebooks.org';

View file

@ -1,4 +1,13 @@
<?
if(!isset($holidays)){
$holidays = false;
}
?>
<aside class="donation">
<? if($holidays){ ?>
<p>We rely on your support to help us keep producing beautiful, free, and unrestricted editions of literature for the digital age.</p>
<p>Will you <a href="/donate">support our efforts with a donation</a> this holiday season?</p>
<p>Will you <a href="/donate">support our efforts with a donation</a>?</p>
<? }else{ ?>
<p>We rely on your support to help us keep producing beautiful, free, and unrestricted editions of literature for the digital age. Will you <a href="/donate">support our efforts with a donation</a>?</p>
<? } ?>
</aside>

View file

@ -133,7 +133,9 @@ catch(\Exception $ex){
<section id="description">
<h2>Description</h2>
<? if(DONATION_ALERT_ON){ ?>
<? if(DONATION_HOLIDAY_ALERT_ON){ ?>
<?= Template::DonationAlert(['holidays' => true]) ?>
<? }elseif(DONATION_ALERT_ON){ ?>
<?= Template::DonationAlert() ?>
<? } ?>
<? if($ebook->LongDescription === null){ ?>

View file

@ -130,8 +130,8 @@ catch(\Exception $ex){
?><?= Template::Header(['title' => $pageTitle, 'highlight' => 'ebooks', 'description' => $pageDescription]) ?>
<main class="ebooks">
<h1><?= $pageHeader ?></h1>
<? if(DONATION_ALERT_ON){ ?>
<?= Template::DonationAlert() ?>
<? if(DONATION_HOLIDAY_ALERT_ON){ ?>
<?= Template::DonationAlert(['holidays' => true]) ?>
<? } ?>
<? if($collection === null){ ?>
<?= Template::SearchForm(['query' => $query, 'tags' => $tags, 'sort' => $sort, 'view' => $view, 'perPage' => $perPage]) ?>