From 2d08f6d42818a17b46a1b02fe56759ac1e6a8941 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Wed, 12 Mar 2025 17:58:03 +0100 Subject: [PATCH] wip #7386 @1 --- .docker/production/docker-compose.yml | 2 +- .idea/lettre-pharma.iml | 3 + .idea/php.xml | 4 +- app/PdfFile.php | 11 +- composer.json | 3 +- composer.lock | 160 ++++++++++++++++++++++++-- config/app.php | 4 +- config/scout.php | 26 ++++- 8 files changed, 196 insertions(+), 17 deletions(-) diff --git a/.docker/production/docker-compose.yml b/.docker/production/docker-compose.yml index 88ea33a..764421b 100644 --- a/.docker/production/docker-compose.yml +++ b/.docker/production/docker-compose.yml @@ -156,7 +156,7 @@ services: typesense: container_name: presquot-typesense - image: typesense/typesense:28.0 + image: typesense/typesense:26.0 restart: unless-stopped volumes: - ./typesense:/data diff --git a/.idea/lettre-pharma.iml b/.idea/lettre-pharma.iml index 1b78ddc..0725d12 100644 --- a/.idea/lettre-pharma.iml +++ b/.idea/lettre-pharma.iml @@ -103,6 +103,9 @@ + + + diff --git a/.idea/php.xml b/.idea/php.xml index 301ef15..9d97bcf 100644 --- a/.idea/php.xml +++ b/.idea/php.xml @@ -166,7 +166,6 @@ - @@ -233,7 +232,10 @@ + + + diff --git a/app/PdfFile.php b/app/PdfFile.php index be90f61..d865db0 100644 --- a/app/PdfFile.php +++ b/app/PdfFile.php @@ -67,6 +67,7 @@ class PdfFile extends TwillModel implements Sortable ]; protected $fillable = [ + 'fluidbook', 'free', 'position', 'title', @@ -80,7 +81,8 @@ class PdfFile extends TwillModel implements Sortable ]; protected $casts = [ - 'is_free' => 'bool', + 'is_fluidbook' => 'bool', + 'fluidbook' => 'bool', 'headlines' => 'array', ]; @@ -107,6 +109,7 @@ class PdfFile extends TwillModel implements Sortable 'slug' => Str::slug("{$collection->slug}_{$ref}"), 'published' => 0, 'collection_id' => $collection_id, + 'fluidbook' => true, ], [ 'ref' => $ref, @@ -135,7 +138,7 @@ 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); + $client->createFluidbook(new \SplFileInfo($this->absolutePdfPath), env('FLUIDBOOK_TOOLBOX_BASE_FLUIDBOOK'), $this->title, env('FLUIDBOOK_TOOLBOX_EXTERNAL_SERVER'), 'PSQ-' . $this->ref); // \Log::debug('json'); // $this->makeJson(); @@ -243,7 +246,9 @@ class PdfFile extends TwillModel implements Sortable */ public function getDirectoryAttribute(): string { - return "flowpaper/$this->slug"; + $dir = $this->fluidbook ? 'fluidbook' : 'flowpaper'; + return "$dir/$this->slug"; + } diff --git a/composer.json b/composer.json index f430f01..f158485 100644 --- a/composer.json +++ b/composer.json @@ -42,6 +42,7 @@ "masterminds/html5": "^2.9", "numaxlab/nova-ckeditor5-classic": "^1.1", "nyholm/psr7": "^1.8", + "php-http/guzzle7-adapter": "^1.1", "php-http/message-factory": "^1.1", "psq/psq-theme": "*", "pusher/pusher-php-server": "~4.1", @@ -50,7 +51,7 @@ "spatie/pdf-to-image": "^2.3", "spatie/pdf-to-text": "^1.53", "stripe/stripe-php": "^7.128", - "typesense/typesense-php": "^5.0", + "typesense/laravel-scout-typesense-driver": "^5.2", "vaites/php-apache-tika": "^v1.3" }, "require-dev": { diff --git a/composer.lock b/composer.lock index ea79b6f..85f047a 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": "ab7ec931421b0512e82bf2ec89f13d39", + "content-hash": "74f5ff2baf2220129295faabc3c4dbc7", "packages": [ { "name": "algolia/algoliasearch-client-php", @@ -6954,6 +6954,65 @@ }, "time": "2024-10-02T11:20:13+00:00" }, + { + "name": "php-http/guzzle7-adapter", + "version": "1.1.0", + "source": { + "type": "git", + "url": "https://github.com/php-http/guzzle7-adapter.git", + "reference": "03a415fde709c2f25539790fecf4d9a31bc3d0eb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-http/guzzle7-adapter/zipball/03a415fde709c2f25539790fecf4d9a31bc3d0eb", + "reference": "03a415fde709c2f25539790fecf4d9a31bc3d0eb", + "shasum": "" + }, + "require": { + "guzzlehttp/guzzle": "^7.0", + "php": "^7.3 | ^8.0", + "php-http/httplug": "^2.0", + "psr/http-client": "^1.0" + }, + "provide": { + "php-http/async-client-implementation": "1.0", + "php-http/client-implementation": "1.0", + "psr/http-client-implementation": "1.0" + }, + "require-dev": { + "php-http/client-integration-tests": "^3.0", + "php-http/message-factory": "^1.1", + "phpspec/prophecy-phpunit": "^2.0", + "phpunit/phpunit": "^8.0|^9.3" + }, + "type": "library", + "autoload": { + "psr-4": { + "Http\\Adapter\\Guzzle7\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Tobias Nyholm", + "email": "tobias.nyholm@gmail.com" + } + ], + "description": "Guzzle 7 HTTP Adapter", + "homepage": "http://httplug.io", + "keywords": [ + "Guzzle", + "http" + ], + "support": { + "issues": "https://github.com/php-http/guzzle7-adapter/issues", + "source": "https://github.com/php-http/guzzle7-adapter/tree/1.1.0" + }, + "time": "2024-11-26T11:14:36+00:00" + }, { "name": "php-http/httplug", "version": "2.4.1", @@ -12164,18 +12223,105 @@ }, "time": "2024-12-21T16:25:41+00:00" }, + { + "name": "typesense/laravel-scout-typesense-driver", + "version": "v5.2.9", + "source": { + "type": "git", + "url": "https://github.com/typesense/laravel-scout-typesense-driver.git", + "reference": "2032523072a10d5afd12108e2975ba4bc6edb504" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/typesense/laravel-scout-typesense-driver/zipball/2032523072a10d5afd12108e2975ba4bc6edb504", + "reference": "2032523072a10d5afd12108e2975ba4bc6edb504", + "shasum": "" + }, + "require": { + "illuminate/bus": "^7.0|^8.0|^9.0|^10.0|^11.0", + "illuminate/contracts": "^7.0|^8.0|^9.0|^10.0|^11.0", + "illuminate/database": "^7.0|^8.0|^9.0|^10.0|^11.0", + "illuminate/pagination": "^7.0|^8.0|^9.0|^10.0|^11.0", + "illuminate/queue": "^7.0|^8.0|^9.0|^10.0|^11.0", + "illuminate/support": "^7.0|^8.0|^9.0|^10.0|^11.0", + "laravel/scout": "^8.0|^9.0|^10.0", + "php": "^8.0", + "typesense/typesense-php": "^4.2" + }, + "require-dev": { + "mockery/mockery": "^1.3", + "orchestra/testbench": "^6.17|^7.0|^8.0|^9.0", + "phpunit/phpunit": "^8.0|^9.0|^10.5", + "symfony/http-client": "^5.4|^7.0" + }, + "suggest": { + "typesense/typesense-php": "Required to use the Typesense php client." + }, + "type": "library", + "extra": { + "laravel": { + "aliases": { + "Typesense": "Typesense\\LaravelTypesense\\TypesenseFacade" + }, + "providers": [ + "Typesense\\LaravelTypesense\\TypesenseServiceProvider" + ] + } + }, + "autoload": { + "psr-4": { + "Typesense\\LaravelTypesense\\": "src/", + "Typesense\\LaravelTypesense\\Tests\\": "tests/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Abdullah Al-Faqeir", + "email": "abdullah@devloops.net", + "homepage": "https://www.devloops.net", + "role": "Developer" + }, + { + "name": "hi019", + "homepage": "https://github.com/hi019", + "role": "Developer" + } + ], + "description": "Laravel Scout Driver for Typesense", + "homepage": "https://typesense.org", + "keywords": [ + "laravel", + "search", + "typesense" + ], + "support": { + "issues": "https://github.com/typesense/laravel-scout-typesense-driver/issues", + "source": "https://github.com/typesense/laravel-scout-typesense-driver/tree/v5.2.9" + }, + "funding": [ + { + "url": "https://github.com/typesense", + "type": "github" + } + ], + "time": "2024-04-07T13:33:52+00:00" + }, { "name": "typesense/typesense-php", - "version": "v5.0.2", + "version": "v4.9.3", "source": { "type": "git", "url": "https://github.com/typesense/typesense-php.git", - "reference": "513270e6a124101c25b03ee27598efd6b87fbec0" + "reference": "50fc2089ff4829c8e0e11d8c674e9da085b49998" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/typesense/typesense-php/zipball/513270e6a124101c25b03ee27598efd6b87fbec0", - "reference": "513270e6a124101c25b03ee27598efd6b87fbec0", + "url": "https://api.github.com/repos/typesense/typesense-php/zipball/50fc2089ff4829c8e0e11d8c674e9da085b49998", + "reference": "50fc2089ff4829c8e0e11d8c674e9da085b49998", "shasum": "" }, "require": { @@ -12191,8 +12337,6 @@ "psr/http-message": "^1.0 || ^2.0" }, "require-dev": { - "mockery/mockery": "^1.6", - "phpunit/phpunit": "^11.2", "squizlabs/php_codesniffer": "3.*", "symfony/http-client": "^5.2" }, @@ -12233,7 +12377,7 @@ "type": "github" } ], - "time": "2025-02-24T21:13:28+00:00" + "time": "2024-04-29T15:34:34+00:00" }, { "name": "vaites/php-apache-tika", diff --git a/config/app.php b/config/app.php index 551cc93..d2cd974 100644 --- a/config/app.php +++ b/config/app.php @@ -182,11 +182,13 @@ return [ */ App\Providers\AppServiceProvider::class, App\Providers\AuthServiceProvider::class, - App\Providers\BroadcastServiceProvider::class, + App\Providers\BroadcastServiceProvider::class, App\Providers\EventServiceProvider::class, App\Providers\HorizonServiceProvider::class, App\Providers\NovaServiceProvider::class, App\Providers\RouteServiceProvider::class, + Typesense\LaravelTypesense\TypesenseServiceProvider::class, + Laravel\Scout\ScoutServiceProvider::class, ], diff --git a/config/scout.php b/config/scout.php index 0ebbbf5..be69739 100644 --- a/config/scout.php +++ b/config/scout.php @@ -86,9 +86,31 @@ return [ */ 'algolia' => [ - 'id' => env('ALGOLIA_APP_ID', '2DN9N2PQBK'), - 'secret' => env('ALGOLIA_SECRET', '8a1916ad1188b1b570cb85a43e5be2fa'), + 'id' => env('ALGOLIA_APP_ID', ''), + 'secret' => env('ALGOLIA_SECRET', ''), 'search_key' => env('ALGOLIA_SEARCH_KEY'), ], + 'typesense' => [ + 'api_key' => env('TYPESENSE_API_KEY', 'xyz'), + 'nodes' => [ + [ + 'host' => env('TYPESENSE_HOST', 'localhost'), + 'port' => env('TYPESENSE_PORT', '8108'), + 'path' => env('TYPESENSE_PATH', ''), + 'protocol' => env('TYPESENSE_PROTOCOL', 'http'), + ], + ], + 'nearest_node' => [ + 'host' => env('TYPESENSE_HOST', 'localhost'), + 'port' => env('TYPESENSE_PORT', '8108'), + 'path' => env('TYPESENSE_PATH', ''), + 'protocol' => env('TYPESENSE_PROTOCOL', 'http'), + ], + 'connection_timeout_seconds' => 2, + 'healthcheck_interval_seconds' => 30, + 'num_retries' => 3, + 'retry_interval_seconds' => 1, + ], + ]; -- 2.39.5