1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-08-09 10:22:51 +03:00

Pages API: Made raw_html available on page responses

To provide a way to see the original un-pre-processed database HTML
content.

For #4310
This commit is contained in:
Dan Brown
2023-06-20 17:07:46 +01:00
parent 41c3ed154b
commit 8b935e71d1
6 changed files with 22 additions and 6 deletions

View File

@@ -13,8 +13,6 @@ use Illuminate\Http\Request;
class PageApiController extends ApiController
{
protected PageRepo $pageRepo;
protected $rules = [
'create' => [
'book_id' => ['required_without:chapter_id', 'integer'],
@@ -34,9 +32,9 @@ class PageApiController extends ApiController
],
];
public function __construct(PageRepo $pageRepo)
{
$this->pageRepo = $pageRepo;
public function __construct(
protected PageRepo $pageRepo
) {
}
/**

View File

@@ -139,6 +139,7 @@ class Page extends BookChild
{
$refreshed = $this->refresh()->unsetRelations()->load(['tags', 'createdBy', 'updatedBy', 'ownedBy']);
$refreshed->setHidden(array_diff($refreshed->getHidden(), ['html', 'markdown']));
$refreshed->setAttribute('raw_html', $refreshed->html);
$refreshed->html = (new PageContent($refreshed))->render();
return $refreshed;