From ff6b0149a328c426b876720f7b1f4a9e84cf269f Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Tue, 15 Jul 2025 16:51:48 +0200 Subject: [PATCH] wip #7556 @1 --- app/Fluidbook/Farm.php | 56 ++--------- app/Models/FluidbookDocument.php | 4 + composer.lock | 168 +++++++++++++++---------------- 3 files changed, 99 insertions(+), 129 deletions(-) diff --git a/app/Fluidbook/Farm.php b/app/Fluidbook/Farm.php index fb04208aa..b0a0986c3 100644 --- a/app/Fluidbook/Farm.php +++ b/app/Fluidbook/Farm.php @@ -192,7 +192,7 @@ class Farm if ((!$res || !file_exists($res)) && $attempts > 0) { Cache::forget($cachekey); - return self::getFileFromPDF($pdf, $page, $format, $resolution, $quality, $withText, $withGraphics,$transparent, $version, $out, true, $attempts - 1); + return self::getFileFromPDF($pdf, $page, $format, $resolution, $quality, $withText, $withGraphics, $transparent, $version, $out, true, $attempts - 1); } return $res; @@ -281,6 +281,16 @@ class Farm }); } + public static function extractMarkdown($pdf, $out) + { + return static::lock($pdf, 'md', function () use ($pdf, $out) { + return self::_getFile( + ['operation' => 'extractmarkdown', + 'pdf' => $pdf, + 'out' => $out], 0, false); + }); + } + public static function extractHighlightsData($pdf, $out, $mode, $ignoreSeparators) { return static::lock($pdf, 'texts_' . $mode . '_' . md5($ignoreSeparators), function () use ($pdf, $out, $mode, $ignoreSeparators) { @@ -390,50 +400,6 @@ class Farm file_put_contents($cache, json_encode($pings)); file_put_contents(self::_serversCache(), json_encode($servers)); } - - public static function ping2($echo = true, $force = false) - { - $cache = self::_ping2Cache(); - $servers = self::getServers(); - $pings = []; - if (file_exists($cache)) { - $cached = json_decode(file_get_contents($cache)); - if (is_countable($cached) && count($cached) === count($servers)) { - $pings = $cached; - } - } - - foreach ($servers as $id => $farmer) { - if ($echo) { - echo $farmer['name'] . ' (' . $id . ') || '; - } - if (isset($pings[$id]) && !$pings[$id]) { - // If ping failed recently, we wait a bit before trying again. - if (!$force && rand(0, 9) != 5) { - if ($echo) { - echo 'Skipped, will try again soon' . "\n"; - } - continue; - } - } - try { - $res = self::sendRequest($farmer, 'ping2.php', [], 5); - $res = json_decode($res, true); - $ok = $res['status'] == "1"; - } catch (\Exception $e) { - $res = $e->getMessage(); - $ok = false; - } - - if ($echo) { - echo ($ok ? 'OK' : 'KO') . ' : ' . json_encode($res) . "\n"; - } - - $pings[$id] = $res; - } - file_put_contents($cache, json_encode($pings)); - file_put_contents(self::_serversCache(), json_encode($servers)); - } } diff --git a/app/Models/FluidbookDocument.php b/app/Models/FluidbookDocument.php index 2eb9d60a1..cf51ce0b3 100644 --- a/app/Models/FluidbookDocument.php +++ b/app/Models/FluidbookDocument.php @@ -152,6 +152,10 @@ class FluidbookDocument extends ToolboxModel Farm::extractHighlightsData($this->getPDFSource(), $this->path(), 'standard', ''); } + public function extractMarkdown(){ + Farm::extractMarkdown($this->getPDFSource(),$this->path()); + } + public function extractLinks() { Farm::extractLinks($this->getPDFSource(), $this->path()); diff --git a/composer.lock b/composer.lock index 10a99c40e..5c65b9090 100644 --- a/composer.lock +++ b/composer.lock @@ -1182,12 +1182,12 @@ "source": { "type": "git", "url": "https://github.com/chillerlan/php-qrcode.git", - "reference": "48747ae5b4db7a66acdcc6bc6e2a36069171e4f0" + "reference": "daf01b96b20ed8a98a70ced71f63ac01d5598df0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/chillerlan/php-qrcode/zipball/48747ae5b4db7a66acdcc6bc6e2a36069171e4f0", - "reference": "48747ae5b4db7a66acdcc6bc6e2a36069171e4f0", + "url": "https://api.github.com/repos/chillerlan/php-qrcode/zipball/daf01b96b20ed8a98a70ced71f63ac01d5598df0", + "reference": "daf01b96b20ed8a98a70ced71f63ac01d5598df0", "shasum": "" }, "require": { @@ -1201,12 +1201,12 @@ "intervention/image": "^3.11", "phpbench/phpbench": "^1.4", "phpmd/phpmd": "^2.15", - "phpstan/phpstan": "^2.1.13", + "phpstan/phpstan": "^2.1.17", "phpstan/phpstan-deprecation-rules": "^2.0", "phpunit/phpunit": "^11.5", "setasign/fpdf": "^1.8.6", - "slevomat/coding-standard": "^8.15", - "squizlabs/php_codesniffer": "^3.12" + "slevomat/coding-standard": "^8.19", + "squizlabs/php_codesniffer": "^3.13" }, "suggest": { "chillerlan/php-authenticator": "Yet another Google authenticator! Also creates URIs for mobile apps.", @@ -1271,7 +1271,7 @@ "type": "Ko-Fi" } ], - "time": "2025-05-01T14:19:25+00:00" + "time": "2025-06-16T16:47:48+00:00" }, { "name": "chillerlan/php-settings-container", @@ -1918,13 +1918,13 @@ "source": { "type": "git", "url": "git://git.cubedesigners.com/cubist_azuretts.git", - "reference": "f36843bc3f2f39746a2765d9e2304bb1e78cbe20" + "reference": "9730f8d9100cd2a3b225bc1d12247ec589bbea2b" }, "dist": { "type": "tar", - "url": "https://composer.cubedesigners.com/dist/cubist/azuretts/cubist-azuretts-dev-master-f765d1.tar", - "reference": "f36843bc3f2f39746a2765d9e2304bb1e78cbe20", - "shasum": "203f3bb7c1a914cc9f57cedb3fd2f7205f856c78" + "url": "https://composer.cubedesigners.com/dist/cubist/azuretts/cubist-azuretts-dev-master-65ab8d.tar", + "reference": "9730f8d9100cd2a3b225bc1d12247ec589bbea2b", + "shasum": "0286bfeb4ee4ca65d26f011884a127c292bcb878" }, "require": { "ext-json": "*", @@ -1953,7 +1953,7 @@ } ], "description": "Azure TTS REST API", - "time": "2023-06-14T07:42:06+00:00" + "time": "2025-06-23T14:13:55+00:00" }, { "name": "cubist/cms-back", @@ -1961,13 +1961,13 @@ "source": { "type": "git", "url": "git://git.cubedesigners.com/cubist_cms-back.git", - "reference": "35e61c0b1c01e1d063ccf10dd1e80ec8c9560661" + "reference": "cef4e4c317a6d33040ce2e45cf342782a3a43237" }, "dist": { "type": "tar", - "url": "https://composer.cubedesigners.com/dist/cubist/cms-back/cubist-cms-back-dev-master-c32f46.tar", - "reference": "35e61c0b1c01e1d063ccf10dd1e80ec8c9560661", - "shasum": "3403ec93a742ed641a25a41e05ca2b790ca0238d" + "url": "https://composer.cubedesigners.com/dist/cubist/cms-back/cubist-cms-back-dev-master-783028.tar", + "reference": "cef4e4c317a6d33040ce2e45cf342782a3a43237", + "shasum": "ca26abbbe5790d1e7bd7cea08b33c7bd2bdf5e40" }, "require": { "backpack/backupmanager": "^v3.0.9", @@ -2046,7 +2046,7 @@ } ], "description": "Cubist Backpack extension", - "time": "2025-06-02T13:52:18+00:00" + "time": "2025-06-16T11:05:49+00:00" }, { "name": "cubist/cms-front", @@ -2347,13 +2347,13 @@ "source": { "type": "git", "url": "git://git.cubedesigners.com/cubist_net.git", - "reference": "8fd1b7b37c92c49aa919854ea9d783a54e401057" + "reference": "e52d890162300b395e768fbc10961ea83285c573" }, "dist": { "type": "tar", - "url": "https://composer.cubedesigners.com/dist/cubist/net/cubist-net-dev-master-8a3e5c.tar", - "reference": "8fd1b7b37c92c49aa919854ea9d783a54e401057", - "shasum": "0fb1307453c3bdc0e3a35ad4f0e78f001c214ede" + "url": "https://composer.cubedesigners.com/dist/cubist/net/cubist-net-dev-master-24d80a.tar", + "reference": "e52d890162300b395e768fbc10961ea83285c573", + "shasum": "58602dd35a546905d49b823c93784728dbbe5590" }, "require": { "aws/aws-sdk-php": "^3.325", @@ -2381,7 +2381,7 @@ } ], "description": "net cubist composer package", - "time": "2025-06-02T15:21:43+00:00" + "time": "2025-06-04T12:42:45+00:00" }, { "name": "cubist/pdf", @@ -2439,13 +2439,13 @@ "source": { "type": "git", "url": "git://git.cubedesigners.com/cubist_scorm.git", - "reference": "1ff6427105048123dfa93cca178c0d7aa4363f3c" + "reference": "14fe1cf16c91054db70c09f76eab9cb10d5ec75d" }, "dist": { "type": "tar", - "url": "https://composer.cubedesigners.com/dist/cubist/scorm/cubist-scorm-dev-master-afa568.tar", - "reference": "1ff6427105048123dfa93cca178c0d7aa4363f3c", - "shasum": "8fbfa91642ab4bf56ad21c2a9750aefb5304cfbd" + "url": "https://composer.cubedesigners.com/dist/cubist/scorm/cubist-scorm-dev-master-904bd2.tar", + "reference": "14fe1cf16c91054db70c09f76eab9cb10d5ec75d", + "shasum": "b255c9c0710bc59f6ffa8d6efcbe855820d6a69e" }, "require": { "ext-mbstring": "*", @@ -2468,7 +2468,7 @@ } ], "description": "cubist_scorm", - "time": "2023-09-22T15:45:05+00:00" + "time": "2025-06-06T10:40:43+00:00" }, { "name": "cubist/util", @@ -2476,13 +2476,13 @@ "source": { "type": "git", "url": "git://git.cubedesigners.com/cubist_util.git", - "reference": "71120d11d7dd1752141999aa364cf66b63392feb" + "reference": "5dccc705639a1cb2725116331e062cb0f0ca3fca" }, "dist": { "type": "tar", - "url": "https://composer.cubedesigners.com/dist/cubist/util/cubist-util-dev-master-8d0c24.tar", - "reference": "71120d11d7dd1752141999aa364cf66b63392feb", - "shasum": "eaa16d45929ff29fcab17170332612ce974dbab5" + "url": "https://composer.cubedesigners.com/dist/cubist/util/cubist-util-dev-master-c849fa.tar", + "reference": "5dccc705639a1cb2725116331e062cb0f0ca3fca", + "shasum": "d4f86e0829922835a97110ae6c4f9e614b87f14f" }, "require": { "cubist/net": "dev-master", @@ -2516,7 +2516,7 @@ } ], "description": "Utilities class", - "time": "2025-06-02T15:18:05+00:00" + "time": "2025-06-12T14:50:04+00:00" }, { "name": "cviebrock/eloquent-sluggable", @@ -3007,16 +3007,16 @@ }, { "name": "doctrine/dbal", - "version": "3.9.4", + "version": "3.9.5", "source": { "type": "git", "url": "https://github.com/doctrine/dbal.git", - "reference": "ec16c82f20be1a7224e65ac67144a29199f87959" + "reference": "4a4e2eed3134036ee36a147ee0dac037dfa17868" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/dbal/zipball/ec16c82f20be1a7224e65ac67144a29199f87959", - "reference": "ec16c82f20be1a7224e65ac67144a29199f87959", + "url": "https://api.github.com/repos/doctrine/dbal/zipball/4a4e2eed3134036ee36a147ee0dac037dfa17868", + "reference": "4a4e2eed3134036ee36a147ee0dac037dfa17868", "shasum": "" }, "require": { @@ -3029,14 +3029,14 @@ "psr/log": "^1|^2|^3" }, "require-dev": { - "doctrine/coding-standard": "12.0.0", + "doctrine/coding-standard": "13.0.0", "fig/log-test": "^1", "jetbrains/phpstorm-stubs": "2023.1", - "phpstan/phpstan": "2.1.1", + "phpstan/phpstan": "2.1.17", "phpstan/phpstan-strict-rules": "^2", - "phpunit/phpunit": "9.6.22", - "slevomat/coding-standard": "8.13.1", - "squizlabs/php_codesniffer": "3.10.2", + "phpunit/phpunit": "9.6.23", + "slevomat/coding-standard": "8.16.2", + "squizlabs/php_codesniffer": "3.13.1", "symfony/cache": "^5.4|^6.0|^7.0", "symfony/console": "^4.4|^5.4|^6.0|^7.0" }, @@ -3098,7 +3098,7 @@ ], "support": { "issues": "https://github.com/doctrine/dbal/issues", - "source": "https://github.com/doctrine/dbal/tree/3.9.4" + "source": "https://github.com/doctrine/dbal/tree/3.9.5" }, "funding": [ { @@ -3114,7 +3114,7 @@ "type": "tidelift" } ], - "time": "2025-01-16T08:28:55+00:00" + "time": "2025-06-15T22:40:05+00:00" }, { "name": "doctrine/deprecations", @@ -4174,13 +4174,13 @@ "source": { "type": "git", "url": "git://git.cubedesigners.com/fluidbook_tools.git", - "reference": "108bbb7ee6a89118bc4002b6a11beca61df75ba1" + "reference": "3d5355494c46d3293d9149c1ead43fded1c59a38" }, "dist": { "type": "tar", - "url": "https://composer.cubedesigners.com/dist/fluidbook/tools/fluidbook-tools-dev-master-4be04d.tar", - "reference": "108bbb7ee6a89118bc4002b6a11beca61df75ba1", - "shasum": "963cf74f90d4af40ffdd1254fec765142c0c6daf" + "url": "https://composer.cubedesigners.com/dist/fluidbook/tools/fluidbook-tools-dev-master-9d23f7.tar", + "reference": "3d5355494c46d3293d9149c1ead43fded1c59a38", + "shasum": "c9c64978defe671276e92a566d4d59ba0a701fd0" }, "require": { "barryvdh/laravel-debugbar": "*", @@ -4216,7 +4216,7 @@ } ], "description": "Fluidbook Tools", - "time": "2025-05-27T08:41:47+00:00" + "time": "2025-06-19T14:24:40+00:00" }, { "name": "fpdf/fpdf", @@ -4405,16 +4405,16 @@ }, { "name": "google/cloud-core", - "version": "v1.62.3", + "version": "v1.63.0", "source": { "type": "git", "url": "https://github.com/googleapis/google-cloud-php-core.git", - "reference": "0c19d76e7f3b6810c4f2cc1330c693af2681c601" + "reference": "14461f7b53b261caeed7174f9d704d10881b02c2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/googleapis/google-cloud-php-core/zipball/0c19d76e7f3b6810c4f2cc1330c693af2681c601", - "reference": "0c19d76e7f3b6810c4f2cc1330c693af2681c601", + "url": "https://api.github.com/repos/googleapis/google-cloud-php-core/zipball/14461f7b53b261caeed7174f9d704d10881b02c2", + "reference": "14461f7b53b261caeed7174f9d704d10881b02c2", "shasum": "" }, "require": { @@ -4465,9 +4465,9 @@ ], "description": "Google Cloud PHP shared dependency, providing functionality useful to all components.", "support": { - "source": "https://github.com/googleapis/google-cloud-php-core/tree/v1.62.3" + "source": "https://github.com/googleapis/google-cloud-php-core/tree/v1.63.0" }, - "time": "2025-05-20T19:49:54+00:00" + "time": "2025-06-13T20:36:13+00:00" }, { "name": "google/cloud-storage", @@ -7931,16 +7931,16 @@ }, { "name": "nette/utils", - "version": "v4.0.6", + "version": "v4.0.7", "source": { "type": "git", "url": "https://github.com/nette/utils.git", - "reference": "ce708655043c7050eb050df361c5e313cf708309" + "reference": "e67c4061eb40b9c113b218214e42cb5a0dda28f2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nette/utils/zipball/ce708655043c7050eb050df361c5e313cf708309", - "reference": "ce708655043c7050eb050df361c5e313cf708309", + "url": "https://api.github.com/repos/nette/utils/zipball/e67c4061eb40b9c113b218214e42cb5a0dda28f2", + "reference": "e67c4061eb40b9c113b218214e42cb5a0dda28f2", "shasum": "" }, "require": { @@ -8011,9 +8011,9 @@ ], "support": { "issues": "https://github.com/nette/utils/issues", - "source": "https://github.com/nette/utils/tree/v4.0.6" + "source": "https://github.com/nette/utils/tree/v4.0.7" }, - "time": "2025-03-30T21:06:30+00:00" + "time": "2025-06-03T04:55:08+00:00" }, { "name": "norkunas/youtube-dl-php", @@ -9199,16 +9199,16 @@ }, { "name": "phpoffice/phpspreadsheet", - "version": "1.29.10", + "version": "1.29.11", "source": { "type": "git", "url": "https://github.com/PHPOffice/PhpSpreadsheet.git", - "reference": "c80041b1628c4f18030407134fe88303661d4e4e" + "reference": "05b6c4378ddf3e81b460ea645c42b46432c0db25" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPOffice/PhpSpreadsheet/zipball/c80041b1628c4f18030407134fe88303661d4e4e", - "reference": "c80041b1628c4f18030407134fe88303661d4e4e", + "url": "https://api.github.com/repos/PHPOffice/PhpSpreadsheet/zipball/05b6c4378ddf3e81b460ea645c42b46432c0db25", + "reference": "05b6c4378ddf3e81b460ea645c42b46432c0db25", "shasum": "" }, "require": { @@ -9299,9 +9299,9 @@ ], "support": { "issues": "https://github.com/PHPOffice/PhpSpreadsheet/issues", - "source": "https://github.com/PHPOffice/PhpSpreadsheet/tree/1.29.10" + "source": "https://github.com/PHPOffice/PhpSpreadsheet/tree/1.29.11" }, - "time": "2025-02-08T02:56:14+00:00" + "time": "2025-06-23T01:22:06+00:00" }, { "name": "phpoption/phpoption", @@ -11660,16 +11660,16 @@ }, { "name": "spomky-labs/pki-framework", - "version": "1.2.3", + "version": "1.3.0", "source": { "type": "git", "url": "https://github.com/Spomky-Labs/pki-framework.git", - "reference": "5ff1dcc21e961b60149a80e77f744fc047800b31" + "reference": "eced5b5ce70518b983ff2be486e902bbd15135ae" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Spomky-Labs/pki-framework/zipball/5ff1dcc21e961b60149a80e77f744fc047800b31", - "reference": "5ff1dcc21e961b60149a80e77f744fc047800b31", + "url": "https://api.github.com/repos/Spomky-Labs/pki-framework/zipball/eced5b5ce70518b983ff2be486e902bbd15135ae", + "reference": "eced5b5ce70518b983ff2be486e902bbd15135ae", "shasum": "" }, "require": { @@ -11753,7 +11753,7 @@ ], "support": { "issues": "https://github.com/Spomky-Labs/pki-framework/issues", - "source": "https://github.com/Spomky-Labs/pki-framework/tree/1.2.3" + "source": "https://github.com/Spomky-Labs/pki-framework/tree/1.3.0" }, "funding": [ { @@ -11765,7 +11765,7 @@ "type": "patreon" } ], - "time": "2025-04-25T15:57:13+00:00" + "time": "2025-06-13T08:35:04+00:00" }, { "name": "swayok/alternative-laravel-cache", @@ -16108,16 +16108,16 @@ }, { "name": "filp/whoops", - "version": "2.18.0", + "version": "2.18.3", "source": { "type": "git", "url": "https://github.com/filp/whoops.git", - "reference": "a7de6c3c6c3c022f5cfc337f8ede6a14460cf77e" + "reference": "59a123a3d459c5a23055802237cb317f609867e5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/filp/whoops/zipball/a7de6c3c6c3c022f5cfc337f8ede6a14460cf77e", - "reference": "a7de6c3c6c3c022f5cfc337f8ede6a14460cf77e", + "url": "https://api.github.com/repos/filp/whoops/zipball/59a123a3d459c5a23055802237cb317f609867e5", + "reference": "59a123a3d459c5a23055802237cb317f609867e5", "shasum": "" }, "require": { @@ -16167,7 +16167,7 @@ ], "support": { "issues": "https://github.com/filp/whoops/issues", - "source": "https://github.com/filp/whoops/tree/2.18.0" + "source": "https://github.com/filp/whoops/tree/2.18.3" }, "funding": [ { @@ -16175,7 +16175,7 @@ "type": "github" } ], - "time": "2025-03-15T12:00:00+00:00" + "time": "2025-06-16T00:02:10+00:00" }, { "name": "hamcrest/hamcrest-php", @@ -17291,16 +17291,16 @@ }, { "name": "psy/psysh", - "version": "v0.12.8", + "version": "v0.12.9", "source": { "type": "git", "url": "https://github.com/bobthecow/psysh.git", - "reference": "85057ceedee50c49d4f6ecaff73ee96adb3b3625" + "reference": "1b801844becfe648985372cb4b12ad6840245ace" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/bobthecow/psysh/zipball/85057ceedee50c49d4f6ecaff73ee96adb3b3625", - "reference": "85057ceedee50c49d4f6ecaff73ee96adb3b3625", + "url": "https://api.github.com/repos/bobthecow/psysh/zipball/1b801844becfe648985372cb4b12ad6840245ace", + "reference": "1b801844becfe648985372cb4b12ad6840245ace", "shasum": "" }, "require": { @@ -17364,9 +17364,9 @@ ], "support": { "issues": "https://github.com/bobthecow/psysh/issues", - "source": "https://github.com/bobthecow/psysh/tree/v0.12.8" + "source": "https://github.com/bobthecow/psysh/tree/v0.12.9" }, - "time": "2025-03-16T03:05:19+00:00" + "time": "2025-06-23T02:35:06+00:00" }, { "name": "sebastian/cli-parser", -- 2.39.5