<%# Multi-page viewer: one attachment per "page", with prev/next. %> <% pages = document.pages.to_a %> <% if pages.empty? %> <%= empty_state t(".no_files_uploaded") %> <% else %> <% current = pages[page - 1] %>
<%= link_to t(".prev"), url_for(page: page - 1), class: ["btn-secondary btn-sm", ("pointer-events-none opacity-40" if page <= 1)] %> <%= t(".page_of_html", page: page, pages: pages.size, link: (link_to current.filename, rails_blob_path(current, disposition: :attachment), class: "link")) %> <%= link_to t(".next"), url_for(page: page + 1), class: ["btn-secondary btn-sm", ("pointer-events-none opacity-40" if page >= pages.size)] %>
<% if current.image? %> <%= image_tag rails_blob_path(current, disposition: :inline), alt: current.filename.to_s, class: "max-h-[80vh] max-w-full" %> <% elsif current.content_type == "application/pdf" %> <% pdf_url = rails_blob_path(current, disposition: :inline) %> <%# Phones get the pages drawn by PDF.js; browsers with a PDF viewer of their own get it in the frame. %>

<%= t("js.pdf.loading") %>

<% else %>

<%= link_to t(".download", filename: current.filename), rails_blob_path(current, disposition: :attachment), class: "link" %>

<% end %>
<% end %>