From ed9f2471ca5265cecadb040826ec4c31045a56c0 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Mon, 20 Dec 2021 20:09:14 +0100 Subject: [PATCH] wait #4972 @1 --- app/Jobs/ProducePackage.php | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/app/Jobs/ProducePackage.php b/app/Jobs/ProducePackage.php index a766bb8..0041f46 100644 --- a/app/Jobs/ProducePackage.php +++ b/app/Jobs/ProducePackage.php @@ -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; } -- 2.39.5