katalyst-content 3.0.3 → 3.1.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 21f461f16b190c9c6cb7147c3ac17588a837b01726384bfa00795c416f83f369
4
- data.tar.gz: a21d83642982020ee92faed0df79c0811f8b4dc9b6af1b08e86cc2fc999ec656
3
+ metadata.gz: 3ba3b723f228e2f561064d4c6e42db46f7dad064163a4b6e44818ef9ef893e5f
4
+ data.tar.gz: 302430ededc05a9a227df3d07e8a4b60b25bc0ab213504e35fcedfd8c9c8d6fa
5
5
  SHA512:
6
- metadata.gz: a15304c5a37802474e1f332c05398aaaf726ba3f3afd7e9f19608895a0b4a39a5202bc96450e357d3f34ea59e1f534e6e7cbea924d20e2c93dd2fc9737775ead
7
- data.tar.gz: 34617f5e64ee96aac094dd1b7c6f4a866c27d4ca4e13b1b322f742c49db283d1371ab5e1c499f2aee10a199648cf9d7d8f500b994585eb179d4257fbf3e08b5a
6
+ metadata.gz: 557be5c1037ddb0563142b18027fc0d5e99be80d1c54e5198546fb2cf774f97b435baf4efb11d1df1005ac8ed477998e4b3a7bb8d835ef3f74a92e66fc22d00b
7
+ data.tar.gz: '08cab857ca6675464b13d5c616efc213bfa9d75e55819ab217a4aef95a7fd812f24c42357ed98980b1d49cc3202ab68a947749dd56996771edf212a84a1c6050'
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
 
@@ -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: :unprocessable_entity
12
+ render :update, locals: { item_editor: }, status: :unprocessable_content
13
13
  end
14
14
  end
15
15
  alias_method :create, :update
@@ -31,11 +31,11 @@ module Katalyst
31
31
  private
32
32
 
33
33
  def content_table_allowed_tags
34
- Katalyst::Content::Config.table_sanitizer_allowed_tags
34
+ Katalyst::Content.config.table_sanitizer_allowed_tags
35
35
  end
36
36
 
37
37
  def content_table_allowed_attributes
38
- Katalyst::Content::Config.table_sanitizer_allowed_attributes
38
+ Katalyst::Content.config.table_sanitizer_allowed_attributes
39
39
  end
40
40
 
41
41
  # rubocop:disable Rails/HelperInstanceVariable
@@ -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?
@@ -1,20 +1,27 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "active_support/configurable"
4
-
5
3
  module Katalyst
6
4
  module Content
7
5
  class Config
8
- include ActiveSupport::Configurable
6
+ attr_accessor :base_controller,
7
+ :default_theme,
8
+ :errors_component,
9
+ :heading_styles,
10
+ :image_mime_types,
11
+ :items,
12
+ :max_image_size,
13
+ :table_sanitizer_allowed_attributes,
14
+ :table_sanitizer_allowed_tags,
15
+ :themes
16
+
17
+ alias_attribute :backgrounds, :themes
9
18
 
10
- config_accessor(:themes) { %w[light dark] }
11
- config_accessor(:default_theme) { themes.first }
12
- alias_method :backgrounds, :themes
13
- alias_method :backgrounds=, :themes=
19
+ def initialize
20
+ self.themes = %w[light dark]
21
+ self.default_theme = themes.first
14
22
 
15
- config_accessor(:heading_styles) { %w[none default] }
16
- config_accessor(:items) do
17
- %w[
23
+ self.heading_styles = %w[none default]
24
+ self.items = %w[
18
25
  Katalyst::Content::Content
19
26
  Katalyst::Content::Figure
20
27
  Katalyst::Content::Table
@@ -23,21 +30,16 @@ module Katalyst
23
30
  Katalyst::Content::Column
24
31
  Katalyst::Content::Aside
25
32
  ]
26
- end
27
- config_accessor(:image_mime_types) { %w[image/png image/gif image/jpeg image/webp] }
28
- config_accessor(:max_image_size) { 20 }
33
+ self.image_mime_types = %w[image/png image/gif image/jpeg image/webp]
34
+ self.max_image_size = 20
35
+ self.errors_component = "Katalyst::Content::Editor::ErrorsComponent"
29
36
 
30
- # Components
31
- config_accessor(:errors_component) { "Katalyst::Content::Editor::ErrorsComponent" }
37
+ self.base_controller = "ApplicationController"
32
38
 
33
- config_accessor(:base_controller) { "ApplicationController" }
34
-
35
- # Sanitizer
36
- config_accessor(:table_sanitizer_allowed_tags) do
37
- %w[table thead tbody tr th td caption a strong em span br p text].freeze
38
- end
39
- config_accessor(:table_sanitizer_allowed_attributes) do
40
- %w[colspan rowspan href].freeze
39
+ # Sanitizer
40
+ self.table_sanitizer_allowed_tags = %w[table thead tbody tr th td caption a strong em span br p
41
+ text].freeze
42
+ self.table_sanitizer_allowed_attributes = %w[colspan rowspan href].freeze
41
43
  end
42
44
  end
43
45
  end
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.0.3
4
+ version: 3.1.1
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: 3.6.9
231
+ rubygems_version: 4.0.3
232
232
  specification_version: 4
233
233
  summary: Rich content page builder and editor
234
234
  test_files: []