diff options
author | Douwe Maan <douwe@gitlab.com> | 2017-04-10 21:23:19 +0000 |
---|---|---|
committer | Robert Speicher <robert@gitlab.com> | 2017-04-10 21:23:19 +0000 |
commit | fb8a12c8fea422a9054fcbdb2e6b22770e9dfab3 (patch) | |
tree | dd8b86df7d03857238a994683a6b7f5014208570 /app/models/blob.rb | |
parent | 520ed0781cc86f3c158b3ebcfb2457dba3b41a6e (diff) | |
download | gitlab-ce-fb8a12c8fea422a9054fcbdb2e6b22770e9dfab3.tar.gz |
Don't show 'Copy content' button on text files that are not rendered as text
Diffstat (limited to 'app/models/blob.rb')
-rw-r--r-- | app/models/blob.rb | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/app/models/blob.rb b/app/models/blob.rb index 801d3442803..55872acef51 100644 --- a/app/models/blob.rb +++ b/app/models/blob.rb @@ -42,12 +42,16 @@ class Blob < SimpleDelegator size && truncated? end + def extension + extname.downcase.delete('.') + end + def svg? text? && language && language.name == 'SVG' end def pdf? - name && File.extname(name) == '.pdf' + extension == 'pdf' end def ipython_notebook? @@ -55,11 +59,15 @@ class Blob < SimpleDelegator end def sketch? - binary? && extname.downcase.delete('.') == 'sketch' + binary? && extension == 'sketch' end def stl? - extname.downcase.delete('.') == 'stl' + extension == 'stl' + end + + def markup? + text? && Gitlab::MarkupHelper.markup?(name) end def size_within_svg_limits? @@ -77,8 +85,10 @@ class Blob < SimpleDelegator else 'text' end - elsif image? || svg? + elsif image? 'image' + elsif svg? + 'svg' elsif pdf? 'pdf' elsif ipython_notebook? @@ -87,8 +97,18 @@ class Blob < SimpleDelegator 'sketch' elsif stl? 'stl' + elsif markup? + if only_display_raw? + 'too_large' + else + 'markup' + end elsif text? - 'text' + if only_display_raw? + 'too_large' + else + 'text' + end else 'download' end |