<%# Copyright (C) The Arvados Authors. All rights reserved. SPDX-License-Identifier: AGPL-3.0 %> <%# The locators in the given text are expected to be of the form JSON_KEEP_LOCATOR_REGEXP %> <% data_height = data_height || 100 %>
<% text_data.each_line do |line| %> <% matches = keep_locator_in_json line %> <% if matches.nil? or matches.empty? %> <%= line %> <% else subs = [] matches.uniq.each do |loc| pdh, filename = loc.split('/', 2) if object_readable(pdh) # Add PDH link replacement = link_to_arvados_object_if_readable(pdh, pdh, friendly_name: true) if filename link_params = {controller: 'collections', action: 'show_file', uuid: pdh, file: filename} if preview_allowed_for(filename) params = {disposition: 'inline'} else params = {disposition: 'attachment'} end file_link = link_to(raw("/"+filename), link_params.merge(params)) # Add file link replacement << file_link end # Add link(s) substitution subs << [loc, replacement] end end # Replace all readable locators with links subs.each do |loc, link| line.gsub!(loc, link) end %> <%= raw line %> <% end %> <% end %>