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 = [];
--- /dev/null
+<?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);
+ }
+ }
+
+}
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;
$this->vdir->file_put_contents('ressources.html', $this->_render($frontController->resources()));
$this->vdir->sync(true);
+
+ Zip::archive($this->dir,$this->dir.'.zip');
}
/**
'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')
class='la la-map-signs'></i>
<span>Visite guidée</span></a></li>
@endcan
+
</ul>
</li>
@endcan