diff options
| author | erdgeist <erdgeist@erdgeist.org> | 2026-07-06 06:09:21 +0200 |
|---|---|---|
| committer | erdgeist <erdgeist@erdgeist.org> | 2026-07-06 06:09:21 +0200 |
| commit | 9e63a6bec1b4ccc45dd684f7b6a941b75f9b9cf0 (patch) | |
| tree | 8c7842b3703ad2224deace37f9bd48df3374349b /app/views/nodes | |
| parent | b547decd1f85b43d5fb9e86cd7462b455059b1d1 (diff) | |
Add public preview links for drafts
Lets editors share a draft with people outside the admin system, via a
random per-page token rather than an enumerable id - /preview/<token>.
shared_previews#show is intentionally unauthenticated. Redirects to the
real public URL once the page is published. Surfaced on nodes#show
(Admin Preview + Public Preview, next to Public Link) as generate/revoke
buttons.
Diffstat (limited to 'app/views/nodes')
| -rw-r--r-- | app/views/nodes/show.html.erb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/app/views/nodes/show.html.erb b/app/views/nodes/show.html.erb index c533a55..d63df86 100644 --- a/app/views/nodes/show.html.erb +++ b/app/views/nodes/show.html.erb | |||
| @@ -12,6 +12,23 @@ | |||
| 12 | <td class="description">Public Link</td> | 12 | <td class="description">Public Link</td> |
| 13 | <td><%= link_to @page.public_link, content_url(@node.unique_path) %></td> | 13 | <td><%= link_to @page.public_link, content_url(@node.unique_path) %></td> |
| 14 | </tr> | 14 | </tr> |
| 15 | <% if @node.draft %> | ||
| 16 | <tr> | ||
| 17 | <td class="description">Admin Preview</td> | ||
| 18 | <td><%= link_to preview_page_path(@node.draft), preview_page_path(@node.draft) %></td> | ||
| 19 | </tr> | ||
| 20 | <tr> | ||
| 21 | <td class="description">Public Preview</td> | ||
| 22 | <td> | ||
| 23 | <% if @node.draft.preview_token.present? %> | ||
| 24 | <%= link_to shared_preview_path(token: @node.draft.preview_token), shared_preview_url(token: @node.draft.preview_token), target: "_blank", rel: "noopener" %> | ||
| 25 | <%= button_to 'Revoke', revoke_shared_preview_node_path(@node), method: :put, form: { data: { confirm: "Revoke this preview link? Anyone currently using it will immediately lose access." } } %> | ||
| 26 | <% else %> | ||
| 27 | <%= button_to 'Create public preview link', generate_shared_preview_node_path(@node), method: :put %> | ||
| 28 | <% end %> | ||
| 29 | </td> | ||
| 30 | </tr> | ||
| 31 | <% end %> | ||
| 15 | <tr> | 32 | <tr> |
| 16 | <td class="description">Author</td> | 33 | <td class="description">Author</td> |
| 17 | <td><%= @page.user.try(:login) %></td> | 34 | <td><%= @page.user.try(:login) %></td> |
