Skip to content
Snippets Groups Projects
Commit 62d42753 authored by Arnaud Levy's avatar Arnaud Levy
Browse files

wip

parent faf1ca75
No related branches found
No related tags found
No related merge requests found
......@@ -318,7 +318,7 @@ GEM
listen (3.8.0)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
loofah (2.21.3)
loofah (2.21.4)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
mail (2.8.1)
......@@ -450,7 +450,7 @@ GEM
rb-fsevent (0.11.2)
rb-inotify (0.10.1)
ffi (~> 1.0)
regexp_parser (2.8.1)
regexp_parser (2.8.2)
requests (1.0.2)
require_all (3.0.0)
responders (3.1.0)
......
......@@ -5,11 +5,31 @@ class Communication::Block::Template::Video < Communication::Block::Template::Ba
has_component :transcription, :text
def video_iframe
Video::Provider.find(url).iframe_tag(title: video_title)
video_provider.iframe_tag(title: video_title)
end
def video_platform
video_provider.platform
end
def video_identifier
video_provider.identifier
end
def video_poster
video_provider.poster
end
def video_embed
video_provider.embed
end
protected
def video_provider
@video_provider ||= Video::Provider.find(url)
end
def check_accessibility
super
accessibility_error 'accessibility.blocks.templates.video.title_missing' if block.title.blank? && video_title.blank?
......
......@@ -6,6 +6,11 @@ class Video::Provider::Dailymotion < Video::Provider::Default
: video_url.split('video/').last
end
# https://www.dailymotion.com/thumbnail/video/x8lyp39
def poster
"https://www.dailymotion.com/thumbnail/video/#{identifier}"
end
# https://developer.dailymotion.com/player#player-parameters
def iframe_url
"https://www.dailymotion.com/embed/video/#{identifier}"
......
......@@ -21,6 +21,18 @@ class Video::Provider::Default
URI.parse(iframe_url).host
end
def identifier
''
end
def poster
''
end
def embed
iframe_url
end
def iframe_tag(**iframe_options)
content_tag(:iframe, nil, default_iframe_options.merge(iframe_options))
end
......
......@@ -5,6 +5,11 @@ class Video::Provider::Vimeo < Video::Provider::Default
video_url.chomp('/').split('/').last
end
# https://vumbnail.com/621585396.jpg
def poster
"https://vumbnail.com/#{identifier}.jpg"
end
# https://help.vimeo.com/hc/en-us/articles/360001494447-Using-Player-Parameters
def iframe_url
"https://player.vimeo.com/video/#{identifier}"
......
......@@ -6,6 +6,11 @@ class Video::Provider::Youtube < Video::Provider::Default
: video_url.split('v=').last
end
# https://img.youtube.com/vi/XEEUOiTgJL0/hqdefault.jpg
def poster
"https://img.youtube.com/vi/#{identifier}/hqdefault.jpg"
end
# https://developers.google.com/youtube/player_parameters
def iframe_url
"https://www.youtube.com/embed/#{identifier}"
......
......@@ -3,5 +3,14 @@
<% if block.template.url.present? %>
video_iframe: >-
<%= block.template.video_iframe %>
video:
platform: "<%= block.template.video_platform %>"
identifier: "<%= block.template.video_identifier %>"
poster: >-
<%= block.template.video_poster %>
embed: >-
<%= block.template.video_embed %>
iframe: >-
<%= block.template.video_iframe %>
<% end %>
<%= block_component_static block, :transcription %>
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