Skip to content

Commit 9886bbd

Browse files
committed
Merge branch 'feature/pagination_settings' of github.com:Xenoamor/BookStack into Xenoamor-feature/pagination_settings
2 parents 92a3c22 + b6110ed commit 9886bbd

File tree

5 files changed

+42
-4
lines changed

5 files changed

+42
-4
lines changed

app/App/HomeController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public function index(
8383
if ($homepageOption === 'bookshelves') {
8484
$shelves = $this->queries->shelves->visibleForListWithCover()
8585
->orderBy($commonData['listOptions']->getSort(), $commonData['listOptions']->getOrder())
86-
->paginate(18);
86+
->paginate(intval(setting('sorting-shelves-per-page', '18')));
8787
$data = array_merge($commonData, ['shelves' => $shelves]);
8888

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

9898
return view('home.books', $data);

app/Entities/Controllers/BookController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function index(Request $request)
5252

5353
$books = $this->queries->visibleForListWithCover()
5454
->orderBy($listOptions->getSort(), $listOptions->getOrder())
55-
->paginate(18);
55+
->paginate(intval(setting('sorting-books-per-page', '18')));
5656
$recents = $this->isSignedIn() ? $this->queries->recentlyViewedForCurrentUser()->take(4)->get() : false;
5757
$popular = $this->queries->popularForList()->take(4)->get();
5858
$new = $this->queries->visibleForList()->orderBy('created_at', 'desc')->take(4)->get();

app/Entities/Controllers/BookshelfController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function index(Request $request)
4545

4646
$shelves = $this->queries->visibleForListWithCover()
4747
->orderBy($listOptions->getSort(), $listOptions->getOrder())
48-
->paginate(18);
48+
->paginate(intval(setting('sorting-shelves-per-page', '18')));
4949
$recents = $this->isSignedIn() ? $this->queries->recentlyViewedForCurrentUser()->get() : false;
5050
$popular = $this->queries->popularForList()->get();
5151
$new = $this->queries->visibleForList()

lang/en/settings.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@
7676

7777
// Sorting Settings
7878
'sorting' => 'Sorting',
79+
'sorting_shelves_per_page' => 'Shelves Per Page',
80+
'sorting_shelves_per_page_desc' => 'Sets the number of shelves shown per page in shelf listings.',
81+
'sorting_books_per_page' => 'Books Per Page',
82+
'sorting_books_per_page_desc' => 'Sets the number of books shown per page in book listings.',
7983
'sorting_book_default' => 'Default Book Sort',
8084
'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.',
8185
'sorting_rules' => 'Sort Rules',

resources/views/settings/categories/sorting.blade.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,40 @@
1010
{{ csrf_field() }}
1111
<input type="hidden" name="section" value="sorting">
1212

13+
<div class="grid half gap-xl items-center">
14+
<div>
15+
<label for="setting-sorting-shelves-per-page"
16+
class="setting-list-label">{{ trans('settings.sorting_shelves_per_page') }}</label>
17+
<p class="small">{{ trans('settings.sorting_shelves_per_page_desc') }}</p>
18+
</div>
19+
<div>
20+
<input type="number"
21+
id="setting-sorting-shelves-per-page"
22+
name="setting-sorting-shelves-per-page"
23+
value="{{ intval(setting('sorting-shelves-per-page', 18)) }}"
24+
min="1"
25+
step="1"
26+
class="@if($errors->has('setting-sorting-shelves-per-page')) neg @endif">
27+
</div>
28+
</div>
29+
30+
<div class="grid half gap-xl items-center">
31+
<div>
32+
<label for="setting-sorting-books-per-page"
33+
class="setting-list-label">{{ trans('settings.sorting_books_per_page') }}</label>
34+
<p class="small">{{ trans('settings.sorting_books_per_page_desc') }}</p>
35+
</div>
36+
<div>
37+
<input type="number"
38+
id="setting-sorting-books-per-page"
39+
name="setting-sorting-books-per-page"
40+
value="{{ intval(setting('sorting-books-per-page', 18)) }}"
41+
min="1"
42+
step="1"
43+
class="@if($errors->has('setting-sorting-books-per-page')) neg @endif">
44+
</div>
45+
</div>
46+
1347
<div class="setting-list">
1448
<div class="grid half gap-xl items-center">
1549
<div>

0 commit comments

Comments
 (0)