From fb862533dc07b417ff7062df5e255addcdbdf74b Mon Sep 17 00:00:00 2001 From: Martin Donnelly Date: Thu, 26 Oct 2017 11:17:26 +0100 Subject: [PATCH] forgot the template --- ecosystem.config.js | 2 +- jade/test.jade | 9 +++++ jade/today.jade | 94 +++++++++++++++++++++++++++++++++++++++++++++ lib/mailer.js | 30 +++++++-------- 4 files changed, 119 insertions(+), 16 deletions(-) create mode 100644 jade/test.jade create mode 100644 jade/today.jade diff --git a/ecosystem.config.js b/ecosystem.config.js index ba628bf..3ec4a07 100644 --- a/ecosystem.config.js +++ b/ecosystem.config.js @@ -2,7 +2,7 @@ module.exports = { apps: [{ name: 'Today', script: './todayV2.js', - interpreter: 'node@8', + interpreter: 'node@8.8.0', 'cwd': '/home/martind2000/dev/today', 'watch': false, 'ignore_watch': [ diff --git a/jade/test.jade b/jade/test.jade new file mode 100644 index 0000000..5df6230 --- /dev/null +++ b/jade/test.jade @@ -0,0 +1,9 @@ +// + Created by marti on 14/02/2016. +doctype html +html(lang="en") + head + title + Test + body + h1 Test diff --git a/jade/today.jade b/jade/today.jade new file mode 100644 index 0000000..ad91be7 --- /dev/null +++ b/jade/today.jade @@ -0,0 +1,94 @@ +html(lang="en") + head + meta(charset='utf-8') + title + Today + body + h1 Today + .stuff + | !{data.today} + .weather + h2 Weather + p Currently: + = ' ' + data.weather.currently + p Today: + = ' ' + data.weather.today + p Later: + = ' ' + data.weather.later + + if data.weather.alerts.length > 0 + h3 ALERT + each alert in data.weather.alerts + p(style="color:red;")= alert.title + p= alert.description + + .travel + h2 Travel + if data.trains.data.length > 0 + each alert in data.trains.data + strong= alert.title + p= alert.description + else + p Nothing to report. + .calendar + h2 Calendar + h3 Today + if (data.cal.today.length > 0) + each line in data.cal.today + p !{line.combined} + else + p Nothing today + h3 Tomorrow + if (data.cal.tomorrow.length > 0) + each line in data.cal.tomorrow + p !{line.combined} + else + p Nothing tomorrow + h3 This week + if (data.cal.week.length > 0) + each line in data.cal.week + p !{line.longcombined} + else + p Nothing later this week + + .fitbit + if data.fitbit.summary + h2 Fitbit + p Yesterday you walked #{data.fitbit.summary.steps} steps and covered #{data.fitbit.summary.distances[0].distance} km. + p You were sedentary for #{data.fitbit.summary.sedentaryMinutes} minutes, lightly active for #{data.fitbit.summary.lightlyActiveMinutes} minutes, fairly active for #{data.fitbit.summary.fairlyActiveMinutes} and very active for #{data.fitbit.summary.veryActiveMinutes} + .ftse + if data.ftse + h2 FTSE + each line in data.ftse + table + tr + td= line.name + td= line.price + td= line.change_amount + td= line.change_percent + .swedish + h2 Word of the day + p(style="font-weight:900;")= data.swedish.xml.words.word + p It is an #{data.swedish.xml.words.wordtype} which means '#{data.swedish.xml.words.translation}'. + p Example: #{data.swedish.xml.words.fnphrase} + p Translated: #{data.swedish.xml.words.enphrase} + + .quotes + h2 Quote + p #{data.quotes.quote} #{data.quotes.author} + + .history + h2 Today in history + if data.history.length > 0 + each line in data.history + p= line + else + p Nothing of note happened today. + + .tv + if data.tv.entries.length > 0 + h2 Todays TV + each line in data.tv.entries + p !{line.combined} + + diff --git a/lib/mailer.js b/lib/mailer.js index 84e5d36..2153872 100644 --- a/lib/mailer.js +++ b/lib/mailer.js @@ -5,29 +5,29 @@ * Time: 16:35 * */ -var jade = require('pug'), UltraSES = require('ultrases'), dateFormat = require('dateformat'); +const jade = require('pug'), UltraSES = require('ultrases'), dateFormat = require('dateformat'); -var logger = require('log4js').getLogger('mailer'); +const logger = require('log4js').getLogger('mailer'); -var mailer = new UltraSES({ - aws: { - accessKeyId: 'AKIAJWJS75F7WNCGK64A', - secretAccessKey: '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', - region: 'eu-west-1' - }, defaults: { - from: 'Martin Donnelly ' +const mailer = new UltraSES({ + 'aws': { + 'accessKeyId': 'AKIAJWJS75F7WNCGK64A', + 'secretAccessKey': '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', + 'region': 'eu-west-1' + }, 'defaults': { + 'from': 'Martin Donnelly ' } }); module.exports = { - sendEmailV1: function(todayCache, newpath) { - var now = new Date(); - var email = { - to: 'martind2000@gmail.com', subject: 'Today - ' + dateFormat(now, 'dddd, mmmm dS, yyyy') + 'sendEmailV1': function(todayCache, newpath) { + const now = new Date(); + const email = { + 'to': 'martind2000@gmail.com', 'subject': `Today - ${ dateFormat(now, 'dddd, mmmm dS, yyyy')}` }; - var template = { - file: newpath + '/' + 'jade/today.jade', locals: todayCache + const template = { + 'file': `${newpath }/` + 'jade/today.jade', 'locals': todayCache }; mailer.sendTemplate(email, template, function(err) { if (err) throw err;