]> _ Git - fluidbook-toolbox.git/commitdiff
wait #6214 @3
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 24 Aug 2023 16:02:22 +0000 (18:02 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 24 Aug 2023 16:02:22 +0000 (18:02 +0200)
app/Http/Controllers/Admin/Operations/FluidbookPublication/CompositionOperation.php
app/Models/FluidbookDocument.php
resources/views/fields/fluidbook_composition.blade.php

index 3bccbef75b0ca06c24ef544c46be32e56b923902..87a4e4362efefc17d5e4ed32b1fcfd3b61ecdd02 100644 (file)
@@ -8,6 +8,7 @@ use App\Models\FluidbookDocument;
 use App\Models\FluidbookPublication;
 use Cubist\Backpack\Http\Controllers\Base\XSendFileController;
 use Cubist\Util\Files\Files;
+use Cubist\Util\Gzip;
 use Cubist\Util\Str;
 use Illuminate\Support\Facades\Route;
 use Illuminate\Support\Facades\Session;
@@ -23,12 +24,29 @@ trait CompositionOperation
         Route::match(['post'], $segment . '/uploaddocument', $controller . '@upload');
         Route::match(['get'], $segment . '/uploadProgress/{uploadID}', $controller . '@uploadProgress');
         Route::match(['get'], $segment . '/docInfos/{doc_id}', $controller . '@docInfos');
+        Route::match(['get'], $segment . '/{fluidbook_id}/{type}/{page}.txt', $controller . '@getPageText');
     }
 
     protected function setupCompositionDefaults()
     {
     }
 
+    protected function getPageText($fluidbook_id, $type, $page)
+    {
+        $types = ['texts' => FluidbookDocument::TEXT_PLAIN, 'index' => FluidbookDocument::TEXT_INDEX];
+        if (!isset($types[$type])) {
+            abort(404, 'Text type not found');
+        }
+        if (!FluidbookPublication::hasPermission($fluidbook_id)) {
+            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']);
+    }
+
 
     protected function getThumb($doc_id, $doc_page)
     {
index 9511ca1eb2d12390b823ae5948b1511e278b25e9..64db70bd8f51f4fa8ab04fabf442f7a903f734f3 100644 (file)
@@ -353,7 +353,7 @@ class FluidbookDocument extends ToolboxModel
                 throw new \Exception('An error occured while producing file ' . $path);
             }
         }
-        return $path;
+        return Gzip::path($path);
     }
 
     protected function _checkTextFile($path)
index 081e70a12b785c54972113f3be5d369c75a9e9f4..d331d00ea08ef9893d1e4a00ea8b5257075eda91 100644 (file)
                                 window.open('/fluidbook-publication/' + {{$entry->id}} + '/edit/links#' + ($(opt.$trigger[0]).index() + 1))
                             },
                         },
-                    }, compositionContextConversionSettings());
+                    }, compositionContextConversionSettings(), compositionContextSee());
+                }
+
+                function compositionContextSee() {
+                    return {
+                        sepsee: "---------",
+                        foldsee: {
+                            name: "{{__('Visualiser')}}",
+                            items: {
+                                seetexts: {
+                                    name: "{{__('Textes extraits')}}",
+                                    callback: function (key, opt) {
+                                        window.open('/fluidbook-publication/' + {{$entry->id}} + '/texts/' + ($(opt.$trigger[0]).index() + 1) + '.txt');
+                                    },
+                                },
+                                seeindex: {
+                                    name: "{{__('Index de recherche')}}",
+                                    callback: function (key, opt) {
+                                        window.open('/fluidbook-publication/' + {{$entry->id}} + '/index/' + ($(opt.$trigger[0]).index() + 1) + '.txt');
+                                    },
+                                }
+                            }
+                        }
+                    };
                 }
 
                 function getPageNumber() {