From d590ce74b9fba8972c96728f05f758ca22f371b9 Mon Sep 17 00:00:00 2001 From: Alex Cabal Date: Sun, 5 Jan 2025 13:19:35 -0600 Subject: [PATCH] Don't show download/feed links for an author if all of their books are placeholders --- www/authors/get.php | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/www/authors/get.php b/www/authors/get.php index e15de7ba..4e3d2320 100644 --- a/www/authors/get.php +++ b/www/authors/get.php @@ -2,6 +2,7 @@ $ebooks = []; $author = ''; $authorUrl = ''; +$showLinks = false; try{ $urlPath = trim(str_replace('.', '', HttpInput::Str(GET, 'url-path') ?? ''), '/'); // Contains the portion of the URL (without query string) that comes after `https://standardebooks.org/ebooks/`. @@ -16,6 +17,14 @@ try{ throw new Exceptions\AuthorNotFoundException(); } + // If all of the author's ebooks are placeholders, don't show download/feed links. + foreach($ebooks as $ebook){ + if(!$ebook->IsPlaceholder()){ + $showLinks = true; + break; + } + } + $author = strip_tags($ebooks[0]->AuthorsHtml); $authorUrl = $ebooks[0]->AuthorsUrl; } @@ -25,10 +34,12 @@ catch(Exceptions\AuthorNotFoundException){ ?> 'Ebooks by ' . $author, 'feedUrl' => str_replace('/ebooks/', '/authors/', $authorUrl), 'feedTitle' => 'Standard Ebooks - Ebooks by ' . $author, 'highlight' => 'ebooks', 'description' => 'All of the Standard Ebooks ebooks by ' . $author, 'canonicalUrl' => SITE_URL . $authorUrl]) ?>

Ebooks by AuthorsHtml ?>

-

- Download collection - Feeds for this author -

+ +

+ Download collection + Feeds for this author +

+ $ebooks, 'view' => Enums\ViewType::Grid]) ?>

We also have bulk ebook downloads and a list of collections available, as well as ebook catalog feeds for use directly in your ereader app or RSS reader.