diff options
| author | erdgeist <erdgeist@erdgeist.org> | 2026-07-21 23:17:56 +0200 |
|---|---|---|
| committer | erdgeist <erdgeist@erdgeist.org> | 2026-07-21 23:17:56 +0200 |
| commit | 8f3f58e3010fa7c923b77b7d2050175890b58f9b (patch) | |
| tree | ece76f69129b8b6c3c59b0b71f69e9fc59950d30 /app/views/content/_headline_image.html.erb | |
| parent | 18114a978b7c037da5194c48f860435e261f9a0b (diff) | |
Render PDF headlines as document cards, not lightbox images
A starred PDF previously ran through the same crop-and-lightbox path
a photo does -- exactly the awkward treatment explicit headline
designation was meant to avoid. _headline_image.html.erb now branches
on @headline_asset.pdf?: a PDF renders as a linked card (a :medium
thumbnail, a file icon, its name), no gallery participation at all.
The existing image-headline and gallery-fallback logic is otherwise
unchanged, now scoped to an image-specific headline only.
Other attached PDFs -- headlined or not -- list below as plain links,
same reasoning as why non-headline photos still get a gallery
trigger: an attached document shouldn't go invisible just because
nothing's been starred yet.
headline_image's own render guard needed widening to cover a page
with PDFs attached but no images and no headline at all -- the one
case none of the existing conditions accounted for.
Diffstat (limited to 'app/views/content/_headline_image.html.erb')
| -rw-r--r-- | app/views/content/_headline_image.html.erb | 42 |
1 files changed, 35 insertions, 7 deletions
diff --git a/app/views/content/_headline_image.html.erb b/app/views/content/_headline_image.html.erb index 13a4ac78..4a3dfdc0 100644 --- a/app/views/content/_headline_image.html.erb +++ b/app/views/content/_headline_image.html.erb | |||
| @@ -1,13 +1,25 @@ | |||
| 1 | <% gallery_images = @page.assets.images %> | 1 | <% gallery_images = @page.assets.images %> |
| 2 | <% image_headline = @headline_asset if @headline_asset&.image? %> | ||
| 3 | <% other_pdfs = @page.assets.pdfs.where.not(id: @headline_asset&.id) %> | ||
| 2 | 4 | ||
| 3 | <% if @headline_asset %> | 5 | <% if @headline_asset&.pdf? %> |
| 6 | <%= link_to @headline_asset.upload.url, :class => "headline_document_card", :target => "_blank", :rel => "noopener" do %> | ||
| 7 | <%= image_tag @headline_asset.upload.url(:medium), :alt => "", :class => "headline_document_card_thumb" %> | ||
| 8 | <div class="headline_document_card_info"> | ||
| 9 | <%= icon("file-text", library: "tabler", "aria-hidden": true) %> | ||
| 10 | <span class="headline_document_card_title"><%= @headline_asset.name %></span> | ||
| 11 | </div> | ||
| 12 | <% end %> | ||
| 13 | <% end %> | ||
| 14 | |||
| 15 | <% if image_headline %> | ||
| 4 | <%= link_to( | 16 | <%= link_to( |
| 5 | image_tag(@headline_asset.upload.url(:headline)), | 17 | image_tag(image_headline.upload.url(:headline)), |
| 6 | @headline_asset.upload.url, | 18 | image_headline.upload.url, |
| 7 | :class => "glightbox", | 19 | :class => "glightbox", |
| 8 | :data => { :gallery => "page-#{@page.node.id}", | 20 | :data => { :gallery => "page-#{@page.node.id}", |
| 9 | :glightbox => glightbox_data(@headline_asset, @headline_asset.name), | 21 | :glightbox => glightbox_data(image_headline, image_headline.name), |
| 10 | :"credit-selector" => (@headline_asset.show_credit? ? "#credit_for_asset_#{@headline_asset.id}" : nil) } | 22 | :"credit-selector" => (image_headline.show_credit? ? "#credit_for_asset_#{image_headline.id}" : nil) } |
| 11 | ) %> | 23 | ) %> |
| 12 | <% if gallery_images.size > 1 %> | 24 | <% if gallery_images.size > 1 %> |
| 13 | <div class="right"><%= "#{gallery_images.size} #{t(:images)}" %></div> | 25 | <div class="right"><%= "#{gallery_images.size} #{t(:images)}" %></div> |
| @@ -22,10 +34,26 @@ | |||
| 22 | <% end %> | 34 | <% end %> |
| 23 | 35 | ||
| 24 | <% gallery_images.each do |image| %> | 36 | <% gallery_images.each do |image| %> |
| 25 | <% next if image == @headline_asset %> | 37 | <% next if image == image_headline %> |
| 26 | <% next if !@headline_asset && image == gallery_images.first %> | 38 | <% next if !image_headline && image == gallery_images.first %> |
| 27 | <%= link_to "", image.upload.url, :class => "glightbox", :style => "display: none", | 39 | <%= link_to "", image.upload.url, :class => "glightbox", :style => "display: none", |
| 28 | :data => { :gallery => "page-#{@page.node.id}", | 40 | :data => { :gallery => "page-#{@page.node.id}", |
| 29 | :glightbox => glightbox_data(image, image.name), | 41 | :glightbox => glightbox_data(image, image.name), |
| 30 | :"credit-selector" => (image.show_credit? ? "#credit_for_asset_#{image.id}" : nil) } %> | 42 | :"credit-selector" => (image.show_credit? ? "#credit_for_asset_#{image.id}" : nil) } %> |
| 31 | <% end %> | 43 | <% end %> |
| 44 | |||
| 45 | <% if other_pdfs.any? %> | ||
| 46 | <div class="related_documents"> | ||
| 47 | <div class="related_documents_label"><%= t(:related_documents) %></div> | ||
| 48 | <ul class="related_documents_list"> | ||
| 49 | <% other_pdfs.each do |pdf| %> | ||
| 50 | <li> | ||
| 51 | <%= link_to pdf.upload.url, :class => "related_document_link", :target => "_blank", :rel => "noopener" do %> | ||
| 52 | <%= icon("file-text", library: "tabler", "aria-hidden": true) %> | ||
| 53 | <span><%= pdf.name %></span> | ||
| 54 | <% end %> | ||
| 55 | </li> | ||
| 56 | <% end %> | ||
| 57 | </ul> | ||
| 58 | </div> | ||
| 59 | <% end %> | ||
