]> _ Git - psq.git/commitdiff
wip #7062 @14
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 31 Oct 2024 14:51:37 +0000 (15:51 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 31 Oct 2024 14:51:37 +0000 (15:51 +0100)
.env.production
.idea/lettre-pharma.iml
.idea/php.xml
app/Jobs/ProcessPdfFile.php
app/PdfFile.php
composer.json
composer.lock
config/app.php
public/assets/admin/twill-manifest.json
resources/views/vendor/twill/partials/footer.blade.php

index d23eeb05c3a111d45c6fb1b147b6c7cfd82a7129..2d94bc743536388137674696812488ae77a6c5df 100644 (file)
@@ -94,3 +94,5 @@ STRIPE_TEST_SOCIAL_ID=14
 GOOGLE_PLACES_API_KEY=AIzaSyDlciNA1QH3yihpyrWMfg7iZbKP-1O6EQg
 
 FLUIDBOOK_TOOLBOX_API_TOKEN=h7kzW72vznLLbUCw9Wy7vk1WjPdX8UtEUL2hfhCIrDOb40sUPJh3WqRUD9H8
+FLUIDBOOK_TOOLBOX_BASE_FLUIDBOOK=31677
+FLUIDBOOK_TOOLBOX_EXTERNAL_SERVER=46
index 3d8e6a510cc5ffcfafe7bc10759c9b85a0be6671..1b78ddc0ead7a2d7d164076c4f9a6427949caa98 100644 (file)
       <excludeFolder url="file://$MODULE_DIR$/vendor/spatie/laravel-package-tools" />
       <excludeFolder url="file://$MODULE_DIR$/vendor/laravel-lang/lang" />
       <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/psr-http-message-bridge" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/fluidbook/toolboxapiclient" />
     </content>
     <content url="file://$MODULE_DIR$/node_modules" />
     <orderEntry type="inheritedJdk" />
index 2c35b7db45e69f6415c006453e9c59e948aaae50..c0792a879bd910d59ebc77ad927eebdcf12ac951 100644 (file)
       <path value="$PROJECT_DIR$/vendor/aws/aws-crt-php" />
       <path value="$PROJECT_DIR$/vendor/laravel-lang/lang" />
       <path value="$PROJECT_DIR$/vendor/symfony/psr-http-message-bridge" />
+      <path value="$PROJECT_DIR$/vendor/fluidbook/toolboxapiclient" />
     </include_path>
   </component>
   <component name="PhpInterpreters">
index 613fdce4a1c32a828ea17b2469b86868d5108dd1..5c3629fed225145a49e07840a00c0a6d79a35a30 100644 (file)
@@ -22,8 +22,6 @@ class ProcessPdfFile implements ShouldQueue
     public $timeout = 180;
 
 
-
-
     /**
      * Create a new job instance.
      *
index 69381709da1cc2b81795ac3dc00e3a38b12a0264..be90f610d740a05fa5f8752e55c2bdc33927bd87 100644 (file)
@@ -9,6 +9,7 @@ use A17\Twill\Models\Model as TwillModel;
 use App\Flowpaper\Pdf2Json;
 use Aws\S3\S3Client;
 use Carbon\Carbon;
+use Fluidbook\ToolboxApiClient\Client;
 use Illuminate\Database\Eloquent\Builder;
 use Illuminate\Database\Eloquent\Collection;
 use Illuminate\Database\Eloquent\Model;
@@ -84,8 +85,6 @@ class PdfFile extends TwillModel implements Sortable
     ];
 
 
-
-
     /**
      * @param Request $request
      * @return PdfFile
@@ -94,13 +93,13 @@ class PdfFile extends TwillModel implements Sortable
     public static function createFromRequest(Request $request): PdfFile
     {
 
-        $ref           = $request->input('ref');
+        $ref = $request->input('ref');
         $collection_id = $request->input('collection_id');
-        $file          = $request->file('file');
-        $headlines     = json_decode($request->input('headlines'), true, 16, JSON_THROW_ON_ERROR);
-        $tags          = explode(',', $request->input('tags'));
+        $file = $request->file('file');
+        $headlines = json_decode($request->input('headlines'), true, 16, JSON_THROW_ON_ERROR);
+        $tags = explode(',', $request->input('tags'));
 
-        $collection    = FileCollection::findOrFail($collection_id);
+        $collection = FileCollection::findOrFail($collection_id);
 
 
         /** @var PdfFile $pdfFile */
@@ -109,11 +108,11 @@ class PdfFile extends TwillModel implements Sortable
             'published' => 0,
             'collection_id' => $collection_id,
         ],
-        [
-            'ref' => $ref,
-            'title' => "{$collection->short_name} - $ref",
-            'headlines' => $headlines,
-        ]);
+            [
+                'ref' => $ref,
+                'title' => "{$collection->short_name} - $ref",
+                'headlines' => $headlines,
+            ]);
 
 
         Storage::makeDirectory($pdfFile->directory);
@@ -135,17 +134,19 @@ class PdfFile extends TwillModel implements Sortable
      */
     public function process(): void
     {
+        $client = new Client(env("FLUIDBOOK_TOOLBOX_API_TOKEN"));
+        $client->createFluidbook(new \SplFileInfo($this->pdfPath), env('FLUIDBOOK_TOOLBOX_BASE_FLUIDBOOK'), $this->title, env('FLUIDBOOK_TOOLBOX_EXTERNAL_SERVER'), 'PSQ-' . $this->ref);
 
-        \Log::debug('json');
-        $this->makeJson();
-        \Log::debug('cover');
-        $this->makeCover();
-        \Log::debug('links');
-        $this->shortenLinks();
-        \Log::debug('searchable');
-        $this->makeSearchable();
-        \Log::debug('cloud');
-        $this->saveToCloud();
+//        \Log::debug('json');
+//        $this->makeJson();
+//        \Log::debug('cover');
+//        $this->makeCover();
+//        \Log::debug('links');
+//        $this->shortenLinks();
+//        \Log::debug('searchable');
+//        $this->makeSearchable();
+//        \Log::debug('cloud');
+//        $this->saveToCloud();
 
     }
 
@@ -159,10 +160,6 @@ class PdfFile extends TwillModel implements Sortable
     }
 
 
-
-
-
-
     /**
      * @return Relations\BelongsTo
      */
@@ -198,7 +195,7 @@ class PdfFile extends TwillModel implements Sortable
     /**
      * @return Relations\BelongsToMany
      */
-    public function fileTags() : Relations\BelongsToMany
+    public function fileTags(): Relations\BelongsToMany
     {
         return $this->belongsToMany(
             FileTag::class,
@@ -355,10 +352,6 @@ class PdfFile extends TwillModel implements Sortable
     }
 
 
-
-
-
-
     /**
      * @return string
      * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
@@ -452,7 +445,7 @@ class PdfFile extends TwillModel implements Sortable
             'inline';
         $fs = Storage::cloud()->getDriver();
         $stream = $fs->readStream($this->binPath);
-        return \Response::stream(function() use ($stream) {
+        return \Response::stream(function () use ($stream) {
             fpassthru($stream);
         }, 200, [
             'Content-Type' => 'application/pdf',
@@ -462,13 +455,12 @@ class PdfFile extends TwillModel implements Sortable
     }
 
 
-
     /**
      * Processes pdf to json conversion for in-file search
      */
     public function makeJson(): void
     {
-        $tmp = sys_get_temp_dir().'/'.uniqid('json_', false);
+        $tmp = sys_get_temp_dir() . '/' . uniqid('json_', false);
 
         Pdf2Json::convert($this->absolutePdfPath, $tmp);
 
@@ -483,7 +475,7 @@ class PdfFile extends TwillModel implements Sortable
      */
     public function makeCover(): void
     {
-        $tmp = sys_get_temp_dir().'/'.uniqid('cover_', false);
+        $tmp = sys_get_temp_dir() . '/' . uniqid('cover_', false);
 
         Storage::disk('public')->makeDirectory('covers');
         $pdf = new PdfToImage\Pdf($this->absolutePdfPath);
@@ -492,7 +484,7 @@ class PdfFile extends TwillModel implements Sortable
             ->setColorspace(\Imagick::COLORSPACE_SRGB)
             ->saveImage($tmp);
 
-        $image =\Image::make($tmp);
+        $image = \Image::make($tmp);
         $image->interlace();
         $image->save(null, 50);
 
@@ -522,15 +514,15 @@ class PdfFile extends TwillModel implements Sortable
 
         $page_i = 0;
 
-        foreach(HtmlDomParser::str_get_html($html)->find('div.page') as $page){
+        foreach (HtmlDomParser::str_get_html($html)->find('div.page') as $page) {
             $page_i++;
 
             $buffer = "";
 
-            foreach ($page->find('p') as $paragraph){
+            foreach ($page->find('p') as $paragraph) {
 
                 $text = html_entity_decode($paragraph->plaintext);
-                if(empty($text))
+                if (empty($text))
                     continue;
 
                 $text = preg_replace('/^([A-Z]) /', '$1', $text);
@@ -538,7 +530,7 @@ class PdfFile extends TwillModel implements Sortable
 
                 $newBuffer = $buffer . ' ' . $text;
 
-                if(Str::length($newBuffer) > config('scout.text_max_length')) {
+                if (Str::length($newBuffer) > config('scout.text_max_length')) {
                     $result[] = [
                         'content' => $buffer,
                         'page' => $page_i,
@@ -588,8 +580,6 @@ class PdfFile extends TwillModel implements Sortable
     }
 
 
-
-
     /**
      * @return \Illuminate\View\View
      * Returns Flowpaper viewer
@@ -605,7 +595,6 @@ class PdfFile extends TwillModel implements Sortable
     }
 
 
-
     /**
      * @param array $tags
      * @return array
@@ -672,7 +661,6 @@ class PdfFile extends TwillModel implements Sortable
     }
 
 
-
     /**
      * @return string
      */
index 9a5689c6abcabd59a48c386bfb51e3373e4ea9b8..60b2d62867f78b182aea1eeced98f216c9a29a32 100644 (file)
@@ -15,9 +15,9 @@
         "anaseqal/nova-import": "^0.0.3",
         "area17/twill": "^2.13",
         "biscolab/laravel-recaptcha": "^5.4",
-        "laravel-lang/lang": "~6.0",
         "coderello/laravel-nova-lang": "^1.8",
         "fideloper/proxy": "^4.4",
+        "fluidbook/toolboxapiclient": "dev-master",
         "fruitcake/laravel-cors": "^1.0",
         "gabrieliuga/laravel-nova-field-iframe": "^1.0",
         "guzzlehttp/guzzle": "^7.8",
@@ -27,6 +27,7 @@
         "judev/php-htmltruncator": "^1.2",
         "kriswallsmith/buzz": "^1.2",
         "kub-at/php-simple-html-dom-parser": "^1.9",
+        "laravel-lang/lang": "~6.0",
         "laravel/cashier": "^12.17",
         "laravel/framework": "^8.83",
         "laravel/horizon": "^5.22",
index 0a1431bc713a2c11993c2050e708188afb54e674..1d5c64a17e3dd3a584062cad4b4ec4435d4d1822 100644 (file)
@@ -4,7 +4,7 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
         "This file is @generated automatically"
     ],
-    "content-hash": "8ddaa8dcd3422434c455762c3aa11a95",
+    "content-hash": "89c0ed662eb3c7c9603625f315066754",
     "packages": [
         {
             "name": "algolia/algoliasearch-client-php",
             },
             "time": "2024-05-18T18:05:11+00:00"
         },
+        {
+            "name": "fluidbook/toolboxapiclient",
+            "version": "dev-master",
+            "source": {
+                "type": "git",
+                "url": "git://git.cubedesigners.com/fluidbook_toolboxapiclient.git",
+                "reference": "1c85c844f895bcea6704ba5994bbd628e3fecfd7"
+            },
+            "dist": {
+                "type": "tar",
+                "url": "https://composer.cubedesigners.com/dist/fluidbook/toolboxapiclient/fluidbook-toolboxapiclient-dev-master-ed747c.tar",
+                "reference": "1c85c844f895bcea6704ba5994bbd628e3fecfd7",
+                "shasum": "c7bd286e5ea4f134b18b408ae01ee7625185e64f"
+            },
+            "require": {
+                "ext-json": "*",
+                "guzzlehttp/guzzle": "^7.0|^8.0",
+                "illuminate/cache": ">=5",
+                "php": "^7.2|>=8.0"
+            },
+            "default-branch": true,
+            "type": "library",
+            "autoload": {
+                "psr-4": {
+                    "Fluidbook\\ToolboxApiClient\\": "src"
+                }
+            },
+            "license": [
+                "proprietary"
+            ],
+            "authors": [
+                {
+                    "name": "Vincent Vanwaelscappel",
+                    "email": "vincent@cubedesigners.com"
+                }
+            ],
+            "description": "Fluidbook Toolbox API Client",
+            "time": "2024-10-29T13:37:45+00:00"
+        },
         {
             "name": "fruitcake/laravel-cors",
             "version": "v1.0.6",
     ],
     "aliases": [],
     "minimum-stability": "dev",
-    "stability-flags": {},
+    "stability-flags": {
+        "fluidbook/toolboxapiclient": 20
+    },
     "prefer-stable": true,
     "prefer-lowest": false,
     "platform": {
         "ext-dom": "*",
         "ext-json": "*"
     },
-    "platform-dev": {},
+    "platform-dev": [],
     "plugin-api-version": "2.6.0"
 }
index 45ea10d0e0c25b79b229c46b14f6fae2534810a7..551cc93f54fb4d5857280db2bc97ca68c27b3c96 100644 (file)
@@ -125,7 +125,7 @@ return [
 
     'aws_s3_url' => 'https://prescription-sante.s3.eu-west-3.amazonaws.com',
 
-    'version' => '0.12.0',
+    'version' => '1.0.0',
 
     'emails' => [
         'subscriptions' => 'abonnement@prescription-quotidien.com',
index b03427a26fee5047f767323c7f5cdbffe51551cd..2fc1b88592c4ea08623ee0001d9e7c984da9e093 100644 (file)
   "Inter-MediumItalic.woff2": "/assets/admin/fonts/Inter-MediumItalic.7a7fd735.woff2",
   "Inter-Regular.woff": "/assets/admin/fonts/Inter-Regular.aebfbb3c.woff",
   "Inter-Regular.woff2": "/assets/admin/fonts/Inter-Regular.bffaed79.woff2",
-  "chunk-common.css": "/assets/admin/css/chunk-common.f96d24c0.css",
-  "chunk-common.js": "/assets/admin/js/chunk-common.bba8d01c.js",
+  "chunk-common.css": "/assets/admin/css/chunk-common.d139ed58.css",
+  "chunk-common.js": "/assets/admin/js/chunk-common.b799ff44.js",
   "chunk-vendors.css": "/assets/admin/css/chunk-vendors.e0f3ef32.css",
-  "chunk-vendors.js": "/assets/admin/js/chunk-vendors.4e27789c.js",
-  "icons-files.svg": "/assets/admin/icons/icons-files.3cdbddfb2725088d.svg",
-  "icons-wysiwyg.svg": "/assets/admin/icons/icons-wysiwyg.63f0e2d625dc615e.svg",
-  "icons.svg": "/assets/admin/icons/icons.2ee8758aafe79e18.svg",
-  "main-buckets.css": "/assets/admin/css/main-buckets.b3760912.css",
-  "main-buckets.js": "/assets/admin/js/main-buckets.92f160f6.js",
-  "main-dashboard.css": "/assets/admin/css/main-dashboard.27f5455a.css",
-  "main-dashboard.js": "/assets/admin/js/main-dashboard.6a45e917.js",
-  "main-form.css": "/assets/admin/css/main-form.067002ed.css",
-  "main-form.js": "/assets/admin/js/main-form.b94d7eae.js",
-  "main-free.js": "/assets/admin/js/main-free.6761fc8a.js",
-  "main-listing.css": "/assets/admin/css/main-listing.77e7845a.css",
-  "main-listing.js": "/assets/admin/js/main-listing.6728fcc5.js"
+  "chunk-vendors.js": "/assets/admin/js/chunk-vendors.3abec3c2.js",
+  "icons-files.php": "/views/partials/icons/icons-files-svg.blade.php",
+  "icons-wysiwyg.php": "/views/partials/icons/icons-wysiwyg-svg.blade.php",
+  "icons.php": "/views/partials/icons/icons-svg.blade.php",
+  "main-buckets.css": "/assets/admin/css/main-buckets.4476e8eb.css",
+  "main-buckets.js": "/assets/admin/js/main-buckets.dba3a77a.js",
+  "main-dashboard.css": "/assets/admin/css/main-dashboard.cc2042d4.css",
+  "main-dashboard.js": "/assets/admin/js/main-dashboard.9bc70e5f.js",
+  "main-form.css": "/assets/admin/css/main-form.59d434eb.css",
+  "main-form.js": "/assets/admin/js/main-form.c5d69e0c.js",
+  "main-free.js": "/assets/admin/js/main-free.e5d8b918.js",
+  "main-listing.css": "/assets/admin/css/main-listing.4c860d28.css",
+  "main-listing.js": "/assets/admin/js/main-listing.6c46b3b2.js"
 }
\ No newline at end of file
index e0ebccfd62dd249406b94c532d915b23e8549a95..8bc92b553938702fa0419cf08f1cdadb31ac06a4 100644 (file)
@@ -1,7 +1,7 @@
 @include('twill::partials.toaster')
 <footer class="footer">
     <div class="container">
-        <span class="footer__copyright">Made by Louis Jeckel for OPRA Editing</span>
+        <span class="footer__copyright"></span>
         <span class="footer__version">Version {{config('app.version')}}</span>
     </div>
 </footer>