katalyst-content 2.5.0 → 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/models/concerns/katalyst/content/has_style.rb +37 -0
- data/app/models/katalyst/content/aside.rb +7 -0
- data/app/models/katalyst/content/item.rb +3 -1
- data/app/models/katalyst/content/types/style_type.rb +32 -0
- data/app/views/katalyst/content/asides/_aside.html+form.erb +5 -0
- data/app/views/katalyst/content/asides/_aside.html.erb +1 -1
- data/db/migrate/20240826042004_add_style_to_content_items.rb +7 -0
- data/lib/katalyst/content/engine.rb +4 -1
- data/lib/katalyst/content.rb +5 -5
- metadata +25 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 57fa137dad1c3a60f7f6689ef806fac3ae17a0dbb4fc21d2e1b4392e1bf47d7f
|
4
|
+
data.tar.gz: 5e528a67bcc761b93a639671132cd554b33b25632840aada6453af58b5866ff6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0785c75b21825b29dae88e7cec9ec3fe409e683a5a28ff08a9a27ada05129045409df9a0e07e52f23b6361d717b1562254a88151c03c23c4eab1c7caa3d659fe'
|
7
|
+
data.tar.gz: 95c86f1111d721bff45326298f256289032d0f4fae91d4d0302c3261c28c61cc5bf240241959e9dd05247b417c96581c14c08fea14598eadf5d6e79e39a60a21
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Katalyst
|
4
|
+
module Content
|
5
|
+
module HasStyle
|
6
|
+
extend ActiveSupport::Concern
|
7
|
+
|
8
|
+
# Style attribute allows items to define their own attributes for use in
|
9
|
+
# content styles. These attribute will be automatically mapped to json
|
10
|
+
# data which is stored and deserialized without needing to add columns.
|
11
|
+
class_methods do
|
12
|
+
def style_attributes(&)
|
13
|
+
style_class = Class.new(Katalyst::Content::HasStyle::StyleBase, &)
|
14
|
+
const_set(:Style, style_class)
|
15
|
+
attribute(:style, Katalyst::Content::Types::StyleType.new(style_class), default: -> { style_class.new })
|
16
|
+
|
17
|
+
style_class.attribute_names.each do |name|
|
18
|
+
define_method(name) { style.public_send(name) }
|
19
|
+
define_method(:"#{name}=") { |value| style.public_send(:"#{name}=", value) }
|
20
|
+
end
|
21
|
+
|
22
|
+
validate do
|
23
|
+
style.validate(validation_context)
|
24
|
+
style.errors.each do |error|
|
25
|
+
errors.add(error.attribute, error.type)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
class StyleBase
|
32
|
+
include ActiveModel::Model
|
33
|
+
include ActiveModel::Attributes
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -4,11 +4,13 @@ module Katalyst
|
|
4
4
|
module Content
|
5
5
|
# STI base class for content items
|
6
6
|
class Item < ApplicationRecord
|
7
|
+
include HasStyle
|
8
|
+
|
7
9
|
def self.config
|
8
10
|
Katalyst::Content.config
|
9
11
|
end
|
10
12
|
|
11
|
-
enum heading_style
|
13
|
+
enum :heading_style, config.heading_styles, prefix: :heading
|
12
14
|
|
13
15
|
belongs_to :container, polymorphic: true
|
14
16
|
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Katalyst
|
4
|
+
module Content
|
5
|
+
module Types
|
6
|
+
# Data serialization/deserialization for Katalyst::Content::Item style data
|
7
|
+
class StyleType < ActiveRecord::Type::Json
|
8
|
+
def initialize(type)
|
9
|
+
super()
|
10
|
+
|
11
|
+
@type = type
|
12
|
+
end
|
13
|
+
|
14
|
+
def serialize(value)
|
15
|
+
super(value.attributes)
|
16
|
+
end
|
17
|
+
|
18
|
+
def deserialize(value)
|
19
|
+
case value
|
20
|
+
when String
|
21
|
+
decoded = super
|
22
|
+
@type.new(**decoded) unless decoded.nil?
|
23
|
+
when Hash
|
24
|
+
@type.new(**value)
|
25
|
+
when HasStyle::StyleBase
|
26
|
+
value
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -1,11 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "
|
3
|
+
require "katalyst/html_attributes"
|
4
|
+
require "katalyst/kpop"
|
5
|
+
require "rails/engine"
|
4
6
|
|
5
7
|
module Katalyst
|
6
8
|
module Content
|
7
9
|
class Engine < ::Rails::Engine
|
8
10
|
isolate_namespace Katalyst::Content
|
11
|
+
config.eager_load_namespaces << Katalyst::Content
|
9
12
|
|
10
13
|
initializer "katalyst-content.factories", after: "factory_bot.set_factory_paths" do
|
11
14
|
FactoryBot.definition_file_paths << Engine.root.join("spec/factories") if defined?(FactoryBot)
|
data/lib/katalyst/content.rb
CHANGED
@@ -1,16 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "active_support"
|
4
|
-
require "katalyst/html_attributes"
|
5
|
-
require "katalyst/kpop"
|
6
|
-
|
7
|
-
require "katalyst/content/config"
|
8
|
-
require "katalyst/content/engine"
|
9
4
|
|
10
5
|
module Katalyst
|
11
6
|
module Content
|
7
|
+
extend ActiveSupport::Autoload
|
12
8
|
extend self
|
13
9
|
|
10
|
+
autoload :Config
|
11
|
+
|
14
12
|
def config
|
15
13
|
@config ||= Config.new
|
16
14
|
end
|
@@ -20,3 +18,5 @@ module Katalyst
|
|
20
18
|
end
|
21
19
|
end
|
22
20
|
end
|
21
|
+
|
22
|
+
require "katalyst/content/engine"
|
metadata
CHANGED
@@ -1,15 +1,35 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: katalyst-content
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.6.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-
|
11
|
+
date: 2024-08-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activerecord
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '7.0'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '7.2'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '7.0'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '7.2'
|
13
33
|
- !ruby/object:Gem::Dependency
|
14
34
|
name: active_storage_validations
|
15
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -128,6 +148,7 @@ files:
|
|
128
148
|
- app/javascript/content/editor/trix_controller.js
|
129
149
|
- app/models/concerns/katalyst/content/container.rb
|
130
150
|
- app/models/concerns/katalyst/content/garbage_collection.rb
|
151
|
+
- app/models/concerns/katalyst/content/has_style.rb
|
131
152
|
- app/models/concerns/katalyst/content/has_tree.rb
|
132
153
|
- app/models/concerns/katalyst/content/version.rb
|
133
154
|
- app/models/katalyst/content/aside.rb
|
@@ -142,6 +163,7 @@ files:
|
|
142
163
|
- app/models/katalyst/content/table.rb
|
143
164
|
- app/models/katalyst/content/tables/importer.rb
|
144
165
|
- app/models/katalyst/content/types/nodes_type.rb
|
166
|
+
- app/models/katalyst/content/types/style_type.rb
|
145
167
|
- app/views/active_storage/blobs/_blob.html.erb
|
146
168
|
- app/views/katalyst/content/asides/_aside.html+form.erb
|
147
169
|
- app/views/katalyst/content/asides/_aside.html.erb
|
@@ -172,6 +194,7 @@ files:
|
|
172
194
|
- db/migrate/20220913003839_create_katalyst_content_items.rb
|
173
195
|
- db/migrate/20220926061535_add_fields_for_figure_to_katalyst_content_items.rb
|
174
196
|
- db/migrate/20230515151440_change_katalyst_content_items_show_heading_column.rb
|
197
|
+
- db/migrate/20240826042004_add_style_to_content_items.rb
|
175
198
|
- lib/katalyst/content.rb
|
176
199
|
- lib/katalyst/content/config.rb
|
177
200
|
- lib/katalyst/content/engine.rb
|