Sha256: aa55ffb34b1e4bcab8c6302407d747f54dd532abaf269ba40924926e3aa03f64

Contents?: true

Size: 821 Bytes

Versions: 2

Compression:

Stored size: 821 Bytes

Contents

# frozen_string_literal: true

module Onebox
  module Engine
    class VideoOnebox
      include Engine

      matches_regexp(/^(https?:)?\/\/.*\.(mov|mp4|webm|ogv)(\?.*)?$/i)

      def always_https?
        WhitelistedGenericOnebox.host_matches(uri, WhitelistedGenericOnebox.https_hosts)
      end

      def to_html
        escaped_url = ::Onebox::Helpers.normalize_url_for_output(@url)
        <<-HTML
          <div class="onebox video-onebox">
            <video width='100%' height='100%' controls>
              <source src='#{escaped_url}'>
              <a href='#{escaped_url}'>#{@url}</a>
            </video>
          </div>
        HTML
      end

      def placeholder_html
        "<div class='onebox-placeholder-container'><span class='placeholder-icon video'></span></div>"
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
onebox-1.9.1 lib/onebox/engine/video_onebox.rb
onebox-1.9.0 lib/onebox/engine/video_onebox.rb