Skip to content

Commit

Permalink
Refine 404 with contextual data (#166)
Browse files Browse the repository at this point in the history
  • Loading branch information
jxjj authored May 9, 2024
1 parent 6c27771 commit 82a2c35
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
6 changes: 5 additions & 1 deletion app/assets/stylesheets/_error-page.scss
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

.error-page__message {
font-size: 1.25rem;
max-width: 30rem;
max-width: 60ch;
margin: auto;
}

Expand All @@ -46,3 +46,7 @@
padding: 3rem 1rem;
}
}

.error-page p {
margin: 1em;
}
1 change: 1 addition & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 6 additions & 4 deletions app/views/errors/not_found.html.erb
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<main class="error-page">
<h1 class="error-page__heading">404</h1>
<h2 class="error-page__subheading">Not Found</h2>

<div class="error-page__message">
<p>
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 <a href="https://usearch.umn.edu/">University of Minnesota Search</a>.
The address
<% if @requested_path %>
<code><%= t('views.not_found.hostname') %><%= @requested_path %></code>
<% end %>
does not exist. Please double check the address, or contact the person who provided you with this link.
</p>
</div>
</main>
</main>
2 changes: 2 additions & 0 deletions config/locales/en.bootstrap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

0 comments on commit 82a2c35

Please sign in to comment.