Sha256: 8ece7c340e3859dff740da0a102cf66d1fc62285ca976f619d6a1dd67e800c38
Contents?: true
Size: 1.63 KB
Versions: 33
Compression:
Stored size: 1.63 KB
Contents
module Onebox module Engine class GfycatOnebox include Engine include JSON matches_regexp(/^https?:\/\/gfycat\.com\//) always_https def self.priority # This engine should have priority over WhitelistedGenericOnebox. 1 end def url "https://gfycat.com/cajax/get/#{match[:name]}" end def to_html <<-HTML <div> <video controls loop autoplay muted poster="#{data[:posterUrl]}" width="#{data[:width]}" height="#{data[:height]}"> <source id="webmSource" src="#{data[:webmUrl]}" type="video/webm"> <source id="mp4Source" src="#{data[:mp4Url]}" type="video/mp4"> <img title="Sorry, your browser doesn't support HTML5 video." src="#{data[:posterUrl]}"> </video><br/> <a href="#{data[:url]}">#{data[:name]}</a> </div> HTML end def placeholder_html <<-HTML <a href="#{data[:url]}"> <img src="#{data[:posterUrl]}" width="#{data[:width]}" height="#{data[:height]}"><br/> #{data[:gfyName]} </a> HTML end private def match @match ||= @url.match(/^https?:\/\/gfycat\.com\/(?<name>.+)/) end def data { name: raw['gfyItem']['gfyName'], url: @url, posterUrl: raw['gfyItem']['posterUrl'], webmUrl: raw['gfyItem']['webmUrl'], mp4Url: raw['gfyItem']['mp4Url'], width: raw['gfyItem']['width'], height: raw['gfyItem']['height'] } end end end end
Version data entries
33 entries across 33 versions & 1 rubygems