diff options
| author | erdgeist <erdgeist@erdgeist.org> | 2026-07-10 02:03:19 +0200 |
|---|---|---|
| committer | erdgeist <erdgeist@erdgeist.org> | 2026-07-10 02:03:19 +0200 |
| commit | 205e6216fc7850fe717122c189e5003d1f9e8afe (patch) | |
| tree | 8627354f3577f0a974949e759b0e93662840ade7 /app/controllers | |
| parent | 81769557804ce59ce3e4603e8f47e731b61b180d (diff) | |
Add head/draft/autosave layer comparison at three UI entry points
Node#resolve_page_reference and #available_layer_pairs let
Page#diff_against compare named layers (head/draft/autosave), not
just numbered revisions -- autosave was never part of Node#pages, so
this was the missing piece.
Wired into nodes#show's Status section, nodes#edit right after an
autosave gets resurrected ("What changed?"), and the admin wizard's
current-drafts table, which now also lists autosave-only nodes it
previously never showed.
revisions#diff hides the numbered-revision picker when comparing
named layers (it can't represent them), shows a plain label instead,
and offers buttons to switch between whichever other pairs make
sense for the node's current state. Destroying the topmost layer is
available directly from the diff view, reusing the existing revert!
path.
"Discard changes" is renamed "Discard Autosave" everywhere it
appears, to match "Destroy Draft".
Diffstat (limited to 'app/controllers')
| -rw-r--r-- | app/controllers/admin_controller.rb | 4 | ||||
| -rw-r--r-- | app/controllers/nodes_controller.rb | 2 | ||||
| -rw-r--r-- | app/controllers/revisions_controller.rb | 16 |
3 files changed, 15 insertions, 7 deletions
diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 3fa0519..6ab2135 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb | |||
| @@ -5,10 +5,10 @@ class AdminController < ApplicationController | |||
| 5 | before_action :login_required | 5 | before_action :login_required |
| 6 | 6 | ||
| 7 | def index | 7 | def index |
| 8 | @drafts = Node.where("draft_id IS NOT NULL") | 8 | @drafts = Node.where("draft_id IS NOT NULL OR autosave_id IS NOT NULL") |
| 9 | .limit(50).order("updated_at desc") | 9 | .limit(50).order("updated_at desc") |
| 10 | 10 | ||
| 11 | @drafts_count = Node.where("draft_id IS NOT NULL").count | 11 | @drafts_count = Node.where("draft_id IS NOT NULL OR autosave_id IS NOT NULL").count |
| 12 | 12 | ||
| 13 | @recent_changes = Node.where( | 13 | @recent_changes = Node.where( |
| 14 | "updated_at < ? AND updated_at > ? AND parent_id IS NOT NULL", | 14 | "updated_at < ? AND updated_at > ? AND parent_id IS NOT NULL", |
diff --git a/app/controllers/nodes_controller.rb b/app/controllers/nodes_controller.rb index 38d42d9..d1538e1 100644 --- a/app/controllers/nodes_controller.rb +++ b/app/controllers/nodes_controller.rb | |||
| @@ -72,7 +72,7 @@ class NodesController < ApplicationController | |||
| 72 | if @node.autosave | 72 | if @node.autosave |
| 73 | flash.now[:notice] = | 73 | flash.now[:notice] = |
| 74 | "This page has unsaved changes from a previous session, shown below. " \ | 74 | "This page has unsaved changes from a previous session, shown below. " \ |
| 75 | "Save to keep them, or use \"Discard changes\" below to go back to the last saved version." | 75 | "Save to keep them, or use \"Discard Autosave\" below to go back to the last saved version." |
| 76 | elsif freshly_locked | 76 | elsif freshly_locked |
| 77 | flash.now[:notice] = "Node locked and ready to edit" | 77 | flash.now[:notice] = "Node locked and ready to edit" |
| 78 | end | 78 | end |
diff --git a/app/controllers/revisions_controller.rb b/app/controllers/revisions_controller.rb index 9acb26f..4b0c549 100644 --- a/app/controllers/revisions_controller.rb +++ b/app/controllers/revisions_controller.rb | |||
| @@ -21,10 +21,18 @@ class RevisionsController < ApplicationController | |||
| 21 | params[:start_revision], params[:end_revision] = 1, 1 | 21 | params[:start_revision], params[:end_revision] = 1, 1 |
| 22 | end | 22 | end |
| 23 | 23 | ||
| 24 | @start = @node.pages.find_by_revision( params[:start_revision] ) | 24 | @start = @node.resolve_page_reference(params[:start_revision]) |
| 25 | @end = @node.pages.find_by_revision( params[:end_revision] ) | 25 | @end = @node.resolve_page_reference(params[:end_revision]) |
| 26 | @diff_view = params[:view] == "side_by_side" ? :side_by_side : :inline | 26 | |
| 27 | @diff = @end.diff_against( @start, view: @diff_view ) | 27 | if @start.nil? || @end.nil? |
| 28 | flash[:error] = "That comparison is no longer available." | ||
| 29 | redirect_to(node_path(@node)) and return | ||
| 30 | end | ||
| 31 | |||
| 32 | @diff_view = params[:view] == "side_by_side" ? :side_by_side : :inline | ||
| 33 | @diff = @end.diff_against(@start, view: @diff_view) | ||
| 34 | @available_layer_pairs = @node.available_layer_pairs | ||
| 35 | @locked_by_other = @node.locked? && @node.lock_owner != current_user | ||
| 28 | end | 36 | end |
| 29 | 37 | ||
| 30 | def show | 38 | def show |
