ability to edit and save custom email templates

This commit is contained in:
psychobunny
2015-09-21 17:44:06 -04:00
parent 46d6be57a8
commit 109fe895b3
5 changed files with 84 additions and 19 deletions

View File

@@ -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;
})
});