Add Page-Title header to tree and blob JSON endpoints

This commit is contained in:
Douwe Maan 2017-08-23 13:23:41 +02:00
parent 923ad9a9e2
commit 711bb28568
4 changed files with 11 additions and 1 deletions

View File

@ -25,6 +25,8 @@ class ApplicationController < ActionController::Base
around_action :set_locale
after_action :set_page_title_header, if: -> { request.format == :json }
protect_from_forgery with: :exception
helper_method :can?, :current_application_settings
@ -335,4 +337,8 @@ class ApplicationController < ActionController::Base
sign_in user, store: false
end
end
def set_page_title_header
response.headers['Page-Title'] = page_title('GitLab')
end
end

View File

@ -41,6 +41,8 @@ class Projects::BlobController < Projects::ApplicationController
end
format.json do
page_title @blob.path, @ref, @project.name_with_namespace
show_json
end
end

View File

@ -35,6 +35,8 @@ class Projects::TreeController < Projects::ApplicationController
end
format.json do
page_title @path.presence || _("Files"), @ref, @project.name_with_namespace
# n+1: https://gitlab.com/gitlab-org/gitlab-ce/issues/38261
Gitlab::GitalyClient.allow_n_plus_1_calls do
render json: TreeSerializer.new(project: @project, repository: @repository, ref: @ref).represent(@tree)

View File

@ -9,7 +9,7 @@ module PageLayoutHelper
end
# Segments are seperated by middot
@page_title.join(" \u00b7 ")
@page_title.join(" · ")
end
# Define or get a description for the current page