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.392 lib/lalala/markdown/handlers/soundcloud.rb
lalala-4.0.0.dev.393 lib/lalala/markdown/handlers/soundcloud.rb