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
Léo-Paul Géneau
gitlab-ce
Commits
21d2ebff
Commit
21d2ebff
authored
Apr 13, 2017
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Render blob viewer error
parent
44cf2470
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
5 deletions
+25
-5
app/helpers/blob_helper.rb
app/helpers/blob_helper.rb
+9
-0
app/views/projects/blob/_render_error.html.haml
app/views/projects/blob/_render_error.html.haml
+16
-0
app/views/projects/blob/_too_large.html.haml
app/views/projects/blob/_too_large.html.haml
+0
-5
No files found.
app/helpers/blob_helper.rb
View file @
21d2ebff
...
...
@@ -217,4 +217,13 @@ module BlobHelper
def
open_raw_file_button
(
path
)
link_to
icon
(
'file-code-o'
),
path
,
class:
'btn btn-sm has-tooltip'
,
target:
'_blank'
,
rel:
'noopener noreferrer'
,
title:
'Open raw'
,
data:
{
container:
'body'
}
end
def
blob_render_error_reason
(
viewer
,
error
)
case
error
when
:too_large
"it is larger than
#{
number_to_human_size
(
viewer
.
relevant_max_size
)
}
"
when
:server_side_but_stored_in_lfs
"it is stored in LFS"
end
end
end
app/views/projects/blob/_render_error.html.haml
0 → 100644
View file @
21d2ebff
-
reason
=
blob_render_error_reason
(
viewer
,
error
)
-
options
=
[]
-
if
error
==
:too_large
&&
viewer
.
can_override_max_size?
-
options
<<
link_to
(
'load it anyway'
,
url_for
(
params
.
merge
(
viewer:
viewer
.
type
,
override_max_size:
true
,
format:
nil
)))
-
if
viewer
.
rich?
&&
viewer
.
blob
.
rendered_as_text?
(
override_max_size:
true
)
-
options
<<
link_to
(
'view the source'
,
'#'
,
class:
'js-blob-viewer-switcher'
,
data:
{
viewer:
'simple'
})
-
options
<<
link_to
(
'download it'
,
blob_raw_url
,
target:
'_blank'
,
rel:
'noopener noreferrer'
)
.file-content.code
.nothing-here-block
The
#{
viewer
.
switcher_title
}
could not be displayed because
#{
reason
}
.
You can
=
options
.
to_sentence
(
two_words_connector:
' or '
,
last_word_connector:
', or '
).
html_safe
instead.
app/views/projects/blob/_too_large.html.haml
deleted
100644 → 0
View file @
44cf2470
.file-content.code
.nothing-here-block
The file could not be displayed as it is too large, you can
#{
link_to
(
'view the raw file'
,
namespace_project_raw_path
(
@project
.
namespace
,
@project
,
@id
),
target:
'_blank'
,
rel:
'noopener noreferrer'
)
}
instead.
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