mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-12-23 00:40:23 +01:00
removed handlebars dependency for emailer, using ANDREWBARS now
This commit is contained in:
@@ -45,7 +45,6 @@
|
|||||||
"cron": "~1.0.1",
|
"cron": "~1.0.1",
|
||||||
"semver": "~2.2.1",
|
"semver": "~2.2.1",
|
||||||
"string": "~1.7.0",
|
"string": "~1.7.0",
|
||||||
"handlebars": "~1.2.1",
|
|
||||||
"xregexp": "~2.0.0"
|
"xregexp": "~2.0.0"
|
||||||
},
|
},
|
||||||
"optionalDependencies": {
|
"optionalDependencies": {
|
||||||
|
|||||||
@@ -99,7 +99,7 @@
|
|||||||
|
|
||||||
str = str.replace(/^\s+|\s+$/g, ''); // trim
|
str = str.replace(/^\s+|\s+$/g, ''); // trim
|
||||||
str = str.toLowerCase();
|
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(/\s+/g, '-') // collapse whitespace and replace by -
|
||||||
str = str.replace(/-+/g, '-'); // collapse dashes
|
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>
|
</p>
|
||||||
|
|
||||||
<blockquote>
|
<blockquote>
|
||||||
{{reset_link}}
|
{reset_link}
|
||||||
</blockquote>
|
</blockquote>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
Thanks!<br />
|
Thanks!<br />
|
||||||
<strong>{{site_title}}</strong>
|
<strong>{site_title}</strong>
|
||||||
</p>
|
</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:
|
To continue with the password reset, please click on the following link:
|
||||||
|
|
||||||
{RESET_LINK}
|
{reset_link}
|
||||||
|
|
||||||
Thanks!
|
Thanks!
|
||||||
NodeBB
|
{site_title}
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
<p>
|
<p>
|
||||||
Hello {{username}},
|
Hello {username},
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<strong>Thank you for registering with {{site_title}}!</strong>
|
<strong>Thank you for registering with {site_title}!</strong>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
@@ -11,10 +11,10 @@
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<blockquote>
|
<blockquote>
|
||||||
{{confirm_link}}
|
{confirm_link}
|
||||||
</blockquote>
|
</blockquote>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
Thanks!<br />
|
Thanks!<br />
|
||||||
<strong>{{site_title}}</strong>
|
<strong>{site_title}</strong>
|
||||||
</p>
|
</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:
|
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!
|
Thanks!
|
||||||
{{site_title}}
|
{site_title}
|
||||||
@@ -2,57 +2,27 @@ var User = require('./user'),
|
|||||||
Plugins = require('./plugins'),
|
Plugins = require('./plugins'),
|
||||||
Meta = require('./meta'),
|
Meta = require('./meta'),
|
||||||
|
|
||||||
Handlebars = require('handlebars'),
|
|
||||||
fs = require('fs'),
|
fs = require('fs'),
|
||||||
async = require('async'),
|
async = require('async'),
|
||||||
path = require('path'),
|
path = require('path'),
|
||||||
|
|
||||||
Emailer = {},
|
Emailer = {};
|
||||||
templates = {};
|
|
||||||
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
// Template loaded already
|
|
||||||
callback();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var render = function(template, params, callback) {
|
var render = function(template, params, callback) {
|
||||||
prepareTemplate(template, function() {
|
|
||||||
if (templates[template] !== null) {
|
if (templates[template] !== null) {
|
||||||
callback(null, templates[template](params));
|
callback(null, templates[template].parse(params));
|
||||||
} else {
|
} else {
|
||||||
callback(null, null);
|
callback(null, null);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Emailer.send = function(template, uid, params) {
|
Emailer.send = function(template, uid, params) {
|
||||||
async.parallel({
|
async.parallel({
|
||||||
html: function(next) {
|
html: function(next) {
|
||||||
render(template, params, next);
|
render('emails/' + template, params, next);
|
||||||
},
|
},
|
||||||
plaintext: function(next) {
|
plaintext: function(next) {
|
||||||
render(template + '_plaintext', params, next);
|
render('emails/' + template + '_plaintext', params, next);
|
||||||
}
|
}
|
||||||
}, function(err, results) {
|
}, function(err, results) {
|
||||||
User.getUserField(uid, 'email', function(err, email) {
|
User.getUserField(uid, 'email', function(err, email) {
|
||||||
|
|||||||
Reference in New Issue
Block a user