diff options
author | Douwe Maan <douwe@selenight.nl> | 2017-08-23 14:23:41 +0300 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2017-09-26 18:31:47 +0300 |
commit | 711bb2856884161c5026964292c87984ba78b05c (patch) | |
tree | ac9ae82a9433940c34a51e49c6ca570558132031 | |
parent | 923ad9a9e2ffca550a06d0cbbd89ac6f276c4605 (diff) |
Add Page-Title header to tree and blob JSON endpoints
-rw-r--r-- | app/controllers/application_controller.rb | 6 | ||||
-rw-r--r-- | app/controllers/projects/blob_controller.rb | 2 | ||||
-rw-r--r-- | app/controllers/projects/tree_controller.rb | 2 | ||||
-rw-r--r-- | app/helpers/page_layout_helper.rb | 2 |
4 files changed, 11 insertions, 1 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 97922e39ba8..02c46e551f6 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -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 diff --git a/app/controllers/projects/blob_controller.rb b/app/controllers/projects/blob_controller.rb index 2b8f3977e6e..183a6f88a6a 100644 --- a/app/controllers/projects/blob_controller.rb +++ b/app/controllers/projects/blob_controller.rb @@ -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 diff --git a/app/controllers/projects/tree_controller.rb b/app/controllers/projects/tree_controller.rb index f3784f4e07c..f3719059f88 100644 --- a/app/controllers/projects/tree_controller.rb +++ b/app/controllers/projects/tree_controller.rb @@ -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) diff --git a/app/helpers/page_layout_helper.rb b/app/helpers/page_layout_helper.rb index 5946c475835..18b9bf214a3 100644 --- a/app/helpers/page_layout_helper.rb +++ b/app/helpers/page_layout_helper.rb @@ -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 |