Skip to content

Commit a4c9439

Browse files
committed
Merge branch 'master' into release
2 parents 53f3cca + 7e6e1fc commit a4c9439

40 files changed

+1480
-1319
lines changed

.github/translators.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,3 +211,7 @@ Mundo Racional (ismael.mesquita) :: Portuguese, Brazilian
211211
Zarik (3apuk) :: Russian
212212
Ali Shaatani (a.shaatani) :: Arabic
213213
ChacMaster :: Portuguese, Brazilian
214+
Saeed (saeed205) :: Persian
215+
Julesdevops :: French
216+
peter cerny (posli.to.semka) :: Slovak
217+
Pavel Karlin (pavelkarlin) :: Russian

app/Entities/Tools/ExportFormatter.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ public function pageToPdf(Page $page)
9292
$html = view('pages.export', [
9393
'page' => $page,
9494
'format' => 'pdf',
95+
'engine' => $this->pdfGenerator->getActiveEngine(),
9596
])->render();
9697

9798
return $this->htmlToPdf($html);
@@ -113,6 +114,7 @@ public function chapterToPdf(Chapter $chapter)
113114
'chapter' => $chapter,
114115
'pages' => $pages,
115116
'format' => 'pdf',
117+
'engine' => $this->pdfGenerator->getActiveEngine(),
116118
])->render();
117119

118120
return $this->htmlToPdf($html);
@@ -130,6 +132,7 @@ public function bookToPdf(Book $book)
130132
'book' => $book,
131133
'bookChildren' => $bookTree,
132134
'format' => 'pdf',
135+
'engine' => $this->pdfGenerator->getActiveEngine(),
133136
])->render();
134137

135138
return $this->htmlToPdf($html);

app/Entities/Tools/PdfGenerator.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@
77

88
class PdfGenerator
99
{
10+
const ENGINE_DOMPDF = 'dompdf';
11+
const ENGINE_WKHTML = 'wkhtml';
12+
1013
/**
1114
* Generate PDF content from the given HTML content.
1215
*/
1316
public function fromHtml(string $html): string
1417
{
15-
$useWKHTML = config('snappy.pdf.binary') !== false && config('app.allow_untrusted_server_fetching') === true;
16-
17-
if ($useWKHTML) {
18+
if ($this->getActiveEngine() === self::ENGINE_WKHTML) {
1819
$pdf = SnappyPDF::loadHTML($html);
1920
$pdf->setOption('print-media-type', true);
2021
} else {
@@ -23,4 +24,15 @@ public function fromHtml(string $html): string
2324

2425
return $pdf->output();
2526
}
27+
28+
/**
29+
* Get the currently active PDF engine.
30+
* Returns the value of an `ENGINE_` const on this class.
31+
*/
32+
public function getActiveEngine(): string
33+
{
34+
$useWKHTML = config('snappy.pdf.binary') !== false && config('app.allow_untrusted_server_fetching') === true;
35+
36+
return $useWKHTML ? self::ENGINE_WKHTML : self::ENGINE_DOMPDF;
37+
}
2638
}

app/Http/Controllers/PageController.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use BookStack\Exceptions\NotFoundException;
1515
use BookStack\Exceptions\PermissionsException;
1616
use Exception;
17+
use Illuminate\Database\Eloquent\Relations\BelongsTo;
1718
use Illuminate\Http\Request;
1819
use Illuminate\Validation\ValidationException;
1920
use Throwable;
@@ -364,15 +365,22 @@ public function destroyDraft(string $bookSlug, int $pageId)
364365
*/
365366
public function showRecentlyUpdated()
366367
{
367-
$pages = Page::visible()->orderBy('updated_at', 'desc')
368+
$visibleBelongsScope = function (BelongsTo $query) {
369+
$query->scopes('visible');
370+
};
371+
372+
$pages = Page::visible()->with(['updatedBy', 'book' => $visibleBelongsScope, 'chapter' => $visibleBelongsScope])
373+
->orderBy('updated_at', 'desc')
368374
->paginate(20)
369375
->setPath(url('/pages/recently-updated'));
370376

371377
$this->setPageTitle(trans('entities.recently_updated_pages'));
372378

373379
return view('common.detailed-listing-paginated', [
374-
'title' => trans('entities.recently_updated_pages'),
375-
'entities' => $pages,
380+
'title' => trans('entities.recently_updated_pages'),
381+
'entities' => $pages,
382+
'showUpdatedBy' => true,
383+
'showPath' => true,
376384
]);
377385
}
378386

app/Http/Controllers/UserController.php

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use BookStack\Uploads\ImageRepo;
1313
use Exception;
1414
use Illuminate\Http\Request;
15+
use Illuminate\Support\Facades\DB;
1516
use Illuminate\Support\Str;
1617
use Illuminate\Validation\Rules\Password;
1718
use Illuminate\Validation\ValidationException;
@@ -99,20 +100,23 @@ public function store(Request $request)
99100
}
100101

101102
$user->refreshSlug();
102-
$user->save();
103103

104-
if ($sendInvite) {
105-
$this->inviteService->sendInvitation($user);
106-
}
104+
DB::transaction(function () use ($user, $sendInvite, $request) {
105+
$user->save();
107106

108-
if ($request->filled('roles')) {
109-
$roles = $request->get('roles');
110-
$this->userRepo->setUserRoles($user, $roles);
111-
}
107+
if ($sendInvite) {
108+
$this->inviteService->sendInvitation($user);
109+
}
110+
111+
if ($request->filled('roles')) {
112+
$roles = $request->get('roles');
113+
$this->userRepo->setUserRoles($user, $roles);
114+
}
112115

113-
$this->userRepo->downloadAndAssignUserAvatar($user);
116+
$this->userRepo->downloadAndAssignUserAvatar($user);
114117

115-
$this->logActivity(ActivityType::USER_CREATE, $user);
118+
$this->logActivity(ActivityType::USER_CREATE, $user);
119+
});
116120

117121
return redirect('/settings/users');
118122
}

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"socialiteproviders/okta": "^4.1",
4242
"socialiteproviders/slack": "^4.1",
4343
"socialiteproviders/twitch": "^5.3",
44-
"ssddanbrown/htmldiff": "^1.0.1"
44+
"ssddanbrown/htmldiff": "^1.0.2"
4545
},
4646
"require-dev": {
4747
"fakerphp/faker": "^1.16",

0 commit comments

Comments
 (0)