]> _ Git - odl.git/commitdiff
wait #4972 @1
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 20 Dec 2021 19:09:14 +0000 (20:09 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 20 Dec 2021 19:09:14 +0000 (20:09 +0100)
app/Jobs/ProducePackage.php

index a766bb86e288be5a0ebc9554db5d7f90060c8d23..0041f465d65d1ee750ebad93e00250ff7749bcc2 100644 (file)
@@ -32,7 +32,7 @@ class ProducePackage implements ShouldQueue, ShouldBeUnique {
         $this->vdir = new VirtualDirectory($this->dir);
 
         $this->vdir->copyDirectory(storage_path('fluidbook/out'), 'coeur');
-        $frontDirectories=['css','fonts','images','js'];
+        $frontDirectories = ['css', 'fonts', 'images', 'js'];
         foreach ($frontDirectories as $frontDirectory) {
             $this->vdir->copyDirectory(public_path($frontDirectory), $frontDirectory);
         }
@@ -51,13 +51,34 @@ class ProducePackage implements ShouldQueue, ShouldBeUnique {
      */
     protected function _render($view) {
         $html = $view->render();
+
+        // Parse html to find storage files that need to be copied in the final package
+        if (preg_match_all('/\\\\?\/storage\\\\?\/([^"?\)&]*)/', $html, $matches)) {
+            $files = array_unique($matches[1]);
+            foreach ($files as $match) {
+                $match = str_replace('\\/', '/', $match);
+                $f = public_path('storage/' . $match);
+                if (file_exists($f)) {
+                    $this->vdir->copy($f, 'storage/' . $match);
+                } else {
+                    echo 'Missing ' . $f . "\n";
+                }
+            }
+        }
+
+        //
         $replace = [
             'https://odl.paris.cubedesigners.com/front/' => './',
-            'https://odl.paris.cubedesigners.com/'=>'./',
-            '/front/'=>'./',
+            'https://cube.odile.space/front/' => './',
+            'https://odl.paris.cubedesigners.com/' => './',
+            'https://cube.odile.space/' => './',
+            '/front/' => './',
+            '\/storage' => '.\/storage',
+            '/storage/' => './storage/',
         ];
         $html = str_replace(array_keys($replace), array_values($replace), $html);
 
+
         return $html;
     }