diff --git a/app/assets/stylesheets/errors.css.scss b/app/assets/stylesheets/errors.css.scss new file mode 100644 index 0000000..07c3490 --- /dev/null +++ b/app/assets/stylesheets/errors.css.scss @@ -0,0 +1,55 @@ +/* + Libraries & Configuration +*/ + +@import "bourbon"; +@import "variables"; +@import "neat"; +@import "neat-helpers"; + +/* + Layout +*/ + +@import "layout/body"; +@import "layout/typography"; + +/* + Error Page +*/ + +html, +body { + height: 100%; +} + +html { + @include linear-gradient($dark-blue, $deep-blue); +} + +body { + color: white; + background: transparent; +} + +#error { + display: table; + height: 100%; + margin: 0 auto; + max-width: 60%; + width: 90%; + text-align: center; + text-shadow: 0px 2px 2px rgba(0, 0, 0, 0.75); + + #code h1 { + font-size: 48px; + margin: 1em 0; + } + + .message { + padding-top: 50px; + display: table-cell; + vertical-align: middle; + padding-bottom: 100px; + } +} diff --git a/app/controllers/errors_controller.rb b/app/controllers/errors_controller.rb new file mode 100644 index 0000000..bf55884 --- /dev/null +++ b/app/controllers/errors_controller.rb @@ -0,0 +1,13 @@ +class ErrorsController < ApplicationController + layout 'errors' + + def show + render status_code.to_s, status: status_code + end + + private + + def status_code + params[:code] || 500 + end +end diff --git a/app/views/errors/403.html.erb b/app/views/errors/403.html.erb new file mode 100644 index 0000000..32eff18 --- /dev/null +++ b/app/views/errors/403.html.erb @@ -0,0 +1,2 @@ +

You are not allowed to visit the page you were looking for.

+

The administrator of this web site has denied access to you at this time.

diff --git a/app/views/errors/404.html.erb b/app/views/errors/404.html.erb new file mode 100644 index 0000000..b001ef3 --- /dev/null +++ b/app/views/errors/404.html.erb @@ -0,0 +1,2 @@ +

The page you were looking for doesn't exist.

+

You may have mistyped the address or the page may have moved.

diff --git a/app/views/errors/422.html.erb b/app/views/errors/422.html.erb new file mode 100644 index 0000000..003efbc --- /dev/null +++ b/app/views/errors/422.html.erb @@ -0,0 +1,2 @@ +

The change you wanted was rejected.

+

Maybe you tried to change something you didn't have access to.

diff --git a/app/views/errors/500.html.erb b/app/views/errors/500.html.erb new file mode 100644 index 0000000..3855eb5 --- /dev/null +++ b/app/views/errors/500.html.erb @@ -0,0 +1,2 @@ +

We're sorry, but something went wrong.

+

We've been notified about this issue and we'll take a look at it shortly.

diff --git a/app/views/layouts/errors.html.erb b/app/views/layouts/errors.html.erb new file mode 100644 index 0000000..580b6fe --- /dev/null +++ b/app/views/layouts/errors.html.erb @@ -0,0 +1,24 @@ + + + + <%= full_title(yield(:title)) %> | Error <%= params[:code] %> + + + + + <%= stylesheet_link_tag 'errors' %> + + +
+
+ +
+

<%= params[:code] %>

+
+ <%= yield %> +
+
+ + diff --git a/config/application.rb b/config/application.rb index 5fe9a48..40a9a44 100644 --- a/config/application.rb +++ b/config/application.rb @@ -1,13 +1,12 @@ require File.expand_path('../boot', __FILE__) require 'rails/all' -Bundler.require(*Rails.groups(:assets => %w(development test))) +Bundler.require(*Rails.groups(assets: %w(development test))) module Ensl class Application < Rails::Application - # Settings in config/environments/* take precedence over those specified here. - # Application configuration should go into files in config/initializers - # -- all .rb files in that directory are automatically loaded. + # Custom error pages + config.exceptions_app = self.routes # Custom directories with classes and modules you want to be autoloadable. config.autoload_paths += Dir["#{config.root}/app/services/**/", "#{config.root}/app/models/concerns/"] @@ -16,16 +15,12 @@ module Ensl config.secret_token = ENV['APP_SECRET'] # Use cookies - config.session_store :cookie_store, :key => '_ENSL_session_key', :expire_after => 30.days.to_i + config.session_store :cookie_store, key: '_ENSL_session_key', expire_after: 30.days.to_i # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. config.time_zone = 'Amsterdam' - # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. - # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] - # config.i18n.default_locale = :de - # Configure the default encoding used in templates for Ruby 1.9. config.encoding = "utf-8" diff --git a/config/routes.rb b/config/routes.rb index 9f94d0a..806b92f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,4 +1,8 @@ Ensl::Application.routes.draw do + %w(403 404 422 500).each do |code| + get code, to: 'errors#show', code: code + end + root to: "articles#news_index" resources :articles do diff --git a/public/403.html b/public/403.html deleted file mode 100644 index d0a1bab..0000000 --- a/public/403.html +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - You are not allowed to access this resource (403) - - - - - -
-

You are not allowed to visit the page you were looking for.

-

The administrator of this web site has denied access to you at this time.

-
HTTP 403 Forbidden
-
- - diff --git a/public/404.html b/public/404.html deleted file mode 100644 index eff660b..0000000 --- a/public/404.html +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - The page you were looking for doesn't exist (404) - - - - - -
-

The page you were looking for doesn't exist.

-

You may have mistyped the address or the page may have moved.

-
- - \ No newline at end of file diff --git a/public/422.html b/public/422.html deleted file mode 100644 index b54e4a3..0000000 --- a/public/422.html +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - The change you wanted was rejected (422) - - - - - -
-

The change you wanted was rejected.

-

Maybe you tried to change something you didn't have access to.

-
- - \ No newline at end of file diff --git a/public/500.html b/public/500.html deleted file mode 100644 index 0cd07c1..0000000 --- a/public/500.html +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - We're sorry, but something went wrong (500) - - - - - -
-

We're sorry, but something went wrong.

-

We've been notified about this issue and we'll take a look at it shortly.

-

(If you're the administrator of this website, then please read - the log file "<%=h RAILS_ENV %>.log" - to find out what went wrong.)

-
- -