diff --git a/app/models/communication/block.rb b/app/models/communication/block.rb index 741732bcd1888253c3cfca779dc9b49f89131d8c..fc952963b097b33781772ce7141a809a03c88c86 100644 --- a/app/models/communication/block.rb +++ b/app/models/communication/block.rb @@ -40,6 +40,7 @@ class Communication::Block < ApplicationRecord IMAGE_MAX_SIZE = 5.megabytes FILE_MAX_SIZE = 100.megabytes BLOCK_COPY_COOKIE = 'osuny-content-editor-block-copy' + DEFAULT_HEADING_LEVEL = 2 # h1 is the page title belongs_to :about, polymorphic: true belongs_to :heading, optional: true @@ -161,6 +162,11 @@ class Communication::Block < ApplicationRecord template.full_text end + def heading_level + heading.present? ? heading.level + 1 + : DEFAULT_HEADING_LEVEL + end + def to_s title.blank? ? "#{Communication::Block.model_name.human} #{position}" : "#{title}" diff --git a/app/models/communication/block/template/agenda.rb b/app/models/communication/block/template/agenda.rb index 9f462772ad0d33f748d47471526fa6f18d411cb6..9442948a9dd4374f72747ad0eb56409975140081 100644 --- a/app/models/communication/block/template/agenda.rb +++ b/app/models/communication/block/template/agenda.rb @@ -12,7 +12,10 @@ class Communication::Block::Template::Agenda < Communication::Block::Template::B has_component :description, :rich_text has_component :quantity, :number, options: 3 has_component :time, :option, options: [:future_or_present, :future, :present, :archive] - + has_component :show_category, :boolean + has_component :show_summary, :boolean + has_component :show_status, :boolean + def selected_events @selected_events ||= events_with_time_scope end diff --git a/app/services/video/provider/youtube.rb b/app/services/video/provider/youtube.rb index 88c249d6eb97e8e99ff1bd30789e1ab8d32f1f7b..82dfe20f87e789a4bd444ca4d893011f37a58d4f 100644 --- a/app/services/video/provider/youtube.rb +++ b/app/services/video/provider/youtube.rb @@ -7,8 +7,8 @@ class Video::Provider::Youtube < Video::Provider::Default ] def identifier - video_url.include?('youtu.be') ? identifier_path - : identifier_param + short_url? ? param_from_short_url + : param_from_regular_url end def csp_domains @@ -32,13 +32,20 @@ class Video::Provider::Youtube < Video::Provider::Default protected - def identifier_path - video_url.split('youtu.be/').last + def short_url? + video_url.include?('youtu.be') end - - def identifier_param + + # youtube.com, www.youtube.com + def param_from_regular_url uri = URI(video_url) params = CGI::parse(uri.query) params['v'].first end + + # youtu.be + def param_from_short_url + video_url.split('youtu.be/').last + .split('?').first + end end diff --git a/app/views/admin/communication/blocks/_static.html.erb b/app/views/admin/communication/blocks/_static.html.erb index 77e6feed7227b6207491f6c5e6a338b7ce05e974..c19209abba1c87538720f5d735e91bcbf4d7ad7c 100644 --- a/app/views/admin/communication/blocks/_static.html.erb +++ b/app/views/admin/communication/blocks/_static.html.erb @@ -7,6 +7,7 @@ should_render_data = block.data && block.data.present? title: >- <%= prepare_text_for_static block.title %> position: <%= block.position %> + heading_level: <%= block.heading_level %> data: <%= render template_path, block: block, diff --git a/app/views/admin/communication/blocks/components/option/_edit.html.erb b/app/views/admin/communication/blocks/components/option/_edit.html.erb index 5613883b66bd88ab46207cbc8b70faea8d03229e..e883aecdba1b69bbd3b60bceeb76836668a3d6ea 100644 --- a/app/views/admin/communication/blocks/components/option/_edit.html.erb +++ b/app/views/admin/communication/blocks/components/option/_edit.html.erb @@ -1,5 +1,5 @@ <fieldset class="mb-3"> - <legend class="col-form-label"><%= label %></legend> + <legend class="form-label"><%= label %></legend> <% component.options.each do |option| %> <div class="form-check"> <input class="form-check-input" diff --git a/app/views/admin/communication/blocks/templates/agenda/_edit.html.erb b/app/views/admin/communication/blocks/templates/agenda/_edit.html.erb index 4a7e9278d614e6f44c51b08c6d58e6676b0c6508..cc218ace713382a59067685870226ea9ce873d0a 100644 --- a/app/views/admin/communication/blocks/templates/agenda/_edit.html.erb +++ b/app/views/admin/communication/blocks/templates/agenda/_edit.html.erb @@ -4,9 +4,17 @@ <div class="col-xl-6"> <%= block_component_edit block, :description %> </div> +</div> + + +<div class="row pure__row--small"> <div class="col-xl-6"> <%= block_component_edit block, :quantity %> + <%= block_component_edit block, :show_summary %> + <%= block_component_edit block, :show_category %> + <%= block_component_edit block, :show_status %> + </div> + <div class="col-xl-6"> + <%= block_component_edit block, :time %> </div> </div> - -<%= block_component_edit block, :time %> \ No newline at end of file diff --git a/app/views/admin/communication/blocks/templates/agenda/_static.html.erb b/app/views/admin/communication/blocks/templates/agenda/_static.html.erb index ab663bee370e0c454303cb16fcbf2edf1cd79ce6..19b26ea0e9fbf219a9a5dc55f52275a027368d4f 100644 --- a/app/views/admin/communication/blocks/templates/agenda/_static.html.erb +++ b/app/views/admin/communication/blocks/templates/agenda/_static.html.erb @@ -1,5 +1,9 @@ layout: <%= block.template.layout %> <%= block_component_static block, :description %> + show_summary: <%= block.template.show_summary %> + show_category: <%= block.template.show_category %> + show_status: <%= block.template.show_status %> + events: <% block.template.selected_events.each do |element| %> - path: "<%= element.current_permalink_in_website(@website)&.path %>" diff --git a/config/locales/communication/contents/en.yml b/config/locales/communication/contents/en.yml index c46d6921c82b24c26dd055795e219ea06ac07d82..5243a645d30d85ecec6e7774a25bf589878cfc39 100644 --- a/config/locales/communication/contents/en.yml +++ b/config/locales/communication/contents/en.yml @@ -71,6 +71,12 @@ en: quantity: label: Quantity of events to show placeholder: Enter quantity + show_category: + label: Show events' categories + show_summary: + label: Show events' summaries + show_status: + label: Show events' status (present, future...) time: label: Which events? options: diff --git a/config/locales/communication/contents/fr.yml b/config/locales/communication/contents/fr.yml index 91ed713a2407e98feeccacb934f0d47b37ea65f4..e165a43b5c5cc238ba85a7090252d46c4b7c512a 100644 --- a/config/locales/communication/contents/fr.yml +++ b/config/locales/communication/contents/fr.yml @@ -71,6 +71,12 @@ fr: quantity: label: Quantité d'événements à afficher placeholder: Entrer la quantité + show_category: + label: Afficher les catégories des événements + show_summary: + label: Afficher le résumé des événements + show_status: + label: Afficher le statut des événements (en cours, à venir...) time: label: Quels événements afficher ? options: