From da546109a5ab0e370ccb9827af2e2fed3b1d076f Mon Sep 17 00:00:00 2001 From: Andy Smith Date: Mon, 28 Jul 2025 15:09:40 -0500 Subject: [PATCH 1/5] Add a custom 404 page --- config/environments/development.rb | 2 +- public/404.html | 197 +++++++++++++++++------------ 2 files changed, 114 insertions(+), 85 deletions(-) diff --git a/config/environments/development.rb b/config/environments/development.rb index 24fc6c04c..6995eab5b 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -12,7 +12,7 @@ Rails.application.configure do config.eager_load = false # Show full error reports. - config.consider_all_requests_local = true + config.consider_all_requests_local = false # Enable server timing config.server_timing = true diff --git a/public/404.html b/public/404.html index dacd6ca5b..6829f81bf 100644 --- a/public/404.html +++ b/public/404.html @@ -1,119 +1,148 @@ - - - The page you were looking for doesn’t exist (404 Not found) - - + .error-page__subtitle { + color: var(--color-accent); + margin-block-end: 1ch; + } + .error-page__notes { + font-size: var(--text-sm); + font-weight: 500; + } + - - - -
-
- +
+ +
+
404
+
Sorry, that page does‘t exist!
+
You may have mistyped the address or the page may have moved
-
-

The page you were looking for doesn’t exist. You may have mistyped the address or the page may have moved. If you’re the application owner check the logs for more information.

-
-
+ - From 84b8bb0a43b739a81c63712f4da0873a0f9a06aa Mon Sep 17 00:00:00 2001 From: Andy Smith Date: Tue, 29 Jul 2025 13:32:00 -0500 Subject: [PATCH 2/5] Add controller, routes, and templates for other error pages --- app/controllers/errors_controller.rb | 25 +++ app/views/errors/bad_request.html.erb | 7 + .../errors/internal_server_error.html.erb | 7 + app/views/errors/not_acceptable.html.erb | 7 + app/views/errors/not_found.html.erb | 7 + .../errors/unprocessable_entity.html.erb | 7 + app/views/layouts/error.html.erb | 164 ++++++++++++++++++ config/application.rb | 3 + config/routes.rb | 6 + public/400.html | 114 ------------ public/404.html | 148 ---------------- public/406-unsupported-browser.html | 156 ----------------- public/422.html | 114 ------------ public/500.html | 114 ------------ 14 files changed, 233 insertions(+), 646 deletions(-) create mode 100644 app/controllers/errors_controller.rb create mode 100644 app/views/errors/bad_request.html.erb create mode 100644 app/views/errors/internal_server_error.html.erb create mode 100644 app/views/errors/not_acceptable.html.erb create mode 100644 app/views/errors/not_found.html.erb create mode 100644 app/views/errors/unprocessable_entity.html.erb create mode 100644 app/views/layouts/error.html.erb delete mode 100644 public/400.html delete mode 100644 public/404.html delete mode 100644 public/406-unsupported-browser.html delete mode 100644 public/422.html delete mode 100644 public/500.html diff --git a/app/controllers/errors_controller.rb b/app/controllers/errors_controller.rb new file mode 100644 index 000000000..168dc12e3 --- /dev/null +++ b/app/controllers/errors_controller.rb @@ -0,0 +1,25 @@ +class ErrorsController < ApplicationController + require_untenanted_access + + layout "error" + + def bad_request + render status: :bad_request + end + + def not_found + render status: :not_found + end + + def not_acceptable + render status: :not_acceptable + end + + def unprocessable_entity + render status: :unprocessable_entity + end + + def internal_server_error + render status: :internal_server_error + end +end diff --git a/app/views/errors/bad_request.html.erb b/app/views/errors/bad_request.html.erb new file mode 100644 index 000000000..19e31fe91 --- /dev/null +++ b/app/views/errors/bad_request.html.erb @@ -0,0 +1,7 @@ +
+

400

+

Bad request

+
+
Your request could not be understood by the server.
+
+ diff --git a/app/views/errors/internal_server_error.html.erb b/app/views/errors/internal_server_error.html.erb new file mode 100644 index 000000000..1f7802f17 --- /dev/null +++ b/app/views/errors/internal_server_error.html.erb @@ -0,0 +1,7 @@ +
+

500

+

Internal server error

+
+
Something went wrong on our end; please try again later.
+
+ diff --git a/app/views/errors/not_acceptable.html.erb b/app/views/errors/not_acceptable.html.erb new file mode 100644 index 000000000..976cc0d89 --- /dev/null +++ b/app/views/errors/not_acceptable.html.erb @@ -0,0 +1,7 @@ +
+

406

+

Not acceptable

+
+
The requested resource is not available in a format acceptable to your browser.
+
+ diff --git a/app/views/errors/not_found.html.erb b/app/views/errors/not_found.html.erb new file mode 100644 index 000000000..f3e9f5e23 --- /dev/null +++ b/app/views/errors/not_found.html.erb @@ -0,0 +1,7 @@ +
+

404

+

Sorry, that page doesn’t exist!

+
+
You may have mistyped the address or the page may have moved.
+
+ diff --git a/app/views/errors/unprocessable_entity.html.erb b/app/views/errors/unprocessable_entity.html.erb new file mode 100644 index 000000000..2e6d18d0d --- /dev/null +++ b/app/views/errors/unprocessable_entity.html.erb @@ -0,0 +1,7 @@ +
+

422

+

Unprocessable entity

+
+
The server understands the request but was unable to process it.
+
+ diff --git a/app/views/layouts/error.html.erb b/app/views/layouts/error.html.erb new file mode 100644 index 000000000..869707883 --- /dev/null +++ b/app/views/layouts/error.html.erb @@ -0,0 +1,164 @@ + + + + The page you were looking for doesn’t exist (404 Not found) + + + + + + + + <%= yield %> + Go back + + diff --git a/config/application.rb b/config/application.rb index 3fc46a769..c39007fb2 100644 --- a/config/application.rb +++ b/config/application.rb @@ -28,5 +28,8 @@ module Fizzy # enable load_async config.active_record.async_query_executor = :global_thread_pool + + # use routes for error pages instead of static files + config.exceptions_app = self.routes end end diff --git a/config/routes.rb b/config/routes.rb index 2a1554e84..15921bb86 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -179,6 +179,12 @@ Rails.application.routes.draw do get "manifest" => "rails/pwa#manifest", as: :pwa_manifest get "service-worker" => "pwa#service_worker" + match "/400", to: "errors#bad_request", via: :all + match "/404", to: "errors#not_found", via: :all + match "/406", to: "errors#not_acceptable", via: :all + match "/422", to: "errors#unprocessable_entity", via: :all + match "/500", to: "errors#internal_server_error", via: :all + root "events#index" Queenbee.routes(self) diff --git a/public/400.html b/public/400.html deleted file mode 100644 index 282dbc8cc..000000000 --- a/public/400.html +++ /dev/null @@ -1,114 +0,0 @@ - - - - - - - The server cannot process the request due to a client error (400 Bad Request) - - - - - - - - - - - - - -
-
- -
-
-

The server cannot process the request due to a client error. Please check the request and try again. If you’re the application owner check the logs for more information.

-
-
- - - - diff --git a/public/404.html b/public/404.html deleted file mode 100644 index 6829f81bf..000000000 --- a/public/404.html +++ /dev/null @@ -1,148 +0,0 @@ - - - - The page you were looking for doesn’t exist (404 Not found) - - - - - - - -
- -
-
404
-
Sorry, that page does‘t exist!
-
You may have mistyped the address or the page may have moved
-
-
- - - diff --git a/public/406-unsupported-browser.html b/public/406-unsupported-browser.html deleted file mode 100644 index f78ac9454..000000000 --- a/public/406-unsupported-browser.html +++ /dev/null @@ -1,156 +0,0 @@ - - - - Your browser is not supported (406) - - - - - - -
-
- - - -
- - - - - Go back - -
-

🇺🇸 Upgrade to a supported web browser. Fizzy requires a modern web browser. Please use one of the browsers listed below and make sure auto-updates are enabled.

-

🇪🇸 Actualiza a un navegador web compatible. Fizzy requiere un navegador web moderno. Utiliza uno de los navegadores listados a continuación y asegúrate de que las actualizaciones automáticas estén habilitadas.

-

🇫🇷 Mettez à jour vers un navigateur web pris en charge. Fizzy nécessite un navigateur web moderne. Veuillez utiliser l'un des navigateurs répertoriés ci-dessous et assurez-vous que les mises à jour automatiques sont activées.

-

🇮🇳 समर्थित वेब ब्राउज़र में अपग्रेड करें। Fizzy को एक आधुनिक वेब ब्राउज़र की आवश्यकता है। कृपया नीचे सूचीबद्ध ब्राउज़रों में से कोई एक का उपयोग करें और सुनिश्चित करें कि स्वचालित अपडेट्स सक्षम हैं।

-

🇩🇪 Aktualisieren Sie auf einen unterstützten Webbrowser. Fizzy erfordert einen modernen Webbrowser. Verwenden Sie bitte einen der unten aufgeführten Browser und stellen Sie sicher, dass automatische Updates aktiviert sind.

-

🇧🇷 Atualize para um navegador compatível. O Fizzy requer um navegador moderno. Por favor, use um dos navegadores listados abaixo e certifique-se de que as atualizações automáticas estão ativadas.

-

Safari 17.2+, Chrome 119+, Firefox 121+, Opera 104+

-
-
- - diff --git a/public/422.html b/public/422.html deleted file mode 100644 index 8bcf06014..000000000 --- a/public/422.html +++ /dev/null @@ -1,114 +0,0 @@ - - - - - - - The change you wanted was rejected (422 Unprocessable Entity) - - - - - - - - - - - - - -
-
- -
-
-

The change you wanted was rejected. Maybe you tried to change something you didn’t have access to. If you’re the application owner check the logs for more information.

-
-
- - - - diff --git a/public/500.html b/public/500.html deleted file mode 100644 index d77718c3a..000000000 --- a/public/500.html +++ /dev/null @@ -1,114 +0,0 @@ - - - - - - - We’re sorry, but something went wrong (500 Internal Server Error) - - - - - - - - - - - - - -
-
- -
-
-

We’re sorry, but something went wrong.
If you’re the application owner check the logs for more information.

-
-
- - - - From c3cecfbd62d190d29dd77c0347e49794d13aea87 Mon Sep 17 00:00:00 2001 From: Andy Smith Date: Tue, 29 Jul 2025 13:35:43 -0500 Subject: [PATCH 3/5] Remove unused classes --- app/views/errors/bad_request.html.erb | 2 +- app/views/errors/internal_server_error.html.erb | 2 +- app/views/errors/not_acceptable.html.erb | 2 +- app/views/errors/not_found.html.erb | 2 +- app/views/errors/unprocessable_entity.html.erb | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/views/errors/bad_request.html.erb b/app/views/errors/bad_request.html.erb index 19e31fe91..00264d09d 100644 --- a/app/views/errors/bad_request.html.erb +++ b/app/views/errors/bad_request.html.erb @@ -1,5 +1,5 @@
-

400

+

400

Bad request


Your request could not be understood by the server.
diff --git a/app/views/errors/internal_server_error.html.erb b/app/views/errors/internal_server_error.html.erb index 1f7802f17..6882a9888 100644 --- a/app/views/errors/internal_server_error.html.erb +++ b/app/views/errors/internal_server_error.html.erb @@ -1,5 +1,5 @@
-

500

+

500

Internal server error


Something went wrong on our end; please try again later.
diff --git a/app/views/errors/not_acceptable.html.erb b/app/views/errors/not_acceptable.html.erb index 976cc0d89..6b85332ac 100644 --- a/app/views/errors/not_acceptable.html.erb +++ b/app/views/errors/not_acceptable.html.erb @@ -1,5 +1,5 @@
-

406

+

406

Not acceptable


The requested resource is not available in a format acceptable to your browser.
diff --git a/app/views/errors/not_found.html.erb b/app/views/errors/not_found.html.erb index f3e9f5e23..6bc003c71 100644 --- a/app/views/errors/not_found.html.erb +++ b/app/views/errors/not_found.html.erb @@ -1,5 +1,5 @@
-

404

+

404

Sorry, that page doesn’t exist!


You may have mistyped the address or the page may have moved.
diff --git a/app/views/errors/unprocessable_entity.html.erb b/app/views/errors/unprocessable_entity.html.erb index 2e6d18d0d..9c904db6d 100644 --- a/app/views/errors/unprocessable_entity.html.erb +++ b/app/views/errors/unprocessable_entity.html.erb @@ -1,5 +1,5 @@
-

422

+

422

Unprocessable entity


The server understands the request but was unable to process it.
From 5d75e9a4d6bb80c84a44e02ad5308000f09a8185 Mon Sep 17 00:00:00 2001 From: Andy Smith Date: Wed, 30 Jul 2025 10:04:08 -0500 Subject: [PATCH 4/5] Add meta titles --- app/views/errors/bad_request.html.erb | 2 ++ app/views/errors/internal_server_error.html.erb | 2 ++ app/views/errors/not_acceptable.html.erb | 2 ++ app/views/errors/not_found.html.erb | 2 ++ app/views/errors/unprocessable_entity.html.erb | 2 ++ app/views/layouts/error.html.erb | 3 ++- 6 files changed, 12 insertions(+), 1 deletion(-) diff --git a/app/views/errors/bad_request.html.erb b/app/views/errors/bad_request.html.erb index 00264d09d..e77283a79 100644 --- a/app/views/errors/bad_request.html.erb +++ b/app/views/errors/bad_request.html.erb @@ -1,3 +1,5 @@ +<% @page_title = "400 Bad Request" %> +

400

Bad request

diff --git a/app/views/errors/internal_server_error.html.erb b/app/views/errors/internal_server_error.html.erb index 6882a9888..a26256503 100644 --- a/app/views/errors/internal_server_error.html.erb +++ b/app/views/errors/internal_server_error.html.erb @@ -1,3 +1,5 @@ +<% @page_title = "500 Internal Server Error" %> +

500

Internal server error

diff --git a/app/views/errors/not_acceptable.html.erb b/app/views/errors/not_acceptable.html.erb index 6b85332ac..9408b22b0 100644 --- a/app/views/errors/not_acceptable.html.erb +++ b/app/views/errors/not_acceptable.html.erb @@ -1,3 +1,5 @@ +<% @page_title = "406 Not Acceptable" %> +

406

Not acceptable

diff --git a/app/views/errors/not_found.html.erb b/app/views/errors/not_found.html.erb index 6bc003c71..c0eafd153 100644 --- a/app/views/errors/not_found.html.erb +++ b/app/views/errors/not_found.html.erb @@ -1,3 +1,5 @@ +<% @page_title = "404 Not Found" %> +

404

Sorry, that page doesn’t exist!

diff --git a/app/views/errors/unprocessable_entity.html.erb b/app/views/errors/unprocessable_entity.html.erb index 9c904db6d..ede9ed3e6 100644 --- a/app/views/errors/unprocessable_entity.html.erb +++ b/app/views/errors/unprocessable_entity.html.erb @@ -1,3 +1,5 @@ +<% @page_title = "422 Unprocessable Entity" %> +

422

Unprocessable entity

diff --git a/app/views/layouts/error.html.erb b/app/views/layouts/error.html.erb index 869707883..673efa465 100644 --- a/app/views/layouts/error.html.erb +++ b/app/views/layouts/error.html.erb @@ -1,7 +1,7 @@ - The page you were looking for doesn’t exist (404 Not found) + <%= page_title_tag %> @@ -131,6 +131,7 @@ inline-size: 100%; border: 0; border-block-start: calc(var(--stroke-width) / 2) solid currentcolor; + color: currentcolor; margin: 1ch auto; } From f8ec00022bc4832828f2caad38910de4270eb47b Mon Sep 17 00:00:00 2001 From: Andy Smith Date: Mon, 4 Aug 2025 11:53:45 -0500 Subject: [PATCH 5/5] Flip config.consider_all_requests_local --- config/environments/development.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/environments/development.rb b/config/environments/development.rb index 6995eab5b..24fc6c04c 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -12,7 +12,7 @@ Rails.application.configure do config.eager_load = false # Show full error reports. - config.consider_all_requests_local = false + config.consider_all_requests_local = true # Enable server timing config.server_timing = true