maglevcms 1.1.6 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/app/components/maglev/content/image.rb +2 -0
  3. data/app/controllers/concerns/maglev/fetchers_concern.rb +1 -0
  4. data/app/controllers/concerns/maglev/standalone_sections_concern.rb +6 -0
  5. data/app/controllers/maglev/sitemap_controller.rb +31 -0
  6. data/app/frontend/editor/assets/remixicons/ri-palette-line.svg +1 -0
  7. data/app/frontend/editor/components/dynamic-form/dynamic-input.vue +2 -1
  8. data/app/frontend/editor/components/header-nav/publish-button.vue +1 -1
  9. data/app/frontend/editor/components/kit/collection-item-input.vue +5 -2
  10. data/app/frontend/editor/components/kit/color-input/core-input.vue +85 -0
  11. data/app/frontend/editor/components/kit/color-input/preset-button.vue +57 -0
  12. data/app/frontend/editor/components/kit/color-input/preset-dropdown.vue +46 -0
  13. data/app/frontend/editor/components/kit/color-input.vue +43 -0
  14. data/app/frontend/editor/components/kit/dropdown.vue +1 -0
  15. data/app/frontend/editor/components/kit/index.js +2 -2
  16. data/app/frontend/editor/components/kit/submit-button.vue +3 -3
  17. data/app/frontend/editor/components/kit/tabs.vue +2 -1
  18. data/app/frontend/editor/components/kit/text-input.vue +2 -2
  19. data/app/frontend/editor/misc/utils.js +32 -2
  20. data/app/frontend/editor/services/api.js +2 -2
  21. data/app/frontend/editor/spec/__mocks__/page.js +36 -36
  22. data/app/frontend/editor/spec/__mocks__/section.js +29 -29
  23. data/app/helpers/maglev/editor_helper.rb +1 -1
  24. data/app/helpers/maglev/page_preview_helper.rb +5 -1
  25. data/app/helpers/maglev/sitemap_helper.rb +13 -0
  26. data/app/models/concerns/maglev/sections_concern.rb +10 -0
  27. data/app/models/maglev/page/path_concern.rb +8 -1
  28. data/app/models/maglev/section/setting.rb +5 -0
  29. data/app/models/maglev/site/locales_concern.rb +8 -0
  30. data/app/services/concerns/maglev/get_page_sections/transform_collection_item_concern.rb +8 -1
  31. data/app/services/maglev/app_container.rb +2 -0
  32. data/app/services/maglev/fetch_collection_items.rb +6 -2
  33. data/app/services/maglev/persist_page.rb +23 -4
  34. data/app/services/maglev/setup_pages.rb +41 -5
  35. data/app/views/maglev/api/pages/_show.json.jbuilder +1 -2
  36. data/app/views/maglev/sitemap/index.xml.builder +21 -0
  37. data/config/routes.rb +1 -0
  38. data/db/migrate/20210830085101_create_maglev_page_paths.rb +1 -1
  39. data/db/migrate/20210906102712_add_canonical_to_pages.rb +1 -1
  40. data/db/migrate/20211008064437_add_locales_to_sites.rb +1 -1
  41. data/db/migrate/20211013210954_translate_section_content.rb +1 -1
  42. data/db/migrate/20211101205001_add_lock_version_to_maglev_pages.rb +1 -1
  43. data/db/migrate/20211116161121_better_page_path_canonical_indices.rb +1 -1
  44. data/db/migrate/20211124101005_fix_page_path_indices.rb +1 -1
  45. data/db/migrate/20211203224112_add_open_graph_tags_to_pages.rb +1 -1
  46. data/db/migrate/20220612092235_add_style_to_sites.rb +1 -1
  47. data/lib/generators/maglev/install_generator.rb +3 -2
  48. data/lib/generators/maglev/section_generator.rb +2 -1
  49. data/lib/generators/maglev/templates/section/app/theme/sections/%category%/%file_name%.yml.tt +13 -9
  50. data/lib/maglev/engine.rb +8 -2
  51. data/lib/maglev/version.rb +1 -1
  52. data/package.json +3 -3
  53. data/yarn.lock +799 -565
  54. metadata +14 -7
  55. data/app/frontend/editor/components/kit/color-picker.vue +0 -81
  56. /data/app/frontend/editor/assets/remixicons/{check-line.svg → ri-check-line.svg} +0 -0
@@ -1,4 +1,4 @@
1
- class AddCanonicalToPages < ActiveRecord::Migration[6.1]
1
+ class AddCanonicalToPages < ActiveRecord::Migration[6.0]
2
2
  def change
3
3
  add_column :maglev_page_paths, :canonical, :boolean, null: true, default: true
4
4
  add_index :maglev_page_paths, %i[canonical maglev_page_id locale], unique: true, name: 'canonical_uniqueness'
@@ -1,4 +1,4 @@
1
- class AddLocalesToSites < ActiveRecord::Migration[6.1]
1
+ class AddLocalesToSites < ActiveRecord::Migration[6.0]
2
2
  def change
3
3
  add_column :maglev_sites, :locales, :jsonb, default: []
4
4
  end
@@ -1,4 +1,4 @@
1
- class TranslateSectionContent < ActiveRecord::Migration[6.1]
1
+ class TranslateSectionContent < ActiveRecord::Migration[6.0]
2
2
  def change
3
3
  remove_column :maglev_sites, :sections, :jsonb, default: []
4
4
  add_column :maglev_sites, :sections_translations, :jsonb, default: {}
@@ -1,4 +1,4 @@
1
- class AddLockVersionToMaglevPages < ActiveRecord::Migration[6.1]
1
+ class AddLockVersionToMaglevPages < ActiveRecord::Migration[6.0]
2
2
  def change
3
3
  add_column :maglev_sites, :lock_version, :integer
4
4
  add_column :maglev_pages, :lock_version, :integer
@@ -1,4 +1,4 @@
1
- class BetterPagePathCanonicalIndices < ActiveRecord::Migration[6.1]
1
+ class BetterPagePathCanonicalIndices < ActiveRecord::Migration[6.0]
2
2
  def change
3
3
  remove_index :maglev_page_paths, [:value, :locale], unique: true
4
4
  remove_index :maglev_page_paths, %i[canonical maglev_page_id locale], unique: true, name: 'canonical_uniqueness'
@@ -1,4 +1,4 @@
1
- class FixPagePathIndices < ActiveRecord::Migration[6.1]
1
+ class FixPagePathIndices < ActiveRecord::Migration[6.0]
2
2
  def change
3
3
  remove_index :maglev_page_paths, %i[canonical maglev_page_id locale value], unique: true, name: 'canonical_uniqueness'
4
4
  add_index :maglev_page_paths, %i[canonical maglev_page_id locale], name: 'scoped_canonical_speed'
@@ -1,4 +1,4 @@
1
- class AddOpenGraphTagsToPages < ActiveRecord::Migration[6.1]
1
+ class AddOpenGraphTagsToPages < ActiveRecord::Migration[6.0]
2
2
  def change
3
3
  change_table :maglev_pages do |t|
4
4
  t.jsonb :og_title_translations, default: {}
@@ -1,4 +1,4 @@
1
- class AddStyleToSites < ActiveRecord::Migration[6.1]
1
+ class AddStyleToSites < ActiveRecord::Migration[6.0]
2
2
  def change
3
3
  change_table :maglev_sites do |t|
4
4
  t.jsonb :style, default: []
@@ -29,6 +29,7 @@ module Maglev
29
29
  inject_into_file 'config/routes.rb', before: /^end/ do
30
30
  <<-CODE
31
31
  mount Maglev::Engine => '/maglev'
32
+ get '/sitemap', to: 'maglev/sitemap#index', defaults: { format: 'xml' }
32
33
  get '(*path)', to: 'maglev/page_preview#index', defaults: { path: 'index' }, constraints: Maglev::PreviewConstraint.new
33
34
  CODE
34
35
  end
@@ -38,8 +39,8 @@ module Maglev
38
39
  $stdout.puts <<~INFO
39
40
  Done! 🎉
40
41
 
41
- You can now tweak /config/initializers/maglev.rb.
42
- You can also modify your theme (in /app/theme and /app/views/theme)
42
+ You can now tweak config/initializers/maglev.rb
43
+ You can also modify your theme (in app/theme and app/views/theme)
43
44
  and generate new sections with rails g maglev:section.
44
45
 
45
46
  👉 The next step is to create a site using `rails maglev:create_site`.
@@ -109,10 +109,11 @@ module Maglev
109
109
  when 'text' then label
110
110
  when 'image' then '"/theme/image-placeholder.jpg"'
111
111
  when 'checkbox' then true
112
- when 'link' then '{ text: "Link", url: "#" }'
112
+ when 'link' then '{ text: "Link", href: "#" }'
113
113
  when 'color' then '#E5E7EB'
114
114
  when 'radio', 'select' then 'option_1'
115
115
  when 'icon' then 'default-icon-class'
116
+ when 'collection_item' then 'any'
116
117
  end
117
118
  end
118
119
  # rubocop:enable Metrics/CyclomaticComplexity
@@ -12,7 +12,7 @@ category: <%= category %>
12
12
  # insert_button: false
13
13
 
14
14
  # Insert this section at the top or the bottom of the page (default: nil)
15
- # insert_at: top
15
+ # insert_at: top
16
16
 
17
17
  # One single instance per page?
18
18
  # singleton: true
@@ -33,20 +33,22 @@ settings:
33
33
  <%- when 'link' -%>
34
34
  with_text: true
35
35
  <%- when 'select', 'radio' -%>
36
- options:
36
+ select_options:
37
37
  - label: Option 1
38
38
  value: option_1
39
39
  - label: Option 2
40
40
  value: option_2
41
41
  <%- when 'color' -%>
42
42
  presets: ['#E5E7EB', '#FECACA', '#FDE68A', '#A7F3D0', '#BFDBFE']
43
+ <%- when 'collection_item' -%>
44
+ collection_id: products # check your config/initializers/maglev.rb to register your collection
43
45
  <%- end -%>
44
46
  <% if setting.value? -%>default: <%= setting.default %><% end -%>
45
47
 
46
48
  <%- end -%>
47
49
  # Definition of the blocks.
48
50
  # You can define as many types of blocks as you want.
49
- blocks: <%- if blocks.blank? -%>[]
51
+ blocks:<%- if blocks.blank? -%> []
50
52
  <% end %>
51
53
  <%- blocks.each do |(type, settings)| -%>
52
54
  - name: "<%= type.humanize %>"
@@ -64,11 +66,13 @@ blocks: <%- if blocks.blank? -%>[]
64
66
  <%- when 'link' -%>
65
67
  with_text: true
66
68
  <%- when 'select', 'radio' -%>
67
- options:
69
+ select_options:
68
70
  - label: Option 1
69
71
  value: option_1
70
72
  - label: Option 2
71
73
  value: option_2
74
+ <%- when 'collection_item' -%>
75
+ collection_id: products # check your config/initializers/maglev.rb to register your collection
72
76
  <%- end -%>
73
77
  <%- if setting.value? -%>
74
78
  default: <%= setting.default %>
@@ -80,12 +84,12 @@ blocks: <%- if blocks.blank? -%>[]
80
84
  # The title can be changed with the following property:
81
85
  # blocks_label: "My list of items"
82
86
 
83
- # By default, blocks are presented as a list in the editor UI.
84
- # If you like to use blocks to build a menu with sub menu items,
87
+ # By default, blocks are presented as a list in the editor UI.
88
+ # If you like to use blocks to build a menu with sub menu items,
85
89
  # consider using the tree presentation
86
90
  # blocks_presentation: "tree"
87
91
 
88
- # In order to get a section with "meaning" content for the editors,
92
+ # In order to get a section with "meaning" content for the editors,
89
93
  # you can set the default content of a new instance of this section.
90
94
  # (it's also be useful when taking a screenshot of the section).
91
95
  # sample:
@@ -94,13 +98,13 @@ blocks: <%- if blocks.blank? -%>[]
94
98
  # <% if setting.value? -%><%= setting.id %>: <%= setting.default %><% end -%>
95
99
 
96
100
  <%- end -%>
97
- # blocks: <%- if blocks.blank? -%>[]
101
+ # blocks:<%- if blocks.blank? -%> []
98
102
  <% end %>
99
103
  <%- blocks.each do |(type, settings)| -%>
100
104
  # - type: <%= type %>
101
105
  # settings:
102
106
  <%- settings.each do |setting| -%>
103
107
  # <% if setting.value? -%><%= setting.id %>: <%= setting.default %><% end -%>
104
-
108
+
105
109
  <%- end -%>
106
110
  <%- end -%>
data/lib/maglev/engine.rb CHANGED
@@ -52,13 +52,19 @@ module Maglev
52
52
  app.middleware.insert_after ActionDispatch::Static,
53
53
  Rack::Static,
54
54
  urls: ["/#{vite_ruby.config.public_output_dir}"],
55
- root: root.join(vite_ruby.config.public_dir)
55
+ root: root.join(vite_ruby.config.public_dir),
56
+ header_rules: [
57
+ [:all, { "Access-Control-Allow-Origin": '*' }]
58
+ ]
56
59
  else
57
60
  # mostly when running the application in production behind NGINX or APACHE
58
61
  app.middleware.insert_before 0,
59
62
  Rack::Static,
60
63
  urls: ["/#{vite_ruby.config.public_output_dir}"],
61
- root: root.join(vite_ruby.config.public_dir)
64
+ root: root.join(vite_ruby.config.public_dir),
65
+ header_rules: [
66
+ [:all, { "Access-Control-Allow-Origin": '*' }]
67
+ ]
62
68
  end
63
69
  end
64
70
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Maglev
4
- VERSION = '1.1.6'
4
+ VERSION = '1.2.0'
5
5
  end
data/package.json CHANGED
@@ -32,11 +32,11 @@
32
32
  "jsdom": "^20.0.2",
33
33
  "postcss": "^8.4.18",
34
34
  "prettier": "^2.3.2",
35
- "sass": "^1.55.0",
35
+ "sass": "^1.55.0",
36
36
  "tailwindcss": "^3.2.1",
37
- "vite": "^3.2.0",
37
+ "vite": "^4.3.0",
38
38
  "vite-plugin-eslint": "^1.8.1",
39
- "vite-plugin-ruby": "^3.1.2",
39
+ "vite-plugin-ruby": "^3.2.0",
40
40
  "vite-plugin-vue2-svg": "^0.3.0",
41
41
  "vitest": "^0.24.4",
42
42
  "vue-template-compiler": "^2.7.13"