Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refine 404 with contextual data #166

Merged
merged 2 commits into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
Loading