mirror of
https://github.com/vale981/Vulcan
synced 2025-03-07 02:21:43 -05:00
adding route for email debugging
This commit is contained in:
parent
5acda44722
commit
42b25d3eb0
5 changed files with 166 additions and 94 deletions
|
@ -71,4 +71,5 @@ Telescope.registerComponent("AccountsForm", require('./users/AccountsForm.jsx'))
|
||||||
|
|
||||||
Telescope.registerComponent("Cheatsheet", require('./debug/Cheatsheet.jsx'));
|
Telescope.registerComponent("Cheatsheet", require('./debug/Cheatsheet.jsx'));
|
||||||
Telescope.registerComponent("Settings", require('./debug/Settings.jsx'));
|
Telescope.registerComponent("Settings", require('./debug/Settings.jsx'));
|
||||||
|
Telescope.registerComponent("Emails", require('./debug/Emails.jsx'));
|
||||||
|
|
||||||
|
|
41
packages/nova-base-components/lib/debug/Emails.jsx
Normal file
41
packages/nova-base-components/lib/debug/Emails.jsx
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
import React from 'react';
|
||||||
|
import emailRoutes from '../server/routes.js';
|
||||||
|
|
||||||
|
const renderEmail = (email, key) => {
|
||||||
|
return (
|
||||||
|
<tr key={key}>
|
||||||
|
<td>{email.name}</td>
|
||||||
|
<td><a href={email.path.replace(":_id?", "")} target="_blank"><code>{email.path}</code></a></td>
|
||||||
|
<td>coming soon…</td>
|
||||||
|
</tr>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
const Emails = props => {
|
||||||
|
return (
|
||||||
|
<div className="emails">
|
||||||
|
<h1>Emails</h1>
|
||||||
|
|
||||||
|
<div className="emails-wrapper">
|
||||||
|
|
||||||
|
<table className="table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<td>Name</td>
|
||||||
|
<td>Preview</td>
|
||||||
|
<td>Send Test</td>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{emailRoutes.map(renderEmail)}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = Emails
|
||||||
|
export default Emails
|
|
@ -122,6 +122,14 @@ Router.route('/settings', {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Router.route('/emails', {
|
||||||
|
name: 'emails',
|
||||||
|
action() {
|
||||||
|
({App, Emails} = Telescope.components);
|
||||||
|
mount(App, {content: <Emails/>});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
FlowRouter.notFound = {
|
FlowRouter.notFound = {
|
||||||
action() {
|
action() {
|
||||||
({Error404} = Telescope.components);
|
({Error404} = Telescope.components);
|
||||||
|
|
|
@ -1,98 +1,120 @@
|
||||||
// import Email from 'meteor/nova:email';
|
|
||||||
import Campaign from 'meteor/nova:newsletter';
|
import Campaign from 'meteor/nova:newsletter';
|
||||||
|
|
||||||
// New post email
|
const emailRoutes = [
|
||||||
Picker.route('/email/new-post/:id?', function(params, req, res, next) {
|
{
|
||||||
var html;
|
name: "New Post",
|
||||||
var post = typeof params.id === "undefined" ? Posts.findOne() : Posts.findOne(params.id);
|
path: "/email/new-post/:_id?",
|
||||||
if (!!post) {
|
action: (params, req, res, next) => {
|
||||||
html = Telescope.email.getTemplate('newPost')(Posts.getNotificationProperties(post));
|
var html;
|
||||||
} else {
|
var post = typeof params.id === "undefined" ? Posts.findOne() : Posts.findOne(params.id);
|
||||||
html = "<h3>No post found.</h3>"
|
if (!!post) {
|
||||||
|
html = Telescope.email.getTemplate('newPost')(Posts.getNotificationProperties(post));
|
||||||
|
} else {
|
||||||
|
html = "<h3>No post found.</h3>"
|
||||||
|
}
|
||||||
|
res.end(Telescope.email.buildTemplate(html));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Post Approved",
|
||||||
|
path: "/email/post-approved/:_id?",
|
||||||
|
action: (params, req, res, next) => {
|
||||||
|
var html;
|
||||||
|
var post = typeof params.id === "undefined" ? Posts.findOne() : Posts.findOne(params.id);
|
||||||
|
if (!!post) {
|
||||||
|
html = Telescope.email.getTemplate('postApproved')(Posts.getNotificationProperties(post));
|
||||||
|
} else {
|
||||||
|
html = "<h3>No post found.</h3>"
|
||||||
|
}
|
||||||
|
res.end(Telescope.email.buildTemplate(html));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "New Comment",
|
||||||
|
path: "/email/new-comment/:_id?",
|
||||||
|
action: (params, req, res, next) => {
|
||||||
|
var html;
|
||||||
|
var comment = typeof params.id === "undefined" ? Comments.findOne() : Comments.findOne(params.id);
|
||||||
|
var post = Posts.findOne(comment.postId);
|
||||||
|
if (!!comment) {
|
||||||
|
html = Telescope.email.getTemplate('newComment')(Comments.getNotificationProperties(comment, post));
|
||||||
|
} else {
|
||||||
|
html = "<h3>No post found.</h3>"
|
||||||
|
}
|
||||||
|
res.end(Telescope.email.buildTemplate(html));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "New Reply",
|
||||||
|
path: "/email/new-reply/:_id?",
|
||||||
|
action: (params, req, res, next) => {
|
||||||
|
var html;
|
||||||
|
var comment = typeof params.id === "undefined" ? Comments.findOne() : Comments.findOne(params.id);
|
||||||
|
var post = Posts.findOne(comment.postId);
|
||||||
|
if (!!comment) {
|
||||||
|
html = Telescope.email.getTemplate('newReply')(Comments.getNotificationProperties(comment, post));
|
||||||
|
} else {
|
||||||
|
html = "<h3>No post found.</h3>"
|
||||||
|
}
|
||||||
|
res.end(Telescope.email.buildTemplate(html));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "New User",
|
||||||
|
path: "/email/new-user/:_id?",
|
||||||
|
action: (params, req, res, next) => {
|
||||||
|
var html;
|
||||||
|
var user = typeof params.id === "undefined" ? Meteor.users.findOne() : Meteor.users.findOne(params.id);
|
||||||
|
var emailProperties = {
|
||||||
|
profileUrl: Users.getProfileUrl(user),
|
||||||
|
username: Users.getUserName(user)
|
||||||
|
};
|
||||||
|
html = Telescope.email.getTemplate('newUser')(emailProperties);
|
||||||
|
res.end(Telescope.email.buildTemplate(html));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Account Approved",
|
||||||
|
path: "/email/account-approved/:_id?",
|
||||||
|
action: (params, req, res, next) => {
|
||||||
|
var user = typeof params.id === "undefined" ? Meteor.users.findOne() : Meteor.users.findOne(params.id);
|
||||||
|
var emailProperties = {
|
||||||
|
profileUrl: Users.getProfileUrl(user),
|
||||||
|
username: Users.getUserName(user),
|
||||||
|
siteTitle: Telescope.settings.get('title'),
|
||||||
|
siteUrl: Telescope.utils.getSiteUrl()
|
||||||
|
};
|
||||||
|
var html = Telescope.email.getTemplate('accountApproved')(emailProperties);
|
||||||
|
res.end(Telescope.email.buildTemplate(html));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Newsletter",
|
||||||
|
path: "/email/newsletter",
|
||||||
|
action: (params, req, res, next) => {
|
||||||
|
var campaign = Campaign.build(Campaign.getPosts(Telescope.settings.get('postsPerNewsletter', 5)));
|
||||||
|
var newsletterEnabled = '<div class="newsletter-enabled"><strong>Newsletter Enabled:</strong> '+Telescope.settings.get('enableNewsletter', true)+'</div>';
|
||||||
|
var mailChimpAPIKey = '<div class="mailChimpAPIKey"><strong>mailChimpAPIKey:</strong> '+(typeof Telescope.settings.get('mailChimpAPIKey') !== "undefined")+'</div>';
|
||||||
|
var mailChimpListId = '<div class="mailChimpListId"><strong>mailChimpListId:</strong> '+(typeof Telescope.settings.get('mailChimpListId') !== "undefined")+'</div>';
|
||||||
|
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>';
|
||||||
|
res.end(newsletterEnabled+mailChimpAPIKey+mailChimpListId+campaignSubject+campaignSchedule+campaign.html);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Newsletter Confirmation",
|
||||||
|
path: "/email/newsletter-confirmation",
|
||||||
|
action: (params, req, res, next) => {
|
||||||
|
var confirmationHtml = Telescope.email.getTemplate('newsletterConfirmation')({
|
||||||
|
time: 'January 1st, 1901',
|
||||||
|
newsletterLink: 'http://example.com',
|
||||||
|
subject: 'Lorem ipsum dolor sit amet'
|
||||||
|
});
|
||||||
|
res.end(Telescope.email.buildTemplate(confirmationHtml));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
res.end(Telescope.email.buildTemplate(html));
|
];
|
||||||
});
|
|
||||||
|
|
||||||
// Post approved
|
emailRoutes.forEach(route => Picker.route(route.path, route.action));
|
||||||
Picker.route('/email/post-approved/:id?', function(params, req, res, next) {
|
|
||||||
var html;
|
|
||||||
var post = typeof params.id === "undefined" ? Posts.findOne() : Posts.findOne(params.id);
|
|
||||||
if (!!post) {
|
|
||||||
html = Telescope.email.getTemplate('postApproved')(Posts.getNotificationProperties(post));
|
|
||||||
} else {
|
|
||||||
html = "<h3>No post found.</h3>"
|
|
||||||
}
|
|
||||||
res.end(Telescope.email.buildTemplate(html));
|
|
||||||
});
|
|
||||||
|
|
||||||
// New comment email
|
export default emailRoutes;
|
||||||
Picker.route('/email/new-comment/:id?', function(params, req, res, next) {
|
|
||||||
var html;
|
|
||||||
var comment = typeof params.id === "undefined" ? Comments.findOne() : Comments.findOne(params.id);
|
|
||||||
var post = Posts.findOne(comment.postId);
|
|
||||||
if (!!comment) {
|
|
||||||
html = Telescope.email.getTemplate('newComment')(Comments.getNotificationProperties(comment, post));
|
|
||||||
} else {
|
|
||||||
html = "<h3>No post found.</h3>"
|
|
||||||
}
|
|
||||||
res.end(Telescope.email.buildTemplate(html));
|
|
||||||
});
|
|
||||||
|
|
||||||
// New reply email
|
|
||||||
Picker.route('/email/new-reply/:id?', function(params, req, res, next) {
|
|
||||||
var html;
|
|
||||||
var comment = typeof params.id === "undefined" ? Comments.findOne() : Comments.findOne(params.id);
|
|
||||||
var post = Posts.findOne(comment.postId);
|
|
||||||
if (!!comment) {
|
|
||||||
html = Telescope.email.getTemplate('newReply')(Comments.getNotificationProperties(comment, post));
|
|
||||||
} else {
|
|
||||||
html = "<h3>No post found.</h3>"
|
|
||||||
}
|
|
||||||
res.end(Telescope.email.buildTemplate(html));
|
|
||||||
});
|
|
||||||
|
|
||||||
// New user email
|
|
||||||
Picker.route('/email/new-user/:id?', function(params, req, res, next) {
|
|
||||||
var html;
|
|
||||||
var user = typeof params.id === "undefined" ? Meteor.users.findOne() : Meteor.users.findOne(params.id);
|
|
||||||
var emailProperties = {
|
|
||||||
profileUrl: Users.getProfileUrl(user),
|
|
||||||
username: Users.getUserName(user)
|
|
||||||
};
|
|
||||||
html = Telescope.email.getTemplate('newUser')(emailProperties);
|
|
||||||
res.end(Telescope.email.buildTemplate(html));
|
|
||||||
});
|
|
||||||
|
|
||||||
// Account approved email
|
|
||||||
Picker.route('/email/account-approved/:id?', function(params, req, res, next) {
|
|
||||||
var user = typeof params.id === "undefined" ? Meteor.users.findOne() : Meteor.users.findOne(params.id);
|
|
||||||
var emailProperties = {
|
|
||||||
profileUrl: Users.getProfileUrl(user),
|
|
||||||
username: Users.getUserName(user),
|
|
||||||
siteTitle: Telescope.settings.get('title'),
|
|
||||||
siteUrl: Telescope.utils.getSiteUrl()
|
|
||||||
};
|
|
||||||
var html = Telescope.email.getTemplate('accountApproved')(emailProperties);
|
|
||||||
res.end(Telescope.email.buildTemplate(html));
|
|
||||||
});
|
|
||||||
|
|
||||||
// Newsletter email
|
|
||||||
Picker.route('/email/newsletter', function(params, req, res, next) {
|
|
||||||
var campaign = Campaign.build(Campaign.getPosts(Telescope.settings.get('postsPerNewsletter', 5)));
|
|
||||||
var newsletterEnabled = '<div class="newsletter-enabled"><strong>Newsletter Enabled:</strong> '+Telescope.settings.get('enableNewsletter', true)+'</div>';
|
|
||||||
var mailChimpAPIKey = '<div class="mailChimpAPIKey"><strong>mailChimpAPIKey:</strong> '+(typeof Telescope.settings.get('mailChimpAPIKey') !== "undefined")+'</div>';
|
|
||||||
var mailChimpListId = '<div class="mailChimpListId"><strong>mailChimpListId:</strong> '+(typeof Telescope.settings.get('mailChimpListId') !== "undefined")+'</div>';
|
|
||||||
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>';
|
|
||||||
res.end(newsletterEnabled+mailChimpAPIKey+mailChimpListId+campaignSubject+campaignSchedule+campaign.html);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Newsletter confirmation email
|
|
||||||
Picker.route('/email/newsletter-confirmation', function(params, req, res, next) {
|
|
||||||
var confirmationHtml = Telescope.email.getTemplate('newsletterConfirmation')({
|
|
||||||
time: 'January 1st, 1901',
|
|
||||||
newsletterLink: 'http://example.com',
|
|
||||||
subject: 'Lorem ipsum dolor sit amet'
|
|
||||||
});
|
|
||||||
res.end(Telescope.email.buildTemplate(confirmationHtml));
|
|
||||||
});
|
|
|
@ -38,7 +38,7 @@ Package.onUse(function (api) {
|
||||||
|
|
||||||
// 'fourseven:scss@3.4.1',
|
// 'fourseven:scss@3.4.1',
|
||||||
// 'kadira:blaze-layout@2.3.0',
|
// 'kadira:blaze-layout@2.3.0',
|
||||||
'meteorhacks:picker@1.0.3',
|
'meteorhacks:picker@1.0.4',
|
||||||
// 'kadira:dochead@1.4.0',
|
// 'kadira:dochead@1.4.0',
|
||||||
'dburles:collection-helpers@1.0.4',
|
'dburles:collection-helpers@1.0.4',
|
||||||
'matb33:collection-hooks@0.8.1',
|
'matb33:collection-hooks@0.8.1',
|
||||||
|
|
Loading…
Add table
Reference in a new issue