katalyst-content 2.6.2 → 2.7.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bdabab79e4bf2448d8557d5e4f6b1f62655b6be942237bf6d0b0846dccb9862d
|
4
|
+
data.tar.gz: 5504a62e8a0cca3f748e3eb4568cef6453588d74c5413f81b8cc586c1052f584
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f96d013e1b4bfe1c1bcd76d3433e789c2b23c74276f65924fa83977a9147930d80352378c15a58a6961bf477caaa088a3a9926c0c6137db85e05863436a983bd
|
7
|
+
data.tar.gz: 869e112cbd54113bf565869e753cddbc6e23a9088a666d39748fe49b67ecbd6f83ddd1edfbed8832d2ab66db458146a17838be7a91b65258d18642fb6a07f0cb
|
@@ -87,15 +87,32 @@ module Katalyst
|
|
87
87
|
#
|
88
88
|
# This mimics the behaviour of direct uploads without requiring the JS
|
89
89
|
# integration.
|
90
|
+
#
|
91
|
+
# Note: this idea comes from various blogs who have documented this approach, such as
|
92
|
+
# https://medium.com/@TETRA2000/active-storage-how-to-retain-uploaded-files-on-form-resubmission-91b57be78d53
|
93
|
+
#
|
94
|
+
# In Rails 7.2 the simple version of this approach was broken to work around a bug that Rails plans to address
|
95
|
+
# in a future release.
|
96
|
+
# https://github.com/rails/rails/commit/82d4ad5da336a18a55a05a50b851e220032369a0
|
97
|
+
#
|
98
|
+
# The work around is to decouple the blobs from their attachments before saving by duping
|
99
|
+
# them. This approach feels a bit hairy and might need to be replaced by a 'standard' direct upload approach
|
100
|
+
# in the future.
|
101
|
+
#
|
102
|
+
# The reason we use this approach currently is to avoid needing a separate direct upload controller for
|
103
|
+
# content which would potentially introduce a back door where un-trusted users are allowed to upload
|
104
|
+
# attachments.
|
90
105
|
def store_attachments(item)
|
91
106
|
item.attachment_changes.each_value do |change|
|
92
107
|
case change
|
93
108
|
when ActiveStorage::Attached::Changes::CreateOne
|
94
109
|
change.upload
|
95
|
-
change.blob.save!
|
110
|
+
change.attachment.blob = change.blob.dup.tap(&:save!)
|
96
111
|
when ActiveStorage::Attached::Changes::CreateMany
|
97
112
|
change.upload
|
98
|
-
change.blobs.each
|
113
|
+
change.attachments.zip(change.blobs).each do |attachment, blob|
|
114
|
+
attachment.blob = blob.dup.tap(&:save!)
|
115
|
+
end
|
99
116
|
end
|
100
117
|
end
|
101
118
|
end
|
@@ -49,8 +49,24 @@ module Katalyst
|
|
49
49
|
dependent: :destroy,
|
50
50
|
validate: true
|
51
51
|
|
52
|
+
# Rails 7.2 dropped support for ActiveModel enums. This is a temporary workaround.
|
53
|
+
# Intended behaviour:
|
54
|
+
# attribute :state, :string
|
55
|
+
# enum :state, %i[published draft unpublished].index_with(&:to_s)
|
52
56
|
attribute :state, :string
|
53
|
-
|
57
|
+
|
58
|
+
# Returns true if there is a published version. Note that this includes drafts.
|
59
|
+
def published?
|
60
|
+
%w[published draft].include?(state)
|
61
|
+
end
|
62
|
+
|
63
|
+
def draft?
|
64
|
+
state == "draft"
|
65
|
+
end
|
66
|
+
|
67
|
+
def unpublished?
|
68
|
+
state == "unpublished"
|
69
|
+
end
|
54
70
|
|
55
71
|
# Find records by their state
|
56
72
|
scope :state, ->(values) do
|
@@ -98,11 +114,6 @@ module Katalyst
|
|
98
114
|
order(stmt.public_send(dir)).order(updated_at: dir)
|
99
115
|
end
|
100
116
|
|
101
|
-
# Returns true if there is a published version. Note that this includes drafts.
|
102
|
-
def published?
|
103
|
-
super || draft?
|
104
|
-
end
|
105
|
-
|
106
117
|
def state=(_)
|
107
118
|
raise NotImplementedError, "state cannot be set directly, use publish!, revert! etc"
|
108
119
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: katalyst-content
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Katalyst Interactive
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-09-
|
11
|
+
date: 2024-09-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -16,20 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
20
|
-
- - "<"
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: '7.2'
|
19
|
+
version: '0'
|
23
20
|
type: :runtime
|
24
21
|
prerelease: false
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
26
23
|
requirements:
|
27
24
|
- - ">="
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version: '
|
30
|
-
- - "<"
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: '7.2'
|
26
|
+
version: '0'
|
33
27
|
- !ruby/object:Gem::Dependency
|
34
28
|
name: active_storage_validations
|
35
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -219,7 +213,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
219
213
|
- !ruby/object:Gem::Version
|
220
214
|
version: '0'
|
221
215
|
requirements: []
|
222
|
-
rubygems_version: 3.5.
|
216
|
+
rubygems_version: 3.5.16
|
223
217
|
signing_key:
|
224
218
|
specification_version: 4
|
225
219
|
summary: Rich content page builder and editor
|