From 87f3403dfcfa008070f69fe588e1e108c001fe27 Mon Sep 17 00:00:00 2001 From: erdgeist Date: Thu, 23 Jul 2026 20:45:22 +0200 Subject: Restyle pdf headline cards --- app/helpers/content_helper.rb | 4 ++++ app/models/concerns/file_attachment.rb | 7 ++++--- app/views/content/_headline_image.html.erb | 9 ++++++--- 3 files changed, 14 insertions(+), 6 deletions(-) (limited to 'app') diff --git a/app/helpers/content_helper.rb b/app/helpers/content_helper.rb index 7a52d9cd..6bb9c4e0 100644 --- a/app/helpers/content_helper.rb +++ b/app/helpers/content_helper.rb @@ -75,6 +75,10 @@ module ContentHelper end end + def humanized_asset_name asset + asset.name.to_s.tr("_", " ") + end + # This method is an output filter for templates. It accepts any kind of text # and checks for an [aggregate short code within it. If such a code is found, # its # attributes are parsed and converted into parameters for the diff --git a/app/models/concerns/file_attachment.rb b/app/models/concerns/file_attachment.rb index 62213123..e577c7fa 100644 --- a/app/models/concerns/file_attachment.rb +++ b/app/models/concerns/file_attachment.rb @@ -98,11 +98,11 @@ module FileAttachment generate_all_variants(original_path) end - def generate_variants(original_path) + def generate_variants(original_path, extra_args = []) STYLES.each do |style, options| dest_path = file_path(style) FileUtils.mkdir_p(File.dirname(dest_path)) - system("magick", original_path, *options[:args], dest_path) + system("magick", original_path, *extra_args, *options[:args], dest_path) end end @@ -120,7 +120,8 @@ module FileAttachment elsif VECTOR_CONTENT_TYPES.include?(upload_content_type) generate_svg_variants(original_path) elsif RASTERIZED_CONTENT_TYPES.include?(upload_content_type) - generate_variants("#{original_path}[0]") + generate_variants("#{original_path}[0]", + ["-background", "white", "-alpha", "remove", "-alpha", "off"]) end end diff --git a/app/views/content/_headline_image.html.erb b/app/views/content/_headline_image.html.erb index 4a3dfdc0..c05b17ef 100644 --- a/app/views/content/_headline_image.html.erb +++ b/app/views/content/_headline_image.html.erb @@ -6,8 +6,11 @@ <%= link_to @headline_asset.upload.url, :class => "headline_document_card", :target => "_blank", :rel => "noopener" do %> <%= image_tag @headline_asset.upload.url(:medium), :alt => "", :class => "headline_document_card_thumb" %>
- <%= icon("file-text", library: "tabler", "aria-hidden": true) %> - <%= @headline_asset.name %> +
+ <%= icon("file-text", library: "tabler", "aria-hidden": true) %> + <%= humanized_asset_name(@headline_asset) %> +
+ PDF ยท <%= number_to_human_size(@headline_asset.upload.size) %>
<% end %> <% end %> @@ -50,7 +53,7 @@
  • <%= link_to pdf.upload.url, :class => "related_document_link", :target => "_blank", :rel => "noopener" do %> <%= icon("file-text", library: "tabler", "aria-hidden": true) %> - <%= pdf.name %> + <%= humanized_asset_name(pdf) %> <% end %>
  • <% end %> -- cgit v1.3