mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-16 02:36:16 +01:00
ability to edit and save custom email templates
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
'use strict';
|
||||
|
||||
var settingsController = {};
|
||||
var async = require('async');
|
||||
var async = require('async'),
|
||||
meta = require('../../meta');
|
||||
|
||||
settingsController.get = function(req, res, next) {
|
||||
var term = req.params.term ? req.params.term : 'general';
|
||||
@@ -25,16 +26,25 @@ function renderEmail(req, res, next) {
|
||||
var emailsPath = path.join(__dirname, '../../../public/templates/emails');
|
||||
utils.walk(emailsPath, function(err, emails) {
|
||||
async.map(emails, function(email, next) {
|
||||
fs.readFile(email, function(err, str) {
|
||||
var path = email.replace(emailsPath, '').substr(1).replace('.tpl', '');
|
||||
|
||||
function callback(err, str) {
|
||||
next(err, {
|
||||
path: email.replace(emailsPath, '').substr(1).replace('.tpl', ''),
|
||||
path: path,
|
||||
fullpath: email,
|
||||
text: str.toString()
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if (meta.config['email:custom:' + path]) {
|
||||
return callback(null, meta.config['email:custom:' + path]);
|
||||
}
|
||||
|
||||
fs.readFile(email, callback);
|
||||
}, function(err, emails) {
|
||||
res.render('admin/settings/email', {
|
||||
emails: emails.filter(function(email) {
|
||||
emails: emails,
|
||||
sendable: emails.filter(function(email) {
|
||||
return email.path.indexOf('_plaintext') === -1 && email.path.indexOf('partials') === -1;
|
||||
})
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user