katalyst-content 0.1.1 → 0.2.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.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/controllers/content/editor/container_controller.js +2 -4
  3. data/app/assets/javascripts/controllers/content/editor/image_field_controller.js +90 -0
  4. data/app/assets/javascripts/controllers/content/editor/trix_controller.js +78 -0
  5. data/app/assets/javascripts/utils/content/editor/item.js +34 -10
  6. data/app/assets/javascripts/utils/content/editor/rules-engine.js +74 -31
  7. data/app/assets/stylesheets/katalyst/content/_index.scss +0 -30
  8. data/app/assets/stylesheets/katalyst/content/editor/_figure.scss +12 -0
  9. data/app/assets/stylesheets/katalyst/content/editor/_index.scss +38 -4
  10. data/app/assets/stylesheets/katalyst/content/editor/_item-actions.scss +24 -6
  11. data/app/assets/stylesheets/katalyst/content/editor/_new-items.scss +21 -1
  12. data/app/assets/stylesheets/katalyst/content/editor/_status-bar.scss +10 -0
  13. data/app/assets/stylesheets/katalyst/content/editor/_trix-rails.scss +30 -0
  14. data/app/controllers/katalyst/content/direct_uploads_controller.rb +8 -0
  15. data/app/controllers/katalyst/content/items_controller.rb +1 -1
  16. data/app/helpers/katalyst/content/editor/base.rb +1 -0
  17. data/app/helpers/katalyst/content/editor/container.rb +0 -4
  18. data/app/helpers/katalyst/content/editor/image_field.rb +72 -0
  19. data/app/helpers/katalyst/content/editor/status_bar.rb +12 -3
  20. data/app/helpers/katalyst/content/editor_helper.rb +20 -0
  21. data/app/helpers/katalyst/content/frontend_helper.rb +59 -0
  22. data/app/models/concerns/katalyst/content/container.rb +33 -6
  23. data/app/models/concerns/katalyst/content/version.rb +4 -0
  24. data/app/{helpers/katalyst/content/application_helper.rb → models/katalyst/content/aside.rb} +1 -1
  25. data/app/models/katalyst/content/column.rb +8 -0
  26. data/app/models/katalyst/content/content.rb +4 -0
  27. data/app/models/katalyst/content/figure.rb +41 -0
  28. data/app/models/katalyst/content/group.rb +8 -0
  29. data/app/models/katalyst/content/item.rb +13 -1
  30. data/app/models/katalyst/content/layout.rb +8 -0
  31. data/app/models/katalyst/content/section.rb +8 -0
  32. data/app/views/active_storage/blobs/_blob.html.erb +1 -1
  33. data/app/views/katalyst/content/asides/_aside.html+form.erb +27 -0
  34. data/app/views/katalyst/content/asides/_aside.html.erb +14 -0
  35. data/app/views/katalyst/content/columns/_column.html+form.erb +27 -0
  36. data/app/views/katalyst/content/columns/_column.html.erb +14 -0
  37. data/app/views/katalyst/content/contents/_content.html+form.erb +3 -10
  38. data/app/views/katalyst/content/contents/_content.html.erb +3 -3
  39. data/app/views/katalyst/content/editor/_item.html.erb +1 -1
  40. data/app/views/katalyst/content/editor/_list_item.html.erb +1 -0
  41. data/app/views/katalyst/content/figures/_figure.html+form.erb +38 -0
  42. data/app/views/katalyst/content/figures/_figure.html.erb +4 -0
  43. data/app/views/katalyst/content/groups/_group.html+form.erb +27 -0
  44. data/app/views/katalyst/content/groups/_group.html.erb +7 -0
  45. data/app/views/katalyst/content/items/_form_errors.html.erb +5 -0
  46. data/app/views/katalyst/content/items/_hidden_fields.html.erb +3 -0
  47. data/app/views/katalyst/content/items/_item.html+form.erb +2 -9
  48. data/app/views/katalyst/content/items/_item.html.erb +3 -3
  49. data/app/views/katalyst/content/sections/_section.html+form.erb +27 -0
  50. data/app/views/katalyst/content/sections/_section.html.erb +7 -0
  51. data/config/locales/en.yml +13 -0
  52. data/config/routes.rb +1 -0
  53. data/db/migrate/20220926061535_add_fields_for_figure_to_katalyst_content_items.rb +7 -0
  54. data/lib/katalyst/content/config.rb +7 -0
  55. data/lib/katalyst/content/version.rb +1 -1
  56. data/spec/factories/katalyst/content/items.rb +30 -4
  57. metadata +43 -4
@@ -1,13 +1,6 @@
1
1
  <%= form_with model: content, scope: :item, url: path do |form| %>
2
- <%= form.hidden_field :container_type %>
3
- <%= form.hidden_field :container_id %>
4
- <%= form.hidden_field :type %>
5
-
6
- <%= tag.div class: "errors" do %>
7
- <% content.errors.full_messages.each do |error| %>
8
- <li class="error"><%= error %></li>
9
- <% end %>
10
- <% end if content.errors.any? %>
2
+ <%= render "hidden_fields", form: form %>
3
+ <%= render "form_errors", form: form %>
11
4
 
12
5
  <div class="field">
13
6
  <%= form.label :heading %>
@@ -31,7 +24,7 @@
31
24
 
32
25
  <div class="field">
33
26
  <%= form.label :content %>
34
- <%= form.rich_text_area :content %>
27
+ <%= form.rich_text_area :content, content_editor_rich_text_options %>
35
28
  </div>
36
29
 
37
30
  <%= form.submit "Done" %>
@@ -1,5 +1,5 @@
1
- <div class="<%= content.background %>">
2
- <%= tag.h2 content.heading if content.show_heading? %>
1
+ <%= content_item_tag content do %>
2
+ <%= tag.h3 content.heading if content.show_heading? %>
3
3
 
4
4
  <%= content.content %>
5
- </div>
5
+ <% end %>
@@ -7,7 +7,7 @@
7
7
  <span role="img" value="invisible" title="Hidden"></span>
8
8
  </div>
9
9
 
10
- <div class="item-background-<%= item.background %>">
10
+ <div class="item-background <%= item.background %>">
11
11
  </div>
12
12
 
13
13
  <%= builder.item_actions %>
@@ -3,6 +3,7 @@
3
3
  data-content-item-id="<%= item.id %>"
4
4
  data-content-index="<%= item.index %>"
5
5
  data-content-depth="<%= item.depth %>"
6
+ <%= "data-content-layout" if item.layout? %>
6
7
  data-deny-de-nest
7
8
  data-deny-nest
8
9
  data-deny-collapse
@@ -0,0 +1,38 @@
1
+ <%= form_with model: figure, scope: :item, url: path do |form| %>
2
+ <%= render "hidden_fields", form: form %>
3
+ <%= render "form_errors", form: form %>
4
+
5
+ <%= content_editor_image_field item: figure, method: :image do |builder| %>
6
+ <div class="field">
7
+ <%= form.label :image %>
8
+ <div>
9
+ <%= builder.preview class: "image-wrapper" %>
10
+ </div>
11
+ <%= form.file_field :image, **builder.file_input_options %>
12
+ <hint><%= builder.hint_text %></hint>
13
+ </div>
14
+ <% end %>
15
+
16
+ <div class="field">
17
+ <%= form.label :heading %>
18
+ <%= form.text_field :heading %>
19
+ </div>
20
+
21
+ <div class="field">
22
+ <%= form.label :background %>
23
+ <%= form.select :background, Katalyst::Content.config.backgrounds %>
24
+ </div>
25
+
26
+ <div class="field">
27
+ <%= form.label :visible %>
28
+ <%= form.check_box :visible %>
29
+ </div>
30
+
31
+ <div class="field">
32
+ <%= form.label :caption %>
33
+ <%= form.text_field :caption %>
34
+ </div>
35
+
36
+ <%= form.submit "Done" %>
37
+ <%= link_to "Discard", :back %>
38
+ <% end %>
@@ -0,0 +1,4 @@
1
+ <%= content_item_tag figure do %>
2
+ <%= image_tag figure.image, alt: figure.alt %>
3
+ <%= tag.figcaption figure.caption if figure.caption.present? %>
4
+ <% end %>
@@ -0,0 +1,27 @@
1
+ <%= form_with model: group, scope: :item, url: path do |form| %>
2
+ <%= render "hidden_fields", form: form %>
3
+ <%= render "form_errors", form: form %>
4
+
5
+ <div class="field">
6
+ <%= form.label :heading %>
7
+ <%= form.text_field :heading %>
8
+ </div>
9
+
10
+ <div class="field">
11
+ <%= form.label :show_heading %>
12
+ <%= form.check_box :show_heading %>
13
+ </div>
14
+
15
+ <div class="field">
16
+ <%= form.label :background %>
17
+ <%= form.select :background, Katalyst::Content.config.backgrounds %>
18
+ </div>
19
+
20
+ <div class="field">
21
+ <%= form.label :visible %>
22
+ <%= form.check_box :visible %>
23
+ </div>
24
+
25
+ <%= form.submit "Done" %>
26
+ <%= link_to "Discard", :back %>
27
+ <% end %>
@@ -0,0 +1,7 @@
1
+ <%= content_item_tag group do %>
2
+ <%= tag.h3 group.heading if group.show_heading? %>
3
+
4
+ <div>
5
+ <%= render_content_items group.children %>
6
+ </div>
7
+ <% end %>
@@ -0,0 +1,5 @@
1
+ <%= tag.ul class: "errors" do %>
2
+ <% form.object.errors.full_messages.each do |error| %>
3
+ <li class="error"><%= error %></li>
4
+ <% end %>
5
+ <% end if form.object.errors.any? %>
@@ -0,0 +1,3 @@
1
+ <%= form.hidden_field :container_type %>
2
+ <%= form.hidden_field :container_id %>
3
+ <%= form.hidden_field :type %>
@@ -1,13 +1,6 @@
1
1
  <%= form_with model: item, scope: :item, url: path do |form| %>
2
- <%= form.hidden_field :container_type %>
3
- <%= form.hidden_field :container_id %>
4
- <%= form.hidden_field :type %>
5
-
6
- <%= tag.div class: "errors" do %>
7
- <% item.errors.full_messages.each do |error| %>
8
- <li class="error"><%= error %></li>
9
- <% end %>
10
- <% end if item.errors.any? %>
2
+ <%= render "hidden_fields", form: form %>
3
+ <%= render "form_errors", form: form %>
11
4
 
12
5
  <div class="field">
13
6
  <%= form.label :heading %>
@@ -1,3 +1,3 @@
1
- <div class="<%= item.background %>">
2
- <%= tag.h2 item.heading if item.show_heading? %>
3
- </div>
1
+ <%= content_item_tag item do %>
2
+ <%= tag.h3 item.heading if item.show_heading? %>
3
+ <% end %>
@@ -0,0 +1,27 @@
1
+ <%= form_with model: section, scope: :item, url: path do |form| %>
2
+ <%= render "hidden_fields", form: form %>
3
+ <%= render "form_errors", form: form %>
4
+
5
+ <div class="field">
6
+ <%= form.label :heading %>
7
+ <%= form.text_field :heading %>
8
+ </div>
9
+
10
+ <div class="field">
11
+ <%= form.label :show_heading %>
12
+ <%= form.check_box :show_heading %>
13
+ </div>
14
+
15
+ <div class="field">
16
+ <%= form.label :background %>
17
+ <%= form.select :background, Katalyst::Content.config.backgrounds %>
18
+ </div>
19
+
20
+ <div class="field">
21
+ <%= form.label :visible %>
22
+ <%= form.check_box :visible %>
23
+ </div>
24
+
25
+ <%= form.submit "Done" %>
26
+ <%= link_to "Discard", :back %>
27
+ <% end %>
@@ -0,0 +1,7 @@
1
+ <%= content_item_tag section do %>
2
+ <%= tag.h2 section.heading if section.show_heading? %>
3
+
4
+ <div>
5
+ <%= render_content_items section.children %>
6
+ </div>
7
+ <% end %>
@@ -1,4 +1,13 @@
1
1
  en:
2
+ activerecord:
3
+ attributes:
4
+ katalyst/content/figure:
5
+ heading: "Alternate text"
6
+ errors:
7
+ models:
8
+ katalyst/content/item:
9
+ content_type_invalid: file type not supported
10
+ file_size_out_of_range: must be less than %{max_size}
2
11
  views:
3
12
  katalyst:
4
13
  content:
@@ -8,5 +17,9 @@ en:
8
17
  discard: Discard
9
18
  publish: Publish
10
19
  published_html: Published <i>(last updated %{last_update})</i>
20
+ unpublished_html: Unpublished
11
21
  revert: Revert
12
22
  save: Save
23
+ item:
24
+ size_hint:
25
+ Must be less than %{max_size}
data/config/routes.rb CHANGED
@@ -1,3 +1,4 @@
1
1
  Katalyst::Content::Engine.routes.draw do
2
+ resources :direct_uploads, only: :create
2
3
  resources :items
3
4
  end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ class AddFieldsForFigureToKatalystContentItems < ActiveRecord::Migration[7.0]
4
+ def change
5
+ add_column :katalyst_content_items, :caption, :string
6
+ end
7
+ end
@@ -11,8 +11,15 @@ module Katalyst
11
11
  config_accessor(:items) do
12
12
  %w[
13
13
  Katalyst::Content::Content
14
+ Katalyst::Content::Figure
15
+ Katalyst::Content::Section
16
+ Katalyst::Content::Group
17
+ Katalyst::Content::Column
18
+ Katalyst::Content::Aside
14
19
  ]
15
20
  end
21
+ config_accessor(:image_mime_types) { %w[image/png image/gif image/jpeg image/webp] }
22
+ config_accessor(:max_image_size) { 20 }
16
23
  end
17
24
  end
18
25
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Katalyst
4
4
  module Content
5
- VERSION = "0.1.1"
5
+ VERSION = "0.2.0"
6
6
  end
7
7
  end
@@ -1,16 +1,42 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  FactoryBot.define do
4
- factory :katalyst_content_item, class: "Katalyst::Content::Item" do
4
+ trait :content_item_defaults do
5
5
  heading { Faker::Lorem.word }
6
6
  show_heading { true }
7
7
  background { Katalyst::Content.config.backgrounds.sample }
8
+ depth { 0 }
9
+ end
10
+
11
+ factory :katalyst_content_item, class: "Katalyst::Content::Item" do
12
+ content_item_defaults
8
13
  end
9
14
 
10
15
  factory :katalyst_content_content, class: "Katalyst::Content::Content" do
11
- heading { Faker::Lorem.word }
12
- show_heading { true }
13
- background { Katalyst::Content.config.backgrounds.sample }
16
+ content_item_defaults
14
17
  content { Faker::Hacker.say_something_smart }
15
18
  end
19
+
20
+ factory :katalyst_content_figure, class: "Katalyst::Content::Figure" do
21
+ content_item_defaults
22
+ image { image_upload }
23
+ alt { Faker::Lorem.sentence }
24
+ caption { Faker::Hacker.say_something_smart }
25
+ end
26
+
27
+ factory :katalyst_content_section, class: "Katalyst::Content::Section" do
28
+ content_item_defaults
29
+ end
30
+
31
+ factory :katalyst_content_group, class: "Katalyst::Content::Group" do
32
+ content_item_defaults
33
+ end
34
+
35
+ factory :katalyst_content_aside, class: "Katalyst::Content::Aside" do
36
+ content_item_defaults
37
+ end
38
+
39
+ factory :katalyst_content_column, class: "Katalyst::Content::Column" do
40
+ content_item_defaults
41
+ end
16
42
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: katalyst-content
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.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: 2022-09-15 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2022-10-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: active_storage_validations
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  description:
14
28
  email:
15
29
  - developers@katalyst.com.au
@@ -21,55 +35,80 @@ files:
21
35
  - README.md
22
36
  - app/assets/config/katalyst-content.js
23
37
  - app/assets/javascripts/controllers/content/editor/container_controller.js
38
+ - app/assets/javascripts/controllers/content/editor/image_field_controller.js
24
39
  - app/assets/javascripts/controllers/content/editor/item_controller.js
25
40
  - app/assets/javascripts/controllers/content/editor/list_controller.js
26
41
  - app/assets/javascripts/controllers/content/editor/new_item_controller.js
27
42
  - app/assets/javascripts/controllers/content/editor/status_bar_controller.js
43
+ - app/assets/javascripts/controllers/content/editor/trix_controller.js
28
44
  - app/assets/javascripts/utils/content/editor/container.js
29
45
  - app/assets/javascripts/utils/content/editor/item.js
30
46
  - app/assets/javascripts/utils/content/editor/rules-engine.js
31
47
  - app/assets/stylesheets/katalyst/content/_index.scss
48
+ - app/assets/stylesheets/katalyst/content/editor/_figure.scss
32
49
  - app/assets/stylesheets/katalyst/content/editor/_icon.scss
33
50
  - app/assets/stylesheets/katalyst/content/editor/_index.scss
34
51
  - app/assets/stylesheets/katalyst/content/editor/_item-actions.scss
35
52
  - app/assets/stylesheets/katalyst/content/editor/_item-rules.scss
36
53
  - app/assets/stylesheets/katalyst/content/editor/_new-items.scss
37
54
  - app/assets/stylesheets/katalyst/content/editor/_status-bar.scss
55
+ - app/assets/stylesheets/katalyst/content/editor/_trix-rails.scss
38
56
  - app/controllers/katalyst/content/application_controller.rb
57
+ - app/controllers/katalyst/content/direct_uploads_controller.rb
39
58
  - app/controllers/katalyst/content/items_controller.rb
40
- - app/helpers/katalyst/content/application_helper.rb
41
59
  - app/helpers/katalyst/content/editor/base.rb
42
60
  - app/helpers/katalyst/content/editor/container.rb
61
+ - app/helpers/katalyst/content/editor/image_field.rb
43
62
  - app/helpers/katalyst/content/editor/item.rb
44
63
  - app/helpers/katalyst/content/editor/list.rb
45
64
  - app/helpers/katalyst/content/editor/new_item.rb
46
65
  - app/helpers/katalyst/content/editor/status_bar.rb
47
66
  - app/helpers/katalyst/content/editor_helper.rb
67
+ - app/helpers/katalyst/content/frontend_helper.rb
48
68
  - app/models/concerns/katalyst/content/container.rb
49
69
  - app/models/concerns/katalyst/content/garbage_collection.rb
50
70
  - app/models/concerns/katalyst/content/has_tree.rb
51
71
  - app/models/concerns/katalyst/content/version.rb
72
+ - app/models/katalyst/content/aside.rb
73
+ - app/models/katalyst/content/column.rb
52
74
  - app/models/katalyst/content/content.rb
75
+ - app/models/katalyst/content/figure.rb
76
+ - app/models/katalyst/content/group.rb
53
77
  - app/models/katalyst/content/item.rb
78
+ - app/models/katalyst/content/layout.rb
54
79
  - app/models/katalyst/content/node.rb
80
+ - app/models/katalyst/content/section.rb
55
81
  - app/models/katalyst/content/types/nodes_type.rb
56
82
  - app/views/active_storage/blobs/_blob.html.erb
83
+ - app/views/katalyst/content/asides/_aside.html+form.erb
84
+ - app/views/katalyst/content/asides/_aside.html.erb
85
+ - app/views/katalyst/content/columns/_column.html+form.erb
86
+ - app/views/katalyst/content/columns/_column.html.erb
57
87
  - app/views/katalyst/content/contents/_content.html+form.erb
58
88
  - app/views/katalyst/content/contents/_content.html.erb
59
89
  - app/views/katalyst/content/editor/_item.html.erb
60
90
  - app/views/katalyst/content/editor/_list_item.html.erb
61
91
  - app/views/katalyst/content/editor/_new_item.html.erb
62
92
  - app/views/katalyst/content/editor/_new_items.html.erb
93
+ - app/views/katalyst/content/figures/_figure.html+form.erb
94
+ - app/views/katalyst/content/figures/_figure.html.erb
95
+ - app/views/katalyst/content/groups/_group.html+form.erb
96
+ - app/views/katalyst/content/groups/_group.html.erb
97
+ - app/views/katalyst/content/items/_form_errors.html.erb
98
+ - app/views/katalyst/content/items/_hidden_fields.html.erb
63
99
  - app/views/katalyst/content/items/_item.html+form.erb
64
100
  - app/views/katalyst/content/items/_item.html.erb
65
101
  - app/views/katalyst/content/items/edit.html.erb
66
102
  - app/views/katalyst/content/items/new.html.erb
67
103
  - app/views/katalyst/content/items/update.turbo_stream.erb
104
+ - app/views/katalyst/content/sections/_section.html+form.erb
105
+ - app/views/katalyst/content/sections/_section.html.erb
68
106
  - app/views/layouts/action_text/contents/_content.html.erb
69
107
  - config/importmap.rb
70
108
  - config/locales/en.yml
71
109
  - config/routes.rb
72
110
  - db/migrate/20220913003839_create_katalyst_content_items.rb
111
+ - db/migrate/20220926061535_add_fields_for_figure_to_katalyst_content_items.rb
73
112
  - lib/katalyst/content.rb
74
113
  - lib/katalyst/content/config.rb
75
114
  - lib/katalyst/content/engine.rb