diff options
| author | erdgeist <erdgeist@erdgeist.org> | 2026-06-27 21:43:55 +0200 |
|---|---|---|
| committer | erdgeist <erdgeist@erdgeist.org> | 2026-06-27 21:43:55 +0200 |
| commit | 8957808536e53bb9329cb6ae12835fde7835210b (patch) | |
| tree | 4bcb4fe279ecd78f8c138f06aec62174beea24aa | |
| parent | a627a650fda4e22107245a3269465347bb778258 (diff) | |
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
| -rw-r--r-- | app/controllers/nodes_controller.rb | 2 | ||||
| -rw-r--r-- | app/models/concerns/file_attachment.rb | 14 | ||||
| -rw-r--r-- | app/views/assets/index.html.erb | 2 | ||||
| -rw-r--r-- | app/views/assets/show.html.erb | 4 |
4 files changed, 17 insertions, 5 deletions
diff --git a/app/controllers/nodes_controller.rb b/app/controllers/nodes_controller.rb index bd60b27..494887d 100644 --- a/app/controllers/nodes_controller.rb +++ b/app/controllers/nodes_controller.rb | |||
| @@ -107,7 +107,7 @@ class NodesController < ApplicationController | |||
| 107 | private | 107 | private |
| 108 | 108 | ||
| 109 | def node_params | 109 | def node_params |
| 110 | params.fetch(:node, {}).permit(:slug, :parent_id) | 110 | params.fetch(:node, {}).permit(:slug, :parent_id, :staged_slug, :staged_parent_id) |
| 111 | end | 111 | end |
| 112 | 112 | ||
| 113 | def page_params | 113 | def page_params |
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 | |||
| 28 | headline: { geometry: "460x250!", format: nil } | 28 | headline: { geometry: "460x250!", format: nil } |
| 29 | }.freeze | 29 | }.freeze |
| 30 | 30 | ||
| 31 | IMAGE_CONTENT_TYPES = %w[image/jpeg image/gif image/png image/webp].freeze | 31 | IMAGE_CONTENT_TYPES = %w[image/jpeg image/gif image/png image/webp].freeze |
| 32 | VECTOR_CONTENT_TYPES = %w[image/svg+xml].freeze | ||
| 33 | DISPLAYABLE_AS_IMAGE = IMAGE_CONTENT_TYPES + VECTOR_CONTENT_TYPES | ||
| 32 | 34 | ||
| 33 | included do | 35 | included do |
| 34 | attr_reader :upload | 36 | attr_reader :upload |
| @@ -69,6 +71,8 @@ module FileAttachment | |||
| 69 | 71 | ||
| 70 | if IMAGE_CONTENT_TYPES.include?(upload_content_type) | 72 | if IMAGE_CONTENT_TYPES.include?(upload_content_type) |
| 71 | generate_variants(original_path) | 73 | generate_variants(original_path) |
| 74 | elsif VECTOR_CONTENT_TYPES.include?(upload_content_type) | ||
| 75 | generate_svg_variants(original_path) | ||
| 72 | end | 76 | end |
| 73 | end | 77 | end |
| 74 | 78 | ||
| @@ -80,6 +84,14 @@ module FileAttachment | |||
| 80 | end | 84 | end |
| 81 | end | 85 | end |
| 82 | 86 | ||
| 87 | def generate_svg_variants(original_path) | ||
| 88 | STYLES.each do |style, _| | ||
| 89 | dest_path = file_path(style) | ||
| 90 | FileUtils.mkdir_p(File.dirname(dest_path)) | ||
| 91 | FileUtils.cp(original_path, dest_path) | ||
| 92 | end | ||
| 93 | end | ||
| 94 | |||
| 83 | def delete_upload_files | 95 | def delete_upload_files |
| 84 | dir = Rails.root.join("public", "system", "uploads", id.to_s) | 96 | dir = Rails.root.join("public", "system", "uploads", id.to_s) |
| 85 | FileUtils.rm_rf(dir) if Dir.exist?(dir) | 97 | FileUtils.rm_rf(dir) if Dir.exist?(dir) |
diff --git a/app/views/assets/index.html.erb b/app/views/assets/index.html.erb index 83d55c2..51fc486 100644 --- a/app/views/assets/index.html.erb +++ b/app/views/assets/index.html.erb | |||
| @@ -10,7 +10,7 @@ | |||
| 10 | </tr> | 10 | </tr> |
| 11 | <% @assets.each do |asset| %> | 11 | <% @assets.each do |asset| %> |
| 12 | <tr> | 12 | <tr> |
| 13 | <td><%= image_tag asset.upload.url(:thumb) %></td> | 13 | <td><%= image_tag asset.upload.url(:thumb), style: "max-width: 100px; max-height: 100px;" %></td> |
| 14 | <td><%= link_to asset.name, asset.upload.url %></td> | 14 | <td><%= link_to asset.name, asset.upload.url %></td> |
| 15 | <td><%= asset.upload.content_type %></td> | 15 | <td><%= asset.upload.content_type %></td> |
| 16 | <td><%= link_to 'Show', asset %></td> | 16 | <td><%= link_to 'Show', asset %></td> |
diff --git a/app/views/assets/show.html.erb b/app/views/assets/show.html.erb index a64987c..694be5a 100644 --- a/app/views/assets/show.html.erb +++ b/app/views/assets/show.html.erb | |||
| @@ -6,7 +6,7 @@ | |||
| 6 | <table> | 6 | <table> |
| 7 | <tr> | 7 | <tr> |
| 8 | <td>Thumbnail</td> | 8 | <td>Thumbnail</td> |
| 9 | <td><%= image_tag @asset.upload.url(:medium) %></td> | 9 | <td><%= image_tag @asset.upload.url(:medium), style: "max-width: 300px; max-height: 300px;" %></td> |
| 10 | </tr> | 10 | </tr> |
| 11 | <tr> | 11 | <tr> |
| 12 | <td>Public Path</td> | 12 | <td>Public Path</td> |
| @@ -20,4 +20,4 @@ | |||
| 20 | <td>Size</td> | 20 | <td>Size</td> |
| 21 | <td><%= "#{@asset.upload.size/1024} KB" %></td> | 21 | <td><%= "#{@asset.upload.size/1024} KB" %></td> |
| 22 | </tr> | 22 | </tr> |
| 23 | </table> \ No newline at end of file | 23 | </table> |
