scinote-web/app/views/search/results/partials/_asset_text.html.erb

44 lines
1.4 KiB
Text
Raw Normal View History

2016-02-12 23:52:43 +08:00
<% query ||= nil %>
<% asset_read_allowed = false %>
2016-07-21 19:11:15 +08:00
<% text = query.present? ? highlight(asset.file_file_name, query.strip.split(/\s+/)) : asset.file_file_name %>
2016-02-12 23:52:43 +08:00
<% if asset.step %>
<% protocol = asset.step.protocol %>
<% if can_read_protocol_in_module?(protocol) ||
can_read_protocol_in_repository?(protocol) %>
<% asset_read_allowed = true %>
<a href="<%= download_asset_path asset %>" target="_blank">
<%= text %>
</a>
<% else %>
<%= text %>
<% end %>
<% elsif asset.result %>
<% if can_read_experiment?(asset.result.my_module.experiment) %>
<% asset_read_allowed = true %>
<a href="<%= download_asset_path asset %>" target="_blank">
<%= text %>
</a>
<% else %>
<%= text %>
<% end %>
<% elsif asset.repository_asset_value %>
<% if can_read_team?(asset.repository_asset_value.repository_cell.repository_row.repository.team) %>
<% asset_read_allowed = true %>
<a href="<%= download_asset_path asset %>" target="_blank">
<%= text %>
</a>
<% else %>
<%= text %>
<% end %>
2016-07-21 19:11:15 +08:00
<% else %>
<%= text %>
2016-10-11 22:16:48 +08:00
<% end %>
<!-- Display asset contents if it exists -->
<% if asset_read_allowed && asset.headline.present? && asset.headline.include?("<mark>") %>
<blockquote class="blockquote-search">
<p><%= highlight(sanitize_input(asset.headline), query.strip.split(/\s+/)) %></p>
</blockquote>
<% end %>