Implement post count

This commit is contained in:
swagg boi 2022-01-11 19:51:45 -05:00
parent 575431237b
commit 53f292ac7c
4 changed files with 7 additions and 4 deletions

View file

@ -55,4 +55,4 @@ Add the `-v` option for more verbose output
## TODOs
1. /spam route would be interesting
1. Include the total number of visitors or messages
1. Visitor counter

View file

@ -7,3 +7,4 @@ requires 'Mojolicious::Plugin::TagHelpers::Pagination';
requires 'Mojolicious::Plugin::AssetPack';
requires 'Regexp::Common::URI';
requires 'CSS::Minifier::XS';
requires 'Number::Format';

View file

@ -7,6 +7,7 @@ use Mojolicious::Lite -signatures;
use Mojo::Pg;
use List::Util qw{shuffle};
use Regexp::Common qw{URI};
use Number::Format qw{format_number};
#use Data::Dumper; # Uncomment for debugging
# Load the model
@ -45,11 +46,13 @@ get '/' => sub ($c) {
my $this_page = $c->param('page') || 1;
my $last_page = $c->message->get_last_page();
my $view_posts = $c->message->get_posts($this_page);
my $post_count = format_number $c->message->get_post_count();
$c->stash(
view_posts => $view_posts,
this_page => $this_page,
last_page => $last_page
last_page => $last_page,
post_count => $post_count
);
$c->render();

View file

@ -28,8 +28,7 @@
</div>
<div class="outer">
<footer>
<p>Maximize your dynamic innovation using battle-tested deep
learning models.</p>
<p><%= $post_count %> visitors have signed the guestbook to date.</p>
</footer>
</div>
</body>