mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-02-04 05:39:51 +01:00
moved get_custom_templates into plugins.js
This commit is contained in:
@@ -13,9 +13,7 @@ var path = require('path'),
|
||||
meta = require('./../meta'),
|
||||
plugins = require('./../plugins'),
|
||||
utils = require('./../../public/src/utils'),
|
||||
pkg = require('./../../package.json'),
|
||||
|
||||
customTemplates = [];
|
||||
pkg = require('./../../package.json');
|
||||
|
||||
|
||||
function searchTerm(req, res, next) {
|
||||
@@ -137,7 +135,7 @@ function getModerators(req, res, next) {
|
||||
|
||||
function getTemplatesListing(req, res, next) {
|
||||
utils.walk(nconf.get('views_dir'), function (err, data) {
|
||||
data = data.concat(customTemplates)
|
||||
data = data.concat(require('./plugins').getCustomTemplates())
|
||||
.filter(function(value, index, self) {
|
||||
return self.indexOf(value) === index;
|
||||
}).map(function(el) {
|
||||
@@ -152,8 +150,6 @@ module.exports = function(app, middleware, controllers) {
|
||||
app.namespace('/api', function () {
|
||||
app.all('*', middleware.updateLastOnlineTime, middleware.prepareAPI);
|
||||
|
||||
customTemplates = app.get_custom_templates();
|
||||
|
||||
app.get('/config', controllers.api.getConfig);
|
||||
|
||||
app.get('/user/uid/:uid', middleware.checkGlobalPrivacySettings, controllers.accounts.getUserByUID);
|
||||
|
||||
@@ -7,7 +7,9 @@ var _ = require('underscore'),
|
||||
validator = require('validator'),
|
||||
async = require('async'),
|
||||
|
||||
plugins = require('../plugins');
|
||||
plugins = require('../plugins'),
|
||||
|
||||
pluginRoutes = [];
|
||||
|
||||
function setupPluginRoutes(app) {
|
||||
var custom_routes = {
|
||||
@@ -16,12 +18,6 @@ function setupPluginRoutes(app) {
|
||||
'templates': []
|
||||
};
|
||||
|
||||
app.get_custom_templates = function() {
|
||||
return custom_routes.templates.map(function(tpl) {
|
||||
return tpl.template;
|
||||
});
|
||||
};
|
||||
|
||||
plugins.ready(function() {
|
||||
/*
|
||||
* TO BE DEPRECATED post 0.4x and replaced with something that isn't as complicated as this...
|
||||
@@ -30,6 +26,8 @@ function setupPluginRoutes(app) {
|
||||
var route,
|
||||
routes = custom_routes.routes;
|
||||
|
||||
pluginRoutes = custom_routes;
|
||||
|
||||
for (route in routes) {
|
||||
if (routes.hasOwnProperty(route)) {
|
||||
(function(route) {
|
||||
@@ -70,7 +68,6 @@ function setupPluginRoutes(app) {
|
||||
}(route));
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -186,4 +183,12 @@ module.exports = function(app, middleware, controllers) {
|
||||
|
||||
setupPluginRoutes(app);
|
||||
setupPluginAdminRoutes(app);
|
||||
|
||||
return {
|
||||
getCustomTemplates: function() {
|
||||
pluginRoutes.templates.map(function(tpl) {
|
||||
return tpl.template;
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user