Class: Decidim::Meetings::MeetingIframeEmbedder

Inherits:
Object
  • Object
show all
Defined in:
decidim-meetings/app/services/decidim/meetings/meeting_iframe_embedder.rb

Overview

This class handles the streaming url to be included in the iframe present in the live event. For some services it's required to transforma a bit the structure of the URL.

Instance Method Summary collapse

Constructor Details

#initialize(online_meeting_service_url) ⇒ MeetingIframeEmbedder

Public: Initializes the service. online_meeting_service_url - A String containing the url of the online meeting


13
14
15
# File 'decidim-meetings/app/services/decidim/meetings/meeting_iframe_embedder.rb', line 13

def initialize(online_meeting_service_url)
  @online_meeting_service_url = online_meeting_service_url
end

Instance Method Details

#embed_code(request_host) ⇒ Object


36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'decidim-meetings/app/services/decidim/meetings/meeting_iframe_embedder.rb', line 36

def embed_code(request_host)
  return nil if parsed_online_meeting_uri.nil?

  %(
<div
  class="disabled-iframe"
  allow="camera; microphone; fullscreen; display-capture; autoplay"
  loading="lazy"
  src="#{embed_transformed_url(request_host)}"
  style="height: 100%; width: 100%; border: 0px;"
></div>
  )
end

#embed_transformed_url(request_host) ⇒ Object


17
18
19
20
21
22
23
24
25
26
27
28
# File 'decidim-meetings/app/services/decidim/meetings/meeting_iframe_embedder.rb', line 17

def embed_transformed_url(request_host)
  return nil if parsed_online_meeting_uri.nil?

  case parsed_online_meeting_uri.host
  when "www.youtube.com"
    transform_youtube_url(parsed_online_meeting_uri)
  when "www.twitch.tv"
    transform_twitch_url(parsed_online_meeting_uri, request_host)
  else
    online_meeting_service_url
  end
end

#embeddable?Boolean

Returns:

  • (Boolean)

30
31
32
33
34
# File 'decidim-meetings/app/services/decidim/meetings/meeting_iframe_embedder.rb', line 30

def embeddable?
  return nil if parsed_online_meeting_uri.nil?

  embeddable_services.include?(parsed_online_meeting_uri.host)
end