Sha256: 1bd9e6a7a43d70fd2f6dd9e30a586c99bd5a8a510f4b409d4309cd8205c89c57

Contents?: true

Size: 898 Bytes

Versions: 1

Compression:

Stored size: 898 Bytes

Contents

AutoHtml.add_filter(:liveleak).with(:width => 420, :height => 315, :frameborder => 0, :wmode => nil, :autoplay => false, :hide_related => false) do |text, options|
  regex = %r{http://www\.liveleak\.com/(?:ll_embed|view)\?.=(\w+)}
  text.gsub(regex) do
    liveleak_id = $1
    width = options[:width]
    height = options[:height]
    frameborder = options[:frameborder]
    wmode = options[:wmode]
    autoplay = options[:autoplay]
    hide_related = options[:hide_related]
    src = "http://www.liveleak.com/ll_embed?f=#{liveleak_id}"
    params = []
    params << "wmode=#{wmode}" if wmode
    params << "autoplay=1" if autoplay
    params << "rel=0" if hide_related
    src += "?#{params.join '&'}" unless params.empty?
    %{<div class="video-container liveleak"><iframe width="#{width}" height="#{height}" src="#{src}" frameborder="#{frameborder}" allowfullscreen></iframe></div>}
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
auto_html-whistlerbrk-2.0.0.pre lib/auto_html/filters/liveleak.rb