Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
haywhy43 committed May 2, 2019
2 parents bb45d14 + d493387 commit 19c17db
Show file tree
Hide file tree
Showing 28 changed files with 1,015 additions and 215 deletions.
4 changes: 3 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
SENDGRID_API_KEY=SG.ehhehghdhghhhghsjkdkdfdd
ZOHO_PASS=Devalert1234$
ZOHO_USER=mail@devalert.me
PAYSTACK_SECRET_KEY=sk_live_jsfjjfsjgjgjjgj
STRIPE_SECRET_KEY=sk_test_noK4m98A2oTBitvmd7uxvWDM00wlz2mEOI
Empty file modified bin/www
100755 → 100644
Empty file.
3 changes: 3 additions & 0 deletions controllers/controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const validateQueryText = require("../validation/controller");
const fetch = require("node-fetch");
const { sendMailForRemoteJob } = require("./user");
const userModel = require("../models/user");
const agentModel = require("../models/agent");

const Jobs = {
async fetchData(req, res) {
Expand Down Expand Up @@ -54,10 +55,12 @@ const Jobs = {
try {
let foundJobs = await db.find(queryText);
let usersCount = await userModel.countDocuments({});
let agentsCount = await agentModel.countDocuments({});
return res.status(200).render("admin_dashboard", {
content: foundJobs,
jobCount: foundJobs.length,
usersCount,
agentsCount,
helpers: {
inc: function(index) {
index++;
Expand Down
124 changes: 67 additions & 57 deletions controllers/home.js
Original file line number Diff line number Diff line change
@@ -1,71 +1,81 @@
class Home {
// Render homepage
static index(req, res, next) {
res.render('index', { title: 'Remote Job Alert' });
}
// Render homepage
static index(req, res, next) {
res.render('index', { title: 'Remote Job Alert' });
}

// Render about us page
static aboutUs(req, res, next) {
res.render("about");
}
// Render about us page
static aboutUs(req, res, next) {
res.render('about');
}


// Dashboard
// Render dashboard page
static dashboard(req, res, next) {
res.render('');
}

//User Pages
// Render user-login page
static userLogin(req, res, next) {
res.render("user-login");
}
// Render manage agents page
static manageagents(req, res, next) {
res.render('manage_agents');
}

// Render user-signup page
static userSignup(req, res, next) {
res.render("user-signup");
}
// Render manage subscribers page
static managesubscribers(req, res, next) {
res.render('manage_subscribers');
}

// Render dashboard page
static dashboard(req, res, next) {
res.render("");
}
//User Pages
// Render user-login page
static userLogin(req, res, next) {
res.render('user-login');
}

// Render manage agents page
static manageagents(req, res, next) {
res.render("manage_agents");
}
// Render user-signup page
static userSignup(req, res, next) {
res.render('user-signup');
}

// Render manage subscribers page
static managesubscribers(req, res, next) {
res.render("manage_subscribers");
}
//Render contact details page
static contactUs(req, res, next) {
res.render("contact");
}
//Render contact details page
static contactUs(req, res, next) {
res.render('contact');
}

//Render FAQs page
static faqs(req, res, next) {
res.render("faqs");
}
//Render Admin page
static admin(req, res, next) {
res.render("admin");
}
//Render FAQs page
static faqs(req, res, next) {
res.render('faqs');
}
//Render Admin page
static admin(req, res, next) {
res.render('admin');
}

// Render job details page
// TODO?
static job_details(req, res, next){
res.render('job_details', { title : 'Job Details' });
}
// Render job details page
// TODO?
static job_details(req, res, next) {
res.render('job_details', { title: 'Job Details' });
}

static managejobs(req, res, next){
res.render('manage_jobs', { title : 'Manage Jobs' });
}
static managejobs(req, res, next) {
res.render('manage_jobs', { title: 'Manage Jobs' });
}

static get_summary(req, res, next){
res.render('get-summary', { title : 'Payment Summary', reference: req.query.reference });
}
static get_applicant(req, res, next){
res.render('applicant', {title: 'Applicant Details'});
}
static get_summary(req, res, next) {
res.render('get-summary', {
title: 'Payment Summary',
reference: req.query.reference
});
}
static get_applicant(req, res, next) {
res.render('applicant', { title: 'Applicant Details' });
}
static unsubscribe(req, res, next) {
const email = req.query.email || 'nomail';
res.render('unsubscribe', { title: 'unsubscribe', email });
}
static unsubscribe_success(req, res, next) {
res.render('unsubscribe_success', { title: 'unsubscribe success' });
}
}

module.exports = Home;
module.exports = Home;
46 changes: 31 additions & 15 deletions controllers/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,26 @@ const Job = require('../models/jobs');
const path = require('path');
const hbs = require('handlebars');
const fs = require('fs');
const sgMail = require('@sendgrid/mail');

sgMail.setApiKey(process.env.SENDGRID_API_KEY);
const transporter = nodemailer.createTransport({
host: 'smtp.zoho.com',
port: 587,
auth: {
user: process.env.ZOHO_USER,
pass: process.env.ZOHO_PASS
}
});

async function unsubscribeUser(req, res, next) {
try {
await User.deleteOne({ email: req.params.email });
req.flash(
'success',
'You successfully unsubscribed from DevAlert NewsLetter'
);
const email = req.params.email;

const user = await User.findOne({ email });

if (user) {
await User.deleteOne({ email });
return res.redirect('/unsubscribe_success');
}
res.redirect('/');
} catch (err) {
console.error(err);
Expand All @@ -26,7 +36,6 @@ async function sendMail(req, res, next) {
const { email } = req.body;
const user = await User.findOne({ email });
if (user) {
console.log(user);
req.flash('emailError', 'Email already subscribed');
return res.redirect('/');
}
Expand All @@ -41,13 +50,13 @@ async function sendMail(req, res, next) {
.toString()
.replace(/{{email}}/, email);
const data = {
from: 'Devalert <noreply@devalert.com>',
from: 'Devalert Team <info@devalert.me>',
to: email,
subject: 'Devalert Subscription',
subject: 'Devalert Remote Job Alert',
html
};
sgMail.send(data);

await transporter.sendMail(data);
req.flash('success', 'Email subscription was successful');
res.redirect('/');
} catch (err) {
Expand All @@ -73,12 +82,12 @@ async function sendMailForRemoteJob() {
.on('data', async function(user) {
const html = template({ jobs, email: user.email });
const data = {
from: 'Devalert <noreply@devalert.com>',
from: 'Devalert Team <info@devalert.com>',
to: user.email,
subject: 'New Remote job Alert! ',
html: html.replace(/{{email}}/, user.email)
};
sgMail.send(data);
await transporter.sendMail(data);
})
.on('end', function() {
console.log('Done!');
Expand All @@ -99,12 +108,19 @@ async function sendContactAlert(req, res, next) {
.toString()
.replace(/{{name}}/, name);
const data = {
from: 'Devalert <supports@devalert.com>',
from: 'Devalert <supports@devalert.me>',
to: email,
subject: 'Contact Us - DevAlert',
html
};
sgMail.send(data);
const support = {
from: 'info@devalert.me',
to: 'supports@devalert.me',
subject: subject + ' - ' + email,
html: `<p style="font-size:17px; font-weight:bold;">{${message}</p>`
};
await transporter.sendMail(data);
await transporter.sendMail(support);

req.flash(
'success',
Expand Down
51 changes: 35 additions & 16 deletions email-templates/welcome.hbs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<!doctype html>
<html xmlns="https://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">
<html xmlns="https://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:o="urn:schemas-microsoft-com:office:office">

<head>
<title>DevAlert</title>
Expand All @@ -25,7 +26,7 @@
line-height: 100%;
}
body {
body {
margin: 0;
padding: 0;
-webkit-text-size-adjust: 100%;
Expand Down Expand Up @@ -59,6 +60,7 @@
@-ms-viewport {
width: 320px;
}
@viewport {
width: 320px;
}
Expand Down Expand Up @@ -90,6 +92,7 @@
width: 100% !important;
max-width: 100%;
}
.mj-column-per-45 {
width: 45% !important;
max-width: 45%;
Expand All @@ -101,6 +104,7 @@
table.full-width-mobile {
width: 100% !important;
}
td.full-width-mobile {
width: auto !important;
}
Expand All @@ -117,16 +121,21 @@
<tr>
<td style="direction:ltr;font-size:0px;padding:0px;text-align:center;vertical-align:top;">
<!--[if mso | IE]><table role="presentation" border="0" cellpadding="0" cellspacing="0"><tr><td class="" style="vertical-align:top;width:600px;" ><![endif]-->
<div class="mj-column-per-100 outlook-group-fix" style="font-size:13px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;">
<table border="0" cellpadding="0" cellspacing="0" role="presentation" style="vertical-align:top;" width="100%">
<div class="mj-column-per-100 outlook-group-fix"
style="font-size:13px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;">
<table border="0" cellpadding="0" cellspacing="0" role="presentation" style="vertical-align:top;"
width="100%">
<tr>
<td align="center" style="font-size:0px;padding:10px 25px;word-break:break-word;">
<table border="0" cellpadding="0" cellspacing="0" role="presentation" style="border-collapse:collapse;border-spacing:0px;">
<table border="0" cellpadding="0" cellspacing="0" role="presentation"
style="border-collapse:collapse;border-spacing:0px;">
<tbody>
<tr>
<td style="width:550px;">
<a href="https://devalert.me" target="_blank">
<img height="auto" src="https://res.cloudinary.com/dqfn8m6ti/image/upload/v1555005327/city-01.png" style="border:0;display:block;outline:none;text-decoration:none;height:auto;width:100%;"
<img height="auto"
src="https://res.cloudinary.com/dqfn8m6ti/image/upload/v1555005327/city-01.png"
style="border:0;display:block;outline:none;text-decoration:none;height:auto;width:100%;"
width="550">
</a>
</td>
Expand All @@ -150,11 +159,15 @@
<tr>
<td style="direction:ltr;font-size:0px;padding:0px;text-align:center;vertical-align:top;">
<!--[if mso | IE]><table role="presentation" border="0" cellpadding="0" cellspacing="0"><tr><td class="" style="vertical-align:top;width:270px;" ><![endif]-->
<div class="mj-column-per-45 outlook-group-fix" style="font-size:13px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;">
<table border="0" cellpadding="0" cellspacing="0" role="presentation" style="vertical-align:top;" width="100%">
<div class="mj-column-per-45 outlook-group-fix"
style="font-size:13px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;">
<table border="0" cellpadding="0" cellspacing="0" role="presentation" style="vertical-align:top;"
width="100%">
<tr>
<td align="center" style="font-size:0px;padding:0px;word-break:break-word;">
<div style="font-family:Roboto, Helvetica, sans-serif;font-size:18px;font-weight:500;line-height:24px;text-align:center;color:#616161;">DevAlert</div>
<div
style="font-family:Roboto, Helvetica, sans-serif;font-size:18px;font-weight:500;line-height:24px;text-align:center;color:#616161;">
DevAlert</div>
</td>
</tr>
<tr>
Expand All @@ -179,18 +192,24 @@
<tr>
<td style="direction:ltr;font-size:0px;padding:0px;padding-top:10px;text-align:center;vertical-align:top;">
<!--[if mso | IE]><table role="presentation" border="0" cellpadding="0" cellspacing="0"><tr><td class="" style="vertical-align:top;width:600px;" ><![endif]-->
<div class="mj-column-per-100 outlook-group-fix" style="font-size:13px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;">
<table border="0" cellpadding="0" cellspacing="0" role="presentation" style="vertical-align:top;" width="100%">
<div class="mj-column-per-100 outlook-group-fix"
style="font-size:13px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;">
<table border="0" cellpadding="0" cellspacing="0" role="presentation" style="vertical-align:top;"
width="100%">
<tr>
<td align="left" style="font-size:0px;padding:10px 25px;word-break:break-word;">
<div style="font-family:Roboto, Helvetica, sans-serif;font-size:16px;font-weight:300;line-height:24px;text-align:left;color:#616161;">
<div
style="font-family:Roboto, Helvetica, sans-serif;font-size:16px;font-weight:300;line-height:24px;text-align:left;color:#616161;">
<p>Hello!</p>
<p>You subscribed to the Devalert newsletter. You would be getting mails for remote jobs around Africa.</p>
<p>You can also hire our agent to apply on your behalf for a fee. We would always keep you notified.</p>
<p>You subscribed to the Devalert newsletter. You would be getting mails for remote jobs around
Africa.</p>
<p>You can also hire our agent to apply on your behalf for a fee. We would always keep you
notified.</p>
<p>Cheers,</p>
<h5>DevAlert Team</h5>

<a href="https://devalert.me/unsubscribe/{{email}}" style="margin-top:20px; color:#1114cc; font-size:12px;">
<a href="https://devalert.me/unsubscribe?email={{email}}"
style="margin-top:20px; color:#1114cc; font-size:12px;">
unsubscribe from newsletter</a>

</div>
Expand All @@ -210,4 +229,4 @@
</div>
</body>

</html>
</html>
Loading

0 comments on commit 19c17db

Please sign in to comment.