removed handlebars dependency for emailer, using ANDREWBARS now

v1.18.x
Julian Lam 11 years ago
parent 5c048ac20a
commit b6fdc5595d

@ -45,7 +45,6 @@
"cron": "~1.0.1",
"semver": "~2.2.1",
"string": "~1.7.0",
"handlebars": "~1.2.1",
"xregexp": "~2.0.0"
},
"optionalDependencies": {

@ -99,7 +99,7 @@
str = str.replace(/^\s+|\s+$/g, ''); // trim
str = str.toLowerCase();
str = XRegExp.replace(str, invalidChars, '');
str = XRegExp.replace(str, invalidChars, '-');
str = str.replace(/\s+/g, '-') // collapse whitespace and replace by -
str = str.replace(/-+/g, '-'); // collapse dashes

@ -1,10 +0,0 @@
</div>
<hr />
<p style="
font-size: 10px;
padding: 6px 12px;
">
This email was sent by NodeBB. If it does not apply to you, please ignore it.
</p>
</div>

@ -1,26 +0,0 @@
<div style="
width: 640px;
border: 1px solid #666;
margin: 0 auto;
font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif;
background: #f6f6f6;
">
<h1 style="
background-color: #1b1b1b;
margin: 0;
padding: 6px 12px;
font-size: 20px;
background-image: -moz-linear-gradient(top,#222,#111);
background-image: -webkit-gradient(linear,0 0,0 100%,from(#222),to(#111));
background-image: -webkit-linear-gradient(top,#222,#111);
background-image: -o-linear-gradient(top,#222,#111);
background-image: linear-gradient(to bottom,#222,#111);
color: #777;
font-weight: normal;
">
NodeBB
</h1>
<div style="
padding: 20px;
color: #333;
">

@ -11,10 +11,10 @@
</p>
<blockquote>
{{reset_link}}
{reset_link}
</blockquote>
<p>
Thanks!<br />
<strong>{{site_title}}</strong>
<strong>{site_title}</strong>
</p>

@ -4,7 +4,7 @@ We received a request to reset your password, possibly because you have forgotte
To continue with the password reset, please click on the following link:
{RESET_LINK}
{reset_link}
Thanks!
NodeBB
{site_title}

@ -1,9 +1,9 @@
<p>
Hello {{username}},
Hello {username},
</p>
<p>
<strong>Thank you for registering with {{site_title}}!</strong>
<strong>Thank you for registering with {site_title}!</strong>
</p>
<p>
@ -11,10 +11,10 @@
</p>
<blockquote>
{{confirm_link}}
{confirm_link}
</blockquote>
<p>
Thanks!<br />
<strong>{{site_title}}</strong>
<strong>{site_title}</strong>
</p>

@ -1,11 +1,11 @@
Hello {{username}},
Hello {username},
Thank you for registering with {{site_title}}!
Thank you for registering with {site_title}!
To fully activate your account, we need to verify that you own the email address you registered with. Please click on the following link:
{{confirm_link}}
{confirm_link}
Thanks!
{{site_title}}
{site_title}

@ -2,57 +2,27 @@ var User = require('./user'),
Plugins = require('./plugins'),
Meta = require('./meta'),
Handlebars = require('handlebars'),
fs = require('fs'),
async = require('async'),
path = require('path'),
Emailer = {},
templates = {};
Emailer = {};
var prepareTemplate = function(template, callback) {
if (templates[template] === undefined) {
var templatePath = path.join(__dirname, '../public/templates/emails/' + template + '.hbs');
fs.exists(templatePath, function(exists) {
if (exists) {
fs.readFile(templatePath, function(err, fileStream) {
if (!err) {
templates[template] = Handlebars.compile(fileStream.toString());
} else {
templates[template] = null;
}
callback();
});
} else {
templates[template] = null;
callback();
}
});
var render = function(template, params, callback) {
if (templates[template] !== null) {
callback(null, templates[template].parse(params));
} else {
// Template loaded already
callback();
callback(null, null);
}
}
var render = function(template, params, callback) {
prepareTemplate(template, function() {
if (templates[template] !== null) {
callback(null, templates[template](params));
} else {
callback(null, null);
}
});
}
Emailer.send = function(template, uid, params) {
async.parallel({
html: function(next) {
render(template, params, next);
render('emails/' + template, params, next);
},
plaintext: function(next) {
render(template + '_plaintext', params, next);
render('emails/' + template + '_plaintext', params, next);
}
}, function(err, results) {
User.getUserField(uid, 'email', function(err, email) {

Loading…
Cancel
Save