summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorazul <azul@leap.se>2014-05-22 14:48:40 +0200
committerazul <azul@leap.se>2014-05-22 14:48:40 +0200
commit0c995deeb434237aa71e3a45f9f5a51f7c79116a (patch)
treed2988d37c9d3bdb02d9e0b36eb1bc61ca0782f1f
parentb9174fdc9d9bd403d9a16650bafc4715e3dbf2d4 (diff)
parentb298cea527f74f682d24defee360e0f45f47d125 (diff)
Merge pull request #162 from azul/feature/3295-custom-error-pages
Feature/3295 custom error pages
-rw-r--r--app/controllers/errors_controller.rb10
-rw-r--r--app/views/errors/not_found.html.haml7
-rw-r--r--app/views/errors/server_error.html.haml7
-rw-r--r--config/application.rb3
-rw-r--r--config/locales/en.yml9
-rw-r--r--config/routes.rb7
-rw-r--r--public/404.html26
-rw-r--r--public/500.html25
8 files changed, 43 insertions, 51 deletions
diff --git a/app/controllers/errors_controller.rb b/app/controllers/errors_controller.rb
new file mode 100644
index 0000000..6c659e6
--- /dev/null
+++ b/app/controllers/errors_controller.rb
@@ -0,0 +1,10 @@
+# We render http errors ourselves so we can customize them
+class ErrorsController < ApplicationController
+ # 404
+ def not_found
+ end
+
+ # 500
+ def server_error
+ end
+end
diff --git a/app/views/errors/not_found.html.haml b/app/views/errors/not_found.html.haml
new file mode 100644
index 0000000..75cb889
--- /dev/null
+++ b/app/views/errors/not_found.html.haml
@@ -0,0 +1,7 @@
+.hero-unit
+ %h1=t :not_found_title
+ %h2=t :not_found_subtitle
+ %p.lead=t :not_found_lead
+ %a.btn.btn-primary.btn-large{href:'/'}
+ %i.icon-home.icon-white
+ =t :home
diff --git a/app/views/errors/server_error.html.haml b/app/views/errors/server_error.html.haml
new file mode 100644
index 0000000..68baf20
--- /dev/null
+++ b/app/views/errors/server_error.html.haml
@@ -0,0 +1,7 @@
+.hero-unit
+ %h1=t :server_error_title
+ %h2=t :server_error_subtitle
+ %p.lead=t :server_error_lead
+ %a.btn.btn-primary.btn-large{href:'/'}
+ %i.icon-home.icon-white
+ =t :home
diff --git a/config/application.rb b/config/application.rb
index 2c9c55a..8555f48 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -91,5 +91,8 @@ module LeapWeb
## see initializers/customization.rb
##
config.paths['app/views'].unshift "config/customization/views"
+
+ # handle http errors ourselves
+ config.exceptions_app = self.routes
end
end
diff --git a/config/locales/en.yml b/config/locales/en.yml
index cebf075..899d659 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -1,10 +1,19 @@
en:
+ home: Home
privacy_policy: Privacy Policy
terms_of_service: Terms of Service
pricing: Pricing
about: About Us
contact: Contact
+
+ not_found_title: Page not found.
+ not_found_subtitle: "The page you were looking for doesn't exist."
+ not_found_lead: "You may have mistyped the address or the page may have moved."
+ server_error_title: Ouch!
+ server_error_subtitle: We ran into a server error.
+ server_error_lead: The problem has been logged and we will look into it.
no_such_thing: "No such %{thing}."
+
thing_was_successfully_created: "%{thing} was successfully created."
create_thing: "Create %{thing}"
diff --git a/config/routes.rb b/config/routes.rb
index 745b97d..9e0b72d 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -6,6 +6,13 @@ LeapWeb::Application.routes.draw do
root :to => "home#index"
get '(:locale)' => 'home#index', :locale => MATCH_LOCALE, :as => 'home'
+ #
+ # HTTP Error Handling
+ # instead of the default error pages use the errors controller and views
+ #
+ match '/404' => 'errors#not_found'
+ match '/500' => 'errors#server_error'
+
scope "(:locale)", :locale => MATCH_LOCALE, :controller => 'pages', :action => 'show' do
get 'privacy-policy', :as => 'privacy_policy'
get 'terms-of-service', :as => 'terms_of_service'
diff --git a/public/404.html b/public/404.html
deleted file mode 100644
index 9a48320..0000000
--- a/public/404.html
+++ /dev/null
@@ -1,26 +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; text-align: center; font-family: arial, sans-serif; }
- div.dialog {
- width: 25em;
- padding: 0 4em;
- margin: 4em auto 0 auto;
- border: 1px solid #ccc;
- border-right-color: #999;
- border-bottom-color: #999;
- }
- h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
- </style>
-</head>
-
-<body>
- <!-- This file lives in public/404.html -->
- <div class="dialog">
- <h1>The page you were looking for doesn't exist.</h1>
- <p>You may have mistyped the address or the page may have moved.</p>
- </div>
-</body>
-</html>
diff --git a/public/500.html b/public/500.html
deleted file mode 100644
index f3648a0..0000000
--- a/public/500.html
+++ /dev/null
@@ -1,25 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
- <title>We're sorry, but something went wrong (500)</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: 4em auto 0 auto;
- border: 1px solid #ccc;
- border-right-color: #999;
- border-bottom-color: #999;
- }
- h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
- </style>
-</head>
-
-<body>
- <!-- This file lives in public/500.html -->
- <div class="dialog">
- <h1>We're sorry, but something went wrong.</h1>
- </div>
-</body>
-</html>