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