add guestbook

This commit is contained in:
b1ek 2023-02-19 15:30:02 +10:00
parent 60d4a477bd
commit 9aa8365c2e
Signed by: blek
GPG Key ID: 14546221E3595D0C
6 changed files with 75 additions and 4 deletions

3
helpers/notfound.js Normal file
View File

@ -0,0 +1,3 @@
async function handler(req, res, next) {
}

View File

@ -8,14 +8,12 @@ const session = require('express-session');
const cookie_parse = require('cookie-parser');
const cookie_encrypt = require('cookie-encrypter');
const Redis = require("ioredis");
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(require('./routes'));
app.use(express.static('public'));
app.use(cookie_parse(APP_KEY))
app.use(cookie_encrypt(APP_KEY));
app.use(session({
@ -27,6 +25,14 @@ app.use(session({
}));
app.use(require('./middleware'));
app.use(require('./routes'));
app.use(express.static('public'));
// 404
app.use((req, res, next) => {
})
const server = app.listen(APP_PORT, () => {
console.log("Listening on port " + APP_PORT);
});

13
routes/guestbook.js Normal file
View File

@ -0,0 +1,13 @@
const Helpers = require('../helpers');
async function handler(req, res) {
res.send(await Helpers.ViewLoader.load('guestbook.pug', {
current_route: req.originalUrl,
ip: req.ip
}));
return;
}
module.exports = (router) => {
router.get('/guestbook', handler);
}

40
view/guestbook.pug Normal file
View File

@ -0,0 +1,40 @@
extends layout/main.pug
block root
- var title = 'Guestbook'
block content
h1 Guestbook
p.
Leave a message if you want.
hr
table
tr
td
h4 Message form
form(method='post' action='/guestbook/submit')
table
tr
td Your name:
td
input(type='text' name='name' value='John Doe')
tr
td Your email:
td
input(type='email' name='email' value='john.doe@example.com')
tr
td Hide your email?
td
input(type='checkbox' name='hidemail')
p(style='margin:6px 0') Your message (512 chars max):
textarea(name='message' style='width:100%;height:150px')
td(style='padding:0 16px;margin:0')
h5 Guidelines
ul
li Follow the DBAA policy.
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.
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.

View File

@ -25,4 +25,5 @@ block content
ul
li
a(href='/project/blek_anal') blek! Analytics
li blek! Launcher
li
a(href='/project/blek_launch') blek! Launcher

View File

@ -0,0 +1,8 @@
extends ../layout/project.pug
block root
- var title = 'blek! Launcher'
block append content
h2 blek! Launcher
p.