summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/controllers/errors_controller.rb10
-rw-r--r--app/helpers/core_helper.rb7
-rw-r--r--app/views/errors/not_found.html.haml7
-rw-r--r--app/views/errors/server_error.html.haml7
-rw-r--r--app/views/layouts/_footer.html.haml2
-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
10 files changed, 51 insertions, 52 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/helpers/core_helper.rb b/app/helpers/core_helper.rb
index 4126906..46e8fa4 100644
--- a/app/helpers/core_helper.rb
+++ b/app/helpers/core_helper.rb
@@ -10,4 +10,11 @@ module CoreHelper
render 'common/home_page_buttons'
end
+ #
+ # returns true if the configured service levels contain a level with a price attached
+ #
+ def paid_service_level?
+ APP_CONFIG[:service_levels].present? && APP_CONFIG[:service_levels].detect{|k,v| v['rate'].present?}
+ 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/app/views/layouts/_footer.html.haml b/app/views/layouts/_footer.html.haml
index 340d36c..de53667 100644
--- a/app/views/layouts/_footer.html.haml
+++ b/app/views/layouts/_footer.html.haml
@@ -6,5 +6,5 @@
= link_to icon('info-sign') + t(:about), about_path
- if lookup_context.exists?('pages/contact')
= link_to icon('comment') + t(:contact), contact_path
- - if APP_CONFIG[:service_levels].present?
+ - if paid_service_level?
= link_to icon('shopping-cart') + t(:pricing), pricing_path
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 2853fbd..4ccfe62 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>