mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 12:05:57 +01:00
Merge pull request #874 from BitBangersCode/templates-fix
Add custom templates to /api/get_templates_listing
This commit is contained in:
@@ -24,7 +24,9 @@ var path = require('path'),
|
|||||||
app.namespace('/api', function () {
|
app.namespace('/api', function () {
|
||||||
app.get('/get_templates_listing', function (req, res) {
|
app.get('/get_templates_listing', function (req, res) {
|
||||||
utils.walk(path.join(__dirname, '../../', 'public/templates'), function (err, data) {
|
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;
|
||||||
|
}));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -911,6 +911,12 @@ module.exports.server = server;
|
|||||||
'templates': []
|
'templates': []
|
||||||
};
|
};
|
||||||
|
|
||||||
|
app.get_custom_templates = function() {
|
||||||
|
return custom_routes.templates.map(function(tpl) {
|
||||||
|
return tpl.template.split('.tpl')[0];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
plugins.ready(function() {
|
plugins.ready(function() {
|
||||||
plugins.fireHook('filter:server.create_routes', custom_routes, function(err, custom_routes) {
|
plugins.fireHook('filter:server.create_routes', custom_routes, function(err, custom_routes) {
|
||||||
var routes = custom_routes.routes;
|
var routes = custom_routes.routes;
|
||||||
|
|||||||
Reference in New Issue
Block a user