diff --git a/README.md b/README.md index 692f937..a942ae6 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,5 @@ Add the `-v` option for more verbose output ## TODOs 1. Input validation -1. Add homepage/URL field and filter URLs out of message body -1. Flash error for CAPTCHA failures and what nots -1. Replace HTML tables with CSS grids(!!) +1. Filter URLs out of message body 1. Add column to tag posts as spam or hidden diff --git a/assets/css/swagg.css b/assets/css/swagg.css index 5e13600..c2d7398 100644 --- a/assets/css/swagg.css +++ b/assets/css/swagg.css @@ -101,7 +101,6 @@ article { article .message.field { font-family: cursive; - /* font-size: 1.35em; */ margin-bottom: 0em; } @@ -124,18 +123,28 @@ nav { flex-flow: row wrap; justify-content: center; gap: 1em; + margin-bottom: 1em; } h1#top { text-align: center; } +.error { + border-style: solid; + border-color: red; + color: red; + padding: 1em; + text-align: center; + margin-bottom: 1em; +} + @media screen and (max-width: 1023px) { .inner { - max-width: 90%; + max-width: 95%; } .outer { - max-width: 95%; + max-width: 99%; } } diff --git a/guestbook-ng.pl b/guestbook-ng.pl index 1920b5d..7dea7f9 100755 --- a/guestbook-ng.pl +++ b/guestbook-ng.pl @@ -43,6 +43,8 @@ under sub ($c) { # https://paramdeo.com/blog/opting-your-website-out-of-googles-floc-network $c->res->headers->header('Permissions-Policy', 'interest-cohort=()'); + $c->session(); + 1; }; @@ -61,14 +63,20 @@ get '/' => sub ($c) { } => 'index'; any [qw{GET POST}], '/sign' => sub ($c) { - if ($c->req->method() eq 'POST' && $c->param('message')) { + if ($c->req->method() eq 'POST') { my $name = $c->param('name') || 'Anonymous'; my $url = $c->param('url'); my $message = $c->param('message'); my $answer = $c->param('answer'); - $c->message->create_post($name, $message, $url) if $answer; - $c->redirect_to('index'); + if ($message && $answer) { + $c->message->create_post($name, $message, $url); + $c->redirect_to('index'); + } + else { + $c->flash(error => 'Uh-oh!! Please try again.'); + $c->redirect_to('sign'); + } } else { # Try to randomize things for the CAPTCHA challenge. The diff --git a/templates/layouts/default.html.ep b/templates/layouts/default.html.ep index 48f4980..9e5dbd1 100644 --- a/templates/layouts/default.html.ep +++ b/templates/layouts/default.html.ep @@ -8,11 +8,17 @@

Guestbook-NG

- + <% if (flash 'error') { =%> +
+

Stop! You've violated the law:

+

<%= flash 'error' %>

+

This incident has been reported to the cyber-police.

+
+ <% } =%>