diff options
| author | erdgeist <erdgeist@erdgeist.org> | 2026-07-18 04:33:53 +0200 |
|---|---|---|
| committer | erdgeist <erdgeist@erdgeist.org> | 2026-07-18 04:33:53 +0200 |
| commit | 49de2e14972030a7ef0ca36a94ab55a23a2f3596 (patch) | |
| tree | 7b05419a805e9bac01a4acea3ba6d0348af50ee6 /app | |
| parent | 10bd6ba5cc640f0a85a3adb3641a65ce5edf831d (diff) | |
Annotate the History list with each revision's lifecycle
Each row in nodes#show's History section now carries terse badges
from the action log: created, published, and restored (rollback
re-promotion), with date and actor, rendered from entry metadata
alone. Backfilled entries wear the inferred marker, so
reconstructed provenance stays distinguishable from witnessed
history. A revision that was published and later restored shows
both badges chronologically -- its true biography.
Only create and publish entries carry page_id; trash, restore, and
destroy annotate the node's own log zoom instead of any single
revision, by design.
Diffstat (limited to 'app')
| -rw-r--r-- | app/controllers/nodes_controller.rb | 3 | ||||
| -rw-r--r-- | app/helpers/node_actions_helper.rb | 26 | ||||
| -rw-r--r-- | app/views/nodes/show.html.erb | 5 |
3 files changed, 33 insertions, 1 deletions
diff --git a/app/controllers/nodes_controller.rb b/app/controllers/nodes_controller.rb index 021f8ff..6caa827 100644 --- a/app/controllers/nodes_controller.rb +++ b/app/controllers/nodes_controller.rb | |||
| @@ -62,6 +62,9 @@ class NodesController < ApplicationController | |||
| 62 | def show | 62 | def show |
| 63 | @page = @node.draft || @node.head | 63 | @page = @node.draft || @node.head |
| 64 | @translations = @page.translation_summary | 64 | @translations = @page.translation_summary |
| 65 | @page_actions = NodeAction.where(:page_id => @node.pages.select(:id)) | ||
| 66 | .order(:occurred_at, :id) | ||
| 67 | .group_by(&:page_id) | ||
| 65 | end | 68 | end |
| 66 | 69 | ||
| 67 | def edit | 70 | def edit |
diff --git a/app/helpers/node_actions_helper.rb b/app/helpers/node_actions_helper.rb index c829dff..eb761e3 100644 --- a/app/helpers/node_actions_helper.rb +++ b/app/helpers/node_actions_helper.rb | |||
| @@ -59,6 +59,32 @@ module NodeActionsHelper | |||
| 59 | end | 59 | end |
| 60 | end | 60 | end |
| 61 | 61 | ||
| 62 | def revision_lifecycle_badges actions | ||
| 63 | return "" if actions.blank? | ||
| 64 | |||
| 65 | badges = actions.map do |action| | ||
| 66 | key = case action.action | ||
| 67 | when "create" then "node_actions.revision_created" | ||
| 68 | when "publish" then action.metadata["via"] == "revision" ? | ||
| 69 | "node_actions.revision_restored" : | ||
| 70 | "node_actions.revision_published" | ||
| 71 | end | ||
| 72 | next unless key | ||
| 73 | |||
| 74 | badge = h(t(key, :date => action.occurred_at.strftime("%Y-%m-%d"), | ||
| 75 | :actor => action.actor_name)) | ||
| 76 | if action.inferred_from | ||
| 77 | badge = safe_join([badge, content_tag(:span, t("node_actions.backfilled"), | ||
| 78 | :class => "node_action_inferred", | ||
| 79 | :title => action.inferred_from)], " ") | ||
| 80 | end | ||
| 81 | badge | ||
| 82 | end.compact | ||
| 83 | |||
| 84 | return "" if badges.empty? | ||
| 85 | safe_join(["โ ", safe_join(badges, " ยท ")]) | ||
| 86 | end | ||
| 87 | |||
| 62 | private | 88 | private |
| 63 | 89 | ||
| 64 | def revision_ref action, key | 90 | def revision_ref action, key |
diff --git a/app/views/nodes/show.html.erb b/app/views/nodes/show.html.erb index 4d4f6d5..af05778 100644 --- a/app/views/nodes/show.html.erb +++ b/app/views/nodes/show.html.erb | |||
| @@ -229,7 +229,10 @@ | |||
| 229 | </summary> | 229 | </summary> |
| 230 | <ul> | 230 | <ul> |
| 231 | <% @node.pages.order(:revision).each do |page| %> | 231 | <% @node.pages.order(:revision).each do |page| %> |
| 232 | <li><%= link_to "##{page.revision} โ #{page.title} (#{page.editor.try(:login)}, #{page.updated_at})", node_revision_path(@node, page) %></li> | 232 | <li> |
| 233 | <%= link_to "##{page.revision} โ #{page.title} (#{page.editor.try(:login)}, #{page.updated_at})", node_revision_path(@node, page) %> | ||
| 234 | <span class="revision_lifecycle"><%= revision_lifecycle_badges(@page_actions[page.id]) %></span> | ||
| 235 | </li> | ||
| 233 | <% end %> | 236 | <% end %> |
| 234 | </ul> | 237 | </ul> |
| 235 | </details> | 238 | </details> |
