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,5 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Alchemy
|
2
4
|
class PagesController < Alchemy::BaseController
|
5
|
+
SHOW_PAGE_PARAMS_KEYS = [
|
6
|
+
'action',
|
7
|
+
'controller',
|
8
|
+
'urlname',
|
9
|
+
'locale'
|
10
|
+
]
|
11
|
+
|
3
12
|
include OnPageLayout::CallbacksRunner
|
4
13
|
|
5
14
|
# Redirecting concerns. Order is important here!
|
@@ -124,8 +133,8 @@ module Alchemy
|
|
124
133
|
# * locale
|
125
134
|
#
|
126
135
|
def additional_params
|
127
|
-
params.
|
128
|
-
|
136
|
+
params.to_unsafe_hash.delete_if do |key, _|
|
137
|
+
SHOW_PAGE_PARAMS_KEYS.include?(key)
|
129
138
|
end
|
130
139
|
end
|
131
140
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Alchemy
|
2
4
|
module Admin
|
3
5
|
# This module contains helper methods for rendering dialogs, toolbar buttons and confirmation windows.
|
@@ -378,34 +380,6 @@ module Alchemy
|
|
378
380
|
method.to_sym, {type: "text", class: type, "data-datepicker-type" => type, value: value}.merge(html_options)
|
379
381
|
end
|
380
382
|
|
381
|
-
# Merges the params-hash with the given hash
|
382
|
-
def merge_params(p = {})
|
383
|
-
params.merge(p).delete_if { |_k, v| v.blank? }
|
384
|
-
end
|
385
|
-
|
386
|
-
# Deletes one or several params from the params-hash and merges some new params in
|
387
|
-
def merge_params_without(excludes, p = {})
|
388
|
-
current_params = params.clone.symbolize_keys
|
389
|
-
if excludes.is_a?(Array)
|
390
|
-
excludes.map { |i| current_params.delete(i.to_sym) }
|
391
|
-
else
|
392
|
-
current_params.delete(excludes.to_sym)
|
393
|
-
end
|
394
|
-
current_params.merge(p).delete_if { |_k, v| v.blank? }
|
395
|
-
end
|
396
|
-
|
397
|
-
# Deletes all params from the params-hash except the given ones and merges some new params in
|
398
|
-
def merge_params_only(includes, p = {})
|
399
|
-
current_params = params.clone.symbolize_keys
|
400
|
-
if includes.is_a?(Array)
|
401
|
-
symbolized_includes = includes.map(&:to_sym)
|
402
|
-
current_params.delete_if { |k, _v| !symbolized_includes.include?(k) }
|
403
|
-
else
|
404
|
-
current_params.delete_if { |k, _v| k != includes.to_sym }
|
405
|
-
end
|
406
|
-
current_params.merge(p).delete_if { |_k, v| v.blank? }
|
407
|
-
end
|
408
|
-
|
409
383
|
# Render a hint icon with tooltip for given object.
|
410
384
|
# The model class needs to include the hints module
|
411
385
|
def render_hint_for(element)
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Alchemy
|
2
4
|
module Admin
|
3
5
|
module TagsHelper
|
@@ -11,102 +13,48 @@ module Alchemy
|
|
11
13
|
#
|
12
14
|
def render_tag_list(class_name)
|
13
15
|
raise ArgumentError, 'Please provide a String as class_name' if class_name.nil?
|
14
|
-
|
15
|
-
|
16
|
-
tags = filtered_by_tag?(tag) ? tag_filter(remove: tag) : tag_filter(add: tag)
|
17
|
-
li_s << content_tag('li', name: tag.name, class: tag_list_tag_active?(tag) ? 'active' : nil) do
|
16
|
+
sorted_tags_from(class_name: class_name).map do |tag|
|
17
|
+
content_tag('li', name: tag.name, class: filtered_by_tag?(tag) ? 'active' : nil) do
|
18
18
|
link_to(
|
19
19
|
"#{tag.name} (#{tag.count})",
|
20
20
|
url_for(
|
21
|
-
|
22
|
-
|
23
|
-
tagged_with: tags
|
21
|
+
search_filter_params.except(:page, :tagged_with).merge(
|
22
|
+
tagged_with: tags_for_filter(current: tag).presence
|
24
23
|
)
|
25
24
|
),
|
26
25
|
remote: request.xhr?,
|
27
26
|
class: 'please_wait'
|
28
27
|
)
|
29
28
|
end
|
30
|
-
end
|
31
|
-
li_s.join.html_safe
|
29
|
+
end.join.html_safe
|
32
30
|
end
|
33
31
|
|
34
|
-
# Returns true if the given tag is in +params[:
|
35
|
-
#
|
36
|
-
# @param tag [ActsAsTaggableOn::Tag]
|
37
|
-
# the tag
|
38
|
-
# @param params [Hash]
|
39
|
-
# url params
|
40
|
-
# @return [Boolean]
|
32
|
+
# Returns true if the given tag is in +params[:tagged_with]+
|
41
33
|
#
|
42
|
-
def tag_list_tag_active?(tag)
|
43
|
-
tag_list_params[:tagged_with].to_s.split(',').include?(tag.name)
|
44
|
-
end
|
45
|
-
|
46
|
-
# Checks if the tagged_with param contains the given tag
|
47
34
|
def filtered_by_tag?(tag)
|
48
|
-
|
49
|
-
tags = tag_list_params[:tagged_with].split(',')
|
50
|
-
tags.include?(tag.name)
|
51
|
-
else
|
52
|
-
false
|
53
|
-
end
|
35
|
+
tags_from_params.include?(tag.name)
|
54
36
|
end
|
55
37
|
|
56
|
-
#
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
# Removes the given tag from the tag filter.
|
67
|
-
def remove_from_tag_filter(tag)
|
68
|
-
if tag_list_params[:tagged_with].present?
|
69
|
-
tags = tag_list_params[:tagged_with].split(',')
|
70
|
-
tags.delete_if { |t| t == tag.name }
|
38
|
+
# Returns the tags from params suitable for the tags filter.
|
39
|
+
#
|
40
|
+
# @param current [ActsAsTaggableOn::Tag] - The current tag that will be added or removed if already present
|
41
|
+
# @returns [String]
|
42
|
+
def tags_for_filter(current:)
|
43
|
+
if filtered_by_tag?(current)
|
44
|
+
tags_from_params - Array(current.name)
|
71
45
|
else
|
72
|
-
|
73
|
-
end
|
46
|
+
tags_from_params.push(current.name)
|
47
|
+
end.uniq.join(',')
|
74
48
|
end
|
75
49
|
|
76
|
-
# Returns
|
77
|
-
#
|
78
|
-
|
79
|
-
|
80
|
-
#
|
81
|
-
# Options are:
|
82
|
-
# * options (Hash):
|
83
|
-
# ** :add (ActsAsTaggableOn::Tag) - The tag that should be added to the tag-filter
|
84
|
-
# ** :remove (ActsAsTaggableOn::Tag) - The tag that should be removed from the tag-filter
|
85
|
-
#
|
86
|
-
def tag_filter(options = {})
|
87
|
-
if options[:add]
|
88
|
-
taglist = add_to_tag_filter(options[:add])
|
89
|
-
elsif options[:remove]
|
90
|
-
taglist = remove_from_tag_filter(options[:remove])
|
91
|
-
else
|
92
|
-
return tag_list_params[:tagged_with]
|
93
|
-
end
|
94
|
-
return nil if taglist.blank?
|
95
|
-
taglist.uniq.join(',')
|
50
|
+
# Returns tags from params
|
51
|
+
# @returns [Array]
|
52
|
+
def tags_from_params
|
53
|
+
search_filter_params[:tagged_with].to_s.split(',')
|
96
54
|
end
|
97
55
|
|
98
|
-
def
|
99
|
-
|
100
|
-
:controller,
|
101
|
-
:content_id,
|
102
|
-
:element_id,
|
103
|
-
:options,
|
104
|
-
:swap,
|
105
|
-
:use_route,
|
106
|
-
:tagged_with,
|
107
|
-
:filter,
|
108
|
-
q: params.fetch(:q, {}).keys
|
109
|
-
)
|
56
|
+
def sorted_tags_from(class_name:)
|
57
|
+
class_name.constantize.tag_counts.sort { |x, y| x.name.downcase <=> y.name.downcase }
|
110
58
|
end
|
111
59
|
end
|
112
60
|
end
|
data/app/models/alchemy.rb
CHANGED
@@ -1,18 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# == Schema Information
|
2
4
|
#
|
3
5
|
# Table name: alchemy_attachments
|
4
6
|
#
|
5
7
|
# id :integer not null, primary key
|
6
|
-
# name :string
|
7
|
-
# file_name :string
|
8
|
-
# file_mime_type :string
|
8
|
+
# name :string
|
9
|
+
# file_name :string
|
10
|
+
# file_mime_type :string
|
9
11
|
# file_size :integer
|
10
12
|
# creator_id :integer
|
11
13
|
# updater_id :integer
|
12
14
|
# created_at :datetime not null
|
13
15
|
# updated_at :datetime not null
|
14
16
|
# cached_tag_list :text
|
15
|
-
# file_uid :string
|
17
|
+
# file_uid :string
|
16
18
|
#
|
17
19
|
|
18
20
|
module Alchemy
|
data/app/models/alchemy/cell.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# == Schema Information
|
2
4
|
#
|
3
5
|
# Table name: alchemy_cells
|
4
6
|
#
|
5
7
|
# id :integer not null, primary key
|
6
|
-
# page_id :integer
|
7
|
-
# name :string
|
8
|
+
# page_id :integer not null
|
9
|
+
# name :string
|
8
10
|
# created_at :datetime not null
|
9
11
|
# updated_at :datetime not null
|
10
12
|
#
|
@@ -1,12 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# == Schema Information
|
2
4
|
#
|
3
5
|
# Table name: alchemy_contents
|
4
6
|
#
|
5
7
|
# id :integer not null, primary key
|
6
|
-
# name :string
|
7
|
-
# essence_type :string
|
8
|
-
# essence_id :integer
|
9
|
-
# element_id :integer
|
8
|
+
# name :string
|
9
|
+
# essence_type :string not null
|
10
|
+
# essence_id :integer not null
|
11
|
+
# element_id :integer not null
|
10
12
|
# position :integer
|
11
13
|
# created_at :datetime not null
|
12
14
|
# updated_at :datetime not null
|
@@ -105,7 +107,7 @@ module Alchemy
|
|
105
107
|
# Settings from the elements.yml definition
|
106
108
|
def settings
|
107
109
|
return {} if definition.blank?
|
108
|
-
@settings ||= definition.fetch(
|
110
|
+
@settings ||= definition.fetch(:settings, {})
|
109
111
|
end
|
110
112
|
|
111
113
|
# Fetches value from settings
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Alchemy
|
2
4
|
# Holds everything concerning the building and creating of contents and the related essence object.
|
3
5
|
#
|
@@ -31,9 +33,8 @@ module Alchemy
|
|
31
33
|
# @return [Alchemy::Content]
|
32
34
|
#
|
33
35
|
def create_from_scratch(element, essence_hash)
|
34
|
-
essence_hash.stringify_keys!
|
35
36
|
if content = build(element, essence_hash)
|
36
|
-
content.create_essence!(essence_hash[
|
37
|
+
content.create_essence!(essence_hash[:essence_type])
|
37
38
|
end
|
38
39
|
content
|
39
40
|
end
|
@@ -49,7 +50,7 @@ module Alchemy
|
|
49
50
|
#
|
50
51
|
def copy(source, differences = {})
|
51
52
|
new_content = Content.new(
|
52
|
-
source.attributes.except(*SKIPPED_ATTRIBUTES_ON_COPY).merge(differences
|
53
|
+
source.attributes.except(*SKIPPED_ATTRIBUTES_ON_COPY).merge(differences)
|
53
54
|
)
|
54
55
|
|
55
56
|
new_essence = new_content.essence.class.create!(
|
@@ -66,12 +67,11 @@ module Alchemy
|
|
66
67
|
# 2. It builds a definition hash from essence type, if the the name key is not present
|
67
68
|
#
|
68
69
|
def content_definition(element, essence_hash)
|
69
|
-
essence_hash.stringify_keys!
|
70
70
|
# No name given. We build the content from essence type.
|
71
|
-
if essence_hash[
|
72
|
-
content_definition_from_essence_type(element, essence_hash[
|
71
|
+
if essence_hash[:name].blank? && essence_hash[:essence_type].present?
|
72
|
+
content_definition_from_essence_type(element, essence_hash[:essence_type])
|
73
73
|
else
|
74
|
-
element.content_definition_for(essence_hash[
|
74
|
+
element.content_definition_for(essence_hash[:name])
|
75
75
|
end
|
76
76
|
end
|
77
77
|
|