spina 2.9.1 → 2.10.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of spina might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/app/controllers/spina/admin/attachments_controller.rb +10 -2
- data/app/controllers/spina/admin/images_controller.rb +9 -1
- data/app/jobs/spina/replace_signed_id_job.rb +24 -0
- data/app/models/spina/page.rb +1 -1
- data/app/views/spina/admin/attachments/_attachment.html.erb +9 -0
- data/app/views/spina/admin/images/_image.html.erb +10 -0
- data/config/locales/de.yml +1 -0
- data/config/locales/en.yml +1 -0
- data/config/locales/nl.yml +1 -0
- data/lib/spina/version.rb +1 -1
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bd9893ef78c55c7d8a448cce6e8bc04fe22d3f48cde3f07bbef32c03d9aaf00e
|
4
|
+
data.tar.gz: bc9fd36b1599b808d0313fabb1508506e4cf9e9e4f26908f645f906db3c5c79a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6c71bf70aa732fe118cdac86c234a99d88adfd0bf2669551a5f94c6847401ca87d0ebabc5afe522749d95d6c9e5f79c1abec95916080f735e5e29d36461c042c
|
7
|
+
data.tar.gz: 8d2da67450bc5c70cfd73c61dadca688ccbacb6b971d465559cca95c9cc2969a02c6f8e84e7dd02e794329a08f94e7fcff31f48382ce93ad64ac84c75333e480
|
@@ -32,13 +32,21 @@ module Spina
|
|
32
32
|
|
33
33
|
def update
|
34
34
|
@attachment = Attachment.find(params[:id])
|
35
|
+
old_signed_id = @attachment.file&.blob&.signed_id
|
36
|
+
@attachment.update(attachment_params) if params[:attachment].present?
|
35
37
|
if params[:filename].present?
|
36
38
|
extension = @attachment.file.filename.extension
|
37
39
|
filename = "#{params[:filename]}.#{extension}"
|
38
40
|
@attachment.file.blob.update(filename: filename)
|
39
41
|
end
|
40
|
-
|
41
|
-
|
42
|
+
|
43
|
+
# Replace all occurrences of the old signed blob ID
|
44
|
+
# with the new ID in a background job
|
45
|
+
if @attachment.reload.file&.blob&.signed_id != old_signed_id
|
46
|
+
Spina::ReplaceSignedIdJob.perform_later(old_signed_id, @attachment.file&.blob&.signed_id)
|
47
|
+
end
|
48
|
+
|
49
|
+
render @attachment
|
42
50
|
end
|
43
51
|
|
44
52
|
def destroy
|
@@ -44,15 +44,23 @@ module Spina
|
|
44
44
|
|
45
45
|
def update
|
46
46
|
@image = Image.find(params[:id])
|
47
|
+
old_signed_id = @image.file&.blob&.signed_id
|
47
48
|
@image.update(image_params) if params[:image].present?
|
48
49
|
if params[:filename].present?
|
49
50
|
extension = @image.file.filename.extension
|
50
51
|
filename = "#{params[:filename]}.#{extension}"
|
51
52
|
@image.file.blob.update(filename: filename)
|
52
53
|
end
|
54
|
+
|
53
55
|
if @image.saved_change_to_media_folder_id?
|
54
56
|
render :update
|
55
57
|
else
|
58
|
+
# Replace all occurrences of the old signed blob ID
|
59
|
+
# with the new ID in a background job
|
60
|
+
if @image.reload.file&.blob&.signed_id != old_signed_id
|
61
|
+
Spina::ReplaceSignedIdJob.perform_later(old_signed_id, @image.file&.blob&.signed_id)
|
62
|
+
end
|
63
|
+
|
56
64
|
@media_folders = MediaFolder.order(:name)
|
57
65
|
render @image
|
58
66
|
end
|
@@ -82,7 +90,7 @@ module Spina
|
|
82
90
|
end
|
83
91
|
|
84
92
|
def image_params
|
85
|
-
params.require(:image).permit(:media_folder_id)
|
93
|
+
params.require(:image).permit(:media_folder_id, :file)
|
86
94
|
end
|
87
95
|
|
88
96
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Spina
|
2
|
+
class ReplaceSignedIdJob < ApplicationJob
|
3
|
+
queue_as { Spina.config.queues[:page_updates] }
|
4
|
+
|
5
|
+
def perform(old_signed_id, new_signed_id)
|
6
|
+
return if old_signed_id.blank? || new_signed_id.blank?
|
7
|
+
|
8
|
+
pages = get_pages(old_signed_id)
|
9
|
+
accounts = Spina::Account.all
|
10
|
+
|
11
|
+
[pages, accounts].each do |records|
|
12
|
+
records.update_all("json_attributes = REGEXP_REPLACE(json_attributes::text, '#{old_signed_id}', '#{new_signed_id}', 'g')::jsonb")
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def get_pages(signed_id)
|
19
|
+
return Spina::Page.none unless signed_id.present?
|
20
|
+
Spina::Page.where("json_attributes::text LIKE ?", "%#{signed_id}%")
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
data/app/models/spina/page.rb
CHANGED
@@ -5,6 +5,15 @@
|
|
5
5
|
<span class="truncate"><%= attachment.file.filename %></span>
|
6
6
|
|
7
7
|
<div class="absolute h-full opacity-0 group-hover:opacity-100 flex items-center right-0 pr-3 top-0">
|
8
|
+
<%= form_with model: attachment, url: spina.admin_attachment_path(attachment), data: {turbo_frame: dom_id(attachment), controller: "form loading-button", loading_message: t('spina.media_library.uploading'), action: "turbo:submit-end->loading-button#doneLoading"} do |f| %>
|
9
|
+
<%= f.file_field :file, id: "attachment_#{attachment.id}_file_field", class: 'hidden', data: {action: "loading-button#loading form#requestSubmit"} %>
|
10
|
+
|
11
|
+
<button type="button" class="btn btn-default h-7 px-2 mr-2 text-xs" data-controller="delegate-click" data-action="delegate-click#click" data-loading-button-target="button" data-delegate-click-target="#attachment_<%= attachment.id %>_file_field">
|
12
|
+
<%= heroicon("upload", style: :solid, class: "w-4 h-4 mr-1 text-gray-600") %>
|
13
|
+
<%=t 'spina.ui.replace' %>
|
14
|
+
</button>
|
15
|
+
<% end %>
|
16
|
+
|
8
17
|
<%= link_to spina.edit_admin_attachment_path(attachment), class: "btn btn-default h-7 px-2 mr-2 text-xs" do %>
|
9
18
|
<%= heroicon('pencil', style: :solid, class: 'w-4 h-4 mr-1 text-gray-600') %>
|
10
19
|
<%=t 'spina.ui.rename' %>
|
@@ -10,6 +10,16 @@
|
|
10
10
|
<span class="truncate"><%= image.file.filename %></span>
|
11
11
|
|
12
12
|
<div class="absolute h-full opacity-0 group-hover:opacity-100 flex items-center right-0 pr-3 top-0">
|
13
|
+
|
14
|
+
<%= form_with model: image, url: spina.admin_image_path(image), data: {turbo_frame: dom_id(image), controller: "form loading-button", loading_message: t('spina.media_library.uploading'), action: "turbo:submit-end->loading-button#doneLoading"} do |f| %>
|
15
|
+
<%= f.file_field :file, accept: "image/*", id: "image_#{image.id}_file_field", class: 'hidden', data: {action: "loading-button#loading form#requestSubmit"} %>
|
16
|
+
|
17
|
+
<button type="button" class="btn btn-default h-7 px-2 mr-2 text-xs" data-controller="delegate-click" data-action="delegate-click#click" data-loading-button-target="button" data-delegate-click-target="#image_<%= image.id %>_file_field">
|
18
|
+
<%= heroicon("upload", style: :solid, class: "w-4 h-4 mr-1 text-gray-600") %>
|
19
|
+
<%=t 'spina.ui.replace' %>
|
20
|
+
</button>
|
21
|
+
<% end %>
|
22
|
+
|
13
23
|
<%= link_to spina.edit_admin_image_path(image), class: "btn btn-default h-7 px-2 mr-2 text-xs" do %>
|
14
24
|
<%= heroicon('pencil', style: :solid, class: 'w-4 h-4 mr-1 text-gray-600') %>
|
15
25
|
<%=t 'spina.ui.rename' %>
|
data/config/locales/de.yml
CHANGED
data/config/locales/en.yml
CHANGED
data/config/locales/nl.yml
CHANGED
data/lib/spina/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spina
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bram Jetten
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-04-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -972,6 +972,7 @@ files:
|
|
972
972
|
- app/helpers/spina/pages_helper.rb
|
973
973
|
- app/helpers/spina/spina_helper.rb
|
974
974
|
- app/jobs/spina/application_job.rb
|
975
|
+
- app/jobs/spina/replace_signed_id_job.rb
|
975
976
|
- app/jobs/spina/resource_pages_update_job.rb
|
976
977
|
- app/mailers/spina/application_mailer.rb
|
977
978
|
- app/mailers/spina/user_mailer.rb
|
@@ -1176,7 +1177,7 @@ metadata:
|
|
1176
1177
|
documentation_uri: https://www.spinacms.com/docs
|
1177
1178
|
changelog_uri: https://github.com/SpinaCMS/Spina/blob/main/CHANGELOG.md
|
1178
1179
|
source_code_uri: https://github.com/SpinaCMS/Spina
|
1179
|
-
post_install_message:
|
1180
|
+
post_install_message:
|
1180
1181
|
rdoc_options: []
|
1181
1182
|
require_paths:
|
1182
1183
|
- lib
|
@@ -1191,8 +1192,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
1191
1192
|
- !ruby/object:Gem::Version
|
1192
1193
|
version: '0'
|
1193
1194
|
requirements: []
|
1194
|
-
rubygems_version: 3.
|
1195
|
-
signing_key:
|
1195
|
+
rubygems_version: 3.3.7
|
1196
|
+
signing_key:
|
1196
1197
|
specification_version: 4
|
1197
1198
|
summary: Spina
|
1198
1199
|
test_files: []
|