Sha256: 6039a50e33615b27cb95bff0e6b0348f4709964a51bf3b7f920750dd588e49c4

Contents?: true

Size: 1008 Bytes

Versions: 22

Compression:

Stored size: 1008 Bytes

Contents

class Lalala::Markdown::Handlers::Soundcloud < Lalala::Markdown::Handlers::Base

  def initialize(options={})
    options.assert_valid_keys(:width, :height)

    options = {
      width:  560,
      height: 166
    }.merge(options)

    @options = options
  end

  def image(url, alt=nil, title=nil)
    unless %r|^soundcloud[:]//(.+)$| === url
      return ""
    end

    id = $1

    helpers.content_tag :span, class: "embed-container is-soundcloud" do
      helpers.content_tag(
        :iframe,
        "",
        class:          "soundcloud-embed js-soundcloud-embed",
        width:           @options[:width],
        height:          @options[:height],
        src:             "//w.soundcloud.com/player/?auto_play=false&hide_related=true&show_comments=false&show_user=false&show_reposts=false&visual=false",
        :"data-url" =>   "https://soundcloud.com/oembed?format=json&url=https://soundcloud.com/#{id}",
        frameborder:     0,
        allowfullscreen: true
      )
    end
  end

end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
lalala-4.1.0.dev.425 lib/lalala/markdown/handlers/soundcloud.rb
lalala-4.1.0.dev.420 lib/lalala/markdown/handlers/soundcloud.rb
lalala-4.1.0.dev.419 lib/lalala/markdown/handlers/soundcloud.rb
lalala-4.1.0.dev.418 lib/lalala/markdown/handlers/soundcloud.rb
lalala-4.1.0.dev.417 lib/lalala/markdown/handlers/soundcloud.rb
lalala-4.0.0.dev.416 lib/lalala/markdown/handlers/soundcloud.rb
lalala-4.1.0.dev.415 lib/lalala/markdown/handlers/soundcloud.rb
lalala-4.1.0.dev.414 lib/lalala/markdown/handlers/soundcloud.rb
lalala-4.1.0.dev.413 lib/lalala/markdown/handlers/soundcloud.rb
lalala-4.1.0.dev.412 lib/lalala/markdown/handlers/soundcloud.rb
lalala-4.1.0.dev.411 lib/lalala/markdown/handlers/soundcloud.rb
lalala-4.1.0.dev.410 lib/lalala/markdown/handlers/soundcloud.rb
lalala-4.1.0.dev.409 lib/lalala/markdown/handlers/soundcloud.rb
lalala-4.0.0.dev.407 lib/lalala/markdown/handlers/soundcloud.rb
lalala-4.1.0.dev.408 lib/lalala/markdown/handlers/soundcloud.rb
lalala-4.1.0.dev.398 lib/lalala/markdown/handlers/soundcloud.rb
lalala-4.1.0.dev.397 lib/lalala/markdown/handlers/soundcloud.rb
lalala-4.0.0.dev.396 lib/lalala/markdown/handlers/soundcloud.rb
lalala-4.0.0.dev.395 lib/lalala/markdown/handlers/soundcloud.rb
lalala-4.1.0.dev.394 lib/lalala/markdown/handlers/soundcloud.rb