From df53c442012c0365418bb36cea5abdff3199882e Mon Sep 17 00:00:00 2001 From: Gregory Ballantine Date: Sun, 7 Jul 2024 18:37:59 -0400 Subject: [PATCH] Added a 404 error page; added some more linking between the pages --- src/routes/error.rb | 12 ++++++++++++ src/routes/init.rb | 1 + views/error/404.erb | 5 +++++ views/index/home.erb | 2 ++ 4 files changed, 20 insertions(+) create mode 100644 src/routes/error.rb create mode 100644 views/error/404.erb diff --git a/src/routes/error.rb b/src/routes/error.rb new file mode 100644 index 0000000..f48d514 --- /dev/null +++ b/src/routes/error.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +# error handling routes +class Destructo < Sinatra::Base + + error 404 do + erb :'error/404', locals: { + title: 'Page not found' + } + end + +end diff --git a/src/routes/init.rb b/src/routes/init.rb index ec70f92..bb513cf 100644 --- a/src/routes/init.rb +++ b/src/routes/init.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true +require_relative 'error' require_relative 'index' require_relative 'message' diff --git a/views/error/404.erb b/views/error/404.erb new file mode 100644 index 0000000..83d3490 --- /dev/null +++ b/views/error/404.erb @@ -0,0 +1,5 @@ +

This page does not exist.

+ +

If you're looking for a message, it's possible that it has already been viewed and subsequently deleted.

+ +

If you would like to send a new message, head back home to get started.

\ No newline at end of file diff --git a/views/index/home.erb b/views/index/home.erb index ed6c601..7e6fe63 100644 --- a/views/index/home.erb +++ b/views/index/home.erb @@ -1,5 +1,7 @@

This is the home page.

+ +

Click here to send a new message.