diff --git a/lib/jekyll-spaceship/processors/media-processor.rb b/lib/jekyll-spaceship/processors/media-processor.rb index 4fdf3df..dec25ac 100644 --- a/lib/jekyll-spaceship/processors/media-processor.rb +++ b/lib/jekyll-spaceship/processors/media-processor.rb @@ -42,7 +42,7 @@ def handle_normal_audio(element) handle_media(element, { media_type: 'audio', host: '(https?:\\/\\/)?.*\\/', - id: '(.+?\\.(mp3|wav|ogg|mid|midi|aac|wma))', + id: '(.+?\\.(mp3|wav|ogg|mid|midi|aac|wma))' }) end @@ -53,7 +53,7 @@ def handle_normal_audio(element) # ![video](//techslides.com/demos/sample-videos/small.mp4?width=400) def handle_normal_video(element) handle_media(element, { - media_type: 'iframe', + media_type: 'video', host: '(https?:\\/\\/)?.*\\/', id: '(.+?\\.(avi|mp4|webm|ogg|ogv|flv|mkv|mov|wmv|3gp|rmvb|asf))' }) @@ -158,6 +158,10 @@ def handle_media(element, data) cfg['loop'] = qs['loop'] || data[:loop] || cfg['loop'] cfg['style'] += ';display: none;' if qs['hidden'] handle_audio(element, { cfg: cfg }) + when 'video' + cfg['autoplay'] = qs['autoplay'] || data[:autoplay] || cfg['autoplay'] + cfg['loop'] = qs['loop'] || data[:loop] || cfg['loop'] + handle_video(element, { cfg: cfg }) when 'iframe' cfg['title'] = title cfg['width'] = qs['width'] || data[:width] || cfg['width'] @@ -188,6 +192,25 @@ def handle_audio(element, data) element.replace(doc.at('body').children.first) end + def handle_video(element, data) + cfg = data[:cfg] + html = "" \ + " " \ + " Your browser doesn't support HTML5 video."\ + " Here is a link to download the video"\ + " instead."\ + "" + doc = Nokogiri::HTML(html) + return if element.parent.nil? + element.replace(doc.at('body').children.first) + end + def handle_iframe(element, data) cfg = data[:cfg] html = "