]> _ Git - fluidbook-toolbox.git/commitdiff
wip #5093 @0.25
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 14 Feb 2022 18:08:57 +0000 (19:08 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 14 Feb 2022 18:08:57 +0000 (19:08 +0100)
.idea/workspace.xml
app/Jobs/Tools/FluidbookAssetsDownloader.php

index 2e1b619ec70df783dcb0d818536aa3a2aa17ffc4..30b5528283414bed1d2ae171d349d332536635ae 100644 (file)
     <select />
   </component>
   <component name="ChangeListManager">
-    <list default="true" id="5d2ecd5e-a05a-4f96-a195-fa6372618165" name="Default Changelist" comment="wip #5041 @1">
-      <change afterPath="$PROJECT_DIR$/app/Http/Controllers/Admin/Operations/Tools/FluidbookAssetsDownloader.php" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/app/Jobs/Tools/FluidbookAssetsDownloader.php" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/public/packages/fluidbook/toolbox/css/tools.css" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/public/packages/fluidbook/toolbox/css/tools.css.map" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/public/packages/fluidbook/toolbox/css/tools.less" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/resources/views/tools/form.blade.php" afterDir="false" />
+    <list default="true" id="5d2ecd5e-a05a-4f96-a195-fa6372618165" name="Default Changelist" comment="wip #5093 @2">
       <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/app/Http/Controllers/Admin/ToolsController.php" beforeDir="false" afterPath="$PROJECT_DIR$/app/Http/Controllers/Admin/ToolsController.php" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/public/packages/fluidbook/toolbox/css/style.less" beforeDir="false" afterPath="$PROJECT_DIR$/public/packages/fluidbook/toolbox/css/style.less" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/resources/views/tools/pdf2svg.blade.php" beforeDir="false" afterPath="$PROJECT_DIR$/resources/views/tools/pdf2svg.blade.php" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/resources/views/tools/sidebar.blade.php" beforeDir="false" afterPath="$PROJECT_DIR$/resources/views/tools/sidebar.blade.php" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/app/Jobs/Tools/FluidbookAssetsDownloader.php" beforeDir="false" afterPath="$PROJECT_DIR$/app/Jobs/Tools/FluidbookAssetsDownloader.php" afterDir="false" />
     </list>
     <option name="SHOW_DIALOG" value="false" />
     <option name="HIGHLIGHT_CONFLICTS" value="true" />
       <workItem from="1644582031422" duration="8556000" />
       <workItem from="1644828785862" duration="9853000" />
       <workItem from="1644851528057" duration="636000" />
-      <workItem from="1644852994411" duration="8772000" />
-    </task>
-    <task id="LOCAL-00198" summary="wip #4891 @0.5">
-      <created>1637226155328</created>
-      <option name="number" value="00198" />
-      <option name="presentableId" value="LOCAL-00198" />
-      <option name="project" value="LOCAL" />
-      <updated>1637226155328</updated>
+      <workItem from="1644852994411" duration="9050000" />
     </task>
     <task id="LOCAL-00199" summary="wip #4891 @1">
       <created>1637241915237</created>
       <option name="project" value="LOCAL" />
       <updated>1644845541532</updated>
     </task>
-    <option name="localTasksCounter" value="247" />
+    <task id="LOCAL-00247" summary="wip #5093 @2">
+      <created>1644861865777</created>
+      <option name="number" value="00247" />
+      <option name="presentableId" value="LOCAL-00247" />
+      <option name="project" value="LOCAL" />
+      <updated>1644861865777</updated>
+    </task>
+    <option name="localTasksCounter" value="248" />
     <servers />
   </component>
   <component name="TypeScriptGeneratedFilesManager">
     <option name="CHECK_CODE_SMELLS_BEFORE_PROJECT_COMMIT" value="false" />
     <option name="CHECK_NEW_TODO" value="false" />
     <option name="ADD_EXTERNAL_FILES_SILENTLY" value="true" />
-    <MESSAGE value="wait #4928 @2" />
     <MESSAGE value="wait #4928 @0.25" />
     <MESSAGE value="wait #4891 @0.5" />
     <MESSAGE value="wait #4949 @2" />
     <MESSAGE value="wip #5041 @0.5" />
     <MESSAGE value="wip #5041 @0.25" />
     <MESSAGE value="wip #5041 @1" />
-    <option name="LAST_COMMIT_MESSAGE" value="wip #5041 @1" />
+    <MESSAGE value="wip #5093 @2" />
+    <option name="LAST_COMMIT_MESSAGE" value="wip #5093 @2" />
   </component>
   <component name="XSLT-Support.FileAssociations.UIState">
     <expand />
index 73e1c4f7ed7189bdf4954f798d5b612d3d948b4a..4c2ed58ef237cafcaea48c2552f02f089d2c05a2 100644 (file)
@@ -16,25 +16,37 @@ class FluidbookAssetsDownloader implements ShouldQueue
 {
     use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
 
+    protected $lines;
+    protected $type;
+    protected $dest;
 
     public function __construct($url, $type, $fluidbook)
     {
         if (!$fluidbook) {
             throw new \Exception('Fluidbook has not be set');
         }
-        $dest = '/home/extranet/www/fluidbook/books/working/' . $fluidbook . '/';
-        $lines = Text::explodeNewLines($url);
-        foreach ($lines as $line) {
-            $this->_downloadFile($line, $dest);
+        $this->dest = '/home/extranet/www/fluidbook/books/working/' . $fluidbook . '/';
+        $this->lines = Text::explodeNewLines($url);
+        $this->type = $type;
+
+    }
+
+    public function handle()
+    {
+        foreach ($this->lines as $line) {
+            $this->_downloadFile($line);
         }
     }
 
-    protected function _downloadFile($url, $dest, $client = null)
+    protected function _downloadFile($url, $client = null)
     {
         $originalURL = $u = trim($url);
+        if (!$u) {
+            return;
+        }
         $hash = hash('sha256', $originalURL);
 
-        $tmp = Files::tempnam();
+        $tmp = Files::tempnam($this->dest);
         if (null === $client) {
             $client = new Client(['cookies' => true]);
         }
@@ -57,7 +69,7 @@ class FluidbookAssetsDownloader implements ShouldQueue
             if ($ct === 'text/html') {
                 if (preg_match('/https:\/\/bynder[^"]+/', file_get_contents($tmp), $matches)) {
                     unlink($tmp);
-                    return $this->_downloadFile(html_entity_decode($matches[0]), $dest, $client);
+                    return $this->_downloadFile(html_entity_decode($matches[0]), $client);
                 }
             }
 
@@ -69,10 +81,10 @@ class FluidbookAssetsDownloader implements ShouldQueue
                 }
             }
         }
-        if ($type === 'download') {
-            rename($tmp, $dest . $filename);
-        } else if ($type === 'unzip') {
-            Zip::extract($tmp, $dest, true);
+        if ($this->type === 'download') {
+            rename($tmp, $this->dest . $filename);
+        } else if ($this->type === 'unzip') {
+            Zip::extract($tmp, $this->dest, true);
             unlink($tmp);
         }
     }