update
This commit is contained in:
@@ -264,35 +264,6 @@ class BrowseGalleryController extends \App\Http\Controllers\Controller
|
||||
);
|
||||
}
|
||||
|
||||
public function legacyCategory(Request $request, ?string $group = null, ?string $slug = null, ?string $id = null)
|
||||
{
|
||||
if ($id !== null && ctype_digit((string) $id)) {
|
||||
$category = Category::with('contentType')->find((int) $id);
|
||||
if (! $category || ! $category->contentType) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
return redirect($category->url, 301);
|
||||
}
|
||||
|
||||
$contentSlug = strtolower((string) $group);
|
||||
if (! in_array($contentSlug, self::CONTENT_TYPE_SLUGS, true)) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
$target = '/' . $contentSlug;
|
||||
$normalizedSlug = trim((string) $slug, '/');
|
||||
if ($normalizedSlug !== '') {
|
||||
$target .= '/' . strtolower($normalizedSlug);
|
||||
}
|
||||
|
||||
if ($request->query()) {
|
||||
$target .= '?' . http_build_query($request->query());
|
||||
}
|
||||
|
||||
return redirect($target, 301);
|
||||
}
|
||||
|
||||
private function presentArtwork(Artwork $artwork): object
|
||||
{
|
||||
$primaryCategory = $artwork->categories->sortBy('sort_order')->first();
|
||||
|
||||
@@ -45,6 +45,10 @@ final class CommunityActivityController extends Controller
|
||||
|
||||
private function resolveFilter(Request $request): string
|
||||
{
|
||||
if ($request->filled('type') && ! $request->filled('filter')) {
|
||||
return (string) $request->query('type', 'all');
|
||||
}
|
||||
|
||||
if ($request->boolean('following') && ! $request->filled('filter')) {
|
||||
return 'following';
|
||||
}
|
||||
|
||||
@@ -4,51 +4,23 @@ namespace App\Http\Controllers\Web;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Artwork;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use App\Support\UsernamePolicy;
|
||||
|
||||
class GalleryController extends Controller
|
||||
{
|
||||
public function show(Request $request, $userId, $username = null)
|
||||
{
|
||||
$user = User::find((int)$userId);
|
||||
$user = User::find((int) $userId);
|
||||
if (! $user) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
// canonicalize username in URL when possible
|
||||
try {
|
||||
$correctName = $user->name ?? $user->uname ?? null;
|
||||
if ($username && $correctName && $username !== $correctName) {
|
||||
$qs = $request->getQueryString();
|
||||
$url = route('legacy.gallery', ['id' => $user->id, 'username' => $correctName]);
|
||||
if ($qs) $url .= '?' . $qs;
|
||||
return redirect($url, 301);
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
// ignore
|
||||
$usernameSlug = UsernamePolicy::normalize((string) ($user->username ?? $user->name ?? ''));
|
||||
if ($usernameSlug === '') {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
$page = max(1, (int) $request->query('page', 1));
|
||||
$hits = 20;
|
||||
|
||||
$query = Artwork::where('user_id', $user->id)
|
||||
->approved()
|
||||
->published()
|
||||
->public()
|
||||
->orderByDesc('published_at');
|
||||
|
||||
$total = (int) $query->count();
|
||||
|
||||
$artworks = $query->skip(($page - 1) * $hits)->take($hits)->get();
|
||||
|
||||
return view('web.gallery', [
|
||||
'user' => $user,
|
||||
'artworks' => $artworks,
|
||||
'page' => $page,
|
||||
'hits' => $hits,
|
||||
'total' => $total,
|
||||
]);
|
||||
return redirect()->route('profile.gallery', ['username' => $usernameSlug], 301);
|
||||
}
|
||||
}
|
||||
|
||||
35
app/Http/Controllers/Web/LeaderboardPageController.php
Normal file
35
app/Http/Controllers/Web/LeaderboardPageController.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Controllers\Web;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Leaderboard;
|
||||
use App\Services\LeaderboardService;
|
||||
use Illuminate\Http\Request;
|
||||
use Inertia\Inertia;
|
||||
use Inertia\Response;
|
||||
|
||||
class LeaderboardPageController extends Controller
|
||||
{
|
||||
public function __invoke(Request $request, LeaderboardService $leaderboards): Response
|
||||
{
|
||||
$period = $leaderboards->normalizePeriod((string) $request->query('period', 'weekly'));
|
||||
$type = match ((string) $request->query('type', 'creators')) {
|
||||
'artworks', Leaderboard::TYPE_ARTWORK => Leaderboard::TYPE_ARTWORK,
|
||||
'stories', Leaderboard::TYPE_STORY => Leaderboard::TYPE_STORY,
|
||||
default => Leaderboard::TYPE_CREATOR,
|
||||
};
|
||||
|
||||
return Inertia::render('Leaderboard/LeaderboardPage', [
|
||||
'initialType' => $type,
|
||||
'initialPeriod' => $period,
|
||||
'initialData' => $leaderboards->getLeaderboard($type, $period),
|
||||
'meta' => [
|
||||
'title' => 'Top Creators & Artworks Leaderboard | Skinbase',
|
||||
'description' => 'Track the leading creators, artworks, and stories across Skinbase by daily, weekly, monthly, and all-time performance.',
|
||||
],
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user