Merge pull request #773 from pelmers/ppp

Add a pastebin plugin
This commit is contained in:
Lorenz Hübschle-Schneider 2016-04-22 09:18:20 +02:00
commit a4d0b4261b
2 changed files with 23 additions and 1 deletions

View file

@ -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('<iframe></iframe>')
.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]
};

View file

@ -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/',