diff --git a/app/models/communication/block/template/agenda.rb b/app/models/communication/block/template/agenda.rb index 4d82d29f628f92ffec6e48cf1b283c7c7c6b4506..a178fb36596fbc1654f2c4f48e99b424a0f24e74 100644 --- a/app/models/communication/block/template/agenda.rb +++ b/app/models/communication/block/template/agenda.rb @@ -64,6 +64,10 @@ class Communication::Block::Template::Agenda < Communication::Block::Template::B link_to_events end + def top_link + title_link + end + protected def link_to_events diff --git a/app/models/communication/block/template/base.rb b/app/models/communication/block/template/base.rb index 3639ff7838598fc88f8f1aa2e9571d5f65afb44c..bf91cf825eaed057d9709d4d9ca5ddb90f215020 100644 --- a/app/models/communication/block/template/base.rb +++ b/app/models/communication/block/template/base.rb @@ -2,6 +2,7 @@ class Communication::Block::Template::Base include WithAccessibility include WithData include WithDependencies + include WithTop class_attribute :components_descriptions, :layouts, diff --git a/app/models/communication/block/template/base/with_top.rb b/app/models/communication/block/template/base/with_top.rb new file mode 100644 index 0000000000000000000000000000000000000000..f4cdeed0da00e279594225d1ad204f762a1f85ec --- /dev/null +++ b/app/models/communication/block/template/base/with_top.rb @@ -0,0 +1,19 @@ +module Communication::Block::Template::Base::WithTop + extend ActiveSupport::Concern + + def top_title + block.try(:title) + end + + def top_description + try(:description) + end + + def top_link + nil + end + + def top_heading + block.heading_rank_base + end +end diff --git a/app/models/communication/block/template/call_to_action.rb b/app/models/communication/block/template/call_to_action.rb index 823cb1df2b5e0123f24c1f1490fe1a70802780f7..a38bcd4b4aaffc39cfeccf38b7a53234df601774 100644 --- a/app/models/communication/block/template/call_to_action.rb +++ b/app/models/communication/block/template/call_to_action.rb @@ -11,6 +11,10 @@ class Communication::Block::Template::CallToAction < Communication::Block::Templ has_component :alt, :string has_component :credit, :rich_text + def top_description + text + end + protected def check_accessibility diff --git a/app/models/communication/block/template/page.rb b/app/models/communication/block/template/page.rb index 4889efca62406a1091257d36a75ba0413402d71d..deb6df9b7a124aef6556e321044a686435114828 100644 --- a/app/models/communication/block/template/page.rb +++ b/app/models/communication/block/template/page.rb @@ -9,7 +9,7 @@ class Communication::Block::Template::Page < Communication::Block::Template::Bas :large ] has_component :mode, :option, options: [:selection, :children] - has_component :text, :rich_text + has_component :text, :rich_text # Deprecated has_component :page_id, :page has_component :option_image, :boolean, default: true @@ -36,8 +36,23 @@ class Communication::Block::Template::Page < Communication::Block::Template::Bas selected_pages end + def top_title + block.title.presence || page_l10n.to_s + end + + def top_description + page_l10n.try(:summary) + end + protected + def page_l10n + return nil if page.nil? + l10n = page.localization_for(language) + return nil if l10n.draft? + l10n + end + def selected_pages_selection elements.map { |element| element.page }.compact end diff --git a/app/models/communication/block/template/paper.rb b/app/models/communication/block/template/paper.rb index d60705594a8fb6615c6078d8a732a99c967d5e2b..1ad969baa44f6fcb3eb21abdb379f1e5dc0245fd 100644 --- a/app/models/communication/block/template/paper.rb +++ b/app/models/communication/block/template/paper.rb @@ -23,6 +23,12 @@ class Communication::Block::Template::Paper < Communication::Block::Template::Ba selected_papers end + def top_link + l10n = special_page.localization_for(language) + return nil if l10n.nil? + l10n.hugo(website).permalink + end + protected def selected_papers_all @@ -43,4 +49,8 @@ class Communication::Block::Template::Paper < Communication::Block::Template::Ba def available_papers website.research_papers end + + def special_page + @special_page ||= website.special_page(Communication::Website::Page::ResearchPaper) + end end diff --git a/app/views/admin/communication/blocks/_static.html.erb b/app/views/admin/communication/blocks/_static.html.erb index e52694a3418d23aea600d32c30734a24eacdf10a..4a980491341cf09f71772b980763f6dd0e8a68c6 100644 --- a/app/views/admin/communication/blocks/_static.html.erb +++ b/app/views/admin/communication/blocks/_static.html.erb @@ -18,6 +18,20 @@ should_render_data = block.data && block.data.present? <% end %> <% if block.html_class.present? %> html_class: "<%= block.html_class_prepared %>" +<% end %> + top: +<% if block.template.top_title.present? %> + title: + value: >- + <%= prepare_text_for_static block.template.top_title %> + heading: <%= block.template.top_heading %> +<% if block.template.top_link.present? %> + link: "<%= block.template.top_link %>" +<% end %> +<% end %> +<% if block.template.top_description.present? %> + description: >- + <%= prepare_html_for_static block.template.top_description %> <% end %> data: <%= render template_path,