-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feature] [WEBSITE-1239] 404 page redesign (#2253)
* 404 page redesign * Fix css format * Fix link destination * Remove old 404 file * Add new controller and helper * Add new 404 template * Add new route to the 404 page * Tell rails to use tempaltes * Error pages sass * Catch errors with custom error pages yielded w/ application layout * update styling and put content inside .container * Optimize calls + raise exception for development mode * Return back static 500 page * Make rails app available to catch RoutingError (raised by ActionDispatch) Ref: rails/rails#671 * Fix not found routes spec * Fix unmactched routes catch * Fix specs
- Loading branch information
1 parent
2a2768f
commit 6b7fde3
Showing
20 changed files
with
188 additions
and
168 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Error Pages (Errors 404, 500 etc) | ||
.error-page { | ||
margin: 100px auto; | ||
|
||
h1 { | ||
font-size: 3.8em; | ||
margin-top: 0; | ||
} | ||
|
||
h2 { | ||
font-size: 3.2rem; | ||
margin: 50px 0; | ||
} | ||
|
||
p { | ||
font-size: 2rem; | ||
font-weight: 300; | ||
line-height: 150%; | ||
margin: 0; | ||
} | ||
|
||
a { | ||
@extend .link-underline; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
module Concerns | ||
module Errors | ||
extend ActiveSupport::Concern | ||
|
||
MYSTERIOUS_ROUTES = [ 'undefined', '/au/undefined', '1000668' ].freeze | ||
|
||
included do | ||
rescue_from ActiveRecord::RecordInvalid, with: -> { render_error(code: 422) } | ||
rescue_from ActiveRecord::RecordNotFound, with: -> { render_error(code: 404) } | ||
rescue_from ActionController::UnknownController, with: -> { render_error(code: 404) } | ||
rescue_from ActionController::RoutingError, with: -> { render_error(code: 404) } | ||
rescue_from AbstractController::ActionNotFound, with: -> { render_error(code: 404) } | ||
end | ||
|
||
def non_matching_request | ||
path = params.fetch(:path, '') | ||
format = params.fetch(:format, '') | ||
|
||
if path.match(/\.php$/) || format.eql?('php') | ||
head :not_acceptable, layout: false | ||
|
||
elsif MYSTERIOUS_ROUTES.any? { |v| v.match(path) } | ||
data = request.env.select {|key,_| key.upcase == key } | ||
NewRelic::Agent.record_custom_event('UndefinedURL', data) | ||
render text: 'Not Found', status: :not_found | ||
|
||
else | ||
# NOTE: Alexey Bobyrev 14 Jan 2017 | ||
# Raise error here to make it visible for application#rescue_from | ||
# Ref: https://github.com/rails/rails/issues/671 | ||
raise ActionController::RoutingError.new(path) | ||
end | ||
end | ||
|
||
protected | ||
|
||
def render_error(code:) | ||
if Rails.application.config.consider_all_requests_local | ||
raise | ||
else | ||
respond_to do |format| | ||
format.html { render "errors/#{code}", status: code } | ||
format.all { render nothing: true, status: code } | ||
end | ||
end | ||
end | ||
|
||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
- @title = "The page you were looking for doesn't exist (404)" | ||
|
||
= render 'errors/analytics_javascript', locals: { code: 404, message: 'not found'} | ||
|
||
.container | ||
.col-xs-12 | ||
.error-page.text-center | ||
h1 | ||
| Looking for something? | ||
h2 | ||
| <em>Sorry,</em> this page doesn't exist. | ||
p | ||
| Try our #{link_to "homepage", root_path} to see what's new and start customizing. | ||
p.thin-line--bottom.thin-line--alignCenter | ||
| Still can't find what you're looking for? #{link_to "E-mail us", 'mailto:team@fameandpartners.com'} at team@fameandpartners.com. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
- @title = "The change you wanted was rejected (422)" | ||
|
||
= render 'errors/analytics_javascript', locals: { code: 422, message: 'unprocessable entity'} | ||
|
||
.container | ||
.col-xs-12 | ||
.error-page.text-center | ||
h1 | ||
| The change you wanted was rejected. | ||
h2 | ||
| Maybe you tried to change something you didn't have access to. | ||
p | ||
| Try our #{link_to "homepage", root_path} to see what's new and start customizing. | ||
p.thin-line--bottom.thin-line--alignCenter | ||
| Still can't find what you're looking for? #{link_to "E-mail us", 'mailto:team@fameandpartners.com'} at team@fameandpartners.com. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
- code = local_assigns[:code] | ||
- message = local_assigns[:message] | ||
|
||
javascript: | ||
(function (i, s, o, g, r, a, m) { | ||
i['GoogleAnalyticsObject'] = r; | ||
i[r] = i[r] || function () { | ||
(i[r].q = i[r].q || []).push(arguments) | ||
}, i[r].l = 1 * new Date(); | ||
a = s.createElement(o), | ||
m = s.getElementsByTagName(o)[0]; | ||
a.async = 1; | ||
a.src = g; | ||
m.parentNode.insertBefore(a, m) | ||
})(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga'); | ||
ga('create', 'UA-41247818-1', 'auto'); | ||
ga('send', 'pageview'); | ||
ga('send', 'event', "#{code}", "#{message}"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.