From 7975844e4d133e35a2b21d4e9a1f73914dddf40c Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Wed, 21 Aug 2013 22:40:47 -0400 Subject: [PATCH 1/2] renamed two hooks and added filter:post.get hook --- src/posts.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/posts.js b/src/posts.js index 4fe5005a5c..3f47a65c5b 100644 --- a/src/posts.js +++ b/src/posts.js @@ -97,7 +97,10 @@ var RDB = require('./redis.js'), Posts.getPostData = function(pid, callback) { RDB.hgetall('post:' + pid, function(err, data) { if(err === null) { - callback(data); + plugins.fireHook('filter:post.get', data.content, function(content) { + data.content = content; + callback(data); + }); } else console.log(err); @@ -263,7 +266,7 @@ var RDB = require('./redis.js'), RDB.incr('global:next_post_id', function(err, pid) { RDB.handle(err); - plugins.fireHook('filter:save_post_content', content, function(content) { + plugins.fireHook('filter:post.save', content, function(content) { var timestamp = Date.now(), postData = { 'pid': pid, @@ -316,7 +319,7 @@ var RDB = require('./redis.js'), callback(postData); }); - plugins.fireHook('action:save_post_content', [pid, content]); + plugins.fireHook('action:post.save', [pid, content]); postSearch.index(content, pid); }); From 2d3d0f688a5662f75a71dc7ab91d1063b97ee1b7 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Thu, 22 Aug 2013 09:50:29 -0400 Subject: [PATCH 2/2] a couple minor 'tweaks' to the plugin system so that it works with npm installed plugins --- public/src/utils.js | 5 ++++ src/plugins.js | 56 +++++++++++++++++++++++++-------------------- src/postTools.js | 2 +- 3 files changed, 37 insertions(+), 26 deletions(-) diff --git a/public/src/utils.js b/public/src/utils.js index fce4d0ecdd..b3d3f756f4 100644 --- a/public/src/utils.js +++ b/public/src/utils.js @@ -153,6 +153,11 @@ .addClass('badge-inverse') } }); + }, + + isRelativeUrl: function(url) { + var firstChar = url.slice(0, 1); + return (firstChar === '.' || firstChar === '/'); } } diff --git a/src/plugins.js b/src/plugins.js index 62de6dc741..4bad96d7e1 100644 --- a/src/plugins.js +++ b/src/plugins.js @@ -20,28 +20,14 @@ var fs = require('fs'), function(plugins, next) { async.each(plugins, function(plugin) { // TODO: Update this check to also check node_modules - var pluginPath = path.join(__dirname, '../plugins/', plugin); - fs.exists(pluginPath, function(exists) { - if (exists) { - fs.readFile(path.join(pluginPath, 'plugin.json'), function(err, data) { - if (err) return next(err); - - var pluginData = JSON.parse(data); - _self.libraries[pluginData.id] = require(path.join(pluginPath, pluginData.library)); - if (pluginData.hooks) { - for(var x=0,numHooks=pluginData.hooks.length;x'); }