katalyst-content 1.1.1 → 2.0.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 (60) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +81 -7
  3. data/app/assets/builds/katalyst/content.esm.js +1004 -0
  4. data/app/assets/builds/katalyst/content.js +1004 -0
  5. data/app/assets/builds/katalyst/content.min.js +2 -0
  6. data/app/assets/builds/katalyst/content.min.js.map +1 -0
  7. data/app/assets/config/katalyst-content.js +1 -1
  8. data/app/assets/stylesheets/katalyst/content/editor/_index.scss +1 -1
  9. data/app/assets/stylesheets/katalyst/content/editor/_new-items.scss +36 -10
  10. data/app/assets/stylesheets/katalyst/content/editor/_status-bar.scss +3 -1
  11. data/app/{helpers/katalyst/content/editor/base.rb → components/katalyst/content/editor/base_component.rb} +15 -12
  12. data/app/components/katalyst/content/editor/errors_component.html.erb +12 -0
  13. data/app/components/katalyst/content/editor/errors_component.rb +15 -0
  14. data/app/components/katalyst/content/editor/item_component.html.erb +25 -0
  15. data/app/components/katalyst/content/editor/item_component.rb +28 -0
  16. data/app/components/katalyst/content/editor/new_item_component.html.erb +22 -0
  17. data/app/components/katalyst/content/editor/new_item_component.rb +52 -0
  18. data/app/{views/katalyst/content/editor/_new_items.html.erb → components/katalyst/content/editor/new_items_component.html.erb} +1 -1
  19. data/app/components/katalyst/content/editor/new_items_component.rb +20 -0
  20. data/app/{views/katalyst/content/editor/_list_item.html.erb → components/katalyst/content/editor/row_component.html.erb} +1 -1
  21. data/app/components/katalyst/content/editor/row_component.rb +13 -0
  22. data/app/{helpers/katalyst/content/editor/status_bar.rb → components/katalyst/content/editor/status_bar_component.rb} +17 -13
  23. data/app/components/katalyst/content/editor/table_component.html.erb +11 -0
  24. data/app/components/katalyst/content/editor/table_component.rb +36 -0
  25. data/app/components/katalyst/content/editor_component.html.erb +9 -0
  26. data/app/components/katalyst/content/editor_component.rb +49 -0
  27. data/app/controllers/katalyst/content/items_controller.rb +6 -3
  28. data/app/helpers/katalyst/content/editor_helper.rb +4 -48
  29. data/app/helpers/katalyst/content/frontend_helper.rb +3 -3
  30. data/app/javascript/content/application.js +35 -0
  31. data/app/{assets/javascripts/utils → javascript}/content/editor/container.js +1 -1
  32. data/app/{assets/javascripts/controllers → javascript}/content/editor/container_controller.js +3 -3
  33. data/app/{assets/javascripts/controllers → javascript}/content/editor/item_controller.js +1 -1
  34. data/app/{assets/javascripts/controllers → javascript}/content/editor/list_controller.js +12 -2
  35. data/app/models/katalyst/content/types/nodes_type.rb +2 -2
  36. data/app/views/active_storage/blobs/_blob.html.erb +1 -1
  37. data/app/views/katalyst/content/asides/_aside.html+form.erb +2 -2
  38. data/app/views/katalyst/content/columns/_column.html+form.erb +2 -2
  39. data/app/views/katalyst/content/contents/_content.html+form.erb +3 -3
  40. data/app/views/katalyst/content/figures/_figure.html+form.erb +2 -2
  41. data/app/views/katalyst/content/groups/_group.html+form.erb +2 -2
  42. data/app/views/katalyst/content/items/_item.html+form.erb +2 -2
  43. data/app/views/katalyst/content/items/update.turbo_stream.erb +2 -2
  44. data/app/views/katalyst/content/sections/_section.html+form.erb +2 -2
  45. data/config/importmap.rb +1 -6
  46. data/lib/katalyst/content.rb +0 -1
  47. metadata +61 -24
  48. data/app/helpers/katalyst/content/editor/container.rb +0 -43
  49. data/app/helpers/katalyst/content/editor/errors.rb +0 -24
  50. data/app/helpers/katalyst/content/editor/item.rb +0 -67
  51. data/app/helpers/katalyst/content/editor/list.rb +0 -41
  52. data/app/helpers/katalyst/content/editor/new_item.rb +0 -53
  53. data/app/views/katalyst/content/editor/_item.html.erb +0 -14
  54. data/app/views/katalyst/content/editor/_new_item.html.erb +0 -3
  55. data/lib/katalyst/content/version.rb +0 -7
  56. /data/app/{assets/javascripts/utils → javascript}/content/editor/item.js +0 -0
  57. /data/app/{assets/javascripts/controllers → javascript}/content/editor/new_item_controller.js +0 -0
  58. /data/app/{assets/javascripts/utils/content/editor/rules-engine.js → javascript/content/editor/rules_engine.js} +0 -0
  59. /data/app/{assets/javascripts/controllers → javascript}/content/editor/status_bar_controller.js +0 -0
  60. /data/app/{assets/javascripts/controllers → javascript}/content/editor/trix_controller.js +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 87e4bd83eeac48370da7a9d48165db46776c97be76b76e08fccf16f7b3890493
4
- data.tar.gz: ab1893973d8a60e5db8eddfaab2fe7251f7df21b7bcb2e5ba34f5408bf438d3a
3
+ metadata.gz: 32b03e6922fb9f2062318ea0fa31fc988463ac2975d9f5ba193187638c4528f2
4
+ data.tar.gz: 1830d2633def549737b742d4c29fddf5a419e253365b1c59f5a40ebbec445d90
5
5
  SHA512:
6
- metadata.gz: a0ea63540fe34c71e88405905054b5ed27d36d7232583f5fe5270d2daf1b40ce7c0a27d42a7fc0d6963c44f1353147d251d406ae1d4cdc4f4d231bfac49d6167
7
- data.tar.gz: 2e41d43a9122257aab1df8c274c7ad09a77e253a48a0c34157fcd08d74ecafd4cc6a113d54cb56f2bc6bf44a53ac9f31755dbc5e835d842ec09d83f6145cc778
6
+ metadata.gz: 63ccbcf8ce1f61175eabb29a7d0d88385245a315c487ce4e78055467a6ada93998592aeb882d1c3b1475a6f864a056166caeac31e69df91522dc7a15f3926f4a
7
+ data.tar.gz: 9b301a53e876f2c76b7e8854429c009af2aa6dd8637c6f76e4f810bb4c44c5d6cb60136dc03e33dbcae66472c5457cbec781ec2a1acd86b8e78d2d2166b17858
data/README.md CHANGED
@@ -5,19 +5,37 @@ applications.
5
5
 
6
6
  ## Installation
7
7
 
8
- Add this line to your application's Gemfile:
8
+ Install the gem as usual
9
9
 
10
10
  ```ruby
11
- gem 'katalyst-content'
11
+ gem "katalyst-content"
12
12
  ```
13
13
 
14
- And then execute:
14
+ Mount the engine in your `routes.rb` file:
15
15
 
16
- $ bundle install
16
+ ```ruby
17
+ mount Katalyst::Content::Engine, at: "content"
18
+ ```
17
19
 
18
- Or install it yourself as:
20
+ Add the Gem's migrations to your application:
19
21
 
20
- $ gem install katalyst-content
22
+ ```ruby
23
+ rake katalyst_content:install:migrations
24
+ ```
25
+
26
+ Add the Gem's javascript and CSS to your build pipeline. This assumes that
27
+ you're using `rails-dartsass` and `importmaps` to manage your assets.
28
+
29
+ ```javascript
30
+ // app/javascript/controllers/application.js
31
+ import { application } from "controllers/application";
32
+ import content from "@katalyst/content";
33
+ application.load(content);
34
+ ```
35
+
36
+ ```sass
37
+ @use "katalyst/content";
38
+ ```
21
39
 
22
40
  ## Usage
23
41
 
@@ -80,11 +98,67 @@ FactoryBot.define do
80
98
  end
81
99
  ```
82
100
 
101
+ Create a controller for editing content. This example assumes you're rendering the editor on the 'show' route of an
102
+ admin controller.
103
+
104
+ ```ruby
105
+ class Admin::PagesController < Admin::BaseController
106
+ before_action :set_page, only: %i[show update]
107
+
108
+ def show; end
109
+
110
+ def update
111
+ @page.attributes = page_params
112
+
113
+ unless @page.valid?
114
+ return respond_to do |format|
115
+ format.turbo_stream { render @editor.errors, status: :unprocessable_entity }
116
+ end
117
+ end
118
+
119
+ case params[:commit]
120
+ when "publish"
121
+ @page.save!
122
+ @page.publish!
123
+ when "save"
124
+ @page.save!
125
+ when "revert"
126
+ @page.revert!
127
+ end
128
+
129
+ redirect_to [:admin, @page], status: :see_other
130
+ end
131
+
132
+ private
133
+
134
+ def set_page
135
+ @page = Page.find(params[:id])
136
+ @editor = Katalyst::Content::EditorComponent.new(container: @page)
137
+ end
138
+
139
+ def page_params
140
+ params.require(:page).permit(items_attributes: %i[id index depth])
141
+ end
142
+ end
143
+ ```
144
+
145
+ And the view:
146
+
147
+ ```erb
148
+ <%# app/views/admin/pages/show.html.erb %>
149
+ <%= render @editor.status_bar %>
150
+ <%= render @editor %>
151
+ <%# We suggest you render new items in a sidebar %>
152
+ <%= render @editor.new_items %>
153
+ ```
154
+
83
155
  ## Development
84
156
 
85
157
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake` to run the tests.
86
158
 
87
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
159
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the
160
+ version number and run `bundle exec rake release`, which will create a git tag for the version, push git commits and
161
+ the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
88
162
 
89
163
  ## Contributing
90
164