2017-03-24 10:35:19 +09:00
|
|
|
import VulcanEmail from 'meteor/vulcan:email';
|
2016-06-23 17:24:58 +09:00
|
|
|
import Newsletter from "../namespace.js";
|
2017-03-23 16:27:59 +09:00
|
|
|
import { getSetting } from 'meteor/vulcan:core';
|
2016-06-23 16:42:06 +09:00
|
|
|
|
2016-06-23 17:24:58 +09:00
|
|
|
// Extend email objects with server-only properties
|
2016-04-13 11:39:01 +09:00
|
|
|
|
2017-03-24 10:35:19 +09:00
|
|
|
VulcanEmail.emails.newsletter = {
|
2016-04-13 11:39:01 +09:00
|
|
|
|
2017-03-24 10:35:19 +09:00
|
|
|
...VulcanEmail.emails.newsletter,
|
2016-04-13 11:39:01 +09:00
|
|
|
|
2016-06-23 17:24:58 +09:00
|
|
|
getNewsletter() {
|
2016-12-12 15:00:56 +09:00
|
|
|
return Newsletter.build(Newsletter.getPosts(getSetting('postsPerNewsletter', 5)));
|
2016-04-13 12:55:21 +09:00
|
|
|
},
|
|
|
|
|
|
|
|
subject() {
|
2016-06-23 17:24:58 +09:00
|
|
|
return this.getNewsletter().subject;
|
2016-04-13 12:55:21 +09:00
|
|
|
},
|
|
|
|
|
2016-04-13 11:39:01 +09:00
|
|
|
getTestHTML() {
|
2016-06-23 17:24:58 +09:00
|
|
|
var campaign = this.getNewsletter();
|
2016-12-12 15:00:56 +09:00
|
|
|
var newsletterEnabled = '<div class="newsletter-enabled"><strong>Newsletter Enabled:</strong> '+getSetting('enableNewsletter', true)+'</div>';
|
|
|
|
var mailChimpAPIKey = '<div class="mailChimpAPIKey"><strong>mailChimpAPIKey:</strong> '+(typeof getSetting('mailChimpAPIKey') !== "undefined")+'</div>';
|
|
|
|
var mailChimpListId = '<div class="mailChimpListId"><strong>mailChimpListId:</strong> '+(typeof getSetting('mailChimpListId') !== "undefined")+'</div>';
|
2016-04-13 11:39:01 +09:00
|
|
|
var campaignSubject = '<div class="campaign-subject"><strong>Subject:</strong> '+campaign.subject+' (note: contents might change)</div>';
|
|
|
|
var campaignSchedule = '<div class="campaign-schedule"><strong>Scheduled for:</strong> '+ Meteor.call('getNextJob') +'</div>';
|
|
|
|
return newsletterEnabled+mailChimpAPIKey+mailChimpListId+campaignSubject+campaignSchedule+campaign.html;
|
|
|
|
}
|
|
|
|
|
2016-06-23 17:24:58 +09:00
|
|
|
};
|
2016-04-13 11:39:01 +09:00
|
|
|
|
2017-03-24 10:35:19 +09:00
|
|
|
VulcanEmail.emails.newsletterConfirmation = {
|
2016-06-23 17:24:58 +09:00
|
|
|
|
2017-03-24 10:35:19 +09:00
|
|
|
...VulcanEmail.emails.newsletterConfirmation,
|
2016-04-13 11:39:01 +09:00
|
|
|
|
|
|
|
getTestHTML() {
|
2017-03-24 10:35:19 +09:00
|
|
|
return VulcanEmail.getTemplate('newsletterConfirmation')({
|
2016-04-13 11:39:01 +09:00
|
|
|
time: 'January 1st, 1901',
|
|
|
|
newsletterLink: 'http://example.com',
|
|
|
|
subject: 'Lorem ipsum dolor sit amet'
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2016-06-23 17:24:58 +09:00
|
|
|
};
|