Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add RealtimeCompiler option to not store rendered pages to disk #1334

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
This release is the first since the official release of HydePHP 1.0.0. It contains a number of bug fixes and improvements, but no breaking changes as the project has reached general availability and adheres to the semantic versioning backwards compatibility promise.

### Added
- for new features.
- Added a RealtimeCompiler config option to disable rendered pages being stored to disk in https://github.com/hydephp/develop/pull/1334

### Changed
- Updated discovery exception message to include the causing exception message in https://github.com/hydephp/develop/pull/1305
Expand Down
1 change: 1 addition & 0 deletions config/hyde.php
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,7 @@
'port' => env('SERVER_PORT', 8080),
'host' => env('SERVER_HOST', 'localhost'),
'dashboard' => env('SERVER_DASHBOARD', true),
'save_preview' => true,
],

/*
Expand Down
1 change: 1 addition & 0 deletions packages/framework/config/hyde.php
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,7 @@
'port' => env('SERVER_PORT', 8080),
'host' => env('SERVER_HOST', 'localhost'),
'dashboard' => env('SERVER_DASHBOARD', true),
'save_preview' => true,
],

/*
Expand Down
8 changes: 7 additions & 1 deletion packages/realtime-compiler/src/Http/DashboardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,13 @@ public static function enabled(): bool
// This method is called from the PageRouter and allows us to serve a dynamic welcome page
public static function renderIndexPage(HydePage $page): string
{
$contents = file_get_contents(StaticPageBuilder::handle($page));
if (config('hyde.server.save_preview')) {
$contents = file_get_contents(StaticPageBuilder::handle($page));
} else {
Hyde::shareViewData($page);

$contents = $page->compile();
}

// If the page is the default welcome page we inject dashboard components
if (str_contains($contents, 'This is the default homepage')) {
Expand Down
9 changes: 8 additions & 1 deletion packages/realtime-compiler/src/Routing/PageRouter.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Hyde\RealtimeCompiler\Concerns\SendsErrorResponses;
use Hyde\RealtimeCompiler\Http\DashboardController;
use Hyde\RealtimeCompiler\Http\HtmlResponse;
use Hyde\Hyde;

/**
* Handle routing for a web page request.
Expand Down Expand Up @@ -63,7 +64,13 @@ protected function getHtml(HydePage $page): string
return DashboardController::renderIndexPage($page);
}

return file_get_contents(StaticPageBuilder::handle($page));
if (config('hyde.server.save_preview')) {
return file_get_contents(StaticPageBuilder::handle($page));
} else {
Hyde::shareViewData($page);

return $page->compile();
}
}

public static function handle(Request $request): Response
Expand Down