moved get_custom_templates into plugins.js

v1.18.x
psychobunny 11 years ago
parent 8f7a7fec7d
commit b9e119241e

@ -13,9 +13,7 @@ var path = require('path'),
meta = require('./../meta'), meta = require('./../meta'),
plugins = require('./../plugins'), plugins = require('./../plugins'),
utils = require('./../../public/src/utils'), utils = require('./../../public/src/utils'),
pkg = require('./../../package.json'), pkg = require('./../../package.json');
customTemplates = [];
function searchTerm(req, res, next) { function searchTerm(req, res, next) {
@ -137,7 +135,7 @@ function getModerators(req, res, next) {
function getTemplatesListing(req, res, next) { function getTemplatesListing(req, res, next) {
utils.walk(nconf.get('views_dir'), function (err, data) { utils.walk(nconf.get('views_dir'), function (err, data) {
data = data.concat(customTemplates) data = data.concat(require('./plugins').getCustomTemplates())
.filter(function(value, index, self) { .filter(function(value, index, self) {
return self.indexOf(value) === index; return self.indexOf(value) === index;
}).map(function(el) { }).map(function(el) {
@ -152,8 +150,6 @@ module.exports = function(app, middleware, controllers) {
app.namespace('/api', function () { app.namespace('/api', function () {
app.all('*', middleware.updateLastOnlineTime, middleware.prepareAPI); app.all('*', middleware.updateLastOnlineTime, middleware.prepareAPI);
customTemplates = app.get_custom_templates();
app.get('/config', controllers.api.getConfig); app.get('/config', controllers.api.getConfig);
app.get('/user/uid/:uid', middleware.checkGlobalPrivacySettings, controllers.accounts.getUserByUID); app.get('/user/uid/:uid', middleware.checkGlobalPrivacySettings, controllers.accounts.getUserByUID);

@ -7,7 +7,9 @@ var _ = require('underscore'),
validator = require('validator'), validator = require('validator'),
async = require('async'), async = require('async'),
plugins = require('../plugins'); plugins = require('../plugins'),
pluginRoutes = [];
function setupPluginRoutes(app) { function setupPluginRoutes(app) {
var custom_routes = { var custom_routes = {
@ -16,12 +18,6 @@ function setupPluginRoutes(app) {
'templates': [] 'templates': []
}; };
app.get_custom_templates = function() {
return custom_routes.templates.map(function(tpl) {
return tpl.template;
});
};
plugins.ready(function() { plugins.ready(function() {
/* /*
* TO BE DEPRECATED post 0.4x and replaced with something that isn't as complicated as this... * 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, var route,
routes = custom_routes.routes; routes = custom_routes.routes;
pluginRoutes = custom_routes;
for (route in routes) { for (route in routes) {
if (routes.hasOwnProperty(route)) { if (routes.hasOwnProperty(route)) {
(function(route) { (function(route) {
@ -70,7 +68,6 @@ function setupPluginRoutes(app) {
}(route)); }(route));
} }
} }
}); });
}); });
} }
@ -186,4 +183,12 @@ module.exports = function(app, middleware, controllers) {
setupPluginRoutes(app); setupPluginRoutes(app);
setupPluginAdminRoutes(app); setupPluginAdminRoutes(app);
return {
getCustomTemplates: function() {
pluginRoutes.templates.map(function(tpl) {
return tpl.template;
});
}
};
}; };
Loading…
Cancel
Save