]> _ Git - odl.git/commitdiff
wip #4972 @2
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 20 Dec 2021 18:24:46 +0000 (19:24 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 20 Dec 2021 18:24:46 +0000 (19:24 +0100)
.gitignore
app/Jobs/ProducePackage.php [new file with mode: 0644]
webpack.mix.js

index e6e9353fe7d64e9e6c4fa9642b636f66349a602b..762165c8255f2c6ab714e25c785015ac0eb8ba00 100644 (file)
@@ -6,6 +6,7 @@
 /public/js
 /public/mix-manifest.json
 /storage/*.key
+/storage/package/*
 /vendor
 .env
 .env.backup
diff --git a/app/Jobs/ProducePackage.php b/app/Jobs/ProducePackage.php
new file mode 100644 (file)
index 0000000..a766bb8
--- /dev/null
@@ -0,0 +1,65 @@
+<?php
+
+namespace App\Jobs;
+
+use App\Http\Controllers\FrontController;
+use Cubist\Util\Files\VirtualDirectory;
+use Illuminate\Bus\Queueable;
+use Illuminate\Contracts\Queue\ShouldBeUnique;
+use Illuminate\Contracts\Queue\ShouldQueue;
+use Illuminate\Foundation\Bus\Dispatchable;
+use Illuminate\Queue\InteractsWithQueue;
+use Illuminate\Queue\SerializesModels;
+use Illuminate\View\View;
+
+class ProducePackage implements ShouldQueue, ShouldBeUnique {
+    /**
+     * @var string
+     */
+
+    protected $dir;
+
+    /**
+     * @var VirtualDirectory
+     */
+    protected $vdir;
+
+    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
+
+    public function handle() {
+
+        $this->dir = storage_path('package');
+        $this->vdir = new VirtualDirectory($this->dir);
+
+        $this->vdir->copyDirectory(storage_path('fluidbook/out'), 'coeur');
+        $frontDirectories=['css','fonts','images','js'];
+        foreach ($frontDirectories as $frontDirectory) {
+            $this->vdir->copyDirectory(public_path($frontDirectory), $frontDirectory);
+        }
+
+        $frontController = new FrontController();
+        $this->vdir->file_put_contents('index.html', $this->_render($frontController->splash()));
+        $this->vdir->file_put_contents('accueil.html', $this->_render($frontController->home()));
+        $this->vdir->file_put_contents('mediatheque.html', $this->_render($frontController->medialibrary()));
+        $this->vdir->file_put_contents('ressources.html', $this->_render($frontController->resources()));
+
+        $this->vdir->sync(true);
+    }
+
+    /**
+     * @param $view View
+     */
+    protected function _render($view) {
+        $html = $view->render();
+        $replace = [
+            'https://odl.paris.cubedesigners.com/front/' => './',
+            'https://odl.paris.cubedesigners.com/'=>'./',
+            '/front/'=>'./',
+        ];
+        $html = str_replace(array_keys($replace), array_values($replace), $html);
+
+        return $html;
+    }
+
+
+}
index 89398b6d91922a0ecbac4c58682e15e362645f19..a298868149a8704554bf7b37fa7f9098d0ef9584 100644 (file)
@@ -2,10 +2,13 @@ const mix = require('laravel-mix');
 
 
 mix.js('resources/js/app.js', 'public/js')
-   .postCss('resources/css/app.css', 'public/css', [
+    .postCss('resources/css/app.css', 'public/css', [
         require('postcss-import'), // Enables build-time imports
         require('tailwindcss'),
-    ]);
+    ]).options({
+    processCssUrls: false
+});
+;
 
 // Copy pre-compiled Isotope JS package
 mix.copy('node_modules/isotope-layout/dist/isotope.pkgd.min.js', 'public/js/isotope.js');