Commit 81092c01984a481e312de10a28e3f1a6dda182a3

Authored by Dmitriy Zaporozhets
1 parent 7d279f93

Status codes for errors, New error pages

app/controllers/application_controller.rb
... ... @@ -9,7 +9,7 @@ class ApplicationController < ActionController::Base
9 9 end
10 10  
11 11 rescue_from ActiveRecord::RecordNotFound do |exception|
12   - render "errors/not_found", :layout => "error"
  12 + render "errors/not_found", :layout => "error", :status => 404
13 13 end
14 14  
15 15 layout :layout_by_resource
... ... @@ -58,15 +58,15 @@ class ApplicationController < ActionController::Base
58 58 end
59 59  
60 60 def access_denied!
61   - render "errors/access_denied", :layout => "error"
  61 + render "errors/access_denied", :layout => "error", :status => 404
62 62 end
63 63  
64 64 def not_found!
65   - render "errors/not_found", :layout => "error"
  65 + render "errors/not_found", :layout => "error", :status => 404
66 66 end
67 67  
68 68 def git_not_found!
69   - render "errors/git_not_found", :layout => "error"
  69 + render "errors/git_not_found", :layout => "error", :status => 404
70 70 end
71 71  
72 72 def method_missing(method_sym, *arguments, &block)
... ...
app/controllers/projects_controller.rb
... ... @@ -114,6 +114,7 @@ class ProjectsController < ApplicationController
114 114  
115 115 def project
116 116 @project ||= Project.find_by_code(params[:id])
  117 + @project || render_404
117 118 end
118 119  
119 120 def determine_layout
... ...
public/404.html
... ... @@ -2,22 +2,12 @@
2 2 <html>
3 3 <head>
4 4 <title>The page you were looking for doesn't exist (404)</title>
5   - <style type="text/css">
6   - body { background-color: #EAEAEA; color: #666; text-align: center; font-family: arial, sans-serif; }
7   - div.dialog {
8   - width: 600px;
9   - padding: 0 4em;
10   - margin: 4em auto 0 auto;
11   - }
12   - h1 { font-size: 48px; color: #444; line-height: 1.5em; }
13   - h2 { font-size: 24px; color: #666; line-height: 1.5em; }
14   - </style>
  5 + <link href="static.css" media="screen" rel="stylesheet" type="text/css" />
15 6 </head>
16 7  
17 8 <body>
18   - <!-- This file lives in public/404.html -->
19   - <div class="dialog">
20   - <h1>404</h1>
  9 + <h1>404</h1>
  10 + <div class="alert-message block-message error">
21 11 <h2>The page you were looking for doesn't exist.</h2>
22 12 <p>You may have mistyped the address or the page may have moved.</p>
23 13 </div>
... ...
public/422.html
... ... @@ -2,22 +2,13 @@
2 2 <html>
3 3 <head>
4 4 <title>The change you wanted was rejected (422)</title>
5   - <style type="text/css">
6   - body { background-color: #EAEAEA; color: #666; text-align: center; font-family: arial, sans-serif; }
7   - div.dialog {
8   - width: 600px;
9   - padding: 0 4em;
10   - margin: 4em auto 0 auto;
11   - }
12   - h1 { font-size: 48px; color: #444; line-height: 1.5em; }
13   - h2 { font-size: 24px; color: #666; line-height: 1.5em; }
14   - </style>
  5 + <link href="static.css" media="screen" rel="stylesheet" type="text/css" />
15 6 </head>
16 7  
17 8 <body>
18 9 <!-- This file lives in public/422.html -->
19   - <div class="dialog">
20   - <h1>422</h1>
  10 + <h1>422</h1>
  11 + <div class="alert-message block-message error">
21 12 <h2>The change you wanted was rejected.</h2>
22 13 <p>Maybe you tried to change something you didn't have access to.</p>
23 14 </div>
... ...
public/500.html
... ... @@ -2,22 +2,13 @@
2 2 <html>
3 3 <head>
4 4 <title>We're sorry, but something went wrong (500)</title>
5   - <style type="text/css">
6   - body { background-color: #EAEAEA; color: #666; text-align: center; font-family: arial, sans-serif; }
7   - div.dialog {
8   - width: 600px;
9   - padding: 0 4em;
10   - margin: 4em auto 0 auto;
11   - }
12   - h1 { font-size: 48px; color: #444; line-height: 1.5em; }
13   - h2 { font-size: 24px; color: #666; line-height: 1.5em; }
14   - </style>
  5 + <link href="static.css" media="screen" rel="stylesheet" type="text/css" />
15 6 </head>
16 7  
17 8 <body>
18 9 <!-- This file lives in public/500.html -->
19   - <div class="dialog">
20   - <h1>500</h1>
  10 + <h1>500</h1>
  11 + <div class="alert-message block-message error">
21 12 <h2>We're sorry, but something went wrong.</h2>
22 13 <p>We've been notified about this issue and we'll take a look at it shortly.</p>
23 14 </div>
... ...
public/static.css 0 → 100644
... ... @@ -0,0 +1,57 @@
  1 +body { color: #666; text-align: center; font-family: arial, sans-serif; margin:0; padding:0; }
  2 +h1 { font-size: 48px; color: #444; line-height: 1.5em; }
  3 +h2 { font-size: 24px; color: #666; line-height: 1.5em; }
  4 +
  5 +.alert-message {
  6 + position: relative;
  7 + padding: 7px 15px;
  8 + margin-bottom: 18px;
  9 + color: #404040;
  10 + background-color: #eedc94;
  11 + background-repeat: repeat-x;
  12 + background-image: -khtml-gradient(linear, left top, left bottom, from(#fceec1), to(#eedc94));
  13 + background-image: -moz-linear-gradient(top, #fceec1, #eedc94);
  14 + background-image: -ms-linear-gradient(top, #fceec1, #eedc94);
  15 + background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #fceec1), color-stop(100%, #eedc94));
  16 + background-image: -webkit-linear-gradient(top, #fceec1, #eedc94);
  17 + background-image: -o-linear-gradient(top, #fceec1, #eedc94);
  18 + background-image: linear-gradient(top, #fceec1, #eedc94);
  19 + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFFCEEC1', endColorstr='#FFEEDC94', GradientType=0);
  20 + text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
  21 + border-color: #eedc94 #eedc94 #e4c652;
  22 + border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) fadein(rgba(0, 0, 0, 0.1), 15%);
  23 + text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
  24 + border-width: 1px;
  25 + border-style: solid;
  26 + -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25);
  27 + -moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25);
  28 + box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25);
  29 +}
  30 +.alert-message .close {
  31 + margin-top: 1px;
  32 + *margin-top: 0;
  33 +}
  34 +.alert-message a {
  35 + font-weight: bold;
  36 + color: #404040;
  37 +}
  38 +.alert-message.danger p a, .alert-message.error p a, .alert-message.success p a, .alert-message.info p a {
  39 + color: #404040;
  40 +}
  41 +.alert-message h5 {
  42 + line-height: 18px;
  43 +}
  44 +.alert-message p {
  45 + margin-bottom: 0;
  46 +}
  47 +.alert-message div {
  48 + margin-top: 5px;
  49 + margin-bottom: 2px;
  50 + line-height: 28px;
  51 +}
  52 +
  53 +.alert-message.block-message.error {
  54 + background: #FDDFDE;
  55 + border-color: #FBC7C6;
  56 +}
  57 +
... ...