Sha256: c4b080a63f181a280f01537046fdd2ff29200873bf0ec4e6eda8a6863efdd2cd

Contents?: true

Size: 1.39 KB

Versions: 38

Compression:

Stored size: 1.39 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 !Onebox::Helpers::blank?(og[:image])
          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)
          escaped_url = ::Onebox::Helpers.normalize_url_for_output(og[:url])

          <<-HTML
            <a href='#{escaped_url}' target='_blank'>
              #{og[:title]}
            </a>
          HTML
        end

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

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

        def image_html(og)
          escaped_url = ::Onebox::Helpers.normalize_url_for_output(og[:url])

          <<-HTML
            <a href='#{escaped_url}' target='_blank'>
              <img src='#{og[:image]}' #{Helpers.title_attr(og)} alt='CloudApp' width='480'>
            </a>
          HTML
        end
    end
  end
end

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
onebox-1.8.55 lib/onebox/engine/cloudapp_onebox.rb
onebox-1.8.54 lib/onebox/engine/cloudapp_onebox.rb
onebox-1.8.53 lib/onebox/engine/cloudapp_onebox.rb
onebox-1.8.52 lib/onebox/engine/cloudapp_onebox.rb
onebox-1.8.51 lib/onebox/engine/cloudapp_onebox.rb
onebox-1.8.50 lib/onebox/engine/cloudapp_onebox.rb
onebox-1.8.49 lib/onebox/engine/cloudapp_onebox.rb
onebox-1.8.48 lib/onebox/engine/cloudapp_onebox.rb
onebox-1.8.47 lib/onebox/engine/cloudapp_onebox.rb
onebox-1.8.46 lib/onebox/engine/cloudapp_onebox.rb
onebox-1.8.45 lib/onebox/engine/cloudapp_onebox.rb
onebox-1.8.44 lib/onebox/engine/cloudapp_onebox.rb
onebox-1.8.43 lib/onebox/engine/cloudapp_onebox.rb
onebox-1.8.42 lib/onebox/engine/cloudapp_onebox.rb
onebox-1.8.41 lib/onebox/engine/cloudapp_onebox.rb
onebox-1.8.40 lib/onebox/engine/cloudapp_onebox.rb
onebox-1.8.39 lib/onebox/engine/cloudapp_onebox.rb
onebox-1.8.38 lib/onebox/engine/cloudapp_onebox.rb
onebox-1.8.36 lib/onebox/engine/cloudapp_onebox.rb
onebox-1.8.35 lib/onebox/engine/cloudapp_onebox.rb