mirror of
https://github.com/standardebooks/web.git
synced 2025-07-21 06:45:14 -04:00
Add new sorting and filtering options to ebook browse page
This commit is contained in:
parent
27f7862ae9
commit
1010b287a6
13 changed files with 786 additions and 442 deletions
|
@ -3,10 +3,10 @@ if(!isset($ebooks)){
|
|||
$ebooks = [];
|
||||
}
|
||||
?>
|
||||
<ol>
|
||||
<ol<? if($view == VIEW_LIST){ ?> class="list"<? } ?>>
|
||||
<? foreach($ebooks as $ebook){ ?>
|
||||
<li>
|
||||
<a href="<?= $ebook->Url ?>">
|
||||
<a href="<?= $ebook->Url ?>" tabindex="-1">
|
||||
<picture>
|
||||
<? if($ebook->CoverImage2xAvifUrl !== null){ ?><source srcset="<?= $ebook->CoverImage2xAvifUrl ?> 2x, <?= $ebook->CoverImageAvifUrl ?> 1x" type="image/avif"/><? } ?>
|
||||
<source srcset="<?= $ebook->CoverImage2xUrl ?> 2x, <?= $ebook->CoverImageUrl ?> 1x" type="image/jpg"/>
|
||||
|
@ -15,9 +15,16 @@ if(!isset($ebooks)){
|
|||
</a>
|
||||
<p><a href="<?= $ebook->Url ?>"><?= Formatter::ToPlainText($ebook->Title) ?></a></p>
|
||||
<? foreach($ebook->Authors as $author){ ?>
|
||||
<? if($author->Name != 'Anonymous'){ ?>
|
||||
<p class="author"><a href="<?= Formatter::ToPlainText($ebook->AuthorsUrl) ?>"><?= Formatter::ToPlainText($author->Name) ?></a></p>
|
||||
<? } ?>
|
||||
<p class="author"><? if($author->Name != 'Anonymous'){ ?><a href="<?= Formatter::ToPlainText($ebook->AuthorsUrl) ?>"><?= Formatter::ToPlainText($author->Name) ?></a><? } ?></p>
|
||||
<? } ?>
|
||||
<? if($view == VIEW_LIST){ ?>
|
||||
<div class="details">
|
||||
<? if($ebook->ContributorsHtml !== null){ ?>
|
||||
<p><?= rtrim($ebook->ContributorsHtml, '.') ?></p>
|
||||
<? } ?>
|
||||
<p><?= number_format($ebook->WordCount) ?> words • <?= $ebook->ReadingEase ?> reading ease</p>
|
||||
<ul class="tags"><? foreach($ebook->Tags as $tag){ ?><li><a href="<?= $tag->Url ?>"><?= Formatter::ToPlainText($tag->Name) ?></a></li><? } ?></ul>
|
||||
</div>
|
||||
<? } ?>
|
||||
</li>
|
||||
<? } ?>
|
||||
|
|
|
@ -1,3 +1,48 @@
|
|||
<?
|
||||
$allSelected = sizeof($tags) == 0 || in_array('all', $tags);
|
||||
?>
|
||||
<form action="/ebooks" method="get">
|
||||
<label class="search">Search ebooks: <input type="search" name="query" placeholder="Search all ebooks..." value="<?= Formatter::ToPlainText($query ?? '') ?>"/></label>
|
||||
<label class="tags">Subjects <span>(select many with <? if(strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') === false){ ?>ctrl<? }else{ ?>⌘<? } ?>)</span>
|
||||
<select multiple="multiple" name="tags[]">
|
||||
<option value="all">All</option>
|
||||
<? foreach(Library::GetTags() as $tag){
|
||||
$lcTag = mb_strtolower($tag); ?>
|
||||
<option value="<?= $lcTag ?>"<? if(!$allSelected && in_array($lcTag, $tags)){ ?> selected="selected"<? } ?>><?= $tag ?></option>
|
||||
<? } ?>
|
||||
</select>
|
||||
</label>
|
||||
<label class="search">Keywords
|
||||
<input type="search" name="query" value="<?= Formatter::ToPlainText($query ?? '') ?>"/>
|
||||
</label>
|
||||
<label class="select sort">
|
||||
<span>Sort</span>
|
||||
<span>
|
||||
<select name="sort">
|
||||
<option value="<?= SORT_NEWEST ?>"<? if($sort == SORT_NEWEST){ ?> selected="selected"<? } ?>>Release date (newest → oldest)</option>
|
||||
<option value="<?= SORT_AUTHOR_ALPHA ?>"<? if($sort == SORT_AUTHOR_ALPHA){ ?> selected="selected"<? } ?>>Author name (a → z)</option>
|
||||
<option value="<?= SORT_READING_EASE ?>"<? if($sort == SORT_READING_EASE){ ?> selected="selected"<? } ?>>Reading ease (easiest → hardest)</option>
|
||||
<option value="<?= SORT_LENGTH ?>"<? if($sort == SORT_LENGTH){ ?> selected="selected"<? } ?>>Length (shortest → longest)</option>
|
||||
</select>
|
||||
</span>
|
||||
</label>
|
||||
<label class="select view">
|
||||
<span>View</span>
|
||||
<span>
|
||||
<select name="view">
|
||||
<option value="<?= VIEW_GRID ?>"<? if($view == VIEW_GRID){ ?> selected="selected"<? } ?>>Grid</option>
|
||||
<option value="<?= VIEW_LIST ?>"<? if($view == VIEW_LIST){ ?> selected="selected"<? } ?>>List</option>
|
||||
</select>
|
||||
</span>
|
||||
</label>
|
||||
<label class="select per-page">
|
||||
<span>Per page</span>
|
||||
<span>
|
||||
<select name="per-page">
|
||||
<option value="12"<? if($perPage == 12){ ?> selected="selected"<? } ?>>12</option>
|
||||
<option value="24"<? if($perPage == 24){ ?> selected="selected"<? } ?>>24</option>
|
||||
<option value="48"<? if($perPage == 48){ ?> selected="selected"<? } ?>>48</option>
|
||||
</select>
|
||||
</span>
|
||||
</label>
|
||||
<button>Filter</button>
|
||||
</form>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue