alchemy_cms 2.6.3 → 2.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.simplecov +14 -0
- data/.travis.yml +1 -1
- data/Gemfile +7 -6
- data/README.md +15 -5
- data/alchemy_cms.gemspec +3 -2
- data/app/assets/javascripts/alchemy/alchemy.base.js.coffee +9 -17
- data/app/assets/javascripts/alchemy/alchemy.dirty.js.coffee +70 -0
- data/app/assets/javascripts/alchemy/alchemy.dragndrop.js.coffee +80 -0
- data/app/assets/javascripts/alchemy/alchemy.element_editors.js.coffee +43 -19
- data/app/assets/javascripts/alchemy/alchemy.gui.js.coffee +3 -1
- data/app/assets/javascripts/alchemy/alchemy.js +4 -2
- data/app/assets/javascripts/alchemy/alchemy.onload.js.coffee +1 -1
- data/app/assets/javascripts/alchemy/alchemy.spinner.js.coffee +14 -0
- data/app/assets/javascripts/alchemy/alchemy.tinymce.js.coffee.erb +96 -0
- data/app/assets/javascripts/alchemy/alchemy.translations.js.coffee +22 -0
- data/app/assets/javascripts/alchemy/alchemy.windows.js.coffee +28 -17
- data/app/assets/stylesheets/alchemy/base.scss +6 -0
- data/app/assets/stylesheets/alchemy/elements.scss +2 -28
- data/app/assets/stylesheets/alchemy/errors.scss +1 -1
- data/app/assets/stylesheets/alchemy/menubar.css.scss +2 -0
- data/app/assets/stylesheets/alchemy/sitemap.scss +21 -34
- data/app/assets/stylesheets/alchemy/tables.scss +13 -3
- data/app/controllers/alchemy/admin/attachments_controller.rb +10 -5
- data/app/controllers/alchemy/admin/base_controller.rb +19 -0
- data/app/controllers/alchemy/admin/contents_controller.rb +1 -4
- data/app/controllers/alchemy/admin/dashboard_controller.rb +2 -1
- data/app/controllers/alchemy/admin/elements_controller.rb +1 -1
- data/app/controllers/alchemy/admin/essence_files_controller.rb +1 -1
- data/app/controllers/alchemy/admin/essence_pictures_controller.rb +70 -56
- data/app/controllers/alchemy/admin/pages_controller.rb +37 -114
- data/app/controllers/alchemy/admin/pictures_controller.rb +5 -12
- data/app/controllers/alchemy/admin/resources_controller.rb +3 -1
- data/app/controllers/alchemy/admin/trash_controller.rb +1 -1
- data/app/controllers/alchemy/attachments_controller.rb +1 -1
- data/app/controllers/alchemy/base_controller.rb +3 -15
- data/app/controllers/alchemy/messages_controller.rb +4 -10
- data/app/controllers/alchemy/pages_controller.rb +6 -6
- data/app/controllers/alchemy/passwords_controller.rb +1 -1
- data/app/controllers/alchemy/user_sessions_controller.rb +1 -1
- data/app/helpers/alchemy/admin/base_helper.rb +49 -230
- data/app/helpers/alchemy/admin/contents_helper.rb +5 -1
- data/app/helpers/alchemy/admin/elements_helper.rb +19 -47
- data/app/helpers/alchemy/admin/essences_helper.rb +59 -17
- data/app/helpers/alchemy/admin/navigation_helper.rb +204 -0
- data/app/helpers/alchemy/admin/pages_helper.rb +22 -79
- data/app/helpers/alchemy/admin/pictures_helper.rb +1 -1
- data/app/helpers/alchemy/admin/tags_helper.rb +42 -0
- data/app/helpers/alchemy/base_helper.rb +0 -11
- data/app/helpers/alchemy/elements_helper.rb +48 -25
- data/app/helpers/alchemy/essences_helper.rb +0 -20
- data/app/helpers/alchemy/pages_helper.rb +18 -14
- data/app/helpers/alchemy/url_helper.rb +1 -0
- data/app/mailers/alchemy/messages.rb +4 -6
- data/app/models/alchemy/attachment.rb +3 -0
- data/app/models/alchemy/cell.rb +33 -35
- data/app/models/alchemy/content.rb +20 -111
- data/app/models/alchemy/content/factory.rb +188 -0
- data/app/models/alchemy/element.rb +51 -200
- data/app/models/alchemy/element/definitions.rb +52 -0
- data/app/models/alchemy/element/presenters.rb +87 -0
- data/app/models/alchemy/essence_date.rb +1 -1
- data/app/models/alchemy/essence_file.rb +6 -7
- data/app/models/alchemy/essence_picture.rb +19 -4
- data/app/models/alchemy/message.rb +18 -14
- data/app/models/alchemy/page.rb +120 -214
- data/app/models/alchemy/page/elements.rb +145 -36
- data/app/models/alchemy/page/natures.rb +90 -0
- data/app/models/alchemy/page/scopes.rb +93 -0
- data/app/models/alchemy/page/users.rb +25 -0
- data/app/models/alchemy/picture.rb +15 -0
- data/app/models/alchemy/site.rb +15 -1
- data/app/models/alchemy/site/layout.rb +38 -0
- data/app/models/alchemy/user.rb +13 -3
- data/app/views/alchemy/admin/attachments/_archive_overlay.html.erb +7 -7
- data/app/views/alchemy/admin/attachments/_file_to_assign.html.erb +8 -8
- data/app/views/alchemy/admin/attachments/_tag_list.html.erb +1 -16
- data/app/views/alchemy/admin/attachments/destroy.js.erb +1 -4
- data/app/views/alchemy/admin/contents/create.js.erb +1 -1
- data/app/views/alchemy/admin/dashboard/index.html.erb +14 -13
- data/app/views/alchemy/admin/elements/_element_head.html.erb +7 -7
- data/app/views/alchemy/admin/elements/_refresh_editor.js.erb +10 -0
- data/app/views/alchemy/admin/elements/create.js.erb +44 -44
- data/app/views/alchemy/admin/elements/fold.js.erb +22 -26
- data/app/views/alchemy/admin/elements/trash.js.erb +1 -1
- data/app/views/alchemy/admin/elements/update.js.erb +22 -25
- data/app/views/alchemy/admin/essence_files/assign.js.erb +8 -3
- data/app/views/alchemy/admin/essence_pictures/crop.html.erb +14 -12
- data/app/views/alchemy/admin/essence_pictures/edit.html.erb +22 -39
- data/app/views/alchemy/admin/pages/_page.html.erb +73 -80
- data/app/views/alchemy/admin/pages/destroy.js.erb +2 -2
- data/app/views/alchemy/admin/pages/edit.html.erb +21 -18
- data/app/views/alchemy/admin/pages/fold.js.erb +1 -0
- data/app/views/alchemy/admin/pages/info.html.erb +32 -0
- data/app/views/alchemy/admin/partials/_main_navigation_entry.html.erb +11 -13
- data/app/views/alchemy/admin/partials/_remote_search_form.html.erb +20 -20
- data/app/views/alchemy/admin/partials/_sub_navigation.html.erb +8 -0
- data/app/views/alchemy/admin/partials/_toolbar_button.html.erb +25 -0
- data/app/views/alchemy/admin/partials/_upload_form.html.erb +15 -15
- data/app/views/alchemy/admin/pictures/_filter_and_size_bar.html.erb +39 -39
- data/app/views/alchemy/admin/pictures/_picture_to_assign.html.erb +10 -10
- data/app/views/alchemy/admin/pictures/_tag_list.html.erb +1 -16
- data/app/views/alchemy/admin/resources/destroy.js.erb +1 -1
- data/app/views/alchemy/base/500.html.erb +1 -1
- data/app/views/alchemy/base/permission_denied.js.erb +1 -1
- data/app/views/alchemy/base/redirect.js.erb +1 -1
- data/app/views/alchemy/essences/_essence_link_editor.html.erb +1 -1
- data/app/views/alchemy/essences/_essence_picture_editor.html.erb +1 -1
- data/app/views/alchemy/essences/_essence_richtext_editor.html.erb +1 -1
- data/app/views/alchemy/essences/_essence_text_editor.html.erb +1 -1
- data/app/views/alchemy/essences/{_essence_picture_tools.html.erb → shared/_essence_picture_tools.html.erb} +5 -5
- data/app/views/alchemy/essences/{_linkable_essence_tools.html.erb → shared/_linkable_essence_tools.html.erb} +0 -0
- data/app/views/alchemy/messages/contact_form_mail.de.text.erb +12 -0
- data/app/views/alchemy/messages/contact_form_mail.en.text.erb +12 -0
- data/app/views/alchemy/notifications/reset_password_instructions.de.text.erb +1 -1
- data/app/views/alchemy/notifications/reset_password_instructions.en.text.erb +2 -2
- data/app/views/alchemy/pages/sitemap.xml.erb +3 -5
- data/app/views/alchemy/user_sessions/leave.html.erb +1 -1
- data/app/views/layouts/alchemy/admin.html.erb +4 -2
- data/app/views/layouts/alchemy/sitemap.xml.erb +1 -1
- data/bin/alchemy +7 -13
- data/config/alchemy/config.yml +1 -0
- data/config/authorization_rules.rb +2 -3
- data/config/initializers/dragonfly.rb +2 -0
- data/config/locales/alchemy.de.yml +8 -9
- data/config/locales/alchemy.en.yml +7 -4
- data/config/routes.rb +3 -0
- data/db/migrate/{20130214233001_alchemy_two_point_five.rb → 20130827094554_alchemy_two_point_six.rb} +29 -6
- data/lib/alchemy/auth/engine.rb +9 -0
- data/lib/alchemy/capistrano.rb +37 -12
- data/lib/alchemy/config.rb +48 -35
- data/lib/alchemy/engine.rb +35 -6
- data/lib/alchemy/essence.rb +25 -29
- data/lib/alchemy/ferret/search.rb +86 -0
- data/lib/alchemy/{scoped_pagination_url_helper.rb → kaminari/scoped_pagination_url_helper.rb} +0 -0
- data/lib/alchemy/logger.rb +3 -4
- data/lib/alchemy/page_layout.rb +124 -55
- data/lib/alchemy/resource.rb +0 -10
- data/lib/alchemy/resources_helper.rb +0 -5
- data/lib/alchemy/seeder.rb +1 -32
- data/lib/alchemy/shell.rb +6 -1
- data/lib/alchemy/tinymce.rb +41 -32
- data/lib/alchemy/upgrader.rb +3 -1
- data/lib/alchemy/upgrader/two_point_five.rb +15 -8
- data/lib/alchemy/upgrader/two_point_one.rb +10 -10
- data/lib/alchemy/upgrader/two_point_two.rb +96 -51
- data/lib/alchemy/version.rb +1 -1
- data/lib/alchemy_cms.rb +5 -46
- data/lib/rails/generators/alchemy/deploy_script/templates/deploy.rb.tt +1 -1
- data/lib/rails/generators/alchemy/devise/devise_generator.rb +9 -4
- data/lib/rails/generators/alchemy/essence/essence_generator.rb +7 -6
- data/lib/rails/generators/alchemy/essence/templates/editor.html.erb +1 -1
- data/lib/rails/generators/alchemy/scaffold/files/_standard.html.erb +1 -0
- data/lib/rails/generators/alchemy/scaffold/scaffold_generator.rb +1 -0
- data/lib/rails/generators/alchemy/site_layouts/site_layouts_generator.rb +23 -0
- data/lib/rails/generators/alchemy/site_layouts/templates/layout.html.erb +1 -0
- data/lib/rails/generators/alchemy/site_layouts/templates/layout.html.haml +1 -0
- data/lib/rails/generators/alchemy/site_layouts/templates/layout.html.slim +1 -0
- data/lib/rails/templates/alchemy.rb +2 -2
- data/lib/tasks/alchemy/db.rake +3 -1
- data/lib/tasks/alchemy/tidy.rake +82 -0
- data/lib/tasks/alchemy/upgrade.rake +2 -1
- data/spec/controllers/admin/attachments_controller_spec.rb +124 -0
- data/spec/controllers/admin/base_controller_spec.rb +35 -0
- data/spec/controllers/admin/clipboard_controller_spec.rb +1 -1
- data/spec/controllers/admin/contents_controller_spec.rb +17 -26
- data/spec/controllers/admin/dashboard_controller_spec.rb +121 -0
- data/spec/controllers/admin/elements_controller_spec.rb +1 -1
- data/spec/controllers/admin/essence_files_controller_spec.rb +67 -0
- data/spec/controllers/admin/essence_pictures_controller_spec.rb +161 -0
- data/spec/controllers/admin/languages_controller_spec.rb +1 -1
- data/spec/controllers/admin/layoutpages_controller_spec.rb +28 -0
- data/spec/controllers/admin/pages_controller_spec.rb +164 -118
- data/spec/controllers/admin/pictures_controller_spec.rb +89 -0
- data/spec/controllers/admin/trash_controller_spec.rb +21 -31
- data/spec/controllers/admin/users_controller_spec.rb +114 -85
- data/spec/controllers/attachments_controller_spec.rb +6 -2
- data/spec/controllers/base_controller_spec.rb +22 -0
- data/spec/controllers/elements_controller_spec.rb +1 -1
- data/spec/controllers/messages_controller_spec.rb +200 -0
- data/spec/controllers/pictures_controller_spec.rb +1 -1
- data/spec/controllers/user_sessions_controller_spec.rb +7 -6
- data/spec/controllers/users_controller_spec.rb +2 -2
- data/spec/dummy/config/alchemy/cells.yml +2 -0
- data/spec/dummy/config/application.rb +19 -8
- data/spec/dummy/db/migrate/{20130214233001_alchemy_two_point_five.rb → 20130827094554_alchemy_two_point_six.rb} +29 -6
- data/spec/dummy/db/schema.rb +1 -1
- data/spec/fast_specs.rb +15 -0
- data/spec/helpers/admin/base_helper_spec.rb +53 -34
- data/spec/helpers/admin/contents_helper_spec.rb +15 -7
- data/spec/helpers/admin/elements_helper_spec.rb +79 -34
- data/spec/helpers/admin/essences_helper_spec.rb +45 -31
- data/spec/helpers/admin/navigation_helper_spec.rb +204 -0
- data/spec/helpers/admin/pages_helper_spec.rb +25 -15
- data/spec/helpers/admin/tags_helper_spec.rb +62 -2
- data/spec/helpers/elements_helper_spec.rb +202 -138
- data/spec/helpers/pages_helper_spec.rb +48 -0
- data/spec/helpers/url_helper_spec.rb +7 -0
- data/spec/libraries/config_spec.rb +110 -3
- data/spec/libraries/essence_spec.rb +29 -9
- data/spec/libraries/page_layout_spec.rb +134 -0
- data/spec/libraries/resource_spec.rb +3 -16
- data/spec/libraries/resources_helper_spec.rb +4 -8
- data/spec/libraries/shell_spec.rb +1 -0
- data/spec/libraries/tinymce_spec.rb +61 -0
- data/spec/mailers/messages_spec.rb +23 -0
- data/spec/models/attachment_spec.rb +45 -0
- data/spec/models/cell_spec.rb +62 -9
- data/spec/models/content_spec.rb +110 -28
- data/spec/models/element_spec.rb +275 -253
- data/spec/models/essence_date_spec.rb +25 -0
- data/spec/models/essence_file_spec.rb +23 -0
- data/spec/models/essence_html_spec.rb +13 -0
- data/spec/models/essence_picture_spec.rb +16 -0
- data/spec/models/essence_text_spec.rb +29 -0
- data/spec/models/language_spec.rb +34 -0
- data/spec/models/message_spec.rb +43 -0
- data/spec/models/page_spec.rb +726 -567
- data/spec/models/picture_spec.rb +98 -0
- data/spec/models/site_spec.rb +60 -2
- data/spec/models/tag_spec.rb +31 -0
- data/spec/models/user_spec.rb +4 -4
- data/spec/spec_helper.rb +49 -58
- data/spec/support/alchemy/controller_helpers.rb +35 -0
- data/spec/support/alchemy/{specs_helpers.rb → integration_helpers.rb} +4 -8
- data/spec/{factories.rb → support/factories.rb} +11 -1
- data/vendor/assets/javascripts/jquery_plugins/jquery.ui.nestedSortable.js +2 -8
- metadata +166 -106
- data/Guardfile +0 -16
- data/app/assets/javascripts/alchemy/alchemy.dirty.js +0 -93
- data/app/assets/javascripts/alchemy/alchemy.dragndrop.js +0 -122
- data/app/models/alchemy/tree_node.rb +0 -4
- data/app/views/alchemy/admin/pages/_page_infos.html.erb +0 -3
- data/app/views/alchemy/admin/partials/_sub_navigation_tab.html.erb +0 -8
- data/app/views/alchemy/messages/contact_form_mail.text.erb +0 -12
- data/config/initializers/kaminari_config.rb +0 -9
- data/db/migrate/20130221200514_migrate_attachments_to_dragonfly.rb +0 -21
- data/db/migrate/20130312205327_change_alchemy_users_role_to_roles.rb +0 -11
- data/lib/alchemy/auth_engine.rb +0 -7
- data/lib/alchemy/authentication_helpers.rb +0 -9
- data/lib/alchemy/ferret_search.rb +0 -84
- data/lib/extensions/array.rb +0 -25
- data/lib/extensions/hash.rb +0 -34
- data/spec/dummy/db/migrate/20130221200514_migrate_attachments_to_dragonfly.rb +0 -21
- data/spec/dummy/db/migrate/20130312205327_change_alchemy_users_role_to_roles.rb +0 -11
- data/spec/models/page_layout_spec.rb +0 -60
data/lib/alchemy/resource.rb
CHANGED
@@ -94,11 +94,6 @@ module Alchemy
|
|
94
94
|
@_resource_name ||= resources_name.singularize
|
95
95
|
end
|
96
96
|
|
97
|
-
def model_name
|
98
|
-
ActiveSupport::Deprecation.warn("model_name is deprecated. Please use resource_name instead!")
|
99
|
-
resource_name
|
100
|
-
end
|
101
|
-
|
102
97
|
def namespaced_resource_name
|
103
98
|
return @_namespaced_resource_name unless @_namespaced_resource_name.nil?
|
104
99
|
resource_name_array = resource_array
|
@@ -106,11 +101,6 @@ module Alchemy
|
|
106
101
|
@_namespaced_resource_name = resource_name_array.join('_').singularize
|
107
102
|
end
|
108
103
|
|
109
|
-
def namespaced_model_name
|
110
|
-
ActiveSupport::Deprecation.warn("namespaced_model_name is deprecated. Please use namespaced_resource_name instead!")
|
111
|
-
namespaced_resource_name
|
112
|
-
end
|
113
|
-
|
114
104
|
def permission_scope
|
115
105
|
#(resource_namespaced? ? "#{resource_namespace.underscore}_admin_#{resources_name}" : "admin_#{resources_name}").to_sym
|
116
106
|
@_permission = @controller_path.gsub('/', '_').to_sym
|
@@ -52,11 +52,6 @@ module Alchemy
|
|
52
52
|
resource_handler.permission_scope
|
53
53
|
end
|
54
54
|
|
55
|
-
def resource_model_name
|
56
|
-
ActiveSupport::Deprecation.warn("resource_model_name is deprecated. Please use resource_name instead!")
|
57
|
-
resource_handler.resource_name
|
58
|
-
end
|
59
|
-
|
60
55
|
def resource_name
|
61
56
|
resource_handler.resource_name
|
62
57
|
end
|
data/lib/alchemy/seeder.rb
CHANGED
@@ -1,8 +1,7 @@
|
|
1
|
-
require "
|
1
|
+
require "alchemy/shell"
|
2
2
|
|
3
3
|
module Alchemy
|
4
4
|
class Seeder
|
5
|
-
|
6
5
|
extend Shell
|
7
6
|
|
8
7
|
class << self
|
@@ -14,36 +13,6 @@ module Alchemy
|
|
14
13
|
create_root_page
|
15
14
|
end
|
16
15
|
|
17
|
-
private
|
18
|
-
|
19
|
-
def desc(message)
|
20
|
-
puts "\n#{message}"
|
21
|
-
puts "#{'-' * message.length}\n"
|
22
|
-
end
|
23
|
-
|
24
|
-
def todo(todo)
|
25
|
-
add_todo todo
|
26
|
-
end
|
27
|
-
|
28
|
-
def add_todo(todo)
|
29
|
-
todos << todo
|
30
|
-
end
|
31
|
-
|
32
|
-
def todos
|
33
|
-
@@todos ||= []
|
34
|
-
end
|
35
|
-
|
36
|
-
def display_todos
|
37
|
-
if todos.length > 0
|
38
|
-
log "\nTODOS:", :message
|
39
|
-
log "------\n", :message
|
40
|
-
todos.each_with_index do |todo, i|
|
41
|
-
log "\n#{i+1}. ", :message
|
42
|
-
log todo, :message
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
16
|
protected
|
48
17
|
|
49
18
|
def create_default_site
|
data/lib/alchemy/shell.rb
CHANGED
@@ -4,10 +4,15 @@ require 'thor/shell/color'
|
|
4
4
|
module Alchemy
|
5
5
|
|
6
6
|
# Provides methods for collecting sentences and displaying them
|
7
|
-
# in a list on the shell / log
|
7
|
+
# in a list on the shell / log
|
8
8
|
#
|
9
9
|
module Shell
|
10
10
|
|
11
|
+
def desc(message)
|
12
|
+
puts "\n#{message}"
|
13
|
+
puts "#{'-' * message.length}\n"
|
14
|
+
end
|
15
|
+
|
11
16
|
def todo(todo)
|
12
17
|
add_todo todo
|
13
18
|
end
|
data/lib/alchemy/tinymce.rb
CHANGED
@@ -1,46 +1,41 @@
|
|
1
1
|
module Alchemy
|
2
2
|
module Tinymce
|
3
|
-
|
4
3
|
mattr_accessor :languages, :themes, :plugins, :setup
|
5
4
|
|
6
5
|
@@setup = nil
|
7
|
-
|
8
6
|
@@plugins = %w(alchemy_link autoresize fullscreen inlinepopups paste table)
|
9
|
-
|
10
7
|
@@languages = ['en', 'de']
|
11
|
-
|
12
8
|
@@themes = ['advanced']
|
13
|
-
|
14
9
|
@@init = {
|
15
|
-
:
|
16
|
-
:
|
17
|
-
:
|
18
|
-
:
|
19
|
-
:
|
20
|
-
:
|
21
|
-
:
|
22
|
-
:
|
23
|
-
:
|
24
|
-
:
|
25
|
-
:
|
26
|
-
:
|
27
|
-
:
|
28
|
-
:
|
29
|
-
:
|
30
|
-
:
|
31
|
-
:
|
32
|
-
:
|
33
|
-
:
|
34
|
-
:
|
35
|
-
:
|
36
|
-
:
|
37
|
-
:
|
38
|
-
:
|
39
|
-
:
|
10
|
+
paste_convert_headers_to_strong: true,
|
11
|
+
paste_convert_middot_lists: true,
|
12
|
+
paste_remove_spans: true,
|
13
|
+
paste_remove_styles: true,
|
14
|
+
paste_strip_class_attributes: true,
|
15
|
+
theme: 'advanced',
|
16
|
+
skin: 'o2k7',
|
17
|
+
skin_variant: 'silver',
|
18
|
+
inlinepopups_skin: 'alchemy-tinymce-dialog',
|
19
|
+
popup_css: "/assets/alchemy/tinymce_dialog.css",
|
20
|
+
content_css: "/assets/alchemy/tinymce_content.css",
|
21
|
+
dialog_type: "modal",
|
22
|
+
width: "100%",
|
23
|
+
theme_advanced_resizing: true,
|
24
|
+
theme_advanced_resize_horizontal: false,
|
25
|
+
theme_advanced_resizing_min_height: '135',
|
26
|
+
theme_advanced_toolbar_align: 'left',
|
27
|
+
theme_advanced_toolbar_location: 'top',
|
28
|
+
theme_advanced_statusbar_location: 'bottom',
|
29
|
+
theme_advanced_buttons1: 'bold,italic,underline,strikethrough,sub,sup,|,numlist,bullist,indent,outdent,|,alchemy_link,unlink,|,removeformat,cleanup,|,fullscreen',
|
30
|
+
theme_advanced_buttons2: 'pastetext,pasteword,charmap,code,help',
|
31
|
+
theme_advanced_buttons3: '',
|
32
|
+
fix_list_elements: true,
|
33
|
+
convert_urls: false,
|
34
|
+
entity_encoding: "raw"
|
40
35
|
}
|
41
36
|
|
42
37
|
def self.init=(settings)
|
43
|
-
@@init
|
38
|
+
@@init.merge!(settings)
|
44
39
|
end
|
45
40
|
|
46
41
|
def self.init
|
@@ -48,7 +43,21 @@ module Alchemy
|
|
48
43
|
end
|
49
44
|
|
50
45
|
def self.custom_config_contents
|
51
|
-
@@custom_config_contents ||=
|
46
|
+
@@custom_config_contents ||= content_definitions_from_elements(Element.definitions)
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.page_custom_config_contents(page)
|
50
|
+
content_definitions_from_elements(page.element_definitions)
|
51
|
+
end
|
52
|
+
|
53
|
+
private
|
54
|
+
|
55
|
+
def self.content_definitions_from_elements(definitions)
|
56
|
+
definitions.collect do |el|
|
57
|
+
contents = el.fetch('contents', []).select { |c| c['settings'] && c['settings']['tinymce'].present? }
|
58
|
+
next if contents.blank?
|
59
|
+
contents.map { |c| c.merge('element' => el['name']) }
|
60
|
+
end.flatten.compact
|
52
61
|
end
|
53
62
|
|
54
63
|
end
|
data/lib/alchemy/upgrader.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'alchemy/seeder'
|
2
|
+
|
1
3
|
module Alchemy
|
2
4
|
class Upgrader < Alchemy::Seeder
|
3
5
|
|
@@ -37,7 +39,7 @@ module Alchemy
|
|
37
39
|
end
|
38
40
|
|
39
41
|
# All available upgrade tasks
|
40
|
-
#
|
42
|
+
#
|
41
43
|
def all_upgrade_tasks
|
42
44
|
private_methods - Object.private_methods - superclass.private_methods
|
43
45
|
end
|
@@ -2,7 +2,7 @@ module Alchemy
|
|
2
2
|
module Upgrader::TwoPointFive
|
3
3
|
|
4
4
|
private
|
5
|
-
|
5
|
+
|
6
6
|
def convert_picture_storage
|
7
7
|
desc "Convert the picture storage"
|
8
8
|
converted_images = []
|
@@ -49,18 +49,25 @@ We changed the authentication provider from Authlogic to Devise.
|
|
49
49
|
|
50
50
|
If you are upgrading from an old Alchemy version < 2.5.0, then you have to make changes to your Devise configuration.
|
51
51
|
|
52
|
-
1.
|
52
|
+
1. Add devise-encryptable to your Gemfile
|
53
|
+
|
54
|
+
# Gemfile
|
55
|
+
gem 'devise-encryptable'
|
56
|
+
|
57
|
+
$ bundle install
|
58
|
+
|
59
|
+
2. Generate devise config:
|
53
60
|
|
54
61
|
$ rails g alchemy:devise
|
55
62
|
|
56
|
-
And alter the encryptor
|
57
|
-
and the stretches value from 10 to 20
|
63
|
+
And alter the encryptor and stretches values
|
58
64
|
|
59
65
|
# config/initializers/devise.rb
|
60
|
-
|
61
|
-
config.
|
66
|
+
...
|
67
|
+
config.stretches = Rails.env.test? ? 1 : 20
|
68
|
+
config.encryptor = :authlogic_sha512
|
62
69
|
|
63
|
-
|
70
|
+
3. Add the encryptable module to your Alchemy config.yml:
|
64
71
|
|
65
72
|
# config/alchemy/config.yml
|
66
73
|
devise_modules:
|
@@ -74,6 +81,6 @@ devise_modules:
|
|
74
81
|
WARN
|
75
82
|
todo warn
|
76
83
|
end
|
77
|
-
|
84
|
+
|
78
85
|
end
|
79
86
|
end
|
@@ -7,18 +7,18 @@ module Alchemy
|
|
7
7
|
# Also creates missing associations between pages and languages
|
8
8
|
def upgrade_to_language
|
9
9
|
desc "Creating languages for pages"
|
10
|
-
Alchemy::Page.
|
11
|
-
if
|
10
|
+
Alchemy::Page.contentpages.each do |page|
|
11
|
+
if page.language_id.nil? && page.language_code.present?
|
12
12
|
root = page.get_language_root
|
13
13
|
lang = Alchemy::Language.find_or_create_by_language_code(
|
14
|
-
:
|
15
|
-
:
|
16
|
-
:
|
17
|
-
:
|
18
|
-
:
|
14
|
+
name: page.language_code.capitalize,
|
15
|
+
language_code: page.language_code,
|
16
|
+
frontpage_name: root.name,
|
17
|
+
page_layout: root.page_layout,
|
18
|
+
public: true
|
19
19
|
)
|
20
20
|
page.language = lang
|
21
|
-
if page.save(:
|
21
|
+
if page.save(validate: false)
|
22
22
|
log "Set language for page #{page.name} to #{lang.name}."
|
23
23
|
end
|
24
24
|
else
|
@@ -34,9 +34,9 @@ module Alchemy
|
|
34
34
|
layoutpages = Alchemy::Page.layoutpages
|
35
35
|
if layoutpages.any?
|
36
36
|
layoutpages.each do |page|
|
37
|
-
if page.
|
37
|
+
if page.language_id.nil?
|
38
38
|
page.language = default_language
|
39
|
-
if page.save(:
|
39
|
+
if page.save(validate: false)
|
40
40
|
log "Set language for page #{page.name} to #{default_language.name}."
|
41
41
|
end
|
42
42
|
else
|
@@ -1,69 +1,114 @@
|
|
1
1
|
module Alchemy
|
2
2
|
module Upgrader::TwoPointTwo
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
if new_content.create_essence!('name' => content.name, 'type' => 'EssenceSelect')
|
18
|
-
new_content.essence.value = content.ingredient
|
19
|
-
if new_content.essence.save
|
20
|
-
contents_found += 1
|
21
|
-
log "Converted #{content.name}'s essence_type into EssenceSelect"
|
22
|
-
content.destroy
|
23
|
-
else
|
24
|
-
log "Could not save essence: #{new_content.essence.errors.full_messages.join(', ')}", :error
|
4
|
+
class ContentsConverter
|
5
|
+
include Alchemy::Shell
|
6
|
+
|
7
|
+
def initialize(display_as, essence_type)
|
8
|
+
@contents_found = 0
|
9
|
+
@display_as = display_as
|
10
|
+
@essence_type = essence_type
|
11
|
+
end
|
12
|
+
|
13
|
+
def convert!
|
14
|
+
if essence_texts.any?
|
15
|
+
essence_texts.each do |content|
|
16
|
+
convert_content(content)
|
25
17
|
end
|
26
18
|
else
|
27
|
-
log "
|
19
|
+
log "No EssenceTexts displayed as #{@display_as} found.", :skip
|
28
20
|
end
|
29
21
|
end
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def essence_texts
|
26
|
+
Alchemy::Content.essence_texts.where(
|
27
|
+
:name => content_names,
|
28
|
+
:alchemy_elements => {:name => elements.collect { |e| e['name'] }}
|
29
|
+
).joins(:element)
|
34
30
|
end
|
35
|
-
end
|
36
31
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
32
|
+
def content_names
|
33
|
+
@content_names ||= contents.collect { |c| c['name'] }
|
34
|
+
end
|
35
|
+
|
36
|
+
def contents
|
37
|
+
@contents ||= elements.collect { |el|
|
38
|
+
el['contents']
|
39
|
+
}.flatten.select { |c|
|
40
|
+
c['settings'] && c['settings']['display_as'] == @display_as
|
41
|
+
}.flatten
|
42
|
+
end
|
43
|
+
|
44
|
+
def elements
|
45
|
+
@elements ||= Alchemy::Element.descriptions.select { |e|
|
46
|
+
e['contents'].present? && !e['contents'].detect { |c|
|
47
|
+
c['settings'].present? && c['settings']['display_as'] == @display_as
|
48
|
+
}.nil?
|
49
|
+
}
|
50
|
+
end
|
51
|
+
|
52
|
+
def convert_content(content)
|
53
|
+
if @new_content = new_content_from(content)
|
54
|
+
update_content(content)
|
57
55
|
else
|
58
56
|
log "Could not create content: #{new_content.errors.full_messages.join(', ')}", :error
|
59
57
|
end
|
60
58
|
end
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
59
|
+
|
60
|
+
def new_content_from(content)
|
61
|
+
content = Alchemy::Content.create(
|
62
|
+
element_id: content.element.id,
|
63
|
+
name: content.name,
|
64
|
+
essence_type: essence_class
|
65
|
+
)
|
66
|
+
content.essence = essence_class.constantize.create
|
67
|
+
content
|
68
|
+
end
|
69
|
+
|
70
|
+
def essence_class
|
71
|
+
"Alchemy::#{@essence_type.classify}"
|
72
|
+
end
|
73
|
+
|
74
|
+
def update_content(content)
|
75
|
+
if update_essence_from(content)
|
76
|
+
@contents_found += 1
|
77
|
+
content.destroy
|
78
|
+
log "Converted #{content.name}'s essence_type into #{@essence_type}"
|
79
|
+
else
|
80
|
+
log "Could not save essence: #{new_content.essence.errors.full_messages.join(', ')}", :error
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def update_essence_from(content)
|
85
|
+
@new_content.essence.ingredient = content.ingredient
|
86
|
+
@new_content.essence.save!
|
87
|
+
end
|
88
|
+
|
89
|
+
def display_result
|
90
|
+
if @contents_found > 0
|
91
|
+
todo "Please open your elements.yml file and change all type values from these contents:\n\n#{@content_names.join(', ')}\n\ninto #{@essence_type}."
|
92
|
+
else
|
93
|
+
log "No EssenceTexts with display_as #{@display_as} setting found.", :skip
|
94
|
+
end
|
65
95
|
end
|
66
96
|
end
|
67
97
|
|
98
|
+
private
|
99
|
+
|
100
|
+
def convert_essence_texts_displayed_as_select_into_essence_selects
|
101
|
+
desc "Converting all EssenceTexts displayed as select into EssenceSelects"
|
102
|
+
converter = ContentsConverter.new('select', 'EssenceSelect')
|
103
|
+
converter.convert!
|
104
|
+
end
|
105
|
+
|
106
|
+
def convert_essence_texts_displayed_as_checkbox_into_essence_booleans
|
107
|
+
desc "Converting all EssenceTexts displayed as checkbox into EssenceBooleans"
|
108
|
+
converter = ContentsConverter.new('checkbox', 'EssenceBoolean')
|
109
|
+
converter.convert!
|
110
|
+
end
|
111
|
+
|
68
112
|
end
|
113
|
+
|
69
114
|
end
|