alchemy_cms 2.5.3.1 → 2.6.0.rc5
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -1
- data/.travis.yml +5 -13
- data/Gemfile +6 -3
- data/README.md +3 -2
- data/alchemy_cms.gemspec +22 -22
- data/app/assets/fonts/alchemy-icons.eot +0 -0
- data/app/assets/fonts/alchemy-icons.svg +54 -0
- data/app/assets/fonts/alchemy-icons.ttf +0 -0
- data/app/assets/fonts/alchemy-icons.woff +0 -0
- data/app/assets/images/alchemy/icons.png +0 -0
- data/app/assets/javascripts/alchemy/alchemy.base.js.coffee +151 -0
- data/app/assets/javascripts/alchemy/alchemy.buttons.js.coffee +3 -2
- data/app/assets/javascripts/alchemy/alchemy.datepicker.js.coffee +31 -0
- data/app/assets/javascripts/alchemy/alchemy.dragndrop.js +1 -1
- data/app/assets/javascripts/alchemy/alchemy.element_editors.js.coffee +98 -0
- data/app/assets/javascripts/alchemy/alchemy.elements_window.js.coffee +23 -24
- data/app/assets/javascripts/alchemy/alchemy.growler.js.coffee +27 -0
- data/app/assets/javascripts/alchemy/alchemy.gui.js.coffee +11 -8
- data/app/assets/javascripts/alchemy/alchemy.hotkeys.js.coffee +32 -0
- data/app/assets/javascripts/alchemy/alchemy.image_cropper.js.coffee +46 -0
- data/app/assets/javascripts/alchemy/alchemy.js +8 -2
- data/app/assets/javascripts/alchemy/alchemy.link_overlay.js.coffee +5 -4
- data/app/assets/javascripts/alchemy/alchemy.list_filter.js.coffee +49 -0
- data/app/assets/javascripts/alchemy/alchemy.onload.js.coffee +3 -0
- data/app/assets/javascripts/alchemy/alchemy.preview_window.js.coffee +71 -0
- data/app/assets/javascripts/alchemy/alchemy.sitemap.js.coffee +61 -0
- data/app/assets/javascripts/alchemy/alchemy.spinner.js.coffee +35 -0
- data/app/assets/javascripts/alchemy/alchemy.string_extension.js.coffee +11 -0
- data/app/assets/javascripts/alchemy/alchemy.windows.js.coffee +278 -0
- data/app/assets/stylesheets/alchemy/admin.css.scss +2 -0
- data/app/assets/stylesheets/alchemy/archive.scss +109 -65
- data/app/assets/stylesheets/alchemy/base.scss +16 -188
- data/app/assets/stylesheets/alchemy/dashboard.scss +2 -2
- data/app/assets/stylesheets/alchemy/defaults.scss +2 -1
- data/app/assets/stylesheets/alchemy/elements.scss +58 -94
- data/app/assets/stylesheets/alchemy/errors.scss +2 -2
- data/app/assets/stylesheets/alchemy/{mixins.scss → extends.scss} +104 -80
- data/app/assets/stylesheets/alchemy/flash.scss +4 -6
- data/app/assets/stylesheets/alchemy/fonts.scss +46 -0
- data/app/assets/stylesheets/alchemy/form_elements.scss +46 -45
- data/app/assets/stylesheets/alchemy/frame.scss +20 -15
- data/app/assets/stylesheets/alchemy/icons.scss +22 -9
- data/app/assets/stylesheets/alchemy/jquery-ui.scss +476 -399
- data/app/assets/stylesheets/alchemy/login.scss +1 -1
- data/app/assets/stylesheets/alchemy/menubar.css.scss +1 -1
- data/app/assets/stylesheets/alchemy/notices.scss +5 -5
- data/app/assets/stylesheets/alchemy/pagination.scss +25 -13
- data/app/assets/stylesheets/alchemy/search.scss +29 -17
- data/app/assets/stylesheets/alchemy/sitemap.scss +41 -36
- data/app/assets/stylesheets/alchemy/tables.scss +102 -50
- data/app/assets/stylesheets/alchemy/tinymce_dialog.css.scss +18 -16
- data/app/assets/stylesheets/alchemy/toolbar.scss +84 -24
- data/app/assets/stylesheets/alchemy/upload.scss +14 -9
- data/app/assets/stylesheets/alchemy/variables.scss +1 -0
- data/app/assets/stylesheets/tiny_mce/plugins/inlinepopups/skins/alchemy/window.css.scss +18 -21
- data/app/controllers/alchemy/admin/attachments_controller.rb +29 -39
- data/app/controllers/alchemy/admin/base_controller.rb +3 -9
- data/app/controllers/alchemy/admin/clipboard_controller.rb +1 -1
- data/app/controllers/alchemy/admin/contents_controller.rb +1 -1
- data/app/controllers/alchemy/admin/dashboard_controller.rb +1 -1
- data/app/controllers/alchemy/admin/elements_controller.rb +3 -3
- data/app/controllers/alchemy/admin/essence_files_controller.rb +1 -1
- data/app/controllers/alchemy/admin/essence_pictures_controller.rb +5 -5
- data/app/controllers/alchemy/admin/languages_controller.rb +1 -1
- data/app/controllers/alchemy/admin/pages_controller.rb +18 -16
- data/app/controllers/alchemy/admin/pictures_controller.rb +11 -10
- data/app/controllers/alchemy/admin/resources_controller.rb +87 -14
- data/app/controllers/alchemy/admin/tags_controller.rb +3 -3
- data/app/controllers/alchemy/admin/trash_controller.rb +3 -3
- data/app/controllers/alchemy/admin/users_controller.rb +6 -11
- data/app/controllers/alchemy/attachments_controller.rb +8 -9
- data/app/controllers/alchemy/base_controller.rb +17 -10
- data/app/controllers/alchemy/pages_controller.rb +7 -19
- data/app/controllers/alchemy/passwords_controller.rb +15 -3
- data/app/controllers/alchemy/user_sessions_controller.rb +5 -4
- data/app/controllers/alchemy/users_controller.rb +1 -1
- data/app/helpers/alchemy/admin/attachments_helper.rb +2 -2
- data/app/helpers/alchemy/admin/base_helper.rb +62 -90
- data/app/helpers/alchemy/admin/elements_helper.rb +13 -5
- data/app/helpers/alchemy/admin/essences_helper.rb +3 -5
- data/app/helpers/alchemy/admin/pages_helper.rb +6 -3
- data/app/helpers/alchemy/admin/tags_helper.rb +60 -0
- data/app/helpers/alchemy/base_helper.rb +16 -20
- data/app/helpers/alchemy/elements_helper.rb +7 -11
- data/app/helpers/alchemy/essences_helper.rb +2 -2
- data/app/helpers/alchemy/pages_helper.rb +31 -69
- data/app/helpers/alchemy/url_helper.rb +11 -3
- data/app/models/alchemy/attachment.rb +73 -45
- data/app/models/alchemy/cell.rb +1 -1
- data/app/models/alchemy/content.rb +20 -9
- data/app/models/alchemy/element.rb +9 -7
- data/app/models/alchemy/page.rb +15 -248
- data/app/models/alchemy/page/cells.rb +71 -0
- data/app/models/alchemy/page/elements.rb +147 -0
- data/app/models/alchemy/page/naming.rb +90 -0
- data/app/models/alchemy/picture.rb +18 -13
- data/app/models/alchemy/tag.rb +1 -1
- data/app/models/alchemy/user.rb +38 -6
- data/app/views/alchemy/admin/attachments/_archive_overlay.html.erb +14 -7
- data/app/views/alchemy/admin/attachments/_attachment.html.erb +17 -12
- data/app/views/alchemy/admin/attachments/_file_to_assign.html.erb +3 -8
- data/app/views/alchemy/admin/attachments/_files_list.html.erb +20 -12
- data/app/views/alchemy/admin/attachments/_overlay_file_list.html.erb +11 -0
- data/app/views/alchemy/admin/attachments/_tag_list.html.erb +31 -0
- data/app/views/alchemy/admin/attachments/archive_overlay.js.erb +4 -0
- data/app/views/alchemy/admin/attachments/edit.html.erb +8 -7
- data/app/views/alchemy/admin/attachments/index.html.erb +19 -12
- data/app/views/alchemy/admin/attachments/new.html.erb +2 -2
- data/app/views/alchemy/admin/attachments/show.html.erb +3 -0
- data/app/views/alchemy/admin/contents/_missing.html.erb +4 -4
- data/app/views/alchemy/admin/contents/create.js.erb +1 -1
- data/app/views/alchemy/admin/contents/new.html.erb +6 -3
- data/app/views/alchemy/admin/dashboard/_locked_pages.html.erb +1 -1
- data/app/views/alchemy/admin/dashboard/_users.html.erb +1 -1
- data/app/views/alchemy/admin/dashboard/index.html.erb +3 -3
- data/app/views/alchemy/admin/dashboard/info.html.erb +16 -13
- data/app/views/alchemy/admin/elements/_add_picture.html.erb +1 -1
- data/app/views/alchemy/admin/elements/_element_foot.html.erb +4 -4
- data/app/views/alchemy/admin/elements/_element_head.html.erb +1 -7
- data/app/views/alchemy/admin/elements/_elements_select.html.erb +2 -2
- data/app/views/alchemy/admin/elements/_new_element_form.html.erb +4 -4
- data/app/views/alchemy/admin/elements/_picture_gallery_editor.html.erb +1 -1
- data/app/views/alchemy/admin/elements/create.js.erb +2 -2
- data/app/views/alchemy/admin/elements/fold.js.erb +3 -6
- data/app/views/alchemy/admin/elements/new.html.erb +1 -1
- data/app/views/alchemy/admin/elements/order.js.erb +1 -1
- data/app/views/alchemy/admin/elements/trash.js.erb +1 -1
- data/app/views/alchemy/admin/elements/update.js.erb +2 -2
- data/app/views/alchemy/admin/essence_files/edit.html.erb +4 -4
- data/app/views/alchemy/admin/essence_pictures/crop.html.erb +17 -18
- data/app/views/alchemy/admin/essence_pictures/edit.html.erb +2 -2
- data/app/views/alchemy/admin/essence_pictures/update.js.erb +1 -0
- data/app/views/alchemy/admin/languages/_form.html.erb +12 -10
- data/app/views/alchemy/admin/languages/_language.html.erb +2 -1
- data/app/views/alchemy/admin/languages/_table.html.erb +3 -3
- data/app/views/alchemy/admin/languages/index.html.erb +15 -15
- data/app/views/alchemy/admin/layoutpages/_layoutpage.html.erb +6 -6
- data/app/views/alchemy/admin/layoutpages/index.html.erb +41 -40
- data/app/views/alchemy/admin/pages/_contactform_links.html.erb +4 -4
- data/app/views/alchemy/admin/pages/_create_language_form.html.erb +6 -6
- data/app/views/alchemy/admin/pages/_external_link.html.erb +2 -2
- data/app/views/alchemy/admin/pages/_file_link.html.erb +3 -3
- data/app/views/alchemy/admin/pages/_internal_link.html.erb +1 -1
- data/app/views/alchemy/admin/pages/_new_page_form.html.erb +1 -1
- data/app/views/alchemy/admin/pages/_page.html.erb +13 -13
- data/app/views/alchemy/admin/pages/_page_for_links.html.erb +2 -4
- data/app/views/alchemy/admin/pages/_sitemap.html.erb +5 -0
- data/app/views/alchemy/admin/pages/configure.html.erb +7 -7
- data/app/views/alchemy/admin/pages/configure_external.html.erb +4 -4
- data/app/views/alchemy/admin/pages/edit.html.erb +23 -30
- data/app/views/alchemy/admin/pages/index.html.erb +34 -23
- data/app/views/alchemy/admin/pages/new.html.erb +1 -1
- data/app/views/alchemy/admin/pages/sort.js.erb +1 -1
- data/app/views/alchemy/admin/partials/_flash_upload.html.erb +2 -3
- data/app/views/alchemy/admin/partials/_remote_search_form.html.erb +2 -2
- data/app/views/alchemy/admin/partials/_search_form.html.erb +3 -3
- data/app/views/alchemy/admin/partials/_upload_form.html.erb +2 -2
- data/app/views/alchemy/admin/pictures/_archive.html.erb +7 -7
- data/app/views/alchemy/admin/pictures/_archive_overlay.html.erb +1 -1
- data/app/views/alchemy/admin/pictures/_filter_and_size_bar.html.erb +6 -6
- data/app/views/alchemy/admin/pictures/_filter_bar.html.erb +4 -4
- data/app/views/alchemy/admin/pictures/_overlay_picture_list.html.erb +1 -1
- data/app/views/alchemy/admin/pictures/_picture.html.erb +3 -8
- data/app/views/alchemy/admin/pictures/_picture_to_assign.html.erb +9 -14
- data/app/views/alchemy/admin/pictures/_tag_list.html.erb +27 -25
- data/app/views/alchemy/admin/pictures/archive_overlay.js.erb +3 -1
- data/app/views/alchemy/admin/pictures/index.html.erb +49 -42
- data/app/views/alchemy/admin/pictures/new.html.erb +2 -2
- data/app/views/alchemy/admin/pictures/show.html.erb +11 -0
- data/app/views/alchemy/admin/resources/_boolean.html.erb +2 -2
- data/app/views/alchemy/admin/resources/_datetime.html.erb +2 -2
- data/app/views/alchemy/admin/resources/_form.html.erb +9 -8
- data/app/views/alchemy/admin/resources/_resource.html.erb +15 -21
- data/app/views/alchemy/admin/resources/_string.html.erb +2 -2
- data/app/views/alchemy/admin/resources/_table.html.erb +11 -13
- data/app/views/alchemy/admin/resources/_text.html.erb +2 -2
- data/app/views/alchemy/admin/resources/index.csv.erb +13 -0
- data/app/views/alchemy/admin/resources/index.html.erb +24 -15
- data/app/views/alchemy/admin/sites/index.html.erb +23 -0
- data/app/views/alchemy/admin/tags/_radio_tag.html.erb +1 -1
- data/app/views/alchemy/admin/tags/_tag.html.erb +2 -1
- data/app/views/alchemy/admin/tags/edit.html.erb +1 -1
- data/app/views/alchemy/admin/tags/index.html.erb +16 -11
- data/app/views/alchemy/admin/tags/new.html.erb +3 -3
- data/app/views/alchemy/admin/trash/clear.js.coffee +1 -1
- data/app/views/alchemy/admin/users/_table.html.erb +12 -5
- data/app/views/alchemy/admin/users/_user.html.erb +16 -16
- data/app/views/alchemy/admin/users/index.html.erb +28 -16
- data/app/views/alchemy/breadcrumb/_page.html.erb +15 -0
- data/app/views/alchemy/breadcrumb/_spacer.html.erb +1 -0
- data/app/views/alchemy/elements/_editor_not_found.html.erb +1 -1
- data/app/views/alchemy/essences/_essence_file_editor.html.erb +16 -16
- data/app/views/alchemy/essences/_essence_file_view.html.erb +8 -9
- data/app/views/alchemy/essences/_essence_picture_editor.html.erb +3 -6
- data/app/views/alchemy/essences/_essence_picture_tools.html.erb +9 -8
- data/app/views/alchemy/essences/_essence_richtext_editor.html.erb +0 -5
- data/app/views/alchemy/essences/_linkable_essence_tools.html.erb +2 -2
- data/app/views/alchemy/navigation/_link.html.erb +7 -7
- data/app/views/alchemy/navigation/_renderer.html.erb +29 -36
- data/app/views/alchemy/notifications/admin_user_created.de.text.erb +5 -1
- data/app/views/alchemy/notifications/admin_user_created.en.text.erb +5 -1
- data/app/views/alchemy/notifications/registered_user_created.de.text.erb +13 -0
- data/app/views/alchemy/notifications/registered_user_created.en.text.erb +13 -0
- data/app/views/alchemy/search/_result.html.erb +4 -6
- data/app/views/alchemy/search/_results.html.erb +4 -5
- data/app/views/alchemy/user_sessions/leave.html.erb +1 -1
- data/app/views/alchemy/user_sessions/new.html.erb +2 -2
- data/app/views/kaminari/_first_page.html.erb +11 -0
- data/app/views/kaminari/_gap.html.erb +1 -1
- data/app/views/kaminari/_last_page.html.erb +11 -0
- data/app/views/kaminari/_next_page.html.erb +2 -2
- data/app/views/kaminari/_page.html.erb +1 -1
- data/app/views/kaminari/_paginator.html.erb +2 -0
- data/app/views/kaminari/_prev_page.html.erb +2 -2
- data/app/views/layouts/alchemy/admin.html.erb +4 -5
- data/config/alchemy/config.yml +8 -12
- data/config/authorization_rules.rb +4 -3
- data/config/initializers/dragonfly.rb +20 -12
- data/config/locales/alchemy.de.yml +20 -15
- data/config/locales/alchemy.en.yml +15 -10
- data/config/locales/devise.de.yml +1 -0
- data/config/routes.rb +3 -3
- data/{spec/dummy/db/migrate/20121118000000_alchemy_two_point_four.rb → db/migrate/20130214233001_alchemy_two_point_five.rb} +50 -36
- data/db/migrate/20130221200514_migrate_attachments_to_dragonfly.rb +21 -0
- data/db/migrate/20130312205327_change_alchemy_users_role_to_roles.rb +11 -0
- data/lib/alchemy/capistrano.rb +10 -8
- data/lib/alchemy/errors.rb +7 -0
- data/lib/alchemy/filetypes.rb +33 -0
- data/lib/alchemy/i18n.rb +9 -1
- data/lib/alchemy/name_conversions.rb +28 -0
- data/lib/alchemy/page_layout.rb +5 -3
- data/lib/alchemy/resource.rb +132 -29
- data/lib/alchemy/resources_helper.rb +81 -12
- data/lib/alchemy/upgrader.rb +14 -276
- data/lib/alchemy/version.rb +1 -1
- data/lib/alchemy_cms.rb +17 -2
- data/lib/rails/generators/alchemy/deploy_script/templates/deploy.rb.tt +1 -1
- data/lib/rails/generators/alchemy/scaffold/scaffold_generator.rb +1 -1
- data/lib/tasks/alchemy/convert.rake +39 -0
- data/lib/tasks/alchemy/install.rake +4 -6
- data/lib/tasks/alchemy/upgrade.rake +18 -1
- data/spec/controllers/admin/clipboard_controller_spec.rb +4 -4
- data/spec/controllers/admin/elements_controller_spec.rb +23 -23
- data/spec/controllers/admin/pages_controller_spec.rb +15 -0
- data/spec/controllers/admin/resources_controller_spec.rb +1 -11
- data/spec/controllers/admin/trash_controller_spec.rb +9 -9
- data/spec/controllers/attachments_controller_spec.rb +3 -3
- data/spec/controllers/elements_controller_spec.rb +2 -2
- data/spec/controllers/pages_controller_spec.rb +160 -129
- data/spec/controllers/pictures_controller_spec.rb +2 -2
- data/spec/controllers/user_sessions_controller_spec.rb +3 -3
- data/spec/controllers/users_controller_spec.rb +2 -2
- data/spec/dummy/app/models/event.rb +2 -2
- data/spec/dummy/app/models/location.rb +4 -0
- data/spec/dummy/app/views/layouts/application.html.erb +6 -42
- data/spec/dummy/config/routes.rb +1 -1
- data/spec/dummy/db/migrate/20121026104128_create_events.rb +0 -1
- data/{db/migrate/20121118000000_alchemy_two_point_four.rb → spec/dummy/db/migrate/20130214233001_alchemy_two_point_five.rb} +50 -36
- data/spec/dummy/db/migrate/20130221200514_migrate_attachments_to_dragonfly.rb +21 -0
- data/spec/dummy/db/migrate/20130312205327_change_alchemy_users_role_to_roles.rb +11 -0
- data/spec/dummy/db/migrate/20130328101418_create_locations.rb +9 -0
- data/spec/dummy/db/schema.rb +15 -6
- data/spec/factories.rb +4 -4
- data/spec/{integration → features}/admin/link_overlay_spec.rb +0 -0
- data/spec/{integration → features}/admin/modules_integration_spec.rb +1 -1
- data/spec/{integration → features}/admin/pages_controller_spec.rb +9 -4
- data/spec/{integration → features}/admin/picture_library_integration_spec.rb +5 -5
- data/spec/{integration → features}/admin/resources_integration_spec.rb +1 -1
- data/spec/{integration → features}/navigation_spec.rb +0 -0
- data/spec/{integration → features}/pages_controller_spec.rb +42 -112
- data/spec/{integration → features}/picture_security_spec.rb +2 -2
- data/spec/{integration → features}/security_spec.rb +7 -7
- data/spec/{integration → features}/translation_integration_spec.rb +0 -0
- data/spec/helpers/admin/base_helper_spec.rb +0 -50
- data/spec/helpers/admin/tags_helper_spec.rb +53 -0
- data/spec/helpers/base_helper_spec.rb +19 -3
- data/spec/helpers/pages_helper_spec.rb +92 -44
- data/spec/{url_helpers_spec.rb → helpers/picture_url_helpers_spec.rb} +7 -7
- data/spec/helpers/url_helper_spec.rb +92 -72
- data/spec/{config_spec.rb → libraries/config_spec.rb} +0 -0
- data/spec/libraries/resource_spec.rb +215 -76
- data/spec/libraries/resources_helper_spec.rb +70 -28
- data/spec/models/attachment_spec.rb +75 -9
- data/spec/models/clipboard_spec.rb +1 -1
- data/spec/models/element_spec.rb +7 -0
- data/spec/models/page_spec.rb +144 -25
- data/spec/models/picture_spec.rb +5 -5
- data/spec/models/resource_spec.rb +47 -10
- data/spec/models/user_spec.rb +115 -3
- data/spec/{routing_spec.rb → routing/routing_spec.rb} +8 -20
- data/spec/spec_helper.rb +5 -6
- data/spec/support/alchemy/specs_helpers.rb +1 -1
- data/spec/support/ci/install_phantomjs +1 -1
- data/spec/support/image with spaces.png +0 -0
- data/vendor/assets/javascripts/jquery_plugins/jquery.Jcrop.min.js +18 -18
- data/vendor/assets/javascripts/jquery_plugins/{jquery.dialogextend.1_0_1.js → jquery.dialogextend.js} +25 -17
- data/vendor/assets/javascripts/jquery_plugins/jquery.scrollTo.min.js +7 -0
- data/vendor/assets/javascripts/jquery_plugins/jquery.ui.tabspaging.js +7 -7
- data/vendor/assets/javascripts/keymage.min.js +6 -0
- data/vendor/assets/javascripts/spin.min.js +1 -0
- metadata +122 -124
- data/app/assets/images/alchemy/ajax_loader.gif +0 -0
- data/app/assets/images/alchemy/gui/toggle.png +0 -0
- data/app/assets/images/alchemy/image_loader.gif +0 -0
- data/app/assets/images/alchemy/shading.png +0 -0
- data/app/assets/images/alchemy/tabs.gif +0 -0
- data/app/assets/javascripts/alchemy/alchemy.base.js +0 -172
- data/app/assets/javascripts/alchemy/alchemy.datepicker.js +0 -47
- data/app/assets/javascripts/alchemy/alchemy.element_editor_selector.js +0 -91
- data/app/assets/javascripts/alchemy/alchemy.growler.js +0 -46
- data/app/assets/javascripts/alchemy/alchemy.image_cropper.js +0 -60
- data/app/assets/javascripts/alchemy/alchemy.js_extensions.js +0 -15
- data/app/assets/javascripts/alchemy/alchemy.preview_window.js +0 -97
- data/app/assets/javascripts/alchemy/alchemy.windows.js +0 -321
- data/app/models/alchemy/clipboard_spec.rb +0 -0
- data/app/views/alchemy/admin/pictures/show_in_window.html.erb +0 -8
- data/app/views/alchemy/notifications/registered_user_created.text.erb +0 -11
- data/db/migrate/20121121162313_switch_from_fleximage_to_dragonfly.rb +0 -21
- data/db/migrate/20121205155004_create_alchemy_sites.rb +0 -14
- data/db/migrate/20121211163003_add_public_to_alchemy_sites.rb +0 -6
- data/db/migrate/20121220102223_add_aliases_to_site.rb +0 -6
- data/db/migrate/20130110212411_create_alchemy_legacy_page_urls.rb +0 -11
- data/db/migrate/20130121092645_migrate_to_devise.rb +0 -24
- data/spec/alchemy_spec.rb +0 -7
- data/spec/dummy/db/migrate/20121121162313_switch_from_fleximage_to_dragonfly.rb +0 -21
- data/spec/dummy/db/migrate/20121205155004_create_alchemy_sites.rb +0 -14
- data/spec/dummy/db/migrate/20121211163003_add_public_to_alchemy_sites.rb +0 -6
- data/spec/dummy/db/migrate/20121220102223_add_aliases_to_site.rb +0 -6
- data/spec/dummy/db/migrate/20130110212411_create_alchemy_legacy_page_urls.rb +0 -11
- data/spec/dummy/db/migrate/20130121092645_migrate_to_devise.rb +0 -24
- data/vendor/assets/javascripts/jquery_plugins/jquery.scrollTo-1.4.2-min.js +0 -11
data/lib/alchemy/resource.rb
CHANGED
@@ -2,35 +2,113 @@ require 'active_support/inflector'
|
|
2
2
|
require 'active_support/core_ext'
|
3
3
|
|
4
4
|
module Alchemy
|
5
|
+
# = Alchemy::Resource
|
6
|
+
#
|
7
|
+
# Used to DRY up resource like structures in Alchemy's admin backend.
|
8
|
+
# So far Language, User and Tag already uses this.
|
9
|
+
#
|
10
|
+
# It provides convenience methods to create an admin interface without further knowledge about
|
11
|
+
# the model and the controller (it's instantiated with controller_path at least and guesses the model accordingly)
|
12
|
+
#
|
13
|
+
# For examples how to use in controllers see Alchemy::ResourcesController or inherit from it directly.
|
14
|
+
#
|
15
|
+
# == Naming Conventions
|
16
|
+
#
|
17
|
+
# As Rails' form helpers, path helpers, etc. and declarative authorization rely on controller_path even if the model
|
18
|
+
# class is named differently (or sits in another namespace) model and controller are handled separatly here.
|
19
|
+
# Therefore "resource" always refers to the controller_path whereas "model" refers to the model class.
|
20
|
+
#
|
21
|
+
# == Skip attributes
|
22
|
+
#
|
23
|
+
# Usually you don't want your users to edit all attributes provided by a model. Hence some default attributes,
|
24
|
+
# namely id, updated_at, created_at, creator_id and updater_id are not returned by Resource#attributes.
|
25
|
+
#
|
26
|
+
# If you want to skip a different set of attributes just define a skip_attributes class method in your model class
|
27
|
+
# that returns an array of strings: %W[id, updated_at]
|
28
|
+
#
|
29
|
+
# == Resource relations
|
30
|
+
#
|
31
|
+
# Alchemy::Resource can take care of ActiveRecord relations. You will have to announce relations by defining a
|
32
|
+
# resource_relations class method in your model class that returns a hash like this:
|
33
|
+
#
|
34
|
+
# {
|
35
|
+
# :location_id => {:attr_method => "location#name", :attr_type => :string},
|
36
|
+
# :organizer_id => {:attr_method => "organizer#name", :attr_type => :string}
|
37
|
+
# }
|
38
|
+
#
|
39
|
+
# With this knowledge Resource#attributes will return location#name and organizer#name instead of location_id
|
40
|
+
# and organizer_id. Refer to Alchemy::ResourcesController for further details on usage.
|
41
|
+
#
|
42
|
+
# == Creation
|
43
|
+
#
|
44
|
+
# Resource needs a controller_path at least. Without other arguments it will guess the model name from it and assume
|
45
|
+
# that the model doesn't live in an engine. Moreover model and controller has to follow Rails' naming convention:
|
46
|
+
#
|
47
|
+
# Event -> EventsController
|
48
|
+
#
|
49
|
+
# It will also strip "admin" automatically, so this is also valid:
|
50
|
+
#
|
51
|
+
# Event -> Admin::EventsController
|
52
|
+
#
|
53
|
+
# If your Resource and it's controllers are part of an engine you need to provide Alchemy's module_definition,
|
54
|
+
# so resource can provide the correct url_proxy. If you don't declare it in Alchemy, you need at least provide the
|
55
|
+
# following hash (i.e. if your engine is named EventEngine):
|
56
|
+
#
|
57
|
+
# resource = Resource.new(controller_path, {"engine_name" => "event_engine"})
|
58
|
+
#
|
59
|
+
# If you don't want to stick with these conventions you can separate model and controller by providing
|
60
|
+
# a model class (for example used by Alchemy's Tags admin interface):
|
61
|
+
#
|
62
|
+
# resource = Resource.new('/admin/tags', {"engine_name"=>"alchemy"}, ActsAsTaggableOn::Tag)
|
63
|
+
#
|
5
64
|
class Resource
|
6
|
-
|
7
|
-
|
65
|
+
attr_accessor :skip_attributes, :resource_relations, :model_associations
|
66
|
+
attr_reader :model
|
8
67
|
|
9
68
|
DEFAULT_SKIPPED_ATTRIBUTES = %W[id updated_at created_at creator_id updater_id]
|
69
|
+
DEFAULT_SKIPPED_ASSOCIATIONS = %w(creator updater)
|
10
70
|
|
11
|
-
def initialize(controller_path, module_definition=nil)
|
71
|
+
def initialize(controller_path, module_definition=nil, custom_model=nil)
|
12
72
|
@controller_path = controller_path
|
13
73
|
@module_definition = module_definition
|
74
|
+
@model = (custom_model or guess_model_from_controller_path)
|
14
75
|
self.skip_attributes = model.respond_to?(:skip_attributes) ? model.skip_attributes : DEFAULT_SKIPPED_ATTRIBUTES
|
15
|
-
|
76
|
+
if model.respond_to?(:resource_relations)
|
77
|
+
if not model.respond_to?(:reflect_on_all_associations)
|
78
|
+
raise MissingActiveRecordAssociation
|
79
|
+
end
|
80
|
+
store_model_associations
|
81
|
+
map_relations
|
82
|
+
end
|
16
83
|
end
|
17
84
|
|
18
|
-
def
|
19
|
-
|
20
|
-
model_array.delete("admin")
|
21
|
-
model_array
|
85
|
+
def resource_array
|
86
|
+
@_resource_array ||= controller_path_array.reject { |el| el == 'admin' }
|
22
87
|
end
|
23
88
|
|
24
|
-
def
|
25
|
-
@
|
89
|
+
def resources_name
|
90
|
+
@_resources_name ||= resource_array.last
|
26
91
|
end
|
27
92
|
|
28
|
-
def
|
29
|
-
@
|
93
|
+
def resource_name
|
94
|
+
@_resource_name ||= resources_name.singularize
|
30
95
|
end
|
31
96
|
|
32
97
|
def model_name
|
33
|
-
|
98
|
+
ActiveSupport::Deprecation.warn("model_name is deprecated. Please use resource_name instead!")
|
99
|
+
resource_name
|
100
|
+
end
|
101
|
+
|
102
|
+
def namespaced_resource_name
|
103
|
+
return @_namespaced_resource_name unless @_namespaced_resource_name.nil?
|
104
|
+
resource_name_array = resource_array
|
105
|
+
resource_name_array.delete(engine_name) if in_engine?
|
106
|
+
@_namespaced_resource_name = resource_name_array.join('_').singularize
|
107
|
+
end
|
108
|
+
|
109
|
+
def namespaced_model_name
|
110
|
+
ActiveSupport::Deprecation.warn("namespaced_model_name is deprecated. Please use namespaced_resource_name instead!")
|
111
|
+
namespaced_resource_name
|
34
112
|
end
|
35
113
|
|
36
114
|
def permission_scope
|
@@ -46,21 +124,20 @@ module Alchemy
|
|
46
124
|
|
47
125
|
def attributes
|
48
126
|
@_attributes ||= self.model.columns.collect do |col|
|
49
|
-
|
127
|
+
unless self.skip_attributes.include?(col.name)
|
128
|
+
{ :name => col.name, :type => resource_relation_type(col.name) || col.type, :relation => resource_relation(col.name) }.delete_if { |k, v | v.nil? }
|
129
|
+
end
|
50
130
|
end.compact
|
51
131
|
end
|
52
132
|
|
133
|
+
# Returns all columns that are searchable
|
134
|
+
#
|
135
|
+
# For now it only uses string type columns
|
136
|
+
#
|
53
137
|
def searchable_attributes
|
54
138
|
self.attributes.select { |a| a[:type] == :string }
|
55
139
|
end
|
56
140
|
|
57
|
-
def namespaced_model_name
|
58
|
-
return @_namespaced_model_name unless @_namespaced_model_name.nil?
|
59
|
-
model_name_array = self.model_array
|
60
|
-
model_name_array.delete(self.engine_name) if in_engine?
|
61
|
-
@_namespaced_model_name = model_name_array.join('_').singularize
|
62
|
-
end
|
63
|
-
|
64
141
|
def in_engine?
|
65
142
|
not self.engine_name.nil?
|
66
143
|
end
|
@@ -76,27 +153,28 @@ module Alchemy
|
|
76
153
|
# de:
|
77
154
|
# alchemy:
|
78
155
|
# resource_help_texts:
|
79
|
-
#
|
156
|
+
# my_resource_name:
|
80
157
|
# attribute_name: This is the fancy help text
|
81
158
|
#
|
82
159
|
def help_text_for(attribute)
|
83
|
-
::I18n.translate!(attribute[:name], :scope => [:alchemy, :resource_help_texts,
|
160
|
+
::I18n.translate!(attribute[:name], :scope => [:alchemy, :resource_help_texts, resource_name])
|
84
161
|
rescue ::I18n::MissingTranslationData
|
85
162
|
false
|
86
163
|
end
|
87
164
|
|
88
|
-
|
165
|
+
|
166
|
+
private
|
167
|
+
|
168
|
+
def guess_model_from_controller_path
|
169
|
+
resource_array.join('/').classify.constantize
|
170
|
+
end
|
89
171
|
|
90
172
|
def controller_path_array
|
91
173
|
@controller_path.split('/')
|
92
174
|
end
|
93
175
|
|
94
176
|
def namespace_diff
|
95
|
-
controller_path_array -
|
96
|
-
end
|
97
|
-
|
98
|
-
def resource_relation_name(column_name)
|
99
|
-
resource_relation(column_name).try(:[], :attr_method)
|
177
|
+
controller_path_array - resource_array
|
100
178
|
end
|
101
179
|
|
102
180
|
def resource_relation_type(column_name)
|
@@ -107,5 +185,30 @@ module Alchemy
|
|
107
185
|
resource_relations[column_name.to_sym] if resource_relations
|
108
186
|
end
|
109
187
|
|
188
|
+
# Expands the resource_relations hash with matching activerecord associations data.
|
189
|
+
def map_relations
|
190
|
+
self.resource_relations = {}
|
191
|
+
model.resource_relations.each do |name, options|
|
192
|
+
name = name.to_s.gsub(/_id$/, '') # ensure that we don't have an id
|
193
|
+
association = association_from_relation_name(name)
|
194
|
+
foreign_key = association.options[:foreign_key] || "#{association.name}_id".to_sym
|
195
|
+
if options[:attr_method].to_s =~ /#/
|
196
|
+
ActiveSupport::Deprecation.warn('Old style :attr_method used in Alchemy::Ressource#resource_relations. Please remove the # and pass column name only.', caller[2..10])
|
197
|
+
options[:attr_method] = options[:attr_method].split('#').last
|
198
|
+
end
|
199
|
+
self.resource_relations[foreign_key] = options.merge(:model_association => association, :name => name)
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
# Stores all activerecord associations in model_associations attribute
|
204
|
+
def store_model_associations
|
205
|
+
self.model_associations = model.reflect_on_all_associations.delete_if { |a| DEFAULT_SKIPPED_ASSOCIATIONS.include?(a.name.to_s) }
|
206
|
+
end
|
207
|
+
|
208
|
+
# Returns activerecord association that has the given name
|
209
|
+
def association_from_relation_name(name)
|
210
|
+
model_associations.detect { |a| a.name == name.to_sym }
|
211
|
+
end
|
212
|
+
|
110
213
|
end
|
111
214
|
end
|
@@ -1,12 +1,18 @@
|
|
1
1
|
module Alchemy
|
2
2
|
module ResourcesHelper
|
3
|
+
# = Alchemy::ResourceHelper
|
4
|
+
#
|
5
|
+
# Used to DRY up resource like structures in Alchemy's admin backend in combination with Alchemy::Resource
|
6
|
+
#
|
7
|
+
# See Alchemy::Resource for examples how to initialize a resource_handler
|
8
|
+
#
|
3
9
|
|
4
10
|
def resource_window_size
|
5
11
|
@resource_window_size ||= "420x#{100 + resource_handler.attributes.length * 40}"
|
6
12
|
end
|
7
13
|
|
8
14
|
def resource_instance_variable
|
9
|
-
instance_variable_get("@#{resource_handler.
|
15
|
+
instance_variable_get("@#{resource_handler.resource_name}")
|
10
16
|
end
|
11
17
|
|
12
18
|
def resources_instance_variable
|
@@ -25,20 +31,21 @@ module Alchemy
|
|
25
31
|
@_resource_scope ||= [resource_url_proxy].concat(resource_handler.namespace_for_scope)
|
26
32
|
end
|
27
33
|
|
28
|
-
def resources_path(
|
29
|
-
polymorphic_path (resource_scope + [
|
34
|
+
def resources_path(resource_or_name=resource_handler.resources_name, options={})
|
35
|
+
polymorphic_path (resource_scope + [resource_or_name]), options
|
30
36
|
end
|
31
37
|
|
32
|
-
def resource_path(resource=resource_handler.
|
38
|
+
def resource_path(resource=resource_handler.resource_name, options={})
|
33
39
|
resources_path(resource, options)
|
34
40
|
end
|
35
41
|
|
36
42
|
def new_resource_path(options={})
|
37
|
-
new_polymorphic_path (resource_scope + [resource_handler.
|
43
|
+
new_polymorphic_path (resource_scope + [resource_handler.resource_name]), options
|
38
44
|
end
|
39
45
|
|
40
46
|
def edit_resource_path(resource=nil, options={})
|
41
|
-
|
47
|
+
path_segments = (resource_scope + [resource] or resource_handler.resource_array)
|
48
|
+
edit_polymorphic_path path_segments, options
|
42
49
|
end
|
43
50
|
|
44
51
|
def resource_permission_scope
|
@@ -46,19 +53,43 @@ module Alchemy
|
|
46
53
|
end
|
47
54
|
|
48
55
|
def resource_model_name
|
49
|
-
|
56
|
+
ActiveSupport::Deprecation.warn("resource_model_name is deprecated. Please use resource_name instead!")
|
57
|
+
resource_handler.resource_name
|
58
|
+
end
|
59
|
+
|
60
|
+
def resource_name
|
61
|
+
resource_handler.resource_name
|
50
62
|
end
|
51
63
|
|
52
64
|
def resource_model
|
53
65
|
resource_handler.model
|
54
66
|
end
|
55
67
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
68
|
+
# Returns the value from resource attribute
|
69
|
+
#
|
70
|
+
# If the attribute has a relation, the related object's attribute value will be returned.
|
71
|
+
#
|
72
|
+
# The output will be truncated after 50 chars.
|
73
|
+
#
|
74
|
+
# @param [Alchemy::Resource] resource
|
75
|
+
# @param [Hash] attribute
|
76
|
+
# @option options [Hash] :truncate (50) The length of the value returned.
|
77
|
+
#
|
78
|
+
# @return [String]
|
79
|
+
#
|
80
|
+
def render_attribute(resource, attribute, options={})
|
81
|
+
options.reverse_merge!(truncate: 50)
|
82
|
+
value = resource.send(attribute[:name])
|
83
|
+
if (relation = attribute[:relation]) && value.present?
|
84
|
+
record = relation[:model_association].klass.find(value)
|
85
|
+
value = record.send(relation[:attr_method])
|
86
|
+
elsif attribute[:type] == :datetime && value.present?
|
87
|
+
value = l(value)
|
60
88
|
end
|
61
|
-
|
89
|
+
value.to_s.truncate(options[:truncate])
|
90
|
+
rescue ActiveRecord::RecordNotFound => e
|
91
|
+
warning e
|
92
|
+
_t(:not_found)
|
62
93
|
end
|
63
94
|
|
64
95
|
def resource_help_text(attribute)
|
@@ -67,5 +98,43 @@ module Alchemy
|
|
67
98
|
end
|
68
99
|
end
|
69
100
|
|
101
|
+
# Renders the human model name with a count as h1 header
|
102
|
+
def resources_header
|
103
|
+
content_tag :h1, "#{resources_instance_variable.total_count} #{resource_model.model_name.human(:count => resources_instance_variable.total_count)}"
|
104
|
+
end
|
105
|
+
|
106
|
+
# Returns true if the resource contains any relations
|
107
|
+
def contains_relations?
|
108
|
+
resource_handler.resource_relations.present?
|
109
|
+
end
|
110
|
+
|
111
|
+
# Returns an array of all resource_relations names
|
112
|
+
def resource_relations_names
|
113
|
+
resource_handler.resource_relations.collect { |k, v| v[:name].to_sym }
|
114
|
+
end
|
115
|
+
|
116
|
+
# Returns the attribute's column for sorting
|
117
|
+
#
|
118
|
+
# If the attribute contains a resource_relation, then the table and column for related model will be returned.
|
119
|
+
#
|
120
|
+
def sortable_resource_header_column(attribute)
|
121
|
+
if relation = attribute[:relation]
|
122
|
+
"#{relation[:model_association].table_name}.#{relation[:attr_method]}"
|
123
|
+
else
|
124
|
+
attribute[:name]
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
# Returns resource relations options hash for a rails select helper.
|
129
|
+
#
|
130
|
+
# @param [Hash] relation
|
131
|
+
# @returns Hash
|
132
|
+
#
|
133
|
+
def options_for_resource_relation_select(relation)
|
134
|
+
relation[:model_association].klass.all.collect do |r|
|
135
|
+
[r.send(relation[:attr_method]), r.id]
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
70
139
|
end
|
71
140
|
end
|
data/lib/alchemy/upgrader.rb
CHANGED
@@ -1,191 +1,29 @@
|
|
1
|
-
require 'fileutils'
|
2
|
-
require 'active_record'
|
3
|
-
|
4
1
|
module Alchemy
|
5
2
|
class Upgrader < Alchemy::Seeder
|
6
|
-
|
7
3
|
class << self
|
8
4
|
|
9
|
-
# Runs
|
5
|
+
# Runs ugrades
|
6
|
+
#
|
7
|
+
# Set UPGRADE env variable to only run a specific task.
|
10
8
|
def run!
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
Seeder.seed!
|
15
|
-
upgrade_to_language
|
16
|
-
upgrade_layoutpages
|
17
|
-
upgrade_essence_link_target_default
|
18
|
-
upgrade_to_namespaced_essence_type
|
19
|
-
convert_essence_texts_displayed_as_select_into_essence_selects
|
20
|
-
convert_essence_texts_displayed_as_checkbox_into_essence_booleans
|
21
|
-
copy_new_config_file
|
22
|
-
gallery_pictures_change_notice
|
23
|
-
removed_richmedia_essences_notice
|
24
|
-
convert_picture_storage
|
25
|
-
removed_standard_set_notice
|
26
|
-
renamed_t_method
|
27
|
-
migrated_to_devise
|
28
|
-
|
29
|
-
display_todos
|
30
|
-
end
|
31
|
-
|
32
|
-
private
|
33
|
-
|
34
|
-
# Creates Language model if it does not exist (Alchemy CMS prior v1.5)
|
35
|
-
# Also creates missing associations between pages and languages
|
36
|
-
def upgrade_to_language
|
37
|
-
desc "Creating languages for pages"
|
38
|
-
Alchemy::Page.all.each do |page|
|
39
|
-
if !page.language_code.blank? && page.language.nil?
|
40
|
-
root = page.get_language_root
|
41
|
-
lang = Alchemy::Language.find_or_create_by_language_code(
|
42
|
-
:name => page.language_code.capitalize,
|
43
|
-
:code => page.language_code,
|
44
|
-
:frontpage_name => root.name,
|
45
|
-
:page_layout => root.page_layout,
|
46
|
-
:public => true
|
47
|
-
)
|
48
|
-
page.language = lang
|
49
|
-
if page.save(:validate => false)
|
50
|
-
log "Set language for page #{page.name} to #{lang.name}."
|
51
|
-
end
|
52
|
-
else
|
53
|
-
log("Language for page #{page.name} already set.", :skip)
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
def upgrade_layoutpages
|
59
|
-
desc "Setting language of layoutpages"
|
60
|
-
default_language = Alchemy::Language.get_default
|
61
|
-
layoutpages = Alchemy::Page.layoutpages
|
62
|
-
if layoutpages.any?
|
63
|
-
layoutpages.each do |page|
|
64
|
-
if page.language.class == String || page.language.nil?
|
65
|
-
page.language = default_language
|
66
|
-
if page.save(:validate => false)
|
67
|
-
log "Set language for page #{page.name} to #{default_language.name}."
|
68
|
-
end
|
69
|
-
else
|
70
|
-
log "Language for page #{page.name} already set.", :skip
|
71
|
-
end
|
9
|
+
if ENV['UPGRADE']
|
10
|
+
ENV['UPGRADE'].split(',').each do |task|
|
11
|
+
self.send(task)
|
72
12
|
end
|
73
13
|
else
|
74
|
-
|
14
|
+
run_all
|
75
15
|
end
|
16
|
+
display_todos
|
76
17
|
end
|
77
18
|
|
78
|
-
def
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
case essence.link_target
|
84
|
-
when '1'
|
85
|
-
if essence.update_column(:link_target, 'blank')
|
86
|
-
log("Updated #{essence.preview_text} link target to #{essence.link_target}.")
|
87
|
-
end
|
88
|
-
when '0'
|
89
|
-
essence.update_column(:link_target, nil)
|
90
|
-
log("Updated #{essence.preview_text} link target to #{essence.link_target.inspect}.")
|
91
|
-
else
|
92
|
-
log("#{essence.preview_text} already upgraded.", :skip)
|
93
|
-
end
|
94
|
-
end
|
95
|
-
else
|
96
|
-
log("No essences to upgrade found.", :skip)
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
# Updates all essence_type of Content if not already namespaced.
|
101
|
-
def upgrade_to_namespaced_essence_type
|
102
|
-
desc "Namespacing essence_type columns"
|
103
|
-
depricated_contents = Alchemy::Content.where("essence_type LIKE ?", "Essence%")
|
104
|
-
if depricated_contents.any?
|
105
|
-
success = 0
|
106
|
-
errors = []
|
107
|
-
depricated_contents.each do |c|
|
108
|
-
if c.update_column(:essence_type, c.essence_type.gsub(/^Essence/, 'Alchemy::Essence'))
|
109
|
-
success += 1
|
110
|
-
else
|
111
|
-
errors << c.errors.full_messages
|
112
|
-
end
|
113
|
-
end
|
114
|
-
log("Namespaced #{success} essence_type columns.") if success > 0
|
115
|
-
log("#{errors.count} errors while namespacing essence_type columns.\n#{errors.join('\n')}", :error) if errors.count > 0
|
116
|
-
else
|
117
|
-
log "No essence_type columns to be namespaced found.", :skip
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
def strip_alchemy_from_schema_version_table
|
122
|
-
desc "Strip -alchemy suffix from schema_version table."
|
123
|
-
database_yml = YAML.load_file(Rails.root.join("config", "database.yml"))
|
124
|
-
adapter = ActiveRecord::Base.establish_connection(database_yml.fetch(Rails.env.to_s).symbolize_keys)
|
125
|
-
adapter.connection.update("UPDATE schema_migrations SET version = REPLACE(`schema_migrations`.`version`,'-alchemy','')")
|
126
|
-
end
|
127
|
-
|
128
|
-
def convert_essence_texts_displayed_as_select_into_essence_selects
|
129
|
-
desc "Converting EssenceTexts displayed as select into EssenceSelects"
|
130
|
-
contents_found = 0
|
131
|
-
elements = Alchemy::Element.descriptions.select { |e| e['contents'].present? && !e['contents'].detect { |c| c['settings'].present? && c['settings']['display_as'] == 'select' }.nil? }
|
132
|
-
contents = elements.collect { |el| el['contents'] }.flatten.select { |c| c['settings'] && c['settings']['display_as'] == 'select' }.flatten
|
133
|
-
content_names = contents.collect { |c| c['name'] }
|
134
|
-
Alchemy::Content.essence_texts.where(
|
135
|
-
:name => content_names,
|
136
|
-
:alchemy_elements => {:name => elements.collect { |e| e['name'] }}
|
137
|
-
).joins(:element).each do |content|
|
138
|
-
new_content = Alchemy::Content.new(:name => content.name, :element_id => content.element.id)
|
139
|
-
if new_content.create_essence!('name' => content.name, 'type' => 'EssenceSelect')
|
140
|
-
new_content.essence.value = content.ingredient
|
141
|
-
if new_content.essence.save
|
142
|
-
contents_found += 1
|
143
|
-
log "Converted #{content.name}'s essence_type into EssenceSelect"
|
144
|
-
content.destroy
|
145
|
-
else
|
146
|
-
log "Could not save essence: #{new_content.essence.errors.full_messages.join(', ')}", :error
|
147
|
-
end
|
148
|
-
else
|
149
|
-
log "Could not create content: #{new_content.errors.full_messages.join(', ')}", :error
|
150
|
-
end
|
151
|
-
end
|
152
|
-
if contents_found > 0
|
153
|
-
todo "Please open your elements.yml file and change all type values from these contents:\n\n#{content_names.join(', ')}\n\ninto EssenceSelect."
|
154
|
-
else
|
155
|
-
log "No EssenceTexts with display_as select setting found.", :skip
|
156
|
-
end
|
19
|
+
def run_all
|
20
|
+
Rake::Task['alchemy:install:migrations'].invoke
|
21
|
+
Rake::Task['db:migrate'].invoke
|
22
|
+
Seeder.seed!
|
23
|
+
copy_new_config_file
|
157
24
|
end
|
158
25
|
|
159
|
-
|
160
|
-
desc "Converting EssenceTexts displayed as checkbox into EssenceBooleans"
|
161
|
-
contents_found = 0
|
162
|
-
elements = Alchemy::Element.descriptions.select { |e| e['contents'].present? && !e['contents'].detect { |c| c['settings'].present? && c['settings']['display_as'] == 'checkbox' }.nil? }
|
163
|
-
contents = elements.collect { |el| el['contents'] }.flatten.select { |c| c['settings'] && c['settings']['display_as'] == 'checkbox' }.flatten
|
164
|
-
content_names = contents.collect { |c| c['name'] }
|
165
|
-
Alchemy::Content.essence_texts.where(
|
166
|
-
:name => content_names,
|
167
|
-
:alchemy_elements => {:name => elements.collect { |e| e['name'] }}
|
168
|
-
).joins(:element).each do |content|
|
169
|
-
new_content = Alchemy::Content.new(:name => content.name, :element_id => content.element.id)
|
170
|
-
if new_content.create_essence!('name' => content.name, 'type' => 'EssenceBoolean')
|
171
|
-
new_content.essence.value = content.ingredient
|
172
|
-
if new_content.essence.save
|
173
|
-
contents_found += 1
|
174
|
-
log "Converted #{content.name}'s essence_type into EssenceBoolean"
|
175
|
-
content.destroy
|
176
|
-
else
|
177
|
-
log "Could not save essence: #{new_content.essence.errors.full_messages.join(', ')}", :error
|
178
|
-
end
|
179
|
-
else
|
180
|
-
log "Could not create content: #{new_content.errors.full_messages.join(', ')}", :error
|
181
|
-
end
|
182
|
-
end
|
183
|
-
if contents_found > 0
|
184
|
-
todo "Please open your elements.yml file and change all type values from these contents:\n\n#{content_names.join(', ')}\n\ninto EssenceBoolean."
|
185
|
-
else
|
186
|
-
log "No EssenceTexts with display_as checkbox setting found.", :skip
|
187
|
-
end
|
188
|
-
end
|
26
|
+
private
|
189
27
|
|
190
28
|
def copy_new_config_file
|
191
29
|
desc "Copy configuration file."
|
@@ -201,106 +39,6 @@ module Alchemy
|
|
201
39
|
end
|
202
40
|
end
|
203
41
|
|
204
|
-
def gallery_pictures_change_notice
|
205
|
-
txt = ["We have changed the way Alchemy handles EssencePictures in elements."]
|
206
|
-
txt << "It is now possible to have single EssencePictures and galleries side by side in the same element."
|
207
|
-
txt << "All element editor views containing render_picture_editor with option `maximum_amount_of_images => 1` must be changed into render_essence_editor_by_name."
|
208
|
-
txt << "In the yml description of these elements add a new content for this picture."
|
209
|
-
txt << "\nIn order to upgrade your elements in the database run:"
|
210
|
-
txt << "\nrails g alchemy:gallery_pictures_migration\n"
|
211
|
-
txt << "and alter `db/seeds.rb`, so that it contains all elements that have essence pictures."
|
212
|
-
todo txt.join("\n")
|
213
|
-
end
|
214
|
-
|
215
|
-
def removed_richmedia_essences_notice
|
216
|
-
warn = <<-WARN
|
217
|
-
We removed the EssenceAudio, EssenceFlash and EssenceVideo essences from Alchemy core!
|
218
|
-
In order to get the essences back, install the `alchemy-richmedia-essences` gem.
|
219
|
-
|
220
|
-
gem 'alchemy-richmedia-essences'
|
221
|
-
|
222
|
-
We left the tables in your database, you can simply drop them if you don't use these essences in your project.
|
223
|
-
|
224
|
-
drop_table :alchemy_essence_audios
|
225
|
-
drop_table :alchemy_essence_flashes
|
226
|
-
drop_table :alchemy_essence_videos
|
227
|
-
WARN
|
228
|
-
todo warn
|
229
|
-
end
|
230
|
-
|
231
|
-
def convert_picture_storage
|
232
|
-
desc "Convert the picture storage"
|
233
|
-
converted_images = []
|
234
|
-
images = Dir.glob Rails.root.join 'uploads/pictures/**/*.*'
|
235
|
-
if images.blank?
|
236
|
-
log "No pictures found", :skip
|
237
|
-
else
|
238
|
-
images.each do |image|
|
239
|
-
image_uid = image.gsub(/#{Rails.root.to_s}\/uploads\/pictures\//, '')
|
240
|
-
image_id = image_uid.split('/').last.split('.').first
|
241
|
-
picture = Alchemy::Picture.find_by_id(image_id)
|
242
|
-
if picture && picture.image_file_uid.blank?
|
243
|
-
picture.image_file_uid = image_uid
|
244
|
-
picture.image_file_size = File.new(image).size
|
245
|
-
if picture.save!
|
246
|
-
log "Converted #{image_uid}"
|
247
|
-
end
|
248
|
-
else
|
249
|
-
log "Picture with id #{image_id} not found or already converted.", :skip
|
250
|
-
end
|
251
|
-
end
|
252
|
-
end
|
253
|
-
end
|
254
|
-
|
255
|
-
def removed_standard_set_notice
|
256
|
-
warn = <<-WARN
|
257
|
-
We removed the standard set from Alchemy core!
|
258
|
-
In order to get the standard set back, install the `alchemy-demo_kit` gem.
|
259
|
-
WARN
|
260
|
-
todo warn
|
261
|
-
end
|
262
|
-
|
263
|
-
def renamed_t_method
|
264
|
-
warn = <<-WARN
|
265
|
-
We renamed alchemy's `t` method override into `_t` to avoid conflicts with Rails own t method!
|
266
|
-
If you use the `t` method to translate alchemy scoped keys, then you have to use the `_t` method from now on.
|
267
|
-
WARN
|
268
|
-
todo warn
|
269
|
-
end
|
270
|
-
|
271
|
-
def migrated_to_devise
|
272
|
-
warn = <<-WARN
|
273
|
-
We changed the authentication provider from Authlogic to Devise.
|
274
|
-
|
275
|
-
If you are upgrading from an old Alchemy version < 2.5.0, then you have to make changes to your Devise configuration.
|
276
|
-
|
277
|
-
1. Run:
|
278
|
-
|
279
|
-
$ rails g alchemy:devise
|
280
|
-
|
281
|
-
And alter the encryptor to authlogic_sha512
|
282
|
-
and the stretches value from 10 to 20
|
283
|
-
|
284
|
-
# config/initializers/devise.rb
|
285
|
-
config.stretches = Rails.env.test? ? 1 : 20
|
286
|
-
config.encryptor = :authlogic_sha512
|
287
|
-
|
288
|
-
2. Add the encryptable module to your Alchemy config.yml:
|
289
|
-
|
290
|
-
# config/alchemy/config.yml
|
291
|
-
devise_modules:
|
292
|
-
- :database_authenticatable
|
293
|
-
- :trackable
|
294
|
-
- :validatable
|
295
|
-
- :timeoutable
|
296
|
-
- :recoverable
|
297
|
-
- :encryptable
|
298
|
-
|
299
|
-
WARN
|
300
|
-
todo warn
|
301
|
-
end
|
302
|
-
|
303
42
|
end
|
304
|
-
|
305
43
|
end
|
306
44
|
end
|