Skip to content
Snippets Groups Projects
Commit 26ad2509 authored by Douwe Maan's avatar Douwe Maan
Browse files

Add a page title to every page.

parent f2cf6d75
No related branches found
No related tags found
No related merge requests found
Showing
with 56 additions and 120 deletions
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 class Profiles::AvatarsController < Profiles::ApplicationController
layout "profile"
def destroy def destroy
@user = current_user @user = current_user
@user.remove_avatar! @user.remove_avatar!
Loading
Loading
class Profiles::EmailsController < ApplicationController class Profiles::EmailsController < Profiles::ApplicationController
layout "profile"
def index def index
@primary = current_user.email @primary = current_user.email
@public_email = current_user.public_email @public_email = current_user.public_email
Loading
Loading
class Profiles::KeysController < ApplicationController class Profiles::KeysController < Profiles::ApplicationController
layout "profile"
skip_before_action :authenticate_user!, only: [:get_keys] skip_before_action :authenticate_user!, only: [:get_keys]
   
def index def index
Loading
Loading
class Profiles::NotificationsController < ApplicationController class Profiles::NotificationsController < Profiles::ApplicationController
layout 'profile'
def show def show
@user = current_user @user = current_user
@notification = current_user.notification @notification = current_user.notification
Loading
Loading
class Profiles::PasswordsController < ApplicationController class Profiles::PasswordsController < ApplicationController
layout :determine_layout
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
Loading
@@ -67,14 +65,10 @@ class Profiles::PasswordsController < ApplicationController
Loading
@@ -67,14 +65,10 @@ class Profiles::PasswordsController < ApplicationController
end end
   
def set_title def set_title
@title = "New password"
end
def determine_layout
if [:new, :create].include?(action_name.to_sym) if [:new, :create].include?(action_name.to_sym)
'navless' @title = "New password"
else else
'profile' super
end end
end end
   
Loading
Loading
class ProfilesController < ApplicationController class ProfilesController < Profiles::ApplicationController
include ActionView::Helpers::SanitizeHelper include ActionView::Helpers::SanitizeHelper
   
before_action :user before_action :user
before_action :authorize_change_username!, only: :update_username before_action :authorize_change_username!, only: :update_username
skip_before_action :require_email, only: [:show, :update] skip_before_action :require_email, only: [:show, :update]
   
layout 'profile'
def show def show
end end
   
Loading
Loading
class Projects::ApplicationController < ApplicationController class Projects::ApplicationController < ApplicationController
before_action :project before_action :project
before_action :repository before_action :repository
layout :determine_layout layout 'project'
   
def authenticate_user! def authenticate_user!
# Restrict access to Projects area only # Restrict access to Projects area only
Loading
@@ -17,14 +17,6 @@ class Projects::ApplicationController < ApplicationController
Loading
@@ -17,14 +17,6 @@ class Projects::ApplicationController < ApplicationController
super super
end end
   
def determine_layout
if current_user
'projects'
else
'public_projects'
end
end
def require_branch_head def require_branch_head
unless @repository.branch_names.include?(@ref) unless @repository.branch_names.include?(@ref)
redirect_to( redirect_to(
Loading
Loading
class Projects::AvatarsController < Projects::ApplicationController class Projects::AvatarsController < Projects::ApplicationController
layout 'project'
before_action :project before_action :project
   
def show def show
Loading
Loading
Loading
@@ -18,7 +18,6 @@ class Projects::ForksController < Projects::ApplicationController
Loading
@@ -18,7 +18,6 @@ class Projects::ForksController < Projects::ApplicationController
notice: 'Project was successfully forked.' notice: 'Project was successfully forked.'
) )
else else
@title = 'Fork project'
render :error render :error
end end
end end
Loading
Loading
class Projects::UploadsController < Projects::ApplicationController class Projects::UploadsController < Projects::ApplicationController
layout 'project'
skip_before_action :authenticate_user!, :reject_blocked!, :project, skip_before_action :authenticate_user!, :reject_blocked!, :project,
:repository, if: -> { action_name == 'show' && image? } :repository, if: -> { action_name == 'show' && image? }
   
Loading
Loading
Loading
@@ -9,14 +9,14 @@ class ProjectsController < ApplicationController
Loading
@@ -9,14 +9,14 @@ class ProjectsController < ApplicationController
before_action :set_title, only: [:new, :create] before_action :set_title, only: [:new, :create]
before_action :event_filter, only: :show before_action :event_filter, only: :show
   
layout 'navless', only: [:new, :create, :fork] layout :determine_layout
   
def new def new
@project = Project.new @project = Project.new
end end
   
def edit def edit
render 'edit', layout: 'project_settings' render 'edit'
end end
   
def create def create
Loading
@@ -46,7 +46,7 @@ class ProjectsController < ApplicationController
Loading
@@ -46,7 +46,7 @@ class ProjectsController < ApplicationController
end end
format.js format.js
else else
format.html { render 'edit', layout: 'project_settings' } format.html { render 'edit' }
format.js format.js
end end
end end
Loading
@@ -72,13 +72,13 @@ class ProjectsController < ApplicationController
Loading
@@ -72,13 +72,13 @@ class ProjectsController < ApplicationController
format.html do format.html do
if @project.repository_exists? if @project.repository_exists?
if @project.empty_repo? if @project.empty_repo?
render 'projects/empty', layout: user_layout render 'projects/empty'
else else
@last_push = current_user.recent_push(@project.id) if current_user @last_push = current_user.recent_push(@project.id) if current_user
render :show, layout: user_layout render :show
end end
else else
render 'projects/no_repo', layout: user_layout render 'projects/no_repo'
end end
end end
   
Loading
@@ -164,8 +164,14 @@ class ProjectsController < ApplicationController
Loading
@@ -164,8 +164,14 @@ class ProjectsController < ApplicationController
@title = 'New Project' @title = 'New Project'
end end
   
def user_layout def determine_layout
current_user ? 'projects' : 'public_projects' if [:new, :create].include?(action_name.to_sym)
'application'
elsif [:edit, :update].include?(action_name.to_sym)
'project_settings'
else
'project'
end
end end
   
def load_events def load_events
Loading
Loading
class SearchController < ApplicationController class SearchController < ApplicationController
include SearchHelper include SearchHelper
   
before_action :set_title
def show def show
return if params[:search].nil? || params[:search].blank? return if params[:search].nil? || params[:search].blank?
   
Loading
@@ -55,4 +57,11 @@ class SearchController < ApplicationController
Loading
@@ -55,4 +57,11 @@ 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
Loading
@@ -13,8 +13,6 @@ class SnippetsController < ApplicationController
Loading
@@ -13,8 +13,6 @@ class SnippetsController < ApplicationController
   
respond_to :html respond_to :html
   
layout :determine_layout
def index def index
if params[:username].present? if params[:username].present?
@user = User.find_by(username: params[:username]) @user = User.find_by(username: params[:username])
Loading
@@ -99,15 +97,12 @@ class SnippetsController < ApplicationController
Loading
@@ -99,15 +97,12 @@ class SnippetsController < ApplicationController
end end
   
def set_title def set_title
@title = 'Snippets' @title = 'Snippets'
@title_url = snippets_path @title_url = snippets_path
@sidebar = "snippets"
end 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
def determine_layout
current_user ? 'snippets' : 'public_users'
end
end end
class UsersController < ApplicationController class UsersController < ApplicationController
skip_before_action :authenticate_user! skip_before_action :authenticate_user!
before_action :set_user before_action :set_user
layout :determine_layout
   
def show def show
@contributed_projects = contributed_projects.joined(@user). @contributed_projects = contributed_projects.joined(@user).
Loading
@@ -51,14 +50,6 @@ class UsersController < ApplicationController
Loading
@@ -51,14 +50,6 @@ class UsersController < ApplicationController
render 'calendar_activities', layout: false render 'calendar_activities', layout: false
end end
   
def determine_layout
if current_user
'navless'
else
'public_users'
end
end
private private
   
def set_user def set_user
Loading
Loading
Loading
@@ -332,4 +332,12 @@ module ApplicationHelper
Loading
@@ -332,4 +332,12 @@ 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
Loading
@@ -19,24 +19,6 @@ module GroupsHelper
Loading
@@ -19,24 +19,6 @@ module GroupsHelper
end end
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? def group_settings_page?
if current_controller?('groups') if current_controller?('groups')
current_action?('edit') || current_action?('projects') current_action?('edit') || current_action?('projects')
Loading
Loading
Loading
@@ -192,46 +192,6 @@ module ProjectsHelper
Loading
@@ -192,46 +192,6 @@ module ProjectsHelper
'unknown' 'unknown'
end 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) def default_url_to_repo(project = nil)
project = project || @project project = project || @project
current_user ? project.url_to_repo : project.http_url_to_repo current_user ? project.url_to_repo : project.http_url_to_repo
Loading
Loading
- page_title "Settings"
%h3.page-title Application settings %h3.page-title Application settings
%hr %hr
= render 'form' = render 'form'
- page_title "Edit", @application.name, "Applications"
%h3.page-title Edit application %h3.page-title Edit application
- @url = admin_application_path(@application) - @url = admin_application_path(@application)
= render 'form', application: @application = render 'form', application: @application
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment