From 869f9e0d86a25d7f125f59eddbf0177fd41caf55 Mon Sep 17 00:00:00 2001 From: MrWaffle Date: Sat, 25 Jan 2014 23:13:51 +0100 Subject: [PATCH] Add custom templates to /api/get_templates_listing --- src/routes/api.js | 4 +++- src/webserver.js | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/routes/api.js b/src/routes/api.js index 78c7e6f8ac..c75cd5ddb8 100644 --- a/src/routes/api.js +++ b/src/routes/api.js @@ -23,7 +23,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 ee5b1a0dc6..8ba6b47c03 100644 --- a/src/webserver.js +++ b/src/webserver.js @@ -877,6 +877,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;