Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
iv
gitlab-ce
Commits
92fd3cce
Commit
92fd3cce
authored
May 01, 2015
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add helpers for header title and sidebar, and move setting those from controllers to layouts.
parent
ae09c2a6
Changes
33
Show whitespace changes
Inline
Side-by-side
Showing
33 changed files
with
112 additions
and
129 deletions
+112
-129
app/assets/javascripts/dispatcher.js.coffee
app/assets/javascripts/dispatcher.js.coffee
+0
-1
app/controllers/admin/application_controller.rb
app/controllers/admin/application_controller.rb
+1
-7
app/controllers/application_controller.rb
app/controllers/application_controller.rb
+1
-0
app/controllers/dashboard/application_controller.rb
app/controllers/dashboard/application_controller.rb
+1
-9
app/controllers/explore/application_controller.rb
app/controllers/explore/application_controller.rb
+1
-9
app/controllers/groups/application_controller.rb
app/controllers/groups/application_controller.rb
+1
-7
app/controllers/groups_controller.rb
app/controllers/groups_controller.rb
+5
-3
app/controllers/help_controller.rb
app/controllers/help_controller.rb
+1
-6
app/controllers/oauth/applications_controller.rb
app/controllers/oauth/applications_controller.rb
+4
-7
app/controllers/oauth/authorizations_controller.rb
app/controllers/oauth/authorizations_controller.rb
+2
-7
app/controllers/oauth/authorized_applications_controller.rb
app/controllers/oauth/authorized_applications_controller.rb
+3
-9
app/controllers/profiles/application_controller.rb
app/controllers/profiles/application_controller.rb
+1
-9
app/controllers/profiles/passwords_controller.rb
app/controllers/profiles/passwords_controller.rb
+5
-4
app/controllers/projects_controller.rb
app/controllers/projects_controller.rb
+0
-5
app/controllers/search_controller.rb
app/controllers/search_controller.rb
+1
-8
app/controllers/snippets_controller.rb
app/controllers/snippets_controller.rb
+1
-8
app/helpers/application_helper.rb
app/helpers/application_helper.rb
+0
-8
app/helpers/page_layout_helper.rb
app/helpers/page_layout_helper.rb
+26
-0
app/views/groups/new.html.haml
app/views/groups/new.html.haml
+2
-0
app/views/layouts/admin.html.haml
app/views/layouts/admin.html.haml
+5
-0
app/views/layouts/application.html.haml
app/views/layouts/application.html.haml
+4
-7
app/views/layouts/dashboard.html.haml
app/views/layouts/dashboard.html.haml
+5
-0
app/views/layouts/explore.html.haml
app/views/layouts/explore.html.haml
+5
-0
app/views/layouts/group.html.haml
app/views/layouts/group.html.haml
+5
-0
app/views/layouts/help.html.haml
app/views/layouts/help.html.haml
+4
-0
app/views/layouts/profile.html.haml
app/views/layouts/profile.html.haml
+5
-0
app/views/layouts/project.html.haml
app/views/layouts/project.html.haml
+7
-13
app/views/layouts/project_settings.html.haml
app/views/layouts/project_settings.html.haml
+3
-1
app/views/layouts/search.html.haml
app/views/layouts/search.html.haml
+4
-0
app/views/layouts/snippets.html.haml
app/views/layouts/snippets.html.haml
+5
-0
app/views/profiles/passwords/new.html.haml
app/views/profiles/passwords/new.html.haml
+2
-0
app/views/projects/edit.html.haml
app/views/projects/edit.html.haml
+0
-1
app/views/projects/new.html.haml
app/views/projects/new.html.haml
+2
-0
No files found.
app/assets/javascripts/dispatcher.js.coffee
View file @
92fd3cce
...
@@ -8,7 +8,6 @@ class Dispatcher
...
@@ -8,7 +8,6 @@ class Dispatcher
initPageScripts
:
->
initPageScripts
:
->
page
=
$
(
'body'
).
attr
(
'data-page'
)
page
=
$
(
'body'
).
attr
(
'data-page'
)
project_id
=
$
(
'body'
).
attr
(
'data-project-id'
)
unless
page
unless
page
return
false
return
false
...
...
app/controllers/admin/application_controller.rb
View file @
92fd3cce
...
@@ -3,15 +3,9 @@
...
@@ -3,15 +3,9 @@
# Automatically sets the layout and ensures an administrator is logged in
# Automatically sets the layout and ensures an administrator is logged in
class
Admin::ApplicationController
<
ApplicationController
class
Admin::ApplicationController
<
ApplicationController
before_action
:authenticate_admin!
before_action
:authenticate_admin!
before_action
:set_title
layout
'admin'
def
authenticate_admin!
def
authenticate_admin!
return
render_404
unless
current_user
.
is_admin?
return
render_404
unless
current_user
.
is_admin?
end
end
def
set_title
@title
=
"Admin area"
@title_url
=
admin_root_path
@sidebar
=
"admin"
end
end
end
app/controllers/application_controller.rb
View file @
92fd3cce
...
@@ -3,6 +3,7 @@ require 'gon'
...
@@ -3,6 +3,7 @@ require 'gon'
class
ApplicationController
<
ActionController
::
Base
class
ApplicationController
<
ActionController
::
Base
include
Gitlab
::
CurrentSettings
include
Gitlab
::
CurrentSettings
include
GitlabRoutingHelper
include
GitlabRoutingHelper
include
PageLayoutHelper
PER_PAGE
=
20
PER_PAGE
=
20
...
...
app/controllers/dashboard/application_controller.rb
View file @
92fd3cce
class
Dashboard::ApplicationController
<
ApplicationController
class
Dashboard::ApplicationController
<
ApplicationController
before_action
:set_title
layout
'dashboard'
private
def
set_title
@title
=
"Dashboard"
@title_url
=
root_path
@sidebar
=
"dashboard"
end
end
end
app/controllers/explore/application_controller.rb
View file @
92fd3cce
class
Explore::ApplicationController
<
ApplicationController
class
Explore::ApplicationController
<
ApplicationController
before_action
:set_title
layout
'explore'
private
def
set_title
@title
=
"Explore GitLab"
@title_url
=
explore_root_path
@sidebar
=
"explore"
end
end
end
app/controllers/groups/application_controller.rb
View file @
92fd3cce
class
Groups::ApplicationController
<
ApplicationController
class
Groups::ApplicationController
<
ApplicationController
before_action
:set_title
layout
'group'
private
private
...
@@ -18,10 +18,4 @@ class Groups::ApplicationController < ApplicationController
...
@@ -18,10 +18,4 @@ class Groups::ApplicationController < ApplicationController
return
render_404
return
render_404
end
end
end
end
def
set_title
@title
=
group
.
name
@title_url
=
group_path
(
group
)
@sidebar
=
"group"
end
end
end
app/controllers/groups_controller.rb
View file @
92fd3cce
...
@@ -12,6 +12,8 @@ class GroupsController < Groups::ApplicationController
...
@@ -12,6 +12,8 @@ class GroupsController < Groups::ApplicationController
before_action
:load_projects
,
except:
[
:new
,
:create
,
:projects
,
:edit
,
:update
]
before_action
:load_projects
,
except:
[
:new
,
:create
,
:projects
,
:edit
,
:update
]
before_action
:event_filter
,
only: :show
before_action
:event_filter
,
only: :show
layout
:determine_layout
def
new
def
new
@group
=
Group
.
new
@group
=
Group
.
new
end
end
...
@@ -116,11 +118,11 @@ class GroupsController < Groups::ApplicationController
...
@@ -116,11 +118,11 @@ class GroupsController < Groups::ApplicationController
end
end
end
end
def
set_title
def
determine_layout
if
[
:new
,
:create
].
include?
(
action_name
.
to_sym
)
if
[
:new
,
:create
].
include?
(
action_name
.
to_sym
)
@title
=
'New Group
'
'application
'
else
else
super
'group'
end
end
end
end
...
...
app/controllers/help_controller.rb
View file @
92fd3cce
class
HelpController
<
ApplicationController
class
HelpController
<
ApplicationController
before_action
:set_title
layout
'help'
def
index
def
index
end
end
...
@@ -46,11 +46,6 @@ class HelpController < ApplicationController
...
@@ -46,11 +46,6 @@ class HelpController < ApplicationController
private
private
def
set_title
@title
=
"Help"
@title_url
=
help_path
end
def
path_params
def
path_params
params
.
require
(
:category
)
params
.
require
(
:category
)
params
.
require
(
:file
)
params
.
require
(
:file
)
...
...
app/controllers/oauth/applications_controller.rb
View file @
92fd3cce
class
Oauth::ApplicationsController
<
Doorkeeper
::
ApplicationsController
class
Oauth::ApplicationsController
<
Doorkeeper
::
ApplicationsController
include
PageLayoutHelper
before_action
:authenticate_user!
before_action
:authenticate_user!
before_action
:set_title
layout
'profile'
def
index
def
index
head
:forbidden
and
return
head
:forbidden
and
return
...
@@ -36,10 +39,4 @@ class Oauth::ApplicationsController < Doorkeeper::ApplicationsController
...
@@ -36,10 +39,4 @@ class Oauth::ApplicationsController < Doorkeeper::ApplicationsController
rescue_from
ActiveRecord
::
RecordNotFound
do
|
exception
|
rescue_from
ActiveRecord
::
RecordNotFound
do
|
exception
|
render
"errors/not_found"
,
layout:
"errors"
,
status:
404
render
"errors/not_found"
,
layout:
"errors"
,
status:
404
end
end
def
set_title
@title
=
"Profile"
@title_url
=
profile_path
@sidebar
=
"profile"
end
end
end
app/controllers/oauth/authorizations_controller.rb
View file @
92fd3cce
class
Oauth::AuthorizationsController
<
Doorkeeper
::
AuthorizationsController
class
Oauth::AuthorizationsController
<
Doorkeeper
::
AuthorizationsController
before_action
:authenticate_resource_owner!
before_action
:authenticate_resource_owner!
before_action
:set_title
layout
'profile'
def
new
def
new
if
pre_auth
.
authorizable?
if
pre_auth
.
authorizable?
...
@@ -54,10 +55,4 @@ class Oauth::AuthorizationsController < Doorkeeper::AuthorizationsController
...
@@ -54,10 +55,4 @@ class Oauth::AuthorizationsController < Doorkeeper::AuthorizationsController
def
strategy
def
strategy
@strategy
||=
server
.
authorization_request
(
pre_auth
.
response_type
)
@strategy
||=
server
.
authorization_request
(
pre_auth
.
response_type
)
end
end
def
set_title
@title
=
"Profile"
@title_url
=
profile_path
@sidebar
=
"profile"
end
end
end
app/controllers/oauth/authorized_applications_controller.rb
View file @
92fd3cce
class
Oauth::AuthorizedApplicationsController
<
Doorkeeper
::
AuthorizedApplicationsController
class
Oauth::AuthorizedApplicationsController
<
Doorkeeper
::
AuthorizedApplicationsController
before_action
:set_title
include
PageLayoutHelper
layout
'profile'
def
destroy
def
destroy
Doorkeeper
::
AccessToken
.
revoke_all_for
(
params
[
:id
],
current_resource_owner
)
Doorkeeper
::
AccessToken
.
revoke_all_for
(
params
[
:id
],
current_resource_owner
)
redirect_to
applications_profile_url
,
notice:
I18n
.
t
(
:notice
,
scope:
[
:doorkeeper
,
:flash
,
:authorized_applications
,
:destroy
])
redirect_to
applications_profile_url
,
notice:
I18n
.
t
(
:notice
,
scope:
[
:doorkeeper
,
:flash
,
:authorized_applications
,
:destroy
])
end
end
private
def
set_title
@title
=
"Profile"
@title_url
=
profile_path
@sidebar
=
"profile"
end
end
end
app/controllers/profiles/application_controller.rb
View file @
92fd3cce
class
Profiles::ApplicationController
<
ApplicationController
class
Profiles::ApplicationController
<
ApplicationController
before_action
:set_title
layout
'profile'
private
def
set_title
@title
=
"Profile"
@title_url
=
profile_path
@sidebar
=
"profile"
end
end
end
app/controllers/profiles/passwords_controller.rb
View file @
92fd3cce
...
@@ -2,9 +2,10 @@ class Profiles::PasswordsController < Profiles::ApplicationController
...
@@ -2,9 +2,10 @@ class Profiles::PasswordsController < Profiles::ApplicationController
skip_before_action
:check_password_expiration
,
only:
[
:new
,
:create
]
skip_before_action
:check_password_expiration
,
only:
[
:new
,
:create
]
before_action
:set_user
before_action
:set_user
before_action
:set_title
before_action
:authorize_change_password!
before_action
:authorize_change_password!
layout
:determine_layout
def
new
def
new
end
end
...
@@ -64,11 +65,11 @@ class Profiles::PasswordsController < Profiles::ApplicationController
...
@@ -64,11 +65,11 @@ class Profiles::PasswordsController < Profiles::ApplicationController
@user
=
current_user
@user
=
current_user
end
end
def
set_title
def
determine_layout
if
[
:new
,
:create
].
include?
(
action_name
.
to_sym
)
if
[
:new
,
:create
].
include?
(
action_name
.
to_sym
)
@title
=
"New password"
'application'
else
else
super
'profile'
end
end
end
end
...
...
app/controllers/projects_controller.rb
View file @
92fd3cce
...
@@ -6,7 +6,6 @@ class ProjectsController < ApplicationController
...
@@ -6,7 +6,6 @@ class ProjectsController < ApplicationController
# Authorize
# Authorize
before_action
:authorize_admin_project!
,
only:
[
:edit
,
:update
,
:destroy
,
:transfer
,
:archive
,
:unarchive
]
before_action
:authorize_admin_project!
,
only:
[
:edit
,
:update
,
:destroy
,
:transfer
,
:archive
,
:unarchive
]
before_action
:set_title
,
only:
[
:new
,
:create
]
before_action
:event_filter
,
only: :show
before_action
:event_filter
,
only: :show
layout
:determine_layout
layout
:determine_layout
...
@@ -160,10 +159,6 @@ class ProjectsController < ApplicationController
...
@@ -160,10 +159,6 @@ class ProjectsController < ApplicationController
private
private
def
set_title
@title
=
'New Project'
end
def
determine_layout
def
determine_layout
if
[
:new
,
:create
].
include?
(
action_name
.
to_sym
)
if
[
:new
,
:create
].
include?
(
action_name
.
to_sym
)
'application'
'application'
...
...
app/controllers/search_controller.rb
View file @
92fd3cce
class
SearchController
<
ApplicationController
class
SearchController
<
ApplicationController
include
SearchHelper
include
SearchHelper
before_action
:set_title
layout
'search'
def
show
def
show
return
if
params
[
:search
].
nil?
||
params
[
:search
].
blank?
return
if
params
[
:search
].
nil?
||
params
[
:search
].
blank?
...
@@ -57,11 +57,4 @@ class SearchController < ApplicationController
...
@@ -57,11 +57,4 @@ class SearchController < ApplicationController
render
json:
search_autocomplete_opts
(
term
).
to_json
render
json:
search_autocomplete_opts
(
term
).
to_json
end
end
private
def
set_title
@title
=
"Search"
@title_url
=
search_path
end
end
end
app/controllers/snippets_controller.rb
View file @
92fd3cce
...
@@ -7,10 +7,9 @@ class SnippetsController < ApplicationController
...
@@ -7,10 +7,9 @@ class SnippetsController < ApplicationController
# Allow destroy snippet
# Allow destroy snippet
before_action
:authorize_admin_snippet!
,
only:
[
:destroy
]
before_action
:authorize_admin_snippet!
,
only:
[
:destroy
]
before_action
:set_title
skip_before_action
:authenticate_user!
,
only:
[
:index
,
:user_index
,
:show
,
:raw
]
skip_before_action
:authenticate_user!
,
only:
[
:index
,
:user_index
,
:show
,
:raw
]
layout
'snippets'
respond_to
:html
respond_to
:html
def
index
def
index
...
@@ -96,12 +95,6 @@ class SnippetsController < ApplicationController
...
@@ -96,12 +95,6 @@ class SnippetsController < ApplicationController
return
render_404
unless
can?
(
current_user
,
:admin_personal_snippet
,
@snippet
)
return
render_404
unless
can?
(
current_user
,
:admin_personal_snippet
,
@snippet
)
end
end
def
set_title
@title
=
'Snippets'
@title_url
=
snippets_path
@sidebar
=
"snippets"
end
def
snippet_params
def
snippet_params
params
.
require
(
:personal_snippet
).
permit
(
:title
,
:content
,
:file_name
,
:private
,
:visibility_level
)
params
.
require
(
:personal_snippet
).
permit
(
:title
,
:content
,
:file_name
,
:private
,
:visibility_level
)
end
end
...
...
app/helpers/application_helper.rb
View file @
92fd3cce
...
@@ -332,12 +332,4 @@ module ApplicationHelper
...
@@ -332,12 +332,4 @@ module ApplicationHelper
end
end
"
#{
entity_title
}#{
count
}
"
"
#{
entity_title
}#{
count
}
"
end
end
def
page_title
(
*
titles
)
@page_title
||=
[]
@page_title
.
push
(
*
titles
.
compact
)
if
titles
.
any?
@page_title
.
join
(
" | "
)
end
end
end
app/helpers/page_layout_helper.rb
0 → 100644
View file @
92fd3cce
module
PageLayoutHelper
def
page_title
(
*
titles
)
@page_title
||=
[]
@page_title
.
push
(
*
titles
.
compact
)
if
titles
.
any?
@page_title
.
join
(
" | "
)
end
def
header_title
(
title
=
nil
,
title_url
=
nil
)
if
title
@header_title
=
title
@header_title_url
=
title_url
else
@header_title_url
?
link_to
(
@header_title
,
@header_title_url
)
:
@header_title
end
end
def
sidebar
(
name
=
nil
)
if
name
@sidebar
=
name
else
@sidebar
end
end
end
app/views/groups/new.html.haml
View file @
92fd3cce
-
page_title
'New Group'
-
header_title
'New Group'
=
form_for
@group
,
html:
{
class:
'group-form form-horizontal'
}
do
|
f
|
=
form_for
@group
,
html:
{
class:
'group-form form-horizontal'
}
do
|
f
|
-
if
@group
.
errors
.
any?
-
if
@group
.
errors
.
any?
.alert.alert-danger
.alert.alert-danger
...
...
app/views/layouts/admin.html.haml
0 → 100644
View file @
92fd3cce
-
page_title
"Admin area"
-
header_title
"Admin area"
,
admin_root_path
-
sidebar
"admin"
=
render
template:
"layouts/application"
app/views/layouts/application.html.haml
View file @
92fd3cce
-
page_title
@title
!!! 5
!!! 5
%html
{
lang:
"en"
}
%html
{
lang:
"en"
}
=
render
"layouts/head"
=
render
"layouts/head"
%body
{
class:
"#{app_theme} application"
,
:'data-page'
=>
body_data_page
}
%body
{
class:
"#{app_theme}"
,
:'data-page'
=>
body_data_page
}
-
title
=
defined?
(
@title_url
)
?
link_to
(
@title
,
@title_url
)
:
@title
-
if
current_user
-
if
current_user
=
render
"layouts/head_panel"
,
title:
title
=
render
"layouts/head_panel"
,
title:
header_
title
-
else
-
else
=
render
"layouts/public_head_panel"
,
title:
title
=
render
"layouts/public_head_panel"
,
title:
header_
title
=
render
'layouts/page'
,
sidebar:
@
sidebar
=
render
'layouts/page'
,
sidebar:
sidebar
app/views/layouts/dashboard.html.haml
0 → 100644
View file @
92fd3cce
-
page_title
"Dashboard"
-
header_title
"Dashboard"
,
root_path
-
sidebar
"dashboard"
=
render
template:
"layouts/application"
app/views/layouts/explore.html.haml
0 → 100644
View file @
92fd3cce
-
page_title
"Explore"
-
header_title
"Explore GitLab"
,
explore_root_path
-
sidebar
"explore"
=
render
template:
"layouts/application"
app/views/layouts/group.html.haml
0 → 100644
View file @
92fd3cce
-
page_title
@group
.
name
-
header_title
@group
.
name
,
group_path
(
@group
)
-
sidebar
"group"
=
render
template:
"layouts/application"
app/views/layouts/help.html.haml
0 → 100644
View file @
92fd3cce
-
page_title
"Help"
-
header_title
"Help"
,
help_path
=
render
template:
"layouts/application"
app/views/layouts/profile.html.haml
0 → 100644
View file @
92fd3cce
-
page_title
"Profile"
-
header_title
"Profile"
,
profile_path
-
sidebar
"profile"
=
render
template:
"layouts/application"
app/views/layouts/project.html.haml
View file @
92fd3cce
-
page_title
@project
.
name_with_namespace
-
page_title
@project
.
name_with_namespace
!!! 5
-
header_title
project_title
(
@project
)
%html
{
lang:
"en"
}
-
sidebar
"project"
unless
sidebar
=
render
"layouts/head"
%body
{
class:
"#{app_theme} project"
,
:'data-page'
=>
body_data_page
,
:'data-project-id'
=>
@project
.
id
}
-
title
=
project_title
(
@project
)
-
if
current_user
-
content_for
:embedded_scripts
do
=
render
"layouts/head_panel"
,
title:
project_title
(
@project
)
=
render
"layouts/init_auto_complete"
if
current_user
=
render
"layouts/init_auto_complete"
-
else
=
render
"layouts/public_head_panel"
,
title:
project_title
(
@project
)
=
render
'layouts/page'
,
sidebar:
@sidebar
||
'project'
=
render
template:
"layouts/application"
app/views/layouts/project_settings.html.haml
View file @
92fd3cce
-
@sidebar
=
"project_settings"
-
page_title
"Settings"
-
sidebar
"project_settings"
=
render
template:
"layouts/project"
=
render
template:
"layouts/project"
app/views/layouts/search.html.haml
0 → 100644
View file @
92fd3cce
-
page_title
"Search"
-
header_title
"Search"
,
search_path
=
render
template:
"layouts/application"
app/views/layouts/snippets.html.haml
0 → 100644
View file @
92fd3cce
-
page_title
'Snippets'
-
header_title
'Snippets'
,
snippets_path
-
sidebar
"snippets"
=
render
template:
"layouts/application"
app/views/profiles/passwords/new.html.haml
View file @
92fd3cce
-
page_title
"New Password"
-
header_title
"New Password"
%h3
.page-title
Setup new password
%h3
.page-title
Setup new password
%hr
%hr
=
form_for
@user
,
url:
profile_password_path
,
method: :post
,
html:
{
class:
'form-horizontal '
}
do
|
f
|
=
form_for
@user
,
url:
profile_password_path
,
method: :post
,
html:
{
class:
'form-horizontal '
}
do
|
f
|
...
...
app/views/projects/edit.html.haml
View file @
92fd3cce
-
page_title
"Settings"
.project-edit-container
.project-edit-container
.project-edit-errors
.project-edit-errors
.project-edit-content
.project-edit-content
...
...
app/views/projects/new.html.haml
View file @
92fd3cce
-
page_title
'New Project'
-
header_title
'New Project'
.project-edit-container
.project-edit-container
.project-edit-errors
.project-edit-errors
=
render
'projects/errors'
=
render
'projects/errors'
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment