custom error pages (404 for the backend section + 500 for the whole application) + clean up

This commit is contained in:
dinedine 2010-07-29 12:46:13 +02:00
parent 37ec70687b
commit e74fa1de56
28 changed files with 308 additions and 358 deletions

View File

@ -1,7 +1,7 @@
module Admin
class CrossDomainSessionsController < BaseController
layout 'admin/login'
layout 'admin/box'
skip_before_filter :verify_authenticity_token
@ -26,8 +26,7 @@ module Admin
sign_in(account)
redirect_to admin_pages_path
else
flash[:alert] = t('flash.admin.cross_domain_sessions.create.alert')
redirect_to new_admin_session_path
redirect_to new_admin_session_path, :alert => t('flash.admin.cross_domain_sessions.create.alert')
end
end

View File

@ -3,7 +3,7 @@ module Admin
include Locomotive::Routing::SiteDispatcher
layout 'admin/login'
layout 'admin/box'
before_filter :require_site

View File

@ -3,7 +3,7 @@ module Admin
include Locomotive::Routing::SiteDispatcher
layout 'admin/login'
layout 'admin/box'
before_filter :require_site

View File

@ -1,3 +1,11 @@
class ApplicationController < ActionController::Base
protect_from_forgery
rescue_from Exception, :with => :render_error
protected
def render_error
render :template => "/admin/errors/500", :layout => 'admin/box', :status => 500
end
end

View File

@ -14,7 +14,7 @@ module Admin::AssetsHelper
def image_picker_include_tags
html = javascript_include_tag 'admin/plugins/json2', 'admin/plugins/scrollTo', 'admin/plugins/codemirror/codemirror', 'admin/plugins/fancybox', 'admin/plugins/plupload/plupload.full', 'admin/plugins/imagepicker'
html += stylesheet_link_tag 'admin/plugins/fancybox', 'admin/box'
html += stylesheet_link_tag 'admin/plugins/fancybox', 'admin/fancybox_changes'
html
end

View File

@ -0,0 +1,7 @@
- title t('.title')
.inner
%p.notice= t('.notice')
%p.link.tright
= link_to preserve(t('.link')), admin_root_url

View File

@ -0,0 +1,7 @@
- title t('.title')
.inner
%p.notice= t('.notice')
%p.link.tright
= link_to preserve(t('.link')), admin_root_url

View File

@ -6,7 +6,7 @@
= javascript_include_tag 'admin/jquery'
= stylesheet_link_tag 'admin/blueprint/screen', 'admin/login', :media => 'screen', :cache => Rails.env.production? && !Locomotive.config.heroku
= stylesheet_link_tag 'admin/blueprint/screen', 'admin/box', :media => 'screen', :cache => Rails.env.production? && !Locomotive.config.heroku
/ [if IE]
= stylesheet_link_tag('admin/blueprint/ie', :media => 'screen')

View File

@ -10,7 +10,7 @@ Locomotive::Application.configure do
config.whiny_nils = true
# Show full error reports and disable caching
config.consider_all_requests_local = true
config.consider_all_requests_local = false
config.action_view.debug_rjs = true
config.action_controller.perform_caching = false

View File

@ -32,6 +32,16 @@ en:
create: Create
update: Update
errors:
"500":
title: Application Error
notice: "Sorry, "
link: "&rarr; Back to the application"
"404":
title: Page not found
notice: "The page you requested does not exist."
link: "&rarr; Back to the application"
custom_fields:
edit:
title: Editing custom field

View File

@ -1,27 +1,15 @@
fr:
admin:
sessions:
new:
title: Connexion
link: "J'ai oublié mon mot de passe"
email: "Email"
password: "Mot de passe"
passwords:
new:
title: Mot de passe oublié
link: "&rarr; Retour page de connexion"
email: "Votre email"
edit:
title: Changer mon mot de passe
link: "&rarr; Retour page de connexion"
errors:
"500":
title: Erreur applicative
notice: "Oups, nous sommes désolés pour le problème rencontré."
link: "&rarr; Retour application"
"404":
title: Page non trouvée
notice: "La page que vous avez demandée n'existe pas."
link: "&rarr; Retour application"
buttons:
login: Se connecter
send_password: Envoyer
change_password: Changer
fr:
admin:
buttons:
login: Se connecter
send_password: Envoyer

View File

@ -25,7 +25,7 @@ fr:
less_than_or_equal_to: "doit être inférieur ou égal à %{count}"
odd: "doit être impair"
even: "doit être pair"
domain_taken: "%{value} a été déjà pris"
invalid_domain: "%{value} n'est pas valide"
missing_content_for_layout: "doit contenir le tag liquid 'content_for_layout'"
@ -34,7 +34,7 @@ fr:
extname_changed: "Nouveau fichier n'a pas l'extension original"
array_too_short: "est trop petit (le nombre minimum d'éléments est %{count})"
liquid_syntax_error: "Erreur de syntaxe dans les sections de page, veuillez vérifier la syntaxe"
attributes:
defaults:
pages:
@ -48,7 +48,7 @@ fr:
body: "Le contenu va ici"
page_parts:
name: "Corps"
activemodel:
attributes:
page:
@ -56,6 +56,7 @@ fr:
layout_id: Gabarit
parent: Parent
slug: Raccourci
templatized: Templatisée
published: Publiée
cache_strategy: Cache
content_type:
@ -92,12 +93,12 @@ fr:
domain_name: Domaine
subdomain: Sous-domaine
restricted_access: Activer ?
access_login: Identifiant
access_login: Identifiant
access_password: "Mot de passe"
pagination:
previous: "&laquo; Précédent"
next: "Suivant &raquo;"
next: "Suivant &raquo;"
date:
formats:
default: "%d/%m/%Y"
@ -183,7 +184,7 @@ fr:
human:
format:
precision: 2
storage_units:
storage_units:
format: '%n %u'
units:
byte: 'Octet'

View File

@ -1,11 +1,6 @@
BOARD:
- refactor slugify method (use parameterize + create a module)
- site selector (cross domain authentication)
x code
- tests (rspec + cucumber)
- nice 404 page => if logged in, link to create the page
- nice error page
BACKLOG:
@ -31,6 +26,7 @@ NICE TO HAVE:
- page redirection (option)
- automatic update !
- import / export site
- page not found (front) => if logged in, link to create the page
DONE:
@ -69,4 +65,7 @@ x page templatized (bound to a model)
x theme asset picker when editing layout / snippet
x templatized: do not display content with visible / active set to false
x theme assets: disable version if not image (handled by the new version of Carrierwave)
x rack app to map pretty asset url to S3 => shortcut urls instead
x rack app to map pretty asset url to S3 => shortcut urls instead
x site selector (cross domain authentication)
x nice error page
x nice 404 page (admin section)

View File

@ -8,13 +8,17 @@ module Locomotive
protected
def render_locomotive_page
@page = locomotive_page
if request.fullpath =~ /^\/admin\//
render :template => "/admin/errors/404", :layout => 'admin/box', :status => 404
else
@page = locomotive_page
redirect_to application_root_url and return if @page.nil?
redirect_to application_root_url and return if @page.nil?
output = @page.render(locomotive_context)
output = @page.render(locomotive_context)
prepare_and_set_response(output)
prepare_and_set_response(output)
end
end
def locomotive_page

View File

@ -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>

View File

@ -1,26 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>The change you wanted was rejected (422)</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/422.html -->
<div class="dialog">
<h1>The change you wanted was rejected.</h1>
<p>Maybe you tried to change something you didn't have access to.</p>
</div>
</body>
</html>

View File

@ -1,26 +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>
<p>We've been notified about this issue and we'll take a look at it shortly.</p>
</div>
</body>
</html>

View File

Before

Width:  |  Height:  |  Size: 878 B

After

Width:  |  Height:  |  Size: 878 B

View File

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

Before

Width:  |  Height:  |  Size: 168 B

After

Width:  |  Height:  |  Size: 168 B

View File

Before

Width:  |  Height:  |  Size: 504 B

After

Width:  |  Height:  |  Size: 504 B

View File

Before

Width:  |  Height:  |  Size: 146 KiB

After

Width:  |  Height:  |  Size: 146 KiB

View File

Before

Width:  |  Height:  |  Size: 984 B

After

Width:  |  Height:  |  Size: 984 B

View File

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

View File

@ -1,98 +1,153 @@
/* custom styles for fancybox */
body { background: #000 url(/images/admin/background/body.png) repeat 0 0; }
/* ___ common ___ */
.box-wrapper { display: none; }
#fancybox-inner h2 {
border-bottom:1px dotted #BBBBBD;
color:#1E1F26;
font-size:1.1em;
font-weight:bold;
padding-bottom:10px;
#wrapper {
background: transparent url(/images/admin/box/wrapper_bg.png) repeat-x 0 0;
min-height: 400px;
}
#fancybox-inner form.formtastic legend span {
background-image: url("/images/admin/form/header-popup.png");
width: 453px;
#light {
background: transparent url(/images/admin/box/light_bg.png) no-repeat center 0;
min-height: 400px;
padding-top: 100px;
}
#fancybox-inner form.formtastic ol {
background-image: url("/images/admin/form/footer-popup.png");
#panel {
background: transparent url(/images/admin/box/top_panel_bg.png) no-repeat center 0;
width: 356px;
height: 344px;
padding: 9px 0px 0 0px;
}
#fancybox-inner form.formtastic fieldset ol li label {
width: 20%;
}
#fancybox-inner form.formtastic fieldset ol li p.inline-hints {
margin-left: 30%;
}
#fancybox-inner form.formtastic .editable-list ol {
width: 433px;
}
#fancybox-inner form.formtastic .editable-list li {
width: 413px;
}
#fancybox-inner form.formtastic .editable-list li {
background-image: url("/images/admin/form/item-popup.png");
}
#fancybox-inner form.formtastic .editable-list li.template {
background-image: url("/images/admin/form/big_item-popup.png");
}
#fancybox-inner p { color:#8B8D9A; font-size:0.8em; }
/* ___ asset picker ___ */
div.asset-picker { width: 470px; position: relative; }
div.asset-picker .actions { position: absolute; right: 4px; top: 0px; }
div.asset-picker p.no-items { background-image: url("/images/admin/list/none-small.png"); }
div.asset-picker ul { overflow: auto; height: 471px; }
div.asset-picker ul li.new-asset { display: none; }
/* ___ custom fields ___ */
#edit-custom-field {
width: 473px;
}
#edit-custom-field-category {
width: 493px;
}
#edit-custom-field-category .inner {
padding: 10px 10px 61px 10px;
}
/* ___ form action ___ */
#fancybox-inner .popup-actions {
position: absolute;
left: 0px;
bottom: 0px;
height: 61px;
width: 100%;
background: #8b8d9a;
}
#fancybox-inner .popup-actions p {
padding: 15px;
#panel h1 {
height: 41px;
margin: 0px;
text-align: right;
padding: 20px 0px 0 0;
font-size: 1.8em;
color: white;
text-align: center;
text-shadow: 1px 1px 1px #000;
}
#panel .inner {
background: transparent url(/images/admin/box/content_panel_bg.png) repeat-y center 0;
padding: 5px 0px 20px 0px;
}
#panel fieldset {
border: 0px;
padding: 0px;
margin: 0px;
}
#panel fieldset ol {
width: 260px;
list-style: none;
padding: 0px;
margin: 0px auto 0 auto;
}
#panel fieldset ol li {
margin-top: 20px;
}
#panel fieldset ol li label {
display: block;
font-size: 1.2em;
color: #222;
}
#panel fieldset ol li input {
background: white url(/images/admin/box/input_bg.png) no-repeat 0 0;
width: 246px;
padding: 7px;
border: 0px;
font-size: 1.2em;
color: #222;
}
#panel fieldset ol li p.inline-errors {
padding: 3px 5px;
margin: 5px 0px;
background: #FFE5E5;
color: #CE2525;
}
#panel p.notice {
font-size: 1.2em;
color: #222;
margin: 15px 49px 0 49px;
text-align: center;
}
#panel p.link {
margin: 15px 0 0 49px;
}
#panel p.link a {
color: #1f82bc;
text-decoration: none;
}
#panel p.link a:hover {
text-decoration: underline;
}
#panel p.tright {
text-align: right;
margin-right: 20px;
}
#panel div.footer {
background: transparent url(/images/admin/box/bottom_panel_bg.png) no-repeat center 0;
text-align: right;
margin: 0px 0px 0 0px;
padding: 22px 0;
}
#panel div.footer .button {
display: inline-block;
background: transparent url(/images/admin/box/buttons/left_bg.png) no-repeat 0 0;
margin: 0 38px 0 0;
padding: 0px 0px 0px 2px;
font-size: 1.1em;
color: white;
cursor: pointer;
border: none;
height: 31px;
}
#panel div.footer .button span {
display: inline-block;
background: transparent url(/images/admin/box/buttons/right_bg.png) no-repeat right top;
position: relative;
top: -1px;
padding: 3px 9px 9px 4px;
line-height: 21px;
}
@media screen and (-webkit-min-device-pixel-ratio:0) {
#panel div.footer .button { padding-left: 5px; }
#panel div.footer .button span { top: 0px; padding-right: 10px; }
}
/* ___ Messages ___ */
div.application-message {
font-size: 1.2em;
font-weight: bold;
padding: 8px;
margin: 10px 20px 0 20px;
text-align: justify;
}
div#flash-alert {
background: #FFE5E5;
color: #CE2525;
}
div#flash-notice {
background: #c7ff99;
color: #58852b;
}
/*#fancybox-inner .actions a {
color: #fff;
text-decoration: none;
font-size: 0.8em;
position: relative;
top: 4px;
}*/

View File

@ -0,0 +1,98 @@
/* custom styles for fancybox */
/* ___ common ___ */
.box-wrapper { display: none; }
#fancybox-inner h2 {
border-bottom:1px dotted #BBBBBD;
color:#1E1F26;
font-size:1.1em;
font-weight:bold;
padding-bottom:10px;
}
#fancybox-inner form.formtastic legend span {
background-image: url("/images/admin/form/header-popup.png");
width: 453px;
}
#fancybox-inner form.formtastic ol {
background-image: url("/images/admin/form/footer-popup.png");
}
#fancybox-inner form.formtastic fieldset ol li label {
width: 20%;
}
#fancybox-inner form.formtastic fieldset ol li p.inline-hints {
margin-left: 30%;
}
#fancybox-inner form.formtastic .editable-list ol {
width: 433px;
}
#fancybox-inner form.formtastic .editable-list li {
width: 413px;
}
#fancybox-inner form.formtastic .editable-list li {
background-image: url("/images/admin/form/item-popup.png");
}
#fancybox-inner form.formtastic .editable-list li.template {
background-image: url("/images/admin/form/big_item-popup.png");
}
#fancybox-inner p { color:#8B8D9A; font-size:0.8em; }
/* ___ asset picker ___ */
div.asset-picker { width: 470px; position: relative; }
div.asset-picker .actions { position: absolute; right: 4px; top: 0px; }
div.asset-picker p.no-items { background-image: url("/images/admin/list/none-small.png"); }
div.asset-picker ul { overflow: auto; height: 471px; }
div.asset-picker ul li.new-asset { display: none; }
/* ___ custom fields ___ */
#edit-custom-field {
width: 473px;
}
#edit-custom-field-category {
width: 493px;
}
#edit-custom-field-category .inner {
padding: 10px 10px 61px 10px;
}
/* ___ form action ___ */
#fancybox-inner .popup-actions {
position: absolute;
left: 0px;
bottom: 0px;
height: 61px;
width: 100%;
background: #8b8d9a;
}
#fancybox-inner .popup-actions p {
padding: 15px;
margin: 0px;
text-align: right;
}
/*#fancybox-inner .actions a {
color: #fff;
text-decoration: none;
font-size: 0.8em;
position: relative;
top: 4px;
}*/

View File

@ -1,148 +0,0 @@
body { background: #000 url(/images/admin/background/body.png) repeat 0 0; }
#wrapper {
background: transparent url(/images/admin/login/wrapper_bg.png) repeat-x 0 0;
min-height: 400px;
}
#light {
background: transparent url(/images/admin/login/light_bg.png) no-repeat center 0;
min-height: 400px;
padding-top: 100px;
}
#panel {
background: transparent url(/images/admin/login/top_panel_bg.png) no-repeat center 0;
width: 356px;
height: 344px;
padding: 9px 0px 0 0px;
}
#panel h1 {
height: 41px;
margin: 0px;
padding: 20px 0px 0 0;
font-size: 1.8em;
color: white;
text-align: center;
text-shadow: 1px 1px 1px #000;
}
#panel .inner {
background: transparent url(/images/admin/login/content_panel_bg.png) repeat-y center 0;
padding: 5px 0px 20px 0px;
}
#panel fieldset {
border: 0px;
padding: 0px;
margin: 0px;
}
#panel fieldset ol {
width: 260px;
list-style: none;
padding: 0px;
margin: 0px auto 0 auto;
}
#panel fieldset ol li {
margin-top: 20px;
}
#panel fieldset ol li label {
display: block;
font-size: 1.2em;
color: #222;
}
#panel fieldset ol li input {
background: white url(/images/admin/login/input_bg.png) no-repeat 0 0;
width: 246px;
padding: 7px;
border: 0px;
font-size: 1.2em;
color: #222;
}
#panel fieldset ol li p.inline-errors {
padding: 3px 5px;
margin: 5px 0px;
background: #FFE5E5;
color: #CE2525;
}
#panel p.notice {
font-size: 1.2em;
color: #222;
margin: 15px 49px 0 49px;
text-align: center;
}
#panel p.link {
margin: 15px 0 0 49px;
}
#panel p.link a {
color: #1f82bc;
text-decoration: none;
}
#panel p.link a:hover {
text-decoration: underline;
}
#panel div.footer {
background: transparent url(/images/admin/login/bottom_panel_bg.png) no-repeat center 0;
text-align: right;
margin: 0px 0px 0 0px;
padding: 22px 0;
}
#panel div.footer .button {
display: inline-block;
background: transparent url(/images/admin/login/buttons/left_bg.png) no-repeat 0 0;
margin: 0 38px 0 0;
padding: 0px 0px 0px 2px;
font-size: 1.1em;
color: white;
cursor: pointer;
border: none;
height: 31px;
}
#panel div.footer .button span {
display: inline-block;
background: transparent url(/images/admin/login/buttons/right_bg.png) no-repeat right top;
position: relative;
top: -1px;
padding: 3px 9px 9px 4px;
line-height: 21px;
}
@media screen and (-webkit-min-device-pixel-ratio:0) {
#panel div.footer .button { padding-left: 5px; }
#panel div.footer .button span { top: 0px; padding-right: 10px; }
}
/* ___ Messages ___ */
div.application-message {
font-size: 1.2em;
font-weight: bold;
padding: 8px;
margin: 10px 20px 0 20px;
text-align: justify;
}
div#flash-alert {
background: #FFE5E5;
color: #CE2525;
}
div#flash-notice {
background: #c7ff99;
color: #58852b;
}