katalyst-content 3.1.0 → 3.1.2
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/README.md +29 -0
- data/app/assets/stylesheets/katalyst/content/frontend/frontend.css +2 -6
- data/app/components/katalyst/content/editor/base_component.rb +1 -1
- data/app/controllers/katalyst/content/items_controller.rb +3 -3
- data/app/controllers/katalyst/content/tables_controller.rb +1 -1
- data/app/helpers/katalyst/content/table_helper.rb +2 -2
- data/app/models/concerns/katalyst/content/container.rb +2 -5
- data/app/models/concerns/katalyst/content/has_tree.rb +2 -2
- data/app/models/concerns/katalyst/content/version.rb +1 -1
- data/app/models/katalyst/content/layout.rb +5 -0
- data/app/models/katalyst/content/tables/importer.rb +5 -5
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5e38cbf36ab348007822df1209895dd018187732543a5e30a415b45c6c76eea2
|
|
4
|
+
data.tar.gz: 1594f99bc385122dec95d1193579de7f7405981233fdff7d304f8628295883fc
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5881d775194f04bb5ac2b53b7585281661c5633306cbf91dbae7c08853ee1e5eba22c92366c65152836543c3c01bbd0952610c77330a2630d0f9cd4c776a9842
|
|
7
|
+
data.tar.gz: 425ca40e2cd4b354e792e09a25dc6ec3cd0a99a4725ee5ce862f7ff9886d4d07fe161882be1a5c209dc5137cd09ef1b2412769a9883c7482a93f83e16fb8866b
|
data/README.md
CHANGED
|
@@ -78,6 +78,35 @@ class CreatePageVersions < ActiveRecord::Migration[7.0]
|
|
|
78
78
|
end
|
|
79
79
|
```
|
|
80
80
|
|
|
81
|
+
If you don't have a pages model yet, add it before the page_versions change:
|
|
82
|
+
```ruby
|
|
83
|
+
class CreatePages < ActiveRecord::Migration[7.0]
|
|
84
|
+
def change
|
|
85
|
+
create_table :pages do |t|
|
|
86
|
+
t.string :title
|
|
87
|
+
t.string :slug
|
|
88
|
+
t.boolean :show_title, default: true, null: false
|
|
89
|
+
|
|
90
|
+
t.timestamps
|
|
91
|
+
end
|
|
92
|
+
add_index :pages, :slug, unique: true
|
|
93
|
+
|
|
94
|
+
create_table :page_versions do |t|
|
|
95
|
+
t.references :parent, foreign_key: { to_table: :pages }, null: false
|
|
96
|
+
t.json :nodes
|
|
97
|
+
|
|
98
|
+
t.timestamps
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
change_table :pages do |t|
|
|
102
|
+
t.references :published_version, foreign_key: { to_table: :page_versions }
|
|
103
|
+
t.references :draft_version, foreign_key: { to_table: :page_versions }
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
|
|
81
110
|
Next, include the `Katalyst::Content` concerns into your model, and add a nested
|
|
82
111
|
model for storing content version information:
|
|
83
112
|
|
|
@@ -34,22 +34,18 @@
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
.content-item [data-content-theme] {
|
|
37
|
+
background: var(--background, unset);
|
|
38
|
+
color: var(--text-color);
|
|
37
39
|
padding-inline: var(--content-inline-gutter);
|
|
38
40
|
}
|
|
39
41
|
|
|
40
42
|
[data-content-theme="light"] {
|
|
41
|
-
background: var(--background, var(--background-color));
|
|
42
|
-
color: var(--text-color);
|
|
43
|
-
|
|
44
43
|
--text-color: var(--color-dark, black);
|
|
45
44
|
--background: var(--color-light, black);
|
|
46
45
|
--link-color: var(--color-dark, black);
|
|
47
46
|
}
|
|
48
47
|
|
|
49
48
|
[data-content-theme="dark"] {
|
|
50
|
-
background: var(--background, var(--background-color));
|
|
51
|
-
color: var(--text-color);
|
|
52
|
-
|
|
53
49
|
--text-color: var(--color-light, white);
|
|
54
50
|
--background: var(--color-dark, black);
|
|
55
51
|
--link-color: var(--color-light, white);
|
|
@@ -50,7 +50,7 @@ module Katalyst
|
|
|
50
50
|
|
|
51
51
|
def item_params_type
|
|
52
52
|
requested_type = params.require(:item).fetch(:type, "")
|
|
53
|
-
if (type
|
|
53
|
+
if (type = Katalyst::Content.config.items.find { |t| t == requested_type })
|
|
54
54
|
type.safe_constantize
|
|
55
55
|
else
|
|
56
56
|
Item
|
|
@@ -70,9 +70,9 @@ module Katalyst
|
|
|
70
70
|
end
|
|
71
71
|
|
|
72
72
|
def set_item
|
|
73
|
-
@item = Item.find(params
|
|
73
|
+
@item = Item.find(params.expect(:id))
|
|
74
74
|
@container = @item.container
|
|
75
|
-
@editor
|
|
75
|
+
@editor = Katalyst::Content::EditorComponent.new(container:, item:)
|
|
76
76
|
end
|
|
77
77
|
|
|
78
78
|
def set_editor_variant
|
|
@@ -9,7 +9,7 @@ module Katalyst
|
|
|
9
9
|
if item.valid?
|
|
10
10
|
render :update, locals: { item_editor: }
|
|
11
11
|
else
|
|
12
|
-
render :update, locals: { item_editor: }, status: :
|
|
12
|
+
render :update, locals: { item_editor: }, status: :unprocessable_content
|
|
13
13
|
end
|
|
14
14
|
end
|
|
15
15
|
alias_method :create, :update
|
|
@@ -53,7 +53,7 @@ module Katalyst
|
|
|
53
53
|
|
|
54
54
|
return unless @node
|
|
55
55
|
|
|
56
|
-
@heading_rows
|
|
56
|
+
@heading_rows = @table.heading_rows.clamp(0..css("tr").length)
|
|
57
57
|
@heading_columns = @table.heading_columns.clamp(0..)
|
|
58
58
|
end
|
|
59
59
|
|
|
@@ -94,7 +94,7 @@ module Katalyst
|
|
|
94
94
|
# e.g. colspan=2 rowspan=3 would occupy 6 cells
|
|
95
95
|
row_range(cell, y).each do |ty|
|
|
96
96
|
col_range(cell, x).each do |tx|
|
|
97
|
-
matrix[ty]
|
|
97
|
+
matrix[ty] ||= []
|
|
98
98
|
matrix[ty][tx] = cell.text
|
|
99
99
|
end
|
|
100
100
|
end
|
|
@@ -49,11 +49,8 @@ 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)
|
|
56
52
|
attribute :state, :string
|
|
53
|
+
enum :state, %i[published draft unpublished].index_with(&:to_s)
|
|
57
54
|
|
|
58
55
|
# Returns true if there is a published version. Note that this includes drafts.
|
|
59
56
|
def published?
|
|
@@ -154,7 +151,7 @@ module Katalyst
|
|
|
154
151
|
private
|
|
155
152
|
|
|
156
153
|
def unset_versions
|
|
157
|
-
self.draft_version_id
|
|
154
|
+
self.draft_version_id = nil
|
|
158
155
|
self.published_version_id = nil
|
|
159
156
|
save!(validate: false)
|
|
160
157
|
end
|
|
@@ -57,7 +57,7 @@ module Katalyst
|
|
|
57
57
|
|
|
58
58
|
# Add node to the top of builder stacks
|
|
59
59
|
def push(node)
|
|
60
|
-
self.depth
|
|
60
|
+
self.depth += 1
|
|
61
61
|
self.current = node
|
|
62
62
|
self.children = node.children = []
|
|
63
63
|
node
|
|
@@ -65,7 +65,7 @@ module Katalyst
|
|
|
65
65
|
|
|
66
66
|
# Remove current from builder stack
|
|
67
67
|
def pop
|
|
68
|
-
previous
|
|
68
|
+
previous = current
|
|
69
69
|
self.depth -= 1
|
|
70
70
|
if depth.zero?
|
|
71
71
|
self.current = nil
|
|
@@ -77,7 +77,7 @@ module Katalyst
|
|
|
77
77
|
|
|
78
78
|
def header_row_caption?
|
|
79
79
|
!at_css("caption") &&
|
|
80
|
-
(tr
|
|
80
|
+
(tr = at_css("thead > tr:first-child"))&.elements&.one? &&
|
|
81
81
|
(colspan = tr.elements.first.attributes["colspan"]&.value) &&
|
|
82
82
|
colspan.to_i > 1
|
|
83
83
|
end
|
|
@@ -130,10 +130,10 @@ module Katalyst
|
|
|
130
130
|
|
|
131
131
|
# Promotes the first row to a caption if it only has one cell.
|
|
132
132
|
def promote_header_row_caption!
|
|
133
|
-
tr
|
|
134
|
-
cell
|
|
133
|
+
tr = at_css("thead > tr:first-child")
|
|
134
|
+
cell = tr.elements.first
|
|
135
135
|
tr.remove
|
|
136
|
-
thead
|
|
136
|
+
thead = at_css("thead")
|
|
137
137
|
thead.before("<caption></caption>")
|
|
138
138
|
thead.remove if thead.elements.empty?
|
|
139
139
|
at_css("caption").inner_html = cell.inner_html.strip
|
|
@@ -141,7 +141,7 @@ module Katalyst
|
|
|
141
141
|
|
|
142
142
|
# Set heading from caption and remove the caption from the table.
|
|
143
143
|
def set_heading!
|
|
144
|
-
caption
|
|
144
|
+
caption = at_css("caption")
|
|
145
145
|
table.heading = caption.text.strip
|
|
146
146
|
table.heading_style = "default"
|
|
147
147
|
caption.remove
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: katalyst-content
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.1.
|
|
4
|
+
version: 3.1.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Katalyst Interactive
|
|
@@ -228,7 +228,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
228
228
|
- !ruby/object:Gem::Version
|
|
229
229
|
version: '0'
|
|
230
230
|
requirements: []
|
|
231
|
-
rubygems_version:
|
|
231
|
+
rubygems_version: 4.0.10
|
|
232
232
|
specification_version: 4
|
|
233
233
|
summary: Rich content page builder and editor
|
|
234
234
|
test_files: []
|