From 49de2e14972030a7ef0ca36a94ab55a23a2f3596 Mon Sep 17 00:00:00 2001 From: erdgeist Date: Sat, 18 Jul 2026 04:33:53 +0200 Subject: 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. --- app/controllers/nodes_controller.rb | 3 +++ app/helpers/node_actions_helper.rb | 26 ++++++++++++++++++++++++++ app/views/nodes/show.html.erb | 5 ++++- 3 files changed, 33 insertions(+), 1 deletion(-) (limited to 'app') 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 def show @page = @node.draft || @node.head @translations = @page.translation_summary + @page_actions = NodeAction.where(:page_id => @node.pages.select(:id)) + .order(:occurred_at, :id) + .group_by(&:page_id) end 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 end end + def revision_lifecycle_badges actions + return "" if actions.blank? + + badges = actions.map do |action| + key = case action.action + when "create" then "node_actions.revision_created" + when "publish" then action.metadata["via"] == "revision" ? + "node_actions.revision_restored" : + "node_actions.revision_published" + end + next unless key + + badge = h(t(key, :date => action.occurred_at.strftime("%Y-%m-%d"), + :actor => action.actor_name)) + if action.inferred_from + badge = safe_join([badge, content_tag(:span, t("node_actions.backfilled"), + :class => "node_action_inferred", + :title => action.inferred_from)], " ") + end + badge + end.compact + + return "" if badges.empty? + safe_join(["โ€” ", safe_join(badges, " ยท ")]) + end + private 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 @@ -- cgit v1.3