firing new third type of hook, static. New hook: static:app.load, closed #1812

v1.18.x
Julian Lam 11 years ago
parent eea987d8dd
commit 0bad6198d4

@ -357,19 +357,6 @@ var fs = require('fs'),
var hookType = hook.split(':')[0]; var hookType = hook.split(':')[0];
switch (hookType) { switch (hookType) {
case 'filter': 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) { async.reduce(hookList, args, function(value, hookObj, next) {
if (hookObj.method) { if (hookObj.method) {
if (!hookObj.hasOwnProperty('callbacked') || hookObj.callbacked === true) { if (!hookObj.hasOwnProperty('callbacked') || hookObj.callbacked === true) {
@ -417,7 +404,7 @@ var fs = require('fs'),
async.each(hookList, function(hookObj, next) { async.each(hookList, function(hookObj, next) {
/* /*
Backwards compatibility block for v0.5.0 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') { if (hook === 'action:app.load') {
deprecationWarn.push(hookObj.id); deprecationWarn.push(hookObj.id);
@ -436,10 +423,10 @@ var fs = require('fs'),
}, function() { }, function() {
/* /*
Backwards compatibility block for v0.5.0 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) { 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++) { for(var x=0,numDeprec=deprecationWarn.length;x<numDeprec;x++) {
process.stdout.write(' * ' + deprecationWarn[x] + '\n'); process.stdout.write(' * ' + deprecationWarn[x] + '\n');
} }
@ -447,6 +434,15 @@ var fs = require('fs'),
/* End backwards compatibility block */ /* End backwards compatibility block */
}); });
break; 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: default:
// Do nothing... // Do nothing...
break; break;
@ -730,7 +726,7 @@ var fs = require('fs'),
var components = lang.route.split('/'), var components = lang.route.split('/'),
language = components[1], language = components[1],
filename = components[2].replace('.json', ''); filename = components[2].replace('.json', '');
translator.addTranslation(language, filename, lang.file); translator.addTranslation(language, filename, lang.file);
}); });

@ -188,7 +188,7 @@ module.exports = function(app, middleware) {
userRoutes(router, middleware, controllers); userRoutes(router, middleware, controllers);
groupRoutes(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, router);
app.use(relativePath, express.static(path.join(__dirname, '../../', 'public'), { app.use(relativePath, express.static(path.join(__dirname, '../../', 'public'), {

Loading…
Cancel
Save