mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Merge pull request #9532 from jibees/9492-translate-404,-500,-422-errors-pages
Translate 404, 500, 422 errors pages
This commit is contained in:
17
app/controllers/errors_controller.rb
Normal file
17
app/controllers/errors_controller.rb
Normal file
@@ -0,0 +1,17 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class ErrorsController < ApplicationController
|
||||
layout "errors"
|
||||
|
||||
def not_found
|
||||
render status: :not_found
|
||||
end
|
||||
|
||||
def internal_server_error
|
||||
render status: :internal_server_error
|
||||
end
|
||||
|
||||
def unprocessable_entity
|
||||
render status: :unprocessable_entity
|
||||
end
|
||||
end
|
||||
8
app/views/errors/internal_server_error.html.haml
Normal file
8
app/views/errors/internal_server_error.html.haml
Normal file
@@ -0,0 +1,8 @@
|
||||
- content_for :title do
|
||||
= I18n.t("errors.internal_server_error.title")
|
||||
.dialog
|
||||
%a{href: "/"}
|
||||
%img{src: "/500.jpg"}
|
||||
%h1
|
||||
= t("errors.internal_server_error.title")
|
||||
= t("errors.internal_server_error.message_html")
|
||||
8
app/views/errors/not_found.html.haml
Normal file
8
app/views/errors/not_found.html.haml
Normal file
@@ -0,0 +1,8 @@
|
||||
- content_for :title do
|
||||
= I18n.t("errors.not_found.title")
|
||||
.dialog
|
||||
%a{href: "/"}
|
||||
%img{src: "/500.jpg"}
|
||||
%h1
|
||||
= t("errors.not_found.title")
|
||||
= t("errors.not_found.message_html")
|
||||
26
app/views/errors/unprocessable_entity.html.haml
Normal file
26
app/views/errors/unprocessable_entity.html.haml
Normal file
@@ -0,0 +1,26 @@
|
||||
:css
|
||||
body {
|
||||
text-align: center;
|
||||
}
|
||||
a {
|
||||
font-size: 100%;
|
||||
color: black;
|
||||
line-height: 1.5em;
|
||||
text-decoration: none;
|
||||
border-bottom: 1px dotted black;
|
||||
padding: 0 0.2rem;
|
||||
}
|
||||
a:hover, a:focus, a:active{
|
||||
background: #8f301d;
|
||||
color: white;
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
- content_for :title do
|
||||
= I18n.t("errors.unprocessable_entity.title")
|
||||
.dialog
|
||||
%a{href: "/", style: "border: none; background: none;"}
|
||||
%img{src: "/422.jpg"}
|
||||
%h1
|
||||
= t("errors.unprocessable_entity.title")
|
||||
= t("errors.unprocessable_entity.message_html")
|
||||
28
app/views/layouts/errors.html.haml
Normal file
28
app/views/layouts/errors.html.haml
Normal file
@@ -0,0 +1,28 @@
|
||||
%html
|
||||
%head
|
||||
:css
|
||||
body {
|
||||
background-color: #fff;
|
||||
color: #666;
|
||||
font-family: arial, sans-serif;
|
||||
|
||||
}
|
||||
div.dialog {
|
||||
width: 600px;
|
||||
margin: auto;
|
||||
}
|
||||
@media only screen
|
||||
and (min-width: 320px)
|
||||
and (max-width: 568px) {
|
||||
div.dialog, div.dialog img {
|
||||
width: 95%;
|
||||
}
|
||||
}
|
||||
div.dialog h1 {
|
||||
font-size: 1.8em;
|
||||
}
|
||||
%title
|
||||
= yield(:title)
|
||||
|
||||
%body
|
||||
= yield
|
||||
@@ -243,5 +243,7 @@ module Openfoodnetwork
|
||||
config.active_storage.service = ENV["S3_BUCKET"].present? ? :amazon : :local
|
||||
config.active_storage.content_types_to_serve_as_binary -= ["image/svg+xml"]
|
||||
config.active_storage.variable_content_types += ["image/svg+xml"]
|
||||
|
||||
config.exceptions_app = self.routes
|
||||
end
|
||||
end
|
||||
|
||||
@@ -4304,3 +4304,25 @@ See the %{link} to find out more about %{sitename}'s features and to start using
|
||||
x_years:
|
||||
one: 1 year
|
||||
other: "%{count} years"
|
||||
errors:
|
||||
not_found:
|
||||
title: "The page you were looking for doesn't exist (404)"
|
||||
message_html: "<b>Please try again</b>
|
||||
<p>This might be a temporary problem. Please click the back button to return to the previous screen or go back to <a href='/'>Home</a> and try again.</p>
|
||||
<b>Contact support</b>
|
||||
<p>If the problem persists or is urgent, please tell us about it. Find our contact details from the global <a href='https://openfoodnetwork.org/ofn-local/' target='blank'>Open Food Network Local page</a>.</p>
|
||||
<p>It really helps us if you can give as much detail as possible about what the missing page is about.</p>"
|
||||
internal_server_error:
|
||||
title: "We're sorry, but something went wrong (500)"
|
||||
message_html: "<b>Please try again</b>
|
||||
<p>This might be a temporary problem. Please click the back button to return to the previous screen or go back to <a href='/''>Home</a> and try again.</p>
|
||||
<b>We're on it</b>
|
||||
<p>If you have seen this problem before, we probably already know about it and are working on a fix. We record all the errors that come up.</p>
|
||||
<b>Contact support</b>
|
||||
<p>If the problem persists or is urgent, please tell us about it. Find our contact details from the global <a href='https://openfoodnetwork.org/ofn-local/' target='blank'>Open Food Network Local page</a>.</p>
|
||||
<p>It really helps us if you can give as much detail as possible about what you were doing when this error occurred.</p>"
|
||||
unprocessable_entity:
|
||||
title: "The change you wanted was rejected (422)"
|
||||
message_html: "<p>The change you wanted was rejected. Maybe you tried to change something you don't have access to.
|
||||
<br><h3><a href='/' >Return home</a></h3>
|
||||
</p>"
|
||||
|
||||
@@ -124,4 +124,9 @@ Openfoodnetwork::Application.routes.draw do
|
||||
|
||||
# Mount Spree's routes
|
||||
mount Spree::Core::Engine, :at => '/'
|
||||
|
||||
# Errors controller
|
||||
match '/404' => 'errors#not_found', via: :all
|
||||
match '/500' => 'errors#internal_server_error', via: :all
|
||||
match '/422' => 'errors#unprocessable_entity', via: :all
|
||||
end
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>The page you were looking for doesn't exist (404)</title>
|
||||
<style type="text/css">
|
||||
body {
|
||||
background-color: #fff;
|
||||
color: #666;
|
||||
font-family: arial, sans-serif;
|
||||
|
||||
}
|
||||
div.dialog {
|
||||
width: 600px;
|
||||
margin: auto;
|
||||
}
|
||||
@media only screen
|
||||
and (min-width: 320px)
|
||||
and (max-width: 568px) {
|
||||
div.dialog, div.dialog img {
|
||||
width: 95%;
|
||||
}
|
||||
}
|
||||
div.dialog h1 {
|
||||
font-size: 1.8em;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!-- This file lives in public/404.html -->
|
||||
<div class="dialog">
|
||||
<a href="/" ><img src="/500.jpg" /></a>
|
||||
<h1>Oops! Page not found.</h1>
|
||||
<b>Please try again</b>
|
||||
<p>This might be a temporary problem. Please click the back button to return to the previous screen or go back to <a class="go_home" href="/">Home</a> and try again.</p>
|
||||
<b>Contact support</b>
|
||||
<p>If the problem persists or is urgent, please tell us about it. Find our contact details from the global <a href="https://openfoodnetwork.org/ofn-local/" target="blank">Open Food Network Local page</a>.</p>
|
||||
<p>It really helps us if you can give as much detail as possible about what the missing page is about.</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,38 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>The change you wanted was rejected (422)</title>
|
||||
<style type="text/css">
|
||||
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
||||
div.dialog {
|
||||
width: 25em;
|
||||
padding: 0 4em;
|
||||
margin: 2em auto 0 auto;
|
||||
}
|
||||
a.go_home {
|
||||
font-size: 100%;
|
||||
color: black;
|
||||
line-height: 1.5em;
|
||||
text-decoration: none;
|
||||
border-bottom: 1px dotted black;
|
||||
padding: 0 0.2rem;
|
||||
}
|
||||
a.go_home:hover, a.go_home:focus, a.go_home:active{
|
||||
background: #8f301d;
|
||||
color: white;
|
||||
border-bottom: none;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!-- This file lives in public/422.html -->
|
||||
<div class="dialog">
|
||||
<a href="/" ><img src="/422.jpg" /></a>
|
||||
<p>The change you wanted was rejected. Maybe you tried to change something you don't have access to.
|
||||
<br><h3><a class="go_home" href="/" >Return home</a></h3>
|
||||
</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user