Commit 26ad2509 authored by Douwe Maan's avatar Douwe Maan

Add a page title to every page.

parent f2cf6d75
Pipeline #20889 failed with stage
......@@ -2,6 +2,7 @@ Please view this file on the master branch, on stable branches it's out of date.
v 7.11.0 (unreleased)
- Don't allow a merge request to be merged when its title starts with "WIP".
- Add a page title to every page.
- Get Gitorious importer to work again.
- Fix clone URL field and X11 Primary selection (Dmitry Medvinsky)
- Ignore invalid lines in .gitmodules
......
......@@ -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
class Dashboard::ApplicationController < ApplicationController
before_action :set_title
private
def set_title
@title = "Dashboard"
@title_url = root_path
@sidebar = "dashboard"
end
end
class Dashboard::GroupsController < ApplicationController
class Dashboard::GroupsController < Dashboard::ApplicationController
def index
@group_members = current_user.group_members.page(params[:page]).per(PER_PAGE)
end
......
class Dashboard::MilestonesController < ApplicationController
class Dashboard::MilestonesController < Dashboard::ApplicationController
before_action :load_projects
def index
......
class Dashboard::ProjectsController < ApplicationController
class Dashboard::ProjectsController < Dashboard::ApplicationController
before_action :event_filter
def starred
......
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)
......
class Explore::ApplicationController < ApplicationController
before_action :set_title
private
def set_title
@title = "Explore GitLab"
@title_url = explore_root_path
@sidebar = "explore"
end
end
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?
......
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)
......
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
class Groups::AvatarsController < ApplicationController
layout "profile"
def destroy
@group = Group.find_by(path: params[:group_id])
@group.remove_avatar!
......
class Groups::MilestonesController < ApplicationController
layout 'group'
class Groups::MilestonesController < Groups::ApplicationController
before_action :authorize_group_milestone!, only: :update
def index
......
......@@ -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
......
......@@ -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')
......
......@@ -4,8 +4,6 @@ class InvitesController < ApplicationController
respond_to :html
layout 'navless'
def show
end
......
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
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
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
class Profiles::AccountsController < ApplicationController
layout "profile"
class Profiles::AccountsController < Profiles::ApplicationController
def show
@user = current_user
end
......
class Profiles::ApplicationController < ApplicationController
before_action :set_title
private
def set_title
@title = "Profile"
@title_url = profile_path
@sidebar = "profile"
end
end
class Profiles::AvatarsController < ApplicationController
layout "profile"
class Profiles::AvatarsController < Profiles::ApplicationController
def destroy
@user = current_user
@user.remove_avatar!
......
class Profiles::EmailsController < ApplicationController
layout "profile"
class Profiles::EmailsController < Profiles::ApplicationController
def index
@primary = current_user.email
@public_email = current_user.public_email
......
class Profiles::KeysController < ApplicationController
layout "profile"
class Profiles::KeysController < Profiles::ApplicationController
skip_before_action :authenticate_user!, only: [:get_keys]
def index
......
class Profiles::NotificationsController < ApplicationController
layout 'profile'
class Profiles::NotificationsController < Profiles::ApplicationController
def show
@user = current_user
@notification = current_user.notification
......
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
......
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
......
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(
......
class Projects::AvatarsController < Projects::ApplicationController
layout 'project'
before_action :project
def show
......
......@@ -18,7 +18,6 @@ class Projects::ForksController < Projects::ApplicationController
notice: 'Project was successfully forked.'
)
else
@title = 'Fork project'
render :error
end
end
......
class Projects::UploadsController < Projects::ApplicationController
layout 'project'
skip_before_action :authenticate_user!, :reject_blocked!, :project,
:repository, if: -> { action_name == 'show' && image? }
......
......@@ -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
......
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
......@@ -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
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
......
......@@ -332,4 +332,12 @@ module ApplicationHelper
end
"#{entity_title}#{count}"
end
def page_title(*titles)
@page_title ||= []
@page_title.push(*titles.compact) if titles.any?
@page_title.join(" | ")
end
end
......@@ -19,24 +19,6 @@ module GroupsHelper
end
end
def group_head_title
title = @group.name
title = if current_action?(:issues)
"Issues - " + title
elsif current_action?(:merge_requests)
"Merge requests - " + title
elsif current_action?(:members)
"Members - " + title
elsif current_action?(:edit)
"Settings - " + title
else
title
end
title
end
def group_settings_page?
if current_controller?('groups')
current_action?('edit') || current_action?('projects')
......
......@@ -192,46 +192,6 @@ module ProjectsHelper
'unknown'
end
def project_head_title
title = @project.name_with_namespace
title = if current_controller?(:tree)
"#{@project.path}\/#{@path} at #{@ref} - " + title
elsif current_controller?(:issues)
if current_action?(:show)
"Issue ##{@issue.iid} - #{@issue.title} - " + title
else
"Issues - " + title
end
elsif current_controller?(:blob)
if current_action?(:new) || current_action?(:create)
"New file at #{@ref}"
elsif current_action?(:show)
"#{@blob.path} at #{@ref}"
elsif @blob
"Edit file #{@blob.path} at #{@ref}"
end
elsif current_controller?(:commits)
"Commits at #{@ref} - " + title
elsif current_controller?(:merge_requests)
if current_action?(:show)
"Merge request ##{@merge_request.iid} - " + title
else
"Merge requests - " + title
end
elsif current_controller?(:wikis)
"Wiki - " + title
elsif current_controller?(:network)
"Network graph - " + title
elsif current_controller?(:graphs)
"Graphs - " + title
else
title
end
title
end
def default_url_to_repo(project = nil)
project = project || @project
current_user ? project.url_to_repo : project.http_url_to_repo
......
- page_title "Settings"
%h3.page-title Application settings
%hr
= render 'form'
- page_title "Edit", @application.name, "Applications"
%h3.page-title Edit application
- @url = admin_application_path(@application)
= render 'form', application: @application
\ No newline at end of file