]> _ Git - odl.git/commitdiff
wip #4666 @2
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 7 Sep 2021 18:26:36 +0000 (20:26 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 7 Sep 2021 18:26:36 +0000 (20:26 +0200)
app/Http/Controllers/Admin/ToolsController.php [new file with mode: 0644]
app/Http/Controllers/Tools/FluidbookConvert.php [new file with mode: 0644]
app/Jobs/ProcessFluidbook.php
resources/views/tools/fluidbookconvert.blade.php [new file with mode: 0644]
routes/web.php

diff --git a/app/Http/Controllers/Admin/ToolsController.php b/app/Http/Controllers/Admin/ToolsController.php
new file mode 100644 (file)
index 0000000..9aa6a68
--- /dev/null
@@ -0,0 +1,26 @@
+<?php
+
+namespace App\Http\Controllers\Admin;
+
+use App\Http\Controllers\Controller;
+use App\Http\Controllers\Tools\FluidbookConvert;
+
+class ToolsController extends Controller
+{
+    use FluidbookConvert;
+
+    protected function index($tool, $args = '')
+    {
+
+        if (!$args) {
+            $args = [];
+        } else {
+            $args = explode('/', $args);
+        }
+
+        if (!method_exists($this, $tool)) {
+            return view('tools.' . $tool, ['args' => $args]);
+        }
+        return $this->$tool($args);
+    }
+}
diff --git a/app/Http/Controllers/Tools/FluidbookConvert.php b/app/Http/Controllers/Tools/FluidbookConvert.php
new file mode 100644 (file)
index 0000000..2ff33f0
--- /dev/null
@@ -0,0 +1,14 @@
+<?php
+
+namespace App\Http\Controllers\Tools;
+
+use App\Jobs\ProcessFluidbook;
+
+trait FluidbookConvert
+{
+    protected function fluidbookconvert($args)
+    {
+        ProcessFluidbook::dispatchSync();
+        return view('tools.fluidbookconvert');
+    }
+}
index 3cacc9d84350b0ddf93b7c675ac8d5bfd318a3a6..ce4ed6f4da640323c5187f527782e4f90700fdba 100644 (file)
@@ -10,6 +10,7 @@ use Illuminate\Contracts\Queue\ShouldBeUnique;
 use Illuminate\Contracts\Queue\ShouldQueue;
 use Illuminate\Foundation\Bus\Dispatchable;
 use Illuminate\Queue\InteractsWithQueue;
+use Illuminate\Queue\Jobs\SyncJob;
 use Illuminate\Queue\SerializesModels;
 
 class ProcessFluidbook implements ShouldQueue, ShouldBeUnique
@@ -40,30 +41,39 @@ class ProcessFluidbook implements ShouldQueue, ShouldBeUnique
      */
     public function handle()
     {
+        $sync = ($this->job instanceof SyncJob);
+
+        start_measure('Process Fluidbook');
         $this->resetOutput();
-        $this->processPages();
+        $this->processPages($sync);
         $this->getTexts();
         $this->getLinks();
         $this->writeConfig();
+        stop_measure('Process Fluidbook');
     }
 
     protected function resetOutput()
     {
+        start_measure("Reset Fluidbook Output");
         $stub = resource_path('fluidbook/');
         $cmd = "rm -rfv $this->out;cp -rv $stub $this->out";
         `$cmd`;
+        stop_measure("Reset Fluidbook Output");
     }
 
 
-    public function processPages()
+    public function processPages($sync = false)
     {
+        start_measure('Process Pages');
         $out = storage_path('fluidbook/convert/' . $this->in->getHash());
         $this->in->processPages($out, [
             ['format' => 'jpg', 'resolution' => '36', 'withTexts' => true, 'withGraphics' => true],
             ['format' => 'jpg', 'resolution' => '150', 'withTexts' => false, 'withGraphics' => true],
-            ['format' => 'jpg', 'resolution' => '300', 'withTexts' => false, 'withGraphics' => true],
+            // ['format' => 'jpg', 'resolution' => '300', 'withTexts' => false, 'withGraphics' => true],
             ['format' => 'svg', 'resolution' => '300', 'withTexts' => true, 'withGraphics' => false],
-        ]);
+        ], $sync);
+        stop_measure('Process Pages');
+
     }
 
     public function getTexts()
diff --git a/resources/views/tools/fluidbookconvert.blade.php b/resources/views/tools/fluidbookconvert.blade.php
new file mode 100644 (file)
index 0000000..c62a2be
--- /dev/null
@@ -0,0 +1,4 @@
+@extends(backpack_view('blank'))
+
+@section('content')
+@endsection
index 9f058cd5c8c2657e962e8541c3d04c5e597d834b..1725466e3a3fa689646f9d3b30de4474d7c25e25 100644 (file)
@@ -7,5 +7,5 @@ Route::group([
     'middleware' => ['web', config('backpack.base.middleware_key', 'admin')],
     'namespace' => '\App\Http\Controllers\Admin',
 ], function () { // custom admin routes
-    //Route::any('tools/{tool}/{args?}', 'ToolsController@index')->where(['args' => '.*']);
+    Route::any('tools/{tool}/{args?}', 'ToolsController@index')->where(['args' => '.*']);
 });