Implement CAPTCHA
This commit is contained in:
parent
5124f61383
commit
b3da6874e1
|
@ -34,6 +34,14 @@ helper message => sub {
|
||||||
};
|
};
|
||||||
|
|
||||||
# Routes
|
# Routes
|
||||||
|
under sub ($c) {
|
||||||
|
# Opt out of Google FLoC
|
||||||
|
# https://paramdeo.com/blog/opting-your-website-out-of-googles-floc-network
|
||||||
|
$c->res->headers->header('Permissions-Policy', 'interest-cohort=()');
|
||||||
|
|
||||||
|
1;
|
||||||
|
};
|
||||||
|
|
||||||
get '/' => sub ($c) {
|
get '/' => sub ($c) {
|
||||||
my $posts = $c->message->get_posts();
|
my $posts = $c->message->get_posts();
|
||||||
my $last_page = $c->message->get_last_page(@$posts);
|
my $last_page = $c->message->get_last_page(@$posts);
|
||||||
|
@ -53,8 +61,9 @@ any '/sign' => sub ($c) {
|
||||||
if ($c->req->method() eq 'POST') {
|
if ($c->req->method() eq 'POST') {
|
||||||
my $name = $c->param('name');
|
my $name = $c->param('name');
|
||||||
my $message = $c->param('message');
|
my $message = $c->param('message');
|
||||||
|
my $answer = $c->param('answer');
|
||||||
|
|
||||||
$c->message->send_post($name, $message);
|
$c->message->send_post($name, $message) if $answer;
|
||||||
$c->redirect_to('index');
|
$c->redirect_to('index');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -36,7 +36,13 @@ sub max_posts($self, $value = undef) {
|
||||||
}
|
}
|
||||||
|
|
||||||
sub get_last_page($self, @posts) {
|
sub get_last_page($self, @posts) {
|
||||||
|
# Add a page if we have "remainder" posts
|
||||||
|
if (scalar(@posts) % $self->{'max_posts'}) {
|
||||||
sprintf('%d', scalar(@posts) / $self->{'max_posts'}) + 1
|
sprintf('%d', scalar(@posts) / $self->{'max_posts'}) + 1
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
sprintf('%d', scalar(@posts) / $self->{'max_posts'})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
|
@ -11,6 +11,27 @@
|
||||||
<th>Message:</th>
|
<th>Message:</th>
|
||||||
<td><%= text_area 'message', cols => 40, rows => 6 %></td>
|
<td><%= text_area 'message', cols => 40, rows => 6 %></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>Swagg CAPTCHA:</th>
|
||||||
|
<td>
|
||||||
|
<%= radio_button answer => 0 %>
|
||||||
|
<%= label_for answer => "I don\'t want to post" %>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th> </th>
|
||||||
|
<td>
|
||||||
|
<%= radio_button answer => "false" %>
|
||||||
|
<%= label_for answer => "I\'m ready to post" %>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th> </th>
|
||||||
|
<td>
|
||||||
|
<%= radio_button answer => undef %>
|
||||||
|
<%= label_for answer => 'This is spam, do not post' %>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th> </th>
|
<th> </th>
|
||||||
<td><%= submit_button 'Send it' %></td>
|
<td><%= submit_button 'Send it' %></td>
|
||||||
|
|
Loading…
Reference in a new issue