Commit bdf317addc2ae586c76f46ccb1aa8659513baf16

Authored by Cyril
1 parent 078a8f0e

layout selected by controller name

app/controllers/application_controller.rb
... ... @@ -11,19 +11,17 @@ class ApplicationController < ActionController::Base
11 11 helper_method :abilities, :can?
12 12  
13 13 rescue_from Gitlab::Gitolite::AccessDenied do |exception|
14   - render "errors/gitolite", layout: "error", status: 500
  14 + render "errors/gitolite", layout: "errors", status: 500
15 15 end
16 16  
17 17 rescue_from Encoding::CompatibilityError do |exception|
18   - render "errors/encoding", layout: "error", status: 500
  18 + render "errors/encoding", layout: "errors", status: 500
19 19 end
20 20  
21 21 rescue_from ActiveRecord::RecordNotFound do |exception|
22   - render "errors/not_found", layout: "error", status: 404
  22 + render "errors/not_found", layout: "errors", status: 404
23 23 end
24 24  
25   - layout :layout_by_resource
26   -
27 25 protected
28 26  
29 27 def check_token_auth
... ... @@ -51,14 +49,6 @@ class ApplicationController < ActionController::Base
51 49 end
52 50 end
53 51  
54   - def layout_by_resource
55   - if devise_controller?
56   - "devise_layout"
57   - else
58   - "application"
59   - end
60   - end
61   -
62 52 def set_current_user_for_mailer
63 53 MailerObserver.current_user = current_user
64 54 end
... ... @@ -93,15 +83,15 @@ class ApplicationController < ActionController::Base
93 83 end
94 84  
95 85 def access_denied!
96   - render "errors/access_denied", layout: "error", status: 404
  86 + render "errors/access_denied", layout: "errors", status: 404
97 87 end
98 88  
99 89 def not_found!
100   - render "errors/not_found", layout: "error", status: 404
  90 + render "errors/not_found", layout: "errors", status: 404
101 91 end
102 92  
103 93 def git_not_found!
104   - render "errors/git_not_found", layout: "error", status: 404
  94 + render "errors/git_not_found", layout: "errors", status: 404
105 95 end
106 96  
107 97 def method_missing(method_sym, *arguments, &block)
... ...
app/controllers/errors_controller.rb
1 1 class ErrorsController < ApplicationController
2   - layout "error"
3   -
4 2 def githost
5 3 render "errors/gitolite"
6 4 end
... ...
app/controllers/profile_controller.rb
1 1 class ProfileController < ApplicationController
2   - layout "profile"
3 2 before_filter :user
4 3  
5 4 def show
... ...
app/controllers/project_controller.rb
... ... @@ -2,15 +2,4 @@ class ProjectController &lt; ApplicationController
2 2 before_filter :project
3 3 # Authorize
4 4 before_filter :add_project_abilities
5   -
6   - layout :determine_layout
7   -
8   - protected
9   - def determine_layout
10   - if @project && !@project.new_record?
11   - 'project'
12   - else
13   - 'application'
14   - end
15   - end
16 5 end
... ...
app/controllers/projects_controller.rb
... ... @@ -8,6 +8,8 @@ class ProjectsController &lt; ProjectController
8 8 before_filter :authorize_admin_project!, only: [:edit, :update, :destroy]
9 9 before_filter :require_non_empty_project, only: [:blob, :tree, :graph]
10 10  
  11 + layout 'application', only: [:new, :create]
  12 +
11 13 def new
12 14 @project = Project.new
13 15 end
... ...
app/views/layouts/error.html.haml
... ... @@ -1,10 +0,0 @@
1   -!!! 5
2   -%html{ lang: "en"}
3   - = render "layouts/head"
4   - %body{class: "#{app_theme} application"}
5   - = render "layouts/flash"
6   - = render "layouts/head_panel", title: ""
7   - .container
8   - .content
9   - %center.padded.prepend-top-20
10   - = yield
app/views/layouts/errors.html.haml 0 → 100644
... ... @@ -0,0 +1,10 @@
  1 +!!! 5
  2 +%html{ lang: "en"}
  3 + = render "layouts/head"
  4 + %body{class: "#{app_theme} application"}
  5 + = render "layouts/flash"
  6 + = render "layouts/head_panel", title: ""
  7 + .container
  8 + .content
  9 + %center.padded.prepend-top-20
  10 + = yield
... ...
config/application.rb
... ... @@ -53,5 +53,9 @@ module Gitlab
53 53  
54 54 # Add fonts
55 55 config.assets.paths << "#{Rails.root}/app/assets/fonts"
  56 +
  57 + config.to_prepare do
  58 + Devise::SessionsController.layout 'devise_layout'
  59 + end
56 60 end
57 61 end
... ...