提交 4328bc17 编写于 作者: D Douwe Maan

Allow blob viewer to support multiple filetypes

上级 361b2b13
......@@ -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?
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册