Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
711bb285
Commit
711bb285
authored
Aug 23, 2017
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Page-Title header to tree and blob JSON endpoints
parent
923ad9a9
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
11 additions
and
1 deletion
+11
-1
app/controllers/application_controller.rb
app/controllers/application_controller.rb
+6
-0
app/controllers/projects/blob_controller.rb
app/controllers/projects/blob_controller.rb
+2
-0
app/controllers/projects/tree_controller.rb
app/controllers/projects/tree_controller.rb
+2
-0
app/helpers/page_layout_helper.rb
app/helpers/page_layout_helper.rb
+1
-1
No files found.
app/controllers/application_controller.rb
View file @
711bb285
...
@@ -25,6 +25,8 @@ class ApplicationController < ActionController::Base
...
@@ -25,6 +25,8 @@ class ApplicationController < ActionController::Base
around_action
:set_locale
around_action
:set_locale
after_action
:set_page_title_header
,
if:
->
{
request
.
format
==
:json
}
protect_from_forgery
with: :exception
protect_from_forgery
with: :exception
helper_method
:can?
,
:current_application_settings
helper_method
:can?
,
:current_application_settings
...
@@ -335,4 +337,8 @@ class ApplicationController < ActionController::Base
...
@@ -335,4 +337,8 @@ class ApplicationController < ActionController::Base
sign_in
user
,
store:
false
sign_in
user
,
store:
false
end
end
end
end
def
set_page_title_header
response
.
headers
[
'Page-Title'
]
=
page_title
(
'GitLab'
)
end
end
end
app/controllers/projects/blob_controller.rb
View file @
711bb285
...
@@ -41,6 +41,8 @@ class Projects::BlobController < Projects::ApplicationController
...
@@ -41,6 +41,8 @@ class Projects::BlobController < Projects::ApplicationController
end
end
format
.
json
do
format
.
json
do
page_title
@blob
.
path
,
@ref
,
@project
.
name_with_namespace
show_json
show_json
end
end
end
end
...
...
app/controllers/projects/tree_controller.rb
View file @
711bb285
...
@@ -35,6 +35,8 @@ class Projects::TreeController < Projects::ApplicationController
...
@@ -35,6 +35,8 @@ class Projects::TreeController < Projects::ApplicationController
end
end
format
.
json
do
format
.
json
do
page_title
@path
.
presence
||
_
(
"Files"
),
@ref
,
@project
.
name_with_namespace
# n+1: https://gitlab.com/gitlab-org/gitlab-ce/issues/38261
# n+1: https://gitlab.com/gitlab-org/gitlab-ce/issues/38261
Gitlab
::
GitalyClient
.
allow_n_plus_1_calls
do
Gitlab
::
GitalyClient
.
allow_n_plus_1_calls
do
render
json:
TreeSerializer
.
new
(
project:
@project
,
repository:
@repository
,
ref:
@ref
).
represent
(
@tree
)
render
json:
TreeSerializer
.
new
(
project:
@project
,
repository:
@repository
,
ref:
@ref
).
represent
(
@tree
)
...
...
app/helpers/page_layout_helper.rb
View file @
711bb285
...
@@ -9,7 +9,7 @@ module PageLayoutHelper
...
@@ -9,7 +9,7 @@ module PageLayoutHelper
end
end
# Segments are seperated by middot
# Segments are seperated by middot
@page_title
.
join
(
"
\u
00b7
"
)
@page_title
.
join
(
"
·
"
)
end
end
# Define or get a description for the current page
# 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