alchemy_cms 7.0.0.pre.a → 7.0.0.pre.b
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/brakeman-analysis.yml +2 -2
- data/.github/workflows/ci.yml +7 -7
- data/.github/workflows/lint.yml +17 -0
- data/.hound.yml +2 -3
- data/.rubocop.yml +4 -350
- data/.standard.yml +3 -0
- data/CHANGELOG.md +29 -0
- data/Gemfile +3 -1
- data/README.md +7 -9
- data/Rakefile +1 -1
- data/alchemy_cms.gemspec +2 -1
- data/app/assets/javascripts/alchemy/admin.js +0 -1
- data/app/assets/javascripts/alchemy/alchemy.link_dialog.js.coffee +6 -1
- data/app/components/alchemy/ingredients/audio_view.rb +37 -0
- data/app/components/alchemy/ingredients/base_view.rb +38 -0
- data/app/components/alchemy/ingredients/boolean_view.rb +13 -0
- data/app/components/alchemy/ingredients/datetime_view.rb +22 -0
- data/app/components/alchemy/ingredients/file_view.rb +40 -0
- data/app/components/alchemy/ingredients/headline_view.rb +20 -0
- data/app/components/alchemy/ingredients/html_view.rb +9 -0
- data/app/components/alchemy/ingredients/link_view.rb +25 -0
- data/app/components/alchemy/ingredients/node_view.rb +11 -0
- data/app/components/alchemy/ingredients/page_view.rb +15 -0
- data/app/components/alchemy/ingredients/picture_view.rb +108 -0
- data/app/components/alchemy/ingredients/richtext_view.rb +22 -0
- data/app/components/alchemy/ingredients/select_view.rb +6 -0
- data/app/components/alchemy/ingredients/text_view.rb +41 -0
- data/app/components/alchemy/ingredients/video_view.rb +39 -0
- data/app/controllers/alchemy/admin/attachments_controller.rb +3 -3
- data/app/controllers/alchemy/admin/base_controller.rb +7 -7
- data/app/controllers/alchemy/admin/clipboard_controller.rb +2 -2
- data/app/controllers/alchemy/admin/elements_controller.rb +26 -11
- data/app/controllers/alchemy/admin/languages_controller.rb +1 -1
- data/app/controllers/alchemy/admin/nodes_controller.rb +2 -2
- data/app/controllers/alchemy/admin/pages_controller.rb +10 -10
- data/app/controllers/alchemy/admin/pictures_controller.rb +14 -14
- data/app/controllers/alchemy/admin/resources_controller.rb +27 -28
- data/app/controllers/alchemy/admin/styleguide_controller.rb +1 -0
- data/app/controllers/alchemy/admin/tags_controller.rb +11 -11
- data/app/controllers/alchemy/api/base_controller.rb +2 -2
- data/app/controllers/alchemy/api/elements_controller.rb +11 -11
- data/app/controllers/alchemy/api/ingredients_controller.rb +1 -1
- data/app/controllers/alchemy/api/nodes_controller.rb +1 -1
- data/app/controllers/alchemy/api/pages_controller.rb +11 -11
- data/app/controllers/alchemy/attachments_controller.rb +3 -3
- data/app/controllers/alchemy/base_controller.rb +1 -1
- data/app/controllers/alchemy/messages_controller.rb +9 -9
- data/app/controllers/alchemy/pages_controller.rb +8 -19
- data/app/controllers/concerns/alchemy/admin/archive_overlay.rb +1 -0
- data/app/controllers/concerns/alchemy/admin/uploader_responses.rb +5 -7
- data/app/controllers/concerns/alchemy/legacy_page_redirects.rb +5 -5
- data/app/decorators/alchemy/element_editor.rb +4 -4
- data/app/decorators/alchemy/ingredient_editor.rb +6 -6
- data/app/helpers/alchemy/admin/attachments_helper.rb +1 -1
- data/app/helpers/alchemy/admin/base_helper.rb +21 -22
- data/app/helpers/alchemy/admin/elements_helper.rb +1 -1
- data/app/helpers/alchemy/admin/form_helper.rb +1 -1
- data/app/helpers/alchemy/admin/navigation_helper.rb +7 -7
- data/app/helpers/alchemy/admin/pages_helper.rb +2 -2
- data/app/helpers/alchemy/admin/tags_helper.rb +3 -3
- data/app/helpers/alchemy/base_helper.rb +2 -2
- data/app/helpers/alchemy/elements_block_helper.rb +9 -7
- data/app/helpers/alchemy/elements_helper.rb +12 -12
- data/app/helpers/alchemy/pages_helper.rb +11 -11
- data/app/helpers/alchemy/url_helper.rb +1 -1
- data/app/mailers/alchemy/messages_mailer.rb +1 -1
- data/app/models/alchemy/attachment.rb +6 -6
- data/app/models/alchemy/base_record.rb +1 -0
- data/app/models/alchemy/eager_loading.rb +6 -6
- data/app/models/alchemy/element/definitions.rb +1 -1
- data/app/models/alchemy/element/element_ingredients.rb +3 -3
- data/app/models/alchemy/element.rb +2 -2
- data/app/models/alchemy/elements_repository.rb +1 -1
- data/app/models/alchemy/image_cropper_settings.rb +2 -2
- data/app/models/alchemy/ingredient.rb +14 -12
- data/app/models/alchemy/ingredient_validator.rb +1 -1
- data/app/models/alchemy/ingredients/datetime.rb +1 -1
- data/app/models/alchemy/ingredients/file.rb +5 -5
- data/app/models/alchemy/ingredients/headline.rb +4 -4
- data/app/models/alchemy/ingredients/picture.rb +27 -9
- data/app/models/alchemy/ingredients/richtext.rb +15 -12
- data/app/models/alchemy/ingredients/text.rb +6 -6
- data/app/models/alchemy/language/code.rb +1 -1
- data/app/models/alchemy/language.rb +4 -4
- data/app/models/alchemy/legacy_page_url.rb +1 -1
- data/app/models/alchemy/node.rb +2 -2
- data/app/models/alchemy/page/page_elements.rb +14 -14
- data/app/models/alchemy/page/page_naming.rb +4 -4
- data/app/models/alchemy/page/page_natures.rb +1 -1
- data/app/models/alchemy/page/page_scopes.rb +5 -5
- data/app/models/alchemy/page.rb +11 -11
- data/app/models/alchemy/picture/calculations.rb +2 -2
- data/app/models/alchemy/picture/transformations.rb +2 -2
- data/app/models/alchemy/picture/url.rb +4 -4
- data/app/models/alchemy/picture.rb +11 -10
- data/app/models/alchemy/picture_thumb/create.rb +1 -1
- data/app/models/alchemy/picture_thumb.rb +1 -1
- data/app/models/alchemy/picture_variant.rb +2 -3
- data/app/models/alchemy/tag.rb +8 -0
- data/app/models/concerns/alchemy/picture_thumbnails.rb +6 -6
- data/app/serializers/alchemy/base_serializer.rb +1 -1
- data/app/serializers/alchemy/page_tree_serializer.rb +7 -7
- data/app/services/alchemy/duplicate_element.rb +3 -3
- data/app/services/alchemy/tag_validations.rb +1 -1
- data/app/views/alchemy/admin/elements/_element.html.erb +3 -0
- data/app/views/alchemy/admin/pages/edit.html.erb +0 -3
- data/app/views/alchemy/admin/pages/update.js.erb +10 -4
- data/app/views/alchemy/admin/pictures/_infos.html.erb +1 -1
- data/app/views/alchemy/ingredients/_audio_view.html.erb +1 -14
- data/app/views/alchemy/ingredients/_boolean_view.html.erb +1 -1
- data/app/views/alchemy/ingredients/_datetime_view.html.erb +3 -9
- data/app/views/alchemy/ingredients/_file_view.html.erb +3 -16
- data/app/views/alchemy/ingredients/_headline_view.html.erb +4 -10
- data/app/views/alchemy/ingredients/_html_view.html.erb +1 -1
- data/app/views/alchemy/ingredients/_link_view.html.erb +4 -9
- data/app/views/alchemy/ingredients/_node_view.html.erb +1 -1
- data/app/views/alchemy/ingredients/_page_view.html.erb +1 -4
- data/app/views/alchemy/ingredients/_picture_view.html.erb +4 -5
- data/app/views/alchemy/ingredients/_richtext_editor.html.erb +11 -2
- data/app/views/alchemy/ingredients/_richtext_view.html.erb +3 -3
- data/app/views/alchemy/ingredients/_select_view.html.erb +1 -1
- data/app/views/alchemy/ingredients/_text_view.html.erb +3 -19
- data/app/views/alchemy/ingredients/_video_view.html.erb +3 -18
- data/app/views/alchemy/ingredients/shared/_link_tools.html.erb +1 -0
- data/app/views/alchemy/ingredients/shared/_picture_tools.html.erb +1 -0
- data/app/views/layouts/alchemy/admin.html.erb +7 -9
- data/bin/setup +37 -0
- data/bin/start +17 -0
- data/config/initializers/assets.rb +1 -0
- data/config/initializers/dragonfly.rb +1 -0
- data/config/initializers/mime_types.rb +1 -0
- data/config/initializers/mini_profiler.rb +1 -0
- data/config/initializers/simple_form.rb +3 -2
- data/config/locales/alchemy.en.yml +1 -1
- data/config/routes.rb +21 -20
- data/config/spring.rb +1 -0
- data/db/migrate/20230121212637_alchemy_six_point_one.rb +8 -8
- data/db/migrate/20230505132743_add_indexes_to_alchemy_pictures.rb +6 -0
- data/lib/alchemy/admin/locale.rb +3 -3
- data/lib/alchemy/admin/preview_url.rb +2 -2
- data/lib/alchemy/auth_accessors.rb +1 -1
- data/lib/alchemy/config.rb +1 -1
- data/lib/alchemy/controller_actions.rb +4 -4
- data/lib/alchemy/deprecation.rb +1 -0
- data/lib/alchemy/dragonfly/processors/thumbnail.rb +1 -1
- data/lib/alchemy/element_definition.rb +2 -2
- data/lib/alchemy/engine.rb +2 -1
- data/lib/alchemy/filetypes.rb +7 -7
- data/lib/alchemy/forms/builder.rb +4 -4
- data/lib/alchemy/i18n.rb +6 -4
- data/lib/alchemy/install/tasks.rb +2 -1
- data/lib/alchemy/name_conversions.rb +1 -1
- data/lib/alchemy/page_layout.rb +1 -1
- data/lib/alchemy/permissions.rb +5 -4
- data/lib/alchemy/resource.rb +10 -10
- data/lib/alchemy/resources_helper.rb +7 -7
- data/lib/alchemy/routing_constraints.rb +2 -2
- data/lib/alchemy/seeder.rb +12 -5
- data/lib/alchemy/shell.rb +2 -1
- data/lib/alchemy/taggable.rb +3 -2
- data/lib/alchemy/tasks/tidy.rb +1 -0
- data/lib/alchemy/test_support/capybara_helpers.rb +1 -1
- data/lib/alchemy/test_support/config_stubbing.rb +1 -0
- data/lib/alchemy/test_support/factories/element_factory.rb +4 -0
- data/lib/alchemy/test_support/factories/page_factory.rb +2 -2
- data/lib/alchemy/test_support/having_crop_action_examples.rb +9 -9
- data/lib/alchemy/test_support/having_picture_thumbnails_examples.rb +33 -33
- data/lib/alchemy/test_support/integration_helpers.rb +4 -3
- data/lib/alchemy/test_support/shared_contexts.rb +2 -1
- data/lib/alchemy/test_support/shared_dom_ids_examples.rb +9 -9
- data/lib/alchemy/test_support/shared_ingredient_examples.rb +12 -6
- data/lib/alchemy/test_support/shared_uploader_examples.rb +1 -0
- data/lib/alchemy/tinymce.rb +3 -26
- data/lib/alchemy/upgrader.rb +1 -0
- data/lib/alchemy/version.rb +1 -1
- data/lib/alchemy_cms.rb +1 -0
- data/lib/generators/alchemy/base.rb +3 -2
- data/lib/generators/alchemy/elements/elements_generator.rb +2 -1
- data/lib/generators/alchemy/ingredient/ingredient_generator.rb +1 -0
- data/lib/generators/alchemy/install/files/application.html.erb +1 -1
- data/lib/generators/alchemy/install/install_generator.rb +2 -1
- data/lib/generators/alchemy/module/module_generator.rb +1 -0
- data/lib/generators/alchemy/page_layouts/page_layouts_generator.rb +1 -0
- data/lib/generators/alchemy/site_layouts/site_layouts_generator.rb +1 -0
- data/lib/generators/alchemy/views/views_generator.rb +2 -1
- data/lib/tasks/alchemy/thumbnails.rake +5 -5
- data/lib/tasks/alchemy/tidy.rake +1 -0
- data/lib/tasks/alchemy/upgrade.rake +6 -5
- data/package/admin.js +2 -0
- data/package/dist/admin.js +3 -3
- data/package/dist/admin.js.map +4 -4
- data/package/src/datepicker.js +1 -0
- data/package/src/tinymce.js +142 -0
- data/package.json +2 -2
- metadata +39 -7
- data/app/assets/javascripts/alchemy/alchemy.tinymce.js.coffee +0 -93
- data/app/presenters/alchemy/picture_view.rb +0 -88
- data/app/views/alchemy/admin/pages/_tinymce_custom_config.html.erb +0 -10
@@ -25,7 +25,7 @@ module Alchemy
|
|
25
25
|
THUMBNAIL_SIZES = {
|
26
26
|
small: "80x60",
|
27
27
|
medium: "160x120",
|
28
|
-
large: "240x180"
|
28
|
+
large: "240x180"
|
29
29
|
}.with_indifferent_access.freeze
|
30
30
|
|
31
31
|
CONVERTIBLE_FILE_FORMATS = %w[gif jpg jpeg png webp].freeze
|
@@ -38,7 +38,7 @@ module Alchemy
|
|
38
38
|
:format,
|
39
39
|
:quality,
|
40
40
|
:size,
|
41
|
-
:upsample
|
41
|
+
:upsample
|
42
42
|
]
|
43
43
|
|
44
44
|
include Alchemy::Logger
|
@@ -64,7 +64,7 @@ module Alchemy
|
|
64
64
|
# to ensure this runs before Dragonfly's before_destroy callback.
|
65
65
|
#
|
66
66
|
before_destroy unless: :deletable? do
|
67
|
-
raise PictureInUseError, Alchemy.t(:cannot_delete_picture_notice) % {
|
67
|
+
raise PictureInUseError, Alchemy.t(:cannot_delete_picture_notice) % {name: name}
|
68
68
|
end
|
69
69
|
|
70
70
|
# Image preprocessing class
|
@@ -117,7 +117,7 @@ module Alchemy
|
|
117
117
|
-> {
|
118
118
|
where("#{table_name}.id NOT IN (SELECT related_object_id FROM alchemy_ingredients WHERE related_object_type = 'Alchemy::Picture')")
|
119
119
|
}
|
120
|
-
scope :without_tag, -> { left_outer_joins(:taggings).where(gutentag_taggings: {
|
120
|
+
scope :without_tag, -> { left_outer_joins(:taggings).where(gutentag_taggings: {id: nil}) }
|
121
121
|
scope :by_file_format, ->(format) { where(image_file_format: format) }
|
122
122
|
|
123
123
|
# Class methods
|
@@ -138,20 +138,21 @@ module Alchemy
|
|
138
138
|
end
|
139
139
|
|
140
140
|
def alchemy_resource_filters
|
141
|
+
@_file_formats ||= distinct.pluck(:image_file_format).compact.presence || []
|
141
142
|
[
|
142
143
|
{
|
143
144
|
name: :by_file_format,
|
144
|
-
values:
|
145
|
+
values: @_file_formats
|
145
146
|
},
|
146
147
|
{
|
147
148
|
name: :misc,
|
148
|
-
values: %w
|
149
|
-
}
|
149
|
+
values: %w[recent last_upload without_tag deletable]
|
150
|
+
}
|
150
151
|
]
|
151
152
|
end
|
152
153
|
|
153
154
|
def searchable_alchemy_resource_attributes
|
154
|
-
%w
|
155
|
+
%w[name image_file_name]
|
155
156
|
end
|
156
157
|
|
157
158
|
def last_upload
|
@@ -183,7 +184,7 @@ module Alchemy
|
|
183
184
|
options.except(*TRANSFORMATION_OPTIONS).merge(
|
184
185
|
basename: name,
|
185
186
|
ext: variant.render_format,
|
186
|
-
name: name
|
187
|
+
name: name
|
187
188
|
)
|
188
189
|
)
|
189
190
|
rescue ::Dragonfly::Job::Fetch::NotFound => e
|
@@ -211,7 +212,7 @@ module Alchemy
|
|
211
212
|
{
|
212
213
|
name: image_file_name,
|
213
214
|
size: image_file_size,
|
214
|
-
error: errors[:image_file].join
|
215
|
+
error: errors[:image_file].join
|
215
216
|
}
|
216
217
|
end
|
217
218
|
|
@@ -42,7 +42,7 @@ module Alchemy
|
|
42
42
|
Alchemy::Picture::THUMBNAIL_SIZES.values.each do |size|
|
43
43
|
variant = Alchemy::PictureVariant.new(picture, {
|
44
44
|
size: size,
|
45
|
-
flatten: true
|
45
|
+
flatten: true
|
46
46
|
})
|
47
47
|
signature = Alchemy::PictureThumb::Signature.call(variant)
|
48
48
|
thumb = find_by(signature: signature)
|
@@ -54,8 +54,7 @@ module Alchemy
|
|
54
54
|
raise MissingImageFileError, "Missing image file for #{picture.inspect}" if image.nil?
|
55
55
|
|
56
56
|
image = processed_image(image, @options)
|
57
|
-
|
58
|
-
image
|
57
|
+
encoded_image(image, @options)
|
59
58
|
rescue MissingImageFileError, WrongImageFormatError => e
|
60
59
|
log_warning(e.message)
|
61
60
|
nil
|
@@ -88,7 +87,7 @@ module Alchemy
|
|
88
87
|
end
|
89
88
|
|
90
89
|
options = {
|
91
|
-
flatten: !render_format.in?(ANIMATED_IMAGE_FORMATS) && picture.image_file_format == "gif"
|
90
|
+
flatten: !render_format.in?(ANIMATED_IMAGE_FORMATS) && picture.image_file_format == "gif"
|
92
91
|
}.with_indifferent_access.merge(options)
|
93
92
|
|
94
93
|
encoding_options = []
|
data/app/models/alchemy/tag.rb
CHANGED
@@ -13,6 +13,14 @@
|
|
13
13
|
# The original Tag model is Gutentag::Tag
|
14
14
|
module Alchemy
|
15
15
|
class Tag < Gutentag::Tag
|
16
|
+
def self.ransackable_attributes(_auth_object = nil)
|
17
|
+
%w[created_at id name taggings_count updated_at]
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.ransackable_associations(_auth_object = nil)
|
21
|
+
%w[taggings]
|
22
|
+
end
|
23
|
+
|
16
24
|
# Replaces tag with new tag on all models tagged with tag.
|
17
25
|
def self.replace(tag, new_tag)
|
18
26
|
tag.taggings.collect(&:taggable).each do |taggable|
|
@@ -56,7 +56,7 @@ module Alchemy
|
|
56
56
|
crop: crop,
|
57
57
|
crop_from: crop && crop_from.presence || nil,
|
58
58
|
crop_size: crop && crop_size.presence || nil,
|
59
|
-
size: settings[:size]
|
59
|
+
size: settings[:size]
|
60
60
|
}.with_indifferent_access
|
61
61
|
end
|
62
62
|
|
@@ -84,7 +84,7 @@ module Alchemy
|
|
84
84
|
crop_from: crop && crop_from.presence || default_crop_from&.join("x"),
|
85
85
|
crop_size: crop && crop_size.presence || default_crop_size&.join("x"),
|
86
86
|
flatten: true,
|
87
|
-
format: picture&.image_file_format || "jpg"
|
87
|
+
format: picture&.image_file_format || "jpg"
|
88
88
|
}
|
89
89
|
end
|
90
90
|
|
@@ -96,7 +96,7 @@ module Alchemy
|
|
96
96
|
default_crop_size: default_crop_size,
|
97
97
|
fixed_ratio: settings[:fixed_ratio],
|
98
98
|
image_width: picture&.image_file_width,
|
99
|
-
image_height: picture&.image_file_height
|
99
|
+
image_height: picture&.image_file_height
|
100
100
|
).to_h
|
101
101
|
end
|
102
102
|
|
@@ -105,7 +105,7 @@ module Alchemy
|
|
105
105
|
settings[:crop] && picture &&
|
106
106
|
picture.can_be_cropped_to?(
|
107
107
|
settings[:size],
|
108
|
-
settings[:upsample]
|
108
|
+
settings[:upsample]
|
109
109
|
) && !!picture.image_file
|
110
110
|
end
|
111
111
|
|
@@ -124,7 +124,7 @@ module Alchemy
|
|
124
124
|
def thumbnail_zoom_factor(mask)
|
125
125
|
[
|
126
126
|
mask[0].to_f / (image_file_width || 1),
|
127
|
-
mask[1].to_f / (image_file_height || 1)
|
127
|
+
mask[1].to_f / (image_file_height || 1)
|
128
128
|
].max
|
129
129
|
end
|
130
130
|
|
@@ -134,7 +134,7 @@ module Alchemy
|
|
134
134
|
|
135
135
|
[
|
136
136
|
((image_file_width || 0) - default_crop_size[0]) / 2,
|
137
|
-
((image_file_height || 0) - default_crop_size[1]) / 2
|
137
|
+
((image_file_height || 0) - default_crop_size[1]) / 2
|
138
138
|
].map(&:round)
|
139
139
|
end
|
140
140
|
|
@@ -14,7 +14,7 @@ module Alchemy
|
|
14
14
|
# The attributes to be serialized. See ActiveModel::Serialization.
|
15
15
|
# By default, serialize all columns from the AR object.
|
16
16
|
def attributes
|
17
|
-
|
17
|
+
object.class.column_names.map { |c| [c, nil] }.to_h
|
18
18
|
end
|
19
19
|
|
20
20
|
private
|
@@ -3,13 +3,13 @@
|
|
3
3
|
module Alchemy
|
4
4
|
class PageTreeSerializer < BaseSerializer
|
5
5
|
def attributes
|
6
|
-
{
|
6
|
+
{"pages" => nil}
|
7
7
|
end
|
8
8
|
|
9
9
|
def pages
|
10
10
|
tree = []
|
11
|
-
path = [{
|
12
|
-
page_list = object.self_and_descendants.includes(:public_version, {
|
11
|
+
path = [{id: object.parent_id, children: tree}]
|
12
|
+
page_list = object.self_and_descendants.includes(:public_version, {language: :site})
|
13
13
|
base_level = object.level - 1
|
14
14
|
# Load folded pages in advance
|
15
15
|
folded_user_pages = FoldedPage.folded_for_user(opts[:user]).pluck(:page_id)
|
@@ -61,7 +61,7 @@ module Alchemy
|
|
61
61
|
level: level,
|
62
62
|
root: page.root?,
|
63
63
|
root_or_leaf: page.root? || page.leaf?,
|
64
|
-
children: []
|
64
|
+
children: []
|
65
65
|
}
|
66
66
|
|
67
67
|
if opts[:elements]
|
@@ -75,7 +75,7 @@ module Alchemy
|
|
75
75
|
locked: page.locked?,
|
76
76
|
locked_notice: page.locked? ? Alchemy.t("This page is locked", name: page.locker_name) : nil,
|
77
77
|
permissions: page_permissions(page, opts[:ability]),
|
78
|
-
status_titles: page_status_titles(page)
|
78
|
+
status_titles: page_status_titles(page)
|
79
79
|
})
|
80
80
|
else
|
81
81
|
p_hash
|
@@ -98,14 +98,14 @@ module Alchemy
|
|
98
98
|
copy: ability.can?(:copy, page),
|
99
99
|
destroy: ability.can?(:destroy, page),
|
100
100
|
create: ability.can?(:create, Alchemy::Page),
|
101
|
-
edit_content: ability.can?(:edit_content, page)
|
101
|
+
edit_content: ability.can?(:edit_content, page)
|
102
102
|
}
|
103
103
|
end
|
104
104
|
|
105
105
|
def page_status_titles(page)
|
106
106
|
{
|
107
107
|
public: page.status_title(:public),
|
108
|
-
restricted: page.status_title(:restricted)
|
108
|
+
restricted: page.status_title(:restricted)
|
109
109
|
}
|
110
110
|
end
|
111
111
|
end
|
@@ -10,7 +10,7 @@ module Alchemy
|
|
10
10
|
"id",
|
11
11
|
"folded",
|
12
12
|
"updated_at",
|
13
|
-
"updater_id"
|
13
|
+
"updater_id"
|
14
14
|
].freeze
|
15
15
|
|
16
16
|
attr_reader :source_element, :repository
|
@@ -27,7 +27,7 @@ module Alchemy
|
|
27
27
|
.merge(
|
28
28
|
autogenerate_ingredients: false,
|
29
29
|
autogenerate_nested_elements: false,
|
30
|
-
tags: source_element.tags
|
30
|
+
tags: source_element.tags
|
31
31
|
)
|
32
32
|
|
33
33
|
new_element = Element.new(attributes)
|
@@ -40,7 +40,7 @@ module Alchemy
|
|
40
40
|
self.class.new(nested_element, repository: repository).call(
|
41
41
|
parent_element: new_element,
|
42
42
|
page_version: new_element.page_version,
|
43
|
-
position: position
|
43
|
+
position: position
|
44
44
|
)
|
45
45
|
end
|
46
46
|
end
|
@@ -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,
|
@@ -138,9 +138,6 @@
|
|
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
143
|
<meta name="turbolinks-cache-control" content="no-cache">
|
@@ -18,10 +18,16 @@
|
|
18
18
|
<% else -%>
|
19
19
|
|
20
20
|
if (page) {
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
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 {
|
@@ -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.
|
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 %>
|
@@ -1,14 +1 @@
|
|
1
|
-
|
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
|
-
<%=
|
1
|
+
<%= render boolean_view.as_view_component -%>
|
@@ -1,9 +1,3 @@
|
|
1
|
-
|
2
|
-
local_assigns.
|
3
|
-
|
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
|
-
|
2
|
-
|
3
|
-
|
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
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
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
|
-
<%=
|
1
|
+
<%= render html_view.as_view_component -%>
|
@@ -1,9 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
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.
|
1
|
+
<%= render node_view.as_view_component -%>
|
@@ -1,5 +1,4 @@
|
|
1
|
-
<%=
|
2
|
-
|
3
|
-
local_assigns
|
4
|
-
|
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:
|
9
|
-
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
|
-
|
2
|
-
|
3
|
-
|
1
|
+
<%= render richtext_view.as_view_component(
|
2
|
+
**local_assigns.slice(:options)
|
3
|
+
) -%>
|
@@ -1 +1 @@
|
|
1
|
-
<%= select_view.
|
1
|
+
<%= render select_view.as_view_component -%>
|
@@ -1,20 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
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
|
-
|
2
|
-
|
3
|
-
|
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>
|
@@ -25,21 +25,19 @@
|
|
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.
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
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
36
|
<%= javascript_include_tag('alchemy/admin/all', 'data-turbolinks-track' => true) %>
|
39
37
|
<% if respond_to?(:javascript_pack_tag) %>
|
40
|
-
<%= javascript_pack_tag('alchemy/admin', 'data-turbolinks-track' => true
|
38
|
+
<%= javascript_pack_tag('alchemy/admin', 'data-turbolinks-track' => true) %>
|
41
39
|
<% else %>
|
42
|
-
<%= javascript_include_tag('alchemy_admin', 'data-turbolinks-track' => true
|
40
|
+
<%= javascript_include_tag('alchemy_admin', 'data-turbolinks-track' => true) %>
|
43
41
|
<% end %>
|
44
42
|
<%= yield :javascript_includes %>
|
45
43
|
</head>
|
data/bin/setup
ADDED
@@ -0,0 +1,37 @@
|
|
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
|
+
puts "\n== Linking Admin JS package =="
|
16
|
+
system! "yarn link"
|
17
|
+
puts "== Installing dependencies =="
|
18
|
+
system! "yarn install"
|
19
|
+
system! "gem install bundler --conservative"
|
20
|
+
system("bundle check") || system!("bundle install")
|
21
|
+
end
|
22
|
+
|
23
|
+
FileUtils.chdir APP_ROOT do
|
24
|
+
puts "\n== Installing Alchemy into dummy app =="
|
25
|
+
system!("bin/rails javascript:install:esbuild")
|
26
|
+
system!("bin/rails g alchemy:install --skip --skip-demo-files --auto-accept")
|
27
|
+
|
28
|
+
puts "\n== Link Alchemy admin package =="
|
29
|
+
system! "yarn link @alchemy_cms/admin"
|
30
|
+
system! "yarn install"
|
31
|
+
|
32
|
+
puts "\n== Removing old logs and tempfiles =="
|
33
|
+
system! "bin/rails log:clear tmp:clear"
|
34
|
+
end
|
35
|
+
|
36
|
+
puts "\n== Alchemy is ready 🎉 =="
|
37
|
+
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/dev"
|
17
|
+
end
|