Skip to content
Snippets Groups Projects
Unverified Commit 9eb1af9d authored by Arnaud Levy's avatar Arnaud Levy Committed by GitHub
Browse files

Merge branch 'main' into block-agenda-settings

parents 87bc3069 9c1a1653
No related branches found
Tags v6.0.14
No related merge requests found
......@@ -39,6 +39,7 @@ class Communication::Block < ApplicationRecord
IMAGE_MAX_SIZE = 5.megabytes
FILE_MAX_SIZE = 100.megabytes
DEFAULT_HEADING_LEVEL = 2 # h1 is the page title
belongs_to :about, polymorphic: true
belongs_to :heading, optional: true
......@@ -152,6 +153,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}"
......
......@@ -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
......@@ -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,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment