Skip to content

Commit

Permalink
feat: Add config useInternalPreviewUrl
Browse files Browse the repository at this point in the history
  • Loading branch information
pboivin committed Sep 30, 2023
1 parent 84436f9 commit 9dffb50
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
17 changes: 10 additions & 7 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@
use Illuminate\Support\Facades\Route;
use Pboivin\FilamentPeek\CachedPreview;

Route::prefix('filament-peek')->group(function () {
Route::get('preview', function () {
abort_unless($token = Request::query('token'), 404);
// @todo: Document config
if (config('filament-peek.useInternalPreviewUrl', false)) {
Route::prefix('filament-peek')->group(function () {
Route::get('preview', function () {
abort_unless($token = Request::query('token'), 404);

abort_unless($preview = CachedPreview::get($token), 404);
abort_unless($preview = CachedPreview::get($token), 404);

return $preview->render();
})->name('filament-peek.preview');
});
return $preview->render();
})->name('filament-peek.preview');
});
}
4 changes: 1 addition & 3 deletions src/Pages/Concerns/HasPreviewModal.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,7 @@ public function openPreviewModal(): void
if ($previewModalUrl = $this->getPreviewModalUrl()) {
// pass
} elseif ($view = $this->getPreviewModalView()) {
$useInternalUrl = true; // @todo: Add config

if ($useInternalUrl) {
if (config('filament-peek.useInternalPreviewUrl', false)) {
$token = md5('preview-'.Auth::user()->getAuthIdentifier().(Auth::user()->password ?? ''));

CachedPreview::make(static::class, $view, $this->previewModalData)->put($token);
Expand Down

0 comments on commit 9dffb50

Please sign in to comment.