add submit button to guestbook
This commit is contained in:
parent
9aa8365c2e
commit
e69e49fae2
4
index.js
4
index.js
|
@ -1,6 +1,7 @@
|
|||
|
||||
// do startup jobs
|
||||
require('./startup');
|
||||
if (process.env.APP_DEBUG == 'true') process.env.DEBUG = '*/*';
|
||||
|
||||
const express = require('express');
|
||||
const app = express();
|
||||
|
@ -8,12 +9,15 @@ const session = require('express-session');
|
|||
const cookie_parse = require('cookie-parser');
|
||||
const cookie_encrypt = require('cookie-encrypter');
|
||||
const Redis = require("ioredis");
|
||||
const bodyparser = require('body-parser');
|
||||
|
||||
let redisClient = new Redis(process.env.REDIS_PORT, process.env.REDIS_HOST);
|
||||
let RedisStore = require("connect-redis")(session)
|
||||
|
||||
const { APP_PORT, APP_KEY } = process.env;
|
||||
|
||||
app.use(bodyparser.json());
|
||||
app.use(bodyparser.urlencoded({ extended: true }));
|
||||
app.use(cookie_parse(APP_KEY))
|
||||
app.use(cookie_encrypt(APP_KEY));
|
||||
app.use(session({
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"body-parser": "^1.20.1",
|
||||
"connect-redis": "^6.1.3",
|
||||
"cookie-encrypter": "^1.0.1",
|
||||
"cookie-parser": "^1.4.6",
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
.send_button_1 {
|
||||
user-select: none;
|
||||
|
||||
box-shadow:inset 0px 1px 1px 0px #91b8b3;
|
||||
background:linear-gradient(to bottom, #768d87 5%, #6c7c7c 100%);
|
||||
background-color:#768d87;
|
||||
border-radius:5px;
|
||||
border:1px solid #566963;
|
||||
display:inline-block;
|
||||
cursor:pointer;
|
||||
color:#1e3038;
|
||||
font-family:Arial;
|
||||
font-size:15px;
|
||||
font-weight:bold;
|
||||
font-style:italic;
|
||||
padding:4px 12px;
|
||||
text-decoration:none;
|
||||
text-shadow:0px -1px 1px #2b665e;
|
||||
}
|
||||
.send_button_1:hover {
|
||||
background:linear-gradient(to bottom, #6c7c7c 5%, #768d87 100%);
|
||||
background-color:#6c7c7c;
|
||||
}
|
||||
.send_button_1:active {
|
||||
position:relative;
|
||||
top:1px;
|
||||
}
|
||||
.send_button_1::before {
|
||||
content: 'send!'
|
||||
}
|
|
@ -8,6 +8,12 @@ async function handler(req, res) {
|
|||
return;
|
||||
}
|
||||
|
||||
async function submit(req, res) {
|
||||
res.send(req.body);
|
||||
return;
|
||||
}
|
||||
|
||||
module.exports = (router) => {
|
||||
router.get('/guestbook', handler);
|
||||
router.post('/guestbook/submit', submit);
|
||||
}
|
|
@ -1,6 +1,8 @@
|
|||
extends layout/main.pug
|
||||
block root
|
||||
- var title = 'Guestbook'
|
||||
block head
|
||||
<link rel='stylesheet' href='/static/ui/send_button.css'>
|
||||
block content
|
||||
h1 Guestbook
|
||||
p.
|
||||
|
@ -25,8 +27,9 @@ block content
|
|||
td
|
||||
input(type='checkbox' name='hidemail')
|
||||
p(style='margin:6px 0') Your message (512 chars max):
|
||||
textarea(name='message' style='width:100%;height:150px')
|
||||
|
||||
textarea(name='message' style='width:100%;height:150px;max-width:600px;max-height:300px')
|
||||
p
|
||||
input(type='submit' class='send_button_1')
|
||||
td(style='padding:0 16px;margin:0')
|
||||
h5 Guidelines
|
||||
ul
|
||||
|
@ -34,7 +37,7 @@ block content
|
|||
li
|
||||
| Do not post spam ads, keep it for humans.
|
||||
ul
|
||||
li There is no captcha for a reason. I'd like it to stay like this for as long as possible, so I humbly ask not to ruin it.
|
||||
li There is no captcha for a reason. I'd like to keep it this way for as long as possible, so I humbly ask not to ruin it.
|
||||
span(style='font-size:10pt;color:darkred;font-weight:bold').
|
||||
Warning: Your ip (#{ip}) will be logged and displayed for everyone.<br/>
|
||||
You can delete your own message if it was sent from the same ip for 24 hours after it was sent.
|
Loading…
Reference in New Issue