From a8cf725312d245d8d1f1df0fff22718975ce249e Mon Sep 17 00:00:00 2001 From: erdgeist Date: Thu, 20 Aug 2026 12:50:30 +0200 Subject: Add redirect ui in in nodes#edit and apply some minor cleanup Also give search inputs a magnifier and a clear control: input_group wraps a field with an icon and, where clearing is meaningful, a button that empties it and any hidden companion named by data-clears. Clean up some inconistency between field hints presented as p and as span. Remove stray console.log. --- app/models/page.rb | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'app/models/page.rb') diff --git a/app/models/page.rb b/app/models/page.rb index 9115ccb0..b17708e7 100644 --- a/app/models/page.rb +++ b/app/models/page.rb @@ -124,7 +124,7 @@ class Page < ApplicationRecord end # One row per non-default locale, read from the actual translation - # row -- never through the locale-dependent accessor, so a locale + # row, never through the locale-dependent accessor, so a locale # with no real translation yet reports as absent rather than quietly # showing a fallback value borrowed from another locale. def translation_summary @@ -311,21 +311,27 @@ class Page < ApplicationRecord published_at.nil? ? true : published_at < Time.now end - # The destination this page sends visitors to, or nil. An internal target - # wins over an external one. A target that is restricted or has no head is - # no destination at all, so the page renders itself rather than linking to - # nothing. The banner partial calls this too, so the precedence cannot - # drift between the redirect and the link. + # Where this page sends visitors, or nil. Internal wins over external. A + # node that is restricted or has no head is no destination at all, so the + # page renders itself rather than pointing at nothing. + RedirectTarget = Struct.new(:node, :url) do + def internal? + node.present? + end + end + def redirect_target return nil if redirect.blank? if redirect_node_id.present? - node = Node.find_by(:id => redirect_node_id) - return nil unless node&.head && !node.restricted? - return node.unique_name + target = Node.find_by(:id => redirect_node_id) + return nil unless target&.head && !target.restricted? + return RedirectTarget.new(target, nil) end - external_url.presence + return RedirectTarget.new(nil, external_url) if external_url.present? + + nil end def redirect_status -- cgit v1.3