alchemy_cms 6.0.0.pre.rc6 → 6.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (94) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +23 -8
  3. data/.github/workflows/stale.yml +21 -7
  4. data/.gitignore +0 -1
  5. data/.rspec +1 -0
  6. data/CHANGELOG.md +102 -0
  7. data/Gemfile +20 -5
  8. data/README.md +4 -3
  9. data/Rakefile +5 -1
  10. data/alchemy_cms.gemspec +3 -3
  11. data/app/assets/javascripts/alchemy/admin.js +0 -1
  12. data/app/assets/javascripts/alchemy/alchemy.link_dialog.js.coffee +2 -0
  13. data/app/assets/javascripts/alchemy/page_select.js +13 -8
  14. data/app/assets/javascripts/alchemy/templates/index.js +1 -0
  15. data/app/assets/javascripts/alchemy/templates/page.hbs +17 -7
  16. data/app/assets/javascripts/alchemy/templates/page_folder.hbs +3 -0
  17. data/app/assets/stylesheets/alchemy/archive.scss +9 -0
  18. data/app/assets/stylesheets/alchemy/elements.scss +4 -0
  19. data/app/assets/stylesheets/alchemy/page-select.scss +29 -4
  20. data/app/assets/stylesheets/alchemy/sitemap.scss +2 -6
  21. data/app/controllers/alchemy/admin/elements_controller.rb +20 -17
  22. data/app/controllers/alchemy/admin/pages_controller.rb +24 -19
  23. data/app/controllers/alchemy/api/base_controller.rb +4 -3
  24. data/app/controllers/alchemy/api/contents_controller.rb +1 -5
  25. data/app/controllers/alchemy/api/elements_controller.rb +2 -6
  26. data/app/controllers/alchemy/api/nodes_controller.rb +1 -0
  27. data/app/controllers/alchemy/api/pages_controller.rb +16 -10
  28. data/app/controllers/alchemy/base_controller.rb +7 -0
  29. data/app/controllers/alchemy/messages_controller.rb +0 -3
  30. data/app/controllers/alchemy/pages_controller.rb +0 -7
  31. data/app/helpers/alchemy/elements_helper.rb +17 -12
  32. data/app/models/alchemy/element.rb +13 -6
  33. data/app/models/alchemy/ingredient.rb +10 -1
  34. data/app/models/alchemy/ingredient_validator.rb +1 -1
  35. data/app/models/alchemy/language.rb +1 -1
  36. data/app/models/alchemy/page/page_elements.rb +2 -2
  37. data/app/models/alchemy/page/page_naming.rb +1 -1
  38. data/app/models/alchemy/page.rb +1 -1
  39. data/app/models/alchemy/picture/transformations.rb +2 -2
  40. data/app/models/alchemy/picture.rb +1 -1
  41. data/app/models/alchemy/picture_variant.rb +3 -1
  42. data/app/models/alchemy/site.rb +1 -1
  43. data/app/serializers/alchemy/page_serializer.rb +7 -1
  44. data/app/serializers/alchemy/page_tree_serializer.rb +3 -3
  45. data/app/views/alchemy/admin/clipboard/insert.js.erb +13 -0
  46. data/app/views/alchemy/admin/elements/_add_nested_element_form.html.erb +27 -0
  47. data/app/views/alchemy/admin/elements/_element.html.erb +1 -23
  48. data/app/views/alchemy/admin/elements/_form.html.erb +5 -1
  49. data/app/views/alchemy/admin/pages/_form.html.erb +19 -0
  50. data/app/views/alchemy/admin/pages/_new_page_form.html.erb +16 -5
  51. data/app/views/alchemy/admin/pages/_page.html.erb +111 -133
  52. data/app/views/alchemy/admin/pages/_sitemap.html.erb +2 -8
  53. data/app/views/alchemy/admin/pages/_toolbar.html.erb +0 -12
  54. data/app/views/alchemy/admin/pages/index.html.erb +1 -1
  55. data/app/views/alchemy/admin/pages/update.js.erb +7 -0
  56. data/app/views/alchemy/admin/partials/_routes.html.erb +12 -1
  57. data/app/views/alchemy/admin/resources/_form.html.erb +5 -0
  58. data/app/views/alchemy/essences/_essence_node_editor.html.erb +1 -1
  59. data/app/views/alchemy/essences/_essence_page_editor.html.erb +1 -1
  60. data/config/alchemy/config.yml +1 -0
  61. data/config/initializers/dragonfly.rb +2 -0
  62. data/config/locales/alchemy.en.yml +0 -3
  63. data/config/routes.rb +4 -2
  64. data/lib/alchemy/config.rb +5 -1
  65. data/lib/alchemy/controller_actions.rb +2 -1
  66. data/lib/alchemy/dragonfly/processors/thumbnail.rb +27 -0
  67. data/lib/alchemy/element_definition.rb +2 -3
  68. data/lib/alchemy/elements_finder.rb +1 -2
  69. data/lib/alchemy/engine.rb +12 -1
  70. data/lib/alchemy/essence.rb +1 -27
  71. data/lib/alchemy/page_layout.rb +5 -1
  72. data/lib/alchemy/permissions.rb +2 -3
  73. data/lib/alchemy/resource.rb +16 -1
  74. data/lib/alchemy/test_support/essence_shared_examples.rb +0 -12
  75. data/lib/alchemy/test_support/shared_ingredient_examples.rb +4 -2
  76. data/lib/alchemy/upgrader/tasks/ingredients_migrator.rb +1 -1
  77. data/lib/alchemy/version.rb +1 -1
  78. data/lib/alchemy.rb +2 -4
  79. data/lib/generators/alchemy/base.rb +7 -3
  80. data/lib/generators/alchemy/install/install_generator.rb +10 -2
  81. data/package/src/image_loader.js +4 -2
  82. data/package/src/node_tree.js +13 -6
  83. data/package/src/page_publication_fields.js +15 -14
  84. data/package/src/page_sorter.js +62 -0
  85. data/package/src/picture_editors.js +8 -8
  86. data/package/src/sitemap.js +51 -36
  87. data/package/src/utils/__tests__/ajax.spec.js +52 -16
  88. data/package/src/utils/ajax.js +12 -0
  89. data/package.json +1 -1
  90. metadata +43 -42
  91. data/app/assets/javascripts/alchemy/alchemy.page_sorter.js +0 -24
  92. data/app/views/alchemy/admin/pages/fold.js.erb +0 -2
  93. data/app/views/alchemy/admin/pages/sort.html.erb +0 -19
  94. data/vendor/assets/javascripts/jquery_plugins/jquery.ui.nestedSortable.js +0 -434
@@ -1,4 +1,8 @@
1
1
  <%= alchemy_form_for [:admin, @page], class: 'edit_page' do |f| %>
2
+ <% unless @page.language_root? || @page.layoutpage %>
3
+ <%= f.input :parent_id, required: true, input_html: { class: 'alchemy_selectbox' } %>
4
+ <% end %>
5
+
2
6
  <div class="input check_boxes">
3
7
  <label class="control-label"><%= Alchemy.t(:page_status) %></label>
4
8
  <div class="control_group">
@@ -37,3 +41,18 @@
37
41
 
38
42
  <%= f.submit Alchemy.t(:save) %>
39
43
  <% end %>
44
+
45
+ <script>
46
+ $('#page_parent_id').alchemyPageSelect({
47
+ placeholder: "<%= Alchemy.t(:search_page) %>",
48
+ url: "<%= alchemy.api_pages_path %>",
49
+ allowClear: false,
50
+ <% if @page.parent %>
51
+ initialSelection: {
52
+ id: <%= @page.parent.id %>,
53
+ text: "<%= @page.parent.name %>",
54
+ url_path: "<%= @page.parent.url_path %>"
55
+ }
56
+ <% end %>
57
+ })
58
+ </script>
@@ -3,11 +3,7 @@
3
3
  <%= f.hidden_field(:parent_id) %>
4
4
  <% else %>
5
5
  <% @page.parent = @current_language.root_page %>
6
- <%= f.input :parent_id,
7
- collection: @current_language.pages.contentpages,
8
- label_method: :name,
9
- value_method: :id,
10
- input_html: { class: "alchemy_selectbox" } %>
6
+ <%= f.input :parent_id, as: :string, input_html: { class: 'alchemy_selectbox' } %>
11
7
  <% end %>
12
8
  <%= f.hidden_field(:language_id) %>
13
9
  <%= f.hidden_field(:layoutpage) %>
@@ -21,3 +17,18 @@
21
17
  <%= f.input :name %>
22
18
  <%= f.submit Alchemy.t(:create) %>
23
19
  <% end %>
20
+
21
+ <script>
22
+ $('input[type="text"]#page_parent_id').alchemyPageSelect({
23
+ placeholder: "<%= Alchemy.t(:search_page) %>",
24
+ url: "<%= alchemy.api_pages_path %>",
25
+ allowClear: false,
26
+ <% if @page.parent %>
27
+ initialSelection: {
28
+ id: <%= @page.parent.id %>,
29
+ text: "<%= @page.parent.name %>",
30
+ url_path: "<%= @page.parent.url_path %>"
31
+ }
32
+ <% end %>
33
+ })
34
+ </script>
@@ -1,24 +1,7 @@
1
- <li id="page_{{id}}" class="page_level_{{level}} {{page_layout}}" data-slug="{{slug}}" data-restricted="{{restricted}}">
1
+ <li id="page_{{id}}" class="sitemap-item {{page_layout}}" data-slug="{{slug}}" data-restricted="{{restricted}}" data-page-id="{{id}}" data-folded="{{folded}}">
2
2
  <div class="sitemap_page{{#if locked}} locked{{/if}}" name="{{name}}">
3
- <div class="sitemap_left_images<% if @sorting %>{{#unless root}} handle{{/unless}}<% end %>">
4
- <% unless @sorting %>
5
- {{#unless root_or_leaf}}
6
- <%= link_to(
7
- alchemy.fold_admin_page_path(page),
8
- remote: true,
9
- method: :post,
10
- class: "page_folder",
11
- title: "{{#if folded}}#{Alchemy.t('Show childpages')}{{else}}#{Alchemy.t('Hide childpages')}{{/if}}",
12
- id: "fold_button_{{id}}"
13
- ) do %>
14
- {{#if folded}}
15
- <i class="far fa-plus-square fa-fw"></i>
16
- {{else}}
17
- <i class="far fa-minus-square fa-fw"></i>
18
- {{/if}}
19
- <% end %>
20
- {{/unless}}
21
- <% end %>
3
+ <div class="sitemap_left_images">
4
+ <span class="page_folder"></span>
22
5
  {{#if definition_missing}}
23
6
  <%= page_layout_missing_warning %>
24
7
  {{else}}
@@ -31,121 +14,121 @@
31
14
  </span>
32
15
  </span>
33
16
  {{else}}
17
+ <span class="{{#unless root}}handle{{/unless}}">
34
18
  <i class="icon far fa-file fa-lg"></i>
19
+ </span>
35
20
  {{/if}}
36
21
  {{else}}
37
22
  <span class="with-hint">
38
23
  <i class="icon fas fa-ban fa-fw"></i>
39
24
  <span class="hint-bubble">
40
- <%= Alchemy.t('Your user role does not allow you to edit this page') %>
25
+ <%= Alchemy.t("Your user role does not allow you to edit this page") %>
41
26
  </span>
42
27
  </span>
43
28
  {{/if}}
44
29
  {{/if}}
45
30
  </div>
46
31
  <div class="sitemap_right_tools">
47
- <%- unless @sorting -%>
48
- {{#if permissions.info}}
49
- <div class="button_with_label sitemap_tool">
50
- <%= link_to_dialog(
51
- render_icon('info-circle'),
52
- alchemy.info_admin_page_path(page),
53
- {
54
- title: Alchemy.t(:page_infos),
55
- size: '520x290'
56
- }
57
- ) %>
58
- <label class="center"><%= Alchemy.t(:page_infos) %></label>
59
- {{else}}
60
- <div class="sitemap_tool disabled with-hint">
61
- <%= render_icon('info-circle') %>
62
- <span class="hint-bubble">
63
- <%= Alchemy.t('Your user role does not allow you to edit this page') %>
64
- </span>
65
- {{/if}}
66
- </div>
67
- {{#if permissions.configure}}
68
- <div class="button_with_label sitemap_tool">
69
- <%= link_to_dialog(
70
- render_icon(:cog),
71
- alchemy.configure_admin_page_path(page),
72
- {
73
- title: Alchemy.t(:edit_page_properties),
74
- size: '450x680'
75
- }
76
- ) -%>
77
- <label class="center"><%= Alchemy.t(:edit_page_properties) %></label>
78
- {{else}}
79
- <div class="sitemap_tool disabled with-hint">
80
- <%= render_icon(:cog) %>
81
- <span class="hint-bubble">
82
- <%= Alchemy.t('Your user role does not allow you to edit this page') %>
83
- </span>
84
- {{/if}}
85
- </div>
86
- {{#if permissions.copy}}
87
- <div class="button_with_label sitemap_tool">
88
- <%= link_to(
89
- render_icon(:copy),
90
- alchemy.insert_admin_clipboard_path(
91
- remarkable_type: page.class.name.demodulize.underscore.pluralize,
92
- remarkable_id: '__ID__',
93
- ).gsub('__ID__', '{{id}}'),
94
- remote: true,
95
- method: 'post'
96
- ) %>
97
- <label class="center"><%= Alchemy.t(:copy_page) %></label>
98
- {{else}}
99
- <div class="sitemap_tool disabled with-hint">
100
- <%= render_icon(:copy) %>
101
- <span class="hint-bubble">
102
- <%= Alchemy.t('Your user role does not allow you to edit this page') %>
103
- </span>
104
- {{/if}}
105
- </div>
106
- {{#if permissions.destroy}}
107
- <div class="button_with_label sitemap_tool">
108
- <%= link_to_confirm_dialog(
109
- render_icon(:minus),
110
- Alchemy.t(:confirm_to_delete_page),
111
- url_for(
112
- controller: 'pages',
113
- action: 'destroy',
114
- id: '__ID__'
115
- ).gsub('__ID__', '{{id}}')
116
- ) -%>
117
- <label class="center"><%= Alchemy.t(:delete_page) %></label>
118
- {{else}}
119
- <div class="sitemap_tool disabled with-hint">
120
- <%= render_icon(:minus) %>
121
- <span class="hint-bubble">
122
- <%= Alchemy.t('Your user role does not allow you to edit this page') %>
123
- </span>
124
- {{/if}}
125
- </div>
126
- {{#if permissions.create}}
127
- <div class="button_with_label sitemap_tool">
128
- <%= link_to_dialog(
129
- render_icon(:plus),
130
- alchemy.new_admin_page_path(parent_id: '__ID__').gsub('__ID__', '{{id}}'),
131
- {
132
- title: Alchemy.t(:create_page),
133
- size: '340x165',
134
- overflow: true
135
- }
136
- ) -%>
137
- <label class="left"><%= Alchemy.t(:create_page) %></label>
138
- {{else}}
139
- <div class="sitemap_tool disabled with-hint">
140
- <%= render_icon(:plus) %>
141
- <span class="hint-bubble">
142
- <%= Alchemy.t('Your user role does not allow you to edit this page') %>
143
- </span>
144
- {{/if}}
145
- </div>
146
- <%- end -%>
32
+ {{#if permissions.info}}
33
+ <div class="button_with_label sitemap_tool">
34
+ <%= link_to_dialog(
35
+ render_icon("info-circle"),
36
+ alchemy.info_admin_page_path(id: "__ID__"),
37
+ {
38
+ title: Alchemy.t(:page_infos),
39
+ size: "520x290"
40
+ }
41
+ ) %>
42
+ <label class="center"><%= Alchemy.t(:page_infos) %></label>
43
+ {{else}}
44
+ <div class="sitemap_tool disabled with-hint">
45
+ <%= render_icon("info-circle") %>
46
+ <span class="hint-bubble">
47
+ <%= Alchemy.t("Your user role does not allow you to edit this page") %>
48
+ </span>
49
+ {{/if}}
50
+ </div>
51
+ {{#if permissions.configure}}
52
+ <div class="button_with_label sitemap_tool">
53
+ <%= link_to_dialog(
54
+ render_icon(:cog),
55
+ alchemy.configure_admin_page_path(id: "__ID__"),
56
+ {
57
+ title: Alchemy.t(:edit_page_properties),
58
+ size: "450x680"
59
+ }
60
+ ) -%>
61
+ <label class="center"><%= Alchemy.t(:edit_page_properties) %></label>
62
+ {{else}}
63
+ <div class="sitemap_tool disabled with-hint">
64
+ <%= render_icon(:cog) %>
65
+ <span class="hint-bubble">
66
+ <%= Alchemy.t("Your user role does not allow you to edit this page") %>
67
+ </span>
68
+ {{/if}}
69
+ </div>
70
+ {{#if permissions.copy}}
71
+ <div class="button_with_label sitemap_tool">
72
+ <%= link_to(
73
+ render_icon(:copy),
74
+ alchemy.insert_admin_clipboard_path(
75
+ remarkable_type: :pages,
76
+ remarkable_id: "__ID__",
77
+ ),
78
+ remote: true,
79
+ method: :post
80
+ ) %>
81
+ <label class="center"><%= Alchemy.t(:copy_page) %></label>
82
+ {{else}}
83
+ <div class="sitemap_tool disabled with-hint">
84
+ <%= render_icon(:copy) %>
85
+ <span class="hint-bubble">
86
+ <%= Alchemy.t("Your user role does not allow you to edit this page") %>
87
+ </span>
88
+ {{/if}}
89
+ </div>
90
+ {{#if permissions.destroy}}
91
+ <div class="button_with_label sitemap_tool">
92
+ <%= link_to_confirm_dialog(
93
+ render_icon(:minus),
94
+ Alchemy.t(:confirm_to_delete_page),
95
+ url_for(
96
+ controller: "pages",
97
+ action: "destroy",
98
+ id: "__ID__"
99
+ )
100
+ ) -%>
101
+ <label class="center"><%= Alchemy.t(:delete_page) %></label>
102
+ {{else}}
103
+ <div class="sitemap_tool disabled with-hint">
104
+ <%= render_icon(:minus) %>
105
+ <span class="hint-bubble">
106
+ <%= Alchemy.t("Your user role does not allow you to edit this page") %>
107
+ </span>
108
+ {{/if}}
109
+ </div>
110
+ {{#if permissions.create}}
111
+ <div class="button_with_label sitemap_tool">
112
+ <%= link_to_dialog(
113
+ render_icon(:plus),
114
+ alchemy.new_admin_page_path(parent_id: "__ID__"),
115
+ {
116
+ title: Alchemy.t(:create_page),
117
+ size: "340x165",
118
+ overflow: true
119
+ }
120
+ ) -%>
121
+ <label class="left"><%= Alchemy.t(:create_page) %></label>
122
+ {{else}}
123
+ <div class="sitemap_tool disabled with-hint">
124
+ <%= render_icon(:plus) %>
125
+ <span class="hint-bubble">
126
+ <%= Alchemy.t("Your user role does not allow you to edit this page") %>
127
+ </span>
128
+ {{/if}}
129
+ </div>
147
130
  </div>
148
- <div class="page_infos" id="page_<%= page.id %>_infos">
131
+ <div class="page_infos">
149
132
  <span class="page_status with-hint">
150
133
  <i class="icon fas fa-fw fa-compass {{#unless public}}disabled{{/unless}}" data-fa-transform="shrink-2"></i>
151
134
  <span class="hint-bubble">{{status_titles.public}}</span>
@@ -160,23 +143,18 @@
160
143
  </div>
161
144
  <div class="sitemap_sitename">
162
145
  {{#if permissions.edit_content}}
163
- <%= link_to_unless(
164
- @sorting,
165
- '{{name}}',
166
- alchemy.edit_admin_page_path(page),
146
+ <%= link_to(
147
+ "{{name}}",
148
+ alchemy.edit_admin_page_path(id: "__ID__"),
167
149
  title: Alchemy.t(:edit_page),
168
150
  class: "sitemap_pagename_link"
169
- ) { content_tag('span', '{{name}}', class: "sitemap_pagename_link") } -%>
151
+ ) -%>
170
152
  {{else}}
171
- <%= content_tag('span', '{{name}}', class: "sitemap_pagename_link") %>
153
+ <%= content_tag("span", "{{name}}", class: "sitemap_pagename_link") %>
172
154
  {{/if}}
173
155
  </div>
174
156
  </div>
175
- {{#if children}}
176
- <% unless @sorting %>{{#unless folded}}<% end %>
177
- <ul id="page_{{id}}_children" class="level_{{level}}_children">
157
+ <ul id="page_{{id}}_children" class="children" data-parent-id="{{id}}">
178
158
  {{> list}}
179
159
  </ul>
180
- <% unless @sorting %>{{/unless}}<% end %>
181
- {{/if}}
182
160
  </li>
@@ -8,7 +8,7 @@
8
8
  </div>
9
9
 
10
10
  <script id="sitemap-template" type="text/x-handlebars-template">
11
- <ul id="sitemap" class="list<%= @sorting ? ' sorting' : nil %>">
11
+ <ul id="sitemap" class="list">
12
12
  {{> list}}
13
13
  </ul>
14
14
  </script>
@@ -23,13 +23,7 @@
23
23
  $(function() {
24
24
  Alchemy.currentSitemap = new Alchemy.Sitemap({
25
25
  url: '<%= alchemy.tree_admin_pages_path %>',
26
- page_root_id: <%= @page_root.id %>,
27
- full: <%= full %>
28
- <% if @sorting %>
29
- ,ready: function () {
30
- Alchemy.PageSorter();
31
- }
32
- <% end %>
26
+ page_root_id: <%= @page_root.id %>
33
27
  });
34
28
  Alchemy.PagePublicationFields();
35
29
  });
@@ -28,18 +28,6 @@
28
28
  <label><%= Alchemy.t("Flush page cache") %></label>
29
29
  </div>
30
30
  <% end %>
31
- <% if can?(:sort, Alchemy::Page) %>
32
- <div class="button_with_label">
33
- <%= link_to(
34
- render_icon(:random),
35
- alchemy.sort_admin_pages_path,
36
- method: :get,
37
- class: "icon_button",
38
- title: Alchemy.t("Sort pages")
39
- ) %>
40
- <label><%= Alchemy.t("Sort pages") %></label>
41
- </div>
42
- <% end %>
43
31
  <div class="button_with_label" id="clipboard_button">
44
32
  <%= link_to_dialog(
45
33
  render_icon(clipboard_empty?("pages") ? :clipboard : :paste),
@@ -30,7 +30,7 @@
30
30
  <% else %>
31
31
  <% if @page_root %>
32
32
  <h2 id="page_filter_result"></h2>
33
- <%= render "sitemap", page_partial: "page", full: !!@sorting %>
33
+ <%= render "sitemap", page_partial: "page" %>
34
34
  <% elsif can?(:create, Alchemy::Page) %>
35
35
  <%= render partial: "create_language_form" %>
36
36
  <% else %>
@@ -8,6 +8,13 @@
8
8
  Alchemy.growl("<%= j @notice %>");
9
9
  Alchemy.closeCurrentDialog();
10
10
 
11
+ <% elsif @page.parent_id != @old_parent_id -%>
12
+
13
+ Alchemy.closeCurrentDialog(function() {
14
+ Alchemy.growl("<%= j @notice %>");
15
+ Alchemy.currentSitemap.load(<%= @page.get_language_root.id %>);
16
+ });
17
+
11
18
  <% else -%>
12
19
 
13
20
  if (page) {
@@ -5,6 +5,10 @@
5
5
  return '<%= alchemy.admin_picture_path(id: 1) %>'.replace(/1/, id);
6
6
  },
7
7
 
8
+ url_admin_picture_path: function(id) {
9
+ return '<%= alchemy.url_admin_picture_path(id: 1) %>'.replace(/1/, id);
10
+ },
11
+
8
12
  fold_admin_element_path: function(id) {
9
13
  return '<%= alchemy.fold_admin_element_path(id: 1) %>'.replace(/1/, id);
10
14
  },
@@ -19,8 +23,15 @@
19
23
  },
20
24
  },
21
25
 
26
+ move_admin_page_path: function(id) {
27
+ return '<%= alchemy.move_api_page_path(id: 1) %>'.replace(/1/, id);
28
+ },
29
+
30
+ fold_admin_page_path: function(id) {
31
+ return '<%= alchemy.fold_admin_page_path(id: 1) %>'.replace(/1/, id);
32
+ },
33
+
22
34
  order_admin_elements_path: '<%= alchemy.order_admin_elements_path %>',
23
- order_admin_pages_path: '<%= alchemy.order_admin_pages_path %>',
24
35
  link_admin_pages_path: '<%= alchemy.link_admin_pages_path %>',
25
36
  api_pages_path: '<%= alchemy.api_pages_path %>',
26
37
  api_elements_path: '<%= alchemy.api_elements_path %>'
@@ -8,6 +8,11 @@
8
8
  input_html: {class: 'alchemy_selectbox'} %>
9
9
  <% elsif attribute[:type].in? %i[date time datetime] %>
10
10
  <%= f.datepicker attribute[:name], resource_attribute_field_options(attribute) %>
11
+ <% elsif attribute[:enum].present? %>
12
+ <%= f.input attribute[:name],
13
+ collection: attribute[:enum],
14
+ include_blank: Alchemy.t(:blank, scope: 'resources.relation_select'),
15
+ input_html: {class: 'alchemy_selectbox'} %>
11
16
  <% else %>
12
17
  <%= f.input attribute[:name], resource_attribute_field_options(attribute) %>
13
18
  <% end %>
@@ -17,7 +17,7 @@
17
17
  }) %>
18
18
  $('#<%= essence_node_editor.form_field_id %>').alchemyNodeSelect({
19
19
  placeholder: "<%= Alchemy.t(:search_node) %>",
20
- url: "<%= alchemy.api_nodes_path %>",
20
+ url: "<%= alchemy.api_nodes_path(language_id: essence_node_editor.page&.language_id) %>",
21
21
  query_params: <%== query_params.to_json %>,
22
22
  <% if essence_node_editor.essence.node %>
23
23
  <% serialized_node = ActiveModelSerializers::SerializableResource.new(essence_node_editor.essence.node, include: :ancestors) %>
@@ -14,7 +14,7 @@
14
14
  <script>
15
15
  $('#<%= essence_page_editor.form_field_id %>').alchemyPageSelect({
16
16
  placeholder: "<%= Alchemy.t(:search_page) %>",
17
- url: "<%= alchemy.api_pages_path %>",
17
+ url: "<%= alchemy.api_pages_path language_id: essence_page_editor.page&.language_id %>",
18
18
  query_params: <%== essence_page_editor.settings[:query_params].to_json %>,
19
19
  <% if essence_page_editor.essence.page %>
20
20
  initialSelection: {
@@ -173,6 +173,7 @@ uploader:
173
173
  - gif
174
174
  - png
175
175
  - svg
176
+ - webp
176
177
 
177
178
  # === Link Target Options
178
179
  #
@@ -2,6 +2,7 @@
2
2
  require "dragonfly_svg"
3
3
  require "alchemy/dragonfly/processors/crop_resize"
4
4
  require "alchemy/dragonfly/processors/auto_orient"
5
+ require "alchemy/dragonfly/processors/thumbnail"
5
6
 
6
7
  # Logger
7
8
  Dragonfly.logger = Rails.logger
@@ -18,4 +19,5 @@ Dragonfly::ImageMagick::Processors::Encode::WHITELISTED_ARGS << "flatten"
18
19
  Rails.application.config.after_initialize do
19
20
  Dragonfly.app(:alchemy_pictures).add_processor(:crop_resize, Alchemy::Dragonfly::Processors::CropResize.new)
20
21
  Dragonfly.app(:alchemy_pictures).add_processor(:auto_orient, Alchemy::Dragonfly::Processors::AutoOrient.new)
22
+ Dragonfly.app(:alchemy_pictures).add_processor(:thumbnail, Alchemy::Dragonfly::Processors::Thumbnail.new)
21
23
  end
@@ -334,7 +334,6 @@ en:
334
334
  "Site successfully removed": "Website successfully removed."
335
335
  "Site successfully updated": "Website successfully updated."
336
336
  "Size": "Size"
337
- "Sort pages": "Reorder pages"
338
337
  "Successfully added content": "Successfully added %{content}"
339
338
  "Successfully deleted content": "Successfully deleted %{content}"
340
339
  "Successfully deleted element": "Successfully deleted %{element}"
@@ -437,7 +436,6 @@ en:
437
436
  enter_external_link: "Please enter the URL you want to link with"
438
437
  explain_cropping: "<p>Move the frame and change its size with the mouse or arrow keys to adjust the image mask. Click on \"apply\" when you are satisfied with your selection.</p><p>If you want to return to the original centered image mask like it was defined in the layout, click \"reset\" and \"apply\" afterwards.</p>"
439
438
  explain_publishing: "Publish current page content"
440
- explain_sitemap_dragndrop_sorting: "Tip: Drag the pages at the icon in order to sort them."
441
439
  explain_unlocking: "Leave page and unlock it for other users."
442
440
  external_link_notice_1: "Please enter the complete url with http:// or a similar protocol."
443
441
  external_link_notice_2: "To refer a path from your website url, start with a /."
@@ -592,7 +590,6 @@ en:
592
590
  robot_follow: "robot may follow links."
593
591
  robot_index: "allow robot to index."
594
592
  save: "Save"
595
- "save order": "Save order"
596
593
  saved_link: "Link saved."
597
594
  search: "search"
598
595
  search_engines: "Search engines"
data/config/routes.rb CHANGED
@@ -28,13 +28,12 @@ Alchemy::Engine.routes.draw do
28
28
  post :copy_language_tree
29
29
  get :create_language
30
30
  get :link
31
- get :sort
32
31
  get :tree
33
32
  end
34
33
  member do
35
34
  post :unlock
36
35
  post :publish
37
- post :fold
36
+ patch :fold
38
37
  get :configure
39
38
  get :preview
40
39
  get :info
@@ -139,6 +138,9 @@ Alchemy::Engine.routes.draw do
139
138
  collection do
140
139
  get :nested
141
140
  end
141
+ member do
142
+ patch :move
143
+ end
142
144
  end
143
145
 
144
146
  get "/pages/*urlname(.:format)" => "pages#show", as: "page"
@@ -55,7 +55,11 @@ module Alchemy
55
55
  # If it does not exist, or its empty, it returns an empty Hash.
56
56
  #
57
57
  def read_file(file)
58
- YAML.safe_load(ERB.new(File.read(file)).result, YAML_WHITELIST_CLASSES, [], true) || {}
58
+ YAML.safe_load(
59
+ ERB.new(File.read(file)).result,
60
+ permitted_classes: YAML_PERMITTED_CLASSES,
61
+ aliases: true,
62
+ ) || {}
59
63
  rescue Errno::ENOENT
60
64
  {}
61
65
  end
@@ -75,7 +75,8 @@ module Alchemy
75
75
 
76
76
  def load_alchemy_language_from_params
77
77
  if params[:locale].present?
78
- Language.find_by_code(params[:locale])
78
+ Language.find_by_code(params[:locale]) ||
79
+ raise(ActionController::RoutingError, "Language not found")
79
80
  end
80
81
  end
81
82
 
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "dragonfly/image_magick/processors/thumb"
4
+
5
+ module Alchemy
6
+ module Dragonfly
7
+ module Processors
8
+ class Thumbnail < ::Dragonfly::ImageMagick::Processors::Thumb
9
+ def call(content, geometry, opts = {})
10
+ # store content into an instance variable to use it in args_for_geometry - method
11
+ @content = content
12
+ super
13
+ end
14
+
15
+ ##
16
+ # due to a missing ImageMagick parameter animated GIFs were broken with the default
17
+ # Dragonfly Thumb processor
18
+ def args_for_geometry(geometry)
19
+ # resize all frames in a GIF
20
+ # @link https://imagemagick.org/script/command-line-options.php#coalesce
21
+ # @link https://imagemagick.org/script/command-line-options.php#deconstruct
22
+ @content&.mime_type == "image/gif" ? "-coalesce #{super} -deconstruct" : super
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -50,9 +50,8 @@ module Alchemy
50
50
  if File.exist?(definitions_file_path)
51
51
  YAML.safe_load(
52
52
  ERB.new(File.read(definitions_file_path)).result,
53
- YAML_WHITELIST_CLASSES,
54
- [],
55
- true
53
+ permitted_classes: YAML_PERMITTED_CLASSES,
54
+ aliases: true,
56
55
  ) || []
57
56
  else
58
57
  raise LoadError,
@@ -54,8 +54,7 @@ module Alchemy
54
54
  def find_elements(page_version)
55
55
  return Alchemy::ElementsRepository.none unless page_version
56
56
 
57
- elements = Alchemy::ElementsRepository.new(page_version.elements.available)
58
- elements = elements.not_nested
57
+ elements = page_version.element_repository.visible.not_nested
59
58
  elements = options[:fixed] ? elements.fixed : elements.unfixed
60
59
 
61
60
  if options[:only]
@@ -37,7 +37,7 @@ module Alchemy
37
37
  end
38
38
  end
39
39
 
40
- initializer "alchemy.userstamp" do
40
+ config.after_initialize do
41
41
  if Alchemy.user_class
42
42
  ActiveSupport.on_load(:active_record) do
43
43
  Alchemy.user_class.model_stamper
@@ -45,5 +45,16 @@ module Alchemy
45
45
  end
46
46
  end
47
47
  end
48
+
49
+ initializer "alchemy.webp-mime_type" do
50
+ # Rails does not know anything about webp even in 2022
51
+ unless Mime::Type.lookup_by_extension(:webp)
52
+ Mime::Type.register("image/webp", :webp)
53
+ end
54
+ # Dragonfly uses Rack to read the mime type and guess what
55
+ unless Rack::Mime::MIME_TYPES[".webp"]
56
+ Rack::Mime::MIME_TYPES[".webp"] = "image/webp"
57
+ end
58
+ end
48
59
  end
49
60
  end