Skip to content

Add settings for number of books/shelves that will be displayed per page #5606

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/App/HomeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function index(
if ($homepageOption === 'bookshelves') {
$shelves = $this->queries->shelves->visibleForListWithCover()
->orderBy($commonData['listOptions']->getSort(), $commonData['listOptions']->getOrder())
->paginate(18);
->paginate(intval(setting('sorting-shelves-per-page', '18')));
$data = array_merge($commonData, ['shelves' => $shelves]);

return view('home.shelves', $data);
Expand All @@ -92,7 +92,7 @@ public function index(
if ($homepageOption === 'books') {
$books = $this->queries->books->visibleForListWithCover()
->orderBy($commonData['listOptions']->getSort(), $commonData['listOptions']->getOrder())
->paginate(18);
->paginate(intval(setting('sorting-books-per-page', '18')));
$data = array_merge($commonData, ['books' => $books]);

return view('home.books', $data);
Expand Down
2 changes: 1 addition & 1 deletion app/Entities/Controllers/BookController.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function index(Request $request)

$books = $this->queries->visibleForListWithCover()
->orderBy($listOptions->getSort(), $listOptions->getOrder())
->paginate(18);
->paginate(intval(setting('sorting-books-per-page', '18')));
$recents = $this->isSignedIn() ? $this->queries->recentlyViewedForCurrentUser()->take(4)->get() : false;
$popular = $this->queries->popularForList()->take(4)->get();
$new = $this->queries->visibleForList()->orderBy('created_at', 'desc')->take(4)->get();
Expand Down
2 changes: 1 addition & 1 deletion app/Entities/Controllers/BookshelfController.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function index(Request $request)

$shelves = $this->queries->visibleForListWithCover()
->orderBy($listOptions->getSort(), $listOptions->getOrder())
->paginate(18);
->paginate(intval(setting('sorting-shelves-per-page', '18')));
$recents = $this->isSignedIn() ? $this->queries->recentlyViewedForCurrentUser()->get() : false;
$popular = $this->queries->popularForList()->get();
$new = $this->queries->visibleForList()
Expand Down
4 changes: 4 additions & 0 deletions lang/en/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@

// Sorting Settings
'sorting' => 'Sorting',
'sorting_shelves_per_page' => 'Shelves Per Page',
'sorting_shelves_per_page_desc' => 'Sets the number of shelves shown per page in shelf listings.',
'sorting_books_per_page' => 'Books Per Page',
'sorting_books_per_page_desc' => 'Sets the number of books shown per page in book listings.',
'sorting_book_default' => 'Default Book Sort',
'sorting_book_default_desc' => 'Select the default sort rule to apply to new books. This won\'t affect existing books, and can be overridden per-book.',
'sorting_rules' => 'Sort Rules',
Expand Down
34 changes: 34 additions & 0 deletions resources/views/settings/categories/sorting.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,40 @@
{{ csrf_field() }}
<input type="hidden" name="section" value="sorting">

<div class="grid half gap-xl items-center">
<div>
<label for="setting-sorting-shelves-per-page"
class="setting-list-label">{{ trans('settings.sorting_shelves_per_page') }}</label>
<p class="small">{{ trans('settings.sorting_shelves_per_page_desc') }}</p>
</div>
<div>
<input type="number"
id="setting-sorting-shelves-per-page"
name="setting-sorting-shelves-per-page"
value="{{ intval(setting('sorting-shelves-per-page', 18)) }}"
min="1"
step="1"
class="@if($errors->has('setting-sorting-shelves-per-page')) neg @endif">
</div>
</div>

<div class="grid half gap-xl items-center">
<div>
<label for="setting-sorting-books-per-page"
class="setting-list-label">{{ trans('settings.sorting_books_per_page') }}</label>
<p class="small">{{ trans('settings.sorting_books_per_page_desc') }}</p>
</div>
<div>
<input type="number"
id="setting-sorting-books-per-page"
name="setting-sorting-books-per-page"
value="{{ intval(setting('sorting-books-per-page', 18)) }}"
min="1"
step="1"
class="@if($errors->has('setting-sorting-books-per-page')) neg @endif">
</div>
</div>

<div class="setting-list">
<div class="grid half gap-xl items-center">
<div>
Expand Down