summaryrefslogtreecommitdiff
path: root/app/controllers
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2015-04-30 19:06:18 +0200
committerDouwe Maan <douwe@gitlab.com>2015-04-30 19:12:15 +0200
commit26ad250989d82b496b131811f8a0ddd7e662b650 (patch)
treea61059ff97f7d5bb1db163fa2dcb041065b092f2 /app/controllers
parentf2cf6d75ecc6082897543f976e8e4bee7ac24e90 (diff)
downloadgitlab-ce-26ad250989d82b496b131811f8a0ddd7e662b650.tar.gz
Add a page title to every page.
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/admin/application_controller.rb8
-rw-r--r--app/controllers/dashboard/application_controller.rb11
-rw-r--r--app/controllers/dashboard/groups_controller.rb2
-rw-r--r--app/controllers/dashboard/milestones_controller.rb2
-rw-r--r--app/controllers/dashboard/projects_controller.rb2
-rw-r--r--app/controllers/dashboard_controller.rb6
-rw-r--r--app/controllers/explore/application_controller.rb11
-rw-r--r--app/controllers/explore/groups_controller.rb4
-rw-r--r--app/controllers/explore/projects_controller.rb4
-rw-r--r--app/controllers/groups/application_controller.rb11
-rw-r--r--app/controllers/groups/avatars_controller.rb2
-rw-r--r--app/controllers/groups/milestones_controller.rb4
-rw-r--r--app/controllers/groups_controller.rb13
-rw-r--r--app/controllers/help_controller.rb8
-rw-r--r--app/controllers/invites_controller.rb2
-rw-r--r--app/controllers/oauth/applications_controller.rb8
-rw-r--r--app/controllers/oauth/authorizations_controller.rb8
-rw-r--r--app/controllers/oauth/authorized_applications_controller.rb10
-rw-r--r--app/controllers/profiles/accounts_controller.rb4
-rw-r--r--app/controllers/profiles/application_controller.rb11
-rw-r--r--app/controllers/profiles/avatars_controller.rb4
-rw-r--r--app/controllers/profiles/emails_controller.rb4
-rw-r--r--app/controllers/profiles/keys_controller.rb3
-rw-r--r--app/controllers/profiles/notifications_controller.rb4
-rw-r--r--app/controllers/profiles/passwords_controller.rb10
-rw-r--r--app/controllers/profiles_controller.rb4
-rw-r--r--app/controllers/projects/application_controller.rb10
-rw-r--r--app/controllers/projects/avatars_controller.rb2
-rw-r--r--app/controllers/projects/forks_controller.rb1
-rw-r--r--app/controllers/projects/uploads_controller.rb2
-rw-r--r--app/controllers/projects_controller.rb22
-rw-r--r--app/controllers/search_controller.rb9
-rw-r--r--app/controllers/snippets_controller.rb11
-rw-r--r--app/controllers/users_controller.rb9
34 files changed, 118 insertions, 108 deletions
diff --git a/app/controllers/admin/application_controller.rb b/app/controllers/admin/application_controller.rb
index fe5456f820c..cfbeb035c0e 100644
--- a/app/controllers/admin/application_controller.rb
+++ b/app/controllers/admin/application_controller.rb
@@ -2,10 +2,16 @@
#
# Automatically sets the layout and ensures an administrator is logged in
class Admin::ApplicationController < ApplicationController
- layout 'admin'
before_action :authenticate_admin!
+ before_action :set_title
def authenticate_admin!
return render_404 unless current_user.is_admin?
end
+
+ def set_title
+ @title = "Admin area"
+ @title_url = admin_root_path
+ @sidebar = "admin"
+ end
end
diff --git a/app/controllers/dashboard/application_controller.rb b/app/controllers/dashboard/application_controller.rb
new file mode 100644
index 00000000000..0a0af3d4ce2
--- /dev/null
+++ b/app/controllers/dashboard/application_controller.rb
@@ -0,0 +1,11 @@
+class Dashboard::ApplicationController < ApplicationController
+ before_action :set_title
+
+ private
+
+ def set_title
+ @title = "Dashboard"
+ @title_url = root_path
+ @sidebar = "dashboard"
+ end
+end
diff --git a/app/controllers/dashboard/groups_controller.rb b/app/controllers/dashboard/groups_controller.rb
index ed14f4e1f3b..3bc94ff2187 100644
--- a/app/controllers/dashboard/groups_controller.rb
+++ b/app/controllers/dashboard/groups_controller.rb
@@ -1,4 +1,4 @@
-class Dashboard::GroupsController < ApplicationController
+class Dashboard::GroupsController < Dashboard::ApplicationController
def index
@group_members = current_user.group_members.page(params[:page]).per(PER_PAGE)
end
diff --git a/app/controllers/dashboard/milestones_controller.rb b/app/controllers/dashboard/milestones_controller.rb
index 33227e7f1d8..53896d4f2c7 100644
--- a/app/controllers/dashboard/milestones_controller.rb
+++ b/app/controllers/dashboard/milestones_controller.rb
@@ -1,4 +1,4 @@
-class Dashboard::MilestonesController < ApplicationController
+class Dashboard::MilestonesController < Dashboard::ApplicationController
before_action :load_projects
def index
diff --git a/app/controllers/dashboard/projects_controller.rb b/app/controllers/dashboard/projects_controller.rb
index 426bc615415..da96171e885 100644
--- a/app/controllers/dashboard/projects_controller.rb
+++ b/app/controllers/dashboard/projects_controller.rb
@@ -1,4 +1,4 @@
-class Dashboard::ProjectsController < ApplicationController
+class Dashboard::ProjectsController < Dashboard::ApplicationController
before_action :event_filter
def starred
diff --git a/app/controllers/dashboard_controller.rb b/app/controllers/dashboard_controller.rb
index 40b5de1295a..17ddde68f93 100644
--- a/app/controllers/dashboard_controller.rb
+++ b/app/controllers/dashboard_controller.rb
@@ -1,8 +1,8 @@
-class DashboardController < ApplicationController
- respond_to :html
-
+class DashboardController < Dashboard::ApplicationController
before_action :load_projects, except: [:projects]
before_action :event_filter, only: :show
+
+ respond_to :html
def show
@projects = @projects.includes(:namespace)
diff --git a/app/controllers/explore/application_controller.rb b/app/controllers/explore/application_controller.rb
new file mode 100644
index 00000000000..8d94fd238a6
--- /dev/null
+++ b/app/controllers/explore/application_controller.rb
@@ -0,0 +1,11 @@
+class Explore::ApplicationController < ApplicationController
+ before_action :set_title
+
+ private
+
+ def set_title
+ @title = "Explore GitLab"
+ @title_url = explore_root_path
+ @sidebar = "explore"
+ end
+end
diff --git a/app/controllers/explore/groups_controller.rb b/app/controllers/explore/groups_controller.rb
index a7250b799f3..55cda0cff17 100644
--- a/app/controllers/explore/groups_controller.rb
+++ b/app/controllers/explore/groups_controller.rb
@@ -1,9 +1,7 @@
-class Explore::GroupsController < ApplicationController
+class Explore::GroupsController < Explore::ApplicationController
skip_before_action :authenticate_user!,
:reject_blocked, :set_current_user_for_observers
- layout "explore"
-
def index
@groups = GroupsFinder.new.execute(current_user)
@groups = @groups.search(params[:search]) if params[:search].present?
diff --git a/app/controllers/explore/projects_controller.rb b/app/controllers/explore/projects_controller.rb
index b1b0a2514dc..e9bcb44f6b3 100644
--- a/app/controllers/explore/projects_controller.rb
+++ b/app/controllers/explore/projects_controller.rb
@@ -1,9 +1,7 @@
-class Explore::ProjectsController < ApplicationController
+class Explore::ProjectsController < Explore::ApplicationController
skip_before_action :authenticate_user!,
:reject_blocked
- layout 'explore'
-
def index
@projects = ProjectsFinder.new.execute(current_user)
@tags = @projects.tags_on(:tags)
diff --git a/app/controllers/groups/application_controller.rb b/app/controllers/groups/application_controller.rb
index 469a6813ee2..e0fd4befae9 100644
--- a/app/controllers/groups/application_controller.rb
+++ b/app/controllers/groups/application_controller.rb
@@ -1,4 +1,5 @@
class Groups::ApplicationController < ApplicationController
+ before_action :set_title
private
@@ -18,11 +19,9 @@ class Groups::ApplicationController < ApplicationController
end
end
- def determine_layout
- if current_user
- 'group'
- else
- 'public_group'
- end
+ def set_title
+ @title = group.name
+ @title_url = group_path(group)
+ @sidebar = "group"
end
end
diff --git a/app/controllers/groups/avatars_controller.rb b/app/controllers/groups/avatars_controller.rb
index 38071410f40..6aa64222f77 100644
--- a/app/controllers/groups/avatars_controller.rb
+++ b/app/controllers/groups/avatars_controller.rb
@@ -1,6 +1,4 @@
class Groups::AvatarsController < ApplicationController
- layout "profile"
-
def destroy
@group = Group.find_by(path: params[:group_id])
@group.remove_avatar!
diff --git a/app/controllers/groups/milestones_controller.rb b/app/controllers/groups/milestones_controller.rb
index 41564b04a92..669f7f3126d 100644
--- a/app/controllers/groups/milestones_controller.rb
+++ b/app/controllers/groups/milestones_controller.rb
@@ -1,6 +1,4 @@
-class Groups::MilestonesController < ApplicationController
- layout 'group'
-
+class Groups::MilestonesController < Groups::ApplicationController
before_action :authorize_group_milestone!, only: :update
def index
diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb
index 294af0b1704..66e92abff8d 100644
--- a/app/controllers/groups_controller.rb
+++ b/app/controllers/groups_controller.rb
@@ -11,9 +11,6 @@ class GroupsController < Groups::ApplicationController
# Load group projects
before_action :load_projects, except: [:new, :create, :projects, :edit, :update]
before_action :event_filter, only: :show
- before_action :set_title, only: [:new, :create]
-
- layout :determine_layout
def new
@group = Group.new
@@ -120,16 +117,10 @@ class GroupsController < Groups::ApplicationController
end
def set_title
- @title = 'New Group'
- end
-
- def determine_layout
if [:new, :create].include?(action_name.to_sym)
- 'navless'
- elsif current_user
- 'group'
+ @title = 'New Group'
else
- 'public_group'
+ super
end
end
diff --git a/app/controllers/help_controller.rb b/app/controllers/help_controller.rb
index 35ece5b270b..b405cc7e689 100644
--- a/app/controllers/help_controller.rb
+++ b/app/controllers/help_controller.rb
@@ -3,12 +3,12 @@ class HelpController < ApplicationController
end
def show
- category = clean_path_info(path_params[:category])
- file = path_params[:file]
+ @category = clean_path_info(path_params[:category])
+ @file = path_params[:file]
respond_to do |format|
format.any(:markdown, :md, :html) do
- path = Rails.root.join('doc', category, "#{file}.md")
+ path = Rails.root.join('doc', @category, "#{@file}.md")
if File.exist?(path)
@markdown = File.read(path)
@@ -22,7 +22,7 @@ class HelpController < ApplicationController
# Allow access to images in the doc folder
format.any(:png, :gif, :jpeg) do
- path = Rails.root.join('doc', category, "#{file}.#{params[:format]}")
+ path = Rails.root.join('doc', @category, "#{@file}.#{params[:format]}")
if File.exist?(path)
send_file(path, disposition: 'inline')
diff --git a/app/controllers/invites_controller.rb b/app/controllers/invites_controller.rb
index a29c03395f4..eb3c8233530 100644
--- a/app/controllers/invites_controller.rb
+++ b/app/controllers/invites_controller.rb
@@ -4,8 +4,6 @@ class InvitesController < ApplicationController
respond_to :html
- layout 'navless'
-
def show
end
diff --git a/app/controllers/oauth/applications_controller.rb b/app/controllers/oauth/applications_controller.rb
index ea256de2c3e..f30a85564d4 100644
--- a/app/controllers/oauth/applications_controller.rb
+++ b/app/controllers/oauth/applications_controller.rb
@@ -1,6 +1,6 @@
class Oauth::ApplicationsController < Doorkeeper::ApplicationsController
before_action :authenticate_user!
- layout "profile"
+ before_action :set_title
def index
head :forbidden and return
@@ -36,4 +36,10 @@ class Oauth::ApplicationsController < Doorkeeper::ApplicationsController
rescue_from ActiveRecord::RecordNotFound do |exception|
render "errors/not_found", layout: "errors", status: 404
end
+
+ def set_title
+ @title = "Profile"
+ @title_url = profile_path
+ @sidebar = "profile"
+ end
end
diff --git a/app/controllers/oauth/authorizations_controller.rb b/app/controllers/oauth/authorizations_controller.rb
index 6d3c1a320db..c62890ba85b 100644
--- a/app/controllers/oauth/authorizations_controller.rb
+++ b/app/controllers/oauth/authorizations_controller.rb
@@ -1,6 +1,6 @@
class Oauth::AuthorizationsController < Doorkeeper::AuthorizationsController
before_action :authenticate_resource_owner!
- layout "profile"
+ before_action :set_title
def new
if pre_auth.authorizable?
@@ -54,4 +54,10 @@ class Oauth::AuthorizationsController < Doorkeeper::AuthorizationsController
def strategy
@strategy ||= server.authorization_request(pre_auth.response_type)
end
+
+ def set_title
+ @title = "Profile"
+ @title_url = profile_path
+ @sidebar = "profile"
+ end
end
diff --git a/app/controllers/oauth/authorized_applications_controller.rb b/app/controllers/oauth/authorized_applications_controller.rb
index 0b27ce7da72..6d0bf9889e6 100644
--- a/app/controllers/oauth/authorized_applications_controller.rb
+++ b/app/controllers/oauth/authorized_applications_controller.rb
@@ -1,8 +1,16 @@
class Oauth::AuthorizedApplicationsController < Doorkeeper::AuthorizedApplicationsController
- layout "profile"
+ before_filter :set_title
def destroy
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])
end
+
+ private
+
+ def set_title
+ @title = "Profile"
+ @title_url = profile_path
+ @sidebar = "profile"
+ end
end
diff --git a/app/controllers/profiles/accounts_controller.rb b/app/controllers/profiles/accounts_controller.rb
index 9bd34fe2261..175afbf8425 100644
--- a/app/controllers/profiles/accounts_controller.rb
+++ b/app/controllers/profiles/accounts_controller.rb
@@ -1,6 +1,4 @@
-class Profiles::AccountsController < ApplicationController
- layout "profile"
-
+class Profiles::AccountsController < Profiles::ApplicationController
def show
@user = current_user
end
diff --git a/app/controllers/profiles/application_controller.rb b/app/controllers/profiles/application_controller.rb
new file mode 100644
index 00000000000..8373ff7a758
--- /dev/null
+++ b/app/controllers/profiles/application_controller.rb
@@ -0,0 +1,11 @@
+class Profiles::ApplicationController < ApplicationController
+ before_action :set_title
+
+ private
+
+ def set_title
+ @title = "Profile"
+ @title_url = profile_path
+ @sidebar = "profile"
+ end
+end
diff --git a/app/controllers/profiles/avatars_controller.rb b/app/controllers/profiles/avatars_controller.rb
index 57f3bbf0627..f193adb46b4 100644
--- a/app/controllers/profiles/avatars_controller.rb
+++ b/app/controllers/profiles/avatars_controller.rb
@@ -1,6 +1,4 @@
-class Profiles::AvatarsController < ApplicationController
- layout "profile"
-
+class Profiles::AvatarsController < Profiles::ApplicationController
def destroy
@user = current_user
@user.remove_avatar!
diff --git a/app/controllers/profiles/emails_controller.rb b/app/controllers/profiles/emails_controller.rb
index 954c98c0d9f..3e904700de5 100644
--- a/app/controllers/profiles/emails_controller.rb
+++ b/app/controllers/profiles/emails_controller.rb
@@ -1,6 +1,4 @@
-class Profiles::EmailsController < ApplicationController
- layout "profile"
-
+class Profiles::EmailsController < Profiles::ApplicationController
def index
@primary = current_user.email
@public_email = current_user.public_email
diff --git a/app/controllers/profiles/keys_controller.rb b/app/controllers/profiles/keys_controller.rb
index b0a5a631c63..f3224148fda 100644
--- a/app/controllers/profiles/keys_controller.rb
+++ b/app/controllers/profiles/keys_controller.rb
@@ -1,5 +1,4 @@
-class Profiles::KeysController < ApplicationController
- layout "profile"
+class Profiles::KeysController < Profiles::ApplicationController
skip_before_action :authenticate_user!, only: [:get_keys]
def index
diff --git a/app/controllers/profiles/notifications_controller.rb b/app/controllers/profiles/notifications_controller.rb
index 3fdcbbab61b..22423651c17 100644
--- a/app/controllers/profiles/notifications_controller.rb
+++ b/app/controllers/profiles/notifications_controller.rb
@@ -1,6 +1,4 @@
-class Profiles::NotificationsController < ApplicationController
- layout 'profile'
-
+class Profiles::NotificationsController < Profiles::ApplicationController
def show
@user = current_user
@notification = current_user.notification
diff --git a/app/controllers/profiles/passwords_controller.rb b/app/controllers/profiles/passwords_controller.rb
index b719a7fe9a9..94ac62cb32c 100644
--- a/app/controllers/profiles/passwords_controller.rb
+++ b/app/controllers/profiles/passwords_controller.rb
@@ -1,6 +1,4 @@
class Profiles::PasswordsController < ApplicationController
- layout :determine_layout
-
skip_before_action :check_password_expiration, only: [:new, :create]
before_action :set_user
@@ -67,14 +65,10 @@ class Profiles::PasswordsController < ApplicationController
end
def set_title
- @title = "New password"
- end
-
- def determine_layout
if [:new, :create].include?(action_name.to_sym)
- 'navless'
+ @title = "New password"
else
- 'profile'
+ super
end
end
diff --git a/app/controllers/profiles_controller.rb b/app/controllers/profiles_controller.rb
index eb001e8d739..f4366c18e7b 100644
--- a/app/controllers/profiles_controller.rb
+++ b/app/controllers/profiles_controller.rb
@@ -1,12 +1,10 @@
-class ProfilesController < ApplicationController
+class ProfilesController < Profiles::ApplicationController
include ActionView::Helpers::SanitizeHelper
before_action :user
before_action :authorize_change_username!, only: :update_username
skip_before_action :require_email, only: [:show, :update]
- layout 'profile'
-
def show
end
diff --git a/app/controllers/projects/application_controller.rb b/app/controllers/projects/application_controller.rb
index f7a28e920d1..ee88d49b400 100644
--- a/app/controllers/projects/application_controller.rb
+++ b/app/controllers/projects/application_controller.rb
@@ -1,7 +1,7 @@
class Projects::ApplicationController < ApplicationController
before_action :project
before_action :repository
- layout :determine_layout
+ layout 'project'
def authenticate_user!
# Restrict access to Projects area only
@@ -17,14 +17,6 @@ class Projects::ApplicationController < ApplicationController
super
end
- def determine_layout
- if current_user
- 'projects'
- else
- 'public_projects'
- end
- end
-
def require_branch_head
unless @repository.branch_names.include?(@ref)
redirect_to(
diff --git a/app/controllers/projects/avatars_controller.rb b/app/controllers/projects/avatars_controller.rb
index 22a12c4b9ae..9c3763d5934 100644
--- a/app/controllers/projects/avatars_controller.rb
+++ b/app/controllers/projects/avatars_controller.rb
@@ -1,6 +1,4 @@
class Projects::AvatarsController < Projects::ApplicationController
- layout 'project'
-
before_action :project
def show
diff --git a/app/controllers/projects/forks_controller.rb b/app/controllers/projects/forks_controller.rb
index 01a079d2e65..9e72597ea87 100644
--- a/app/controllers/projects/forks_controller.rb
+++ b/app/controllers/projects/forks_controller.rb
@@ -18,7 +18,6 @@ class Projects::ForksController < Projects::ApplicationController
notice: 'Project was successfully forked.'
)
else
- @title = 'Fork project'
render :error
end
end
diff --git a/app/controllers/projects/uploads_controller.rb b/app/controllers/projects/uploads_controller.rb
index e2d0b0d9459..71ecc20dd95 100644
--- a/app/controllers/projects/uploads_controller.rb
+++ b/app/controllers/projects/uploads_controller.rb
@@ -1,6 +1,4 @@
class Projects::UploadsController < Projects::ApplicationController
- layout 'project'
-
skip_before_action :authenticate_user!, :reject_blocked!, :project,
:repository, if: -> { action_name == 'show' && image? }
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index 883e5865a21..da6b0c3c91a 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -9,14 +9,14 @@ class ProjectsController < ApplicationController
before_action :set_title, only: [:new, :create]
before_action :event_filter, only: :show
- layout 'navless', only: [:new, :create, :fork]
+ layout :determine_layout
def new
@project = Project.new
end
def edit
- render 'edit', layout: 'project_settings'
+ render 'edit'
end
def create
@@ -46,7 +46,7 @@ class ProjectsController < ApplicationController
end
format.js
else
- format.html { render 'edit', layout: 'project_settings' }
+ format.html { render 'edit' }
format.js
end
end
@@ -72,13 +72,13 @@ class ProjectsController < ApplicationController
format.html do
if @project.repository_exists?
if @project.empty_repo?
- render 'projects/empty', layout: user_layout
+ render 'projects/empty'
else
@last_push = current_user.recent_push(@project.id) if current_user
- render :show, layout: user_layout
+ render :show
end
else
- render 'projects/no_repo', layout: user_layout
+ render 'projects/no_repo'
end
end
@@ -164,8 +164,14 @@ class ProjectsController < ApplicationController
@title = 'New Project'
end
- def user_layout
- current_user ? 'projects' : 'public_projects'
+ def determine_layout
+ if [:new, :create].include?(action_name.to_sym)
+ 'application'
+ elsif [:edit, :update].include?(action_name.to_sym)
+ 'project_settings'
+ else
+ 'project'
+ end
end
def load_events
diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb
index ad9e9e8487e..ba6f2a41fdc 100644
--- a/app/controllers/search_controller.rb
+++ b/app/controllers/search_controller.rb
@@ -1,6 +1,8 @@
class SearchController < ApplicationController
include SearchHelper
+ before_action :set_title
+
def show
return if params[:search].nil? || params[:search].blank?
@@ -55,4 +57,11 @@ class SearchController < ApplicationController
render json: search_autocomplete_opts(term).to_json
end
+
+ private
+
+ def set_title
+ @title = "Search"
+ @title_url = search_path
+ end
end
diff --git a/app/controllers/snippets_controller.rb b/app/controllers/snippets_controller.rb
index a5259466cb8..c960724b47a 100644
--- a/app/controllers/snippets_controller.rb
+++ b/app/controllers/snippets_controller.rb
@@ -13,8 +13,6 @@ class SnippetsController < ApplicationController
respond_to :html
- layout :determine_layout
-
def index
if params[:username].present?
@user = User.find_by(username: params[:username])
@@ -99,15 +97,12 @@ class SnippetsController < ApplicationController
end
def set_title
- @title = 'Snippets'
- @title_url = snippets_path
+ @title = 'Snippets'
+ @title_url = snippets_path
+ @sidebar = "snippets"
end
def snippet_params
params.require(:personal_snippet).permit(:title, :content, :file_name, :private, :visibility_level)
end
-
- def determine_layout
- current_user ? 'snippets' : 'public_users'
- end
end
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 460cc868b35..7285098435b 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -1,7 +1,6 @@
class UsersController < ApplicationController
skip_before_action :authenticate_user!
before_action :set_user
- layout :determine_layout
def show
@contributed_projects = contributed_projects.joined(@user).
@@ -51,14 +50,6 @@ class UsersController < ApplicationController
render 'calendar_activities', layout: false
end
- def determine_layout
- if current_user
- 'navless'
- else
- 'public_users'
- end
- end
-
private
def set_user