diff --git a/routes/guestbook.js b/routes/guestbook.js
index a321f15..63526e3 100644
--- a/routes/guestbook.js
+++ b/routes/guestbook.js
@@ -1,15 +1,37 @@
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;
+async function handler(req, res, next) {
+ try {
+ res.send(await Helpers.ViewLoader.load('guestbook.pug', {
+ current_route: req.originalUrl,
+ ip: req.ip,
+ data: {
+ // TODO: load from db
+ 1: {
+ name: 'John Doe',
+ email: 'a@b.c',
+ text: 'hiiii',
+ hidemail: false,
+ ip: '0.0.0.0',
+ hidden: false,
+ time: Date.now()
+ }
+ }
+ }));
+ return;
+ } catch (err) {
+ next(err);
+ }
}
async function submit(req, res) {
- res.send(req.body);
+ const { name, email, message } = req.body;
+ const hidemail = req.body.hidemail ? (req.body.hidemail == 'on' ? true : false) : false;
+
+ res.send({
+ name, email, message, hidemail
+ });
+
return;
}
diff --git a/view/guestbook.pug b/view/guestbook.pug
index 38058df..86fcf76 100644
--- a/view/guestbook.pug
+++ b/view/guestbook.pug
@@ -40,4 +40,23 @@ block content
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.
- You can delete your own message if it was sent from the same ip for 24 hours after it was sent.
\ No newline at end of file
+ You can delete your own message if it was sent from the same ip for 24 hours after it was sent.
+ hr
+
+ if (!data)
+ p No records available.
+ else
+ table
+ each entry, id in data
+ tr
+ td(width='20%' class='gb_sender_data')
+ p(style='font-size:9pt').
+ ID: ##{id}
+ Sender: #{entry.name}
+ Email: #{entry.email}
+ IP: #{entry.ip}
+ Date: #{new Date(entry.time).toISOString()}
+ td(width='80%' style='padding:0 8px')
+ p(style='font-size:9pt;font-weight:bold;margin:0;padding:0;padding-top:1em') Message:
+ p(style='margin:0;padding:0;font-size:10pt').
+ hiii
\ No newline at end of file