From 82a2c353e925cb91b6bac78a1d94e50047dd93bc Mon Sep 17 00:00:00 2001 From: James Johnson Date: Thu, 9 May 2024 11:57:49 -0500 Subject: [PATCH] Refine 404 with contextual data (#166) --- app/assets/stylesheets/_error-page.scss | 6 +++++- app/controllers/application_controller.rb | 1 + app/views/errors/not_found.html.erb | 10 ++++++---- config/locales/en.bootstrap.yml | 2 ++ 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/app/assets/stylesheets/_error-page.scss b/app/assets/stylesheets/_error-page.scss index f457b61e..20adf8ee 100644 --- a/app/assets/stylesheets/_error-page.scss +++ b/app/assets/stylesheets/_error-page.scss @@ -28,7 +28,7 @@ .error-page__message { font-size: 1.25rem; - max-width: 30rem; + max-width: 60ch; margin: auto; } @@ -46,3 +46,7 @@ padding: 3rem 1rem; } } + +.error-page p { + margin: 1em; +} \ No newline at end of file diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index d26de965..5cfec6bf 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -41,6 +41,7 @@ def set_admin_view end def render_not_found + @requested_path = request.path render template: 'errors/not_found', layout: 'layouts/application', status: :not_found, formats: [:html] end diff --git a/app/views/errors/not_found.html.erb b/app/views/errors/not_found.html.erb index dc450af5..c202d584 100644 --- a/app/views/errors/not_found.html.erb +++ b/app/views/errors/not_found.html.erb @@ -1,10 +1,12 @@

404

Not Found

-

- We can’t seem to find what you’re looking for. This could be caused by a bad link or a mistyped URL. You could try the University of Minnesota Search. + The address + <% if @requested_path %> + <%= t('views.not_found.hostname') %><%= @requested_path %> + <% end %> + does not exist. Please double check the address, or contact the person who provided you with this link.

-
-
+ diff --git a/config/locales/en.bootstrap.yml b/config/locales/en.bootstrap.yml index d5372dbb..366dff3e 100644 --- a/config/locales/en.bootstrap.yml +++ b/config/locales/en.bootstrap.yml @@ -242,3 +242,5 @@ en: submit: "Delete URLs" submit_confirm: "Are you sure you want to delete these URLs?" cancel: "Cancel" + not_found: + hostname: "z.umn.edu" \ No newline at end of file