Fix 2.4.2 upgrade notes formatting refs #19330
[arvados.git] / apps / workbench / app / views / application / _show_text_with_locators.html.erb
1 <%# Copyright (C) The Arvados Authors. All rights reserved.
2
3 SPDX-License-Identifier: AGPL-3.0 %>
4
5 <%# The locators in the given text are expected to be of the form JSON_KEEP_LOCATOR_REGEXP %>
6
7 <% data_height = data_height || 100 %>
8   <div style="max-height:<%=data_height%>px; overflow:auto;">
9     <% text_data.each_line do |line| %>
10       <% matches = keep_locator_in_json line %>
11
12       <% if matches.nil? or matches.empty? %>
13         <span style="white-space: pre-wrap; margin: none;"><%= line %></span>
14       <% else
15         subs = []
16         matches.uniq.each do |loc|
17           pdh, filename = loc.split('/', 2)
18
19           if object_readable(pdh)
20             # Add PDH link
21             replacement = link_to_arvados_object_if_readable(pdh, pdh, friendly_name: true)
22             if filename
23               link_params = {controller: 'collections', action: 'show_file', uuid: pdh, file: filename}
24               if preview_allowed_for(filename)
25                 params = {disposition: 'inline'}
26               else
27                 params = {disposition: 'attachment'}
28               end
29               file_link = link_to(raw("/"+filename), link_params.merge(params))
30               # Add file link
31               replacement << file_link
32             end
33             # Add link(s) substitution
34             subs << [loc, replacement]
35           end
36         end
37         # Replace all readable locators with links
38         subs.each do |loc, link|
39           line.gsub!(loc, link)
40         end %>
41         <span style="white-space: pre-wrap; margin: none;"><%= raw line %></span>
42       <% end %>
43     <% end %>
44   </div>