Skip to content

Commit

Permalink
Merge pull request #1334 from hydephp/add-realtime-compiler-option-to…
Browse files Browse the repository at this point in the history
…-not-store-rendered-pages-to-disk

Add RealtimeCompiler option to not store rendered pages to disk
  • Loading branch information
caendesilva authored Mar 18, 2023
2 parents f780285 + 3a3dc1f commit e848c5f
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 3 deletions.
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

0 comments on commit e848c5f

Please sign in to comment.