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
@@ -64,12 +64,20 @@ module Alchemy
|
|
64
64
|
end
|
65
65
|
alias_method :render_picture_editor, :render_picture_gallery_editor
|
66
66
|
|
67
|
-
# Returns
|
68
|
-
#
|
67
|
+
# Returns a elements options string for select helper.
|
68
|
+
#
|
69
|
+
# @param [Array] elements descriptions
|
70
|
+
# @return [String]
|
71
|
+
#
|
69
72
|
def elements_for_select(elements)
|
70
73
|
return [] if elements.nil?
|
71
|
-
options = elements.collect
|
72
|
-
|
74
|
+
options = elements.collect do |e|
|
75
|
+
[
|
76
|
+
_t(e['name'], scope: 'element_names', default: e['name'].to_s.humanize),
|
77
|
+
e['name']
|
78
|
+
]
|
79
|
+
end
|
80
|
+
options_for_select(options)
|
73
81
|
end
|
74
82
|
|
75
83
|
# Returns all elements that could be placed on that page because of the pages layout.
|
@@ -106,7 +114,7 @@ module Alchemy
|
|
106
114
|
]
|
107
115
|
else
|
108
116
|
[
|
109
|
-
|
117
|
+
_t(e['name'], scope: :element_names, default: e['name'].to_s.humanize),
|
110
118
|
e[object_method] + (cell ? "##{cell['name']}" : "")
|
111
119
|
]
|
112
120
|
end
|
@@ -22,7 +22,7 @@ module Alchemy
|
|
22
22
|
# * editor_options (Hash) - Will be passed to the render_essence_editor partial renderer
|
23
23
|
#
|
24
24
|
def render_essence_editor_by_type(element, essence_type, options = {}, editor_options = {})
|
25
|
-
return warning('Element is nil', _t(
|
25
|
+
return warning('Element is nil', _t(:no_element_given)) if element.blank?
|
26
26
|
return warning('EssenceType is blank', _t("No EssenceType given")) if essence_type.blank?
|
27
27
|
defaults = {
|
28
28
|
:position => 1,
|
@@ -68,7 +68,7 @@ module Alchemy
|
|
68
68
|
#
|
69
69
|
def render_essence_editor_by_name(element, name, options = {}, html_options = {})
|
70
70
|
if element.blank?
|
71
|
-
return warning('Element is nil', _t(
|
71
|
+
return warning('Element is nil', _t(:no_element_given))
|
72
72
|
end
|
73
73
|
content = element.content_by_name(name)
|
74
74
|
if content.nil?
|
@@ -141,9 +141,7 @@ module Alchemy
|
|
141
141
|
}.merge(image_options)),
|
142
142
|
:alt => content.ingredient.name,
|
143
143
|
:class => 'img_paddingtop',
|
144
|
-
:title => _t(
|
145
|
-
:onload => "Alchemy.fadeImage(this, '##{content_dom_id(content)} .picture_content_spinner');",
|
146
|
-
:style => "display: none;"
|
144
|
+
:title => _t(:image_name) + ": #{content.ingredient.name}"
|
147
145
|
)
|
148
146
|
end
|
149
147
|
|
@@ -19,12 +19,14 @@ module Alchemy
|
|
19
19
|
Alchemy.Tinymce = {
|
20
20
|
init : function(callback) {
|
21
21
|
var init = { #{init} };
|
22
|
+
var spinner = Alchemy.Spinner.small();
|
23
|
+
$('.tinymce_container').prepend(spinner.spin().el);
|
22
24
|
init.mode = 'specific_textareas';
|
23
25
|
init.editor_selector = 'default_tinymce';
|
24
26
|
init.plugins = '#{Alchemy::Tinymce.plugins.join(',')}';
|
25
27
|
init.language = '#{::I18n.locale.to_s.split('-')[0].downcase }';
|
26
28
|
init.init_instance_callback = function(inst) {
|
27
|
-
$('#' + inst.editorId).prev('.
|
29
|
+
$('#' + inst.editorId).prev('.spinner').remove();
|
28
30
|
}
|
29
31
|
if (callback)
|
30
32
|
init.oninit = callback;
|
@@ -67,9 +69,10 @@ module Alchemy
|
|
67
69
|
init.language = '#{::I18n.locale.to_s.split('-')[0].downcase }';
|
68
70
|
init.init_instance_callback = function(inst) {
|
69
71
|
var $this = $('#' + inst.editorId);
|
70
|
-
$this.
|
72
|
+
var parent = $this.parents('.element_editor');
|
73
|
+
parent.find('.spinner').remove();
|
71
74
|
inst.onChange.add(function (ed, l) {
|
72
|
-
Alchemy.setElementDirty(
|
75
|
+
Alchemy.setElementDirty(parent);
|
73
76
|
});
|
74
77
|
}
|
75
78
|
tinymce.init(init);
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module Alchemy
|
2
|
+
module Admin
|
3
|
+
module TagsHelper
|
4
|
+
|
5
|
+
# Checks if the tagged_with param contains the given tag
|
6
|
+
def filtered_by_tag?(tag)
|
7
|
+
if params[:tagged_with].present?
|
8
|
+
tags = params[:tagged_with].split(',')
|
9
|
+
tags.include?(tag.name)
|
10
|
+
else
|
11
|
+
false
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
# Adds the given tag to the tag filter.
|
16
|
+
def add_to_tag_filter(tag)
|
17
|
+
if params[:tagged_with].present?
|
18
|
+
tags = params[:tagged_with].split(',')
|
19
|
+
tags << tag.name
|
20
|
+
else
|
21
|
+
[tag.name]
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
# Removes the given tag from the tag filter.
|
26
|
+
def remove_from_tag_filter(tag)
|
27
|
+
if params[:tagged_with].present?
|
28
|
+
tags = params[:tagged_with].split(',')
|
29
|
+
tags.delete_if { |t| t == tag.name }
|
30
|
+
else
|
31
|
+
[]
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# Returns the tag filter from params.
|
36
|
+
#
|
37
|
+
# A tag can be added to the filter.
|
38
|
+
# A tag can also be removed.
|
39
|
+
#
|
40
|
+
# Options are:
|
41
|
+
# * options (Hash):
|
42
|
+
# ** :add (ActsAsTaggableOn::Tag) - The tag that should be added to the tag-filter
|
43
|
+
# ** :remove (ActsAsTaggableOn::Tag) - The tag that should be removed from the tag-filter
|
44
|
+
#
|
45
|
+
def tag_filter(options={})
|
46
|
+
case
|
47
|
+
when options[:add]
|
48
|
+
taglist = add_to_tag_filter(options[:add]) if options[:add]
|
49
|
+
when options[:remove]
|
50
|
+
taglist = remove_from_tag_filter(options[:remove]) if options[:remove]
|
51
|
+
else
|
52
|
+
return params[:tagged_with]
|
53
|
+
end
|
54
|
+
return nil if taglist.blank?
|
55
|
+
taglist.uniq.join(',')
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -69,26 +69,7 @@ module Alchemy
|
|
69
69
|
# I.e. used to find the active page in navigation.
|
70
70
|
def breadcrumb(current)
|
71
71
|
return [] if current.nil?
|
72
|
-
|
73
|
-
result << current
|
74
|
-
while current = current.parent
|
75
|
-
result << current
|
76
|
-
end
|
77
|
-
return result.reverse
|
78
|
-
end
|
79
|
-
|
80
|
-
# Returns a hash with urlname for each url level.
|
81
|
-
# I.e.: +{:level1 => 'company', :level2 => 'history'}+
|
82
|
-
def params_for_nested_url(page = nil)
|
83
|
-
page ||= @page
|
84
|
-
raise ArgumentError if page.nil?
|
85
|
-
nested_urL_params = {}
|
86
|
-
page_bread_crumb = breadcrumb(page)
|
87
|
-
urlnames = page_bread_crumb[2..page_bread_crumb.length-2].collect(&:urlname)
|
88
|
-
urlnames.each_with_index do |urlname, i|
|
89
|
-
nested_urL_params["level#{i+1}"] = urlname
|
90
|
-
end
|
91
|
-
nested_urL_params.symbolize_keys
|
72
|
+
current.self_and_ancestors.where("parent_id IS NOT NULL")
|
92
73
|
end
|
93
74
|
|
94
75
|
# Returns the Alchemy configuration.
|
@@ -120,5 +101,20 @@ module Alchemy
|
|
120
101
|
render('alchemy/admin/partials/flash', flash_type: style, message: notice)
|
121
102
|
end
|
122
103
|
|
104
|
+
# Checks if the given argument is a String or a Page object.
|
105
|
+
# If a String is given, it tries to find the page via page_layout
|
106
|
+
# Logs a warning if no page is given.
|
107
|
+
def page_or_find(page)
|
108
|
+
if page.is_a?(String)
|
109
|
+
page = Page.where(page_layout: page, language_id: session[:language_id]).first
|
110
|
+
end
|
111
|
+
if page.blank?
|
112
|
+
warning("No Page found for #{page.inspect}")
|
113
|
+
return
|
114
|
+
else
|
115
|
+
page
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
123
119
|
end
|
124
120
|
end
|
@@ -11,9 +11,9 @@ module Alchemy
|
|
11
11
|
#
|
12
12
|
# :only => [] # A list of element names to be rendered only. Very useful if you want to render a specific element type in a special html part (e.g.. <div>) of your page and all other elements in another part.
|
13
13
|
# :except => [] # A list of element names to be rendered. The opposite of the only option.
|
14
|
-
# :from_page
|
15
|
-
# :from_cell
|
16
|
-
# :count
|
14
|
+
# :from_page => @page # The Alchemy::Page.page_layout string from which the elements are rendered from, or you even pass a Page object.
|
15
|
+
# :from_cell => nil # The Cell object from which the elements are rendered from.
|
16
|
+
# :count => nil # The amount of elements to be rendered (begins with first element found)
|
17
17
|
# :fallback => { # You can use the fallback option as an override. So you can take elements from a glo´bal laout page and only if the user adds an element on current page the local one gets rendered.
|
18
18
|
# :for => 'ELEMENT_NAME', # The name of the element the fallback is for
|
19
19
|
# :with => 'ELEMENT_NAME', # (OPTIONAL) the name of element to fallback with
|
@@ -30,7 +30,7 @@ module Alchemy
|
|
30
30
|
default_options = {
|
31
31
|
:except => [],
|
32
32
|
:only => [],
|
33
|
-
:from_page =>
|
33
|
+
:from_page => @page,
|
34
34
|
:from_cell => nil,
|
35
35
|
:count => nil,
|
36
36
|
:offset => nil,
|
@@ -39,14 +39,10 @@ module Alchemy
|
|
39
39
|
:fallback => nil
|
40
40
|
}
|
41
41
|
options = default_options.merge(options)
|
42
|
-
if options[:from_page].
|
43
|
-
page =
|
42
|
+
if options[:from_page].class == Page
|
43
|
+
page = options[:from_page]
|
44
44
|
else
|
45
|
-
|
46
|
-
page = options[:from_page]
|
47
|
-
else
|
48
|
-
page = Page.where(:page_layout => options[:from_page]).with_language(session[:language_id]).all
|
49
|
-
end
|
45
|
+
page = Page.where(:page_layout => options[:from_page]).with_language(session[:language_id]).all
|
50
46
|
end
|
51
47
|
if page.blank?
|
52
48
|
warning('Page is nil')
|
@@ -110,9 +110,9 @@ module Alchemy
|
|
110
110
|
def render_essence(content, part = :view, options = {}, html_options = {})
|
111
111
|
options = {:for_view => {}, :for_editor => {}}.update(options)
|
112
112
|
if content.nil?
|
113
|
-
return part == :view ? "" : warning('Content is nil', _t(
|
113
|
+
return part == :view ? "" : warning('Content is nil', _t(:content_not_found))
|
114
114
|
elsif content.essence.nil?
|
115
|
-
return part == :view ? "" : warning('Essence is nil', _t(
|
115
|
+
return part == :view ? "" : warning('Essence is nil', _t(:content_essence_not_found))
|
116
116
|
end
|
117
117
|
render(
|
118
118
|
:partial => "alchemy/essences/#{content.essence_partial_name}_#{part.to_s}",
|
@@ -131,57 +131,45 @@ module Alchemy
|
|
131
131
|
# :submenu => false # Do you want a nested <ul> <li> structure for the deeper levels of your navigation, or not? Used to display the subnavigation within the mainnaviagtion. E.g. for dropdown menues.
|
132
132
|
# :all_sub_menues => false # Renders the whole page tree.
|
133
133
|
# :from_page => @root_page # Do you want to render a navigation from a different page then the current page? Then pass an Page instance or a Alchemy::PageLayout name as string.
|
134
|
-
# :spacer =>
|
135
|
-
# :navigation_partial => "navigation/renderer" # Pass a different partial to be taken for the navigation rendering.
|
134
|
+
# :spacer => nil # A spacer for the entries can be passed. Simple string, or even a complex html structure. E.g: "<span class='spacer'>|</spacer>".
|
135
|
+
# :navigation_partial => "navigation/renderer" # Pass a different partial to be taken for the navigation rendering.
|
136
136
|
# :navigation_link_partial => "navigation/link" # Alchemy places an <a> html link in <li> tags. The tag automatically has an active css class if necessary. So styling is everything. But maybe you don't want this. So feel free to make you own partial and pass the filename here.
|
137
137
|
# :show_nonactive => false # Commonly Alchemy only displays the submenu of the active page (if :submenu => true). If you want to display all child pages then pass true (together with :submenu => true of course). E.g. for the popular css-driven dropdownmenues these days.
|
138
138
|
# :show_title => true # For our beloved SEOs :). Appends a title attribute to all links and places the page.title content into it.
|
139
|
-
# :restricted_only =>
|
139
|
+
# :restricted_only => false # Render only restricted pages. I.E for members only navigations.
|
140
140
|
# :show_title => true # Show a title on navigation links. Title attribute from page.
|
141
141
|
# :reverse => false # Reverse the navigation
|
142
142
|
# :reverse_children => false # Reverse the nested children
|
143
|
+
# :deepness => nil # Show only pages up to this depth.
|
143
144
|
#
|
144
145
|
# === Passing HTML classes and ids to the renderer
|
145
146
|
#
|
146
|
-
# A second hash
|
147
|
+
# A second hash can be passed as html_options to the navigation renderer partial.
|
147
148
|
#
|
148
149
|
# ==== Example:
|
149
150
|
#
|
150
151
|
# <%= render_navigation({from_page => 'subnavi'}, {:class => 'navigation', :id => 'subnavigation'}) %>
|
151
152
|
#
|
152
153
|
def render_navigation(options = {}, html_options = {})
|
153
|
-
|
154
|
+
options = {
|
154
155
|
:submenu => false,
|
155
156
|
:all_sub_menues => false,
|
156
157
|
:from_page => @root_page || Page.language_root_for(session[:language_id]),
|
157
|
-
:spacer =>
|
158
|
+
:spacer => nil,
|
158
159
|
:navigation_partial => "alchemy/navigation/renderer",
|
159
160
|
:navigation_link_partial => "alchemy/navigation/link",
|
160
161
|
:show_nonactive => false,
|
161
|
-
:restricted_only =>
|
162
|
+
:restricted_only => false,
|
162
163
|
:show_title => true,
|
163
164
|
:reverse => false,
|
164
165
|
:reverse_children => false
|
165
|
-
}
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
166
|
+
}.merge(options)
|
167
|
+
page = page_or_find(options[:from_page])
|
168
|
+
pages = page.children.visible.with_permissions_to(:show, :context => :alchemy_pages)
|
169
|
+
pages = pages.restricted if options.delete(:restricted_only)
|
170
|
+
if depth = options[:deepness]
|
171
|
+
pages = pages.where("#{Page.table_name}.depth <= #{depth}")
|
171
172
|
end
|
172
|
-
if page.blank?
|
173
|
-
warning("No Page found for #{options[:from_page]}")
|
174
|
-
return ""
|
175
|
-
end
|
176
|
-
conditions = {
|
177
|
-
:parent_id => page.id,
|
178
|
-
:restricted => options[:restricted_only] || false,
|
179
|
-
:visible => true
|
180
|
-
}
|
181
|
-
if options[:restricted_only].nil?
|
182
|
-
conditions.delete(:restricted)
|
183
|
-
end
|
184
|
-
pages = Page.where(conditions).order("lft ASC")
|
185
173
|
if options[:reverse]
|
186
174
|
pages.reverse!
|
187
175
|
end
|
@@ -240,60 +228,34 @@ module Alchemy
|
|
240
228
|
#
|
241
229
|
# :seperator => %(<span class="seperator">></span>) # Maybe you don't want this seperator. Pass another one.
|
242
230
|
# :page => @page # Pass a different Page instead of the default (@page).
|
243
|
-
# :without => nil # Pass
|
244
|
-
# :public_only => false # Pass boolean for displaying published pages only.
|
245
|
-
# :visible_only => true # Pass boolean for displaying (in navigation) visible pages only.
|
231
|
+
# :without => nil # Pass Page object or array of Pages that must not be displayed.
|
246
232
|
# :restricted_only => false # Pass boolean for displaying restricted pages only.
|
247
|
-
# :reverse => false # Pass boolean for displaying reversed
|
233
|
+
# :reverse => false # Pass boolean for displaying breadcrumb in reversed reversed.
|
248
234
|
#
|
249
235
|
def render_breadcrumb(options={})
|
250
|
-
|
236
|
+
options = {
|
251
237
|
:seperator => %(<span class="seperator">></span>),
|
252
238
|
:page => @page,
|
253
|
-
:without => nil,
|
254
|
-
:public_only => true,
|
255
|
-
:visible_only => true,
|
256
239
|
:restricted_only => false,
|
257
240
|
:reverse => false,
|
258
241
|
:link_active_page => false
|
259
|
-
}
|
260
|
-
|
261
|
-
pages =
|
262
|
-
pages.
|
263
|
-
|
264
|
-
|
265
|
-
pages.
|
242
|
+
}.merge(options)
|
243
|
+
pages = breadcrumb(options[:page]).published.visible.with_permissions_to(:show, :context => :alchemy_pages)
|
244
|
+
pages = pages.restricted if options.delete(:restricted_only)
|
245
|
+
pages.to_a.reverse! if options[:reverse]
|
246
|
+
if options[:without].present?
|
247
|
+
if options[:without].class == Array
|
248
|
+
pages = pages.to_a - options[:without]
|
266
249
|
else
|
267
|
-
pages
|
250
|
+
pages.to_a.delete(options[:without])
|
268
251
|
end
|
269
252
|
end
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
if options[:restricted_only]
|
277
|
-
pages.reject! { |p| !p.restricted? }
|
278
|
-
end
|
279
|
-
if options[:reverse]
|
280
|
-
pages.reverse!
|
281
|
-
end
|
282
|
-
bc = []
|
283
|
-
pages.each do |page|
|
284
|
-
css_class = page.name == @page.name ? "active" : nil
|
285
|
-
if page == pages.last
|
286
|
-
css_class = css_class.blank? ? "last" : [css_class, "last"].join(" ")
|
287
|
-
elsif page == pages.first
|
288
|
-
css_class = css_class.blank? ? "first" : [css_class, "first"].join(" ")
|
289
|
-
end
|
290
|
-
if !options[:link_active_page] && page.name == @page.name
|
291
|
-
bc << content_tag(:span, h(page.name), :class => css_class)
|
292
|
-
else
|
293
|
-
bc << link_to(h(page.name), show_alchemy_page_path(page), :class => css_class, :title => page.title)
|
294
|
-
end
|
295
|
-
end
|
296
|
-
bc.join(options[:seperator]).html_safe
|
253
|
+
render(
|
254
|
+
partial: 'alchemy/breadcrumb/page',
|
255
|
+
collection: pages,
|
256
|
+
spacer_template: 'alchemy/breadcrumb/spacer',
|
257
|
+
locals: {pages: pages, options: options}
|
258
|
+
)
|
297
259
|
end
|
298
260
|
|
299
261
|
# Returns current page title
|
@@ -77,11 +77,19 @@ module Alchemy
|
|
77
77
|
# Returns the correct params-hash for passing to show_page_path
|
78
78
|
def show_page_path_params(page, optional_params={})
|
79
79
|
raise ArgumentError, 'Page is nil' if page.nil?
|
80
|
-
url_params = {:
|
81
|
-
url_params.update(optional_params)
|
82
|
-
url_params.update(params_for_nested_url(page)) if configuration(:url_nesting)
|
80
|
+
url_params = {:urlname => page.urlname}.update(optional_params)
|
83
81
|
multi_language? ? url_params.update(:lang => page.language_code) : url_params
|
84
82
|
end
|
85
83
|
|
84
|
+
# Returns the path for downloading an alchemy attachment
|
85
|
+
def download_alchemy_attachment_path(attachment)
|
86
|
+
alchemy.download_attachment_path(attachment, attachment.urlname)
|
87
|
+
end
|
88
|
+
|
89
|
+
# Returns the url for downloading an alchemy attachment
|
90
|
+
def download_alchemy_attachment_url(attachment)
|
91
|
+
alchemy.download_attachment_url(attachment, attachment.urlname)
|
92
|
+
end
|
93
|
+
|
86
94
|
end
|
87
95
|
end
|
@@ -1,33 +1,52 @@
|
|
1
1
|
module Alchemy
|
2
2
|
class Attachment < ActiveRecord::Base
|
3
|
+
include Filetypes
|
4
|
+
include NameConversions
|
5
|
+
|
6
|
+
acts_as_taggable
|
7
|
+
file_accessor :file
|
8
|
+
stampable :stamper_class_name => 'Alchemy::User'
|
9
|
+
|
10
|
+
attr_accessible :file, :name, :file_name, :tag_list
|
3
11
|
|
4
12
|
has_many :essence_files, :class_name => 'Alchemy::EssenceFile', :foreign_key => 'attachment_id'
|
5
13
|
has_many :contents, :through => :essence_files
|
6
14
|
has_many :elements, :through => :contents
|
7
15
|
has_many :pages, :through => :elements
|
8
16
|
|
9
|
-
|
17
|
+
validates_presence_of :file
|
18
|
+
validates_format_of :file_name, :with => /^[A-Za-z0-9\.\-_]+$/, :on => :update
|
19
|
+
validates_size_of :file, :maximum => Config.get(:uploader)['file_size_limit'].megabytes
|
20
|
+
validates_property(
|
21
|
+
:format,
|
22
|
+
:of => :file,
|
23
|
+
:in => Config.get(:uploader)['allowed_filetypes']['attachments'],
|
24
|
+
:case_sensitive => false,
|
25
|
+
:message => I18n.t("not a valid file"),
|
26
|
+
:unless => proc { Config.get(:uploader)['allowed_filetypes']['attachments'].include?('*') }
|
27
|
+
)
|
28
|
+
|
29
|
+
before_create do
|
30
|
+
write_attribute(:name, convert_to_humanized_name(self.file_name, self.file.ext))
|
31
|
+
write_attribute(:file_name, sanitized_filename)
|
32
|
+
end
|
10
33
|
|
11
|
-
|
34
|
+
# Class methods
|
12
35
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
36
|
+
class << self
|
37
|
+
|
38
|
+
def find_paginated(params, per_page, order)
|
39
|
+
attachments = Attachment.arel_table
|
40
|
+
cond = attachments[:name].matches("%#{params[:query]}%").or(attachments[:file_name].matches("%#{params[:query]}%"))
|
41
|
+
self.where(cond).page(params[:page] || 1).per(per_page).order(order)
|
42
|
+
end
|
20
43
|
|
21
|
-
def self.find_paginated(params, per_page)
|
22
|
-
attachments = Attachment.arel_table
|
23
|
-
cond = attachments[:name].matches("%#{params[:query]}%").or(attachments[:filename].matches("%#{params[:query]}%"))
|
24
|
-
self.where(cond).page(params[:page] || 1).per(per_page).order(:name)
|
25
44
|
end
|
26
45
|
|
46
|
+
# Instance methods
|
47
|
+
|
27
48
|
def urlname
|
28
|
-
|
29
|
-
sfx = parts.pop
|
30
|
-
"#{parts.join('-')}.#{sfx}"
|
49
|
+
read_attribute :file_name
|
31
50
|
end
|
32
51
|
|
33
52
|
# Checks if the attachment is restricted, because it is attached on restricted pages only
|
@@ -36,41 +55,50 @@ module Alchemy
|
|
36
55
|
end
|
37
56
|
|
38
57
|
def extension
|
39
|
-
|
58
|
+
file_name.split(".").last
|
40
59
|
end
|
41
60
|
alias_method :suffix, :extension
|
42
61
|
|
62
|
+
# Returns a css class name for kind of file
|
63
|
+
#
|
43
64
|
def icon_css_class
|
44
|
-
case
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
when "application/vcard" then "vcard"
|
71
|
-
else "file"
|
65
|
+
case file_mime_type
|
66
|
+
when *ARCHIVE_FILE_TYPES
|
67
|
+
then "archive"
|
68
|
+
when *AUDIO_FILE_TYPES
|
69
|
+
then "audio"
|
70
|
+
when *IMAGE_FILE_TYPES
|
71
|
+
then "image"
|
72
|
+
when *VIDEO_FILE_TYPES
|
73
|
+
then "video"
|
74
|
+
when "application/x-shockwave-flash"
|
75
|
+
then "flash"
|
76
|
+
when "image/x-psd"
|
77
|
+
then "psd"
|
78
|
+
when "text/plain"
|
79
|
+
then "text"
|
80
|
+
when "application/rtf"
|
81
|
+
then "rtf"
|
82
|
+
when "application/pdf"
|
83
|
+
then "pdf"
|
84
|
+
when "application/msword"
|
85
|
+
then "word"
|
86
|
+
when "application/vnd.ms-excel"
|
87
|
+
then "excel"
|
88
|
+
when *VCARD_FILE_TYPES
|
89
|
+
then "vcard"
|
90
|
+
else "file"
|
72
91
|
end
|
73
92
|
end
|
74
93
|
|
94
|
+
private
|
95
|
+
|
96
|
+
def sanitized_filename
|
97
|
+
parts = self.file_name.split('.')
|
98
|
+
sfx = parts.pop
|
99
|
+
name = convert_to_urlname(parts.join('-'))
|
100
|
+
"#{name}.#{sfx}"
|
101
|
+
end
|
102
|
+
|
75
103
|
end
|
76
104
|
end
|