observe-to-email

git clone git://git.codymlewis.com/observe-to-email.git
Log | Files | Refs | README

commit c90e5079a41a4187826232abca2242f2ac915206
parent 5fbfab6f28c67515789fe385ca587bcddbc9d50d
Author: Cody Lewis <luxdotsugi@gmail.com>
Date:   Thu,  8 Nov 2018 14:42:32 +1100

Generalized the system

Diffstat:
Mpackage-lock.json | 48------------------------------------------------
Mpublic/stylesheets/style.css | 9---------
Mroutes/index.js | 24++++++++++++++----------
3 files changed, 14 insertions(+), 67 deletions(-)

diff --git a/package-lock.json b/package-lock.json @@ -100,30 +100,6 @@ "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-1.11.0.tgz", "integrity": "sha1-RqoXUftqL5PuXmibsQh9SxTGwgU=" }, - "body-parser": { - "version": "1.18.3", - "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.18.3.tgz", - "integrity": "sha1-WykhmP/dVTs6DyDe0FkrlWlVyLQ=", - "requires": { - "bytes": "3.0.0", - "content-type": "~1.0.4", - "debug": "2.6.9", - "depd": "~1.1.2", - "http-errors": "~1.6.3", - "iconv-lite": "0.4.23", - "on-finished": "~2.3.0", - "qs": "6.5.2", - "raw-body": "2.3.3", - "type-is": "~1.6.16" - }, - "dependencies": { - "qs": { - "version": "6.5.2", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", - "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==" - } - } - }, "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", @@ -999,14 +975,6 @@ "statuses": ">= 1.4.0 < 2" } }, - "iconv-lite": { - "version": "0.4.23", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.23.tgz", - "integrity": "sha512-neyTUVFtahjf0mB3dZT77u+8O0QB89jFdnBkd5P1JgYPbPaia3gXXOVL2fq8VyU2gMMD7SaN7QukTB/pmXYvDA==", - "requires": { - "safer-buffer": ">= 2.1.2 < 3" - } - }, "inflight": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", @@ -1333,17 +1301,6 @@ "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.0.tgz", "integrity": "sha1-9JvmtIeJTdxA3MlKMi9hEJLgDV4=" }, - "raw-body": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.3.3.tgz", - "integrity": "sha512-9esiElv1BrZoI3rCDuOuKCBRbuApGGaDPQfjSflGxdy4oyzqghxu6klEkkVIvBje+FF0BX9coEv8KqW6X/7njw==", - "requires": { - "bytes": "3.0.0", - "http-errors": "1.6.3", - "iconv-lite": "0.4.23", - "unpipe": "1.0.0" - } - }, "readable-stream": { "version": "2.3.6", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", @@ -1413,11 +1370,6 @@ "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" }, - "safer-buffer": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", - "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" - }, "send": { "version": "0.16.2", "resolved": "https://registry.npmjs.org/send/-/send-0.16.2.tgz", diff --git a/public/stylesheets/style.css b/public/stylesheets/style.css @@ -1,12 +1,3 @@ -body { - background-image: url("https://www.newcastle.edu.au/__data/assets/image/0003/330429/image0017.jpg"); - background-position: top-right; - background-repeat: no-repeat; - background-size: cover; - background-attachment: fixed; - padding-top: 10%; -} - div { padding: 1%; } diff --git a/routes/index.js b/routes/index.js @@ -4,7 +4,7 @@ var nodemailer = require('nodemailer'); /* GET home page. */ router.get('/', function(req, res, next) { - res.render('index', { title: 'HLA9000 - Observations' }); + res.render('index', { title: 'Observations' }); }); router.get('/observe', function(req, res, next) { res.redirect('/'); @@ -12,15 +12,17 @@ router.get('/observe', function(req, res, next) { router.get('/observe/submit', function(req, res, next) { var today = new Date(); - msg = '\\subsubsection{Test from ' + today.toDateString() + '}\n' + - '\\begin{center}\n\\begin{tabular}{| c | c |}\n\\hline\n' + - '\ninterface type & ' + req.query.interface + - '\\\\\\hline\ntime taken & ' + req.query.time + 'mins' + - '\\\\\\hline\nThe tester felt & ' + req.query.expression + - '\\\\\\hline\nThe tester thought the system would be useful for & ' + req.query.testerAction + - '\\\\\\hline\nThe tester commented & ' + req.query.testerComment + - '\\\\\\hline\nOther observations & ' + req.query.otherComment + - '\\\\\n\\hline\n\\end{tabular}\n\\end{center}'; + msg = '% Make sure to include the tabularx package and the booktabs package\n' + + '\\subsubsection{Test from ' + today.toDateString() + '}\n' + + '\\begin{tabularx}{\\textwidth}{X X}\n\\toprule\n' + + '\ninterface type & ' + req.query.interface + '\\\\\n\\midrule\n' + + 'time taken & ' + req.query.time + 'mins \\\\\n\\midrule\n' + + 'The tester felt & ' + req.query.expression + '\\\\\n\\midrule\n' + + 'The tester thought the system would be useful for & ' + req.query.testerAction + '\\\\\n\\midrule\n' + + 'The tester commented & ' + req.query.testerComment + '\\\\\n\\midrule\n' + + 'Other observations & ' + req.query.otherComment + + '\\\\\n\\bottomrule\n\\end{tabularx}'; + console.log(msg); var subject = 'HLA9000 - Observations: ' + today.toDateString(); email(subject, msg, 0); res.redirect('/success'); @@ -46,6 +48,8 @@ function email(subject, msg, i) { if(i < 5) { console.log("Trying again"); email(subject, msg, i + 1); + } else { + console.log(`Failed ${i} times, it seems something is wrong with the emailing service`); } } else { console.log('Email sent: ' + info.response);