summaryrefslogtreecommitdiff
path: root/app/models/page.rb
diff options
context:
space:
mode:
authorerdgeist <erdgeist@erdgeist.org>2026-08-20 12:50:30 +0200
committererdgeist <erdgeist@erdgeist.org>2026-08-20 12:50:30 +0200
commita8cf725312d245d8d1f1df0fff22718975ce249e (patch)
treec5084dfe79e6eac647b0253a305361aa8ff6efbc /app/models/page.rb
parent4df88b601b1900c287051d827eaff46f498f60d0 (diff)
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.
Diffstat (limited to 'app/models/page.rb')
-rw-r--r--app/models/page.rb26
1 files changed, 16 insertions, 10 deletions
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
124 end 124 end
125 125
126 # One row per non-default locale, read from the actual translation 126 # One row per non-default locale, read from the actual translation
127 # row -- never through the locale-dependent accessor, so a locale 127 # row, never through the locale-dependent accessor, so a locale
128 # with no real translation yet reports as absent rather than quietly 128 # with no real translation yet reports as absent rather than quietly
129 # showing a fallback value borrowed from another locale. 129 # showing a fallback value borrowed from another locale.
130 def translation_summary 130 def translation_summary
@@ -311,21 +311,27 @@ class Page < ApplicationRecord
311 published_at.nil? ? true : published_at < Time.now 311 published_at.nil? ? true : published_at < Time.now
312 end 312 end
313 313
314 # The destination this page sends visitors to, or nil. An internal target 314 # Where this page sends visitors, or nil. Internal wins over external. A
315 # wins over an external one. A target that is restricted or has no head is 315 # node that is restricted or has no head is no destination at all, so the
316 # no destination at all, so the page renders itself rather than linking to 316 # page renders itself rather than pointing at nothing.
317 # nothing. The banner partial calls this too, so the precedence cannot 317 RedirectTarget = Struct.new(:node, :url) do
318 # drift between the redirect and the link. 318 def internal?
319 node.present?
320 end
321 end
322
319 def redirect_target 323 def redirect_target
320 return nil if redirect.blank? 324 return nil if redirect.blank?
321 325
322 if redirect_node_id.present? 326 if redirect_node_id.present?
323 node = Node.find_by(:id => redirect_node_id) 327 target = Node.find_by(:id => redirect_node_id)
324 return nil unless node&.head && !node.restricted? 328 return nil unless target&.head && !target.restricted?
325 return node.unique_name 329 return RedirectTarget.new(target, nil)
326 end 330 end
327 331
328 external_url.presence 332 return RedirectTarget.new(nil, external_url) if external_url.present?
333
334 nil
329 end 335 end
330 336
331 def redirect_status 337 def redirect_status