]> _ Git - fluidbook-toolbox.git/commitdiff
wip #8000 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 13 Feb 2026 11:24:53 +0000 (12:24 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 13 Feb 2026 11:24:53 +0000 (12:24 +0100)
app/Fluidbook/Compiler/Compiler.php
app/Fluidbook/Compiler/Links.php
app/Http/Controllers/Admin/Operations/FluidbookPublication/Services/ShortLinksOperation.php

index 53b7f30c54d6dd5c85247a38774394a63579c52f..b9ce8f1c3f06be2e57d932c1a544778409a22900 100644 (file)
@@ -559,6 +559,8 @@ class Compiler extends Base implements CompilerInterface, IVirtualDirectoryError
 
         $this->config->triggersLinks = [];
         $this->config->hasContentLock = false;
+
+        $this->config->specialShortLinks=[];
     }
 
     public function addMask($layer, $page, $area)
index fe7925d79ee2169f42d51b789f0ef3290b1666db..d19e3fc0270c50e57134eba33a43773b79512372 100644 (file)
@@ -130,7 +130,7 @@ trait Links
         $linksCopy = $links;
 
         foreach ($linksCopy as $k => $linkData) {
-            if(!$linkData['to']) {
+            if (!$linkData['to']) {
                 continue;
             }
             if (stristr($linkData['to'], 'javascript:canvasToPDF(')) {
@@ -531,13 +531,18 @@ trait Links
         $this->config->push('triggersLinks', ['page' => $page, 'link' => $link, 'delay' => $delay]);
     }
 
-    public function shortenURL($url)
+    public function shortenURL($url, $special = false)
     {
 
         if (!$this->config->linkShortener || $this->config->linkShortener === 'none' || !Url::isDistant($url)) {
             return $url;
         }
-        return LinkShortener::shorturl($url, $this->config->linkShortener);
+
+        $res = LinkShortener::shorturl($url, $this->config->linkShortener);
+        if ($special) {
+            $this->config->push('specialShortLinks', $res);
+        }
+        return $res;
     }
 
 }
index e547c9f5461ecae0f44f3fc9961b086e890faa9f..3f314f11d20cc7665dc0aacd0143e48373cede35 100644 (file)
@@ -3,8 +3,12 @@
 namespace App\Http\Controllers\Admin\Operations\FluidbookPublication\Services;
 
 use App\Fluidbook\Link\LinksData;
+use App\Http\Middleware\Authenticate;
 use App\Http\Middleware\CheckIfAdmin;
+use App\Http\Middleware\VerifyCsrfToken;
 use App\Models\FluidbookPublication;
+use App\Models\LinkShortener;
+use Cubist\Backpack\Middleware\CORSMiddleware;
 use Fluidbook\Tools\Links\Link;
 use Illuminate\Support\Facades\Route;
 
@@ -15,13 +19,13 @@ trait ShortLinksOperation
     protected function setupShortlinkRoutes($segment, $routeName, $controller)
     {
         foreach (['services', 's'] as $segment) {
-            Route::match(['get'], $segment . '/shortlinks/{cid?}', $controller . '@listShortLinks')->withoutMiddleware([CheckIfAdmin::class]);
+            Route::match(['post'], $segment . '/shortlinks', $controller . '@listShortLinks')->withoutMiddleware([CORSMiddleware::class])->withoutMiddleware([Authenticate::class, VerifyCsrfToken::class, CheckIfAdmin::class]);
         }
     }
 
-    public function listShortLinks($cid)
+    public function listShortLinks()
     {
-        $publication = FluidbookPublication::where('cid', $cid)->first();
+        $publication = FluidbookPublication::where('cid', request('cid'))->first();
         if (null === $publication) {
             abort(404);
         }
@@ -29,13 +33,11 @@ trait ShortLinksOperation
             abort(404);
         }
 
-        LinksData::getLinksAndRulers($publication->id, $links, $rulers);
-        $res = ['youtube' => []];
-        foreach ($links as $link) {
-            if ($link['type'] == Link::WEBVIDEO && $link['video_service'] == 'youtube') {
-
-            }
+        $res = [];
+        foreach (request('links') as $url) {
+            $res[$url] = LinkShortener::expand($url, $publication->linkShortener);
         }
+        return $res;
     }
 
 }