Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
heptapod
heptapod
Commits
993e43f120a4
Commit
711bb285
authored
Aug 23, 2017
by
Douwe Maan
Browse files
Add Page-Title header to tree and blob JSON endpoints
parent
1091eaf635a3
Changes
4
Hide whitespace changes
Inline
Side-by-side
app/controllers/application_controller.rb
View file @
993e43f1
...
...
@@ -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 @@ def sessionless_sign_in(user)
sign_in
user
,
store:
false
end
end
def
set_page_title_header
response
.
headers
[
'Page-Title'
]
=
page_title
(
'GitLab'
)
end
end
app/controllers/projects/blob_controller.rb
View file @
993e43f1
...
...
@@ -41,6 +41,8 @@ def show
end
format
.
json
do
page_title
@blob
.
path
,
@ref
,
@project
.
name_with_namespace
show_json
end
end
...
...
app/controllers/projects/tree_controller.rb
View file @
993e43f1
...
...
@@ -35,6 +35,8 @@ def show
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
)
...
...
app/helpers/page_layout_helper.rb
View file @
993e43f1
...
...
@@ -9,7 +9,7 @@ def page_title(*titles)
end
# Segments are seperated by middot
@page_title
.
join
(
"
\u
00b7
"
)
@page_title
.
join
(
"
·
"
)
end
# Define or get a description for the current page
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment