Add cover, list and show thumbs views to cover pages

This commit is contained in:
DariusIII
2026-01-15 22:09:58 +01:00
parent f45e72949b
commit 1cf7d16fbf
9 changed files with 237 additions and 45 deletions
+31 -13
View File
@@ -84,21 +84,39 @@ class BrowseController extends BasePageController
$catname = 'All';
} elseif ($category !== -1 && $grp === -1) {
$catname = $id;
// Determine the root category ID - either from the category's root_categories_id
// or the category itself if it IS a root category
$rootCategoryId = null;
$cdata = Category::find($category);
if ($cdata !== null) {
if ($cdata->root_categories_id === Category::GAME_ROOT) {
$covgroup = 'console';
} elseif ($cdata->root_categories_id === Category::MOVIE_ROOT) {
$covgroup = 'movies';
} elseif ($cdata->root_categories_id === Category::PC_ROOT) {
$covgroup = 'games';
} elseif ($cdata->root_categories_id === Category::MUSIC_ROOT) {
$covgroup = 'music';
} elseif ($cdata->root_categories_id === Category::BOOKS_ROOT) {
$covgroup = 'books';
} elseif ($cdata->root_categories_id === Category::TV_ROOT) {
$shows = true;
}
$rootCategoryId = $cdata->root_categories_id ?? $category;
} else {
// Category not found in categories table, might be a root category
// Check if it matches a known root category ID
$rootCategoryId = $category;
}
// Also check RootCategory table for parent categories (when $id is 'All')
if ($id === 'All' && $parentId !== null) {
$rootCategoryId = $parentId;
}
// Set covgroup based on root category
if ($rootCategoryId === Category::GAME_ROOT) {
$covgroup = 'console';
} elseif ($rootCategoryId === Category::MOVIE_ROOT) {
$covgroup = 'movies';
} elseif ($rootCategoryId === Category::PC_ROOT) {
$covgroup = 'games';
} elseif ($rootCategoryId === Category::MUSIC_ROOT) {
$covgroup = 'music';
} elseif ($rootCategoryId === Category::BOOKS_ROOT) {
$covgroup = 'books';
} elseif ($rootCategoryId === Category::XXX_ROOT) {
$covgroup = 'xxx';
} elseif ($rootCategoryId === Category::TV_ROOT) {
$shows = true;
}
} else {
$catname = $grp;
+14 -5
View File
@@ -74,11 +74,20 @@
<!-- Results -->
@if(count($results) > 0)
<div class="mb-4 flex justify-between items-center">
<h2 class="text-xl font-semibold text-gray-800">
<i class="fa fa-book mr-2 text-blue-600"></i>
{{ $catname ?? 'All' }} Books
</h2>
<span class="text-sm text-gray-600">
<div class="flex items-center gap-4">
<h2 class="text-xl font-semibold text-gray-800 dark:text-gray-200">
<i class="fa fa-book mr-2 text-blue-600"></i>
{{ $catname ?? 'All' }} Books
</h2>
<x-view-toggle
current-view="covers"
covgroup="books"
:category="$categorytitle ?? 'All'"
parentcat="Books"
:shows="false"
/>
</div>
<span class="text-sm text-gray-600 dark:text-gray-400">
{{ $results->total() }} results found
</span>
</div>
+17 -9
View File
@@ -56,13 +56,14 @@
</div>
@endif
@if(isset($covgroup) && $covgroup != '')
<div class="flex items-center gap-2 text-sm">
<span class="text-gray-600 dark:text-gray-400 dark:text-gray-400">View:</span>
<a href="{{ url('/' . $covgroup . '/' . $category) }}" class="text-blue-600 dark:text-blue-400 dark:text-blue-400 hover:text-blue-800 dark:hover:text-blue-300 dark:hover:text-blue-300">Covers</a>
<span class="text-gray-400 dark:text-gray-500">|</span>
<span class="font-semibold text-gray-800 dark:text-gray-200 dark:text-gray-200">List</span>
</div>
@if(isset($covgroup) && $covgroup != '' || isset($shows) && $shows)
<x-view-toggle
current-view="list"
:covgroup="$covgroup ?? null"
:category="$category ?? null"
:parentcat="$parentcat ?? null"
:shows="$shows ?? false"
/>
@endif
<div class="flex flex-wrap items-center gap-2">
@@ -136,8 +137,15 @@
</td>
<td class="px-3 py-4">
<div class="flex items-start">
@if($result->cover ?? false)
<img src="{{ $result->cover }}" class="w-12 h-16 object-cover rounded mr-3" alt="Cover">
@php
$showThumbnails = request()->query('thumbs', '0') === '1';
$coverUrl = ($result->cover ?? false) ? $result->cover : ($showThumbnails ? getReleaseCover($result) : null);
$hasValidCover = $coverUrl && !str_contains($coverUrl, 'no-cover.png');
@endphp
@if($hasValidCover)
<a href="{{ url('/details/' . $result->guid) }}" class="flex-shrink-0">
<img src="{{ $coverUrl }}" class="w-12 h-16 object-cover rounded mr-3 shadow-sm hover:shadow-md transition" alt="Cover" loading="lazy">
</a>
@endif
<div class="flex-1">
<div class="flex items-center gap-2 flex-wrap">
@@ -0,0 +1,118 @@
@props([
'currentView' => 'list',
'covgroup' => null,
'category' => null,
'parentcat' => null,
'shows' => false
])
@php
// Build URLs for toggling views while preserving current query parameters
$currentParams = request()->query();
// Map covgroup to correct cover view route
$coverRouteMap = [
'movies' => 'Movies',
'console' => 'Console',
'games' => 'Games',
'music' => 'Music',
'books' => 'Books',
'xxx' => 'XXX',
];
// Map covgroup to correct list browse parent category
$listParentMap = [
'movies' => 'Movies',
'console' => 'Console',
'games' => 'PC',
'music' => 'Audio',
'books' => 'Books',
'xxx' => 'XXX',
];
// Parent category IDs - these should not be appended to URLs
$parentCategoryIds = [
1000, // Console/Game
2000, // Movies
3000, // Audio/Music
4000, // PC
5000, // TV
6000, // XXX
7000, // Books
8000, // Other
];
// Check if category is a parent category ID (should not be in URL path)
$isParentCategory = is_numeric($category) && in_array((int)$category, $parentCategoryIds);
// Build cover view URL
if ($covgroup && isset($coverRouteMap[$covgroup])) {
$coverRoute = $coverRouteMap[$covgroup];
// Only append category if it's not a parent category ID and not 'All' or -1
$catParam = ($category && $category !== -1 && $category !== 'All' && !$isParentCategory) ? $category : '';
$coverUrl = url('/' . $coverRoute . ($catParam ? '/' . $catParam : ''));
} elseif ($shows) {
$coverUrl = route('series');
} else {
$coverUrl = '#';
}
// Build list view URL - preserve query params except view and thumbs for clean URL
$listParams = $currentParams;
unset($listParams['view']);
// Determine the correct parent category for list view
$listParent = $parentcat;
if ($covgroup && isset($listParentMap[$covgroup])) {
$listParent = $listParentMap[$covgroup];
}
// Only append category to list URL if it's not a parent category ID
if ($listParent && $category && $category !== -1 && $category !== 'All' && !$isParentCategory) {
$listUrl = url('/browse/' . $listParent . '/' . $category);
} elseif ($listParent) {
$listUrl = url('/browse/' . $listParent);
} else {
$listUrl = request()->url();
}
// Add query string if there are params
if (!empty($listParams)) {
$listUrl .= '?' . http_build_query($listParams);
}
// Build thumbnail toggle URL for list view
$thumbParams = $currentParams;
$showThumbnails = request()->query('thumbs', '0') === '1';
$thumbParams['thumbs'] = $showThumbnails ? '0' : '1';
$thumbUrl = request()->url() . '?' . http_build_query($thumbParams);
@endphp
<div class="flex items-center gap-2 text-sm">
<span class="text-gray-600 dark:text-gray-400">View:</span>
@if($currentView === 'covers')
{{-- Currently in cover view --}}
<span class="font-semibold text-gray-800 dark:text-gray-200">Covers</span>
<span class="text-gray-400 dark:text-gray-500">|</span>
<a href="{{ $listUrl }}" class="text-blue-600 dark:text-blue-400 hover:text-blue-800 dark:hover:text-blue-300">List</a>
@else
{{-- Currently in list view --}}
@if($covgroup || $shows)
<a href="{{ $coverUrl }}" class="text-blue-600 dark:text-blue-400 hover:text-blue-800 dark:hover:text-blue-300">Covers</a>
<span class="text-gray-400 dark:text-gray-500">|</span>
@endif
<span class="font-semibold text-gray-800 dark:text-gray-200">List</span>
{{-- Thumbnail toggle in list view --}}
@if($covgroup || $shows)
<span class="text-gray-400 dark:text-gray-500 ml-2">|</span>
<a href="{{ $thumbUrl }}"
class="inline-flex items-center gap-1 {{ $showThumbnails ? 'text-green-600 dark:text-green-400' : 'text-blue-600 dark:text-blue-400' }} hover:text-blue-800 dark:hover:text-blue-300"
title="{{ $showThumbnails ? 'Hide thumbnails' : 'Show thumbnails' }}">
<i class="fas fa-image text-xs"></i>
<span>{{ $showThumbnails ? 'Hide Thumbs' : 'Show Thumbs' }}</span>
</a>
@endif
@endif
</div>
+7 -4
View File
@@ -42,10 +42,13 @@
<div class="flex flex-col lg:flex-row justify-between items-start lg:items-center gap-4">
<!-- Left Section -->
<div class="flex flex-col sm:flex-row items-start sm:items-center gap-4">
<div class="text-sm">
<span class="text-gray-600">View: <strong>Covers</strong> |
<a href="{{ url('/browse/Console/' . ($categorytitle ?? '')) }}" class="text-blue-600 dark:text-blue-400 hover:text-blue-800">List</a></span>
</div>
<x-view-toggle
current-view="covers"
covgroup="console"
:category="$categorytitle ?? 'All'"
parentcat="Console"
:shows="false"
/>
<div class="flex items-center gap-2">
<small class="text-gray-600">With Selected:</small>
+14 -5
View File
@@ -93,11 +93,20 @@
<!-- Results -->
@if(count($results) > 0)
<div class="mb-4 flex justify-between items-center">
<h2 class="text-xl font-semibold text-gray-800">
<i class="fa fa-gamepad mr-2 text-blue-600"></i>
{{ $catname ?? 'All' }} Games
</h2>
<span class="text-sm text-gray-600">
<div class="flex items-center gap-4">
<h2 class="text-xl font-semibold text-gray-800 dark:text-gray-200">
<i class="fa fa-gamepad mr-2 text-blue-600"></i>
{{ $catname ?? 'All' }} Games
</h2>
<x-view-toggle
current-view="covers"
covgroup="games"
:category="$catname ?? 'All'"
parentcat="PC"
:shows="false"
/>
</div>
<span class="text-sm text-gray-600 dark:text-gray-400">
{{ $results->total() }} results found
</span>
</div>
+10 -1
View File
@@ -24,7 +24,16 @@
<!-- Movies Filter Section -->
<div class="px-6 py-4 bg-gray-50 dark:bg-gray-900 border-b border-gray-200">
<div class="flex justify-between items-center mb-4">
<h2 class="text-xl font-semibold text-gray-800 dark:text-gray-200">Filter Movies</h2>
<div class="flex items-center gap-4">
<h2 class="text-xl font-semibold text-gray-800 dark:text-gray-200">Filter Movies</h2>
<x-view-toggle
current-view="covers"
covgroup="movies"
category="All"
parentcat="Movies"
:shows="false"
/>
</div>
<div class="flex gap-2">
<!-- Layout Toggle Button -->
<button id="layoutToggle" class="inline-flex items-center px-4 py-2 bg-gray-600 dark:bg-gray-700 text-white rounded-lg hover:bg-gray-700 dark:hover:bg-gray-800 transition shadow-md" title="Toggle layout">
+13 -4
View File
@@ -90,10 +90,19 @@
<!-- Results -->
@if(count($results) > 0)
<div class="mb-4 flex justify-between items-center">
<h2 class="text-xl font-semibold text-gray-800 dark:text-gray-200">
<i class="fa fa-music mr-2 text-blue-600 dark:text-blue-400"></i>
{{ $catname ?? 'All' }} Albums
</h2>
<div class="flex items-center gap-4">
<h2 class="text-xl font-semibold text-gray-800 dark:text-gray-200">
<i class="fa fa-music mr-2 text-blue-600 dark:text-blue-400"></i>
{{ $catname ?? 'All' }} Albums
</h2>
<x-view-toggle
current-view="covers"
covgroup="music"
:category="$categorytitle ?? 'All'"
parentcat="Audio"
:shows="false"
/>
</div>
<span class="text-sm text-gray-600 dark:text-gray-400">
{{ $results->total() }} results found
</span>
+13 -4
View File
@@ -85,10 +85,19 @@
<!-- Results -->
@if(count($results) > 0)
<div class="mb-4 flex justify-between items-center">
<h2 class="text-xl font-semibold text-gray-800 dark:text-gray-200">
<i class="fa fa-film mr-2 text-blue-600"></i>
{{ $catname ?? 'All' }} XXX
</h2>
<div class="flex items-center gap-4">
<h2 class="text-xl font-semibold text-gray-800 dark:text-gray-200">
<i class="fa fa-film mr-2 text-blue-600"></i>
{{ $catname ?? 'All' }} XXX
</h2>
<x-view-toggle
current-view="covers"
covgroup="xxx"
:category="$categorytitle ?? 'All'"
parentcat="XXX"
:shows="false"
/>
</div>
<span class="text-sm text-gray-600 dark:text-gray-400">
{{ $results->total() }} results found
</span>