20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/textile_extension_pack/tags.rb', line 20
def video(opts)
file_name, width, height, text, img = opts[:text].split('|').map! { |str| str.strip }
width ||= 700
height ||= 395
html = %Q{<div class="video">\n}
html << %Q{<div class="video-wrapper #{opts[:class]}">\n}
html << %Q{<div class="video-wrapper-inner">\n}
html << %Q{<div class="video-wrapper-inner-inner">\n}
html << %Q{ <video width="#{width}" height="#{height}" id="player#{file_name}" poster="#{img}" controls="controls" preload="none"> }
{:mp4 => "mp4", :webm => "webm", :ogg => "ogv"}.each do |format, extension|
html << %Q{ <source type="video/#{format}" src="/files/videos/#{file_name}.#{extension}"/> }
end
html << %Q{ <object width="#{width}" height="#{height}" type="application/x-shockwave-flash" data="/mediaelements/flashmediaelement.swf">
<param name="movie" value="/mediaelements/flashmediaelement.swf"/>
<param name="flashvars" value="controls=true&file=/files/videos/#{file_name}.mp4"/>
</object> }
html << %Q{</div>\n}
html << %Q{</div>\n}
html << %Q{</div>\n}
html << %Q{ <p>#{text}</p>\n} if text.present?
html << %Q{</div>\n}
end
|