Upload beautify
This commit is contained in:
112
routes/web.php
112
routes/web.php
@@ -1,8 +1,12 @@
|
||||
<?php
|
||||
|
||||
use App\Http\Controllers\ProfileController;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use App\Http\Controllers\ProfileController;
|
||||
use App\Models\ContentType;
|
||||
use App\Http\Controllers\AvatarController;
|
||||
use App\Http\Controllers\ManageController;
|
||||
use App\Http\Controllers\Dashboard\ArtworkController as DashboardArtworkController;
|
||||
use Inertia\Inertia;
|
||||
|
||||
// Legacy routes are defined in routes/legacy.php and provide the site's
|
||||
// legacy pages (art, forum, news, profile, etc.). We keep the auth routes
|
||||
@@ -22,33 +26,107 @@ Route::middleware(['auth'])->prefix('dashboard')->name('dashboard.')->group(func
|
||||
|
||||
Route::middleware('auth')->group(function () {
|
||||
Route::get('/profile', [ProfileController::class, 'edit'])->name('profile.edit');
|
||||
Route::patch('/profile', [ProfileController::class, 'update'])->name('profile.update');
|
||||
Route::match(['post','put','patch'], '/profile', [ProfileController::class, 'update'])->name('profile.update');
|
||||
Route::delete('/profile', [ProfileController::class, 'destroy'])->name('profile.destroy');
|
||||
// Password change endpoint (accepts POST or PUT from legacy and new forms)
|
||||
Route::match(['post', 'put'], '/profile/password', [ProfileController::class, 'password'])->name('profile.password');
|
||||
// Avatar upload (backend only) - processes and stores avatars
|
||||
Route::post('/avatar/upload', [AvatarController::class, 'upload'])->name('avatar.upload');
|
||||
});
|
||||
|
||||
Route::middleware(['auth'])->group(function () {
|
||||
Route::get('/upload', function () {
|
||||
$contentTypes = ContentType::with(['rootCategories.children'])->get()->map(function ($ct) {
|
||||
return [
|
||||
'id' => $ct->id,
|
||||
'name' => $ct->name,
|
||||
'categories' => $ct->rootCategories->map(function ($c) {
|
||||
return [
|
||||
'id' => $c->id,
|
||||
'name' => $c->name,
|
||||
'children' => $c->children->map(function ($ch) {
|
||||
return ['id' => $ch->id, 'name' => $ch->name];
|
||||
})->values()->all(),
|
||||
];
|
||||
})->values()->all(),
|
||||
];
|
||||
})->values()->all();
|
||||
|
||||
return Inertia::render('Upload/Index', [
|
||||
'draftId' => null,
|
||||
'content_types' => $contentTypes,
|
||||
'suggested_tags' => [],
|
||||
'filesCdnUrl' => config('cdn.files_url'),
|
||||
'chunkSize' => (int) config('uploads.chunk.max_bytes', 5242880),
|
||||
'feature_flags' => [
|
||||
'uploads_v2' => (bool) config('features.uploads_v2', false),
|
||||
],
|
||||
]);
|
||||
})->name('upload');
|
||||
|
||||
Route::get('/upload/draft/{id}', function (string $id) {
|
||||
$contentTypes = ContentType::with(['rootCategories.children'])->get()->map(function ($ct) {
|
||||
return [
|
||||
'id' => $ct->id,
|
||||
'name' => $ct->name,
|
||||
'categories' => $ct->rootCategories->map(function ($c) {
|
||||
return [
|
||||
'id' => $c->id,
|
||||
'name' => $c->name,
|
||||
'children' => $c->children->map(function ($ch) {
|
||||
return ['id' => $ch->id, 'name' => $ch->name];
|
||||
})->values()->all(),
|
||||
];
|
||||
})->values()->all(),
|
||||
];
|
||||
})->values()->all();
|
||||
|
||||
return Inertia::render('Upload/Index', [
|
||||
'draftId' => $id,
|
||||
'content_types' => $contentTypes,
|
||||
'suggested_tags' => [],
|
||||
'filesCdnUrl' => config('cdn.files_url'),
|
||||
'chunkSize' => (int) config('uploads.chunk.max_bytes', 5242880),
|
||||
'feature_flags' => [
|
||||
'uploads_v2' => (bool) config('features.uploads_v2', false),
|
||||
],
|
||||
]);
|
||||
})->whereUuid('id')->name('upload.draft');
|
||||
});
|
||||
|
||||
|
||||
|
||||
require __DIR__.'/auth.php';
|
||||
|
||||
Route::get('/tag/{tag:slug}', [\App\Http\Controllers\Web\TagController::class, 'show'])
|
||||
->where('tag', '[a-z0-9\-]+')
|
||||
->name('tags.show');
|
||||
|
||||
Route::view('/blank', 'blank')->name('blank');
|
||||
|
||||
// Artwork public show (slug-based). This must come before the category route so the artwork
|
||||
// slug (last segment) is matched correctly while allowing multi-segment category paths.
|
||||
Route::get('/{contentTypeSlug}/{categoryPath}/{artwork}', [\App\Http\Controllers\ArtworkController::class, 'show'])
|
||||
->where([
|
||||
'contentTypeSlug' => 'photography|wallpapers|skins|other',
|
||||
'categoryPath' => '.*',
|
||||
'artwork' => '[A-Za-z0-9\-]+'
|
||||
])
|
||||
// Bind the artwork route parameter to a model if it exists, otherwise return null
|
||||
use App\Models\Artwork;
|
||||
Route::bind('artwork', function ($value) {
|
||||
return Artwork::where('slug', $value)->first();
|
||||
});
|
||||
|
||||
// Universal content router: handles content-type roots, nested categories and artwork slugs.
|
||||
// Keep the explicit /photography route above (if present) so the legacy controller can continue
|
||||
// to serve photography's root page. This catch-all route delegates to a controller that
|
||||
// will forward to the appropriate existing controller (artwork or category handlers).
|
||||
// Provide a named route alias for legacy artwork URL generation used in tests.
|
||||
Route::get('/{contentTypeSlug}/{categoryPath}/{artwork}', [\App\Http\Controllers\ContentRouterController::class, 'handle'])
|
||||
->where('contentTypeSlug', 'photography|wallpapers|skins|other')
|
||||
->where('categoryPath', '[^/]+(?:/[^/]+)*')
|
||||
->name('artworks.show');
|
||||
|
||||
// New slug-based category routes (e.g., /photography/audio/winamp)
|
||||
Route::get('/{contentTypeSlug}/{categoryPath?}', [\App\Http\Controllers\CategoryPageController::class, 'show'])
|
||||
Route::get('/{contentTypeSlug}/{path?}', [\App\Http\Controllers\ContentRouterController::class, 'handle'])
|
||||
->where('contentTypeSlug', 'photography|wallpapers|skins|other')
|
||||
->where('categoryPath', '.*')
|
||||
->name('category.slug');
|
||||
->where('path', '.*')
|
||||
->name('content.route');
|
||||
|
||||
|
||||
|
||||
use App\Http\Controllers\ManageController;
|
||||
|
||||
Route::middleware(['auth'])->group(function () {
|
||||
Route::get('/manage', [ManageController::class, 'index'])->name('manage');
|
||||
@@ -59,6 +137,10 @@ Route::middleware(['auth'])->group(function () {
|
||||
|
||||
// Admin routes for artworks (separated from public routes)
|
||||
Route::middleware(['auth'])->prefix('admin')->name('admin.')->group(function () {
|
||||
Route::get('uploads/moderation', function () {
|
||||
return Inertia::render('Admin/UploadQueue');
|
||||
})->middleware('admin.moderation')->name('uploads.moderation');
|
||||
|
||||
Route::resource('artworks', \App\Http\Controllers\Admin\ArtworkController::class)->except(['show']);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user