]> _ Git - psq.git/commitdiff
wait #7605 @1
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 11 Sep 2025 16:11:31 +0000 (18:11 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 11 Sep 2025 16:11:31 +0000 (18:11 +0200)
app/Http/Controllers/FluidbookController.php
app/Http/Controllers/XSendFileController.php
app/PdfFile.php
public/.htaccess
routes/web.php

index 25b954cd19e5402a3e50e9cadb1491159384fb84..832de9bca830610c5a242b11715567f56de82a5e 100644 (file)
@@ -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);
+
     }
 
 
index 2cdc707a109e070f66cc82473081efc79c44fdea..f947e639ca05f820be135589ce846fb22d232f73 100644 (file)
@@ -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);
     }
 
index 3e93fd92ba584e5ead467e95c3c20cfa9be2b493..c20639529bdadd9b9199e4868cf229e3d59fe921 100644 (file)
@@ -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;
     }
 
     /**
index 3aec5e27e5db801fa9e321c0a97acbb49e10908f..c65d98cc66367dd4253972900a21464ec0fc1327 100644 (file)
@@ -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
index c839f8bb3e861d7ddca8e3afed3e7d3a78f45bcb..565ae5fe0f5976cf2721aa60378c05ef7bd853f6 100644 (file)
@@ -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');