diff options
| author | erdgeist <erdgeist@erdgeist.org> | 2026-07-23 20:45:22 +0200 |
|---|---|---|
| committer | erdgeist <erdgeist@erdgeist.org> | 2026-07-23 20:45:22 +0200 |
| commit | 87f3403dfcfa008070f69fe588e1e108c001fe27 (patch) | |
| tree | 2a1af10cc692a72de21dc6c3108e2be5b0067e23 | |
| parent | f0745de7f661a27b4d20d2ba317d1b31bf9a6c4b (diff) | |
Restyle pdf headline cards
| -rw-r--r-- | app/helpers/content_helper.rb | 4 | ||||
| -rw-r--r-- | app/models/concerns/file_attachment.rb | 7 | ||||
| -rw-r--r-- | app/views/content/_headline_image.html.erb | 9 | ||||
| -rw-r--r-- | public/javascripts/admin_interface.js | 2 | ||||
| -rw-r--r-- | public/stylesheets/ccc.css | 35 |
5 files changed, 34 insertions, 23 deletions
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 | |||
| 75 | end | 75 | end |
| 76 | end | 76 | end |
| 77 | 77 | ||
| 78 | def humanized_asset_name asset | ||
| 79 | asset.name.to_s.tr("_", " ") | ||
| 80 | end | ||
| 81 | |||
| 78 | # This method is an output filter for templates. It accepts any kind of text | 82 | # This method is an output filter for templates. It accepts any kind of text |
| 79 | # and checks for an [aggregate short code within it. If such a code is found, | 83 | # and checks for an [aggregate short code within it. If such a code is found, |
| 80 | # its # attributes are parsed and converted into parameters for the | 84 | # 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 | |||
| 98 | generate_all_variants(original_path) | 98 | generate_all_variants(original_path) |
| 99 | end | 99 | end |
| 100 | 100 | ||
| 101 | def generate_variants(original_path) | 101 | def generate_variants(original_path, extra_args = []) |
| 102 | STYLES.each do |style, options| | 102 | STYLES.each do |style, options| |
| 103 | dest_path = file_path(style) | 103 | dest_path = file_path(style) |
| 104 | FileUtils.mkdir_p(File.dirname(dest_path)) | 104 | FileUtils.mkdir_p(File.dirname(dest_path)) |
| 105 | system("magick", original_path, *options[:args], dest_path) | 105 | system("magick", original_path, *extra_args, *options[:args], dest_path) |
| 106 | end | 106 | end |
| 107 | end | 107 | end |
| 108 | 108 | ||
| @@ -120,7 +120,8 @@ module FileAttachment | |||
| 120 | elsif VECTOR_CONTENT_TYPES.include?(upload_content_type) | 120 | elsif VECTOR_CONTENT_TYPES.include?(upload_content_type) |
| 121 | generate_svg_variants(original_path) | 121 | generate_svg_variants(original_path) |
| 122 | elsif RASTERIZED_CONTENT_TYPES.include?(upload_content_type) | 122 | elsif RASTERIZED_CONTENT_TYPES.include?(upload_content_type) |
| 123 | generate_variants("#{original_path}[0]") | 123 | generate_variants("#{original_path}[0]", |
| 124 | ["-background", "white", "-alpha", "remove", "-alpha", "off"]) | ||
| 124 | end | 125 | end |
| 125 | end | 126 | end |
| 126 | 127 | ||
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 @@ | |||
| 6 | <%= link_to @headline_asset.upload.url, :class => "headline_document_card", :target => "_blank", :rel => "noopener" do %> | 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" %> | 7 | <%= image_tag @headline_asset.upload.url(:medium), :alt => "", :class => "headline_document_card_thumb" %> |
| 8 | <div class="headline_document_card_info"> | 8 | <div class="headline_document_card_info"> |
| 9 | <%= icon("file-text", library: "tabler", "aria-hidden": true) %> | 9 | <div class="headline_document_card_titlerow"> |
| 10 | <span class="headline_document_card_title"><%= @headline_asset.name %></span> | 10 | <%= icon("file-text", library: "tabler", "aria-hidden": true) %> |
| 11 | <span class="headline_document_card_title"><%= humanized_asset_name(@headline_asset) %></span> | ||
| 12 | </div> | ||
| 13 | <span class="headline_document_card_meta">PDF ยท <%= number_to_human_size(@headline_asset.upload.size) %></span> | ||
| 11 | </div> | 14 | </div> |
| 12 | <% end %> | 15 | <% end %> |
| 13 | <% end %> | 16 | <% end %> |
| @@ -50,7 +53,7 @@ | |||
| 50 | <li> | 53 | <li> |
| 51 | <%= link_to pdf.upload.url, :class => "related_document_link", :target => "_blank", :rel => "noopener" do %> | 54 | <%= link_to pdf.upload.url, :class => "related_document_link", :target => "_blank", :rel => "noopener" do %> |
| 52 | <%= icon("file-text", library: "tabler", "aria-hidden": true) %> | 55 | <%= icon("file-text", library: "tabler", "aria-hidden": true) %> |
| 53 | <span><%= pdf.name %></span> | 56 | <span><%= humanized_asset_name(pdf) %></span> |
| 54 | <% end %> | 57 | <% end %> |
| 55 | </li> | 58 | </li> |
| 56 | <% end %> | 59 | <% end %> |
diff --git a/public/javascripts/admin_interface.js b/public/javascripts/admin_interface.js index 284d2b72..7ff10ade 100644 --- a/public/javascripts/admin_interface.js +++ b/public/javascripts/admin_interface.js | |||
| @@ -117,7 +117,7 @@ $(document).ready(function () { | |||
| 117 | input.addEventListener('change', function() { | 117 | input.addEventListener('change', function() { |
| 118 | var name_field = document.getElementById('asset_name'); | 118 | var name_field = document.getElementById('asset_name'); |
| 119 | if (input.files.length && name_field && name_field.value === '') { | 119 | if (input.files.length && name_field && name_field.value === '') { |
| 120 | name_field.value = input.files[0].name.replace(/\.[^.]+$/, ''); | 120 | name_field.value = input.files[0].name.replace(/\.[^.]+$/, '').replace(/[_-]+/g, ' '); |
| 121 | } | 121 | } |
| 122 | }); | 122 | }); |
| 123 | } | 123 | } |
diff --git a/public/stylesheets/ccc.css b/public/stylesheets/ccc.css index 91f7a06a..5046baac 100644 --- a/public/stylesheets/ccc.css +++ b/public/stylesheets/ccc.css | |||
| @@ -778,36 +778,39 @@ div.teaser_ruler { | |||
| 778 | 778 | ||
| 779 | .headline_document_card { | 779 | .headline_document_card { |
| 780 | display: flex; | 780 | display: flex; |
| 781 | gap: 1rem; | ||
| 782 | align-items: flex-start; | 781 | align-items: flex-start; |
| 783 | border: 1px solid color-mix(in srgb, CanvasText, #808080 25%); | 782 | gap: 1.5em; |
| 784 | border-radius: 6px; | 783 | margin: 1.5em 0; |
| 785 | padding: 1rem; | ||
| 786 | text-decoration: none; | 784 | text-decoration: none; |
| 787 | color: inherit; | ||
| 788 | } | ||
| 789 | |||
| 790 | .headline_document_card:hover { | ||
| 791 | border-color: CanvasText; | ||
| 792 | } | 785 | } |
| 793 | 786 | ||
| 794 | .headline_document_card_thumb { | 787 | .headline_document_card_thumb { |
| 795 | max-width: 120px; | 788 | border: 1px solid rgba(128, 128, 128, 0.4); |
| 796 | max-height: 160px; | 789 | box-shadow: 2px 3px 8px rgba(0, 0, 0, 0.25); |
| 797 | border: 1px solid color-mix(in srgb, CanvasText, #808080 25%); | 790 | max-width: 180px; |
| 798 | flex-shrink: 0; | 791 | height: auto; |
| 799 | } | 792 | } |
| 800 | 793 | ||
| 801 | .headline_document_card_info { | 794 | .headline_document_card_info { |
| 802 | display: flex; | 795 | display: flex; |
| 803 | align-items: center; | 796 | flex-direction: column; |
| 804 | gap: 0.5rem; | 797 | gap: 0.3em; |
| 798 | padding-top: 0.5em; | ||
| 805 | } | 799 | } |
| 806 | 800 | ||
| 807 | .headline_document_card_title { | 801 | .headline_document_card_titlerow { |
| 802 | display: flex; | ||
| 803 | align-items: center; | ||
| 804 | gap: 0.4em; | ||
| 808 | font-weight: bold; | 805 | font-weight: bold; |
| 809 | } | 806 | } |
| 810 | 807 | ||
| 808 | .headline_document_card_meta { | ||
| 809 | font-size: 0.85em; | ||
| 810 | font-weight: normal; | ||
| 811 | color: rgba(128, 128, 128, 0.95); | ||
| 812 | } | ||
| 813 | |||
| 811 | .related_documents { | 814 | .related_documents { |
| 812 | margin-top: 1rem; | 815 | margin-top: 1rem; |
| 813 | } | 816 | } |
