Sha256: ba7c913514adb637e2560f468d1238248f8a97c0e8429412cb950ab563286be1

Contents?: true

Size: 589 Bytes

Versions: 10

Compression:

Stored size: 589 Bytes

Contents

# frozen_string_literal: true

module Onebox
  module Engine
    class AudioOnebox
      include Engine

      matches_regexp(/^(https?:)?\/\/.*\.(mp3|ogg|opus|wav|m4a)(\?.*)?$/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
          <audio controls>
            <source src="#{escaped_url}">
            <a href="#{escaped_url}">#{@url}</a>
          </audio>
        HTML
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
onebox-1.8.99 lib/onebox/engine/audio_onebox.rb
onebox-1.8.98 lib/onebox/engine/audio_onebox.rb
onebox-1.8.97 lib/onebox/engine/audio_onebox.rb
onebox-1.8.96 lib/onebox/engine/audio_onebox.rb
onebox-1.8.95 lib/onebox/engine/audio_onebox.rb
onebox-1.8.94 lib/onebox/engine/audio_onebox.rb
onebox-1.8.93 lib/onebox/engine/audio_onebox.rb
onebox-1.8.92 lib/onebox/engine/audio_onebox.rb
onebox-1.8.91 lib/onebox/engine/audio_onebox.rb
onebox-1.8.90 lib/onebox/engine/audio_onebox.rb