mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-09 15:35:47 +01:00
updated site upload logic so that site logo is resized for email header, implemented site logo in email header
This commit is contained in:
@@ -146,6 +146,22 @@ function uploadImage(filename, folder, uploadedFile, req, res, next) {
|
||||
file.saveFileToLocal(filename, folder, uploadedFile.path, next);
|
||||
}
|
||||
},
|
||||
function (imageData, next) {
|
||||
// Post-processing for site-logo
|
||||
if (path.basename(filename, path.extname(filename)) === 'site-logo' && folder === 'system') {
|
||||
var uploadPath = path.join(nconf.get('upload_path'), folder, 'site-logo-x50.png');
|
||||
image.resizeImage({
|
||||
path: uploadedFile.path,
|
||||
target: uploadPath,
|
||||
extension: 'png',
|
||||
height: 50,
|
||||
}, function (err) {
|
||||
next(err, imageData);
|
||||
});
|
||||
} else {
|
||||
setImmediate(next, null, imageData);
|
||||
}
|
||||
},
|
||||
], function (err, image) {
|
||||
file.delete(uploadedFile.path);
|
||||
if (err) {
|
||||
|
||||
@@ -14,6 +14,7 @@ var User = require('./user');
|
||||
var Plugins = require('./plugins');
|
||||
var meta = require('./meta');
|
||||
var translator = require('./translator');
|
||||
var pubsub = require('./pubsub');
|
||||
|
||||
var transports = {
|
||||
sendmail: nodemailer.createTransport(sendmailTransport()),
|
||||
@@ -33,7 +34,11 @@ Emailer.registerApp = function (expressApp) {
|
||||
Emailer._defaultPayload = {
|
||||
url: nconf.get('url'),
|
||||
site_title: meta.config.title || 'NodeBB',
|
||||
'brand:logo': nconf.get('url') + meta.config['brand:logo'],
|
||||
logo: {
|
||||
src: nconf.get('url') + meta.config['brand:logo'].replace('.png', '-x50.png'),
|
||||
height: meta.config['brand:emailLogo:height'],
|
||||
width: meta.config['brand:emailLogo:width'],
|
||||
},
|
||||
};
|
||||
|
||||
// Enable Gmail transport if enabled in ACP
|
||||
@@ -52,6 +57,14 @@ Emailer.registerApp = function (expressApp) {
|
||||
fallbackTransport = transports.sendmail;
|
||||
}
|
||||
|
||||
// Update default payload if new logo is uploaded
|
||||
pubsub.on('config:update', function (config) {
|
||||
if (config) {
|
||||
Emailer._defaultPayload.logo.height = config['brand:emailLogo:height'];
|
||||
Emailer._defaultPayload.logo.width = config['brand:emailLogo:width'];
|
||||
}
|
||||
});
|
||||
|
||||
return Emailer;
|
||||
};
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
var async = require('async');
|
||||
var nconf = require('nconf');
|
||||
var path = require('path');
|
||||
|
||||
var db = require('../database');
|
||||
var pubsub = require('../pubsub');
|
||||
@@ -80,13 +81,28 @@ Configs.setMultiple = function (data, callback) {
|
||||
};
|
||||
|
||||
function processConfig(data, callback) {
|
||||
if (data.customCSS) {
|
||||
return saveRenderedCss(data, callback);
|
||||
async.parallel([
|
||||
async.apply(saveRenderedCss, data),
|
||||
function (next) {
|
||||
var image = require('../image');
|
||||
if (data['brand:logo']) {
|
||||
image.size(path.join(nconf.get('upload_path'), 'system', 'site-logo-x50.png'), function (err, size) {
|
||||
data['brand:emailLogo:height'] = size.height;
|
||||
data['brand:emailLogo:width'] = size.width;
|
||||
next(err);
|
||||
});
|
||||
}
|
||||
setImmediate(callback);
|
||||
},
|
||||
], function (err) {
|
||||
callback(err);
|
||||
});
|
||||
}
|
||||
|
||||
function saveRenderedCss(data, callback) {
|
||||
if (!data.customCSS) {
|
||||
return setImmediate(callback);
|
||||
}
|
||||
|
||||
var less = require('less');
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
|
||||
@@ -172,7 +172,7 @@
|
||||
<table role="presentation" cellspacing="0" cellpadding="0" border="0" align="center" width="100%" style="max-width: 600px;">
|
||||
<tr>
|
||||
<td style="padding: 20px 0; text-align: center">
|
||||
<img src="{url}/assets/images/emails/nodebb.png" height="49" width="192" alt="{site_title}" border="0" style="height: 49px; width: 192px; background: #222222; font-family: sans-serif; font-size: 15px; line-height: 20px; color: #555555;">
|
||||
<img src="{logo.src}" height="{logo.height}" width="{logo.width}" alt="{site_title}" border="0" style="height: 49px; width: 192px; background: #222222; font-family: sans-serif; font-size: 15px; line-height: 20px; color: #555555;">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
Reference in New Issue
Block a user