Sha256: f5816b01c6a4f6a681fd57b6ab862d12c0e9a665e32fba7d7ba9ab73e9b61716

Contents?: true

Size: 644 Bytes

Versions: 78

Compression:

Stored size: 644 Bytes

Contents

module Onebox
  module Engine
    class AsciinemaOnebox
      include Engine
      include StandardEmbed

      always_https

      matches_regexp(/^https?:\/\/asciinema\.org\/a\/[\p{Alnum}_\-]+$/)

      def to_html
        "<script type='text/javascript' src='https://asciinema.org/a/#{match[:asciinema_id]}.js' id='asciicast-#{match[:asciinema_id]}' async></script>"
      end

      def placeholder_html
        "<img src='https://asciinema.org/a/#{match[:asciinema_id]}.png'>"
      end

      private

        def match
          @match ||= @url.match(/asciinema\.org\/a\/(?<asciinema_id>[\p{Alnum}_\-]+)$/)
        end
    end
  end
end

Version data entries

78 entries across 78 versions & 1 rubygems

Version Path
onebox-1.8.26 lib/onebox/engine/asciinema_onebox.rb
onebox-1.8.25 lib/onebox/engine/asciinema_onebox.rb
onebox-1.8.24 lib/onebox/engine/asciinema_onebox.rb
onebox-1.8.23 lib/onebox/engine/asciinema_onebox.rb
onebox-1.8.22 lib/onebox/engine/asciinema_onebox.rb
onebox-1.8.21 lib/onebox/engine/asciinema_onebox.rb
onebox-1.8.20 lib/onebox/engine/asciinema_onebox.rb
onebox-1.8.19 lib/onebox/engine/asciinema_onebox.rb
onebox-1.8.18 lib/onebox/engine/asciinema_onebox.rb
onebox-1.8.17 lib/onebox/engine/asciinema_onebox.rb
onebox-1.8.16 lib/onebox/engine/asciinema_onebox.rb
onebox-1.8.15 lib/onebox/engine/asciinema_onebox.rb
onebox-1.8.14 lib/onebox/engine/asciinema_onebox.rb
onebox-1.8.13 lib/onebox/engine/asciinema_onebox.rb
onebox-1.8.12 lib/onebox/engine/asciinema_onebox.rb
onebox-1.8.11 lib/onebox/engine/asciinema_onebox.rb
onebox-1.8.10 lib/onebox/engine/asciinema_onebox.rb
onebox-1.8.9 lib/onebox/engine/asciinema_onebox.rb
onebox-1.8.8 lib/onebox/engine/asciinema_onebox.rb
onebox-1.8.7 lib/onebox/engine/asciinema_onebox.rb