Node.js based forum software built for the modern web
firing new third type of hook, static. New hook: static:app.load, closed #1812
Julian Lam0bad6198d403
diff --git a/src/plugins.js b/src/plugins.jsindex a56fef1b8f..ed169f70f2 100644--- a/src/plugins.js+++ b/src/plugins.js@@ -357,19 +357,6 @@ var fs = require('fs'),var hookType = hook.split(':')[0];switch (hookType) {case 'filter':- if (hook === 'filter:app.load') {- // Special case for this hook, as arguments passed in are always the same- async.each(hookList, function(hookObj, next) {- if (hookObj.method) {- hookObj.method.apply(Plugins, args.concat(next));- }- }, function(err) {- callback(err);- });-- return;- }-async.reduce(hookList, args, function(value, hookObj, next) {if (hookObj.method) {if (!hookObj.hasOwnProperty('callbacked') || hookObj.callbacked === true) {@@ -417,7 +404,7 @@ var fs = require('fs'),async.each(hookList, function(hookObj, next) {/*Backwards compatibility block for v0.5.0- Remove this once NodeBB enters v0.5.0-1+ Remove this once NodeBB enters v0.6.0-1*/if (hook === 'action:app.load') {deprecationWarn.push(hookObj.id);@@ -436,10 +423,10 @@ var fs = require('fs'),}, function() {/*Backwards compatibility block for v0.5.0- Remove this once NodeBB enters v0.5.0-1+ Remove this once NodeBB enters v0.6.0-1*/if (deprecationWarn.length) {- winston.warn('[plugins] The `action:app.load` hook is deprecated in favour of `filter:app.load`, please notify the developers of the following plugins:');+ winston.warn('[plugins] The `action:app.load` hook is deprecated in favour of `static:app.load`, please notify the developers of the following plugins:');for(var x=0,numDeprec=deprecationWarn.length;x<numDeprec;x++) {process.stdout.write(' * ' + deprecationWarn[x] + '\n');}@@ -447,6 +434,15 @@ var fs = require('fs'),/* End backwards compatibility block */});break;+ case 'static':+ async.each(hookList, function(hookObj, next) {+ if (hookObj.method) {+ hookObj.method.apply(Plugins, args.concat(next));+ }+ }, function(err) {+ callback(err);+ });+ break;default:// Do nothing...break;@@ -730,7 +726,7 @@ var fs = require('fs'),var components = lang.route.split('/'),language = components[1],filename = components[2].replace('.json', '');-+translator.addTranslation(language, filename, lang.file);});diff --git a/src/routes/index.js b/src/routes/index.jsindex 1128bccc8f..4838621e76 100644--- a/src/routes/index.js+++ b/src/routes/index.js@@ -188,7 +188,7 @@ module.exports = function(app, middleware) {userRoutes(router, middleware, controllers);groupRoutes(router, middleware, controllers);- plugins.fireHook('filter:app.load', router, middleware, controllers, function() {+ plugins.fireHook('static:app.load', router, middleware, controllers, function() {app.use(relativePath, router);app.use(relativePath, express.static(path.join(__dirname, '../../', 'public'), {