From c7d00e834ea32d836e7049d6f9518c81a7da2454 Mon Sep 17 00:00:00 2001 From: swag Date: Tue, 25 Apr 2023 22:28:11 -0400 Subject: [PATCH] Create 'about' and 'rules' pages --- lib/PostText.pm | 5 ++++ lib/PostText/Controller/Page.pm | 9 +++++++ t/admin.t | 2 +- t/moderator.t | 2 +- t/page.t | 11 +++++++++ t/remark.t | 2 +- t/root.t | 2 +- t/thread.t | 2 +- templates/layouts/default.html.ep | 8 ++++--- templates/page/about.html.ep | 39 +++++++++++++++++++++++++++++++ templates/page/rules.html.ep | 22 +++++++++++++++++ 11 files changed, 96 insertions(+), 8 deletions(-) create mode 100644 lib/PostText/Controller/Page.pm create mode 100644 t/page.t create mode 100644 templates/page/about.html.ep create mode 100644 templates/page/rules.html.ep diff --git a/lib/PostText.pm b/lib/PostText.pm index 1b496f1..73a393b 100644 --- a/lib/PostText.pm +++ b/lib/PostText.pm @@ -96,6 +96,11 @@ sub startup($self) { # Root redirect $r->get('/', sub ($c) { $c->redirect_to('threads_list') }); + # Static pages + $r->get('/about')->to('page#about')->name('about_page'); + + $r->get('/rules')->to('page#rules')->name('rules_page'); + # Thread my $thread = $r->any('/thread'); diff --git a/lib/PostText/Controller/Page.pm b/lib/PostText/Controller/Page.pm new file mode 100644 index 0000000..0958ecc --- /dev/null +++ b/lib/PostText/Controller/Page.pm @@ -0,0 +1,9 @@ +package PostText::Controller::Page; + +use Mojo::Base 'Mojolicious::Controller', -signatures; + +sub about($self) { $self->render } + +sub rules($self) { $self->render } + +'false'; diff --git a/t/admin.t b/t/admin.t index f635a22..43a663c 100644 --- a/t/admin.t +++ b/t/admin.t @@ -127,4 +127,4 @@ subtest Login => sub { }; }; -done_testing(); +done_testing; diff --git a/t/moderator.t b/t/moderator.t index dfdbcb2..acf52a7 100644 --- a/t/moderator.t +++ b/t/moderator.t @@ -136,4 +136,4 @@ subtest Login => sub { }; }; -done_testing(); +done_testing; diff --git a/t/page.t b/t/page.t new file mode 100644 index 0000000..910fc49 --- /dev/null +++ b/t/page.t @@ -0,0 +1,11 @@ +use Mojo::Base -strict; +use Test::More; +use Test::Mojo; + +my $t = Test::Mojo->new('PostText'); + +$t->get_ok('/about')->status_is(200)->text_like(h2 => qr/About Post::Text/); + +$t->get_ok('/rules')->status_is(200)->text_like(h2 => qr/The Rules/); + +done_testing; diff --git a/t/remark.t b/t/remark.t index cf1df17..8aafb3e 100644 --- a/t/remark.t +++ b/t/remark.t @@ -53,4 +53,4 @@ subtest 'Flagging remark', sub { ->text_like(p => qr/Remark #1 has been flagged/); }; -done_testing(); +done_testing; diff --git a/t/root.t b/t/root.t index c41e894..481f2b3 100644 --- a/t/root.t +++ b/t/root.t @@ -6,4 +6,4 @@ my $t = Test::Mojo->new('PostText'); $t->get_ok('/')->status_is(302)->header_like(Location => qr/thread/); -done_testing(); +done_testing; diff --git a/t/thread.t b/t/thread.t index cf06cef..ab538d9 100644 --- a/t/thread.t +++ b/t/thread.t @@ -100,4 +100,4 @@ subtest 'Flagging thread', sub { ->text_like(p => qr/Thread #1 has been flagged/); }; -done_testing(); +done_testing; diff --git a/templates/layouts/default.html.ep b/templates/layouts/default.html.ep index 4e7483d..5ae8e6e 100644 --- a/templates/layouts/default.html.ep +++ b/templates/layouts/default.html.ep @@ -8,9 +8,11 @@

Post::Text