mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-08-26 04:05:57 +00:00
Aligned export styles a little better and fixed potential DOMPDF css error
- Removed different PDF template used on pages. - Updated export view files to have the intended format passed. - Shared the export CSS amoung the export templates. Should hopefully address #1886
This commit is contained in:
parent
14363edb73
commit
ccd50fe918
@ -29,8 +29,9 @@ class ExportService
|
|||||||
public function pageToContainedHtml(Page $page)
|
public function pageToContainedHtml(Page $page)
|
||||||
{
|
{
|
||||||
$page->html = (new PageContent($page))->render();
|
$page->html = (new PageContent($page))->render();
|
||||||
$pageHtml = view('pages/export', [
|
$pageHtml = view('pages.export', [
|
||||||
'page' => $page
|
'page' => $page,
|
||||||
|
'format' => 'html',
|
||||||
])->render();
|
])->render();
|
||||||
return $this->containHtml($pageHtml);
|
return $this->containHtml($pageHtml);
|
||||||
}
|
}
|
||||||
@ -45,9 +46,10 @@ class ExportService
|
|||||||
$pages->each(function ($page) {
|
$pages->each(function ($page) {
|
||||||
$page->html = (new PageContent($page))->render();
|
$page->html = (new PageContent($page))->render();
|
||||||
});
|
});
|
||||||
$html = view('chapters/export', [
|
$html = view('chapters.export', [
|
||||||
'chapter' => $chapter,
|
'chapter' => $chapter,
|
||||||
'pages' => $pages
|
'pages' => $pages,
|
||||||
|
'format' => 'html',
|
||||||
])->render();
|
])->render();
|
||||||
return $this->containHtml($html);
|
return $this->containHtml($html);
|
||||||
}
|
}
|
||||||
@ -59,9 +61,10 @@ class ExportService
|
|||||||
public function bookToContainedHtml(Book $book)
|
public function bookToContainedHtml(Book $book)
|
||||||
{
|
{
|
||||||
$bookTree = (new BookContents($book))->getTree(false, true);
|
$bookTree = (new BookContents($book))->getTree(false, true);
|
||||||
$html = view('books/export', [
|
$html = view('books.export', [
|
||||||
'book' => $book,
|
'book' => $book,
|
||||||
'bookChildren' => $bookTree
|
'bookChildren' => $bookTree,
|
||||||
|
'format' => 'html',
|
||||||
])->render();
|
])->render();
|
||||||
return $this->containHtml($html);
|
return $this->containHtml($html);
|
||||||
}
|
}
|
||||||
@ -73,8 +76,9 @@ class ExportService
|
|||||||
public function pageToPdf(Page $page)
|
public function pageToPdf(Page $page)
|
||||||
{
|
{
|
||||||
$page->html = (new PageContent($page))->render();
|
$page->html = (new PageContent($page))->render();
|
||||||
$html = view('pages/pdf', [
|
$html = view('pages.export', [
|
||||||
'page' => $page
|
'page' => $page,
|
||||||
|
'format' => 'pdf',
|
||||||
])->render();
|
])->render();
|
||||||
return $this->htmlToPdf($html);
|
return $this->htmlToPdf($html);
|
||||||
}
|
}
|
||||||
@ -90,9 +94,10 @@ class ExportService
|
|||||||
$page->html = (new PageContent($page))->render();
|
$page->html = (new PageContent($page))->render();
|
||||||
});
|
});
|
||||||
|
|
||||||
$html = view('chapters/export', [
|
$html = view('chapters.export', [
|
||||||
'chapter' => $chapter,
|
'chapter' => $chapter,
|
||||||
'pages' => $pages
|
'pages' => $pages,
|
||||||
|
'format' => 'pdf',
|
||||||
])->render();
|
])->render();
|
||||||
|
|
||||||
return $this->htmlToPdf($html);
|
return $this->htmlToPdf($html);
|
||||||
@ -105,9 +110,10 @@ class ExportService
|
|||||||
public function bookToPdf(Book $book)
|
public function bookToPdf(Book $book)
|
||||||
{
|
{
|
||||||
$bookTree = (new BookContents($book))->getTree(false, true);
|
$bookTree = (new BookContents($book))->getTree(false, true);
|
||||||
$html = view('books/export', [
|
$html = view('books.export', [
|
||||||
'book' => $book,
|
'book' => $book,
|
||||||
'bookChildren' => $bookTree
|
'bookChildren' => $bookTree,
|
||||||
|
'format' => 'pdf',
|
||||||
])->render();
|
])->render();
|
||||||
return $this->htmlToPdf($html);
|
return $this->htmlToPdf($html);
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
@import "text";
|
@import "text";
|
||||||
@import "layout";
|
@import "layout";
|
||||||
@import "blocks";
|
@import "blocks";
|
||||||
@import "forms";
|
|
||||||
@import "tables";
|
@import "tables";
|
||||||
@import "header";
|
@import "header";
|
||||||
@import "lists";
|
@import "lists";
|
||||||
|
@ -4,10 +4,9 @@
|
|||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
||||||
<title>{{ $book->name }}</title>
|
<title>{{ $book->name }}</title>
|
||||||
|
|
||||||
|
@include('partials.export-styles', ['format' => $format])
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
@if (!app()->environment('testing'))
|
|
||||||
{!! file_get_contents(public_path('/dist/export-styles.css')) !!}
|
|
||||||
@endif
|
|
||||||
.page-break {
|
.page-break {
|
||||||
page-break-after: always;
|
page-break-after: always;
|
||||||
}
|
}
|
||||||
|
@ -4,10 +4,9 @@
|
|||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
||||||
<title>{{ $chapter->name }}</title>
|
<title>{{ $chapter->name }}</title>
|
||||||
|
|
||||||
|
@include('partials.export-styles', ['format' => $format])
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
@if (!app()->environment('testing'))
|
|
||||||
{!! file_get_contents(public_path('/dist/export-styles.css')) !!}
|
|
||||||
@endif
|
|
||||||
.page-break {
|
.page-break {
|
||||||
page-break-after: always;
|
page-break-after: always;
|
||||||
}
|
}
|
||||||
@ -20,7 +19,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
@yield('head')
|
|
||||||
@include('partials.custom-head')
|
@include('partials.custom-head')
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
@ -4,12 +4,31 @@
|
|||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
||||||
<title>{{ $page->name }}</title>
|
<title>{{ $page->name }}</title>
|
||||||
|
|
||||||
<style>
|
@include('partials.export-styles', ['format' => $format])
|
||||||
@if (!app()->environment('testing'))
|
|
||||||
{!! file_get_contents(public_path('/dist/export-styles.css')) !!}
|
@if($format === 'pdf')
|
||||||
@endif
|
<style>
|
||||||
</style>
|
body {
|
||||||
@yield('head')
|
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;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
@endif
|
||||||
|
|
||||||
@include('partials.custom-head')
|
@include('partials.custom-head')
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
@ -1,34 +0,0 @@
|
|||||||
@extends('pages/export')
|
|
||||||
|
|
||||||
@section('head')
|
|
||||||
<style>
|
|
||||||
body {
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@stop
|
|
29
resources/views/partials/export-styles.blade.php
Normal file
29
resources/views/partials/export-styles.blade.php
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
<style>
|
||||||
|
@if (!app()->environment('testing'))
|
||||||
|
{!! file_get_contents(public_path('/dist/export-styles.css')) !!}
|
||||||
|
@endif
|
||||||
|
</style>
|
||||||
|
|
||||||
|
@if ($format === 'pdf')
|
||||||
|
<style>
|
||||||
|
/* Patches for CSS variable colors */
|
||||||
|
a {
|
||||||
|
color: {{ setting('app-color') }};
|
||||||
|
}
|
||||||
|
|
||||||
|
blockquote {
|
||||||
|
border-left-color: {{ setting('app-color') }};
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Patches for content layout */
|
||||||
|
.page-content .float {
|
||||||
|
float: none !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.page-content img.align-left, .page-content img.align-right {
|
||||||
|
float: none !important;
|
||||||
|
clear: both;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
@endif
|
Loading…
Reference in New Issue
Block a user