v1.4.1
This commit is contained in:
parent
ab988837fe
commit
84869dafa7
7 changed files with 81 additions and 34 deletions
|
@ -1,5 +1,9 @@
|
||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 1.4.1 2016-05-04
|
||||||
|
|
||||||
|
* Added support for RSS templates
|
||||||
|
|
||||||
## 1.4.0 2016-05-04
|
## 1.4.0 2016-05-04
|
||||||
|
|
||||||
* Added support for RSS campaigns
|
* Added support for RSS campaigns
|
||||||
|
|
|
@ -10,6 +10,7 @@ let shortid = require('shortid');
|
||||||
let isUrl = require('is-url');
|
let isUrl = require('is-url');
|
||||||
let feed = require('../feed');
|
let feed = require('../feed');
|
||||||
let log = require('npmlog');
|
let log = require('npmlog');
|
||||||
|
let mailer = require('../mailer');
|
||||||
|
|
||||||
let allowedKeys = ['description', 'from', 'address', 'subject', 'template', 'source_url', 'list', 'segment', 'html', 'text'];
|
let allowedKeys = ['description', 'from', 'address', 'subject', 'template', 'source_url', 'list', 'segment', 'html', 'text'];
|
||||||
|
|
||||||
|
@ -323,6 +324,13 @@ module.exports.create = (campaign, opts, callback) => {
|
||||||
return callback(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mailer.getTemplate('emails/rss-html.hbs', (err, rendererHtml) => {
|
||||||
|
if (err) {
|
||||||
|
return callback(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
campaign.html = rendererHtml();
|
||||||
|
|
||||||
create((err, campaignId) => {
|
create((err, campaignId) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
return callback(err);
|
return callback(err);
|
||||||
|
@ -357,6 +365,7 @@ module.exports.create = (campaign, opts, callback) => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
} else if (campaign.template) {
|
} else if (campaign.template) {
|
||||||
templates.get(campaign.template, (err, template) => {
|
templates.get(campaign.template, (err, template) => {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "mailtrain",
|
"name": "mailtrain",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "1.4.0",
|
"version": "1.4.1",
|
||||||
"description": "Self hosted email newsletter app",
|
"description": "Self hosted email newsletter app",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|
|
@ -15,7 +15,7 @@ function feedLoop() {
|
||||||
return setTimeout(feedLoop, 15 * 1000);
|
return setTimeout(feedLoop, 15 * 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
let query = 'SELECT `id`, `source_url`, `from`, `address`, `subject`, `list`, `segment` FROM `campaigns` WHERE `type`=2 AND `status`=6 AND (`last_check` IS NULL OR `last_check`< NOW() - INTERVAL 10 MINUTE) LIMIT 1';
|
let query = 'SELECT `id`, `source_url`, `from`, `address`, `subject`, `list`, `segment`, `html` FROM `campaigns` WHERE `type`=2 AND `status`=6 AND (`last_check` IS NULL OR `last_check`< NOW() - INTERVAL 10 MINUTE) LIMIT 1';
|
||||||
|
|
||||||
connection.query(query, (err, rows) => {
|
connection.query(query, (err, rows) => {
|
||||||
connection.release();
|
connection.release();
|
||||||
|
@ -125,6 +125,13 @@ function checkEntries(parent, entries, callback) {
|
||||||
}
|
}
|
||||||
|
|
||||||
let entryId = result.insertId;
|
let entryId = result.insertId;
|
||||||
|
let html = (parent.html || '').toString().trim();
|
||||||
|
|
||||||
|
if (/\[RSS_ENTRY\]/i.test(html)) {
|
||||||
|
html = html.replace(/\[RSS_ENTRY\]/, entry.content);
|
||||||
|
} else {
|
||||||
|
html = entry.content + html;
|
||||||
|
}
|
||||||
|
|
||||||
let campaign = {
|
let campaign = {
|
||||||
type: 'entry',
|
type: 'entry',
|
||||||
|
@ -134,7 +141,7 @@ function checkEntries(parent, entries, callback) {
|
||||||
subject: entry.title || parent.subject,
|
subject: entry.title || parent.subject,
|
||||||
list: parent.list,
|
list: parent.list,
|
||||||
segment: parent.segment,
|
segment: parent.segment,
|
||||||
html: entry.content
|
html
|
||||||
};
|
};
|
||||||
|
|
||||||
campaigns.create(campaign, {
|
campaigns.create(campaign, {
|
||||||
|
|
|
@ -73,18 +73,13 @@
|
||||||
<input type="text" class="form-control" name="from" id="from" value="{{from}}" placeholder="This is the name your emails will come from" required>
|
<input type="text" class="form-control" name="from" id="from" value="{{from}}" placeholder="This is the name your emails will come from" required>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="address" class="col-sm-2 control-label">Email "from" address</label>
|
<label for="address" class="col-sm-2 control-label">Email "from" address</label>
|
||||||
<div class="col-sm-10">
|
<div class="col-sm-10">
|
||||||
<input type="email" class="form-control" name="address" id="address" value="{{address}}" placeholder="This is the address people will send replies to" required>
|
<input type="email" class="form-control" name="address" id="address" value="{{address}}" placeholder="This is the address people will send replies to" required>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
|
||||||
<label for="subject" class="col-sm-2 control-label">Email "subject line"</label>
|
|
||||||
<div class="col-sm-10">
|
|
||||||
<input type="text" class="form-control" name="subject" id="subject" value="{{subject}}" placeholder="Keep it relevant and non-spammy" required>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<hr />
|
<hr />
|
||||||
|
|
||||||
|
|
|
@ -76,6 +76,20 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="template-html" class="col-sm-2 control-label">Template content (HTML)</label>
|
||||||
|
<div class="col-sm-10">
|
||||||
|
{{#if disableWysiwyg}}
|
||||||
|
<div class="code-editor" id="template-html">{{html}}</div>
|
||||||
|
<input type="hidden" name="html">
|
||||||
|
{{else}}
|
||||||
|
<textarea class="form-control summernote" id="template-html" name="html" rows="8">{{html}}</textarea>
|
||||||
|
{{/if}}
|
||||||
|
<span class="help-block">Use special merge tag <code>[RSS_ENTRY]</code> to mark the position for the RSS post content. Additionally you can use any valid merge tag as well.</span>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<hr />
|
<hr />
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
@ -90,12 +104,6 @@
|
||||||
<input type="email" class="form-control" name="address" id="address" value="{{address}}" placeholder="This is the address people will send replies to" required>
|
<input type="email" class="form-control" name="address" id="address" value="{{address}}" placeholder="This is the address people will send replies to" required>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
|
||||||
<label for="subject" class="col-sm-2 control-label">Email "subject line"</label>
|
|
||||||
<div class="col-sm-10">
|
|
||||||
<input type="text" class="form-control" name="subject" id="subject" value="{{subject}}" placeholder="Keep it relevant and non-spammy" required>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
<hr />
|
<hr />
|
||||||
|
|
24
views/emails/rss-html.hbs
Normal file
24
views/emails/rss-html.hbs
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html>
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
[RSS_ENTRY]
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<a href="[LINK_PREFERENCES]" style="color: #666666; text-decoration: none;">Preferences</a>
|
||||||
|
<span style="color: #444444;"> | </span>
|
||||||
|
<a href="[LINK_UNSUBSCRIBE]" style="color: #666666; text-decoration: none;">Unsubscribe</a>
|
||||||
|
<span style="color: #444444;"> | </span>
|
||||||
|
<a href="[LINK_BROWSER]" style="color: #666666; text-decoration: none;">View this email in your browser</a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
Loading…
Add table
Add a link
Reference in a new issue