Initial flash error implementation

This commit is contained in:
swag 2022-01-01 23:37:41 -05:00
parent 052fb6f6a1
commit 2845fd7499
4 changed files with 31 additions and 10 deletions

View File

@ -50,7 +50,5 @@ Add the `-v` option for more verbose output
## TODOs ## TODOs
1. Input validation 1. Input validation
1. Add homepage/URL field and filter URLs out of message body 1. Filter URLs out of message body
1. Flash error for CAPTCHA failures and what nots
1. Replace HTML tables with CSS grids(!!)
1. Add column to tag posts as spam or hidden 1. Add column to tag posts as spam or hidden

View File

@ -101,7 +101,6 @@ article {
article .message.field { article .message.field {
font-family: cursive; font-family: cursive;
/* font-size: 1.35em; */
margin-bottom: 0em; margin-bottom: 0em;
} }
@ -124,18 +123,28 @@ nav {
flex-flow: row wrap; flex-flow: row wrap;
justify-content: center; justify-content: center;
gap: 1em; gap: 1em;
margin-bottom: 1em;
} }
h1#top { h1#top {
text-align: center; 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) { @media screen and (max-width: 1023px) {
.inner { .inner {
max-width: 90%; max-width: 95%;
} }
.outer { .outer {
max-width: 95%; max-width: 99%;
} }
} }

View File

@ -43,6 +43,8 @@ under sub ($c) {
# https://paramdeo.com/blog/opting-your-website-out-of-googles-floc-network # https://paramdeo.com/blog/opting-your-website-out-of-googles-floc-network
$c->res->headers->header('Permissions-Policy', 'interest-cohort=()'); $c->res->headers->header('Permissions-Policy', 'interest-cohort=()');
$c->session();
1; 1;
}; };
@ -61,14 +63,20 @@ get '/' => sub ($c) {
} => 'index'; } => 'index';
any [qw{GET POST}], '/sign' => sub ($c) { 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 $name = $c->param('name') || 'Anonymous';
my $url = $c->param('url'); my $url = $c->param('url');
my $message = $c->param('message'); my $message = $c->param('message');
my $answer = $c->param('answer'); my $answer = $c->param('answer');
$c->message->create_post($name, $message, $url) if $answer; if ($message && $answer) {
$c->redirect_to('index'); $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 { else {
# Try to randomize things for the CAPTCHA challenge. The # Try to randomize things for the CAPTCHA challenge. The

View File

@ -8,11 +8,17 @@
<body> <body>
<div class="outer"> <div class="outer">
<h1 id="top">Guestbook-NG</h1> <h1 id="top">Guestbook-NG</h1>
<!-- Nav table -->
<nav> <nav>
<%= link_to View => 'index' %> <%= link_to View => 'index' %>
<%= link_to Sign => 'sign' %> <%= link_to Sign => 'sign' %>
</nav> </nav>
<% if (flash 'error') { =%>
<div class="error">
<h2>Stop! You've violated the law:</h2>
<p><%= flash 'error' %></p>
<p>This incident has been reported to the cyber-police.</p>
</div>
<% } =%>
<hr> <hr>
</div> </div>
<div class="inner"> <div class="inner">