From fa992e2fa5a070e7775a37e07be457806020a2de Mon Sep 17 00:00:00 2001 From: Peter Elmers Date: Thu, 21 Apr 2016 18:37:51 -0500 Subject: [PATCH 1/3] Add a pastebin plugin --- js/plugins.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/js/plugins.js b/js/plugins.js index 7ba506d..25a6436 100644 --- a/js/plugins.js +++ b/js/plugins.js @@ -455,6 +455,20 @@ plugins.factory('userPlugins', function() { } }); + var pastebinPlugin = new UrlPlugin('Pastebin', function(url) { + var regexp = /^http:\/\/pastebin.com\/([^.?]+)/i; + var match = url.match(regexp); + if (match) { + var id = match[1], + embedurl = "http://pastebin.com/embed_iframe/" + id, + element = angular.element('') + .attr('src', embedurl) + .attr('width', '100%') + .attr('height', '480') + return element.prop('outerHTML'); + } + }); + /* match giphy links and display the assocaited gif images * sample input: http://giphy.com/gifs/eyes-shocked-bird-feqkVgjJpYtjy * sample output: https://media.giphy.com/media/feqkVgjJpYtjy/giphy.gif @@ -522,7 +536,7 @@ plugins.factory('userPlugins', function() { }); return { - plugins: [youtubePlugin, dailymotionPlugin, allocinePlugin, imagePlugin, videoPlugin, audioPlugin, spotifyPlugin, cloudmusicPlugin, googlemapPlugin, asciinemaPlugin, yrPlugin, gistPlugin, giphyPlugin, tweetPlugin, vinePlugin] + plugins: [youtubePlugin, dailymotionPlugin, allocinePlugin, imagePlugin, videoPlugin, audioPlugin, spotifyPlugin, cloudmusicPlugin, googlemapPlugin, asciinemaPlugin, yrPlugin, gistPlugin, pastebinPlugin, giphyPlugin, tweetPlugin, vinePlugin] }; From 0b98f4c8f61df14add2c03d0db875b2d36c693e3 Mon Sep 17 00:00:00 2001 From: Peter Elmers Date: Thu, 21 Apr 2016 18:42:38 -0500 Subject: [PATCH 2/3] Write a test --- test/unit/plugins.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/unit/plugins.js b/test/unit/plugins.js index 34be685..8842f05 100644 --- a/test/unit/plugins.js +++ b/test/unit/plugins.js @@ -139,6 +139,14 @@ describe('filter', function() { plugins); })); + it('should recognize pastebins', inject(function(plugins) { + expectTheseMessagesToContain([ + 'http://pastebin.com/Wn3TetSE', + ], + 'Pastebin', + plugins); + })); + it('should recognize giphy gifs', inject(function(plugins) { expectTheseMessagesToContain([ 'https://giphy.com/gifs/eyes-shocked-bird-feqkVgjJpYtjy/', From 05f5629ba75a943e5d08c02597b8ff3188cd3556 Mon Sep 17 00:00:00 2001 From: Peter Elmers Date: Thu, 21 Apr 2016 19:13:27 -0500 Subject: [PATCH 3/3] Please linter --- js/plugins.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/plugins.js b/js/plugins.js index 25a6436..36f3430 100644 --- a/js/plugins.js +++ b/js/plugins.js @@ -464,7 +464,7 @@ plugins.factory('userPlugins', function() { element = angular.element('') .attr('src', embedurl) .attr('width', '100%') - .attr('height', '480') + .attr('height', '480'); return element.prop('outerHTML'); } });