katalyst-content 0.1.2 → 0.2.0

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 +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/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 +21 -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 +1 -1
  15. data/app/helpers/katalyst/content/editor/base.rb +1 -0
  16. data/app/helpers/katalyst/content/editor/container.rb +0 -4
  17. data/app/helpers/katalyst/content/editor/image_field.rb +72 -0
  18. data/app/helpers/katalyst/content/editor/status_bar.rb +12 -3
  19. data/app/helpers/katalyst/content/editor_helper.rb +20 -0
  20. data/app/helpers/katalyst/content/frontend_helper.rb +59 -0
  21. data/app/models/concerns/katalyst/content/container.rb +33 -6
  22. data/app/models/concerns/katalyst/content/version.rb +4 -0
  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 +13 -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 +38 -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 +13 -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 +42 -4
@@ -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.2"
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.2
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,14 +35,17 @@ 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
@@ -37,40 +54,61 @@ files:
37
54
  - app/assets/stylesheets/katalyst/content/editor/_status-bar.scss
38
55
  - app/assets/stylesheets/katalyst/content/editor/_trix-rails.scss
39
56
  - app/controllers/katalyst/content/application_controller.rb
57
+ - app/controllers/katalyst/content/direct_uploads_controller.rb
40
58
  - app/controllers/katalyst/content/items_controller.rb
41
- - app/helpers/katalyst/content/application_helper.rb
42
59
  - app/helpers/katalyst/content/editor/base.rb
43
60
  - app/helpers/katalyst/content/editor/container.rb
61
+ - app/helpers/katalyst/content/editor/image_field.rb
44
62
  - app/helpers/katalyst/content/editor/item.rb
45
63
  - app/helpers/katalyst/content/editor/list.rb
46
64
  - app/helpers/katalyst/content/editor/new_item.rb
47
65
  - app/helpers/katalyst/content/editor/status_bar.rb
48
66
  - app/helpers/katalyst/content/editor_helper.rb
67
+ - app/helpers/katalyst/content/frontend_helper.rb
49
68
  - app/models/concerns/katalyst/content/container.rb
50
69
  - app/models/concerns/katalyst/content/garbage_collection.rb
51
70
  - app/models/concerns/katalyst/content/has_tree.rb
52
71
  - app/models/concerns/katalyst/content/version.rb
72
+ - app/models/katalyst/content/aside.rb
73
+ - app/models/katalyst/content/column.rb
53
74
  - app/models/katalyst/content/content.rb
75
+ - app/models/katalyst/content/figure.rb
76
+ - app/models/katalyst/content/group.rb
54
77
  - app/models/katalyst/content/item.rb
78
+ - app/models/katalyst/content/layout.rb
55
79
  - app/models/katalyst/content/node.rb
80
+ - app/models/katalyst/content/section.rb
56
81
  - app/models/katalyst/content/types/nodes_type.rb
57
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
58
87
  - app/views/katalyst/content/contents/_content.html+form.erb
59
88
  - app/views/katalyst/content/contents/_content.html.erb
60
89
  - app/views/katalyst/content/editor/_item.html.erb
61
90
  - app/views/katalyst/content/editor/_list_item.html.erb
62
91
  - app/views/katalyst/content/editor/_new_item.html.erb
63
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
64
99
  - app/views/katalyst/content/items/_item.html+form.erb
65
100
  - app/views/katalyst/content/items/_item.html.erb
66
101
  - app/views/katalyst/content/items/edit.html.erb
67
102
  - app/views/katalyst/content/items/new.html.erb
68
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
69
106
  - app/views/layouts/action_text/contents/_content.html.erb
70
107
  - config/importmap.rb
71
108
  - config/locales/en.yml
72
109
  - config/routes.rb
73
110
  - db/migrate/20220913003839_create_katalyst_content_items.rb
111
+ - db/migrate/20220926061535_add_fields_for_figure_to_katalyst_content_items.rb
74
112
  - lib/katalyst/content.rb
75
113
  - lib/katalyst/content/config.rb
76
114
  - lib/katalyst/content/engine.rb