diff options
| author | erdgeist <erdgeist@erdgeist.org> | 2026-08-20 19:39:39 +0200 |
|---|---|---|
| committer | erdgeist <erdgeist@erdgeist.org> | 2026-08-20 19:39:39 +0200 |
| commit | a986b1f2b5676624f02373cb54eb3b81b18f3f79 (patch) | |
| tree | 7ea53301f7c00bcec2b9e0349fb9633e0d9e956a | |
| parent | b689127a29b050b9eefac1381fe150ec0da695a8 (diff) | |
Add banner render logic
| -rw-r--r-- | app/controllers/content_controller.rb | 1 | ||||
| -rw-r--r-- | app/models/node.rb | 11 | ||||
| -rw-r--r-- | app/models/page.rb | 17 | ||||
| -rw-r--r-- | app/views/layouts/application.html.erb | 3 | ||||
| -rw-r--r-- | public/stylesheets/ccc.css | 6 |
5 files changed, 29 insertions, 9 deletions
diff --git a/app/controllers/content_controller.rb b/app/controllers/content_controller.rb index debb69b9..8a25f8f7 100644 --- a/app/controllers/content_controller.rb +++ b/app/controllers/content_controller.rb | |||
| @@ -19,6 +19,7 @@ class ContentController < ApplicationController | |||
| 19 | :status => @page.redirect_status) | 19 | :status => @page.redirect_status) |
| 20 | end | 20 | end |
| 21 | 21 | ||
| 22 | @banners = Node.current_banners.to_a | ||
| 22 | render( | 23 | render( |
| 23 | :template => @page.valid_template, | 24 | :template => @page.valid_template, |
| 24 | :layout => true | 25 | :layout => true |
diff --git a/app/models/node.rb b/app/models/node.rb index ef981a97..8f59de43 100644 --- a/app/models/node.rb +++ b/app/models/node.rb | |||
| @@ -632,6 +632,17 @@ class Node < ApplicationRecord | |||
| 632 | .distinct | 632 | .distinct |
| 633 | end | 633 | end |
| 634 | 634 | ||
| 635 | def self.current_banners | ||
| 636 | parent = Node.find_by(:unique_name => CccConventions::BANNER_PARENT_NAME) | ||
| 637 | return Node.none unless parent | ||
| 638 | |||
| 639 | parent.children | ||
| 640 | .joins(:head) | ||
| 641 | .where("pages.published_at IS NULL OR pages.published_at <= ?", Time.now) | ||
| 642 | .order("pages.published_at DESC") | ||
| 643 | .includes(:head => { :related_assets => :asset }) | ||
| 644 | end | ||
| 645 | |||
| 635 | # This one is for admin-only views, where finding a draft is the point. | 646 | # This one is for admin-only views, where finding a draft is the point. |
| 636 | # Substring match on whichever of head/draft is present. | 647 | # Substring match on whichever of head/draft is present. |
| 637 | def self.editor_search(term) | 648 | def self.editor_search(term) |
diff --git a/app/models/page.rb b/app/models/page.rb index 91b7e975..679a4aff 100644 --- a/app/models/page.rb +++ b/app/models/page.rb | |||
| @@ -327,17 +327,16 @@ class Page < ApplicationRecord | |||
| 327 | end | 327 | end |
| 328 | end | 328 | end |
| 329 | 329 | ||
| 330 | def redirect_target | 330 | def link_target |
| 331 | return nil if redirect.blank? | 331 | if redirect_node_id.present? && redirect_node&.head |
| 332 | 332 | RedirectTarget.new(redirect_node, nil) | |
| 333 | if redirect_node_id.present? | 333 | elsif external_url.present? |
| 334 | return nil unless redirect_node&.head | 334 | RedirectTarget.new(nil, external_url) |
| 335 | return RedirectTarget.new(redirect_node, nil) | ||
| 336 | end | 335 | end |
| 336 | end | ||
| 337 | 337 | ||
| 338 | return RedirectTarget.new(nil, external_url) if external_url.present? | 338 | def redirect_target |
| 339 | 339 | redirect.present? ? link_target : nil | |
| 340 | nil | ||
| 341 | end | 340 | end |
| 342 | 341 | ||
| 343 | def redirect_status | 342 | def redirect_status |
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 756b4bdd..55cb4e34 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb | |||
| @@ -64,6 +64,9 @@ | |||
| 64 | <%= calendar %> | 64 | <%= calendar %> |
| 65 | </div> | 65 | </div> |
| 66 | <div id="center_column"> | 66 | <div id="center_column"> |
| 67 | <% if @banners&.any? %> | ||
| 68 | <%= render "content/banner", :banner => @banners.first %> | ||
| 69 | <% end %> | ||
| 67 | <%= yield :layout %> | 70 | <%= yield :layout %> |
| 68 | <div id="footer"> | 71 | <div id="footer"> |
| 69 | <p style="text-align: center"> | 72 | <p style="text-align: center"> |
diff --git a/public/stylesheets/ccc.css b/public/stylesheets/ccc.css index 2cf57a65..52994fde 100644 --- a/public/stylesheets/ccc.css +++ b/public/stylesheets/ccc.css | |||
| @@ -102,6 +102,12 @@ dd { | |||
| 102 | margin-bottom: .5rem; | 102 | margin-bottom: .5rem; |
| 103 | } | 103 | } |
| 104 | 104 | ||
| 105 | .banner img { | ||
| 106 | display: block; | ||
| 107 | max-height: 8rem; | ||
| 108 | width: auto; | ||
| 109 | } | ||
| 110 | |||
| 105 | /* Single caller: _headline_image.html.erb's image-count caption | 111 | /* Single caller: _headline_image.html.erb's image-count caption |
| 106 | ("N Bilder"), shown only when a gallery has more than one image. */ | 112 | ("N Bilder"), shown only when a gallery has more than one image. */ |
| 107 | .right { | 113 | .right { |
