mirror of
https://github.com/standardebooks/web.git
synced 2025-07-05 06:10:36 -04:00
Add Authors index
This commit is contained in:
parent
0e92b3acc8
commit
93b55d2da2
7 changed files with 37 additions and 11 deletions
|
@ -44,23 +44,27 @@ class Contributor{
|
|||
/**
|
||||
* @return array<Contributor>
|
||||
*/
|
||||
public static function GetAllAuthorNames(): array{
|
||||
public static function GetAllByMarcRole(Enums\MarcRole $marcRole): array{
|
||||
return Db::Query('
|
||||
SELECT DISTINCT Name
|
||||
SELECT
|
||||
*
|
||||
from Contributors
|
||||
where MarcRole = "aut"
|
||||
order by Name asc', [], Contributor::class);
|
||||
where MarcRole = ?
|
||||
and SortName is not null
|
||||
group by SortName
|
||||
order by SortName asc', [$marcRole], Contributor::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<Contributor>
|
||||
* @return array<stdClass>
|
||||
*/
|
||||
public static function GetAllTranslatorNames(): array{
|
||||
public static function GetAllNamesByMarcRole(Enums\MarcRole $marcRole): array{
|
||||
return Db::Query('
|
||||
SELECT DISTINCT Name
|
||||
SELECT
|
||||
distinct Name
|
||||
from Contributors
|
||||
where MarcRole = "trl"
|
||||
order by Name asc', [], Contributor::class);
|
||||
where MarcRole = ?
|
||||
order by Name asc', [$marcRole]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -11,7 +11,7 @@ $showProjectForm ??= true;
|
|||
<label class="icon user">
|
||||
<span>Author</span>
|
||||
<datalist id="author-names">
|
||||
<? foreach(Contributor::GetAllAuthorNames() as $author){ ?>
|
||||
<? foreach(Contributor::GetAllNamesByMarcRole(Enums\MarcRole::Author) as $author){ ?>
|
||||
<option value="<?= Formatter::EscapeHtml($author->Name) ?>"><?= Formatter::EscapeHtml($author->Name) ?></option>
|
||||
<? } ?>
|
||||
</datalist>
|
||||
|
@ -48,7 +48,7 @@ $showProjectForm ??= true;
|
|||
<label class="icon language">
|
||||
<span>Translator</span>
|
||||
<datalist id="translator-names">
|
||||
<? foreach(Contributor::GetAllTranslatorNames() as $translator){ ?>
|
||||
<? foreach(Contributor::GetAllNamesByMarcRole(Enums\MarcRole::Translator) as $translator){ ?>
|
||||
<option value="<?= Formatter::EscapeHtml($translator->Name) ?>"><?= Formatter::EscapeHtml($translator->Name) ?></option>
|
||||
<? } ?>
|
||||
</datalist>
|
||||
|
|
22
www/authors/index.php
Normal file
22
www/authors/index.php
Normal file
|
@ -0,0 +1,22 @@
|
|||
<?
|
||||
$authors = Contributor::GetAllByMarcRole(Enums\MarcRole::Author);
|
||||
|
||||
?><?= Template::Header(title: 'Authors', description: 'Browse all Standard Ebooks authors.') ?>
|
||||
<main>
|
||||
<section class="narrow has-hero">
|
||||
<h1>Authors</h1>
|
||||
<picture data-caption="Leo Tolstoy in His Study. Ilya Repin, 1891">
|
||||
<source srcset="/images/leo-tolstoy-in-his-study@2x.avif 2x, /images/leo-tolstoy-in-his-study.avif 1x" type="image/avif"/>
|
||||
<source srcset="/images/leo-tolstoy-in-his-study@2x.jpg 2x, /images/leo-tolstoy-in-his-study.jpg 1x" type="image/jpg"/>
|
||||
<img src="/images/leo-tolstoy-in-his-study@2x.jpg" alt="Leo Tolstoy sitting at a desk and writing."/>
|
||||
</picture>
|
||||
<ul>
|
||||
<? foreach($authors as $author){ ?>
|
||||
<li>
|
||||
<p><a href="<?= $author->Url ?>"><?= Formatter::EscapeHtml($author->Name) ?></a></p>
|
||||
</li>
|
||||
<? } ?>
|
||||
</ul>
|
||||
</section>
|
||||
</main>
|
||||
<?= Template::Footer() ?>
|
BIN
www/images/leo-tolstoy-in-his-study.avif
Normal file
BIN
www/images/leo-tolstoy-in-his-study.avif
Normal file
Binary file not shown.
After Width: | Height: | Size: 49 KiB |
BIN
www/images/leo-tolstoy-in-his-study.jpg
Normal file
BIN
www/images/leo-tolstoy-in-his-study.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 57 KiB |
BIN
www/images/leo-tolstoy-in-his-study@2x.avif
Normal file
BIN
www/images/leo-tolstoy-in-his-study@2x.avif
Normal file
Binary file not shown.
After Width: | Height: | Size: 117 KiB |
BIN
www/images/leo-tolstoy-in-his-study@2x.jpg
Normal file
BIN
www/images/leo-tolstoy-in-his-study@2x.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 178 KiB |
Loading…
Add table
Add a link
Reference in a new issue