alchemy_cms 4.0.0.beta → 4.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +4 -7
- data/CHANGELOG.md +23 -0
- data/README.md +1 -1
- data/alchemy_cms.gemspec +1 -1
- data/app/assets/javascripts/alchemy/alchemy.dragndrop.js.coffee +2 -2
- data/app/assets/stylesheets/alchemy/_extends.scss +3 -5
- data/app/assets/stylesheets/alchemy/_mixins.scss +1 -1
- data/app/assets/stylesheets/alchemy/base.scss +2 -2
- data/app/assets/stylesheets/alchemy/buttons.scss +2 -2
- data/app/assets/stylesheets/alchemy/dialogs.scss +3 -3
- data/app/assets/stylesheets/alchemy/elements.scss +2 -2
- data/app/assets/stylesheets/alchemy/image_library.scss +10 -10
- data/app/assets/stylesheets/alchemy/jquery.datetimepicker.scss +2 -2
- data/app/assets/stylesheets/alchemy/lists.scss +2 -1
- data/app/assets/stylesheets/alchemy/sitemap.scss +1 -16
- data/app/assets/stylesheets/alchemy/tables.scss +1 -1
- data/app/assets/stylesheets/tinymce/skins/alchemy/skin.min.css.scss +4 -4
- data/app/controllers/alchemy/admin/attachments_controller.rb +10 -10
- data/app/controllers/alchemy/admin/base_controller.rb +10 -19
- data/app/controllers/alchemy/admin/clipboard_controller.rb +20 -7
- data/app/controllers/alchemy/admin/contents_controller.rb +5 -19
- data/app/controllers/alchemy/admin/dashboard_controller.rb +5 -3
- data/app/controllers/alchemy/admin/elements_controller.rb +7 -1
- data/app/controllers/alchemy/admin/essence_files_controller.rb +2 -2
- data/app/controllers/alchemy/admin/essence_pictures_controller.rb +8 -13
- data/app/controllers/alchemy/admin/languages_controller.rb +2 -0
- data/app/controllers/alchemy/admin/layoutpages_controller.rb +2 -0
- data/app/controllers/alchemy/admin/legacy_page_urls_controller.rb +2 -0
- data/app/controllers/alchemy/admin/pages_controller.rb +3 -1
- data/app/controllers/alchemy/admin/pictures_controller.rb +11 -9
- data/app/controllers/alchemy/admin/resources_controller.rb +25 -4
- data/app/controllers/alchemy/admin/sites_controller.rb +2 -0
- data/app/controllers/alchemy/admin/tags_controller.rb +2 -0
- data/app/controllers/alchemy/admin/trash_controller.rb +2 -0
- data/app/controllers/alchemy/api/base_controller.rb +2 -0
- data/app/controllers/alchemy/api/contents_controller.rb +2 -0
- data/app/controllers/alchemy/api/elements_controller.rb +2 -0
- data/app/controllers/alchemy/api/pages_controller.rb +2 -0
- data/app/controllers/alchemy/attachments_controller.rb +2 -0
- data/app/controllers/alchemy/base_controller.rb +3 -1
- data/app/controllers/alchemy/elements_controller.rb +2 -0
- data/app/controllers/alchemy/messages_controller.rb +2 -0
- data/app/controllers/alchemy/pages_controller.rb +11 -2
- data/app/controllers/concerns/alchemy/admin/uploader_responses.rb +2 -0
- data/app/controllers/concerns/alchemy/legacy_page_redirects.rb +2 -0
- data/app/controllers/concerns/alchemy/locale_redirects.rb +2 -0
- data/app/controllers/concerns/alchemy/page_redirects.rb +2 -0
- data/app/controllers/concerns/alchemy/site_redirects.rb +2 -0
- data/app/helpers/alchemy/admin/attachments_helper.rb +2 -0
- data/app/helpers/alchemy/admin/base_helper.rb +2 -28
- data/app/helpers/alchemy/admin/contents_helper.rb +2 -0
- data/app/helpers/alchemy/admin/elements_helper.rb +2 -0
- data/app/helpers/alchemy/admin/essences_helper.rb +2 -0
- data/app/helpers/alchemy/admin/form_helper.rb +2 -0
- data/app/helpers/alchemy/admin/navigation_helper.rb +2 -0
- data/app/helpers/alchemy/admin/pages_helper.rb +2 -0
- data/app/helpers/alchemy/admin/pictures_helper.rb +2 -0
- data/app/helpers/alchemy/admin/tags_helper.rb +24 -76
- data/app/helpers/alchemy/base_helper.rb +2 -0
- data/app/helpers/alchemy/deprecated_pages_helper.rb +2 -0
- data/app/helpers/alchemy/elements_block_helper.rb +2 -0
- data/app/helpers/alchemy/elements_helper.rb +2 -0
- data/app/helpers/alchemy/essences_helper.rb +2 -0
- data/app/helpers/alchemy/pages_helper.rb +2 -0
- data/app/helpers/alchemy/url_helper.rb +2 -0
- data/app/mailers/alchemy/base_mailer.rb +2 -0
- data/app/mailers/alchemy/messages_mailer.rb +2 -0
- data/app/models/alchemy.rb +2 -0
- data/app/models/alchemy/attachment.rb +6 -4
- data/app/models/alchemy/cell.rb +4 -2
- data/app/models/alchemy/content.rb +7 -5
- data/app/models/alchemy/content/factory.rb +7 -7
- data/app/models/alchemy/element.rb +21 -28
- data/app/models/alchemy/element/definitions.rb +4 -2
- data/app/models/alchemy/element/element_contents.rb +3 -1
- data/app/models/alchemy/element/element_essences.rb +2 -0
- data/app/models/alchemy/element/presenters.rb +2 -0
- data/app/models/alchemy/element_to_page.rb +2 -0
- data/app/models/alchemy/essence_boolean.rb +2 -0
- data/app/models/alchemy/essence_date.rb +2 -0
- data/app/models/alchemy/essence_file.rb +2 -0
- data/app/models/alchemy/essence_html.rb +2 -0
- data/app/models/alchemy/essence_link.rb +6 -4
- data/app/models/alchemy/essence_picture.rb +13 -11
- data/app/models/alchemy/essence_picture_view.rb +2 -0
- data/app/models/alchemy/essence_richtext.rb +2 -0
- data/app/models/alchemy/essence_select.rb +3 -1
- data/app/models/alchemy/essence_text.rb +6 -4
- data/app/models/alchemy/folded_page.rb +4 -2
- data/app/models/alchemy/language.rb +9 -6
- data/app/models/alchemy/language/code.rb +2 -0
- data/app/models/alchemy/legacy_page_url.rb +3 -1
- data/app/models/alchemy/message.rb +2 -0
- data/app/models/alchemy/page.rb +3 -2
- data/app/models/alchemy/page/fixed_attributes.rb +2 -0
- data/app/models/alchemy/page/page_cells.rb +2 -0
- data/app/models/alchemy/page/page_elements.rb +3 -1
- data/app/models/alchemy/page/page_naming.rb +2 -0
- data/app/models/alchemy/page/page_natures.rb +2 -1
- data/app/models/alchemy/page/page_scopes.rb +2 -0
- data/app/models/alchemy/page/page_users.rb +2 -0
- data/app/models/alchemy/picture.rb +2 -0
- data/app/models/alchemy/picture/transformations.rb +2 -0
- data/app/models/alchemy/picture/url.rb +2 -0
- data/app/models/alchemy/site.rb +4 -2
- data/app/models/alchemy/site/layout.rb +2 -0
- data/app/models/alchemy/tag.rb +5 -2
- data/app/models/alchemy/tree_node.rb +2 -0
- data/app/serializers/alchemy/attachment_serializer.rb +2 -0
- data/app/serializers/alchemy/base_serializer.rb +2 -0
- data/app/serializers/alchemy/cell_serializer.rb +2 -0
- data/app/serializers/alchemy/content_serializer.rb +2 -0
- data/app/serializers/alchemy/element_serializer.rb +2 -0
- data/app/serializers/alchemy/essence_boolean_serializer.rb +2 -0
- data/app/serializers/alchemy/essence_date_serializer.rb +2 -0
- data/app/serializers/alchemy/essence_file_serializer.rb +2 -0
- data/app/serializers/alchemy/essence_html_serializer.rb +2 -0
- data/app/serializers/alchemy/essence_link_serializer.rb +2 -0
- data/app/serializers/alchemy/essence_picture_serializer.rb +2 -0
- data/app/serializers/alchemy/essence_richtext_serializer.rb +2 -0
- data/app/serializers/alchemy/essence_select_serializer.rb +2 -0
- data/app/serializers/alchemy/essence_text_serializer.rb +2 -0
- data/app/serializers/alchemy/legacy_element_serializer.rb +2 -0
- data/app/serializers/alchemy/page_serializer.rb +2 -0
- data/app/serializers/alchemy/page_tree_serializer.rb +2 -0
- data/app/serializers/alchemy/picture_serializer.rb +2 -0
- data/app/views/alchemy/admin/attachments/_archive_overlay.html.erb +1 -1
- data/app/views/alchemy/admin/attachments/_file_to_assign.html.erb +1 -1
- data/app/views/alchemy/admin/attachments/_filter_bar.html.erb +1 -3
- data/app/views/alchemy/admin/attachments/_tag_list.html.erb +1 -1
- data/app/views/alchemy/admin/contents/_missing.html.erb +1 -1
- data/app/views/alchemy/admin/contents/create.js.erb +9 -13
- data/app/views/alchemy/admin/contents/new.html.erb +1 -1
- data/app/views/alchemy/admin/elements/_picture_gallery_editor.html.erb +4 -4
- data/app/views/alchemy/admin/essence_files/assign.js.erb +1 -1
- data/app/views/alchemy/admin/essence_pictures/assign.js.erb +1 -1
- data/app/views/alchemy/admin/essence_pictures/crop.html.erb +1 -1
- data/app/views/alchemy/admin/essence_pictures/destroy.js.erb +10 -7
- data/app/views/alchemy/admin/essence_pictures/edit.html.erb +8 -6
- data/app/views/alchemy/admin/essence_pictures/update.js.erb +1 -1
- data/app/views/alchemy/admin/partials/_remote_search_form.html.erb +2 -2
- data/app/views/alchemy/admin/pictures/_filter_and_size_bar.html.erb +4 -4
- data/app/views/alchemy/admin/pictures/_filter_bar.html.erb +1 -3
- data/app/views/alchemy/admin/pictures/_overlay_picture_list.html.erb +1 -1
- data/app/views/alchemy/admin/pictures/_picture_to_assign.html.erb +1 -1
- data/app/views/alchemy/admin/pictures/_tag_list.html.erb +1 -1
- data/app/views/alchemy/admin/resources/_filter_bar.html.erb +1 -3
- data/app/views/alchemy/admin/resources/_tag_list.html.erb +1 -1
- data/app/views/alchemy/admin/uploader/_button.html.erb +1 -1
- data/app/views/alchemy/essences/_essence_file_editor.html.erb +2 -2
- data/app/views/alchemy/essences/_essence_picture_editor.html.erb +2 -2
- data/app/views/alchemy/essences/shared/_essence_picture_tools.html.erb +3 -3
- data/app/views/alchemy/navigation/_renderer.html.erb +1 -2
- data/config/brakeman.ignore +65 -0
- data/db/migrate/20130827094554_alchemy_two_point_six.rb +1 -1
- data/db/migrate/20130828121054_remove_do_not_index_from_alchemy_essence_texts.rb +1 -1
- data/db/migrate/20130828121120_remove_do_not_index_from_alchemy_essence_richtexts.rb +1 -1
- data/db/migrate/20130918201742_add_published_at_to_alchemy_pages.rb +1 -1
- data/db/migrate/20150608204610_add_parent_element_id_to_alchemy_elements.rb +1 -1
- data/db/migrate/20150729151825_add_link_text_to_alchemy_essence_files.rb +1 -1
- data/db/migrate/20150906195818_add_locale_to_alchemy_languages.rb +1 -1
- data/db/migrate/20160108174834_add_timebased_publishing_columns_to_pages.rb +1 -1
- data/db/migrate/20160422195310_add_image_file_format_to_alchemy_pictures.rb +1 -1
- data/db/migrate/20160617224938_change_alchemy_pages_locked_to_locked_at.rb +1 -1
- data/db/migrate/20160912223112_add_index_to_alchemy_pages_rgt.rb +1 -1
- data/db/migrate/20160927205604_add_foreign_key_indices_and_null_constraints.rb +1 -1
- data/db/migrate/20160928080104_add_foreign_keys.rb +1 -1
- data/lib/alchemy/ability_helper.rb +2 -0
- data/lib/alchemy/admin/locale.rb +2 -0
- data/lib/alchemy/auth_accessors.rb +2 -0
- data/lib/alchemy/cache_digests/template_tracker.rb +2 -0
- data/lib/alchemy/config.rb +2 -0
- data/lib/alchemy/configuration_methods.rb +2 -0
- data/lib/alchemy/controller_actions.rb +2 -0
- data/lib/alchemy/deprecation.rb +3 -0
- data/lib/alchemy/errors.rb +2 -0
- data/lib/alchemy/essence.rb +2 -0
- data/lib/alchemy/filetypes.rb +2 -0
- data/lib/alchemy/forms/builder.rb +2 -0
- data/lib/alchemy/hints.rb +2 -0
- data/lib/alchemy/i18n.rb +2 -0
- data/lib/alchemy/logger.rb +2 -0
- data/lib/alchemy/modules.rb +2 -0
- data/lib/alchemy/name_conversions.rb +2 -0
- data/lib/alchemy/on_page_layout.rb +2 -0
- data/lib/alchemy/on_page_layout/callbacks_runner.rb +2 -0
- data/lib/alchemy/page_layout.rb +3 -1
- data/lib/alchemy/paths.rb +2 -0
- data/lib/alchemy/permissions.rb +2 -0
- data/lib/alchemy/picture_attributes.rb +2 -0
- data/lib/alchemy/resource.rb +2 -0
- data/lib/alchemy/resources_helper.rb +14 -12
- data/lib/alchemy/routing_constraints.rb +2 -0
- data/lib/alchemy/ssl_protection.rb +2 -0
- data/lib/alchemy/test_support/controller_requests.rb +20 -0
- data/lib/alchemy/test_support/essence_shared_examples.rb +3 -21
- data/lib/alchemy/tinymce.rb +2 -0
- data/lib/alchemy/touching.rb +2 -0
- data/lib/alchemy/upgrader/three_point_four.rb +20 -3
- data/lib/alchemy/userstamp.rb +2 -0
- data/lib/alchemy/version.rb +3 -1
- data/lib/alchemy_cms.rb +1 -0
- data/lib/tasks/alchemy/upgrade.rake +5 -1
- metadata +7 -5
@@ -1,6 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Alchemy
|
2
4
|
module Admin
|
3
5
|
class ClipboardController < Alchemy::Admin::BaseController
|
6
|
+
REMARKABLE_TYPES = %w(elements pages)
|
7
|
+
|
4
8
|
authorize_resource class: :alchemy_admin_clipboard
|
5
9
|
before_action :set_clipboard
|
6
10
|
|
@@ -12,10 +16,10 @@ module Alchemy
|
|
12
16
|
end
|
13
17
|
|
14
18
|
def insert
|
15
|
-
@item = model_class.find(
|
16
|
-
unless @clipboard.detect { |item| item['id'] ==
|
19
|
+
@item = model_class.find(remarkable_params[:remarkable_id])
|
20
|
+
unless @clipboard.detect { |item| item['id'] == remarkable_params[:remarkable_id] }
|
17
21
|
@clipboard << {
|
18
|
-
'id' =>
|
22
|
+
'id' => remarkable_params[:remarkable_id],
|
19
23
|
'action' => params[:remove] ? 'cut' : 'copy'
|
20
24
|
}
|
21
25
|
end
|
@@ -25,8 +29,8 @@ module Alchemy
|
|
25
29
|
end
|
26
30
|
|
27
31
|
def remove
|
28
|
-
@item = model_class.find(
|
29
|
-
@clipboard.delete_if { |item| item['id'] ==
|
32
|
+
@item = model_class.find(remarkable_params[:remarkable_id])
|
33
|
+
@clipboard.delete_if { |item| item['id'] == remarkable_params[:remarkable_id] }
|
30
34
|
respond_to do |format|
|
31
35
|
format.js
|
32
36
|
end
|
@@ -39,11 +43,20 @@ module Alchemy
|
|
39
43
|
private
|
40
44
|
|
41
45
|
def set_clipboard
|
42
|
-
@clipboard = get_clipboard(
|
46
|
+
@clipboard = get_clipboard(remarkable_type)
|
43
47
|
end
|
44
48
|
|
45
49
|
def model_class
|
46
|
-
|
50
|
+
raise ActionController::BadRequest unless remarkable_type
|
51
|
+
"alchemy/#{remarkable_type}".classify.constantize
|
52
|
+
end
|
53
|
+
|
54
|
+
def remarkable_params
|
55
|
+
params.permit(:remarkable_type, :remarkable_id)
|
56
|
+
end
|
57
|
+
|
58
|
+
def remarkable_type
|
59
|
+
remarkable_params.keep_if { |_k, type| type.in? REMARKABLE_TYPES }[:remarkable_type]
|
47
60
|
end
|
48
61
|
end
|
49
62
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Alchemy
|
2
4
|
module Admin
|
3
5
|
class ContentsController < Alchemy::Admin::BaseController
|
@@ -7,23 +9,21 @@ module Alchemy
|
|
7
9
|
|
8
10
|
def new
|
9
11
|
@element = Element.find(params[:element_id])
|
10
|
-
@options = options_from_params
|
11
12
|
@content = @element.contents.build
|
12
13
|
end
|
13
14
|
|
14
15
|
def create
|
15
16
|
@element = Element.find(params[:content][:element_id])
|
16
17
|
@content = Content.create_from_scratch(@element, content_params)
|
17
|
-
@options = options_from_params
|
18
18
|
@html_options = params[:html_options] || {}
|
19
19
|
if picture_gallery_editor?
|
20
20
|
@content.update_essence(picture_id: params[:picture_id])
|
21
|
-
@
|
21
|
+
@gallery_pictures = @element.contents.gallery_pictures
|
22
|
+
options_from_params[:sortable] = @gallery_pictures.size > 1
|
22
23
|
@content_dom_id = "#add_picture_#{@element.id}"
|
23
24
|
else
|
24
25
|
@content_dom_id = "#add_content_for_element_#{@element.id}"
|
25
26
|
end
|
26
|
-
@locals = essence_editor_locals
|
27
27
|
end
|
28
28
|
|
29
29
|
def update
|
@@ -54,21 +54,7 @@ module Alchemy
|
|
54
54
|
end
|
55
55
|
|
56
56
|
def picture_gallery_editor?
|
57
|
-
params[:content][:essence_type] == 'Alchemy::EssencePicture' &&
|
58
|
-
end
|
59
|
-
|
60
|
-
def options_for_picture_gallery
|
61
|
-
@gallery_pictures = @element.contents.gallery_pictures
|
62
|
-
@dragable = @gallery_pictures.size > 1
|
63
|
-
@options.merge(dragable: @dragable)
|
64
|
-
end
|
65
|
-
|
66
|
-
def essence_editor_locals
|
67
|
-
{
|
68
|
-
content: @content,
|
69
|
-
options: @options.symbolize_keys,
|
70
|
-
html_options: @html_options.symbolize_keys
|
71
|
-
}
|
57
|
+
params[:content][:essence_type] == 'Alchemy::EssencePicture' && options_from_params[:grouped] == 'true'
|
72
58
|
end
|
73
59
|
end
|
74
60
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'net/http'
|
2
4
|
require 'alchemy/version'
|
3
5
|
|
@@ -26,12 +28,12 @@ module Alchemy
|
|
26
28
|
def update_check
|
27
29
|
@alchemy_version = Alchemy.version
|
28
30
|
if @alchemy_version < latest_alchemy_version
|
29
|
-
render
|
31
|
+
render plain: 'true'
|
30
32
|
else
|
31
|
-
render
|
33
|
+
render plain: 'false'
|
32
34
|
end
|
33
35
|
rescue UpdateServiceUnavailable => e
|
34
|
-
render
|
36
|
+
render plain: e, status: 503
|
35
37
|
end
|
36
38
|
|
37
39
|
private
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Alchemy
|
2
4
|
module Admin
|
3
5
|
class ElementsController < Alchemy::Admin::BaseController
|
@@ -39,7 +41,7 @@ module Alchemy
|
|
39
41
|
@element = paste_element_from_clipboard
|
40
42
|
@cell = @element.cell
|
41
43
|
else
|
42
|
-
@element = Element.new_from_scratch(
|
44
|
+
@element = Element.new_from_scratch(create_element_params)
|
43
45
|
if @page.can_have_cells?
|
44
46
|
@cell = find_or_create_cell
|
45
47
|
@element.cell = @cell
|
@@ -173,6 +175,10 @@ module Alchemy
|
|
173
175
|
params.fetch(:element, {})
|
174
176
|
end
|
175
177
|
end
|
178
|
+
|
179
|
+
def create_element_params
|
180
|
+
params.require(:element).permit(:name, :page_id, :parent_element_id)
|
181
|
+
end
|
176
182
|
end
|
177
183
|
end
|
178
184
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Alchemy
|
2
4
|
module Admin
|
3
5
|
class EssenceFilesController < Alchemy::Admin::BaseController
|
@@ -9,7 +11,6 @@ module Alchemy
|
|
9
11
|
|
10
12
|
def edit
|
11
13
|
@content = @essence_file.content
|
12
|
-
@options = options_from_params
|
13
14
|
end
|
14
15
|
|
15
16
|
def update
|
@@ -24,7 +25,6 @@ module Alchemy
|
|
24
25
|
@content = Content.find_by(id: params[:content_id])
|
25
26
|
@attachment = Attachment.find_by(id: params[:attachment_id])
|
26
27
|
@content.essence.attachment = @attachment
|
27
|
-
@options = options_from_params
|
28
28
|
|
29
29
|
# We need to update timestamp here because we don't save yet,
|
30
30
|
# but the cache needs to be get invalid.
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Alchemy
|
2
4
|
module Admin
|
3
5
|
class EssencePicturesController < Alchemy::Admin::BaseController
|
@@ -6,7 +8,6 @@ module Alchemy
|
|
6
8
|
|
7
9
|
before_action :load_essence_picture, only: [:edit, :crop, :update]
|
8
10
|
before_action :load_content, only: [:edit, :update, :assign]
|
9
|
-
before_action :load_options
|
10
11
|
|
11
12
|
helper 'alchemy/admin/contents'
|
12
13
|
helper 'alchemy/admin/essences'
|
@@ -18,7 +19,7 @@ module Alchemy
|
|
18
19
|
def crop
|
19
20
|
if @picture = @essence_picture.picture
|
20
21
|
@content = @essence_picture.content
|
21
|
-
|
22
|
+
options_from_params[:format] ||= (configuration(:image_store_format) || 'png')
|
22
23
|
|
23
24
|
@min_size = sizes_from_essence_or_params
|
24
25
|
@ratio = ratio_from_size_or_params
|
@@ -35,7 +36,7 @@ module Alchemy
|
|
35
36
|
@essence_picture.update(essence_picture_params)
|
36
37
|
end
|
37
38
|
|
38
|
-
# Assigns picture, but does not
|
39
|
+
# Assigns picture, but does not save it.
|
39
40
|
#
|
40
41
|
# When the user saves the element the content gets updated as well.
|
41
42
|
#
|
@@ -43,8 +44,6 @@ module Alchemy
|
|
43
44
|
@picture = Picture.find_by(id: params[:picture_id])
|
44
45
|
@content.essence.picture = @picture
|
45
46
|
@element = @content.element
|
46
|
-
@dragable = @options[:grouped]
|
47
|
-
@options = @options.merge(dragable: @dragable)
|
48
47
|
|
49
48
|
# We need to update timestamp here because we don't save yet,
|
50
49
|
# but the cache needs to be get invalid.
|
@@ -63,10 +62,6 @@ module Alchemy
|
|
63
62
|
|
64
63
|
private
|
65
64
|
|
66
|
-
def load_options
|
67
|
-
@options = options_from_params
|
68
|
-
end
|
69
|
-
|
70
65
|
def load_essence_picture
|
71
66
|
@essence_picture = EssencePicture.find(params[:id])
|
72
67
|
end
|
@@ -82,8 +77,8 @@ module Alchemy
|
|
82
77
|
def sizes_from_essence_or_params
|
83
78
|
if @essence_picture.render_size?
|
84
79
|
@essence_picture.sizes_from_string(@essence_picture.render_size)
|
85
|
-
elsif
|
86
|
-
@essence_picture.sizes_from_string(
|
80
|
+
elsif options_from_params[:size]
|
81
|
+
@essence_picture.sizes_from_string(options_from_params[:size])
|
87
82
|
else
|
88
83
|
{ width: 0, height: 0 }
|
89
84
|
end
|
@@ -93,8 +88,8 @@ module Alchemy
|
|
93
88
|
# aspect ratio, don't specify a size or only width or height.
|
94
89
|
#
|
95
90
|
def ratio_from_size_or_params
|
96
|
-
if @min_size.value?(0) &&
|
97
|
-
|
91
|
+
if @min_size.value?(0) && options_from_params[:fixed_ratio].to_s =~ FLOAT_REGEX
|
92
|
+
options_from_params[:fixed_ratio].to_f
|
98
93
|
elsif !@min_size[:width].zero? && !@min_size[:height].zero?
|
99
94
|
@min_size[:width].to_f / @min_size[:height].to_f
|
100
95
|
else
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Alchemy
|
2
4
|
module Admin
|
3
5
|
class PagesController < Alchemy::Admin::BaseController
|
@@ -187,7 +189,7 @@ module Alchemy
|
|
187
189
|
# fetching page via before filter
|
188
190
|
@page.publish!
|
189
191
|
flash[:notice] = Alchemy.t(:page_published, name: @page.name)
|
190
|
-
|
192
|
+
redirect_back(fallback_location: admin_pages_path)
|
191
193
|
end
|
192
194
|
|
193
195
|
def copy_language_tree
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Alchemy
|
2
4
|
module Admin
|
3
5
|
class PicturesController < Alchemy::Admin::ResourcesController
|
@@ -127,7 +129,6 @@ module Alchemy
|
|
127
129
|
def archive_overlay
|
128
130
|
@content = Content.select('id').find_by(id: params[:content_id])
|
129
131
|
@element = Element.select('id').find_by(id: params[:element_id])
|
130
|
-
@options = options_from_params
|
131
132
|
|
132
133
|
respond_to do |format|
|
133
134
|
format.html { render partial: 'archive_overlay' }
|
@@ -136,16 +137,17 @@ module Alchemy
|
|
136
137
|
end
|
137
138
|
|
138
139
|
def redirect_to_index
|
139
|
-
do_redirect_to admin_pictures_path(
|
140
|
+
do_redirect_to admin_pictures_path(search_filter_params)
|
140
141
|
end
|
141
142
|
|
142
|
-
def
|
143
|
-
params.except(
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
143
|
+
def search_filter_params
|
144
|
+
params.except(*COMMON_SEARCH_FILTER_EXCLUDES + [:picture_ids]).permit(
|
145
|
+
*common_search_filter_includes + [
|
146
|
+
:size,
|
147
|
+
:element_id,
|
148
|
+
:swap,
|
149
|
+
:content_id
|
150
|
+
]
|
149
151
|
)
|
150
152
|
end
|
151
153
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'csv'
|
2
4
|
require 'alchemy/resource'
|
3
5
|
require 'alchemy/resources_helper'
|
@@ -5,17 +7,17 @@ require 'alchemy/resources_helper'
|
|
5
7
|
module Alchemy
|
6
8
|
module Admin
|
7
9
|
class ResourcesController < Alchemy::Admin::BaseController
|
10
|
+
COMMON_SEARCH_FILTER_EXCLUDES = [:id, :utf8, :_method, :_].freeze
|
11
|
+
|
8
12
|
include Alchemy::ResourcesHelper
|
9
13
|
|
10
14
|
helper Alchemy::ResourcesHelper, TagsHelper
|
11
|
-
helper_method :resource_handler
|
15
|
+
helper_method :resource_handler, :search_filter_params
|
12
16
|
|
13
17
|
before_action :load_resource,
|
14
18
|
only: [:show, :edit, :update, :destroy]
|
15
19
|
|
16
|
-
before_action
|
17
|
-
authorize!(action_name.to_sym, resource_instance_variable || resource_handler.model)
|
18
|
-
end
|
20
|
+
before_action :authorize_resource
|
19
21
|
|
20
22
|
def index
|
21
23
|
@query = resource_handler.model.ransack(params[:q])
|
@@ -112,6 +114,10 @@ module Alchemy
|
|
112
114
|
instance_variable_set("@#{resource_handler.resource_name}", resource_handler.model.find(params[:id]))
|
113
115
|
end
|
114
116
|
|
117
|
+
def authorize_resource
|
118
|
+
authorize!(action_name.to_sym, resource_instance_variable || resource_handler.model)
|
119
|
+
end
|
120
|
+
|
115
121
|
# Permits all parameters as default!
|
116
122
|
#
|
117
123
|
# THIS IS INSECURE! Although only signed in admin users can send requests anyway, but we should change this.
|
@@ -129,6 +135,21 @@ module Alchemy
|
|
129
135
|
filter == params[:filter]
|
130
136
|
end || :all
|
131
137
|
end
|
138
|
+
|
139
|
+
def search_filter_params
|
140
|
+
params.except(*COMMON_SEARCH_FILTER_EXCLUDES).permit(*common_search_filter_includes)
|
141
|
+
end
|
142
|
+
|
143
|
+
def common_search_filter_includes
|
144
|
+
[
|
145
|
+
# contrary to Rails' documentation passing an empty hash to permit all keys does not work
|
146
|
+
{options: options_from_params.keys},
|
147
|
+
{q: resource_handler.search_field_name},
|
148
|
+
:tagged_with,
|
149
|
+
:filter,
|
150
|
+
:page
|
151
|
+
].freeze
|
152
|
+
end
|
132
153
|
end
|
133
154
|
end
|
134
155
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# This is the main Alchemy controller all other controllers inherit from.
|
2
4
|
#
|
3
5
|
module Alchemy
|
@@ -76,7 +78,7 @@ module Alchemy
|
|
76
78
|
if request.xhr?
|
77
79
|
respond_to do |format|
|
78
80
|
format.js do
|
79
|
-
render
|
81
|
+
render plain: flash.discard(:warning), status: 403
|
80
82
|
end
|
81
83
|
format.html do
|
82
84
|
render partial: 'alchemy/admin/partials/flash',
|