]> _ Git - odl.git/commitdiff
wait #4972 @1
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 21 Dec 2021 10:08:49 +0000 (11:08 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 21 Dec 2021 10:08:54 +0000 (11:08 +0100)
app/Http/Controllers/Admin/ToolsController.php
app/Http/Controllers/Tools/PackageDownload.php [new file with mode: 0644]
app/Jobs/ProducePackage.php
resources/views/vendor/backpack/base/dashboard.blade.php
resources/views/vendor/backpack/base/inc/sidebar_content.blade.php

index 9cdd92463ee5a6d87621fcc0b61132a0e2ac5b78..270ea73da3add0d61699a897ff6c0379c22de9e8 100644 (file)
@@ -4,14 +4,14 @@ namespace App\Http\Controllers\Admin;
 
 use App\Http\Controllers\Tools\FluidbookConvert;
 use App\Http\Controllers\Tools\FluidbookPreview;
+use App\Http\Controllers\Tools\PackageDownload;
 
-class ToolsController
-{
+class ToolsController {
     use FluidbookConvert;
     use FluidbookPreview;
+    use PackageDownload;
 
-    public function index($tool, $args = '')
-    {
+    public function index($tool, $args = '') {
 
         if (!$args) {
             $args = [];
diff --git a/app/Http/Controllers/Tools/PackageDownload.php b/app/Http/Controllers/Tools/PackageDownload.php
new file mode 100644 (file)
index 0000000..6829b89
--- /dev/null
@@ -0,0 +1,24 @@
+<?php
+
+namespace App\Http\Controllers\Tools;
+
+use App\Jobs\ProducePackage;
+use Cubist\Util\Files\Files;
+
+trait PackageDownload {
+    protected function packagedownload() {
+        if(!can('packagedownload')){
+            return abort(403);
+        }
+        ProducePackage::dispatchSync();
+
+        $path = storage_path('package.zip');
+
+        if (file_exists($path)) {
+            return response(null)->header('Content-Disposition', 'attachment;filename=package.zip')->header('Content-Type', Files::_getMimeType($path))->header('X-Sendfile', $path);
+        } else {
+            return response(null)->setStatusCode(404);
+        }
+    }
+
+}
index 0041f465d65d1ee750ebad93e00250ff7749bcc2..b9a195bb7859d747da3bd456e391ef1829361169 100644 (file)
@@ -4,6 +4,7 @@ namespace App\Jobs;
 
 use App\Http\Controllers\FrontController;
 use Cubist\Util\Files\VirtualDirectory;
+use Cubist\Util\Zip;
 use Illuminate\Bus\Queueable;
 use Illuminate\Contracts\Queue\ShouldBeUnique;
 use Illuminate\Contracts\Queue\ShouldQueue;
@@ -44,6 +45,8 @@ class ProducePackage implements ShouldQueue, ShouldBeUnique {
         $this->vdir->file_put_contents('ressources.html', $this->_render($frontController->resources()));
 
         $this->vdir->sync(true);
+
+        Zip::archive($this->dir,$this->dir.'.zip');
     }
 
     /**
index 89cd3181060107b6f100af28ac9f90e3dd593640..eed94dc5c1b64fd3ddc2cc7f7d2a50bed3367e6f 100644 (file)
@@ -7,10 +7,20 @@
             'type'        => 'jumbotron',
             'heading'     => 'Bienvenue !',
             'content'     => 'Bienvenue dans l\'interface de création de la réponse. Utilisez les fonctions dans la barre latérale pour éditer les contenus. Cliquer sur le bouton ci-dessous pour visualiser la réponse.',
-            'button_link' => '/front/index.html',
+            'button_link' => backpack_url('/front/index.html'),
             'button_text' => 'Prévisualisation de la réponse',
         ];
         }
+               if(can('packagedownload')){
+                               $widgets['before_content'][] = [
+            'wrapper' => ['class' => 'col-sm-6 col-md-6'],
+            'type'        => 'jumbotron',
+            'heading'     => 'Télécharger',
+            'content'     => 'Télécharger la réponse au format zip pour l\'installation sur les tablettes',
+            'button_link' => backpack_url('tools/packagedownload'),
+            'button_text' => 'Compiler et télécharger',
+        ];
+               }
 @endphp
 
 @section('content')
index d64f0417305095d49a06d87b92381db615db55e7..eb76a0205d4b6bf739f57c73eca951898d591042 100644 (file)
@@ -29,6 +29,7 @@
                             class='la la-map-signs'></i>
                         <span>Visite guidée</span></a></li>
             @endcan
+
         </ul>
     </li>
 @endcan