From: Vincent Vanwaelscappel Date: Thu, 11 Sep 2025 16:11:31 +0000 (+0200) Subject: wait #7605 @1 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=7ff7728923bc954272a8f7c7471d804612ef7b1f;p=psq.git wait #7605 @1 --- diff --git a/app/Http/Controllers/FluidbookController.php b/app/Http/Controllers/FluidbookController.php index 25b954c..832de9b 100644 --- a/app/Http/Controllers/FluidbookController.php +++ b/app/Http/Controllers/FluidbookController.php @@ -4,6 +4,7 @@ namespace App\Http\Controllers; use App\AccessLog; use App\PdfFile; +use Cubist\Util\Files\Files; use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; use Illuminate\View\View; @@ -12,17 +13,29 @@ class FluidbookController extends Controller { - /** * @param PdfFile $file * @param Request $request - * @return RedirectResponse|View + * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\Routing\ResponseFactory|\Illuminate\Http\Response|object * @throws \Illuminate\Auth\Access\AuthorizationException * Auth'd route */ - public function view(PdfFile $file, Request $request) + public function view(PdfFile $file, string $path = '') { -$file->getFluidbookPath(); + // Add trailing slash if needed + $request = request(); + if ($request->getPathInfo() === '/view/' . $file->slug) { + $uri = str_replace('/view/' . $file->slug, '/view/' . $file->slug . '/index.html', $request->getRequestUri()); + return redirect($uri); + } + + $path = ltrim($path, '/'); + if (!$path) { + $path = 'index.html'; + } + $pathname = $file->getFluidbookPath($path); + return XSendFileController::sendfile($pathname); + } diff --git a/app/Http/Controllers/XSendFileController.php b/app/Http/Controllers/XSendFileController.php index 2cdc707..f947e63 100644 --- a/app/Http/Controllers/XSendFileController.php +++ b/app/Http/Controllers/XSendFileController.php @@ -35,7 +35,6 @@ class XSendFileController extends Controller foreach ($headers as $key => $value) { $response->header($key, $value); } - $response->setContent(':/'); return $response->header('X-Sendfile', $path); } diff --git a/app/PdfFile.php b/app/PdfFile.php index 3e93fd9..c206395 100644 --- a/app/PdfFile.php +++ b/app/PdfFile.php @@ -136,12 +136,7 @@ class PdfFile extends TwillModel implements Sortable public function getFluidbookPath($path = '') { $base = \Cubist\Util\Files\Files::mkdir(storage_path('fluidbook/' . $this->slug . '/')); - if (!$path) { - $path = 'index.html'; - } - $pathname = $base . $path; - $res = XSendFileController::sendfile($pathname); - return $res; + return $base . $path; } /** diff --git a/public/.htaccess b/public/.htaccess index 3aec5e2..c65d98c 100644 --- a/public/.htaccess +++ b/public/.htaccess @@ -9,10 +9,10 @@ RewriteCond %{HTTP:Authorization} . RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] - # Redirect Trailing Slashes If Not A Folder... - RewriteCond %{REQUEST_FILENAME} !-d - RewriteCond %{REQUEST_URI} (.+)/$ - RewriteRule ^ %1 [L,R=301] +# # Redirect Trailing Slashes If Not A Folder... +# RewriteCond %{REQUEST_FILENAME} !-d +# RewriteCond %{REQUEST_URI} (.+)/$ +# RewriteRule ^ %1 [L,R=301] # Send Requests To Front Controller... RewriteCond %{REQUEST_FILENAME} !-d diff --git a/routes/web.php b/routes/web.php index c839f8b..565ae5f 100644 --- a/routes/web.php +++ b/routes/web.php @@ -69,7 +69,8 @@ Route::domain(env('CLIENT_DOMAIN_NAME'))->group(function () { /** Fluidbook viewer */ Route::middleware(['login.token', 'authed.verified']) - ->get('/view/{file:slug}', 'FluidbookController@view') + ->get('/view/{file:slug}/{path?}', 'FluidbookController@view') + ->where('path', '.*') ->name('fluidbook.view'); Route::get('edition/{file:slug}', 'FileController@show');