Sha256: 5e90aa82a8a08fa1e6bfb3c7cf250b99bfe4b629a0a2b3e5899b04041555c1c6

Contents?: true

Size: 1.18 KB

Versions: 1

Compression:

Stored size: 1.18 KB

Contents

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?
          return image_html(og)
        elsif og.title.to_s[/\.(mp4|ogv|webm)$/]
          return video_html(og)
        else
          return link_html(og)
        end
      end

      private

      def link_html(og)
        <<-HTML
            <a href='#{og.url}' target='_blank'>
              #{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'>
              <img src='#{og.image}' #{og.title_attr} alt='CloudApp' width='480'>
            </a>
          HTML
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
onebox-1.8.81 lib/onebox/engine/cloudapp_onebox.rb