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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
f711b2df
Commit
f711b2df
authored
Aug 03, 2017
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up some backend
parent
2197ee02
Changes
21
Hide whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
68 additions
and
54 deletions
+68
-54
app/controllers/concerns/renders_blob.rb
app/controllers/concerns/renders_blob.rb
+13
-21
app/controllers/projects/blob_controller.rb
app/controllers/projects/blob_controller.rb
+20
-6
app/helpers/blob_helper.rb
app/helpers/blob_helper.rb
+3
-3
app/models/blob_viewer/base.rb
app/models/blob_viewer/base.rb
+1
-1
app/models/blob_viewer/server_side.rb
app/models/blob_viewer/server_side.rb
+1
-1
app/views/projects/_files.html.haml
app/views/projects/_files.html.haml
+2
-1
app/views/projects/blob/_blob.html.haml
app/views/projects/blob/_blob.html.haml
+1
-1
app/views/projects/blob/show.html.haml
app/views/projects/blob/show.html.haml
+13
-7
app/views/projects/blob/viewers/_balsamiq.html.haml
app/views/projects/blob/viewers/_balsamiq.html.haml
+1
-1
app/views/projects/blob/viewers/_download.html.haml
app/views/projects/blob/viewers/_download.html.haml
+1
-1
app/views/projects/blob/viewers/_image.html.haml
app/views/projects/blob/viewers/_image.html.haml
+1
-1
app/views/projects/blob/viewers/_notebook.html.haml
app/views/projects/blob/viewers/_notebook.html.haml
+1
-1
app/views/projects/blob/viewers/_pdf.html.haml
app/views/projects/blob/viewers/_pdf.html.haml
+1
-1
app/views/projects/blob/viewers/_sketch.html.haml
app/views/projects/blob/viewers/_sketch.html.haml
+1
-1
app/views/projects/blob/viewers/_stl.html.haml
app/views/projects/blob/viewers/_stl.html.haml
+1
-1
app/views/projects/blob/viewers/_video.html.haml
app/views/projects/blob/viewers/_video.html.haml
+1
-1
app/views/projects/tree/_tree_content.html.haml
app/views/projects/tree/_tree_content.html.haml
+2
-1
app/views/projects/tree/_tree_header.html.haml
app/views/projects/tree/_tree_header.html.haml
+1
-1
app/views/projects/tree/show.html.haml
app/views/projects/tree/show.html.haml
+1
-1
app/views/shared/repo/_repo.html.haml
app/views/shared/repo/_repo.html.haml
+1
-1
yarn.lock
yarn.lock
+1
-1
No files found.
app/controllers/concerns/renders_blob.rb
View file @
f711b2df
module
RendersBlob
module
RendersBlob
extend
ActiveSupport
::
Concern
extend
ActiveSupport
::
Concern
def
render_
blob_json
(
blob
)
def
blob_json
(
blob
)
viewer
=
viewer
=
case
params
[
:viewer
]
case
params
[
:viewer
]
when
'rich'
when
'rich'
...
@@ -11,27 +11,19 @@ module RendersBlob
...
@@ -11,27 +11,19 @@ module RendersBlob
else
else
blob
.
simple_viewer
blob
.
simple_viewer
end
end
return
render_404
unless
viewer
if
blob
.
binary?
return
unless
viewer
render
json:
{
binary:
true
,
{
mime_type:
blob
.
mime_type
,
html:
view_to_html_string
(
"projects/blob/_viewer"
,
viewer:
viewer
,
load_async:
false
)
name:
blob
.
name
,
}
extension:
blob
.
extension
,
end
size:
blob
.
raw_size
}
def
render_blob_json
(
blob
)
else
json
=
blob_json
(
blob
)
render
json:
{
return
render_404
unless
json
html:
view_to_html_string
(
"projects/blob/_viewer"
,
viewer:
viewer
,
load_async:
false
),
plain:
blob
.
data
,
render
json:
json
name:
blob
.
name
,
extension:
blob
.
extension
,
size:
blob
.
raw_size
,
mime_type:
blob
.
mime_type
}
end
end
end
def
conditionally_expand_blob
(
blob
)
def
conditionally_expand_blob
(
blob
)
...
...
app/controllers/projects/blob_controller.rb
View file @
f711b2df
...
@@ -4,7 +4,6 @@ class Projects::BlobController < Projects::ApplicationController
...
@@ -4,7 +4,6 @@ class Projects::BlobController < Projects::ApplicationController
include
CreatesCommit
include
CreatesCommit
include
RendersBlob
include
RendersBlob
include
ActionView
::
Helpers
::
SanitizeHelper
include
ActionView
::
Helpers
::
SanitizeHelper
include
ApplicationHelper
# Raised when given an invalid file path
# Raised when given an invalid file path
InvalidPathError
=
Class
.
new
(
StandardError
)
InvalidPathError
=
Class
.
new
(
StandardError
)
...
@@ -38,17 +37,32 @@ class Projects::BlobController < Projects::ApplicationController
...
@@ -38,17 +37,32 @@ class Projects::BlobController < Projects::ApplicationController
respond_to
do
|
format
|
respond_to
do
|
format
|
format
.
html
do
format
.
html
do
assign_ref_vars
environment_params
=
@repository
.
branch_exists?
(
@ref
)
?
{
ref:
@ref
}
:
{
commit:
@commit
}
environment_params
=
@repository
.
branch_exists?
(
@ref
)
?
{
ref:
@ref
}
:
{
commit:
@commit
}
@environment
=
EnvironmentsFinder
.
new
(
@project
,
current_user
,
environment_params
).
execute
.
last
@environment
=
EnvironmentsFinder
.
new
(
@project
,
current_user
,
environment_params
).
execute
.
last
@last_commit
=
@repository
.
last_commit_for_path
(
@commit
.
id
,
tree
.
path
)
||
@commit
@last_commit
=
@repository
.
last_commit_for_path
(
@commit
.
id
,
@blob
.
path
)
show_new_repo?
?
render
(
'projects/tree/show'
)
:
render
(
'show'
)
render
'show'
end
end
format
.
json
do
format
.
json
do
render_blob_json
(
@blob
)
json
=
blob_json
(
@blob
)
return
render_404
unless
json
render
json:
json
.
merge
(
path:
blob
.
path
,
name:
blob
.
name
,
extension:
blob
.
extension
,
size:
blob
.
raw_size
,
mime_type:
blob
.
mime_type
,
binary:
blob
.
raw_binary?
,
simple_viewer:
blob
.
simple_viewer
&
.
class
&
.
partial_name
,
rich_viewer:
blob
.
rich_viewer
&
.
class
&
.
partial_name
,
show_viewer_switcher:
!!
blob
.
show_viewer_switcher?
,
raw_path:
project_raw_path
(
project
,
@id
),
blame_path:
project_blame_path
(
project
,
@id
),
commits_path:
project_commits_path
(
project
,
@id
),
permalink:
project_blob_path
(
project
,
File
.
join
(
@commit
.
id
,
@path
)),
)
end
end
end
end
end
end
...
...
app/helpers/blob_helper.rb
View file @
f711b2df
...
@@ -118,7 +118,7 @@ module BlobHelper
...
@@ -118,7 +118,7 @@ module BlobHelper
icon
(
"
#{
file_type_icon_class
(
'file'
,
mode
,
name
)
}
fw"
)
icon
(
"
#{
file_type_icon_class
(
'file'
,
mode
,
name
)
}
fw"
)
end
end
def
blob_raw_
url
def
blob_raw_
path
if
@build
&&
@entry
if
@build
&&
@entry
raw_project_job_artifacts_path
(
@project
,
@build
,
path:
@entry
.
path
)
raw_project_job_artifacts_path
(
@project
,
@build
,
path:
@entry
.
path
)
elsif
@snippet
elsif
@snippet
...
@@ -235,7 +235,7 @@ module BlobHelper
...
@@ -235,7 +235,7 @@ module BlobHelper
title
=
'Open raw'
title
=
'Open raw'
end
end
link_to
icon
,
blob_raw_
url
,
class:
'btn btn-sm has-tooltip'
,
target:
'_blank'
,
rel:
'noopener noreferrer'
,
title:
title
,
data:
{
container:
'body'
}
link_to
icon
,
blob_raw_
path
,
class:
'btn btn-sm has-tooltip'
,
target:
'_blank'
,
rel:
'noopener noreferrer'
,
title:
title
,
data:
{
container:
'body'
}
end
end
def
blob_render_error_reason
(
viewer
)
def
blob_render_error_reason
(
viewer
)
...
@@ -270,7 +270,7 @@ module BlobHelper
...
@@ -270,7 +270,7 @@ module BlobHelper
options
<<
link_to
(
'view the source'
,
'#'
,
class:
'js-blob-viewer-switch-btn'
,
data:
{
viewer:
'simple'
})
options
<<
link_to
(
'view the source'
,
'#'
,
class:
'js-blob-viewer-switch-btn'
,
data:
{
viewer:
'simple'
})
end
end
options
<<
link_to
(
'download it'
,
blob_raw_
url
,
target:
'_blank'
,
rel:
'noopener noreferrer'
)
options
<<
link_to
(
'download it'
,
blob_raw_
path
,
target:
'_blank'
,
rel:
'noopener noreferrer'
)
options
options
end
end
...
...
app/models/blob_viewer/base.rb
View file @
f711b2df
...
@@ -82,7 +82,7 @@ module BlobViewer
...
@@ -82,7 +82,7 @@ module BlobViewer
# format of the blob.
# format of the blob.
#
#
# Prefer to implement a client-side viewer, where the JS component loads the
# Prefer to implement a client-side viewer, where the JS component loads the
# binary from `blob_raw_
url
` and does its own format validation and error
# binary from `blob_raw_
path
` and does its own format validation and error
# rendering, especially for potentially large binary formats.
# rendering, especially for potentially large binary formats.
def
render_error
def
render_error
if
too_large?
if
too_large?
...
...
app/models/blob_viewer/server_side.rb
View file @
f711b2df
...
@@ -17,7 +17,7 @@ module BlobViewer
...
@@ -17,7 +17,7 @@ module BlobViewer
# build artifacts, can only be rendered using a client-side viewer,
# build artifacts, can only be rendered using a client-side viewer,
# since we do not want to read large amounts of data into memory on the
# since we do not want to read large amounts of data into memory on the
# server side. Client-side viewers use JS and can fetch the file from
# server side. Client-side viewers use JS and can fetch the file from
# `blob_raw_
url
` using AJAX.
# `blob_raw_
path
` using AJAX.
return
:server_side_but_stored_externally
if
blob
.
stored_externally?
return
:server_side_but_stored_externally
if
blob
.
stored_externally?
super
super
...
...
app/views/projects/_files.html.haml
View file @
f711b2df
-
commit
=
local_assigns
.
fetch
(
:commit
)
{
@repository
.
commit
}
-
commit
=
local_assigns
.
fetch
(
:commit
)
{
@repository
.
commit
}
-
ref
=
local_assigns
.
fetch
(
:ref
)
{
current_ref
}
-
ref
=
local_assigns
.
fetch
(
:ref
)
{
current_ref
}
-
project
=
local_assigns
.
fetch
(
:project
)
{
@project
}
-
project
=
local_assigns
.
fetch
(
:project
)
{
@project
}
-
content_url
=
local_assigns
.
fetch
(
:content_url
)
{
@tree
.
readme
?
project_blob_path
(
@project
,
tree_join
(
@ref
,
@tree
.
readme
.
path
))
:
project_tree_path
(
@project
,
@ref
)
}
#tree-holder
.tree-holder.clearfix
#tree-holder
.tree-holder.clearfix
.nav-block
.nav-block
...
@@ -9,4 +10,4 @@
...
@@ -9,4 +10,4 @@
-
if
!
show_new_repo?
&&
commit
-
if
!
show_new_repo?
&&
commit
=
render
'shared/commit_well'
,
commit:
commit
,
ref:
ref
,
project:
project
=
render
'shared/commit_well'
,
commit:
commit
,
ref:
ref
,
project:
project
=
render
'projects/tree/tree_content'
,
tree:
@tree
=
render
'projects/tree/tree_content'
,
tree:
@tree
,
content_url:
content_url
app/views/projects/blob/_blob.html.haml
View file @
f711b2df
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
=
render
"projects/blob/auxiliary_viewer"
,
blob:
blob
=
render
"projects/blob/auxiliary_viewer"
,
blob:
blob
#blob-content-holder
.blob-content-holder
#blob-content-holder
.blob-content-holder
-
if
!
show_new_repo?
-
unless
show_new_repo?
%article
.file-holder
%article
.file-holder
=
render
'projects/blob/header'
,
blob:
blob
=
render
'projects/blob/header'
,
blob:
blob
=
render
'projects/blob/content'
,
blob:
blob
=
render
'projects/blob/content'
,
blob:
blob
app/views/projects/blob/show.html.haml
View file @
f711b2df
...
@@ -6,16 +6,22 @@
...
@@ -6,16 +6,22 @@
-
content_for
:page_specific_javascripts
do
-
content_for
:page_specific_javascripts
do
=
webpack_bundle_tag
'blob'
=
webpack_bundle_tag
'blob'
=
webpack_bundle_tag
'common_vue'
-
if
show_new_repo?
=
webpack_bundle_tag
'common_vue'
=
webpack_bundle_tag
'repo'
=
render
'projects/last_push'
=
render
'projects/last_push'
%div
{
class:
container_class
}
%div
{
class:
container_class
}
#tree-holder
.tree-holder
-
if
show_new_repo?
=
render
'blob'
,
blob:
@blob
=
render
'projects/files'
,
commit:
@last_commit
,
project:
@project
,
ref:
@ref
,
content_url:
project_blob_path
(
@project
,
@id
)
-
else
#tree-holder
.tree-holder
=
render
'blob'
,
blob:
@blob
-
if
can_modify_blob?
(
@blob
)
-
if
can_modify_blob?
(
@blob
)
=
render
'projects/blob/remove'
=
render
'projects/blob/remove'
-
title
=
"Replace
#{
@blob
.
name
}
"
-
title
=
"Replace
#{
@blob
.
name
}
"
=
render
'projects/blob/upload'
,
title:
title
,
placeholder:
title
,
button_title:
'Replace file'
,
form_path:
project_update_blob_path
(
@project
,
@id
),
method: :put
=
render
'projects/blob/upload'
,
title:
title
,
placeholder:
title
,
button_title:
'Replace file'
,
form_path:
project_update_blob_path
(
@project
,
@id
),
method: :put
app/views/projects/blob/viewers/_balsamiq.html.haml
View file @
f711b2df
-
content_for
:page_specific_javascripts
do
-
content_for
:page_specific_javascripts
do
=
page_specific_javascript_bundle_tag
(
'balsamiq_viewer'
)
=
page_specific_javascript_bundle_tag
(
'balsamiq_viewer'
)
.file-content.balsamiq-viewer
#js-balsamiq-viewer
{
data:
{
endpoint:
blob_raw_
url
}
}
.file-content.balsamiq-viewer
#js-balsamiq-viewer
{
data:
{
endpoint:
blob_raw_
path
}
}
app/views/projects/blob/viewers/_download.html.haml
View file @
f711b2df
.file-content.blob_file.blob-no-preview
.file-content.blob_file.blob-no-preview
.center
.center
=
link_to
blob_raw_
url
do
=
link_to
blob_raw_
path
do
%h1
.light
%h1
.light
=
icon
(
'download'
)
=
icon
(
'download'
)
%h4
%h4
...
...
app/views/projects/blob/viewers/_image.html.haml
View file @
f711b2df
.file-content.image_file
.file-content.image_file
=
image_tag
(
blob_raw_
url
,
alt:
viewer
.
blob
.
name
)
=
image_tag
(
blob_raw_
path
,
alt:
viewer
.
blob
.
name
)
app/views/projects/blob/viewers/_notebook.html.haml
View file @
f711b2df
...
@@ -2,4 +2,4 @@
...
@@ -2,4 +2,4 @@
=
page_specific_javascript_bundle_tag
(
'common_vue'
)
=
page_specific_javascript_bundle_tag
(
'common_vue'
)
=
page_specific_javascript_bundle_tag
(
'notebook_viewer'
)
=
page_specific_javascript_bundle_tag
(
'notebook_viewer'
)
.file-content
#js-notebook-viewer
{
data:
{
endpoint:
blob_raw_
url
}
}
.file-content
#js-notebook-viewer
{
data:
{
endpoint:
blob_raw_
path
}
}
app/views/projects/blob/viewers/_pdf.html.haml
View file @
f711b2df
...
@@ -2,4 +2,4 @@
...
@@ -2,4 +2,4 @@
=
page_specific_javascript_bundle_tag
(
'common_vue'
)
=
page_specific_javascript_bundle_tag
(
'common_vue'
)
=
page_specific_javascript_bundle_tag
(
'pdf_viewer'
)
=
page_specific_javascript_bundle_tag
(
'pdf_viewer'
)
.file-content
#js-pdf-viewer
{
data:
{
endpoint:
blob_raw_
url
}
}
.file-content
#js-pdf-viewer
{
data:
{
endpoint:
blob_raw_
path
}
}
app/views/projects/blob/viewers/_sketch.html.haml
View file @
f711b2df
...
@@ -2,6 +2,6 @@
...
@@ -2,6 +2,6 @@
=
page_specific_javascript_bundle_tag
(
'common_vue'
)
=
page_specific_javascript_bundle_tag
(
'common_vue'
)
=
page_specific_javascript_bundle_tag
(
'sketch_viewer'
)
=
page_specific_javascript_bundle_tag
(
'sketch_viewer'
)
.file-content
#js-sketch-viewer
{
data:
{
endpoint:
blob_raw_
url
}
}
.file-content
#js-sketch-viewer
{
data:
{
endpoint:
blob_raw_
path
}
}
.js-loading-icon.text-center.prepend-top-default.append-bottom-default.js-loading-icon
{
'aria-label'
=>
'Loading Sketch preview'
}
.js-loading-icon.text-center.prepend-top-default.append-bottom-default.js-loading-icon
{
'aria-label'
=>
'Loading Sketch preview'
}
=
icon
(
'spinner spin 2x'
,
'aria-hidden'
=>
'true'
);
=
icon
(
'spinner spin 2x'
,
'aria-hidden'
=>
'true'
);
app/views/projects/blob/viewers/_stl.html.haml
View file @
f711b2df
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
=
page_specific_javascript_bundle_tag
(
'stl_viewer'
)
=
page_specific_javascript_bundle_tag
(
'stl_viewer'
)
.file-content.is-stl-loading
.file-content.is-stl-loading
.text-center
#js-stl-viewer
{
data:
{
endpoint:
blob_raw_
url
}
}
.text-center
#js-stl-viewer
{
data:
{
endpoint:
blob_raw_
path
}
}
=
icon
(
'spinner spin 2x'
,
class:
'prepend-top-default append-bottom-default'
,
'aria-hidden'
=>
'true'
,
'aria-label'
=>
'Loading'
)
=
icon
(
'spinner spin 2x'
,
class:
'prepend-top-default append-bottom-default'
,
'aria-hidden'
=>
'true'
,
'aria-label'
=>
'Loading'
)
.text-center.prepend-top-default.append-bottom-default.stl-controls
.text-center.prepend-top-default.append-bottom-default.stl-controls
.btn-group
.btn-group
...
...
app/views/projects/blob/viewers/_video.html.haml
View file @
f711b2df
.file-content.video
.file-content.video
%video
{
src:
blob_raw_
url
,
controls:
true
,
data:
{
setup:
'
{}
'
}
}
%video
{
src:
blob_raw_
path
,
controls:
true
,
data:
{
setup:
'
{}
'
}
}
app/views/projects/tree/_tree_content.html.haml
View file @
f711b2df
-
content_url
=
local_assigns
.
fetch
(
:content_url
,
nil
)
-
if
show_new_repo?
-
if
show_new_repo?
=
render
'shared/repo/repo'
,
project:
@project
=
render
'shared/repo/repo'
,
project:
@project
,
content_url:
content_url
-
else
-
else
=
render
'projects/tree/old_tree_content'
,
tree:
tree
=
render
'projects/tree/old_tree_content'
,
tree:
tree
app/views/projects/tree/_tree_header.html.haml
View file @
f711b2df
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
=
icon
(
'long-arrow-right'
,
title:
'to target branch'
)
=
icon
(
'long-arrow-right'
,
title:
'to target branch'
)
=
render
'shared/target_switcher'
,
destination:
'tree'
,
path:
@path
=
render
'shared/target_switcher'
,
destination:
'tree'
,
path:
@path
-
if
!
show_new_repo?
-
unless
show_new_repo?
=
render
'projects/tree/old_tree_header'
=
render
'projects/tree/old_tree_header'
.tree-controls
.tree-controls
...
...
app/views/projects/tree/show.html.haml
View file @
f711b2df
...
@@ -15,4 +15,4 @@
...
@@ -15,4 +15,4 @@
%div
{
class:
[
container_class
,
(
"limit-container-width"
unless
fluid_layout
)]
}
%div
{
class:
[
container_class
,
(
"limit-container-width"
unless
fluid_layout
)]
}
=
render
'projects/last_push'
=
render
'projects/last_push'
=
render
'projects/files'
,
commit:
@last_commit
,
project:
@project
,
ref:
@ref
=
render
'projects/files'
,
commit:
@last_commit
,
project:
@project
,
ref:
@ref
,
content_url:
project_tree_path
(
@project
,
@id
)
app/views/shared/repo/_repo.html.haml
View file @
f711b2df
#repo
{
data:
{
url:
repo_url
(
project
)
,
project_name:
project
.
name
,
refs_url:
refs_project_path
(
project
,
format: :json
),
project_url:
project_path
(
project
),
project_id:
project
.
id
}
}
#repo
{
data:
{
url:
content_url
,
project_name:
project
.
name
,
refs_url:
refs_project_path
(
project
,
format: :json
),
project_url:
project_path
(
project
),
project_id:
project
.
id
}
}
yarn.lock
View file @
f711b2df
...
@@ -2616,7 +2616,7 @@ got@^7.0.0:
...
@@ -2616,7 +2616,7 @@ got@^7.0.0:
url-parse-lax "^1.0.0"
url-parse-lax "^1.0.0"
url-to-options "^1.0.1"
url-to-options "^1.0.1"
graceful-fs@^4.1.11, graceful-fs@^4.1.2:
graceful-fs@^4.1.11, graceful-fs@^4.1.2
, graceful-fs@^4.1.6, graceful-fs@^4.1.9
:
version "4.1.11"
version "4.1.11"
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658"
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658"
...
...
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