Sha256: 938533e1866db3a502ce64b7bb721cd990a299497050796e8cac05bf0b325e44

Contents?: true

Size: 944 Bytes

Versions: 10

Compression:

Stored size: 944 Bytes

Contents

module Onebox
  module Engine
    class GfycatOnebox
      include Engine
      include StandardEmbed

      matches_regexp(/^https?:\/\/gfycat\.com\//)
      always_https

      def to_html
        oembed = get_oembed
        src = Nokogiri::HTML::fragment(oembed[:html]).at_css("iframe")["src"]
        escaped_src = ::Onebox::Helpers.normalize_url_for_output(src)

        <<-HTML
          <iframe src="#{escaped_src}"
                  width="#{oembed[:width]}"
                  height="#{oembed[:height]}"
                  scrolling="no"
                  frameborder="0"
                  allowfullscreen>
          </iframe>
        HTML
      end

      def placeholder_html
        og = get_opengraph
        escaped_src = ::Onebox::Helpers.normalize_url_for_output(og[:image])

        <<-HTML
          <img src="#{escaped_src}" width="#{og[:image_width]}" height="#{og[:image_height]}">
        HTML
      end

    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
onebox-1.8.3 lib/onebox/engine/gfycat_onebox.rb
onebox-1.8.2 lib/onebox/engine/gfycat_onebox.rb
onebox-1.8.1 lib/onebox/engine/gfycat_onebox.rb
onebox-1.8.0 lib/onebox/engine/gfycat_onebox.rb
onebox-1.7.9 lib/onebox/engine/gfycat_onebox.rb
onebox-1.7.8 lib/onebox/engine/gfycat_onebox.rb
onebox-1.7.7 lib/onebox/engine/gfycat_onebox.rb
onebox-1.7.6 lib/onebox/engine/gfycat_onebox.rb
onebox-1.7.5 lib/onebox/engine/gfycat_onebox.rb
onebox-1.7.4 lib/onebox/engine/gfycat_onebox.rb