Move items out of the 'patrons-circle' folder into the root

This commit is contained in:
Alex Cabal 2022-07-09 19:39:29 -05:00
parent 12b79b5dcd
commit 76a4c34688
17 changed files with 95 additions and 39 deletions

4
.gitignore vendored
View file

@ -14,5 +14,5 @@ composer.lock
www/manual/*
!www/manual/index.php
config/php/fpm/standardebooks.org-secrets.ini
www/patrons-circle/downloads/months
www/patrons-circle/downloads/subjects
www/bulk-downloads/months
www/bulk-downloads/subjects

View file

@ -259,15 +259,15 @@ Define webroot /standardebooks.org/web
RewriteRule ^/newsletter/subscriptions/([^/\.]+?)/(confirm|delete)$ /newsletter/subscriptions/$2.php?uuid=$1 [L]
# Polls
RewriteRule ^/patrons-circle/polls/([^/\.]+)$ /patrons-circle/polls/get.php?pollurlname=$1 [L]
RewriteRule ^/patrons-circle/polls/([^/\.]+)/votes/new$ /patrons-circle/polls/votes/new.php?pollurlname=$1 [L]
RewriteRule ^/patrons-circle/polls/([^/\.]+)/votes/([0-9]+)$ /patrons-circle/polls/votes/get.php?pollurlname=$1&userid=$2 [L]
RewriteRule ^/polls/([^/\.]+)$ /polls/get.php?pollurlname=$1 [L]
RewriteRule ^/polls/([^/\.]+)/votes/new$ /polls/votes/new.php?pollurlname=$1 [L]
RewriteRule ^/polls/([^/\.]+)/votes/([0-9]+)$ /polls/votes/get.php?pollurlname=$1&userid=$2 [L]
RewriteCond expr "tolower(%{REQUEST_METHOD}) =~ /^get$/"
RewriteRule ^/patrons-circle/polls/([^/\.]+)/votes$ /patrons-circle/polls/votes/index.php?pollurlname=$1 [L]
RewriteRule ^/polls/([^/\.]+)/votes$ /polls/votes/index.php?pollurlname=$1 [L]
RewriteCond expr "tolower(%{REQUEST_METHOD}) =~ /^post$/"
RewriteRule ^/patrons-circle/polls/([^/\.]+)/votes$ /patrons-circle/polls/votes/post.php?pollurlname=$1 [L]
RewriteRule ^/polls/([^/\.]+)/votes$ /polls/votes/post.php?pollurlname=$1 [L]
# Feeds
# Rewrite old links to feeds
@ -281,9 +281,10 @@ Define webroot /standardebooks.org/web
DBDriver mysql
DBDParams "dbname=se user=www-data"
# HTTP Basic Auth configuration for:
# /patrons-circle/downloads
# /bulk-downloads
# /feeds
<DirectoryMatch "^${webroot}/www/(patrons-circle|feeds/(opds|rss|atom))">
# /polls/votes (we will allow access to view results at /polls/votes/index.php further down)
<DirectoryMatch "^${webroot}/www/(polls/votes|bulk-downloads|feeds/(opds|rss|atom))">
AuthType Basic
AuthName "Enter your Patrons Circle email address and leave the password empty."
Require valid-user
@ -307,15 +308,23 @@ Define webroot /standardebooks.org/web
"
</DirectoryMatch>
# Specific config for /patrons-circle/downloads
<DirectoryMatch "^${webroot}/www/patrons-circle/downloads">
# Specific config for /bulk-downloads
<DirectoryMatch "^${webroot}/www/bulk-downloads">
<FilesMatch "\.php$">
# Disable HTTP Basic auth for the index and 401 pages
Require all granted
</FilesMatch>
<FilesMatch "\.zip$">
ErrorDocument 401 /patrons-circle/downloads
ErrorDocument 401 /bulk-downloads
</FilesMatch>
</DirectoryMatch>
# Specific config for /polls/votes
<DirectoryMatch "^${webroot}/www/polls/votes">
<FilesMatch "index.php$">
# Disable HTTP Basic auth for the index page
Require all granted
</FilesMatch>
</DirectoryMatch>

View file

@ -241,15 +241,15 @@ Define webroot /standardebooks.org/web
RewriteRule ^/newsletter/subscriptions/([^/\.]+?)/(confirm|delete)$ /newsletter/subscriptions/$2.php?uuid=$1 [L]
# Polls
RewriteRule ^/patrons-circle/polls/([^/\.]+)$ /patrons-circle/polls/get.php?pollurlname=$1 [L]
RewriteRule ^/patrons-circle/polls/([^/\.]+)/votes/new$ /patrons-circle/polls/votes/new.php?pollurlname=$1 [L]
RewriteRule ^/patrons-circle/polls/([^/\.]+)/votes/([0-9]+)$ /patrons-circle/polls/votes/get.php?pollurlname=$1&userid=$2 [L]
RewriteRule ^/polls/([^/\.]+)$ /polls/get.php?pollurlname=$1 [L]
RewriteRule ^/polls/([^/\.]+)/votes/new$ /polls/votes/new.php?pollurlname=$1 [L]
RewriteRule ^/polls/([^/\.]+)/votes/([0-9]+)$ /polls/votes/get.php?pollurlname=$1&userid=$2 [L]
RewriteCond expr "tolower(%{REQUEST_METHOD}) =~ /^get$/"
RewriteRule ^/patrons-circle/polls/([^/\.]+)/votes$ /patrons-circle/polls/votes/index.php?pollurlname=$1 [L]
RewriteRule ^/polls/([^/\.]+)/votes$ /polls/votes/index.php?pollurlname=$1 [L]
RewriteCond expr "tolower(%{REQUEST_METHOD}) =~ /^post$/"
RewriteRule ^/patrons-circle/polls/([^/\.]+)/votes$ /patrons-circle/polls/votes/post.php?pollurlname=$1 [L]
RewriteRule ^/polls/([^/\.]+)/votes$ /polls/votes/post.php?pollurlname=$1 [L]
# Feeds
# Rewrite old links to feeds
@ -263,9 +263,10 @@ Define webroot /standardebooks.org/web
DBDriver mysql
DBDParams "dbname=se user=www-data"
# HTTP Basic Auth configuration for:
# /patrons-circle/downloads
# /bulk-downloads
# /feeds
<DirectoryMatch "^${webroot}/www/(patrons-circle|feeds/(opds|rss|atom))">
# /polls/votes (we will allow access to view results at /polls/votes/index.php further down)
<DirectoryMatch "^${webroot}/www/(polls/votes|bulk-downloads|feeds/(opds|rss|atom))">
AuthType Basic
AuthName "Enter your Patrons Circle email address and leave the password empty."
Require valid-user
@ -289,15 +290,23 @@ Define webroot /standardebooks.org/web
"
</DirectoryMatch>
# Specific config for /patrons-circle/downloads
<DirectoryMatch "^${webroot}/www/patrons-circle/downloads">
# Specific config for /bulk-downloads
<DirectoryMatch "^${webroot}/www/bulk-downloads">
<FilesMatch "\.php$">
# Disable HTTP Basic auth for the index and 401 pages
Require all granted
</FilesMatch>
<FilesMatch "\.zip$">
ErrorDocument 401 /patrons-circle/downloads
ErrorDocument 401 /bulk-downloads
</FilesMatch>
</DirectoryMatch>
# Specific config for /polls/votes
<DirectoryMatch "^${webroot}/www/polls/votes">
<FilesMatch "index.php$">
# Disable HTTP Basic auth for the index page
Require all granted
</FilesMatch>
</DirectoryMatch>

View file

@ -28,7 +28,7 @@ class Poll extends PropertiesBase{
protected function GetUrl(): string{
if($this->_Url === null){
$this->_Url = '/patrons-circle/polls/' . $this->UrlName;
$this->_Url = '/polls/' . $this->UrlName;
}
return $this->_Url;

View file

@ -119,7 +119,7 @@ $types = ['epub', 'epub-advanced', 'azw3', 'kepub', 'xhtml'];
foreach($ebooksByMonth as $month => $ebooks){
foreach($types as $type){
$filename = 'se-ebooks-' . $month . '-' . $type . '.zip';
$filePath = $webRoot . '/patrons-circle/downloads/months/' . $month . '/' . $filename;
$filePath = $webRoot . '/bulk-downloads/months/' . $month . '/' . $filename;
// If the file doesn't exist, or if the content.opf last updated time is newer than the file modification time
if(!file_exists($filePath) || filemtime($filePath) < $lastUpdatedTimestampsByMonth[$month]){
@ -134,7 +134,7 @@ foreach($ebooksBySubject as $subject => $ebooks){
foreach($types as $type){
$urlSafeSubject = Formatter::MakeUrlSafe($subject);
$filename = 'se-ebooks-' . $urlSafeSubject . '-' . $type . '.zip';
$filePath = $webRoot . '/patrons-circle/downloads/subjects/' . $urlSafeSubject . '/'. $filename;
$filePath = $webRoot . '/bulk-downloads/subjects/' . $urlSafeSubject . '/'. $filename;
// If the file doesn't exist, or if the content.opf last updated time is newer than the file modification time
if(!file_exists($filePath) || filemtime($filePath) < $lastUpdatedTimestampsBySubject[$subject]){

View file

@ -7,7 +7,7 @@
<li><p>Join the <a href="/donate#patrons-circle">Patrons Circle</a> by making a donation to get access to all of our ebook feeds for the duration of your gift.</p></li>
<li><p><a href="/contribute">Produce an ebook</a> for Standard Ebooks to get lifetime access to our ebook feeds. If youve already done that, <a href="/about#editor-in-chief">contact us</a> to enable your access.</p></li>
</ul>
<p>To access a feed, when prompted enter the email address you used to make your donation or on the S.E. mailing list, and leave the password field blank.</p>
<p>To access a feed, when prompted enter your email address and leave the password field blank.</p>
</section>
<section id="organizations-and-projects">
<h3>Organizations and projects</h3>

View file

@ -20,7 +20,7 @@
<a href="https://github.com/standardebooks">GitHub</a>
</li>
<li>
<a href="/patrons-circle/downloads">Bulk downloads</a>
<a href="/bulk-downloads">Bulk downloads</a>
</li>
<li>
<a href="/feeds">Ebook Feeds</a>

View file

@ -29,7 +29,7 @@ try{
catch(Safe\Exceptions\ApcuException $ex){
// Nothing in the cache, generate the files
$files = glob(WEB_ROOT . '/patrons-circle/downloads/months/*/*.zip');
$files = glob(WEB_ROOT . '/bulk-downloads/months/*/*.zip');
rsort($files);
foreach($files as $file){
@ -49,7 +49,7 @@ catch(Safe\Exceptions\ApcuException $ex){
}
$obj->Month = $date->format('Y-m');
$obj->Url = '/patrons-circle/downloads/months/' . $obj->Month . '/' . basename($file);
$obj->Url = '/bulk-downloads/months/' . $obj->Month . '/' . basename($file);
$obj->Size = Formatter::ToFileSize(filesize($file));
// The count of ebooks in each file is stored as a filesystem attribute
@ -98,12 +98,12 @@ try{
}
catch(Safe\Exceptions\ApcuException $ex){
// Nothing in the cache, generate the files
$files = glob(WEB_ROOT . '/patrons-circle/downloads/subjects/*/*.zip');
$files = glob(WEB_ROOT . '/bulk-downloads/subjects/*/*.zip');
sort($files);
foreach($files as $file){
$obj = new stdClass();
$obj->Url = '/patrons-circle/downloads/' . basename($file);
$obj->Url = '/bulk-downloads/' . basename($file);
$obj->Size = Formatter::ToFileSize(filesize($file));
$obj->Updated = new DateTime('@' . filemtime($file));
@ -160,7 +160,7 @@ catch(Safe\Exceptions\ApcuException $ex){
<? } ?>
<p><a href="/about#patrons-circle">Patrons circle members</a> can download zip files containing all of the ebooks that were released in a given month of Standard Ebooks history. You can <a href="/donate#patrons-circle">join the Patrons Circle</a> with a small donation in support of our continuing mission to create free, beautiful digital literature.</p>
<p>These zip files contain each ebook in every format we offer, and are updated once daily with the latest versions of each ebook.</p>
<p>If youre a Patrons Circle member, when prompted enter your email address and leave the password blank to download these files.</p>
<p>If youre a Patrons Circle member, when prompted enter your email address and leave the password field blank to download these files.</p>
<section id="downloads-by-subject">
<h2>Downloads by subject</h2>

View file

@ -47,7 +47,7 @@ require_once('Core.php');
</ul>
</li>
<li>
<p>Access to <a href="/patrons-circle/downloads">bulk ebook downloads</a> to easily download entire months worth of ebooks at once.</p>
<p>Access to <a href="/bulk-downloads">bulk ebook downloads</a> to easily download entire months worth of ebooks at once.</p>
</li>
<li>
<p>The ability to submit a book for inclusion on our <a href="/contribute/wanted-ebooks">Wanted Ebooks list</a>, once per quarter. (Submissions must conform to our <a href="/contribute/collections-policy">collections policy</a> and are subject to approval.)</p>
@ -146,7 +146,7 @@ require_once('Core.php');
<p>Get access to our OPDS, Atom, and RSS <a href="/feeds">ebook feeds</a> for use by your organization for the duration of your sponsorship. We can also produce different kinds of feeds to meet your needs, like <abbr class="acronym">ONIX</abbr> feeds.</p>
</li>
<li>
<p>Get access to <a href="/patrons-circle/downloads">bulk ebook downloads</a> to easily download large categories of ebooks, all at once.</p>
<p>Get access to <a href="/bulk-downloads">bulk ebook downloads</a> to easily download large categories of ebooks, all at once.</p>
</li>
</ul>
<p>To inquire about sponsorship options, contact the <a href="/about#editor-in-chief">Standard Ebooks Editor-in-Chief</a>.</p>

View file

@ -151,7 +151,7 @@ catch(Exceptions\InvalidCollectionException $ex){
<a<? if($page < ceil($totalEbooks / $perPage)){ ?> href="/ebooks/?page=<?= $page + 1 ?><? if($queryString != ''){ ?>&amp;<?= $queryString ?><? } ?>" rel="next"<? }else{ ?> aria-disabled="true"<? } ?>>Next</a>
</nav>
<? } ?>
<p class="feeds-alert">We also have <a href="/patrons-circle/downloads">bulk ebook downloads</a> available, as well as <a href="/feeds">ebook catalog feeds</a> for use directly in your ereader app or RSS reader.</p>
<p class="feeds-alert">We also have <a href="/bulk-downloads">bulk ebook downloads</a> available, as well as <a href="/feeds">ebook catalog feeds</a> for use directly in your ereader app or RSS reader.</p>
<? if(sizeof($ebooks) > 0 && $query == '' && sizeof($tags) == 0 && $collection === null && $page == 1){ ?>
<?= Template::ContributeAlert() ?>
<? } ?>

View file

@ -1,3 +0,0 @@
<?
header('Location: /donate#patrons-circle');
exit();

View file

@ -21,6 +21,7 @@ catch(Exceptions\SeException $ex){
<? if($poll->End !== null){ ?>
<p class="center-notice">This poll closes on <?= $poll->End->format('F j, Y g:i A') ?>.</p>
<? } ?>
<p><i>If youre a Patrons Circle member, when prompted enter your email address and leave the password field blank to vote.</i></p>
<p class="button-row narrow">
<a href="<?= $poll->Url ?>/votes/new" class="button">Vote now</a>
<a href="<?= $poll->Url ?>/votes" class="button">View results</a>

40
www/polls/index.php Normal file
View file

@ -0,0 +1,40 @@
<?
require_once('Core.php');
$pastPolls = Db::Query('select * from Polls where utc_timestamp() >= End order by Created desc', [], 'Poll');
$openPolls = Db::Query('select * from Polls where (End is null or utc_timestamp() <= End) and (Start is null or Start <= utc_timestamp()) order by Created desc', [], 'Poll');
?><?= Template::Header(['title' => 'Polls', 'highlight' => '', 'description' => 'The various polls active at Standard Ebooks.']) ?>
<main>
<section class="narrow">
<h1>Polls</h1>
<p>Periodically members of the <a href="/about#patrons-circle">Standard Ebooks Patrons Circle</a> vote on the next ebook from the <a href="/contribute/wanted-ebooks">Wanted Ebook List</a> to enter immediate production.</p>
<p>Anyone can <a href="/donate#patrons-circle">join the Patrons Circle</a> by making a small donation in support of our mission of producing beautiful digital literature, for free distribution.</p>
<? if(sizeof($openPolls) > 0){ ?>
<section id="open-polls">
<h2>Open polls</h2>
<ul>
<? foreach($openPolls as $poll){ ?>
<li>
<p><a href="<?= $poll->Url ?>"><?= Formatter::ToPlainText($poll->Name) ?></a></p>
</li>
<? } ?>
</ul>
</section>
<? } ?>
<? if(sizeof($pastPolls) > 0){ ?>
<section id="ended-polls">
<h2>Past polls</h2>
<ul>
<? foreach($pastPolls as $poll){ ?>
<li>
<p><a href="<?= $poll->Url ?>"><?= Formatter::ToPlainText($poll->Name) ?></a></p>
</li>
<? } ?>
</ul>
</section>
<? } ?>
</section>
</main>
<?= Template::Footer() ?>

View file

@ -43,7 +43,7 @@ catch(Exceptions\SeException $ex){
// Access via form; 303 redirect to the form, which will emit a 400 BAD REQUEST
http_response_code(303);
header('Location: /patrons-circle/polls/' . HttpInput::Str(GET, 'pollurlname', false) . '/votes/new');
header('Location: /polls/' . HttpInput::Str(GET, 'pollurlname', false) . '/votes/new');
}
else{
// Access via REST api; 400 BAD REQUEST