From 7fc40d89bee91514d75596e7adba5b397e8435dc Mon Sep 17 00:00:00 2001 From: Jack McDade Date: Thu, 20 Aug 2026 15:44:54 -0400 Subject: [PATCH 1/5] Add shareable draft preview links Login-free tokens for unpublished, scheduled, and working-copy entries, minted from the publish form. Co-authored-by: Cursor --- config/live_preview.php | 11 + lang/en/messages.php | 1 + .../js/components/entries/PublishForm.vue | 48 +++- routes/cp.php | 2 + src/Entries/Entry.php | 7 + .../CP/Collections/EntriesController.php | 1 + .../EntrySharedPreviewController.php | 30 +++ src/Http/Responses/DataResponse.php | 3 +- src/Providers/AppServiceProvider.php | 11 + src/Tokens/Handlers/SharedPreview.php | 37 +++ .../Entries/SharedPreviewEntryTest.php | 159 ++++++++++++ .../Feature/Entries/ViewSharedPreviewTest.php | 240 ++++++++++++++++++ 12 files changed, 547 insertions(+), 3 deletions(-) create mode 100644 src/Http/Controllers/CP/Collections/EntrySharedPreviewController.php create mode 100644 src/Tokens/Handlers/SharedPreview.php create mode 100644 tests/Feature/Entries/SharedPreviewEntryTest.php create mode 100644 tests/Feature/Entries/ViewSharedPreviewTest.php diff --git a/config/live_preview.php b/config/live_preview.php index 6e213fc953f..4f5b4133813 100644 --- a/config/live_preview.php +++ b/config/live_preview.php @@ -69,4 +69,15 @@ 'hot_reload_contents' => true, + /* + |-------------------------------------------------------------------------- + | Shared Preview Links + |-------------------------------------------------------------------------- + | + | How long shareable draft preview links should remain valid, in minutes. + | + */ + + 'shared_link_expiry' => 1440, + ]; diff --git a/lang/en/messages.php b/lang/en/messages.php index 9fa65df7fcd..f09a543bcf5 100644 --- a/lang/en/messages.php +++ b/lang/en/messages.php @@ -245,6 +245,7 @@ 'session_expiry_logging_out_in_seconds' => 'You have been inactive for a while and will be logged out in :seconds seconds.', 'session_expiry_new_window' => 'This will open in a new window. Return here after authenticating.', 'set_new_password_instructions' => 'Confirm your email address and create a new password.', + 'shared_preview_link_copied' => 'Preview link copied. Expires in :hours hours.', 'show_slugs_instructions' => 'Show slugs in the tree view.', 'site_configure_attributes_instructions' => 'Add arbitrary attributes to your site\'s config which can be accessed in your templates. [Learn more](https://statamic.dev/multi-site#additional-attributes).', 'site_configure_handle_instructions' => 'A unique reference to this site. This cannot be easily changed later.', diff --git a/resources/js/components/entries/PublishForm.vue b/resources/js/components/entries/PublishForm.vue index 2c888064b35..e8ca97afa49 100644 --- a/resources/js/components/entries/PublishForm.vue +++ b/resources/js/components/entries/PublishForm.vue @@ -101,8 +101,8 @@