diff options
Diffstat (limited to 'app/models/blob.rb')
-rw-r--r-- | app/models/blob.rb | 42 |
1 files changed, 40 insertions, 2 deletions
diff --git a/app/models/blob.rb b/app/models/blob.rb index 95d2111a992..55872acef51 100644 --- a/app/models/blob.rb +++ b/app/models/blob.rb @@ -42,14 +42,34 @@ class Blob < SimpleDelegator size && truncated? end + def extension + extname.downcase.delete('.') + end + def svg? text? && language && language.name == 'SVG' end + def pdf? + extension == 'pdf' + end + def ipython_notebook? text? && language&.name == 'Jupyter Notebook' end + def sketch? + binary? && extension == 'sketch' + end + + def stl? + extension == 'stl' + end + + def markup? + text? && Gitlab::MarkupHelper.markup?(name) + end + def size_within_svg_limits? size <= MAXIMUM_SVG_SIZE end @@ -65,12 +85,30 @@ class Blob < SimpleDelegator else 'text' end - elsif image? || svg? + elsif image? 'image' + elsif svg? + 'svg' + elsif pdf? + 'pdf' elsif ipython_notebook? 'notebook' + elsif sketch? + '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 |