diff --git a/app/Entities/Tools/ExportFormatter.php b/app/Entities/Tools/ExportFormatter.php index 99aa4536f..97902db82 100644 --- a/app/Entities/Tools/ExportFormatter.php +++ b/app/Entities/Tools/ExportFormatter.php @@ -39,7 +39,7 @@ class ExportFormatter public function pageToContainedHtml(Page $page) { $page->html = (new PageContent($page))->render(); - $pageHtml = view('pages.export', [ + $pageHtml = view('exports.page', [ 'page' => $page, 'format' => 'html', 'cspContent' => $this->cspService->getCspMetaTagValue(), @@ -59,7 +59,7 @@ class ExportFormatter $pages->each(function ($page) { $page->html = (new PageContent($page))->render(); }); - $html = view('chapters.export', [ + $html = view('exports.chapter', [ 'chapter' => $chapter, 'pages' => $pages, 'format' => 'html', @@ -77,7 +77,7 @@ class ExportFormatter public function bookToContainedHtml(Book $book) { $bookTree = (new BookContents($book))->getTree(false, true); - $html = view('books.export', [ + $html = view('exports.book', [ 'book' => $book, 'bookChildren' => $bookTree, 'format' => 'html', @@ -95,7 +95,7 @@ class ExportFormatter public function pageToPdf(Page $page) { $page->html = (new PageContent($page))->render(); - $html = view('pages.export', [ + $html = view('exports.page', [ 'page' => $page, 'format' => 'pdf', 'engine' => $this->pdfGenerator->getActiveEngine(), @@ -116,7 +116,7 @@ class ExportFormatter $page->html = (new PageContent($page))->render(); }); - $html = view('chapters.export', [ + $html = view('exports.chapter', [ 'chapter' => $chapter, 'pages' => $pages, 'format' => 'pdf', @@ -134,7 +134,7 @@ class ExportFormatter public function bookToPdf(Book $book) { $bookTree = (new BookContents($book))->getTree(false, true); - $html = view('books.export', [ + $html = view('exports.book', [ 'book' => $book, 'bookChildren' => $bookTree, 'format' => 'pdf', diff --git a/resources/sass/export-styles.scss b/resources/sass/export-styles.scss index 1a8b34c5b..b8160b4c2 100644 --- a/resources/sass/export-styles.scss +++ b/resources/sass/export-styles.scss @@ -59,4 +59,47 @@ ul.contents ul li { } .chapter-hint + h1 { margin-top: 0; +} + +// PDF specific overrides +body.export-format-pdf { + font-size: 14px; + line-height: 1.2; + + h1, h2, h3, h4, h5, h6 { + line-height: 1.2; + } + + table { + max-width: 800px !important; + font-size: 0.8em; + width: 100% !important; + } + + table td { + width: auto !important; + } + + .page-content .float { + float: none !important; + } + + .page-content img.align-left, .page-content img.align-right { + float: none !important; + clear: both; + display: block; + } + +} + +// DOMPDF pdf export specific overrides +body.export-format-pdf.export-engine-dompdf { + // Fix for full width linked image sizes on DOMPDF + .page-content a > img { + max-width: 700px; + } + // Undoes the above for table images to prevent visually worse scenario, Awaiting next DOMPDF release for patch + .page-content td a > img { + max-width: 100%; + } } \ No newline at end of file diff --git a/resources/views/books/export.blade.php b/resources/views/books/export.blade.php deleted file mode 100644 index 0b6b4a58c..000000000 --- a/resources/views/books/export.blade.php +++ /dev/null @@ -1,46 +0,0 @@ -@extends('layouts.export') - -@section('title', $book->name) - -@section('content') -
{{ $book->description }}
- - @if(count($bookChildren) > 0) -{{ $bookChild->description }}
- - @if(count($bookChild->visible_pages) > 0) - @foreach($bookChild->visible_pages as $page) - -{{ $chapter->description }}
- - @if(count($pages) > 0) -{{ $book->description }}
+ + @include('exports.parts.book-contents-menu', ['children' => $bookChildren]) + + @foreach($bookChildren as $bookChild) + @if($bookChild->isA('chapter')) + @include('exports.parts.chapter-item', ['chapter' => $bookChild]) + @else + @include('exports.parts.page-item', ['page' => $bookChild, 'chapter' => null]) + @endif + @endforeach + +@endsection \ No newline at end of file diff --git a/resources/views/exports/chapter.blade.php b/resources/views/exports/chapter.blade.php new file mode 100644 index 000000000..ae49fa918 --- /dev/null +++ b/resources/views/exports/chapter.blade.php @@ -0,0 +1,16 @@ +@extends('layouts.export') + +@section('title', $chapter->name) + +@section('content') + +{{ $chapter->description }}
+ + @include('exports.parts.chapter-contents-menu', ['pages' => $pages]) + + @foreach($pages as $page) + @include('exports.parts.page-item', ['page' => $page, 'chapter' => null]) + @endforeach + +@endsection \ No newline at end of file diff --git a/resources/views/pages/export.blade.php b/resources/views/exports/page.blade.php similarity index 71% rename from resources/views/pages/export.blade.php rename to resources/views/exports/page.blade.php index d2f448d6e..e9324e96b 100644 --- a/resources/views/pages/export.blade.php +++ b/resources/views/exports/page.blade.php @@ -8,6 +8,6 @@{{ $chapter->description }}
+ +@if(count($chapter->visible_pages) > 0) + @foreach($chapter->visible_pages as $page) + @include('exports.parts.page-item', ['page' => $page, 'chapter' => $chapter]) + @endforeach +@endif \ No newline at end of file diff --git a/resources/views/common/export-custom-head.blade.php b/resources/views/exports/parts/custom-head.blade.php similarity index 100% rename from resources/views/common/export-custom-head.blade.php rename to resources/views/exports/parts/custom-head.blade.php diff --git a/resources/views/entities/export-meta.blade.php b/resources/views/exports/parts/meta.blade.php similarity index 100% rename from resources/views/entities/export-meta.blade.php rename to resources/views/exports/parts/meta.blade.php diff --git a/resources/views/exports/parts/page-item.blade.php b/resources/views/exports/parts/page-item.blade.php new file mode 100644 index 000000000..1a138ae43 --- /dev/null +++ b/resources/views/exports/parts/page-item.blade.php @@ -0,0 +1,8 @@ + + +@if (isset($chapter)) +