katalyst-content 1.0.2 → 1.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: 433c0f1ad7f53e425f5feaeacde9ad27ec1303062aeda91dcae10e8ef326679c
4
- data.tar.gz: f49acc4f588d226dddca67f181604605b44f353d67e0a38c5d7a578e1c835c9a
3
+ metadata.gz: 87e4bd83eeac48370da7a9d48165db46776c97be76b76e08fccf16f7b3890493
4
+ data.tar.gz: ab1893973d8a60e5db8eddfaab2fe7251f7df21b7bcb2e5ba34f5408bf438d3a
5
5
  SHA512:
6
- metadata.gz: bd55fbd95ac4e58a8e6860b3f278f4b17fd1752ec777b4ce1cbfc7fe9998155ff5c7b8cbc409e60d4cd33ed824390e3d5f9efe5d098d332e41965502e3095724
7
- data.tar.gz: a0c9151ed9800288dd8a8b56ed121e523a9cca2bcc64c73ff58368ce2c32c87738539fad679816bdfb3c431eaf90b9f8c098057f83e0b60c92590b4af528fe54
6
+ metadata.gz: a0ea63540fe34c71e88405905054b5ed27d36d7232583f5fe5270d2daf1b40ce7c0a27d42a7fc0d6963c44f1353147d251d406ae1d4cdc4f4d231bfac49d6167
7
+ data.tar.gz: 2e41d43a9122257aab1df8c274c7ad09a77e253a48a0c34157fcd08d74ecafd4cc6a113d54cb56f2bc6bf44a53ac9f31755dbc5e835d842ec09d83f6145cc778
@@ -1,5 +1,10 @@
1
1
  import { Controller } from "@hotwired/stimulus";
2
- import Trix from "trix";
2
+ import "trix";
3
+
4
+ // Note, action_text 7.1.2 changes how Trix is bundled and loaded. This
5
+ // seems to have broken the default export from trix. This is a workaround
6
+ // that relies on the backwards compatibility of the old export to window.Trix.
7
+ const Trix = window.Trix;
3
8
 
4
9
  // Stimulus controller doesn't do anything, but having one ensures that trix
5
10
  // will be lazy loaded when a trix-editor is added to the dom.
@@ -5,7 +5,7 @@ module Katalyst
5
5
  module EditorHelper
6
6
  def content_editor_new_items(container:)
7
7
  Katalyst::Content.config.items.map do |item_class|
8
- item_class = item_class.is_a?(String) ? item_class.safe_constantize : item_class
8
+ item_class = item_class.safe_constantize if item_class.is_a?(String)
9
9
  item_class.new(container: container)
10
10
  end
11
11
  end
@@ -55,8 +55,8 @@ module Katalyst
55
55
  defaults.deep_merge(options)
56
56
  end
57
57
 
58
- def content_editor_image_field(item:, method:, **options, &block)
59
- Editor::ImageField.new(self, item.container).build(item, method, **options, &block)
58
+ def content_editor_image_field(...)
59
+ Editor::ImageField.new(self, item.container).build(...)
60
60
  end
61
61
 
62
62
  # When rendering item forms do not include the controller namespace prefix (katalyst/content)
@@ -25,8 +25,8 @@ module Katalyst
25
25
  end
26
26
  end
27
27
 
28
- def content_item_tag(item, **options, &block)
29
- FrontendBuilder.new(self, item).render(**options, &block)
28
+ def content_item_tag(item, ...)
29
+ FrontendBuilder.new(self, item).render(...)
30
30
  end
31
31
 
32
32
  private
@@ -26,7 +26,7 @@ module Katalyst
26
26
  end
27
27
 
28
28
  def self.permitted_params
29
- super - %i[show_heading] + %i[image caption]
29
+ super - %i[heading_style] + %i[image caption]
30
30
  end
31
31
 
32
32
  alias_attribute :alt, :heading
@@ -8,12 +8,16 @@ module Katalyst
8
8
  Katalyst::Content.config
9
9
  end
10
10
 
11
+ enum heading_style: config.heading_styles, _prefix: :heading
12
+
11
13
  belongs_to :container, polymorphic: true
12
14
 
13
15
  validates :heading, presence: true
16
+ validates :heading_style, inclusion: { in: config.heading_styles }
14
17
  validates :background, presence: true, inclusion: { in: config.backgrounds }, if: :validate_background?
15
18
 
16
19
  after_initialize :initialize_tree
20
+ before_validation :set_defaults
17
21
 
18
22
  attr_accessor :parent, :children, :index, :depth
19
23
 
@@ -23,7 +27,7 @@ module Katalyst
23
27
  container_id
24
28
  type
25
29
  heading
26
- show_heading
30
+ heading_style
27
31
  background
28
32
  visible
29
33
  ]
@@ -33,6 +37,14 @@ module Katalyst
33
37
  heading if show_heading? && visible?
34
38
  end
35
39
 
40
+ def show_heading?
41
+ !heading_none?
42
+ end
43
+
44
+ def heading_style_class
45
+ heading_style unless heading_default?
46
+ end
47
+
36
48
  def layout?
37
49
  is_a? Layout
38
50
  end
@@ -44,6 +56,10 @@ module Katalyst
44
56
  self.children ||= []
45
57
  end
46
58
 
59
+ def set_defaults
60
+ self.heading_style = "none" if heading_style.blank?
61
+ end
62
+
47
63
  def validate_background?
48
64
  true
49
65
  end
@@ -8,8 +8,8 @@
8
8
  </div>
9
9
 
10
10
  <div class="field">
11
- <%= form.label :show_heading %>
12
- <%= form.check_box :show_heading %>
11
+ <%= form.label :heading_style %>
12
+ <%= form.collection_radio_buttons :heading_style, Katalyst::Content.config.heading_styles, :itself, :itself %>
13
13
  </div>
14
14
 
15
15
  <div class="field">
@@ -1,5 +1,5 @@
1
1
  <%= content_item_tag aside do %>
2
- <%= tag.h3 aside.heading if aside.show_heading? %>
2
+ <%= tag.h3 aside.heading, class: aside.heading_style_class if aside.show_heading? %>
3
3
 
4
4
  <% items = aside.children.select(&:visible?) %>
5
5
  <% last = items.pop %>
@@ -8,8 +8,8 @@
8
8
  </div>
9
9
 
10
10
  <div class="field">
11
- <%= form.label :show_heading %>
12
- <%= form.check_box :show_heading %>
11
+ <%= form.label :heading_style %>
12
+ <%= form.collection_radio_buttons :heading_style, Katalyst::Content.config.heading_styles, :itself, :itself %>
13
13
  </div>
14
14
 
15
15
  <div class="field">
@@ -1,14 +1,18 @@
1
1
  <%= content_item_tag column do %>
2
- <%= tag.h3 column.heading if column.show_heading? %>
2
+ <%= tag.h3 column.heading, class: column.heading_style_class if column.show_heading? %>
3
3
 
4
4
  <% items = column.children.select(&:visible?) %>
5
5
  <% last = items.pop %>
6
6
  <div class="columns-container">
7
7
  <div class="column">
8
- <%= render_content_items items %>
8
+ <% if items.any? %>
9
+ <%= render_content_items items %>
10
+ <% elsif last %>
11
+ <%= render_content_items [last] %>
12
+ <% end %>
9
13
  </div>
10
14
  <div class="column">
11
- <%= render_content_items [last] if last %>
15
+ <%= render_content_items [last] if last && items.any? %>
12
16
  </div>
13
17
  </div>
14
18
  <% end %>
@@ -8,8 +8,8 @@
8
8
  </div>
9
9
 
10
10
  <div class="field">
11
- <%= form.label :show_heading %>
12
- <%= form.check_box :show_heading %>
11
+ <%= form.label :heading_style %>
12
+ <%= form.collection_radio_buttons :heading_style, Katalyst::Content.config.heading_styles, :itself, :itself %>
13
13
  </div>
14
14
 
15
15
  <div class="field">
@@ -1,5 +1,5 @@
1
1
  <%= content_item_tag content do %>
2
- <%= tag.h3 content.heading if content.show_heading? %>
2
+ <%= tag.h3 content.heading, class: content.heading_style_class if content.show_heading? %>
3
3
 
4
4
  <%= content.content %>
5
5
  <% end %>
@@ -8,8 +8,8 @@
8
8
  </div>
9
9
 
10
10
  <div class="field">
11
- <%= form.label :show_heading %>
12
- <%= form.check_box :show_heading %>
11
+ <%= form.label :heading_style %>
12
+ <%= form.collection_radio_buttons :heading_style, Katalyst::Content.config.heading_styles, :itself, :itself %>
13
13
  </div>
14
14
 
15
15
  <div class="field">
@@ -1,5 +1,5 @@
1
1
  <%= content_item_tag group do %>
2
- <%= tag.h3 group.heading if group.show_heading? %>
2
+ <%= tag.h3 group.heading, class: group.heading_style_class if group.show_heading? %>
3
3
 
4
4
  <div>
5
5
  <%= render_content_items group.children %>
@@ -8,8 +8,8 @@
8
8
  </div>
9
9
 
10
10
  <div class="field">
11
- <%= form.label :show_heading %>
12
- <%= form.check_box :show_heading %>
11
+ <%= form.label :heading_style %>
12
+ <%= form.collection_radio_buttons :heading_style, Katalyst::Content.config.heading_styles, :itself, :itself %>
13
13
  </div>
14
14
 
15
15
  <div class="field">
@@ -8,8 +8,8 @@
8
8
  </div>
9
9
 
10
10
  <div class="field">
11
- <%= form.label :show_heading %>
12
- <%= form.check_box :show_heading %>
11
+ <%= form.label :heading_style %>
12
+ <%= form.collection_radio_buttons :heading_style, Katalyst::Content.config.heading_styles, :itself, :itself %>
13
13
  </div>
14
14
 
15
15
  <div class="field">
@@ -1,5 +1,5 @@
1
1
  <%= content_item_tag section do %>
2
- <%= tag.h2 section.heading if section.show_heading? %>
2
+ <%= tag.h2 section.heading, class: section.heading_style_class if section.show_heading? %>
3
3
 
4
4
  <div>
5
5
  <%= render_content_items section.children %>
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ class ChangeKatalystContentItemsShowHeadingColumn < ActiveRecord::Migration[7.0]
4
+ def up
5
+ add_column :katalyst_content_items, :heading_style, :integer, null: false, default: 0
6
+ Katalyst::Content::Item.where(show_heading: true).update_all(heading_style: 1)
7
+ remove_column :katalyst_content_items, :show_heading, :boolean
8
+ end
9
+
10
+ def down
11
+ raise ActiveRecord::IrreversibleMigration
12
+ end
13
+ end
@@ -8,6 +8,7 @@ module Katalyst
8
8
  include ActiveSupport::Configurable
9
9
 
10
10
  config_accessor(:backgrounds) { %w[light dark] }
11
+ config_accessor(:heading_styles) { %w[none default] }
11
12
  config_accessor(:items) do
12
13
  %w[
13
14
  Katalyst::Content::Content
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Katalyst
4
4
  module Content
5
- VERSION = "1.0.2"
5
+ VERSION = "1.1.1"
6
6
  end
7
7
  end
@@ -3,7 +3,7 @@
3
3
  FactoryBot.define do
4
4
  trait :content_item_defaults do
5
5
  heading { Faker::Lorem.word }
6
- show_heading { true }
6
+ heading_style { "default" }
7
7
  background { Katalyst::Content.config.backgrounds.sample }
8
8
  depth { 0 }
9
9
  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: 1.0.2
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Katalyst Interactive
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-05-15 00:00:00.000000000 Z
11
+ date: 2023-11-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_storage_validations
@@ -108,6 +108,7 @@ files:
108
108
  - config/routes.rb
109
109
  - db/migrate/20220913003839_create_katalyst_content_items.rb
110
110
  - db/migrate/20220926061535_add_fields_for_figure_to_katalyst_content_items.rb
111
+ - db/migrate/20230515151440_change_katalyst_content_items_show_heading_column.rb
111
112
  - lib/katalyst/content.rb
112
113
  - lib/katalyst/content/config.rb
113
114
  - lib/katalyst/content/engine.rb
@@ -133,7 +134,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
133
134
  - !ruby/object:Gem::Version
134
135
  version: '0'
135
136
  requirements: []
136
- rubygems_version: 3.3.7
137
+ rubygems_version: 3.4.20
137
138
  signing_key:
138
139
  specification_version: 4
139
140
  summary: Rich content page builder and editor