]> _ Git - fluidbook-toolbox.git/commitdiff
wait #6214 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 25 Aug 2023 07:35:21 +0000 (09:35 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 25 Aug 2023 07:35:21 +0000 (09:35 +0200)
app/Http/Controllers/Admin/Operations/FluidbookPublication/CompositionOperation.php
app/Models/FluidbookDocument.php
resources/views/fields/fluidbook_composition.blade.php

index 87a4e4362efefc17d5e4ed32b1fcfd3b61ecdd02..dc2e1af1444ef2c414145e7dfe2dc6de58f234eb 100644 (file)
@@ -33,7 +33,7 @@ trait CompositionOperation
 
     protected function getPageText($fluidbook_id, $type, $page)
     {
-        $types = ['texts' => FluidbookDocument::TEXT_PLAIN, 'index' => FluidbookDocument::TEXT_INDEX];
+        $types = ['texts' => FluidbookDocument::TEXT_PLAIN, 'index' => FluidbookDocument::TEXT_INDEX, 'layout' => FluidbookDocument::TEXT_LAYOUT];
         if (!isset($types[$type])) {
             abort(404, 'Text type not found');
         }
@@ -41,10 +41,15 @@ trait CompositionOperation
             abort(401);
         }
         /** @var FluidbookPublication $fb */
-        $fb = FluidbookPublication::find($fluidbook_id);
-        $document = $fb->getDocument($page);
-        $path = $document->getTextFile($page, $types[$type], $fb->textExtraction, $fb->ignoreSearchSeparators);
-        return response(Gzip::file_get_contents($path), 200, ['content-type' => 'text/plain']);
+        $fb = FluidbookPublication::withoutGlobalScopes()->find($fluidbook_id);
+        $contentType = 'text/plain';
+        if ($type == FluidbookDocument::TEXT_LAYOUT) {
+            $path = $fb->getHightlightFile($page);
+            $contentType = 'application/json';
+        } else {
+            $path = $fb->getTextFile($page, $types[$type]);
+        }
+        return response(Gzip::file_get_contents($path), 200, ['content-type' => $contentType]);
     }
 
 
index 64db70bd8f51f4fa8ab04fabf442f7a903f734f3..5725777c78ae5979cda328a6f5bed7e7dda382f7 100644 (file)
@@ -38,6 +38,7 @@ class FluidbookDocument extends ToolboxModel
     const TEXT_PLAIN = 'p';
     const TEXT_INDEX = 'i';
     const TEXT_HTML = 'h';
+    const TEXT_LAYOUT = 'layout';
 
     public function setFields()
     {
index d331d00ea08ef9893d1e4a00ea8b5257075eda91..896d0a88bbe910d6a4118d2d5c6ef72f03b1a8cc 100644 (file)
                                     callback: function (key, opt) {
                                         window.open('/fluidbook-publication/' + {{$entry->id}} + '/index/' + ($(opt.$trigger[0]).index() + 1) + '.txt');
                                     },
+                                },
+                                seelayout: {
+                                    name: "{{__('Informations pour le surlignage')}}",
+                                    callback: function (key, opt) {
+                                        window.open('/fluidbook-publication/' + {{$entry->id}} + '/layout/' + ($(opt.$trigger[0]).index() + 1) + '.txt');
+                                    },
                                 }
                             }
                         }