fixed browse and tailwindcss style
This commit is contained in:
@@ -4,12 +4,12 @@ namespace App\Http\Controllers\Legacy;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Artwork;
|
||||
use App\Models\ContentType;
|
||||
use App\Services\ArtworkService;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Pagination\CursorPaginator;
|
||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class BrowseController extends Controller
|
||||
{
|
||||
@@ -27,18 +27,22 @@ class BrowseController extends Controller
|
||||
$page_meta_keywords = 'photography, wallpapers, skins, stock, browse, social, community, artist, picture, photo';
|
||||
|
||||
$perPage = (int) $request->get('per_page', 24);
|
||||
$sort = (string) $request->get('sort', 'latest');
|
||||
|
||||
$categoryPath = trim((string) $request->query('category', ''), '/');
|
||||
// Canonical browse routes are slug-based (/photography, /wallpapers, /skins, /other, /{type}/{path}).
|
||||
// Prevent duplicate query-driven browse URLs.
|
||||
$legacyCategory = trim((string) $request->query('category', ''), '/');
|
||||
if ($legacyCategory !== '') {
|
||||
return redirect('/' . strtolower($legacyCategory), 301);
|
||||
}
|
||||
$legacyContentType = trim((string) $request->query('content_type', ''), '/');
|
||||
if ($legacyContentType !== '') {
|
||||
return redirect('/' . strtolower($legacyContentType), 301);
|
||||
}
|
||||
|
||||
try {
|
||||
if ($categoryPath !== '') {
|
||||
$slugs = array_values(array_filter(explode('/', $categoryPath)));
|
||||
/** @var CursorPaginator $artworks */
|
||||
$artworks = $this->artworks->getArtworksByCategoryPath($slugs, $perPage);
|
||||
} else {
|
||||
/** @var CursorPaginator $artworks */
|
||||
$artworks = $this->artworks->browsePublicArtworks($perPage);
|
||||
}
|
||||
/** @var CursorPaginator $artworks */
|
||||
$artworks = $this->artworks->browsePublicArtworks($perPage, $sort);
|
||||
} catch (ModelNotFoundException $e) {
|
||||
abort(404);
|
||||
}
|
||||
@@ -46,7 +50,6 @@ class BrowseController extends Controller
|
||||
if (count($artworks) === 0) {
|
||||
Log::warning('browse.missing_artworks', [
|
||||
'url' => $request->fullUrl(),
|
||||
'category_path' => $categoryPath ?: null,
|
||||
]);
|
||||
abort(410);
|
||||
}
|
||||
@@ -54,7 +57,16 @@ class BrowseController extends Controller
|
||||
// Shape data for the legacy Blade while using authoritative tables only.
|
||||
$artworks->getCollection()->transform(fn (Artwork $artwork) => $this->mapArtwork($artwork));
|
||||
|
||||
return view('legacy.browse', compact('page_title', 'page_meta_description', 'page_meta_keywords', 'artworks'));
|
||||
$rootCategories = ContentType::orderBy('id')
|
||||
->get(['name', 'slug'])
|
||||
->map(fn (ContentType $type) => (object) [
|
||||
'name' => $type->name,
|
||||
'url' => '/' . strtolower($type->slug),
|
||||
]);
|
||||
|
||||
$page_canonical = url('/browse');
|
||||
|
||||
return view('legacy.browse', compact('page_title', 'page_meta_description', 'page_meta_keywords', 'page_canonical', 'artworks', 'rootCategories'));
|
||||
}
|
||||
|
||||
private function mapArtwork(Artwork $artwork): object
|
||||
|
||||
@@ -49,9 +49,10 @@ class CategoryController extends Controller
|
||||
$slugs = array_merge([$contentTypeSlug], $parts);
|
||||
|
||||
$perPage = (int) $request->get('per_page', 40);
|
||||
$sort = (string) $request->get('sort', 'latest');
|
||||
|
||||
try {
|
||||
$artworks = $this->artworkService->getArtworksByCategoryPath($slugs, $perPage);
|
||||
$artworks = $this->artworkService->getArtworksByCategoryPath($slugs, $perPage, $sort);
|
||||
} catch (ModelNotFoundException $e) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
@@ -53,24 +53,11 @@ class PhotographyController extends Controller
|
||||
$tidy = $category->description ?? ($ct->description ?? null);
|
||||
|
||||
$perPage = 40;
|
||||
$sort = (string) $request->get('sort', 'latest');
|
||||
|
||||
// Load artworks for the requested content type using standard pagination
|
||||
try {
|
||||
$artQuery = \App\Models\Artwork::public()
|
||||
->published()
|
||||
->whereHas('categories', function ($q) use ($ct) {
|
||||
$q->where('categories.content_type_id', $ct->id);
|
||||
})
|
||||
->with([
|
||||
'user:id,name',
|
||||
'categories' => function ($q) {
|
||||
$q->select('categories.id', 'categories.content_type_id', 'categories.parent_id', 'categories.name', 'categories.slug', 'categories.sort_order')
|
||||
->with(['parent:id,parent_id,content_type_id,name,slug', 'contentType:id,slug,name']);
|
||||
},
|
||||
])
|
||||
->orderByDesc('published_at');
|
||||
|
||||
$artworks = $artQuery->paginate($perPage)->withQueryString();
|
||||
$artworks = $this->artworks->getArtworksByContentType($contentSlug, $perPage, $sort);
|
||||
} catch (\Throwable $e) {
|
||||
// Return an empty paginator so views using ->links() / ->firstItem() work
|
||||
$artworks = new \Illuminate\Pagination\LengthAwarePaginator([], 0, $perPage, 1, [
|
||||
|
||||
Reference in New Issue
Block a user