scinote-web/app/views/shared/_asset_link.html.erb

37 lines
1.4 KiB
Text

<% if asset.file_present %>
<% if asset.file.processing? && display_image_tag && asset.is_image? %>
<span data-status='asset-loading'
data-present-url='<%= file_present_asset_path(asset.id) %>'>
<%= image_tag 'medium/processing.gif' %>
<%= link_to download_asset_path(asset),
class: 'file-preview-link',
id: "modal_link#{asset.id}",
data: { no_turbolink: true, id: true, status: 'asset-present', 'preview-url': asset_file_preview_path(asset) } do %>
<span><%= truncate(asset.file_file_name,
length: Constants::FILENAME_TRUNCATION_LENGTH) %></span>
<% end %>
</span>
<% else %>
<%= link_to download_asset_path(asset),
class: 'file-preview-link',
id: "modal_link#{asset.id}",
data: { no_turbolink: true, id: true, status: 'asset-present', 'preview-url': asset_file_preview_path(asset) } do %>
<% if asset.is_image? && display_image_tag %>
<%= image_tag asset.url(:medium) %>
<% end %>
<% if display_image_tag %>
<p>
<%= truncate(asset.file_file_name,
length: Constants::FILENAME_TRUNCATION_LENGTH) %>
</p>
<% else %>
<span>
<%= truncate(asset.file_file_name,
length: Constants::FILENAME_TRUNCATION_LENGTH) %>
</span>
<% end %>
<% end %>
<% end %>
<% else %>
<%= image_tag 'medium/processing.gif' %>
<% end %>