From 8957808536e53bb9329cb6ae12835fde7835210b Mon Sep 17 00:00:00 2001 From: erdgeist Date: Sat, 27 Jun 2026 21:43:55 +0200 Subject: Stage 7 click-testing fixes (2) - nodes_controller: permit staged_slug and staged_parent_id in node params; these were silently dropped since strong parameters migration, breaking the two-phase slug/parent change workflow - file_attachment: add SVG support; vector files are copied to all style directories without rasterisation, preserving scalability in the browser - assets index/show: constrain image display with max-width/max-height via admin.css td img rule; fixes oversized SVG thumbnails while leaving raster variants unaffected --- app/models/concerns/file_attachment.rb | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'app/models') diff --git a/app/models/concerns/file_attachment.rb b/app/models/concerns/file_attachment.rb index e9acda6..0e99fa2 100644 --- a/app/models/concerns/file_attachment.rb +++ b/app/models/concerns/file_attachment.rb @@ -28,7 +28,9 @@ module FileAttachment headline: { geometry: "460x250!", format: nil } }.freeze - IMAGE_CONTENT_TYPES = %w[image/jpeg image/gif image/png image/webp].freeze + IMAGE_CONTENT_TYPES = %w[image/jpeg image/gif image/png image/webp].freeze + VECTOR_CONTENT_TYPES = %w[image/svg+xml].freeze + DISPLAYABLE_AS_IMAGE = IMAGE_CONTENT_TYPES + VECTOR_CONTENT_TYPES included do attr_reader :upload @@ -69,6 +71,8 @@ module FileAttachment if IMAGE_CONTENT_TYPES.include?(upload_content_type) generate_variants(original_path) + elsif VECTOR_CONTENT_TYPES.include?(upload_content_type) + generate_svg_variants(original_path) end end @@ -80,6 +84,14 @@ module FileAttachment end end + def generate_svg_variants(original_path) + STYLES.each do |style, _| + dest_path = file_path(style) + FileUtils.mkdir_p(File.dirname(dest_path)) + FileUtils.cp(original_path, dest_path) + end + end + def delete_upload_files dir = Rails.root.join("public", "system", "uploads", id.to_s) FileUtils.rm_rf(dir) if Dir.exist?(dir) -- cgit v1.3