-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature] [WEBSITE-1239] 404 page redesign #2253
Merged
Merged
Changes from 16 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
a753792
404 page redesign
albertorenteria c302215
Fix css format
albertorenteria 5276732
Fix link destination
albertorenteria 11e1ee2
Remove old 404 file
albertorenteria c6e4587
Add new controller and helper
albertorenteria 6488abf
Add new 404 template
albertorenteria 47fc5cf
Add new route to the 404 page
albertorenteria e1bcb68
Tell rails to use tempaltes
albertorenteria 6090944
Error pages sass
albertorenteria 9bb059c
Catch errors with custom error pages yielded w/ application layout
sfate 0e6dbf8
Optimize calls + raise exception for development mode
sfate 4d06368
update styling and put content inside .container
d5f7492
Return back static 500 page
sfate 89c8e57
Make rails app available to catch RoutingError (raised by ActionDispa…
sfate bf0a952
Fix not found routes spec
sfate ab239d5
Fix unmactched routes catch
sfate 62843b2
Fix specs
sfate File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we're on Rails 3, do you think it would be possible replacing those
ActiveRecord/ActionController
exceptions to something like this: https://mattbrictson.com/dynamic-rails-error-pages ?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tiagoamaro
I don't like this behavior (from the article) by this points:
ActiveRecord::NotFound
exception and it showed up an a standard rails error page (instead of 404's page from controller).Why I'd prefer solution with catching exceptions in concern:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. Continue and will check it back when the 500 HTML is restored.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tiagoamaro returned back 500 static page: 4930a91
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sfate already deploying your changes to staging. Nice timing.