diff --git a/src/plugins.js b/src/plugins.js index 5f1bd0d4e2..700b5d7082 100644 --- a/src/plugins.js +++ b/src/plugins.js @@ -4,7 +4,8 @@ var fs = require('fs'), winston = require('winston'), nconf = require('nconf'), eventEmitter = require('events').EventEmitter, - db = require('./database'); + db = require('./database'), + meta = require('./meta'); (function(Plugins) { @@ -63,7 +64,9 @@ var fs = require('fs'), db.getSetMembers('plugins:active', next); }, function(plugins, next) { - if (plugins && Array.isArray(plugins) && plugins.length > 0) { + if (plugins && Array.isArray(plugins)) { + plugins.push(meta.config['theme:id']); + async.each(plugins, function(plugin, next) { var modulePath = path.join(__dirname, '../node_modules/', plugin); if (fs.existsSync(modulePath)) { @@ -94,7 +97,7 @@ var fs = require('fs'), Plugins.loadPlugin = function(pluginPath, callback) { fs.readFile(path.join(pluginPath, 'plugin.json'), function(err, data) { if (err) { - return callback(err); + return callback(pluginPath.match('nodebb-theme') ? null : err); } var pluginData = JSON.parse(data), diff --git a/src/routes/api.js b/src/routes/api.js index 08d4107f74..32c38363f7 100644 --- a/src/routes/api.js +++ b/src/routes/api.js @@ -24,7 +24,9 @@ var path = require('path'), app.namespace('/api', function () { app.get('/get_templates_listing', function (req, res) { utils.walk(path.join(__dirname, '../../', 'public/templates'), function (err, data) { - res.json(data); + res.json(data.concat(app.get_custom_templates()).filter(function(value, index, self) { + return self.indexOf(value) === index; + })); }); }); diff --git a/src/webserver.js b/src/webserver.js index 3b07f18343..743512e4f2 100644 --- a/src/webserver.js +++ b/src/webserver.js @@ -911,6 +911,12 @@ module.exports.server = server; 'templates': [] }; + app.get_custom_templates = function() { + return custom_routes.templates.map(function(tpl) { + return tpl.template.split('.tpl')[0]; + }); + } + plugins.ready(function() { plugins.fireHook('filter:server.create_routes', custom_routes, function(err, custom_routes) { var routes = custom_routes.routes;