alchemy_cms 6.1.10 โ†’ 7.0.0.pre.a

Sign up to get free protection for your applications and to get access to all the features.
Files changed (249) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +0 -3
  3. data/.gitignore +1 -6
  4. data/CHANGELOG.md +19 -44
  5. data/Gemfile +1 -1
  6. data/Rakefile +14 -9
  7. data/alchemy_cms.gemspec +2 -3
  8. data/app/assets/javascripts/alchemy/alchemy.dirty.js.coffee +1 -1
  9. data/app/assets/javascripts/alchemy/alchemy.element_editors.js.coffee +18 -32
  10. data/app/assets/javascripts/alchemy/alchemy.elements_window.js.coffee +2 -2
  11. data/app/assets/javascripts/alchemy/alchemy.gui.js.coffee +2 -2
  12. data/app/assets/javascripts/alchemy/alchemy.link_dialog.js.coffee +27 -29
  13. data/app/assets/stylesheets/alchemy/elements.scss +16 -35
  14. data/app/assets/stylesheets/alchemy/forms.scss +0 -4
  15. data/app/assets/stylesheets/alchemy/node-select.scss +2 -2
  16. data/app/controllers/alchemy/admin/attachments_controller.rb +0 -1
  17. data/app/controllers/alchemy/admin/elements_controller.rb +7 -32
  18. data/app/controllers/alchemy/admin/pages_controller.rb +1 -1
  19. data/app/controllers/alchemy/admin/pictures_controller.rb +1 -1
  20. data/app/controllers/alchemy/admin/resources_controller.rb +1 -18
  21. data/app/controllers/alchemy/api/elements_controller.rb +0 -2
  22. data/app/controllers/alchemy/api/pages_controller.rb +8 -4
  23. data/app/controllers/alchemy/messages_controller.rb +9 -9
  24. data/app/controllers/alchemy/pages_controller.rb +23 -18
  25. data/app/decorators/alchemy/element_editor.rb +10 -30
  26. data/app/helpers/alchemy/admin/elements_helper.rb +0 -2
  27. data/app/helpers/alchemy/elements_block_helper.rb +5 -42
  28. data/app/helpers/alchemy/elements_helper.rb +3 -11
  29. data/app/helpers/alchemy/pages_helper.rb +0 -4
  30. data/app/models/alchemy/attachment.rb +6 -3
  31. data/app/models/alchemy/base_record.rb +2 -0
  32. data/app/models/alchemy/eager_loading.rb +0 -1
  33. data/app/models/alchemy/element/element_ingredients.rb +1 -8
  34. data/app/models/alchemy/element/presenters.rb +9 -25
  35. data/app/models/alchemy/element.rb +2 -18
  36. data/app/models/alchemy/ingredient.rb +17 -6
  37. data/app/models/alchemy/ingredients/audio.rb +2 -0
  38. data/app/models/alchemy/ingredients/datetime.rb +3 -1
  39. data/app/models/alchemy/ingredients/file.rb +7 -0
  40. data/app/models/alchemy/ingredients/headline.rb +6 -0
  41. data/app/models/alchemy/ingredients/link.rb +2 -0
  42. data/app/models/alchemy/ingredients/node.rb +2 -0
  43. data/app/models/alchemy/ingredients/page.rb +2 -0
  44. data/app/models/alchemy/ingredients/picture.rb +11 -0
  45. data/app/models/alchemy/ingredients/richtext.rb +6 -0
  46. data/app/models/alchemy/ingredients/select.rb +1 -0
  47. data/app/models/alchemy/ingredients/text.rb +8 -0
  48. data/app/models/alchemy/ingredients/video.rb +2 -0
  49. data/app/models/alchemy/node.rb +9 -6
  50. data/app/models/alchemy/page/page_elements.rb +5 -26
  51. data/app/models/alchemy/page/page_layouts.rb +0 -14
  52. data/app/models/alchemy/page/page_natures.rb +0 -10
  53. data/app/models/alchemy/page.rb +0 -10
  54. data/app/models/alchemy/picture/transformations.rb +0 -30
  55. data/app/models/alchemy/picture/url.rb +1 -1
  56. data/app/models/alchemy/picture.rb +14 -13
  57. data/app/models/alchemy/picture_thumb/create.rb +7 -18
  58. data/app/models/alchemy/picture_thumb/file_store.rb +33 -0
  59. data/app/models/alchemy/picture_thumb.rb +10 -10
  60. data/app/models/concerns/alchemy/picture_thumbnails.rb +2 -6
  61. data/app/serializers/alchemy/element_serializer.rb +1 -6
  62. data/app/services/alchemy/delete_elements.rb +1 -7
  63. data/app/services/alchemy/duplicate_element.rb +1 -6
  64. data/app/views/alchemy/admin/elements/_element.html.erb +5 -22
  65. data/app/views/alchemy/admin/elements/create.js.erb +1 -1
  66. data/app/views/alchemy/admin/elements/fold.js.erb +2 -2
  67. data/app/views/alchemy/admin/elements/order.js.erb +1 -1
  68. data/app/views/alchemy/admin/elements/update.js.erb +1 -2
  69. data/app/views/alchemy/admin/pages/_external_link.html.erb +2 -2
  70. data/app/views/alchemy/admin/pages/_file_link.html.erb +2 -2
  71. data/app/views/alchemy/admin/pages/_internal_link.html.erb +2 -2
  72. data/app/views/alchemy/admin/pages/_table.html.erb +0 -6
  73. data/app/views/alchemy/admin/pages/_tinymce_custom_config.html.erb +3 -6
  74. data/app/views/alchemy/admin/pages/edit.html.erb +1 -1
  75. data/app/views/alchemy/admin/pictures/_filter_and_size_bar.html.erb +1 -3
  76. data/app/views/alchemy/admin/pictures/_infos.html.erb +4 -6
  77. data/app/views/alchemy/admin/resources/_per_page_select.html.erb +1 -1
  78. data/app/views/alchemy/ingredients/_boolean_editor.html.erb +1 -1
  79. data/app/views/alchemy/ingredients/_headline_editor.html.erb +1 -1
  80. data/app/views/alchemy/ingredients/_html_editor.html.erb +1 -1
  81. data/app/views/alchemy/ingredients/_node_editor.html.erb +1 -1
  82. data/app/views/alchemy/ingredients/_picture_editor.html.erb +4 -4
  83. data/app/views/alchemy/ingredients/_select_editor.html.erb +2 -2
  84. data/app/views/alchemy/ingredients/_text_editor.html.erb +1 -1
  85. data/app/views/alchemy/ingredients/shared/_link_tools.html.erb +3 -3
  86. data/app/views/alchemy/pages/_meta_data.html.erb +0 -1
  87. data/app/views/layouts/alchemy/admin.html.erb +5 -1
  88. data/config/alchemy/config.yml +6 -6
  89. data/config/brakeman.ignore +56 -57
  90. data/config/locales/alchemy.en.yml +99 -113
  91. data/config/routes.rb +1 -16
  92. data/db/migrate/20230121212637_alchemy_six_point_one.rb +248 -0
  93. data/lib/alchemy/cache_digests/template_tracker.rb +6 -7
  94. data/lib/alchemy/config.rb +2 -2
  95. data/lib/alchemy/deprecation.rb +1 -1
  96. data/lib/alchemy/errors.rb +0 -11
  97. data/lib/alchemy/hints.rb +10 -10
  98. data/lib/alchemy/permissions.rb +4 -17
  99. data/lib/alchemy/routing_constraints.rb +3 -3
  100. data/lib/alchemy/searchable_resource.rb +38 -0
  101. data/lib/alchemy/seeder.rb +2 -8
  102. data/lib/alchemy/tasks/tidy.rb +0 -38
  103. data/lib/alchemy/test_support/capybara_helpers.rb +69 -0
  104. data/lib/alchemy/test_support/factories/element_factory.rb +0 -6
  105. data/lib/alchemy/test_support/factories/ingredient_factory.rb +1 -1
  106. data/lib/alchemy/test_support/factories/page_factory.rb +4 -2
  107. data/lib/alchemy/test_support/having_picture_thumbnails_examples.rb +0 -20
  108. data/lib/alchemy/test_support/shared_dom_ids_examples.rb +1 -1
  109. data/lib/alchemy/test_support/shared_ingredient_examples.rb +1 -1
  110. data/lib/alchemy/tinymce.rb +1 -18
  111. data/lib/alchemy/upgrader/seven_point_zero.rb +45 -0
  112. data/lib/alchemy/upgrader/tasks/.keep +0 -0
  113. data/lib/alchemy/upgrader.rb +8 -3
  114. data/lib/alchemy/version.rb +1 -1
  115. data/lib/alchemy.rb +0 -19
  116. data/lib/alchemy_cms.rb +1 -2
  117. data/lib/generators/alchemy/elements/elements_generator.rb +0 -1
  118. data/lib/generators/alchemy/elements/templates/view.html.erb +1 -10
  119. data/lib/generators/alchemy/elements/templates/view.html.haml +1 -9
  120. data/lib/generators/alchemy/elements/templates/view.html.slim +1 -9
  121. data/lib/generators/alchemy/install/files/alchemy.en.yml +7 -8
  122. data/lib/generators/alchemy/install/files/application.html.erb +1 -1
  123. data/lib/generators/alchemy/install/install_generator.rb +18 -34
  124. data/lib/generators/alchemy/install/templates/elements.yml.tt +12 -12
  125. data/lib/non_stupid_digest_assets.rb +1 -1
  126. data/lib/tasks/alchemy/thumbnails.rake +2 -21
  127. data/lib/tasks/alchemy/tidy.rake +1 -12
  128. data/lib/tasks/alchemy/upgrade.rake +10 -47
  129. data/package/dist/admin.js +16 -0
  130. data/package/dist/admin.js.map +7 -0
  131. data/package.json +5 -3
  132. metadata +18 -147
  133. data/app/controllers/alchemy/admin/contents_controller.rb +0 -21
  134. data/app/controllers/alchemy/admin/essence_audios_controller.rb +0 -30
  135. data/app/controllers/alchemy/admin/essence_files_controller.rb +0 -31
  136. data/app/controllers/alchemy/admin/essence_pictures_controller.rb +0 -43
  137. data/app/controllers/alchemy/admin/essence_videos_controller.rb +0 -34
  138. data/app/controllers/alchemy/api/contents_controller.rb +0 -52
  139. data/app/decorators/alchemy/content_editor.rb +0 -119
  140. data/app/helpers/alchemy/admin/contents_helper.rb +0 -42
  141. data/app/helpers/alchemy/admin/essences_helper.rb +0 -31
  142. data/app/models/alchemy/content/factory.rb +0 -143
  143. data/app/models/alchemy/content.rb +0 -247
  144. data/app/models/alchemy/element/element_contents.rb +0 -200
  145. data/app/models/alchemy/element/element_essences.rb +0 -133
  146. data/app/models/alchemy/essence_audio.rb +0 -13
  147. data/app/models/alchemy/essence_boolean.rb +0 -20
  148. data/app/models/alchemy/essence_date.rb +0 -25
  149. data/app/models/alchemy/essence_file.rb +0 -49
  150. data/app/models/alchemy/essence_headline.rb +0 -41
  151. data/app/models/alchemy/essence_html.rb +0 -23
  152. data/app/models/alchemy/essence_link.rb +0 -21
  153. data/app/models/alchemy/essence_node.rb +0 -19
  154. data/app/models/alchemy/essence_page.rb +0 -17
  155. data/app/models/alchemy/essence_picture.rb +0 -67
  156. data/app/models/alchemy/essence_picture_view.rb +0 -90
  157. data/app/models/alchemy/essence_richtext.rb +0 -44
  158. data/app/models/alchemy/essence_select.rb +0 -19
  159. data/app/models/alchemy/essence_text.rb +0 -23
  160. data/app/models/alchemy/essence_video.rb +0 -13
  161. data/app/serializers/alchemy/content_serializer.rb +0 -17
  162. data/app/serializers/alchemy/essence_boolean_serializer.rb +0 -10
  163. data/app/serializers/alchemy/essence_date_serializer.rb +0 -10
  164. data/app/serializers/alchemy/essence_file_serializer.rb +0 -13
  165. data/app/serializers/alchemy/essence_html_serializer.rb +0 -10
  166. data/app/serializers/alchemy/essence_link_serializer.rb +0 -13
  167. data/app/serializers/alchemy/essence_picture_serializer.rb +0 -28
  168. data/app/serializers/alchemy/essence_richtext_serializer.rb +0 -11
  169. data/app/serializers/alchemy/essence_select_serializer.rb +0 -10
  170. data/app/serializers/alchemy/essence_text_serializer.rb +0 -22
  171. data/app/views/alchemy/admin/contents/create.js.erb +0 -21
  172. data/app/views/alchemy/admin/essence_audios/edit.html.erb +0 -7
  173. data/app/views/alchemy/admin/essence_files/edit.html.erb +0 -21
  174. data/app/views/alchemy/admin/essence_pictures/destroy.js.erb +0 -5
  175. data/app/views/alchemy/admin/essence_pictures/edit.html.erb +0 -30
  176. data/app/views/alchemy/admin/essence_pictures/save_link.js.erb +0 -3
  177. data/app/views/alchemy/admin/essence_pictures/update.js.erb +0 -8
  178. data/app/views/alchemy/admin/essence_videos/edit.html.erb +0 -12
  179. data/app/views/alchemy/essences/_essence_audio_editor.html.erb +0 -4
  180. data/app/views/alchemy/essences/_essence_audio_view.html.erb +0 -15
  181. data/app/views/alchemy/essences/_essence_boolean_editor.html.erb +0 -11
  182. data/app/views/alchemy/essences/_essence_boolean_view.html.erb +0 -2
  183. data/app/views/alchemy/essences/_essence_date_editor.html.erb +0 -16
  184. data/app/views/alchemy/essences/_essence_date_view.html.erb +0 -10
  185. data/app/views/alchemy/essences/_essence_file_editor.html.erb +0 -54
  186. data/app/views/alchemy/essences/_essence_file_view.html.erb +0 -18
  187. data/app/views/alchemy/essences/_essence_headline_editor.html.erb +0 -36
  188. data/app/views/alchemy/essences/_essence_headline_view.html.erb +0 -10
  189. data/app/views/alchemy/essences/_essence_html_editor.html.erb +0 -10
  190. data/app/views/alchemy/essences/_essence_html_view.html.erb +0 -2
  191. data/app/views/alchemy/essences/_essence_link_editor.html.erb +0 -30
  192. data/app/views/alchemy/essences/_essence_link_view.html.erb +0 -10
  193. data/app/views/alchemy/essences/_essence_node_editor.html.erb +0 -27
  194. data/app/views/alchemy/essences/_essence_node_view.html.erb +0 -1
  195. data/app/views/alchemy/essences/_essence_page_editor.html.erb +0 -26
  196. data/app/views/alchemy/essences/_essence_page_view.html.erb +0 -5
  197. data/app/views/alchemy/essences/_essence_picture_editor.html.erb +0 -59
  198. data/app/views/alchemy/essences/_essence_picture_view.html.erb +0 -6
  199. data/app/views/alchemy/essences/_essence_richtext_editor.html.erb +0 -14
  200. data/app/views/alchemy/essences/_essence_richtext_view.html.erb +0 -4
  201. data/app/views/alchemy/essences/_essence_select_editor.html.erb +0 -28
  202. data/app/views/alchemy/essences/_essence_select_view.html.erb +0 -2
  203. data/app/views/alchemy/essences/_essence_text_editor.html.erb +0 -29
  204. data/app/views/alchemy/essences/_essence_text_view.html.erb +0 -17
  205. data/app/views/alchemy/essences/_essence_video_editor.html.erb +0 -4
  206. data/app/views/alchemy/essences/_essence_video_view.html.erb +0 -19
  207. data/app/views/alchemy/essences/shared/_essence_picture_tools.html.erb +0 -59
  208. data/app/views/alchemy/essences/shared/_linkable_essence_tools.html.erb +0 -20
  209. data/app/views/alchemy/pages/show.rss.builder +0 -21
  210. data/db/migrate/20200226213334_alchemy_four_point_four.rb +0 -313
  211. data/db/migrate/20200423073425_create_alchemy_essence_nodes.rb +0 -11
  212. data/db/migrate/20200504210159_remove_site_id_from_nodes.rb +0 -28
  213. data/db/migrate/20200505215518_add_language_id_foreign_key_to_alchemy_pages.rb +0 -8
  214. data/db/migrate/20200511113603_add_menu_type_to_alchemy_nodes.rb +0 -27
  215. data/db/migrate/20200514091507_make_page_layoutpage_null_false.rb +0 -6
  216. data/db/migrate/20200519073500_remove_visible_from_alchemy_pages.rb +0 -24
  217. data/db/migrate/20200617110713_create_alchemy_picture_thumbs.rb +0 -22
  218. data/db/migrate/20200907111332_remove_tri_state_booleans.rb +0 -33
  219. data/db/migrate/20201207131309_create_page_versions.rb +0 -19
  220. data/db/migrate/20201207135820_add_page_version_id_to_alchemy_elements.rb +0 -76
  221. data/db/migrate/20210205143548_rename_public_on_and_public_until_on_alchemy_pages.rb +0 -10
  222. data/db/migrate/20210326105046_add_sanitized_body_to_alchemy_essence_richtexts.rb +0 -7
  223. data/db/migrate/20210406093436_add_alchemy_essence_headlines.rb +0 -12
  224. data/db/migrate/20210506135919_create_essence_audios.rb +0 -19
  225. data/db/migrate/20210506140258_create_essence_videos.rb +0 -23
  226. data/db/migrate/20210508091432_create_alchemy_ingredients.rb +0 -22
  227. data/db/migrate/20220514072456_restrict_on_delete_page_id_foreign_key_from_alchemy_nodes.rb +0 -13
  228. data/db/migrate/20220622130905_add_playsinline_to_alchemy_essence_videos.rb +0 -9
  229. data/lib/alchemy/essence.rb +0 -250
  230. data/lib/alchemy/tasks/usage.rb +0 -34
  231. data/lib/alchemy/test_support/essence_shared_examples.rb +0 -271
  232. data/lib/alchemy/test_support/factories/content_factory.rb +0 -20
  233. data/lib/alchemy/test_support/factories/essence_audio_factory.rb +0 -7
  234. data/lib/alchemy/test_support/factories/essence_file_factory.rb +0 -7
  235. data/lib/alchemy/test_support/factories/essence_page_factory.rb +0 -7
  236. data/lib/alchemy/test_support/factories/essence_picture_factory.rb +0 -11
  237. data/lib/alchemy/test_support/factories/essence_text_factory.rb +0 -7
  238. data/lib/alchemy/test_support/factories/essence_video_factory.rb +0 -7
  239. data/lib/alchemy/upgrader/five_point_zero.rb +0 -41
  240. data/lib/alchemy/upgrader/six_point_zero.rb +0 -21
  241. data/lib/alchemy/upgrader/tasks/add_page_versions.rb +0 -33
  242. data/lib/alchemy/upgrader/tasks/element_views_updater.rb +0 -34
  243. data/lib/alchemy/upgrader/tasks/harden_gutentag_migrations.rb +0 -29
  244. data/lib/alchemy/upgrader/tasks/ingredients_migrator.rb +0 -73
  245. data/lib/generators/alchemy/essence/essence_generator.rb +0 -49
  246. data/lib/generators/alchemy/essence/templates/editor.html.erb +0 -17
  247. data/lib/generators/alchemy/essence/templates/view.html.erb +0 -2
  248. data/lib/generators/alchemy/install/files/babel.config.js +0 -64
  249. data/lib/tasks/alchemy/usage.rake +0 -44
@@ -1,21 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "tasks/add_page_versions"
4
- require_relative "tasks/ingredients_migrator"
5
-
6
- module Alchemy
7
- class Upgrader::SixPointZero < Upgrader
8
- class << self
9
- def create_public_page_versions
10
- desc "Create public page versions for pages"
11
- Alchemy::Upgrader::Tasks::AddPageVersions.new.create_public_page_versions
12
- end
13
-
14
- def create_ingredients
15
- desc "Create ingredients for elements with ingredients defined"
16
- Alchemy::Upgrader::Tasks::IngredientsMigrator.new.create_ingredients
17
- log "Done.", :success
18
- end
19
- end
20
- end
21
- end
@@ -1,33 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "alchemy/upgrader"
4
-
5
- module Alchemy::Upgrader::Tasks
6
- class AddPageVersions < Thor
7
- include Thor::Actions
8
-
9
- no_tasks do
10
- def create_public_page_versions
11
- Alchemy::Deprecation.silence do
12
- Alchemy::Page.where.not(legacy_public_on: nil).find_each do |page|
13
- next if page.versions.published.any?
14
-
15
- Alchemy::Page.transaction do
16
- page.versions.create!(
17
- public_on: page.legacy_public_on,
18
- public_until: page.legacy_public_until
19
- ).tap do |version|
20
- # We must not use .find_each here to not mess up the order of elements
21
- page.draft_version.elements.not_nested.available.each do |element|
22
- Alchemy::Element.copy(element, page_version_id: version.id)
23
- end
24
- end
25
- end
26
-
27
- print "."
28
- end
29
- end
30
- end
31
- end
32
- end
33
- end
@@ -1,34 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "alchemy/upgrader"
4
-
5
- module Alchemy::Upgrader::Tasks
6
- class ElementViewsUpdater < Thor
7
- include Thor::Actions
8
-
9
- no_tasks do
10
- def rename_element_views
11
- puts "-- Removing '_view' suffix from element views"
12
-
13
- Dir.glob("#{elements_view_folder}/*_view.*").each do |file|
14
- FileUtils.mv(file, file.to_s.sub(/_view/, ""))
15
- end
16
- end
17
-
18
- def update_local_variable
19
- puts "-- Updating element views local variable to element name"
20
-
21
- Alchemy::Element.definitions.map { |e| e["name"] }.each do |name|
22
- view = Dir.glob("#{elements_view_folder}/_#{name}.*").last
23
- gsub_file(view, /\b#{name}_view\b/, name)
24
- end
25
- end
26
- end
27
-
28
- private
29
-
30
- def elements_view_folder
31
- Rails.root.join("app", "views", "alchemy", "elements")
32
- end
33
- end
34
- end
@@ -1,29 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "thor"
4
-
5
- module Alchemy::Upgrader::Tasks
6
- class HardenGutentagMigrations < Thor
7
- include Thor::Actions
8
-
9
- no_tasks do
10
- def patch_migrations
11
- sentinel = /def up/
12
-
13
- migration_file = Dir.glob("db/migrate/*_gutentag_tables.gutentag.rb").first
14
- if migration_file
15
- inject_into_file migration_file,
16
- "\n # inserted by Alchemy CMS upgrader\n return if table_exists?(:gutentag_taggings)\n",
17
- { after: sentinel, verbose: true }
18
- end
19
-
20
- migration_file = Dir.glob("db/migrate/*_gutentag_cache_counter.gutentag.rb").first
21
- if migration_file
22
- inject_into_file migration_file,
23
- "\n # inserted by Alchemy CMS upgrader\n return if column_exists?(:gutentag_tags, :taggings_count)\n",
24
- { after: sentinel, verbose: true }
25
- end
26
- end
27
- end
28
- end
29
- end
@@ -1,73 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "alchemy/upgrader"
4
-
5
- module Alchemy::Upgrader::Tasks
6
- class IngredientsMigrator < Thor
7
- include Thor::Actions
8
-
9
- no_tasks do
10
- def create_ingredients(verbose: !Rails.env.test?)
11
- Rails.logger.silence do
12
- Alchemy::Deprecation.silence do
13
- elements_with_ingredients = Alchemy::ElementDefinition.all.select { |d| d.key?(:ingredients) }
14
- if ENV["ONLY"]
15
- elements_with_ingredients = elements_with_ingredients.select { |d| d[:name].in? ENV["ONLY"].split(",") }
16
- end
17
- elements_with_ingredients.each do |element_definition|
18
- elements = Alchemy::Element
19
- .named(element_definition[:name])
20
- .left_outer_joins(:ingredients).where(alchemy_ingredients: { id: nil })
21
- count = elements.count
22
- if count.positive?
23
- puts "-- Creating ingredients for #{elements.count} #{element_definition[:name]}(s)" if verbose
24
- elements.preload(contents: :essence).find_each.with_index(1) do |element, index|
25
- MigrateElementIngredients.call(element)
26
- puts "\e[H\e[2J #{index}/#{count}" if verbose
27
- end
28
- puts "\n" if verbose
29
- elsif verbose
30
- puts "-- No #{element_definition[:name]} elements found for migration."
31
- end
32
- end
33
- end
34
- end
35
- end
36
- end
37
-
38
- class MigrateElementIngredients
39
- def self.call(element)
40
- Alchemy::Element.transaction do
41
- element.definition[:ingredients].each do |ingredient_definition|
42
- ingredient = element.ingredients.build(
43
- role: ingredient_definition[:role],
44
- type: Alchemy::Ingredient.normalize_type(ingredient_definition[:type]),
45
- )
46
-
47
- content = element.content_by_name(ingredient_definition[:role])
48
- if content
49
- essence = content.essence
50
- if essence
51
- belongs_to_associations = essence.class.reflect_on_all_associations(:belongs_to)
52
- if belongs_to_associations.any?
53
- ingredient.related_object = essence.public_send(belongs_to_associations.first.name)
54
- else
55
- ingredient.value = content.ingredient
56
- end
57
- data = ingredient.class.stored_attributes.fetch(:data, []).each_with_object({}) do |attr, d|
58
- next unless essence.respond_to?(attr)
59
-
60
- d[attr] = essence.public_send(attr)
61
- end
62
- ingredient.data = data
63
- end
64
- content.destroy!
65
- end
66
-
67
- ingredient.save!
68
- end
69
- end
70
- end
71
- end
72
- end
73
- end
@@ -1,49 +0,0 @@
1
- # frozen_string_literal: true
2
- require "rails"
3
-
4
- module Alchemy
5
- module Generators
6
- class EssenceGenerator < ::Rails::Generators::Base
7
- desc "This generator generates an Alchemy essence for you."
8
- argument :essence_name, banner: "YourEssenceName"
9
- source_root File.expand_path("templates", __dir__)
10
-
11
- def init
12
- @essence_name = essence_name.underscore
13
- @essence_view_path = "app/views/alchemy/essences"
14
- end
15
-
16
- def create_model
17
- invoke("model", [@essence_name])
18
- end
19
-
20
- def act_as_essence
21
- essence_class_file = "app/models/#{@essence_name}.rb"
22
- essence_class = @essence_name.classify
23
- inject_into_class essence_class_file, essence_class, <<~CLASSMETHOD
24
- acts_as_essence(
25
- # Your options:
26
- #
27
- # ingredient_column: [String or Symbol] - Specifies the column name you use for storing the content in the database. (Default :body)
28
- # validate_column: [String or Symbol] - Which column should be validated. (Default: ingredient_column)
29
- # preview_text_column: [String or Symbol] - Specifies the column for the preview_text method. (Default: ingredient_column)
30
- # preview_text_method: [String or Symbol] - A method called on ingredient to get the preview text. (Default: ingredient_column)
31
- )
32
- CLASSMETHOD
33
- end
34
-
35
- def copy_templates
36
- essence_name = @essence_name.classify.demodulize.underscore
37
- @essence_editor_local = "#{essence_name}_editor"
38
- template "view.html.erb", "#{@essence_view_path}/_#{essence_name}_view.html.erb"
39
- template "editor.html.erb", "#{@essence_view_path}/_#{essence_name}_editor.html.erb"
40
- end
41
-
42
- def show_todo
43
- say "\nPlease open the generated migration file and add your columns to your table."
44
- say "Then run 'rake db:migrate' to update your database."
45
- say "Also check the generated view files and alter them to fit your needs."
46
- end
47
- end
48
- end
49
- end
@@ -1,17 +0,0 @@
1
- <%%#
2
- Available locals:
3
- * <%= @essence_editor_local %> - A Alchemy::ContentEditor instance
4
-
5
- Please consult Alchemy::Content.rb docs for further methods on the content object
6
- %>
7
- <%%= content_tag :div,
8
- id: <%= @essence_editor_local %>.dom_id,
9
- class: <%= @essence_editor_local %>.css_classes,
10
- data: <%= @essence_editor_local %>.data_attributes do %>
11
- <%%= content_label(<%= @essence_editor_local %>) %>
12
- <%%= text_field_tag(
13
- <%= @essence_editor_local %>.form_field_name,
14
- <%= @essence_editor_local %>.ingredient,
15
- id: <%= @essence_editor_local %>.form_field_id
16
- ) %>
17
- <%% end %>
@@ -1,2 +0,0 @@
1
- <%%# The content object holds the essence %>
2
- <%%= content.ingredient %>
@@ -1,64 +0,0 @@
1
- module.exports = function (api) {
2
- var validEnv = ["development", "test", "production"]
3
- var currentEnv = api.env()
4
- var isDevelopmentEnv = api.env("development")
5
- var isProductionEnv = api.env("production")
6
- var isTestEnv = api.env("test")
7
-
8
- if (!validEnv.includes(currentEnv)) {
9
- throw new Error(
10
- "Please specify a valid `NODE_ENV` or " +
11
- '`BABEL_ENV` environment variables. Valid values are "development", ' +
12
- '"test", and "production". Instead, received: ' +
13
- JSON.stringify(currentEnv) +
14
- "."
15
- )
16
- }
17
-
18
- return {
19
- presets: [
20
- isTestEnv && [
21
- "@babel/preset-env",
22
- {
23
- targets: {
24
- node: "current"
25
- }
26
- }
27
- ],
28
- (isProductionEnv || isDevelopmentEnv) && [
29
- "@babel/preset-env",
30
- {
31
- forceAllTransforms: true,
32
- useBuiltIns: "entry",
33
- corejs: 3,
34
- modules: false,
35
- exclude: ["transform-typeof-symbol"]
36
- }
37
- ]
38
- ].filter(Boolean),
39
- plugins: [
40
- "babel-plugin-macros",
41
- "@babel/plugin-syntax-dynamic-import",
42
- isTestEnv && "babel-plugin-dynamic-import-node",
43
- "@babel/plugin-transform-destructuring",
44
- [
45
- "@babel/plugin-proposal-object-rest-spread",
46
- {
47
- useBuiltIns: true
48
- }
49
- ],
50
- [
51
- "@babel/plugin-transform-runtime",
52
- {
53
- helpers: false
54
- }
55
- ],
56
- [
57
- "@babel/plugin-transform-regenerator",
58
- {
59
- async: false
60
- }
61
- ]
62
- ].filter(Boolean)
63
- }
64
- }
@@ -1,44 +0,0 @@
1
- require "alchemy/tasks/usage"
2
-
3
- namespace :alchemy do
4
- desc "List Alchemy elements and pages usage"
5
- task usage: [:page_usage, :element_usage]
6
-
7
- desc "List Alchemy elements usage"
8
- task page_usage: :environment do
9
- include ActionView::Helpers::NumberHelper
10
- puts "\n Alchemy pages usage"
11
- results = Alchemy::Tasks::Usage.pages_count_by_type
12
- if results.any?
13
- puts " ----------------------"
14
- puts "\n"
15
- results.each do |row|
16
- puts " #{number_with_delimiter(row["count"])} ๐—‘ #{row["page_layout"]}"
17
- end
18
- puts "\n = #{number_with_delimiter(Alchemy::Page.count)} pages in total."
19
- else
20
- puts " > No pages found!"
21
- end
22
- end
23
-
24
- desc "List Alchemy elements usage"
25
- task element_usage: :environment do
26
- include ActionView::Helpers::NumberHelper
27
- puts "\n Alchemy elements usage"
28
- results = Alchemy::Tasks::Usage.elements_count_by_name
29
- if results.any?
30
- puts " ----------------------"
31
- puts "\n"
32
- results.each do |row|
33
- ingredients = row.key?("ingredients") ? "uses ingredients โœ…" : nil
34
- contents = row.key?("contents") ? "still uses contents โ€ผ๏ธ" : nil
35
- type = ingredients || contents
36
- suffix = type ? " ยท #{type}" : nil
37
- puts " #{number_with_delimiter(row["count"])} ๐—‘ #{row["name"]}#{suffix}"
38
- end
39
- puts "\n = #{number_with_delimiter(Alchemy::Element.count)} elements in total."
40
- else
41
- puts " > No elements found!"
42
- end
43
- end
44
- end