summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouwe Maan <douwe@selenight.nl>2017-05-12 14:31:29 -0500
committerDouwe Maan <douwe@selenight.nl>2017-05-13 11:46:10 -0500
commit4328bc1769c52393580cb777d34dbd6ebff089cf (patch)
tree51c58b1d6dd11f491c7c0b82b182ac81bcf07aa5
parent361b2b135ff020cb628f1d0617e191a8bde620bf (diff)
downloadgitlab-ce-4328bc1769c52393580cb777d34dbd6ebff089cf.tar.gz
Allow blob viewer to support multiple filetypes
-rw-r--r--app/models/blob_viewer/base.rb8
-rw-r--r--app/models/blob_viewer/gitlab_ci_yml.rb2
-rw-r--r--app/models/blob_viewer/license.rb2
-rw-r--r--app/models/blob_viewer/route_map.rb2
4 files changed, 7 insertions, 7 deletions
diff --git a/app/models/blob_viewer/base.rb b/app/models/blob_viewer/base.rb
index 4f38c31714b..7164e4ece78 100644
--- a/app/models/blob_viewer/base.rb
+++ b/app/models/blob_viewer/base.rb
@@ -2,7 +2,7 @@ module BlobViewer
class Base
PARTIAL_PATH_PREFIX = 'projects/blob/viewers'.freeze
- class_attribute :partial_name, :loading_partial_name, :type, :extensions, :file_type, :client_side, :binary, :switcher_icon, :switcher_title, :max_size, :absolute_max_size
+ class_attribute :partial_name, :loading_partial_name, :type, :extensions, :file_types, :client_side, :binary, :switcher_icon, :switcher_title, :max_size, :absolute_max_size
self.loading_partial_name = 'loading'
@@ -54,17 +54,17 @@ module BlobViewer
def self.can_render?(blob, verify_binary: true)
return false if verify_binary && binary? != blob.binary?
return true if extensions&.include?(blob.extension)
- return true if file_type && Gitlab::FileDetector.type_of(blob.path) == file_type
+ return true if file_types&.include?(Gitlab::FileDetector.type_of(blob.path))
false
end
def too_large?
- blob.raw_size > max_size
+ max_size && blob.raw_size > max_size
end
def absolutely_too_large?
- blob.raw_size > absolute_max_size
+ absolute_max_size && blob.raw_size > absolute_max_size
end
def can_override_max_size?
diff --git a/app/models/blob_viewer/gitlab_ci_yml.rb b/app/models/blob_viewer/gitlab_ci_yml.rb
index 81afab2f49b..7267c3965d3 100644
--- a/app/models/blob_viewer/gitlab_ci_yml.rb
+++ b/app/models/blob_viewer/gitlab_ci_yml.rb
@@ -5,7 +5,7 @@ module BlobViewer
self.partial_name = 'gitlab_ci_yml'
self.loading_partial_name = 'gitlab_ci_yml_loading'
- self.file_type = :gitlab_ci
+ self.file_types = %i(gitlab_ci)
self.binary = false
def validation_message
diff --git a/app/models/blob_viewer/license.rb b/app/models/blob_viewer/license.rb
index 3ad49570c88..5e60ff2af97 100644
--- a/app/models/blob_viewer/license.rb
+++ b/app/models/blob_viewer/license.rb
@@ -7,7 +7,7 @@ module BlobViewer
include Auxiliary
self.partial_name = 'license'
- self.file_type = :license
+ self.file_types = %i(license)
self.binary = false
def license
diff --git a/app/models/blob_viewer/route_map.rb b/app/models/blob_viewer/route_map.rb
index 1ca730c1ea0..153b4eeb2c9 100644
--- a/app/models/blob_viewer/route_map.rb
+++ b/app/models/blob_viewer/route_map.rb
@@ -5,7 +5,7 @@ module BlobViewer
self.partial_name = 'route_map'
self.loading_partial_name = 'route_map_loading'
- self.file_type = :route_map
+ self.file_types = %i(route_map)
self.binary = false
def validation_message