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/helpers/node_actions_helper.rb | |
| 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/helpers/node_actions_helper.rb')
| -rw-r--r-- | app/helpers/node_actions_helper.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/app/helpers/node_actions_helper.rb b/app/helpers/node_actions_helper.rb index c829dff7..eb761e3b 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 |
