From e8a96a383922683b8c8beabf15dc16e16b9e2316 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Thu, 18 Apr 2024 16:54:02 +0200 Subject: [PATCH] wip #6871 @0.5 --- app/Http/Controllers/CatalogController.php | 18 ++++++++++++++---- routes/web.php | 1 + 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/CatalogController.php b/app/Http/Controllers/CatalogController.php index 8f25bde..94895e6 100644 --- a/app/Http/Controllers/CatalogController.php +++ b/app/Http/Controllers/CatalogController.php @@ -2,20 +2,30 @@ namespace App\Http\Controllers; -use App\Fluidbook\Compiler\Compiler; -use App\Models\FluidbookHealthIssues; use Cubist\Backpack\Http\Controllers\Base\XSendFileController; use Cubist\Util\PHP; class CatalogController extends Controller { - public function index($path = 'index.html') + public function index($path = '', $forceGuest = false) { PHP::neverStop(false); + if (!$path && !str_ends_with($_SERVER['REQUEST_URI'], '/')) { + return redirect($_SERVER['REQUEST_URI'] . '/index.html'); + } + if (!$path) { + $path = 'index.html'; + } - $cpath = auth()->guest() ? 'fluidbooks/catalogue_invite' : 'fluidbooks/catalogue'; + $cpath = $forceGuest || auth()->guest() ? 'fluidbooks/catalogue_invite' : 'fluidbooks/catalogue'; $relayPath = base_path($cpath) . '/' . $path; return XSendFileController::sendfile($relayPath); } + + public function guest($path = '') + { + return $this->index($path, true); + } + } diff --git a/routes/web.php b/routes/web.php index a420db0..1571c5e 100644 --- a/routes/web.php +++ b/routes/web.php @@ -3,3 +3,4 @@ use Illuminate\Support\Facades\Route; Route::get('/catalogue/{path?}', \App\Http\Controllers\CatalogController::class . '@index')->where('path', '.*'); +Route::get('/catalogue_invite/{path?}', \App\Http\Controllers\CatalogController::class . '@guest')->where('path', '.*'); -- 2.39.5