From d8c4ba78c1eec24ec99c49c198eb5f1fe64cbc06 Mon Sep 17 00:00:00 2001 From: David Cormier Date: Fri, 2 Jan 2015 23:59:51 -0500 Subject: [PATCH 1/2] plugins: add html5 video support Shows ogv, mp4 and webm files inside a video tag --- css/glowingbear.css | 4 ++++ js/plugins.js | 11 ++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/css/glowingbear.css b/css/glowingbear.css index d171615..cf54fed 100644 --- a/css/glowingbear.css +++ b/css/glowingbear.css @@ -309,6 +309,10 @@ div.embed img.embed { max-width: 100%; } +video.embed { + max-width: 100%; +} + div.colourbox { display: inline-block; border-radius: 3px; diff --git a/js/plugins.js b/js/plugins.js index b282d13..8a84758 100644 --- a/js/plugins.js +++ b/js/plugins.js @@ -267,6 +267,15 @@ plugins.factory('userPlugins', function() { } }); + /* + * mp4 video Preview + */ + var videoPlugin = new UrlPlugin('video', function(url) { + if (url.match(/\.(mp4|webm|ogv)\b/i)) { + return ''; + } + }); + /* * Cloud Music Embedded Players */ @@ -382,7 +391,7 @@ plugins.factory('userPlugins', function() { }); return { - plugins: [youtubePlugin, dailymotionPlugin, allocinePlugin, imagePlugin, spotifyPlugin, cloudmusicPlugin, googlemapPlugin, asciinemaPlugin, yrPlugin, gistPlugin, tweetPlugin, vinePlugin] + plugins: [youtubePlugin, dailymotionPlugin, allocinePlugin, imagePlugin, videoPlugin, spotifyPlugin, cloudmusicPlugin, googlemapPlugin, asciinemaPlugin, yrPlugin, gistPlugin, tweetPlugin, vinePlugin] }; From 0165e5e3207ce28f4bd4b8bfd16a5590292bbbe0 Mon Sep 17 00:00:00 2001 From: David Cormier Date: Sat, 3 Jan 2015 00:01:46 -0500 Subject: [PATCH 2/2] plugins: add tests for video plugin Test ogv, webm and mp4 urls --- test/unit/plugins.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/unit/plugins.js b/test/unit/plugins.js index 537f86a..e179c0a 100644 --- a/test/unit/plugins.js +++ b/test/unit/plugins.js @@ -71,6 +71,16 @@ describe('filter', function() { plugins); })); + it('should recognize html5 videos', inject(function(plugins) { + expectTheseMessagesToContain([ + 'http://www.quirksmode.org/html5/videos/big_buck_bunny.mp4', + 'http://www.quirksmode.org/html5/videos/big_buck_bunny.webm', + 'http://www.quirksmode.org/html5/videos/big_buck_bunny.ogv', + ], + 'video', + plugins); + })); + it('should recognize images', inject(function(plugins) { expectTheseMessagesToContain([ 'http://i.imgur.com/BTNIDBR.gif',