Sha256: 387661c183e537894d4afe1fdf733e657c85fefd17b7e642a3cc7ad239d80523

Contents?: true

Size: 816 Bytes

Versions: 5

Compression:

Stored size: 816 Bytes

Contents

# frozen_string_literal: true

module Onebox
  module Engine
    class TrelloOnebox
      include Engine
      include StandardEmbed

      matches_regexp(/^https:\/\/trello\.com\/[bc]\/\W*/)
      requires_iframe_origins "https://trello.com"
      always_https

      def to_html
        src = "https://trello.com/#{match[:type]}/#{match[:key]}.html"
        height = match[:type] == 'b' ? 400 : 200

        <<-HTML
          <iframe src="#{src}" width="100%" height="#{height}" frameborder="0" style="border:0"></iframe>
        HTML
      end

      def placeholder_html
        ::Onebox::Helpers.generic_placeholder_html
      end

      private

      def match
        return @match if defined?(@match)
        @match = @url.match(%{trello\.com/(?<type>[^/]+)/(?<key>[^/]+)/?\W*})
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
onebox-2.2.19 lib/onebox/engine/trello_onebox.rb
onebox-2.2.18 lib/onebox/engine/trello_onebox.rb
onebox-2.2.17 lib/onebox/engine/trello_onebox.rb
onebox-2.2.16 lib/onebox/engine/trello_onebox.rb
onebox-2.2.15 lib/onebox/engine/trello_onebox.rb