From: Vincent Vanwaelscappel Date: Thu, 31 Oct 2024 14:51:37 +0000 (+0100) Subject: wip #7062 @14 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=75038dd3d8f3a4d2de409db68ecc8ae177588ef7;p=psq.git wip #7062 @14 --- diff --git a/.env.production b/.env.production index d23eeb0..2d94bc7 100644 --- a/.env.production +++ b/.env.production @@ -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 diff --git a/.idea/lettre-pharma.iml b/.idea/lettre-pharma.iml index 3d8e6a5..1b78ddc 100644 --- a/.idea/lettre-pharma.iml +++ b/.idea/lettre-pharma.iml @@ -102,6 +102,7 @@ + diff --git a/.idea/php.xml b/.idea/php.xml index 2c35b7d..c0792a8 100644 --- a/.idea/php.xml +++ b/.idea/php.xml @@ -232,6 +232,7 @@ + diff --git a/app/Jobs/ProcessPdfFile.php b/app/Jobs/ProcessPdfFile.php index 613fdce..5c3629f 100644 --- a/app/Jobs/ProcessPdfFile.php +++ b/app/Jobs/ProcessPdfFile.php @@ -22,8 +22,6 @@ class ProcessPdfFile implements ShouldQueue public $timeout = 180; - - /** * Create a new job instance. * diff --git a/app/PdfFile.php b/app/PdfFile.php index 6938170..be90f61 100644 --- a/app/PdfFile.php +++ b/app/PdfFile.php @@ -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 */ diff --git a/composer.json b/composer.json index 9a5689c..60b2d62 100644 --- a/composer.json +++ b/composer.json @@ -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", diff --git a/composer.lock b/composer.lock index 0a1431b..1d5c64a 100644 --- a/composer.lock +++ b/composer.lock @@ -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", @@ -2065,6 +2065,45 @@ }, "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", @@ -15210,7 +15249,9 @@ ], "aliases": [], "minimum-stability": "dev", - "stability-flags": {}, + "stability-flags": { + "fluidbook/toolboxapiclient": 20 + }, "prefer-stable": true, "prefer-lowest": false, "platform": { @@ -15218,6 +15259,6 @@ "ext-dom": "*", "ext-json": "*" }, - "platform-dev": {}, + "platform-dev": [], "plugin-api-version": "2.6.0" } diff --git a/config/app.php b/config/app.php index 45ea10d..551cc93 100644 --- a/config/app.php +++ b/config/app.php @@ -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', diff --git a/public/assets/admin/twill-manifest.json b/public/assets/admin/twill-manifest.json index b03427a..2fc1b88 100644 --- a/public/assets/admin/twill-manifest.json +++ b/public/assets/admin/twill-manifest.json @@ -11,20 +11,20 @@ "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 diff --git a/resources/views/vendor/twill/partials/footer.blade.php b/resources/views/vendor/twill/partials/footer.blade.php index e0ebccf..8bc92b5 100644 --- a/resources/views/vendor/twill/partials/footer.blade.php +++ b/resources/views/vendor/twill/partials/footer.blade.php @@ -1,7 +1,7 @@ @include('twill::partials.toaster')