]> _ Git - fluidbook-toolbox.git/commitdiff
wip #7556 @3
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 16 Jul 2025 12:17:29 +0000 (14:17 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 16 Jul 2025 12:17:29 +0000 (14:17 +0200)
app/Http/Controllers/Admin/Operations/FluidbookPublication/CompositionOperation.php
app/Models/FluidbookDocument.php
app/Models/FluidbookPublication.php

index 5b069386fe671627e4ab7f0fdc3f3568d50b2925..6e186b3f2f50ea6706597e6325a1c9302ce0b077 100644 (file)
@@ -25,7 +25,7 @@ trait CompositionOperation
         Route::match(['get'], $segment . '/docInfos/{doc_id}', $controller . '@docInfos');
         Route::match(['get'], $segment . '/{fluidbook_id}/pdfarchive/{time}', $controller . '@pdfArchive');
         Route::match(['get'], $segment . '/{fluidbook_id}/{type}/{page}.{ext}', $controller . '@getPageAsset')
-            ->whereIn('type', ['originalpdf', 'texts', 'index', 'layout', 'links']);
+            ->whereIn('type', ['originalpdf', 'texts', 'index', 'layout', 'links', 'accessible']);
     }
 
     protected function setupCompositionDefaults()
@@ -47,6 +47,10 @@ trait CompositionOperation
             $file = $fb->getLinksFile($page);
             return XSendFileController::sendfile($file, headers: ['Content-type', 'text/plain']);
         }
+        if ($type === 'accessible') {
+            $file = $fb->getAccessibleFile($page, $ext);
+            return XSendFileController::sendfile($file, headers: ['Content-type', Files::getMimeType($file)]);
+        }
         $types = ['texts' => FluidbookDocument::TEXT_PLAIN, 'index' => FluidbookDocument::TEXT_INDEX, 'layout' => FluidbookDocument::TEXT_LAYOUT];
         if (!isset($types[$type])) {
             abort(404, 'Text type not found');
index de07efbcf0cdfe45ff1b0bdec718d5e2ca9f9a4a..ee894ef298de33f61f2b4bb7502383fc2d510b61 100644 (file)
@@ -93,8 +93,6 @@ class FluidbookDocument extends ToolboxModel
         $this->splitPDF();
         $this->updateProgression($uploadID, __('Extraction des textes'), 1.6);
         $this->extractTexts();
-        $this->updateProgression($uploadID, __('Extraction du HTML'), 1.75);
-        $this->extractMarkdown();
         $this->updateProgression($uploadID, __('Extraction des liens'), 1.9);
         $this->extractLinks();
         $this->updateProgression($uploadID, __('Conversion des pages'), 2);
@@ -139,6 +137,14 @@ class FluidbookDocument extends ToolboxModel
         }
     }
 
+    public function getMarkdown($page)
+    {
+        if (!file_exists($this->path('docling/p1.md'))) {
+            $this->extractMarkdown();
+        }
+        return $this->path('docling/p' . $page . '.md');
+    }
+
     public function echoStatus($id)
     {
         if (!$this->processSync) {
index df76a196850e01115493cd07fedf18da42d4c626..37cf7896a83b4a0813ad4189cdfa6ee9e9cc4484 100644 (file)
@@ -461,6 +461,11 @@ class FluidbookPublication extends ToolboxStatusModel
         return self::_getDocument($compo[0])->getHightlightFile($compo[1], $this->search_mode ?: 'standard', $this->ignoreSearchSeparators);
     }
 
+    public function getAccessibleFile($page,$format='md'){
+        $compo = $this->getComposition()[$page];
+        return self::_getDocument($compo[0])->getMarkdown($compo[1]);
+    }
+
     public function getPDFSplitSource($page)
     {
         if ($page > $this->getPagesNumber()) {