diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/css/styles.css | 4 | ||||
-rw-r--r-- | src/html/email.html | 38 | ||||
-rw-r--r-- | src/html/index.html | 3 | ||||
-rw-r--r-- | src/index.js | 4 | ||||
-rw-r--r-- | src/server.js | 11 |
5 files changed, 57 insertions, 3 deletions
diff --git a/src/css/styles.css b/src/css/styles.css index e9677ed..f0f90d2 100644 --- a/src/css/styles.css +++ b/src/css/styles.css @@ -103,7 +103,7 @@ p { .card img { width: 400px; } - form input[type=text], input[type=password] { + form input[type=text], input[type=password], input[type=email] { max-width: 600px; } form textarea { @@ -176,7 +176,7 @@ form { width: 85%; } -input[type=text], input[type=password] { +input[type=text], input[type=password], input[type=email] { height:1.5em; width: 100%; display: block; diff --git a/src/html/email.html b/src/html/email.html new file mode 100644 index 0000000..dfd9b51 --- /dev/null +++ b/src/html/email.html @@ -0,0 +1,38 @@ +<!doctype html> +<html lang="en"> + +<head> + <title>Mark's Kitchen - Email</title> + <meta charset="UTF-8"> + <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> + <link rel="stylesheet" type="text/css" href="/css/styles.css"> + <!-- <script src="https://cdn.jsdelivr.net/npm/vue"></script> --> + <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script> + <script> + window.onload = function(){ + var feed = new Vue({ + el: '#status', + data: { + show: window.location.hash == '#success' + }, + }); + } + </script> +</head> + +<body> + <div> + <h1>Email</h1> + <p>Sign up to receive Mark's email newsletter</p> + <h2 id="status" v-if='show'>Success, thank you!</h2> + <div class="form"> + <form action="/email" method="post" enctype="application/x-www-form-urlencoded"> + <input type="text" placeholder="Your name" name="name" required> + <input type="email" placeholder="Your email" name="email" required> + <input type="submit" value="Submit"> + </form> + </div> + </div> +</body> + +</html>
\ No newline at end of file diff --git a/src/html/index.html b/src/html/index.html index f004784..1d57609 100644 --- a/src/html/index.html +++ b/src/html/index.html @@ -31,7 +31,8 @@ <nav class="titlebar"> <a href="bread" class="btn btn-primary">Bread</a> <a href="blog" class="btn btn-primary">Blog</a> - <a href="essay" class="btn btn-primary">Essays</a> + <!-- <a href="essay" class="btn btn-primary">Essays</a> (Hello inspector, this page exists, but just isn't very interesting, so I'm removing the link) --> + <a href="email" class="btn btn-primary">Email</a> </nav> <div id="feed"></div> diff --git a/src/index.js b/src/index.js index 3a0573e..1214038 100644 --- a/src/index.js +++ b/src/index.js @@ -73,6 +73,10 @@ function setUpModels(){ session: Sequelize.STRING, method: Sequelize.STRING, url: Sequelize.STRING, + }), + "emails": database.define('email', { + address: Sequelize.STRING, + name: Sequelize.STRING }) } models.pictures.belongsTo(models.posts); diff --git a/src/server.js b/src/server.js index eae99e4..9899736 100644 --- a/src/server.js +++ b/src/server.js @@ -84,6 +84,7 @@ function setUpRoutes(models, jwtFunctions, database) { server.get('/index', (req, res) => res.sendFile(__dirname + "/html/index.html")) server.get('/admin', (req, res) => res.sendFile(__dirname + "/html/admin.html")); server.get('/login', (req, res) => res.sendFile(__dirname + "/html/login.html")) + server.get('/email', (req, res) => res.sendFile(__dirname + "/html/email.html")) server.get('/bread', (req, res) => res.sendFile(__dirname + "/html/bread.html")); server.get('/blog', (req, res) => res.sendFile(__dirname + "/html/blog.html")); server.get('/tags', (req, res) => res.sendFile(__dirname + "/html/tags.html")); @@ -175,6 +176,16 @@ function setUpRoutes(models, jwtFunctions, database) { res.redirect('/login'); } }) + server.post('/email', async (req, res, next) => { + const name = req.body.name; + const email = req.body.email; + if (name && email) { + models.emails.create({"name": name, "address": email}) + res.redirect('/email#success'); + } else { + console.debug("Error with email submission") + } + }) server.get('/favicon.ico', (req, res) => res.sendFile(__dirname + "/icon/favicon.ico")) |