katalyst-content 0.1.2 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/controllers/content/editor/container_controller.js +38 -6
  3. data/app/assets/javascripts/controllers/content/editor/list_controller.js +6 -5
  4. data/app/assets/javascripts/controllers/content/editor/trix_controller.js +88 -0
  5. data/app/assets/javascripts/utils/content/editor/item.js +29 -24
  6. data/app/assets/javascripts/utils/content/editor/rules-engine.js +74 -31
  7. data/app/assets/stylesheets/katalyst/content/editor/_figure.scss +12 -0
  8. data/app/assets/stylesheets/katalyst/content/editor/_index.scss +7 -1
  9. data/app/assets/stylesheets/katalyst/content/editor/_item-actions.scss +24 -6
  10. data/app/assets/stylesheets/katalyst/content/editor/_new-items.scss +22 -1
  11. data/app/assets/stylesheets/katalyst/content/editor/_status-bar.scss +10 -0
  12. data/app/assets/stylesheets/katalyst/content/editor/_trix-rails.scss +4 -4
  13. data/app/controllers/katalyst/content/direct_uploads_controller.rb +8 -0
  14. data/app/controllers/katalyst/content/items_controller.rb +5 -5
  15. data/app/helpers/katalyst/content/editor/base.rb +1 -0
  16. data/app/helpers/katalyst/content/editor/container.rb +6 -4
  17. data/app/helpers/katalyst/content/editor/errors.rb +24 -0
  18. data/app/helpers/katalyst/content/editor/status_bar.rb +12 -3
  19. data/app/helpers/katalyst/content/editor_helper.rb +26 -0
  20. data/app/helpers/katalyst/content/frontend_helper.rb +59 -0
  21. data/app/models/concerns/katalyst/content/container.rb +38 -6
  22. data/app/models/concerns/katalyst/content/version.rb +14 -4
  23. data/app/{helpers/katalyst/content/application_helper.rb → models/katalyst/content/aside.rb} +1 -1
  24. data/app/models/katalyst/content/column.rb +8 -0
  25. data/app/models/katalyst/content/content.rb +4 -0
  26. data/app/models/katalyst/content/figure.rb +41 -0
  27. data/app/models/katalyst/content/group.rb +8 -0
  28. data/app/models/katalyst/content/item.rb +17 -1
  29. data/app/models/katalyst/content/layout.rb +8 -0
  30. data/app/models/katalyst/content/section.rb +8 -0
  31. data/app/views/active_storage/blobs/_blob.html.erb +1 -1
  32. data/app/views/katalyst/content/asides/_aside.html+form.erb +27 -0
  33. data/app/views/katalyst/content/asides/_aside.html.erb +14 -0
  34. data/app/views/katalyst/content/columns/_column.html+form.erb +27 -0
  35. data/app/views/katalyst/content/columns/_column.html.erb +14 -0
  36. data/app/views/katalyst/content/contents/_content.html+form.erb +3 -10
  37. data/app/views/katalyst/content/contents/_content.html.erb +3 -3
  38. data/app/views/katalyst/content/editor/_list_item.html.erb +1 -0
  39. data/app/views/katalyst/content/figures/_figure.html+form.erb +32 -0
  40. data/app/views/katalyst/content/figures/_figure.html.erb +4 -0
  41. data/app/views/katalyst/content/groups/_group.html+form.erb +27 -0
  42. data/app/views/katalyst/content/groups/_group.html.erb +7 -0
  43. data/app/views/katalyst/content/items/_form_errors.html.erb +5 -0
  44. data/app/views/katalyst/content/items/_hidden_fields.html.erb +3 -0
  45. data/app/views/katalyst/content/items/_item.html+form.erb +2 -9
  46. data/app/views/katalyst/content/items/_item.html.erb +3 -3
  47. data/app/views/katalyst/content/sections/_section.html+form.erb +27 -0
  48. data/app/views/katalyst/content/sections/_section.html.erb +7 -0
  49. data/config/locales/en.yml +15 -0
  50. data/config/routes.rb +1 -0
  51. data/db/migrate/20220926061535_add_fields_for_figure_to_katalyst_content_items.rb +7 -0
  52. data/lib/katalyst/content/config.rb +7 -0
  53. data/lib/katalyst/content/version.rb +1 -1
  54. data/spec/factories/katalyst/content/items.rb +30 -4
  55. metadata +41 -4
@@ -0,0 +1,27 @@
1
+ <%= form_with model: column, 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,14 @@
1
+ <%= content_item_tag column do %>
2
+ <%= tag.h3 column.heading if column.show_heading? %>
3
+
4
+ <% items = column.children.select(&:visible?) %>
5
+ <% last = items.pop %>
6
+ <div class="columns-container">
7
+ <div class="column">
8
+ <%= render_content_items items %>
9
+ </div>
10
+ <div class="column">
11
+ <%= render_content_items [last] if last %>
12
+ </div>
13
+ </div>
14
+ <% end %>
@@ -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 %>
@@ -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,32 @@
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
+ <div class="field">
6
+ <%= form.label :image %>
7
+ <%= form.file_field :image %>
8
+ </div>
9
+
10
+ <div class="field">
11
+ <%= form.label :heading %>
12
+ <%= form.text_field :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
+ <div class="field">
26
+ <%= form.label :caption %>
27
+ <%= form.text_field :caption %>
28
+ </div>
29
+
30
+ <%= form.submit "Done" %>
31
+ <%= link_to "Discard", :back %>
32
+ <% 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,15 @@
1
1
  en:
2
+ activerecord:
3
+ attributes:
4
+ katalyst/content/figure:
5
+ heading: "Alternate text"
6
+ errors:
7
+ messages:
8
+ missing_item: Content items are missing or invalid
9
+ models:
10
+ katalyst/content/item:
11
+ content_type_invalid: file type not supported
12
+ file_size_out_of_range: must be less than %{max_size}
2
13
  views:
3
14
  katalyst:
4
15
  content:
@@ -8,5 +19,9 @@ en:
8
19
  discard: Discard
9
20
  publish: Publish
10
21
  published_html: Published <i>(last updated %{last_update})</i>
22
+ unpublished_html: Unpublished
11
23
  revert: Revert
12
24
  save: Save
25
+ item:
26
+ size_hint:
27
+ 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.2"
5
+ VERSION = "0.2.1"
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.2
4
+ version: 0.2.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: 2022-09-15 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2022-11-02 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
@@ -25,10 +39,12 @@ files:
25
39
  - app/assets/javascripts/controllers/content/editor/list_controller.js
26
40
  - app/assets/javascripts/controllers/content/editor/new_item_controller.js
27
41
  - app/assets/javascripts/controllers/content/editor/status_bar_controller.js
42
+ - app/assets/javascripts/controllers/content/editor/trix_controller.js
28
43
  - app/assets/javascripts/utils/content/editor/container.js
29
44
  - app/assets/javascripts/utils/content/editor/item.js
30
45
  - app/assets/javascripts/utils/content/editor/rules-engine.js
31
46
  - app/assets/stylesheets/katalyst/content/_index.scss
47
+ - app/assets/stylesheets/katalyst/content/editor/_figure.scss
32
48
  - app/assets/stylesheets/katalyst/content/editor/_icon.scss
33
49
  - app/assets/stylesheets/katalyst/content/editor/_index.scss
34
50
  - app/assets/stylesheets/katalyst/content/editor/_item-actions.scss
@@ -37,40 +53,61 @@ files:
37
53
  - app/assets/stylesheets/katalyst/content/editor/_status-bar.scss
38
54
  - app/assets/stylesheets/katalyst/content/editor/_trix-rails.scss
39
55
  - app/controllers/katalyst/content/application_controller.rb
56
+ - app/controllers/katalyst/content/direct_uploads_controller.rb
40
57
  - app/controllers/katalyst/content/items_controller.rb
41
- - app/helpers/katalyst/content/application_helper.rb
42
58
  - app/helpers/katalyst/content/editor/base.rb
43
59
  - app/helpers/katalyst/content/editor/container.rb
60
+ - app/helpers/katalyst/content/editor/errors.rb
44
61
  - app/helpers/katalyst/content/editor/item.rb
45
62
  - app/helpers/katalyst/content/editor/list.rb
46
63
  - app/helpers/katalyst/content/editor/new_item.rb
47
64
  - app/helpers/katalyst/content/editor/status_bar.rb
48
65
  - app/helpers/katalyst/content/editor_helper.rb
66
+ - app/helpers/katalyst/content/frontend_helper.rb
49
67
  - app/models/concerns/katalyst/content/container.rb
50
68
  - app/models/concerns/katalyst/content/garbage_collection.rb
51
69
  - app/models/concerns/katalyst/content/has_tree.rb
52
70
  - app/models/concerns/katalyst/content/version.rb
71
+ - app/models/katalyst/content/aside.rb
72
+ - app/models/katalyst/content/column.rb
53
73
  - app/models/katalyst/content/content.rb
74
+ - app/models/katalyst/content/figure.rb
75
+ - app/models/katalyst/content/group.rb
54
76
  - app/models/katalyst/content/item.rb
77
+ - app/models/katalyst/content/layout.rb
55
78
  - app/models/katalyst/content/node.rb
79
+ - app/models/katalyst/content/section.rb
56
80
  - app/models/katalyst/content/types/nodes_type.rb
57
81
  - app/views/active_storage/blobs/_blob.html.erb
82
+ - app/views/katalyst/content/asides/_aside.html+form.erb
83
+ - app/views/katalyst/content/asides/_aside.html.erb
84
+ - app/views/katalyst/content/columns/_column.html+form.erb
85
+ - app/views/katalyst/content/columns/_column.html.erb
58
86
  - app/views/katalyst/content/contents/_content.html+form.erb
59
87
  - app/views/katalyst/content/contents/_content.html.erb
60
88
  - app/views/katalyst/content/editor/_item.html.erb
61
89
  - app/views/katalyst/content/editor/_list_item.html.erb
62
90
  - app/views/katalyst/content/editor/_new_item.html.erb
63
91
  - app/views/katalyst/content/editor/_new_items.html.erb
92
+ - app/views/katalyst/content/figures/_figure.html+form.erb
93
+ - app/views/katalyst/content/figures/_figure.html.erb
94
+ - app/views/katalyst/content/groups/_group.html+form.erb
95
+ - app/views/katalyst/content/groups/_group.html.erb
96
+ - app/views/katalyst/content/items/_form_errors.html.erb
97
+ - app/views/katalyst/content/items/_hidden_fields.html.erb
64
98
  - app/views/katalyst/content/items/_item.html+form.erb
65
99
  - app/views/katalyst/content/items/_item.html.erb
66
100
  - app/views/katalyst/content/items/edit.html.erb
67
101
  - app/views/katalyst/content/items/new.html.erb
68
102
  - app/views/katalyst/content/items/update.turbo_stream.erb
103
+ - app/views/katalyst/content/sections/_section.html+form.erb
104
+ - app/views/katalyst/content/sections/_section.html.erb
69
105
  - app/views/layouts/action_text/contents/_content.html.erb
70
106
  - config/importmap.rb
71
107
  - config/locales/en.yml
72
108
  - config/routes.rb
73
109
  - db/migrate/20220913003839_create_katalyst_content_items.rb
110
+ - db/migrate/20220926061535_add_fields_for_figure_to_katalyst_content_items.rb
74
111
  - lib/katalyst/content.rb
75
112
  - lib/katalyst/content/config.rb
76
113
  - lib/katalyst/content/engine.rb