Merge pull request #6 from cormier/plugin/image

js: add image plugin
This commit is contained in:
David Cormier 2013-10-02 16:24:40 -07:00
commit 9dfce743cf
1 changed files with 15 additions and 2 deletions

View File

@ -101,9 +101,9 @@ weechat.factory('colors', [function($scope) {
}]);
weechat.factory('pluginManager', ['youtubePlugin', 'urlPlugin', function(youtubePlugin, urlPlugin) {
weechat.factory('pluginManager', ['youtubePlugin', 'urlPlugin', 'imagePlugin', function(youtubePlugin, urlPlugin, imagePlugin) {
var plugins = [youtubePlugin, urlPlugin]
var plugins = [youtubePlugin, urlPlugin, imagePlugin]
var hookPlugin = function(plugin) {
plugins.push(plugin);
@ -163,7 +163,20 @@ weechat.factory('urlPlugin', [function() {
}
}]);
weechat.factory('imagePlugin', [function() {
var contentForMessage = function(message) {
var urls = message.match(/https?:\/\/[^\s]*\.(jpg|png|gif)\b/)
if (urls != null) {
var url = urls[0]; /* Actually parse one url per message */
return '<img src="' + url + '" height="300">';
}
return null;
}
return {
contentForMessage: contentForMessage
}
}]);
weechat.factory('handlers', ['$rootScope', 'colors', 'pluginManager', function($rootScope, colors, pluginManager) {