%# A squawk's files: photos open in the in-app viewer, everything else opens in
a new tab. Every file has a download link. %>
<% files = squawk.attachments.to_a %>
<% if files.any? %>
<% photos, others = files.partition(&:image?) %>
<% photos.each do |file| %>
<%= link_to rails_blob_path(file, disposition: :inline), class: "px-2 py-1 text-sky-700 hover:bg-slate-100",
title: "Preview #{file.filename}",
data: { gallery_target: "item", action: "gallery#open", gallery_name: file.filename.to_s,
gallery_download: rails_blob_path(file, disposition: :attachment) } do %>
🖼 <%= file.filename.to_s.truncate(28, omission: "…") %>
<% end %>
<%= link_to "⬇", rails_blob_path(file, disposition: :attachment), download: file.filename.to_s,
class: "border-l border-slate-300 px-1.5 py-1 text-slate-500 hover:bg-slate-100 hover:text-sky-700",
title: "Download #{file.filename}", aria: { label: "Download #{file.filename}" } %>
<% end %>
<% others.each do |file| %>
<%= link_to "📎 #{file.filename.to_s.truncate(28, omission: "…")}", rails_blob_path(file, disposition: :inline),
class: "px-2 py-1 text-sky-700 hover:bg-slate-100", target: "_blank", rel: "noopener", title: "Open #{file.filename}" %>
<%= link_to "⬇", rails_blob_path(file, disposition: :attachment), download: file.filename.to_s,
class: "border-l border-slate-300 px-1.5 py-1 text-slate-500 hover:bg-slate-100 hover:text-sky-700",
title: "Download #{file.filename}", aria: { label: "Download #{file.filename}" } %>
<% end %>
<% if photos.any? %>
‹
›
<% end %>
<% end %>