+# Copyright (C) The Arvados Authors. All rights reserved.
+#
+# SPDX-License-Identifier: AGPL-3.0
+
module CollectionsHelper
def d3ify_links(links)
links.collect do |x|
f0 = '' if f0 == '.'
f0 = f0[2..-1] if f0[0..1] == './'
f0 += '/' if not f0.empty?
- file_path = "#{f0}#{file[1]}"
+ "#{f0}#{file[1]}"
+ end
+
+ ##
+ # Check if collection preview is allowed for the given filename with extension
+ #
+ def preview_allowed_for file_name
+ file_type = MIME::Types.type_for(file_name).first
+ if file_type.nil?
+ if file_name.downcase.end_with?('.cwl') # unknown mime type, but we support preview
+ true
+ else
+ false
+ end
+ elsif (file_type.raw_media_type == "text") || (file_type.raw_media_type == "image")
+ true
+ elsif (file_type.raw_media_type == "application") &&
+ Rails.configuration.Workbench.ApplicationMimetypesWithViewIcon[file_type.sub_type]
+ true
+ else
+ false
+ end
end
end