diff --git a/app/App/HomeController.php b/app/App/HomeController.php index 0585e0af5cc..00e2db3df43 100644 --- a/app/App/HomeController.php +++ b/app/App/HomeController.php @@ -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(setting()->getInteger('lists-page-count-shelves', 18, 1, 1000)); $data = array_merge($commonData, ['shelves' => $shelves]); return view('home.shelves', $data); @@ -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(setting()->getInteger('lists-page-count-books', 18, 1, 1000)); $data = array_merge($commonData, ['books' => $books]); return view('home.books', $data); diff --git a/app/Entities/Controllers/BookController.php b/app/Entities/Controllers/BookController.php index 0610c2ef5ea..c94057fa99b 100644 --- a/app/Entities/Controllers/BookController.php +++ b/app/Entities/Controllers/BookController.php @@ -52,7 +52,7 @@ public function index(Request $request) $books = $this->queries->visibleForListWithCover() ->orderBy($listOptions->getSort(), $listOptions->getOrder()) - ->paginate(18); + ->paginate(setting()->getInteger('lists-page-count-books', 18, 1, 1000)); $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(); diff --git a/app/Entities/Controllers/BookshelfController.php b/app/Entities/Controllers/BookshelfController.php index c4b861c9010..f5f4a90bfe9 100644 --- a/app/Entities/Controllers/BookshelfController.php +++ b/app/Entities/Controllers/BookshelfController.php @@ -45,7 +45,7 @@ public function index(Request $request) $shelves = $this->queries->visibleForListWithCover() ->orderBy($listOptions->getSort(), $listOptions->getOrder()) - ->paginate(18); + ->paginate(setting()->getInteger('lists-page-count-shelves', 18, 1, 1000)); $recents = $this->isSignedIn() ? $this->queries->recentlyViewedForCurrentUser()->get() : false; $popular = $this->queries->popularForList()->get(); $new = $this->queries->visibleForList() diff --git a/app/Search/SearchController.php b/app/Search/SearchController.php index 9586beffba2..2b9ea79740f 100644 --- a/app/Search/SearchController.php +++ b/app/Search/SearchController.php @@ -25,10 +25,11 @@ public function search(Request $request, SearchResultsFormatter $formatter) $searchOpts = SearchOptions::fromRequest($request); $fullSearchString = $searchOpts->toString(); $page = intval($request->get('page', '0')) ?: 1; + $count = setting()->getInteger('lists-page-count-search', 18, 1, 1000); - $results = $this->searchRunner->searchEntities($searchOpts, 'all', $page, 20); + $results = $this->searchRunner->searchEntities($searchOpts, 'all', $page, $count); $formatter->format($results['results']->all(), $searchOpts); - $paginator = new LengthAwarePaginator($results['results'], $results['total'], 20, $page); + $paginator = new LengthAwarePaginator($results['results'], $results['total'], $count, $page); $paginator->setPath('/search'); $paginator->appends($request->except('page')); diff --git a/app/Settings/AppSettingsStore.php b/app/Settings/AppSettingsStore.php index e6fc466baa2..e098d87f8e4 100644 --- a/app/Settings/AppSettingsStore.php +++ b/app/Settings/AppSettingsStore.php @@ -14,7 +14,7 @@ public function __construct( ) { } - public function storeFromUpdateRequest(Request $request, string $category) + public function storeFromUpdateRequest(Request $request, string $category): void { $this->storeSimpleSettings($request); if ($category === 'customization') { @@ -76,7 +76,7 @@ protected function updateAppLogo(Request $request): void protected function storeSimpleSettings(Request $request): void { foreach ($request->all() as $name => $value) { - if (strpos($name, 'setting-') !== 0) { + if (!str_starts_with($name, 'setting-')) { continue; } @@ -85,7 +85,7 @@ protected function storeSimpleSettings(Request $request): void } } - protected function destroyExistingSettingImage(string $settingKey) + protected function destroyExistingSettingImage(string $settingKey): void { $existingVal = setting()->get($settingKey); if ($existingVal) { diff --git a/app/Settings/SettingService.php b/app/Settings/SettingService.php index 31debdaea85..e0b13618012 100644 --- a/app/Settings/SettingService.php +++ b/app/Settings/SettingService.php @@ -28,6 +28,21 @@ public function get(string $key, $default = null): mixed return $this->formatValue($value, $default); } + /** + * Get a setting from the database as an integer. + * Returns the default value if not found or not an integer, and clamps the value to the given min/max range. + */ + public function getInteger(string $key, int $default, int $min = 0, int $max = PHP_INT_MAX): int + { + $value = $this->get($key, $default); + if (!is_numeric($value)) { + return $default; + } + + $int = intval($value); + return max($min, min($max, $int)); + } + /** * Get a value from the session instead of the main store option. */ diff --git a/lang/en/settings.php b/lang/en/settings.php index 81c2c0a93c3..1b5f9ce144c 100644 --- a/lang/en/settings.php +++ b/lang/en/settings.php @@ -75,8 +75,8 @@ 'reg_confirm_restrict_domain_placeholder' => 'No restriction set', // Sorting Settings - 'sorting' => 'Sorting', - 'sorting_book_default' => 'Default Book Sort', + 'sorting' => 'Lists & Sorting', + 'sorting_book_default' => 'Default Book Sort Rule', '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', 'sorting_rules_desc' => 'These are predefined sorting operations which can be applied to content in the system.', @@ -103,6 +103,8 @@ 'sort_rule_op_updated_date' => 'Updated Date', 'sort_rule_op_chapters_first' => 'Chapters First', 'sort_rule_op_chapters_last' => 'Chapters Last', + 'sorting_page_limits' => 'Per-Page Display Limits', + 'sorting_page_limits_desc' => 'Set how many items to show per-page in various lists within the system. Typically a lower amount will be more performant, while a higher amount avoids the need to click through multiple pages. Using an even multiple of 3 (18, 24, 30, etc...) is recommended.', // Maintenance settings 'maint' => 'Maintenance', diff --git a/resources/sass/_forms.scss b/resources/sass/_forms.scss index 12fb3385f96..13a4232fc7e 100644 --- a/resources/sass/_forms.scss +++ b/resources/sass/_forms.scss @@ -348,6 +348,10 @@ input[type=color] { } } +.small-inputs input { + width: 150px; +} + .simple-code-input { background-color: #F8F8F8; font-family: monospace; diff --git a/resources/views/form/number.blade.php b/resources/views/form/number.blade.php index a37cd36941c..b70b7e8db3c 100644 --- a/resources/views/form/number.blade.php +++ b/resources/views/form/number.blade.php @@ -6,7 +6,8 @@ @if($readonly ?? false) readonly="readonly" @endif @if($min ?? false) min="{{ $min }}" @endif @if($max ?? false) max="{{ $max }}" @endif - @if(isset($model) || old($name)) value="{{ old($name) ? old($name) : $model->$name}}" @endif> + @if($step ?? false) step="{{ $step }}" @endif + @if(isset($model) || old($name) || isset($value)) value="{{ old($name) ?? $model->$name ?? $value }}" @endif> @if($errors->has($name))
{{ $errors->first($name) }}
@endif diff --git a/resources/views/settings/categories/sorting.blade.php b/resources/views/settings/categories/sorting.blade.php index 9d1d9814b96..0c9dc1f9595 100644 --- a/resources/views/settings/categories/sorting.blade.php +++ b/resources/views/settings/categories/sorting.blade.php @@ -11,6 +11,29 @@
+
+
+ +

{{ trans('settings.sorting_page_limits_desc') }}

+
+
+ @php + $labelByKey = ['shelves' => trans('entities.shelves'), 'books' => trans('entities.books'), 'search' => trans('entities.search_results')]; + @endphp + @foreach($labelByKey as $key => $label) +
+ + @include('form.number', [ + 'name' => 'setting-lists-page-count-' . $key, + 'value' => setting()->getInteger('lists-page-count-' . $key, 18, 1, 1000), + 'min' => 1, + 'step' => 1, + ]) +
+ @endforeach +
+
+