Sha256: bba5e786f7361282934cc218c01cd6c0324de3a97d82ac7fb251d5235407d227

Contents?: true

Size: 835 Bytes

Versions: 21

Compression:

Stored size: 835 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
        link = "https://trello.com/#{match[:type]}/#{match[:key]}.html"

        height = match[:type] == 'b' ? 400 : 200

        <<-HTML
          <iframe src=\"#{link}\" 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 @match

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

        @match
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
onebox-2.2.12 lib/onebox/engine/trello_onebox.rb
onebox-2.2.11 lib/onebox/engine/trello_onebox.rb
onebox-2.2.10 lib/onebox/engine/trello_onebox.rb
onebox-2.2.9 lib/onebox/engine/trello_onebox.rb
onebox-2.2.8 lib/onebox/engine/trello_onebox.rb
onebox-2.2.6 lib/onebox/engine/trello_onebox.rb
onebox-2.2.5 lib/onebox/engine/trello_onebox.rb
onebox-2.2.4 lib/onebox/engine/trello_onebox.rb
onebox-2.2.2 lib/onebox/engine/trello_onebox.rb
onebox-2.2.1 lib/onebox/engine/trello_onebox.rb
onebox-2.2.0 lib/onebox/engine/trello_onebox.rb
onebox-2.1.9 lib/onebox/engine/trello_onebox.rb
onebox-2.1.8 lib/onebox/engine/trello_onebox.rb
onebox-2.1.7 lib/onebox/engine/trello_onebox.rb
onebox-2.1.6 lib/onebox/engine/trello_onebox.rb
onebox-2.1.5 lib/onebox/engine/trello_onebox.rb
onebox-2.1.4 lib/onebox/engine/trello_onebox.rb
onebox-2.1.3 lib/onebox/engine/trello_onebox.rb
onebox-2.1.2 lib/onebox/engine/trello_onebox.rb
onebox-2.1.1 lib/onebox/engine/trello_onebox.rb