From bce8bbeb1c2791734e5b8c6e50c4c54ca7cb5f0e Mon Sep 17 00:00:00 2001 From: barnold Date: Thu, 15 Sep 2022 08:52:05 +0100 Subject: [PATCH] Add an About page. --- lib/MyApp.pm | 1 + lib/MyApp/Controller/Home.pm | 5 +++-- templates/home/about.html.ep | 5 +++++ templates/home/index.html.ep | 1 + 4 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 templates/home/about.html.ep diff --git a/lib/MyApp.pm b/lib/MyApp.pm index 1fc18d7..d56368b 100644 --- a/lib/MyApp.pm +++ b/lib/MyApp.pm @@ -7,6 +7,7 @@ sub startup ($self) { # route's default name seems to come from '/path' with the leading # '/' removed. $r->get('/')->to('home#index')->name('home'); + $r->get('/about')->to('home#about'); $r->get('/auth')->to('auth#index'); $r->post('/login')->to('auth#login'); $r->get('/logout')->to('auth#logout'); diff --git a/lib/MyApp/Controller/Home.pm b/lib/MyApp/Controller/Home.pm index 3cf8384..478f6b1 100644 --- a/lib/MyApp/Controller/Home.pm +++ b/lib/MyApp/Controller/Home.pm @@ -1,7 +1,8 @@ package MyApp::Controller::Home; use Mojo::Base 'Mojolicious::Controller', -signatures; -sub index ($self) { -} +# No need for a method for either 'index' or 'about'. +# sub index ($self) { +# } 1; diff --git a/templates/home/about.html.ep b/templates/home/about.html.ep new file mode 100644 index 0000000..94030ef --- /dev/null +++ b/templates/home/about.html.ep @@ -0,0 +1,5 @@ +% layout 'default'; +% title 'About'; +

About

+ +All about MyApp. diff --git a/templates/home/index.html.ep b/templates/home/index.html.ep index 2c1e669..666d5aa 100644 --- a/templates/home/index.html.ep +++ b/templates/home/index.html.ep @@ -4,6 +4,7 @@

Other pages:

+

<%= link_to("About" => 'about') %>

<%= link_to("Books" => 'book') %>

<%= link_to("Foo" => 'foo') %>

<%= link_to("temp1" => 'temp1') %>