alchemy_cms 7.0.0.pre.a → 7.0.0.pre.c

Sign up to get free protection for your applications and to get access to all the features.
Files changed (237) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/brakeman-analysis.yml +2 -2
  3. data/.github/workflows/lint.yml +37 -0
  4. data/.github/workflows/{ci.yml → test.yml} +8 -8
  5. data/.gitignore +0 -5
  6. data/.hound.yml +2 -3
  7. data/.rubocop.yml +4 -350
  8. data/.standard.yml +3 -0
  9. data/CHANGELOG.md +33 -0
  10. data/Gemfile +3 -2
  11. data/README.md +10 -12
  12. data/Rakefile +0 -19
  13. data/alchemy_cms.gemspec +4 -2
  14. data/app/assets/config/alchemy_manifest.js +1 -0
  15. data/app/assets/javascripts/alchemy/admin.js +0 -2
  16. data/app/assets/javascripts/alchemy/alchemy.dirty.js.coffee +1 -1
  17. data/app/assets/javascripts/alchemy/alchemy.initializer.js.coffee +5 -12
  18. data/app/assets/javascripts/alchemy/alchemy.link_dialog.js.coffee +6 -1
  19. data/app/assets/stylesheets/alchemy/base.scss +2 -2
  20. data/app/components/alchemy/ingredients/audio_view.rb +37 -0
  21. data/app/components/alchemy/ingredients/base_view.rb +38 -0
  22. data/app/components/alchemy/ingredients/boolean_view.rb +13 -0
  23. data/app/components/alchemy/ingredients/datetime_view.rb +22 -0
  24. data/app/components/alchemy/ingredients/file_view.rb +40 -0
  25. data/app/components/alchemy/ingredients/headline_view.rb +20 -0
  26. data/app/components/alchemy/ingredients/html_view.rb +9 -0
  27. data/app/components/alchemy/ingredients/link_view.rb +25 -0
  28. data/app/components/alchemy/ingredients/node_view.rb +11 -0
  29. data/app/components/alchemy/ingredients/page_view.rb +15 -0
  30. data/app/components/alchemy/ingredients/picture_view.rb +108 -0
  31. data/app/components/alchemy/ingredients/richtext_view.rb +22 -0
  32. data/app/components/alchemy/ingredients/select_view.rb +6 -0
  33. data/app/components/alchemy/ingredients/text_view.rb +41 -0
  34. data/app/components/alchemy/ingredients/video_view.rb +39 -0
  35. data/app/controllers/alchemy/admin/attachments_controller.rb +3 -3
  36. data/app/controllers/alchemy/admin/base_controller.rb +7 -7
  37. data/app/controllers/alchemy/admin/clipboard_controller.rb +2 -2
  38. data/app/controllers/alchemy/admin/elements_controller.rb +26 -11
  39. data/app/controllers/alchemy/admin/languages_controller.rb +1 -1
  40. data/app/controllers/alchemy/admin/nodes_controller.rb +2 -2
  41. data/app/controllers/alchemy/admin/pages_controller.rb +10 -10
  42. data/app/controllers/alchemy/admin/pictures_controller.rb +14 -14
  43. data/app/controllers/alchemy/admin/resources_controller.rb +27 -28
  44. data/app/controllers/alchemy/admin/styleguide_controller.rb +1 -0
  45. data/app/controllers/alchemy/admin/tags_controller.rb +11 -11
  46. data/app/controllers/alchemy/api/base_controller.rb +2 -2
  47. data/app/controllers/alchemy/api/elements_controller.rb +11 -11
  48. data/app/controllers/alchemy/api/ingredients_controller.rb +1 -1
  49. data/app/controllers/alchemy/api/nodes_controller.rb +1 -1
  50. data/app/controllers/alchemy/api/pages_controller.rb +11 -11
  51. data/app/controllers/alchemy/attachments_controller.rb +3 -3
  52. data/app/controllers/alchemy/base_controller.rb +1 -8
  53. data/app/controllers/alchemy/messages_controller.rb +9 -9
  54. data/app/controllers/alchemy/pages_controller.rb +8 -19
  55. data/app/controllers/concerns/alchemy/admin/archive_overlay.rb +1 -0
  56. data/app/controllers/concerns/alchemy/admin/uploader_responses.rb +5 -7
  57. data/app/controllers/concerns/alchemy/legacy_page_redirects.rb +5 -5
  58. data/app/decorators/alchemy/element_editor.rb +4 -4
  59. data/app/decorators/alchemy/ingredient_editor.rb +6 -6
  60. data/app/helpers/alchemy/admin/attachments_helper.rb +1 -1
  61. data/app/helpers/alchemy/admin/base_helper.rb +21 -22
  62. data/app/helpers/alchemy/admin/elements_helper.rb +1 -1
  63. data/app/helpers/alchemy/admin/form_helper.rb +1 -1
  64. data/app/helpers/alchemy/admin/navigation_helper.rb +7 -7
  65. data/app/helpers/alchemy/admin/pages_helper.rb +2 -2
  66. data/app/helpers/alchemy/admin/tags_helper.rb +3 -3
  67. data/app/helpers/alchemy/base_helper.rb +2 -2
  68. data/app/helpers/alchemy/elements_block_helper.rb +9 -7
  69. data/app/helpers/alchemy/elements_helper.rb +12 -12
  70. data/app/helpers/alchemy/pages_helper.rb +11 -11
  71. data/app/helpers/alchemy/url_helper.rb +1 -1
  72. data/{package/src → app/javascript/alchemy_admin}/datepicker.js +1 -0
  73. data/{package/src → app/javascript/alchemy_admin}/node_tree.js +2 -2
  74. data/{package/src → app/javascript/alchemy_admin}/page_publication_fields.js +1 -1
  75. data/{package/src → app/javascript/alchemy_admin}/page_sorter.js +1 -1
  76. data/{package/src → app/javascript/alchemy_admin}/picture_editors.js +2 -2
  77. data/{package/src → app/javascript/alchemy_admin}/sitemap.js +4 -4
  78. data/app/javascript/alchemy_admin/tinymce.js +142 -0
  79. data/app/javascript/alchemy_admin.js +34 -0
  80. data/app/mailers/alchemy/messages_mailer.rb +1 -1
  81. data/app/models/alchemy/attachment.rb +6 -6
  82. data/app/models/alchemy/base_record.rb +1 -0
  83. data/app/models/alchemy/eager_loading.rb +6 -6
  84. data/app/models/alchemy/element/definitions.rb +1 -1
  85. data/app/models/alchemy/element/element_ingredients.rb +3 -3
  86. data/app/models/alchemy/element.rb +2 -2
  87. data/app/models/alchemy/elements_repository.rb +1 -1
  88. data/app/models/alchemy/image_cropper_settings.rb +2 -2
  89. data/app/models/alchemy/ingredient.rb +14 -12
  90. data/app/models/alchemy/ingredient_validator.rb +1 -1
  91. data/app/models/alchemy/ingredients/datetime.rb +1 -1
  92. data/app/models/alchemy/ingredients/file.rb +5 -5
  93. data/app/models/alchemy/ingredients/headline.rb +4 -4
  94. data/app/models/alchemy/ingredients/picture.rb +27 -9
  95. data/app/models/alchemy/ingredients/richtext.rb +15 -12
  96. data/app/models/alchemy/ingredients/text.rb +6 -6
  97. data/app/models/alchemy/language/code.rb +1 -1
  98. data/app/models/alchemy/language.rb +4 -4
  99. data/app/models/alchemy/legacy_page_url.rb +1 -1
  100. data/app/models/alchemy/node.rb +2 -2
  101. data/app/models/alchemy/page/page_elements.rb +14 -14
  102. data/app/models/alchemy/page/page_naming.rb +4 -4
  103. data/app/models/alchemy/page/page_natures.rb +1 -1
  104. data/app/models/alchemy/page/page_scopes.rb +5 -5
  105. data/app/models/alchemy/page.rb +11 -11
  106. data/app/models/alchemy/picture/calculations.rb +2 -2
  107. data/app/models/alchemy/picture/transformations.rb +2 -2
  108. data/app/models/alchemy/picture/url.rb +4 -4
  109. data/app/models/alchemy/picture.rb +11 -10
  110. data/app/models/alchemy/picture_thumb/create.rb +1 -1
  111. data/app/models/alchemy/picture_thumb.rb +1 -1
  112. data/app/models/alchemy/picture_variant.rb +2 -3
  113. data/app/models/alchemy/tag.rb +8 -0
  114. data/app/models/concerns/alchemy/picture_thumbnails.rb +6 -6
  115. data/app/serializers/alchemy/base_serializer.rb +1 -1
  116. data/app/serializers/alchemy/page_tree_serializer.rb +7 -7
  117. data/app/services/alchemy/duplicate_element.rb +3 -3
  118. data/app/services/alchemy/tag_validations.rb +1 -1
  119. data/app/views/alchemy/_menubar.html.erb +1 -1
  120. data/app/views/alchemy/admin/attachments/_replace_button.html.erb +1 -1
  121. data/app/views/alchemy/admin/attachments/destroy.js.erb +1 -1
  122. data/app/views/alchemy/admin/elements/_element.html.erb +3 -0
  123. data/app/views/alchemy/admin/nodes/index.html.erb +4 -2
  124. data/app/views/alchemy/admin/pages/_page_layout_filter.html.erb +1 -1
  125. data/app/views/alchemy/admin/pages/edit.html.erb +3 -7
  126. data/app/views/alchemy/admin/pages/index.html.erb +1 -1
  127. data/app/views/alchemy/admin/pages/update.js.erb +12 -6
  128. data/app/views/alchemy/admin/pictures/_infos.html.erb +1 -1
  129. data/app/views/alchemy/admin/resources/_filter_bar.html.erb +1 -1
  130. data/app/views/alchemy/admin/styleguide/index.html.erb +1 -1
  131. data/app/views/alchemy/admin/uploader/_button.html.erb +1 -1
  132. data/app/views/alchemy/base/permission_denied.js.erb +1 -1
  133. data/app/views/alchemy/base/redirect.js.erb +1 -1
  134. data/app/views/alchemy/ingredients/_audio_view.html.erb +1 -14
  135. data/app/views/alchemy/ingredients/_boolean_view.html.erb +1 -1
  136. data/app/views/alchemy/ingredients/_datetime_view.html.erb +3 -9
  137. data/app/views/alchemy/ingredients/_file_view.html.erb +3 -16
  138. data/app/views/alchemy/ingredients/_headline_view.html.erb +4 -10
  139. data/app/views/alchemy/ingredients/_html_view.html.erb +1 -1
  140. data/app/views/alchemy/ingredients/_link_view.html.erb +4 -9
  141. data/app/views/alchemy/ingredients/_node_view.html.erb +1 -1
  142. data/app/views/alchemy/ingredients/_page_view.html.erb +1 -4
  143. data/app/views/alchemy/ingredients/_picture_view.html.erb +4 -5
  144. data/app/views/alchemy/ingredients/_richtext_editor.html.erb +11 -2
  145. data/app/views/alchemy/ingredients/_richtext_view.html.erb +3 -3
  146. data/app/views/alchemy/ingredients/_select_view.html.erb +1 -1
  147. data/app/views/alchemy/ingredients/_text_view.html.erb +3 -19
  148. data/app/views/alchemy/ingredients/_video_view.html.erb +3 -18
  149. data/app/views/alchemy/ingredients/shared/_link_tools.html.erb +1 -0
  150. data/app/views/alchemy/ingredients/shared/_picture_tools.html.erb +1 -0
  151. data/app/views/layouts/alchemy/admin.html.erb +9 -15
  152. data/bin/importmap +4 -0
  153. data/bin/setup +28 -0
  154. data/bin/start +17 -0
  155. data/config/brakeman.ignore +0 -46
  156. data/config/importmap.rb +8 -0
  157. data/config/initializers/assets.rb +1 -0
  158. data/config/initializers/dragonfly.rb +1 -0
  159. data/config/initializers/mime_types.rb +1 -0
  160. data/config/initializers/mini_profiler.rb +1 -0
  161. data/config/initializers/simple_form.rb +3 -2
  162. data/config/locales/alchemy.en.yml +1 -1
  163. data/config/routes.rb +21 -20
  164. data/config/spring.rb +1 -0
  165. data/db/migrate/20230121212637_alchemy_six_point_one.rb +8 -8
  166. data/db/migrate/20230505132743_add_indexes_to_alchemy_pictures.rb +6 -0
  167. data/lib/alchemy/admin/locale.rb +3 -3
  168. data/lib/alchemy/admin/preview_url.rb +2 -2
  169. data/lib/alchemy/auth_accessors.rb +1 -1
  170. data/lib/alchemy/config.rb +1 -1
  171. data/lib/alchemy/controller_actions.rb +4 -4
  172. data/lib/alchemy/deprecation.rb +1 -0
  173. data/lib/alchemy/dragonfly/processors/thumbnail.rb +1 -1
  174. data/lib/alchemy/element_definition.rb +2 -2
  175. data/lib/alchemy/engine.rb +16 -1
  176. data/lib/alchemy/filetypes.rb +7 -7
  177. data/lib/alchemy/forms/builder.rb +4 -4
  178. data/lib/alchemy/i18n.rb +6 -4
  179. data/lib/alchemy/install/tasks.rb +2 -1
  180. data/lib/alchemy/name_conversions.rb +1 -1
  181. data/lib/alchemy/page_layout.rb +1 -1
  182. data/lib/alchemy/permissions.rb +5 -4
  183. data/lib/alchemy/resource.rb +10 -10
  184. data/lib/alchemy/resources_helper.rb +7 -7
  185. data/lib/alchemy/routing_constraints.rb +2 -2
  186. data/lib/alchemy/seeder.rb +12 -5
  187. data/lib/alchemy/shell.rb +2 -1
  188. data/lib/alchemy/taggable.rb +3 -2
  189. data/lib/alchemy/tasks/tidy.rb +1 -0
  190. data/lib/alchemy/test_support/capybara_helpers.rb +1 -1
  191. data/lib/alchemy/test_support/config_stubbing.rb +1 -0
  192. data/lib/alchemy/test_support/factories/element_factory.rb +4 -0
  193. data/lib/alchemy/test_support/factories/page_factory.rb +2 -2
  194. data/lib/alchemy/test_support/having_crop_action_examples.rb +9 -9
  195. data/lib/alchemy/test_support/having_picture_thumbnails_examples.rb +33 -33
  196. data/lib/alchemy/test_support/integration_helpers.rb +4 -3
  197. data/lib/alchemy/test_support/shared_contexts.rb +2 -1
  198. data/lib/alchemy/test_support/shared_dom_ids_examples.rb +9 -9
  199. data/lib/alchemy/test_support/shared_ingredient_examples.rb +12 -6
  200. data/lib/alchemy/test_support/shared_uploader_examples.rb +1 -0
  201. data/lib/alchemy/tinymce.rb +3 -26
  202. data/lib/alchemy/upgrader/seven_point_zero.rb +13 -23
  203. data/lib/alchemy/upgrader.rb +1 -11
  204. data/lib/alchemy/version.rb +1 -1
  205. data/lib/alchemy.rb +5 -0
  206. data/lib/alchemy_cms.rb +3 -1
  207. data/lib/generators/alchemy/base.rb +3 -2
  208. data/lib/generators/alchemy/elements/elements_generator.rb +2 -1
  209. data/lib/generators/alchemy/ingredient/ingredient_generator.rb +1 -0
  210. data/lib/generators/alchemy/install/files/application.html.erb +2 -2
  211. data/lib/generators/alchemy/install/install_generator.rb +2 -25
  212. data/lib/generators/alchemy/module/module_generator.rb +1 -0
  213. data/lib/generators/alchemy/page_layouts/page_layouts_generator.rb +1 -0
  214. data/lib/generators/alchemy/site_layouts/site_layouts_generator.rb +1 -0
  215. data/lib/generators/alchemy/views/views_generator.rb +2 -1
  216. data/lib/tasks/alchemy/thumbnails.rake +5 -5
  217. data/lib/tasks/alchemy/tidy.rake +1 -0
  218. data/lib/tasks/alchemy/upgrade.rake +10 -15
  219. data/package.json +6 -26
  220. metadata +80 -31
  221. data/app/assets/javascripts/alchemy/alchemy.tinymce.js.coffee +0 -93
  222. data/app/presenters/alchemy/picture_view.rb +0 -88
  223. data/app/views/alchemy/admin/pages/_tinymce_custom_config.html.erb +0 -10
  224. data/package/admin.js +0 -32
  225. data/package/dist/admin.js +0 -16
  226. data/package/dist/admin.js.map +0 -7
  227. data/package/src/__tests__/i18n.spec.js +0 -93
  228. data/package/src/utils/__tests__/ajax.spec.js +0 -168
  229. data/package/src/utils/__tests__/events.spec.js +0 -38
  230. /data/{package/src → app/javascript/alchemy_admin}/file_editors.js +0 -0
  231. /data/{package/src → app/javascript/alchemy_admin}/i18n.js +0 -0
  232. /data/{package/src → app/javascript/alchemy_admin}/image_cropper.js +0 -0
  233. /data/{package/src → app/javascript/alchemy_admin}/image_loader.js +0 -0
  234. /data/{package/src → app/javascript/alchemy_admin}/ingredient_anchor_link.js +0 -0
  235. /data/{package/src → app/javascript/alchemy_admin}/translations.js +0 -0
  236. /data/{package/src → app/javascript/alchemy_admin}/utils/ajax.js +0 -0
  237. /data/{package/src → app/javascript/alchemy_admin}/utils/events.js +0 -0
@@ -11,7 +11,7 @@ module Alchemy
11
11
  end
12
12
 
13
13
  def call
14
- klass.validates :name, presence: true, uniqueness: { case_sensitive: true }
14
+ klass.validates :name, presence: true, uniqueness: {case_sensitive: true}
15
15
  end
16
16
 
17
17
  private
@@ -1,5 +1,5 @@
1
1
  <% if !@preview_mode && @page && can?(:edit_content, @page) %>
2
- <div id="alchemy_menubar" style="display: none" data-turbolinks="false">
2
+ <div id="alchemy_menubar" style="display: none" data-turbo="false">
3
3
  <ul>
4
4
  <li><%= link_to Alchemy.t(:to_alchemy), alchemy.admin_dashboard_url %></li>
5
5
  <li><%= link_to Alchemy.t(:edit_page), alchemy.edit_admin_page_url(@page) %></li>
@@ -17,7 +17,7 @@
17
17
  selector: '#replace_<%= dom_id(object) %>',
18
18
  file_types: '<%= file_types.join("|") %>',
19
19
  complete: function() {
20
- Turbolinks.visit('<%= redirect_url.html_safe %>');
20
+ Turbo.visit('<%= redirect_url.html_safe %>');
21
21
  }
22
22
  };
23
23
  Alchemy.Uploader(options);
@@ -1 +1 @@
1
- Turbolinks.visit('<%= @url %>');
1
+ Turbo.visit('<%= @url %>');
@@ -56,6 +56,9 @@
56
56
  <% end %>
57
57
  <% end %>
58
58
 
59
+ <%# We need to render nested elements even if the element is folded,
60
+ because we need the element present in the DOM for the feature
61
+ "click element in the preview => load and expand element editor". %>
59
62
  <% if element.nestable_elements.any? %>
60
63
  <div class="nestable-elements">
61
64
  <%= content_tag :div,
@@ -42,6 +42,8 @@
42
42
  <% end %>
43
43
  </div>
44
44
 
45
- <script>
46
- Alchemy.NodeTree()
45
+ <script type="module">
46
+ import NodeTree from "alchemy_admin/node_tree"
47
+
48
+ NodeTree()
47
49
  </script>
@@ -23,7 +23,7 @@
23
23
  $("#page_layout").on("change", function(e) {
24
24
  var url = "<%= alchemy.admin_pages_path(search_filter_params.except(:page_layout, :page).merge(view: "list")) %>";
25
25
  delimiter = url.match(/\?/) ? "&" : "?";
26
- Turbolinks.visit(url + delimiter + "page_layout=" + encodeURIComponent($(this).val()));
26
+ Turbo.visit(url + delimiter + "page_layout=" + encodeURIComponent($(this).val()));
27
27
  });
28
28
  });
29
29
  </script>
@@ -81,7 +81,7 @@
81
81
  host: @page.site.host == "*" ? request.host : @page.site.host,
82
82
  ),
83
83
  title: Alchemy.t("Visit page"),
84
- data: { turbolinks: false },
84
+ data: { turbo: false },
85
85
  target: "_blank",
86
86
  class: 'icon_button' do %>
87
87
  <%= render_icon('external-link-alt') %>
@@ -138,17 +138,13 @@
138
138
  <% end %>
139
139
 
140
140
  <% content_for :javascripts do %>
141
- <% if Alchemy::Tinymce.custom_configs_present?(@page) %>
142
- <%= render 'tinymce_custom_config' %>
143
- <% end %>
144
141
 
145
142
  <% content_for :javascript_includes do %>
146
- <meta name="turbolinks-cache-control" content="no-cache">
143
+ <meta name="turbo-cache-control" content="no-cache">
147
144
  <% end %>
148
145
 
149
146
  <script type="text/javascript" charset="utf-8">
150
-
151
- $(function() {
147
+ $(document).one('turbo:load', function() {
152
148
  $('#unlock_page_form, #publish_page_form').on('submit', function(event) {
153
149
  var not_dirty = Alchemy.checkPageDirtyness(this);
154
150
  if (!not_dirty) Alchemy.pleaseWaitOverlay(false);
@@ -1,5 +1,5 @@
1
1
  <% content_for :javascript_includes do %>
2
- <meta name="turbolinks-cache-control" content="no-cache">
2
+ <meta name="turbo-cache-control" content="no-cache">
3
3
  <% end %>
4
4
 
5
5
  <% content_for :toolbar do %>
@@ -18,18 +18,24 @@
18
18
  <% else -%>
19
19
 
20
20
  if (page) {
21
- var page_html = "<%= j render('page', page: @page) %>".replace(/__ID__/g, "<%= @page.id %>");;
22
- var compiler = Handlebars.compile(page_html);
23
- var tree = <%== @tree.to_json %>;
24
- page.outerHTML = compiler(tree.pages[0]);
21
+
22
+ <% if @page.layoutpage %>
23
+ page.outerHTML = "<%= j render('alchemy/admin/layoutpages/layoutpage', layoutpage: @page) %>"
24
+ <% else %>
25
+ const page_html = "<%= j render('page', page: @page) %>".replace(/__ID__/g, "<%= @page.id %>");
26
+ const compiler = Handlebars.compile(page_html);
27
+ const tree = <%== @tree.to_json %>;
28
+ page.outerHTML = compiler(tree.pages[0]);
29
+ <% end %>
30
+
25
31
  Alchemy.growl("<%= j @notice %>");
26
32
  Alchemy.closeCurrentDialog();
27
33
  } else {
28
- document.addEventListener('turbolinks:load', function () {
34
+ document.addEventListener('turbo:load', function () {
29
35
  Alchemy.growl("<%= j @notice %>");
30
36
  }, { once: true })
31
37
  Alchemy.closeCurrentDialog(function() {
32
- Turbolinks.visit(location.toString(), { action: "replace" });
38
+ Turbo.visit(location.toString(), { action: "replace" });
33
39
  });
34
40
  }
35
41
 
@@ -34,7 +34,7 @@
34
34
  <li class="<%= cycle('even', 'odd') %>">
35
35
  <% page_link = link_to element.display_name_with_preview_text,
36
36
  edit_admin_page_path(page, anchor: "element_#{element.id}") %>
37
- <% ingredients = picture_ingredients.collect(&:translated_role).to_sentence %>
37
+ <% ingredients = picture_ingredients.map { |p| Alchemy::IngredientEditor.new(p).translated_role }.to_sentence %>
38
38
  <% if element.public? %>
39
39
  <%= render_icon('window-maximize', style: 'regular') %>
40
40
  <% else %>
@@ -19,7 +19,7 @@
19
19
  if ($this.data('remote') === true) {
20
20
  $.get(path, params.toString(), null, 'script');
21
21
  } else {
22
- Turbolinks.visit(path + '?' + params.toString());
22
+ Turbo.visit(path + '?' + params.toString());
23
23
  }
24
24
  return false;
25
25
  });
@@ -3,7 +3,7 @@
3
3
  <% end %>
4
4
 
5
5
  <% content_for :javascript_includes do %>
6
- <meta name="turbolinks-cache-control" content="no-cache">
6
+ <meta name="turbo-cache-control" content="no-cache">
7
7
  <% end %>
8
8
 
9
9
  <% content_for(:toolbar) do %>
@@ -27,7 +27,7 @@
27
27
  <% if local_assigns[:in_dialog] %>
28
28
  $.get(url, null, null, 'script');
29
29
  <% else %>
30
- Turbolinks.visit(url);
30
+ Turbo.visit(url);
31
31
  <% end %>
32
32
  }
33
33
  };
@@ -1,3 +1,3 @@
1
1
  Alchemy.closeCurrentDialog(function() {
2
- Turbolinks.visit('<%= Alchemy.login_path %>');
2
+ Turbo.visit('<%= Alchemy.login_path %>');
3
3
  });
@@ -1,7 +1,7 @@
1
1
  (function() {
2
2
  var dialog = Alchemy.currentDialog();
3
3
  var callback = function() {
4
- Turbolinks.visit('<%= url_for(@redirect_url) %>');
4
+ Turbo.visit('<%= url_for(@redirect_url) %>');
5
5
  };
6
6
  if (dialog) {
7
7
  Alchemy.closeCurrentDialog(callback);
@@ -1,14 +1 @@
1
- <%- if audio_view.attachment -%>
2
- <%= content_tag :audio,
3
- controls: audio_view.controls,
4
- autoplay: audio_view.autoplay,
5
- loop: audio_view.loop,
6
- muted: audio_view.muted do %>
7
- <%= tag :source,
8
- src: alchemy.show_attachment_path(
9
- audio_view.attachment,
10
- format: audio_view.attachment.suffix
11
- ),
12
- type: audio_view.attachment.file_mime_type %>
13
- <% end %>
14
- <%- end -%>
1
+ <%= render audio_view.as_view_component -%>
@@ -1 +1 @@
1
- <%= Alchemy.t(boolean_view.value, scope: "ingredient_values.boolean") unless boolean_view.value.nil? -%>
1
+ <%= render boolean_view.as_view_component -%>
@@ -1,9 +1,3 @@
1
- <%- date_format = datetime_view.settings_value(:date_format,
2
- local_assigns.fetch(:options, {})) -%>
3
- <%- if datetime_view.value.present? -%>
4
- <%- if date_format == 'rfc822' -%>
5
- <%= datetime_view.value.to_s(:rfc822) %>
6
- <%- else -%>
7
- <%= l(datetime_view.value, format: date_format) %>
8
- <%- end -%>
9
- <%- end -%>
1
+ <%= render datetime_view.as_view_component(
2
+ **local_assigns.slice(:options)
3
+ ) -%>
@@ -1,17 +1,4 @@
1
- <%- if attachment = file_view.attachment -%>
2
- <%- html_options = local_assigns.fetch(:html_options, {}) -%>
3
- <%= link_to(
4
- file_view.link_text.presence ||
5
- file_view.settings_value(:link_text, local_assigns.fetch(:options, {})) ||
6
- attachment.name,
7
- attachment.url(
8
- download: true,
9
- name: attachment.slug,
10
- format: attachment.suffix
11
- ),
12
- {
13
- class: file_view.css_class.presence,
14
- title: file_view.title.presence
15
- }.merge(html_options)
1
+ <%= render file_view.as_view_component(
2
+ **local_assigns.slice(:options),
3
+ **local_assigns.slice(:html_options)
16
4
  ) -%>
17
- <%- end -%>
@@ -1,10 +1,4 @@
1
- <%- html_options = local_assigns.fetch(:html_options, {}) -%>
2
-
3
- <%= content_tag "h#{headline_view.level}",
4
- headline_view.value,
5
- id: headline_view.dom_id.presence,
6
- class: [
7
- headline_view.size ? "h#{headline_view.size}" : nil,
8
- html_options[:class]
9
- ]
10
- %>
1
+ <%= render headline_view.as_view_component(
2
+ **local_assigns.slice(:options),
3
+ **local_assigns.slice(:html_options)
4
+ ) -%>
@@ -1 +1 @@
1
- <%= raw html_view.value -%>
1
+ <%= render html_view.as_view_component -%>
@@ -1,9 +1,4 @@
1
- <%- if link_view.value.present? -%>
2
- <%- html_options = {
3
- target: link_view.link_target == "blank" ? "_blank" : nil
4
- }.merge(local_assigns.fetch(:html_options, {})) -%>
5
- <%= link_to(link_view.value, html_options) do -%>
6
- <%= link_view.settings_value(:text, local_assigns.fetch(:options, {})) ||
7
- link_view.value -%>
8
- <%- end -%>
9
- <%- end -%>
1
+ <%= render link_view.as_view_component(
2
+ **local_assigns.slice(:options),
3
+ **local_assigns.slice(:html_options)
4
+ ) -%>
@@ -1 +1 @@
1
- <%= render node_view.node if node_view.node %>
1
+ <%= render node_view.as_view_component -%>
@@ -1,4 +1 @@
1
- <% page = page_view.page %>
2
- <% if page %>
3
- <%= link_to page.name, alchemy.show_page_path(urlname: page.urlname) %>
4
- <% end %>
1
+ <%= render page_view.as_view_component -%>
@@ -1,5 +1,4 @@
1
- <%= Alchemy::PictureView.new(
2
- picture_view,
3
- local_assigns[:options],
4
- local_assigns[:html_options]
5
- ).render %>
1
+ <%= render picture_view.as_view_component(
2
+ **local_assigns.slice(:options),
3
+ **local_assigns.slice(:html_options)
4
+ ) -%>
@@ -5,8 +5,17 @@
5
5
  <%= ingredient_label(richtext_editor) %>
6
6
  <div class="tinymce_container">
7
7
  <%= f.text_area :value,
8
- class: richtext_editor.tinymce_class_name,
9
- id: "tinymce_#{richtext_editor.id}" %>
8
+ class: "has_tinymce",
9
+ id: richtext_editor.element_id %>
10
10
  </div>
11
11
  <% end %>
12
+ <% if richtext_editor.has_custom_tinymce_config? %>
13
+ <script type="text/javascript" charset="utf-8">
14
+ Alchemy.Tinymce.setCustomConfig("<%= richtext_editor.element_id %>", {
15
+ <% richtext_editor.custom_tinymce_config.each do |k, v| %>
16
+ <%= k %>: <%== v.to_json %>,
17
+ <% end %>
18
+ });
19
+ </script>
20
+ <% end %>
12
21
  <% end %>
@@ -1,3 +1,3 @@
1
- <%- options = local_assigns.fetch(:options, {}) -%>
2
- <%- plain_text = !!richtext_view.settings_value(:plain_text, options) -%>
3
- <%= raw richtext_view.public_send(plain_text ? :stripped_body : :value) -%>
1
+ <%= render richtext_view.as_view_component(
2
+ **local_assigns.slice(:options)
3
+ ) -%>
@@ -1 +1 @@
1
- <%= select_view.value %>
1
+ <%= render select_view.as_view_component -%>
@@ -1,20 +1,4 @@
1
- <%- options = local_assigns.fetch(:options, {}) -%>
2
- <%- html_options = local_assigns.fetch(:html_options, {}) -%>
3
- <%- if text_view.link.blank? || text_view.settings_value(:disable_link, options) -%>
4
- <%- if text_view.dom_id.present? -%>
5
- <%= content_tag :a, text_view.value, id: text_view.dom_id %>
6
- <% else %>
7
- <%= text_view.value -%>
8
- <%- end -%>
9
- <%- else -%>
10
- <%= link_to(
11
- text_view.value,
12
- url_for(text_view.link),
13
- {
14
- id: text_view.dom_id.presence,
15
- title: text_view.link_title,
16
- target: (text_view.link_target == "blank" ? "_blank" : nil),
17
- 'data-link-target' => text_view.link_target
18
- }.merge(html_options)
1
+ <%= render text_view.as_view_component(
2
+ **local_assigns.slice(:options),
3
+ **local_assigns.slice(:html_options)
19
4
  ) -%>
20
- <%- end -%>
@@ -1,18 +1,3 @@
1
- <%- if video_view.attachment -%>
2
- <%= content_tag :video,
3
- controls: video_view.controls,
4
- autoplay: video_view.autoplay,
5
- loop: video_view.loop,
6
- muted: video_view.muted,
7
- playsinline: video_view.playsinline,
8
- preload: video_view.preload.presence,
9
- width: video_view.width.presence,
10
- height: video_view.height.presence do %>
11
- <%= tag :source,
12
- src: alchemy.show_attachment_path(
13
- video_view.attachment,
14
- format: video_view.attachment.suffix
15
- ),
16
- type: video_view.attachment.file_mime_type %>
17
- <% end %>
18
- <%- end -%>
1
+ <%= render video_view.as_view_component(
2
+ **local_assigns.slice(:html_options)
3
+ ) -%>
@@ -5,6 +5,7 @@
5
5
  onclick: 'new Alchemy.LinkDialog(this).open(); return false;',
6
6
  class: "icon_button#{ingredient_editor.linked? ? ' linked' : ''} link-ingredient",
7
7
  "data-parent-selector": "[data-ingredient-id='#{ingredient_editor.id}']",
8
+ "data-language-id": ingredient_editor.page&.language_id,
8
9
  title: Alchemy.t(:place_link),
9
10
  id: "edit_link_#{ingredient_editor.id}"
10
11
  ) %>
@@ -34,6 +34,7 @@
34
34
  class: picture_editor.linked? ? "linked" : nil,
35
35
  title: Alchemy.t(:link_image),
36
36
  "data-parent-selector": "[data-ingredient-id='#{picture_editor.id}']",
37
+ "data-language-id": picture_editor.page&.language_id,
37
38
  id: "edit_link_#{picture_editor.id}"
38
39
  } do %>
39
40
  <span class="disabled" tabindex="-1"><%= render_icon(:link) %></span>
@@ -7,8 +7,8 @@
7
7
  <link rel="shortcut icon" href="<%= asset_path('alchemy/favicon.ico') %>">
8
8
  <%= csrf_meta_tag %>
9
9
  <meta name="robots" content="noindex">
10
- <%= stylesheet_link_tag('alchemy/admin/all', media: 'screen', 'data-turbolinks-track' => true) %>
11
- <%= stylesheet_link_tag('alchemy/print', media: 'print', 'data-turbolinks-track' => true) %>
10
+ <%= stylesheet_link_tag('alchemy/admin/all', media: 'screen', 'data-turbo-track' => true) %>
11
+ <%= stylesheet_link_tag('alchemy/print', media: 'print', 'data-turbo-track' => true) %>
12
12
  <%= yield :stylesheets %>
13
13
  <script>
14
14
  // Global Alchemy JavaScript object.
@@ -25,22 +25,16 @@
25
25
  // Store regular expression for external link url matching.
26
26
  Alchemy.link_url_regexp = <%= link_url_regexp.inspect %>;
27
27
  // Holds the default Alchemy TinyMCE configuration
28
- Alchemy.Tinymce = {
29
- defaults: {
30
- plugins: '<%= Alchemy::Tinymce.plugins.join(',') %>',
31
- <% Alchemy::Tinymce.init.each do |k, v| %>
32
- <%= k %>: <%== v.to_json %>,
33
- <% end %>
34
- }
28
+ Alchemy.TinymceDefaults = {
29
+ plugins: '<%= Alchemy::Tinymce.plugins.join(',') %>',
30
+ <% Alchemy::Tinymce.init.each do |k, v| %>
31
+ <%= k %>: <%== v.to_json %>,
32
+ <% end %>
35
33
  };
36
34
  </script>
37
35
  <%= render 'alchemy/admin/partials/routes' %>
38
- <%= javascript_include_tag('alchemy/admin/all', 'data-turbolinks-track' => true) %>
39
- <% if respond_to?(:javascript_pack_tag) %>
40
- <%= javascript_pack_tag('alchemy/admin', 'data-turbolinks-track' => true, defer: true) %>
41
- <% else %>
42
- <%= javascript_include_tag('alchemy_admin', 'data-turbolinks-track' => true, defer: true) %>
43
- <% end %>
36
+ <%= javascript_include_tag('alchemy/admin/all', 'data-turbo-track' => true) %>
37
+ <%= javascript_importmap_tags("alchemy_admin", importmap: Alchemy.importmap) %>
44
38
  <%= yield :javascript_includes %>
45
39
  </head>
46
40
  <%= content_tag :body, id: 'alchemy', class: alchemy_body_class do %>
data/bin/importmap ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative "../spec/dummy/config/application"
4
+ require "importmap/commands"
data/bin/setup ADDED
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env ruby
2
+ require "fileutils"
3
+
4
+ # path to dummy application root.
5
+ APP_ROOT = File.expand_path("../spec/dummy", __dir__)
6
+
7
+ # path to alchemy gem
8
+ GEM_ROOT = File.expand_path("../", __dir__)
9
+
10
+ def system!(*args)
11
+ system(*args) || abort("\n== Command #{args} failed ==")
12
+ end
13
+
14
+ FileUtils.chdir GEM_ROOT do
15
+ system! "gem install bundler --conservative"
16
+ system("bundle check") || system!("bundle install")
17
+ end
18
+
19
+ FileUtils.chdir APP_ROOT do
20
+ puts "\n== Installing Alchemy into dummy app =="
21
+ system!("bin/rails g alchemy:install --skip --skip-demo-files --auto-accept")
22
+
23
+ puts "\n== Removing old logs and tempfiles =="
24
+ system! "bin/rails log:clear tmp:clear"
25
+ end
26
+
27
+ puts "\n== Alchemy is ready 🎉 =="
28
+ puts "Start server by typing:\n\n bin/start"
data/bin/start ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+ require "fileutils"
3
+
4
+ # path to dummy application root.
5
+ APP_ROOT = File.expand_path("../spec/dummy", __dir__)
6
+
7
+ # path to alchemy gem
8
+ GEM_ROOT = File.expand_path("../", __dir__)
9
+
10
+ def system!(*args)
11
+ system(*args) || abort("\n== Command #{args} failed ==")
12
+ end
13
+
14
+ FileUtils.chdir APP_ROOT do
15
+ puts "\n== Starting dummy app =="
16
+ system! "bin/rails server"
17
+ end
@@ -80,29 +80,6 @@
80
80
  ],
81
81
  "note": ""
82
82
  },
83
- {
84
- "warning_type": "Command Injection",
85
- "warning_code": 14,
86
- "fingerprint": "6addfcb9d23d2d6f699f2f3542169744ff749dc4d0a97f8ac783ab92593e1d84",
87
- "check_name": "Execute",
88
- "message": "Possible command injection",
89
- "file": "lib/alchemy/upgrader.rb",
90
- "line": 33,
91
- "link": "https://brakemanscanner.org/docs/warning_types/command_injection/",
92
- "code": "`yarn add @alchemy_cms/admin@~#{Alchemy.version}`",
93
- "render_path": null,
94
- "location": {
95
- "type": "method",
96
- "class": "Alchemy::Upgrader",
97
- "method": "update_npm_package"
98
- },
99
- "user_input": "Alchemy.version",
100
- "confidence": "Medium",
101
- "cwe_id": [
102
- 77
103
- ],
104
- "note": "The alchemy version is safe"
105
- },
106
83
  {
107
84
  "warning_type": "Cross-Site Scripting",
108
85
  "warning_code": 4,
@@ -227,29 +204,6 @@
227
204
  ],
228
205
  "note": ""
229
206
  },
230
- {
231
- "warning_type": "Command Injection",
232
- "warning_code": 14,
233
- "fingerprint": "98ca8e77026312eaa7eec15ce26bfe45aa8dd0fcd38e4cff104cb9dffbde1733",
234
- "check_name": "Execute",
235
- "message": "Possible command injection",
236
- "file": "lib/alchemy/upgrader.rb",
237
- "line": 31,
238
- "link": "https://brakemanscanner.org/docs/warning_types/command_injection/",
239
- "code": "`bin/importmap pin @alchemy_cms/admin@~#{Alchemy.version}`",
240
- "render_path": null,
241
- "location": {
242
- "type": "method",
243
- "class": "Alchemy::Upgrader",
244
- "method": "update_npm_package"
245
- },
246
- "user_input": "Alchemy.version",
247
- "confidence": "Medium",
248
- "cwe_id": [
249
- 77
250
- ],
251
- "note": ""
252
- },
253
207
  {
254
208
  "warning_type": "File Access",
255
209
  "warning_code": 16,
@@ -0,0 +1,8 @@
1
+ pin "flatpickr", to: "https://ga.jspm.io/npm:flatpickr@4.6.13/dist/esm/index.js", preload: true
2
+ pin "lodash-es/debounce", to: "https://ga.jspm.io/npm:lodash-es@4.17.21/debounce.js", preload: true
3
+ pin "lodash-es/max", to: "https://ga.jspm.io/npm:lodash-es@4.17.21/max.js", preload: true
4
+ pin "sortablejs", to: "https://ga.jspm.io/npm:sortablejs@1.15.0/modular/sortable.esm.js", preload: true
5
+ pin "@hotwired/turbo-rails", to: "turbo.min.js", preload: true
6
+
7
+ pin "alchemy_admin", to: "alchemy_admin.js", preload: true
8
+ pin_all_from File.expand_path("../app/javascript/alchemy_admin", __dir__), under: "alchemy_admin"
@@ -1,3 +1,4 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  # Add Alchemy assets for precompiling
3
4
  Rails.application.config.assets.precompile << "alchemy_manifest.js"
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require "dragonfly_svg"
3
4
  require "alchemy/dragonfly/processors/crop_resize"
4
5
  require "alchemy/dragonfly/processors/auto_orient"
@@ -1,2 +1,3 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  Mime::Type.register "image/svg+xml", :svg
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  begin
3
4
  require "rack-mini-profiler"
4
5
  Rack::MiniProfiler.config.position = "right"
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  #
3
4
  # Uncomment this and change the path if necessary to include your own
4
5
  # components.
@@ -57,8 +58,8 @@ SimpleForm.setup do |config|
57
58
  ## Inputs
58
59
  # b.use :input, class: 'input', error_class: 'is-invalid'
59
60
  b.use :label_input
60
- b.use :error, wrap_with: { tag: :small, class: :error }
61
- b.use :hint, wrap_with: { tag: :small, class: :hint }
61
+ b.use :error, wrap_with: {tag: :small, class: :error}
62
+ b.use :hint, wrap_with: {tag: :small, class: :hint}
62
63
 
63
64
  ## full_messages_for
64
65
  # If you want to display the full error message for the attribute, you can
@@ -125,6 +125,7 @@ en:
125
125
  last_upload: Last upload only
126
126
  recent: Recently uploaded only
127
127
  without_tag: Without tag
128
+ deletable: Not linked by file content
128
129
  attachment:
129
130
  by_file_type:
130
131
  name: File Type
@@ -136,7 +137,6 @@ en:
136
137
  last_upload: Last upload only
137
138
  recent: Recently uploaded only
138
139
  without_tag: Without tag
139
- deletable: Not linked by file content
140
140
 
141
141
  # === Translations for ingredient validations
142
142
  # Used when a user did not enter (correct) values to the ingredient field.