From: Vincent Vanwaelscappel Date: Thu, 24 Aug 2023 16:02:22 +0000 (+0200) Subject: wait #6214 @3 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=65a977f093b33992ebf776b7f9e5832756464a7e;p=fluidbook-toolbox.git wait #6214 @3 --- diff --git a/app/Http/Controllers/Admin/Operations/FluidbookPublication/CompositionOperation.php b/app/Http/Controllers/Admin/Operations/FluidbookPublication/CompositionOperation.php index 3bccbef75..87a4e4362 100644 --- a/app/Http/Controllers/Admin/Operations/FluidbookPublication/CompositionOperation.php +++ b/app/Http/Controllers/Admin/Operations/FluidbookPublication/CompositionOperation.php @@ -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) { diff --git a/app/Models/FluidbookDocument.php b/app/Models/FluidbookDocument.php index 9511ca1eb..64db70bd8 100644 --- a/app/Models/FluidbookDocument.php +++ b/app/Models/FluidbookDocument.php @@ -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) diff --git a/resources/views/fields/fluidbook_composition.blade.php b/resources/views/fields/fluidbook_composition.blade.php index 081e70a12..d331d00ea 100644 --- a/resources/views/fields/fluidbook_composition.blade.php +++ b/resources/views/fields/fluidbook_composition.blade.php @@ -454,7 +454,30 @@ 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() {