Sha256: 03a1ef0b5f7ed9fbc82407cd170403c4150a09e8b1fda6476a4789a4940973f1

Contents?: true

Size: 1.17 KB

Versions: 32

Compression:

Stored size: 1.17 KB

Contents

# frozen_string_literal: true

module Onebox
  module Engine
    class CloudAppOnebox
      include Engine
      include StandardEmbed

      matches_regexp(/^https?:\/\/cl\.ly/)
      always_https

      def to_html
        og = get_opengraph

        if !og.image.nil?
          image_html(og)
        elsif og.title.to_s[/\.(mp4|ogv|webm)$/]
          video_html(og)
        else
          link_html(og)
        end
      end

      private

      def link_html(og)
        <<-HTML
            <a href='#{og.url}' target='_blank' rel='noopener'>
              #{og.title}
            </a>
          HTML
      end

      def video_html(og)
        direct_src = ::Onebox::Helpers.normalize_url_for_output("#{og.get(:url)}/#{og.title}")

        <<-HTML
            <video width='480' height='360' #{og.title_attr} controls loop>
              <source src='#{direct_src}' type='video/mp4'>
            </video>
          HTML
      end

      def image_html(og)
        <<-HTML
            <a href='#{og.url}' target='_blank' class='onebox' rel='noopener'>
              <img src='#{og.image}' #{og.title_attr} alt='CloudApp' width='480'>
            </a>
          HTML
      end
    end
  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
onebox-2.1.0 lib/onebox/engine/cloudapp_onebox.rb
onebox-2.0.2 lib/onebox/engine/cloudapp_onebox.rb
onebox-2.0.1 lib/onebox/engine/cloudapp_onebox.rb
onebox-2.0.0 lib/onebox/engine/cloudapp_onebox.rb
onebox-1.9.30 lib/onebox/engine/cloudapp_onebox.rb
onebox-1.9.29 lib/onebox/engine/cloudapp_onebox.rb
onebox-1.9.28.4 lib/onebox/engine/cloudapp_onebox.rb
onebox-1.9.28.3 lib/onebox/engine/cloudapp_onebox.rb
onebox-1.9.28.2 lib/onebox/engine/cloudapp_onebox.rb
onebox-1.9.28.1 lib/onebox/engine/cloudapp_onebox.rb
onebox-1.9.28 lib/onebox/engine/cloudapp_onebox.rb
onebox-1.9.27.2 lib/onebox/engine/cloudapp_onebox.rb