browsercms 3.4.2 → 3.5.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +1 -0
- data/app/assets/images/cms/file-uploading.gif +0 -0
- data/app/assets/javascripts/cms/application.js +1 -0
- data/app/assets/javascripts/cms/attachment_manager.js.erb +87 -0
- data/app/assets/javascripts/cms/core_library.js.erb +38 -25
- data/app/assets/stylesheets/cms/application.css.erb +1 -0
- data/app/assets/stylesheets/cms/attachment_manager.css.scss +28 -0
- data/app/controllers/cms/application_controller.rb +1 -1
- data/app/controllers/cms/attachments_controller.rb +45 -10
- data/app/controllers/cms/cache_controller.rb +1 -1
- data/app/controllers/cms/content_block_controller.rb +134 -122
- data/app/controllers/cms/content_controller.rb +143 -155
- data/app/controllers/cms/dashboard_controller.rb +11 -9
- data/app/controllers/cms/error_handling.rb +19 -7
- data/app/controllers/cms/file_blocks_controller.rb +2 -2
- data/app/controllers/cms/home_controller.rb +3 -0
- data/app/controllers/cms/section_nodes_controller.rb +52 -44
- data/app/controllers/cms/sections_controller.rb +4 -2
- data/app/controllers/cms/toolbar_controller.rb +14 -10
- data/app/helpers/cms/application_helper.rb +23 -19
- data/app/helpers/cms/form_builder.rb +65 -18
- data/app/helpers/cms/mobile_helper.rb +19 -0
- data/app/helpers/cms/path_helper.rb +30 -4
- data/app/helpers/cms/rendering_helper.rb +9 -1
- data/app/models/cms/abstract_file_block.rb +6 -6
- data/app/models/cms/attachment.rb +196 -107
- data/app/models/cms/category.rb +3 -0
- data/app/models/cms/category_type.rb +2 -0
- data/app/models/cms/connector.rb +3 -0
- data/app/models/cms/content_type.rb +3 -0
- data/app/models/cms/content_type_group.rb +2 -0
- data/app/models/cms/dynamic_view.rb +4 -0
- data/app/models/cms/email_message.rb +2 -0
- data/app/models/cms/file_block.rb +9 -2
- data/app/models/cms/group.rb +5 -2
- data/app/models/cms/group_permission.rb +2 -0
- data/app/models/cms/group_section.rb +3 -0
- data/app/models/cms/group_type.rb +2 -0
- data/app/models/cms/group_type_permission.rb +2 -0
- data/app/models/cms/html_block.rb +3 -2
- data/app/models/cms/image_block.rb +13 -2
- data/app/models/cms/page.rb +14 -3
- data/app/models/cms/page_route.rb +4 -0
- data/app/models/cms/page_route_condition.rb +1 -0
- data/app/models/cms/page_route_option.rb +2 -0
- data/app/models/cms/page_route_requirement.rb +1 -0
- data/app/models/cms/permission.rb +3 -0
- data/app/models/cms/portlet.rb +2 -2
- data/app/models/cms/redirect.rb +2 -0
- data/app/models/cms/section.rb +15 -1
- data/app/models/cms/section_node.rb +1 -0
- data/app/models/cms/site.rb +3 -0
- data/app/models/cms/tag.rb +2 -0
- data/app/models/cms/tagging.rb +3 -0
- data/app/models/cms/task.rb +5 -1
- data/app/models/cms/user.rb +1 -1
- data/app/models/cms/user_group_membership.rb +3 -0
- data/app/views/cms/attachments/_attachment.html.erb +14 -0
- data/app/views/cms/attachments/_attachment_table.html.erb +17 -0
- data/app/views/cms/attachments/_attachment_wrapper.html.erb +4 -0
- data/app/views/cms/blocks/index.html.erb +2 -3
- data/app/views/cms/blocks/show.html.erb +1 -1
- data/app/views/cms/dynamic_views/index.html.erb +1 -1
- data/app/views/cms/email_messages/index.html.erb +1 -1
- data/app/views/cms/file_blocks/_form.html.erb +1 -27
- data/app/views/cms/file_blocks/_section_selector.html.erb +13 -0
- data/app/views/cms/file_blocks/render.html.erb +3 -3
- data/app/views/cms/form_builder/_cms_attachment_manager.html.erb +26 -0
- data/app/views/cms/form_builder/_cms_file_field.html.erb +27 -35
- data/app/views/cms/groups/index.html.erb +1 -1
- data/app/views/cms/image_blocks/_form.html.erb +1 -27
- data/app/views/cms/image_blocks/render.html.erb +4 -1
- data/app/views/cms/page_routes/index.html.erb +3 -0
- data/app/views/cms/shared/error.xml.erb +8 -0
- data/app/views/cms/tags/render.html.erb +1 -1
- data/app/views/cms/toolbar/_mobile_toggle.html.erb +33 -0
- data/app/views/cms/users/index.html.erb +1 -1
- data/app/views/layouts/_page_toolbar.html.erb +2 -1
- data/bin/bcms +21 -26
- data/config/routes.rb +3 -2
- data/db/browsercms.seeds.rb +2 -1
- data/db/migrate/20111130221145_browsercms340.rb +5 -4
- data/db/migrate/20120329144406_browsercms350.rb +32 -0
- data/{test/dummy/db → db}/schema.rb +97 -128
- data/{performance_tuning_notes.md → doc/performance_tuning_notes.md} +0 -0
- data/doc/release_notes.md +74 -0
- data/lib/browsercms.rb +3 -0
- data/lib/cms/acts/content_block.rb +10 -2
- data/lib/cms/addressable.rb +8 -0
- data/lib/cms/attachments/attachment_serving.rb +59 -0
- data/lib/cms/attachments/configuration.rb +88 -0
- data/lib/cms/behaviors/attaching.rb +305 -136
- data/lib/cms/behaviors/connecting.rb +3 -4
- data/lib/cms/behaviors/dynamic_attributes.rb +121 -118
- data/lib/cms/behaviors/flush_cache_on_change.rb +1 -3
- data/lib/cms/behaviors/naming.rb +16 -0
- data/lib/cms/behaviors/pagination.rb +4 -1
- data/lib/cms/behaviors/publishing.rb +9 -3
- data/lib/cms/behaviors/searching.rb +3 -8
- data/lib/cms/behaviors/soft_deleting.rb +1 -0
- data/lib/cms/behaviors/taggable.rb +2 -0
- data/lib/cms/behaviors/versioning.rb +73 -120
- data/lib/cms/caching.rb +53 -11
- data/lib/cms/commands/actions.rb +19 -2
- data/lib/cms/configuration.rb +44 -0
- data/lib/cms/content_rendering_support.rb +9 -6
- data/lib/cms/default_accessible.rb +13 -0
- data/lib/cms/domain_support.rb +22 -0
- data/lib/cms/engine.rb +40 -19
- data/lib/cms/engine_helper.rb +54 -0
- data/lib/cms/extensions/active_record/connection_adapters/abstract/schema_statements.rb +14 -2
- data/lib/cms/mobile_aware.rb +67 -0
- data/lib/cms/route_extensions.rb +3 -0
- data/lib/cms/upgrades/v3_5_0.rb +155 -0
- data/lib/cms/version.rb +6 -1
- data/lib/generators/cms/content_block/content_block_generator.rb +14 -9
- data/lib/generators/cms/content_block/templates/_form.html.erb +17 -6
- data/lib/generators/cms/content_block/templates/render.html.erb +12 -5
- data/lib/generators/cms/template/template_generator.rb +11 -2
- data/lib/tasks/cms.rake +23 -0
- data/lib/templates/active_record/model/model.rb +6 -0
- metadata +127 -517
- data/.gitignore +0 -24
- data/.rvmrc +0 -2
- data/Gemfile +0 -29
- data/Gemfile.lock +0 -196
- data/Rakefile +0 -97
- data/app/assets/images/browsercms/.gitkeep +0 -0
- data/app/controllers/browsercms/application_controller.rb +0 -4
- data/browsercms.gemspec +0 -35
- data/config/cucumber.yml +0 -8
- data/config/database.jdbcmysql.yml +0 -30
- data/config/database.mysql.yml +0 -27
- data/config/database.postgres.yml +0 -25
- data/config/database.sqlite3.yml +0 -11
- data/config/environment.rb +0 -6
- data/config/initializers/query_reviewer_patch.rb +0 -12
- data/config/initializers/rack_1_2_1_patch.rb +0 -12
- data/config/locales/en.yml +0 -5
- data/features/acts_as_content_page.feature +0 -62
- data/features/add_content_to_pages.feature +0 -45
- data/features/caching.feature +0 -13
- data/features/ckeditor.feature +0 -11
- data/features/commands/confirm_aruba_works.feature +0 -24
- data/features/commands/generate_module.feature +0 -54
- data/features/commands/install_browsercms.feature +0 -21
- data/features/commands/new_demo_project.feature +0 -30
- data/features/commands/new_projects.feature +0 -50
- data/features/commands/upgrade_modules_to_3_4_0_from_3_1_x.feature +0 -19
- data/features/commands/upgrade_project_to_3_4_0_from_3_3_x.feature +0 -52
- data/features/commands/upgrading_modules.feature +0 -67
- data/features/content_blocks/manage_custom_blocks.feature +0 -67
- data/features/content_blocks/manage_html_blocks.feature +0 -48
- data/features/content_blocks/manage_image_blocks.feature +0 -41
- data/features/content_files.feature +0 -37
- data/features/content_pages.feature +0 -21
- data/features/generators/content_blocks_for_modules.feature +0 -58
- data/features/generators/content_blocks_for_projects.feature +0 -109
- data/features/install_content.feature +0 -25
- data/features/jquery-testplan.txt +0 -12
- data/features/manage_groups.feature +0 -33
- data/features/manage_page_routes.feature +0 -72
- data/features/manage_redirects.feature +0 -20
- data/features/manage_sections.feature +0 -12
- data/features/manage_tasks.feature +0 -25
- data/features/manage_users.feature +0 -38
- data/features/page_templates.feature +0 -49
- data/features/portlets/email_friend_portlet.feature +0 -29
- data/features/portlets/portlets.feature +0 -100
- data/features/portlets/tag_cloud_portlet.feature +0 -28
- data/features/sitemap/create_pages.feature +0 -15
- data/features/sitemap/manage_links.feature +0 -29
- data/features/sitemap/sitemap.feature +0 -18
- data/features/step_definitions/acts_as_content_page_steps.rb.rb +0 -3
- data/features/step_definitions/ckeditor_steps.rb +0 -13
- data/features/step_definitions/command_line_steps.rb +0 -212
- data/features/step_definitions/content_pages_steps.rb +0 -170
- data/features/step_definitions/data_steps.rb +0 -48
- data/features/step_definitions/edit_page_templates_steps.rb +0 -21
- data/features/step_definitions/html_blocks_steps.rb +0 -9
- data/features/step_definitions/install_content_steps.rb +0 -4
- data/features/step_definitions/manage_content_blocks_steps.rb +0 -26
- data/features/step_definitions/manage_image_blocks_steps.rb +0 -31
- data/features/step_definitions/manage_sections_steps.rb +0 -18
- data/features/step_definitions/manage_user_steps.rb +0 -22
- data/features/step_definitions/more_custom_block_steps.rb +0 -34
- data/features/step_definitions/page_route_steps.rb +0 -65
- data/features/step_definitions/page_template_steps.rb +0 -5
- data/features/step_definitions/permissions_steps.rb +0 -13
- data/features/step_definitions/portlets_steps.rb +0 -64
- data/features/step_definitions/redirect_steps.rb +0 -12
- data/features/step_definitions/sitemap_steps.rb +0 -18
- data/features/step_definitions/tag_cloud_steps.rb +0 -11
- data/features/step_definitions/task_steps.rb +0 -4
- data/features/step_definitions/taxonomy_steps.rb +0 -16
- data/features/step_definitions/upgrade_module_steps.rb +0 -76
- data/features/step_definitions/web_steps.rb +0 -211
- data/features/support/async_support.rb +0 -17
- data/features/support/command_line_helpers.rb +0 -63
- data/features/support/debug_formatter.rb +0 -7
- data/features/support/debugging.rb +0 -28
- data/features/support/env.rb +0 -73
- data/features/support/git_api.rb +0 -9
- data/features/support/open_on_first_failure.rb +0 -25
- data/features/support/paths.rb +0 -32
- data/features/support/rails_api.rb +0 -8
- data/features/support/selectors.rb +0 -39
- data/features/support/transforms.rb +0 -7
- data/features/taxonomy/add_content_with_category.feature +0 -30
- data/features/taxonomy/manage_categories.feature +0 -20
- data/features/taxonomy/manage_category_types.feature +0 -16
- data/lib/cms/init.rb +0 -105
- data/lib/tasks/data.rake +0 -43
- data/lib/tasks/db.rake +0 -82
- data/public/styled_file_field/index.html +0 -72
- data/script/cucumber +0 -10
- data/script/rails +0 -6
- data/test/console_helper.rb +0 -5
- data/test/custom_assertions.rb +0 -84
- data/test/dummy/Rakefile +0 -7
- data/test/dummy/app/assets/javascripts/application.js +0 -9
- data/test/dummy/app/assets/javascripts/content_page.js +0 -2
- data/test/dummy/app/assets/stylesheets/application.css +0 -7
- data/test/dummy/app/assets/stylesheets/content_page.css +0 -4
- data/test/dummy/app/controllers/application_controller.rb +0 -3
- data/test/dummy/app/controllers/cms/products_controller.rb +0 -2
- data/test/dummy/app/controllers/cms/sample_blocks_controller.rb +0 -3
- data/test/dummy/app/controllers/content_page_controller.rb +0 -13
- data/test/dummy/app/helpers/application_helper.rb +0 -2
- data/test/dummy/app/helpers/content_page_helper.rb +0 -2
- data/test/dummy/app/mailers/.gitkeep +0 -0
- data/test/dummy/app/models/.gitkeep +0 -0
- data/test/dummy/app/models/cms/sample_block.rb +0 -22
- data/test/dummy/app/models/product.rb +0 -5
- data/test/dummy/app/views/cms/products/_form.html.erb +0 -7
- data/test/dummy/app/views/cms/products/render.html.erb +0 -3
- data/test/dummy/app/views/content_page/custom_page.html.erb +0 -3
- data/test/dummy/app/views/content_page/index.html.erb +0 -2
- data/test/dummy/app/views/layouts/application.html.erb +0 -14
- data/test/dummy/app/views/layouts/templates/default.html.erb +0 -17
- data/test/dummy/app/views/layouts/templates/subpage.html.erb +0 -16
- data/test/dummy/app/views/test_route/index.html.erb +0 -14
- data/test/dummy/config.ru +0 -4
- data/test/dummy/config/application.rb +0 -45
- data/test/dummy/config/boot.rb +0 -10
- data/test/dummy/config/database.yml +0 -27
- data/test/dummy/config/environment.rb +0 -5
- data/test/dummy/config/environments/development.rb +0 -32
- data/test/dummy/config/environments/production.rb +0 -60
- data/test/dummy/config/environments/test.rb +0 -46
- data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/test/dummy/config/initializers/browsercms.rb +0 -7
- data/test/dummy/config/initializers/inflections.rb +0 -10
- data/test/dummy/config/initializers/mime_types.rb +0 -5
- data/test/dummy/config/initializers/quiet_sprocket_assets.rb +0 -13
- data/test/dummy/config/initializers/secret_token.rb +0 -7
- data/test/dummy/config/initializers/session_store.rb +0 -8
- data/test/dummy/config/initializers/wrap_parameters.rb +0 -14
- data/test/dummy/config/locales/en.yml +0 -5
- data/test/dummy/config/routes.rb +0 -23
- data/test/dummy/db/migrate/20111228141250_create_products.rb +0 -16
- data/test/dummy/db/seeds.rb +0 -1
- data/test/dummy/lib/assets/.gitkeep +0 -0
- data/test/dummy/public/404.html +0 -26
- data/test/dummy/public/422.html +0 -26
- data/test/dummy/public/500.html +0 -26
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/script/rails +0 -6
- data/test/dummy/test/functional/content_page_controller_test.rb +0 -9
- data/test/dummy/test/unit/helpers/content_page_helper_test.rb +0 -4
- data/test/factories.rb +0 -235
- data/test/fixtures/multipart/foo.jpg +0 -0
- data/test/fixtures/multipart/sample_upload.txt +0 -1
- data/test/fixtures/multipart/second_upload.txt +0 -1
- data/test/fixtures/multipart/test.jpg +0 -0
- data/test/fixtures/multipart/version1.txt +0 -1
- data/test/fixtures/multipart/version2.txt +0 -1
- data/test/functional/cms/cache_controller_test.rb +0 -16
- data/test/functional/cms/categories_controller_test.rb +0 -28
- data/test/functional/cms/connectors_controller_test.rb +0 -64
- data/test/functional/cms/content_block_controller_test.rb +0 -127
- data/test/functional/cms/content_controller_test.rb +0 -351
- data/test/functional/cms/dashboard_controller_test.rb +0 -20
- data/test/functional/cms/file_blocks_controller_test.rb +0 -55
- data/test/functional/cms/home_controller_test.rb +0 -160
- data/test/functional/cms/html_blocks_controller_test.rb +0 -159
- data/test/functional/cms/image_blocks_controller_test.rb +0 -78
- data/test/functional/cms/links_controller_test.rb +0 -92
- data/test/functional/cms/log/test.log +0 -0
- data/test/functional/cms/pages_controller_test.rb +0 -233
- data/test/functional/cms/portlets_controller_test.rb +0 -57
- data/test/functional/cms/sections_controller_test.rb +0 -234
- data/test/functional/cms/sessions_controller_test.rb +0 -80
- data/test/functional/cms/tasks_controller_test.rb +0 -64
- data/test/functional/cms/toolbar_controller_test.rb +0 -76
- data/test/functional/cms/users_controller_test.rb +0 -218
- data/test/integration/cms/password_management_test.rb +0 -66
- data/test/integration/sitemap_performance_test.rb +0 -26
- data/test/mock_file.rb +0 -33
- data/test/performance/browsing_test.rb +0 -9
- data/test/support/engine_controller_hacks.rb +0 -34
- data/test/support/factory_helpers.rb +0 -57
- data/test/support/rails_3_1_routes_hack.rb +0 -70
- data/test/test_helper.rb +0 -199
- data/test/test_logging.rb +0 -67
- data/test/unit/active_record_callbacks.rb +0 -50
- data/test/unit/behaviors/attaching_test.rb +0 -370
- data/test/unit/behaviors/cms_user_test.rb +0 -67
- data/test/unit/behaviors/connectable_test.rb +0 -32
- data/test/unit/behaviors/connecting_test.rb +0 -56
- data/test/unit/behaviors/dynamic_attributes_test.rb +0 -74
- data/test/unit/behaviors/namespacing_test.rb +0 -76
- data/test/unit/behaviors/publishable_test.rb +0 -83
- data/test/unit/behaviors/rendering_test.rb +0 -68
- data/test/unit/behaviors/searching_test.rb +0 -102
- data/test/unit/behaviors/taggable_test.rb +0 -110
- data/test/unit/behaviors/userstamping_test.rb +0 -27
- data/test/unit/behaviors/versioning_test.rb +0 -102
- data/test/unit/extensions/active_record/base_test.rb +0 -25
- data/test/unit/extensions/hash_test.rb +0 -26
- data/test/unit/extensions/integer_test.rb +0 -10
- data/test/unit/extensions/string_test.rb +0 -14
- data/test/unit/factories_test.rb +0 -50
- data/test/unit/generators/install_generator_test.rb +0 -15
- data/test/unit/helpers/application_helper_test.rb +0 -104
- data/test/unit/helpers/date_picker_test.rb +0 -17
- data/test/unit/helpers/menu_helper_test.rb +0 -240
- data/test/unit/helpers/page_helper_test.rb +0 -69
- data/test/unit/helpers/path_helper_test.rb +0 -38
- data/test/unit/helpers/rendering_helper_test.rb +0 -8
- data/test/unit/lib/acts_as_content_page_test.rb +0 -72
- data/test/unit/lib/cms/authentication/controller_test.rb +0 -20
- data/test/unit/lib/cms/engine_helper_test.rb +0 -119
- data/test/unit/lib/cms/sitemap_test.rb +0 -210
- data/test/unit/lib/cms_domain_support_test.rb +0 -44
- data/test/unit/lib/command_line_test.rb +0 -70
- data/test/unit/lib/content_block_test.rb +0 -304
- data/test/unit/lib/content_rendering_support_test.rb +0 -40
- data/test/unit/lib/generators_test.rb +0 -40
- data/test/unit/lib/routes_test.rb +0 -98
- data/test/unit/mock_file_test.rb +0 -19
- data/test/unit/models/attachment_test.rb +0 -160
- data/test/unit/models/category_test.rb +0 -40
- data/test/unit/models/category_type_test.rb +0 -8
- data/test/unit/models/connector_test.rb +0 -152
- data/test/unit/models/content_type_group_test.rb +0 -26
- data/test/unit/models/content_type_test.rb +0 -177
- data/test/unit/models/dynamic_views_test.rb +0 -36
- data/test/unit/models/email_page_portlet_test.rb +0 -20
- data/test/unit/models/file_block_test.rb +0 -246
- data/test/unit/models/group_test.rb +0 -29
- data/test/unit/models/html_block_test.rb +0 -121
- data/test/unit/models/image_block_test.rb +0 -35
- data/test/unit/models/link_test.rb +0 -52
- data/test/unit/models/namespaces_test.rb +0 -57
- data/test/unit/models/page_partial_test.rb +0 -37
- data/test/unit/models/page_route_test.rb +0 -113
- data/test/unit/models/page_template_test.rb +0 -50
- data/test/unit/models/page_test.rb +0 -879
- data/test/unit/models/permission_test.rb +0 -10
- data/test/unit/models/portlet_test.rb +0 -99
- data/test/unit/models/sections_test.rb +0 -278
- data/test/unit/models/site_test.rb +0 -50
- data/test/unit/models/task_test.rb +0 -150
- data/test/unit/models/user_test.rb +0 -358
- data/test/unit/schema_statements_test.rb +0 -137
- data/todo_list.markdown +0 -50
data/README.markdown
CHANGED
@@ -12,6 +12,7 @@ BrowserCMS is intended to offer features comparable to commercial CMS products,
|
|
12
12
|
Here's a quick overview of some of the more notable features:
|
13
13
|
|
14
14
|
* Mountable Engine: Each CMS project is a rails project that depends on the BrowserCMS engine. Developers can add new controllers, views, etc; just like any rails project.
|
15
|
+
* Mobile Friendly: Sites can be built to use mobile optimized designs that are optimized for small screens, with low bandwidth, with responsive design.
|
15
16
|
* In Context Editing: Users can browse their site to locate content and change it right on the page itself.
|
16
17
|
* Design friendly Templates: Pages aren't just a template and giant single chunk of HTML. Templates can be built to have multiple editable areas, to allow for rich designs that are still easy to manage by non-technical users.
|
17
18
|
* Sitemap: An explorer/finder style view of sections and pages in a site allowing users to add and organize pages.
|
Binary file
|
@@ -0,0 +1,87 @@
|
|
1
|
+
// Allows users to upload files via AJAX as attachments for a given block.
|
2
|
+
//
|
3
|
+
$(function () {
|
4
|
+
|
5
|
+
// Return the authenticity token for any JS function that needs to do AJAX.
|
6
|
+
// Since AJAX posts will fail if you don't attach this as defined here: http://michaelhendrickx.com/201012_jquery-ajax-with-rails-authenticity-token.html
|
7
|
+
$.cms.auth_token = function () {
|
8
|
+
return $('meta[name=csrf-token]').attr('content');
|
9
|
+
};
|
10
|
+
|
11
|
+
$.cms.AttachmentManager = {
|
12
|
+
upload:function (file) {
|
13
|
+
var assetName = $('#asset_types').val()
|
14
|
+
, attachableClass = $('#asset_attachable_class').val()
|
15
|
+
, attachableIDField = $('#asset_attachable_id')
|
16
|
+
, attachableID = attachableIDField.val()
|
17
|
+
, file = $('#asset_add_file')
|
18
|
+
, clone = file.clone()
|
19
|
+
, form = $('<form target="asset_add_uploader" method="post" action="/cms/attachments" enctype="multipart/form-data" style="visibility:hidden">')
|
20
|
+
, fields = '';
|
21
|
+
|
22
|
+
fields += '<input type="hidden" name="attachment[attachment_name]" value="' + assetName.toLowerCase() + '" />';
|
23
|
+
fields += '<input type="hidden" name="attachment[attachable_class]" value="' + attachableClass + '" />';
|
24
|
+
fields += '<input type="hidden" name="attachment[attachable_type]" value="' + attachableClass + '" />';
|
25
|
+
fields += '<input type="hidden" name="attachment[attachable_id]" value="' + attachableID + '" />';
|
26
|
+
fields += '<input type="hidden" name="authenticity_token" value="' + $.cms.authenticity_token + '" />';
|
27
|
+
|
28
|
+
$('body').append(form);
|
29
|
+
form.append(fields);
|
30
|
+
form.append(file);
|
31
|
+
attachableIDField.after(clone);
|
32
|
+
|
33
|
+
var inp = $('<input type="file" name="attachment[data]" id="asset_add_file" onchange="$.cms.AttachmentManager.upload(this)" />');
|
34
|
+
|
35
|
+
clone.after($('<img>')
|
36
|
+
.css({position:'static', margin:'5px 0 0 5px', 'verticalAlign':'middle'})
|
37
|
+
.attr({'id':'file-asset-uploader', 'src':'<%= asset_path 'cms/file-uploading.gif' %>'}));
|
38
|
+
clone.replaceWith(inp);
|
39
|
+
|
40
|
+
form.submit();
|
41
|
+
|
42
|
+
$('div.buttons').hide();
|
43
|
+
|
44
|
+
},
|
45
|
+
|
46
|
+
// @param [Integer] id The id of the attachment to delete.
|
47
|
+
destroy:function (id) {
|
48
|
+
if (confirm("Are you sure want to delete this attachment?")) {
|
49
|
+
$.post('/cms/attachments/' + id, {_method:'delete', authenticity_token:$.cms.auth_token()}, function (attachment_id) {
|
50
|
+
console.log(attachment_id);
|
51
|
+
$("#attachment_" + attachment_id).hide();
|
52
|
+
if ($("#assets_table > table tr:visible").length <= 2) {
|
53
|
+
$("#assets_table > table").hide();
|
54
|
+
}
|
55
|
+
}, 'script');
|
56
|
+
|
57
|
+
}
|
58
|
+
return false;
|
59
|
+
}
|
60
|
+
}
|
61
|
+
|
62
|
+
$('#asset_types').selectbox({width:'445px'});
|
63
|
+
|
64
|
+
$('#asset_types').change(function () {
|
65
|
+
if ($(this).val().indexOf('Select') != 0) {
|
66
|
+
$('#asset_add').show();
|
67
|
+
} else {
|
68
|
+
$('#asset_add').hide();
|
69
|
+
}
|
70
|
+
});
|
71
|
+
|
72
|
+
// After an attachment is uploaded, copy the values into the main attachment table.
|
73
|
+
$('#asset_add_uploader').load(function () {
|
74
|
+
var response = $(this).contents();
|
75
|
+
|
76
|
+
if (response.find('tr').html()) {
|
77
|
+
var asset = $(response).find('tr').clone();
|
78
|
+
var id = $(response).find("#asset-id").html();
|
79
|
+
var asset_ids = $('#attachment_manager_ids_list');
|
80
|
+
|
81
|
+
$(asset_ids).val($(asset_ids).val() + id + ",");
|
82
|
+
$('#file-asset-uploader').remove();
|
83
|
+
$('#assets_table > table').append(asset).show();
|
84
|
+
$('div.buttons').show();
|
85
|
+
}
|
86
|
+
});
|
87
|
+
});
|
@@ -3,7 +3,7 @@
|
|
3
3
|
//
|
4
4
|
//= require jquery
|
5
5
|
//
|
6
|
-
jQuery(function($) {
|
6
|
+
jQuery(function ($) {
|
7
7
|
|
8
8
|
//It would be cool if these were added to the real jQuery
|
9
9
|
//You can call this a few ways:
|
@@ -11,7 +11,7 @@ jQuery(function($) {
|
|
11
11
|
//createElement('p','hi') => "<p>hi</p>"
|
12
12
|
//createElement('p', {align: 'center'}) => "<p align="center"/>"
|
13
13
|
//createElement('p','hi',{align: 'center'}) => "<p align="center">hi</p>"
|
14
|
-
$.createElement = function(tag_name, tag_value, tag_attrs) {
|
14
|
+
$.createElement = function (tag_name, tag_value, tag_attrs) {
|
15
15
|
var name = tag_name
|
16
16
|
if (typeof tag_value == "object") {
|
17
17
|
var value = null
|
@@ -22,7 +22,7 @@ jQuery(function($) {
|
|
22
22
|
}
|
23
23
|
var element = $(document.createElement(tag_name))
|
24
24
|
if (attrs) {
|
25
|
-
$.each(attrs, function(k, v) {
|
25
|
+
$.each(attrs, function (k, v) {
|
26
26
|
element.attr(k, v)
|
27
27
|
})
|
28
28
|
}
|
@@ -40,29 +40,29 @@ jQuery(function($) {
|
|
40
40
|
]
|
41
41
|
|
42
42
|
$.cms = {
|
43
|
-
sanitizeFileName:
|
43
|
+
sanitizeFileName:function (s) {
|
44
44
|
var split = s.split(/\/|\\/)
|
45
45
|
s = split[split.length - 1]
|
46
|
-
$.each(sanitizationRegexes, function(i, e) {
|
46
|
+
$.each(sanitizationRegexes, function (i, e) {
|
47
47
|
var r = new RegExp(e[0].source, 'g')
|
48
48
|
s = s.replace(r, e[1])
|
49
49
|
})
|
50
50
|
return s;
|
51
51
|
},
|
52
|
-
slug:
|
52
|
+
slug:function (s) {
|
53
53
|
return $.trim(s.toLowerCase().replace(/[^a-zA-Z0-9_\s]+/g, '')).replace(/\ +/g, '-')
|
54
54
|
},
|
55
|
-
showNotice:
|
56
|
-
$('#message').removeClass('error').addClass('notice').html(msg).parent().show().animate({opacity:
|
55
|
+
showNotice:function (msg) {
|
56
|
+
$('#message').removeClass('error').addClass('notice').html(msg).parent().show().animate({opacity:1.0}, 3000).fadeOut("normal")
|
57
57
|
},
|
58
|
-
showError:
|
59
|
-
$('#message').removeClass('notice').addClass('error').html(msg).parent().show().animate({opacity:
|
58
|
+
showError:function (msg) {
|
59
|
+
$('#message').removeClass('notice').addClass('error').html(msg).parent().show().animate({opacity:1.0}, 3000).fadeOut("normal")
|
60
60
|
},
|
61
|
-
attachEventHandlers:
|
62
|
-
$('a.button', context).click(function() {
|
61
|
+
attachEventHandlers:function (context) {
|
62
|
+
$('a.button', context).click(function () {
|
63
63
|
if ($(this).hasClass('disabled')) return false;
|
64
64
|
});
|
65
|
-
$('a.http_post, a.http_put, a.http_delete', context).click(function() {
|
65
|
+
$('a.http_post, a.http_put, a.http_delete', context).click(function () {
|
66
66
|
if ($(this).hasClass('disabled')) return false;
|
67
67
|
if ($(this).hasClass('confirm_with_title') ? confirm(this.title) : true) {
|
68
68
|
|
@@ -96,25 +96,38 @@ jQuery(function($) {
|
|
96
96
|
|
97
97
|
$.cms.attachEventHandlers(document);
|
98
98
|
|
99
|
-
$('#message.notice').parent().show().animate({opacity:
|
100
|
-
$('#message.error').parent().show().animate({opacity:
|
99
|
+
$('#message.notice').parent().show().animate({opacity:1.0}, 3000).fadeOut("normal")
|
100
|
+
$('#message.error').parent().show().animate({opacity:1.0}, 3000).fadeOut("normal")
|
101
101
|
|
102
102
|
});
|
103
103
|
|
104
104
|
// Automatically enable date_picker controls
|
105
|
-
$(function() {
|
106
|
-
|
107
|
-
|
108
|
-
|
105
|
+
$(function () {
|
106
|
+
if ($.datepicker) {
|
107
|
+
$('input.date_picker').datepicker({ changeFirstDay:false, changeMonth:true, changeYear:true, closeText:'', showButtonPanel:true, dateFormat:'<%= Cms::DatePicker.jquery_format %>' });
|
108
|
+
}
|
109
|
+
});
|
110
|
+
|
111
|
+
// UI Enhancement to suggest paths for uploaded files
|
112
|
+
$(function () {
|
113
|
+
var path_input = $('.suggest_file_path');
|
114
|
+
if (path_input.length) {
|
115
|
+
$('select[data-purpose=section_selector], input[data-purpose=cms_file_field]').change(function () {
|
116
|
+
var section_id = $('select[data-purpose=section_selector]').val();
|
117
|
+
var section_path = $('.section_id_map[data-id='+ section_id +']').data('path');
|
118
|
+
var file_path = $.cms.sanitizeFileName($('input[data-purpose=cms_file_field]').val());
|
119
|
+
path_input.val(section_path + file_path);
|
120
|
+
});
|
121
|
+
}
|
109
122
|
});
|
110
123
|
|
111
124
|
//CookieSet allows us to treat one cookie value as a set of values
|
112
|
-
jQuery(function($) {
|
125
|
+
jQuery(function ($) {
|
113
126
|
var sep = '|'
|
114
127
|
|
115
128
|
$.cookieSet = {
|
116
129
|
//Treats the cookie as an array
|
117
|
-
add:
|
130
|
+
add:function (name, value, options) {
|
118
131
|
this.remove(name, value, options)
|
119
132
|
var set = this.get(name)
|
120
133
|
if (set) {
|
@@ -126,7 +139,7 @@ jQuery(function($) {
|
|
126
139
|
return this.get(name)
|
127
140
|
},
|
128
141
|
|
129
|
-
get:
|
142
|
+
get:function (name) {
|
130
143
|
var val = $.cookie(name)
|
131
144
|
if (val) {
|
132
145
|
return val.split(sep)
|
@@ -135,11 +148,11 @@ jQuery(function($) {
|
|
135
148
|
}
|
136
149
|
},
|
137
150
|
|
138
|
-
remove:
|
151
|
+
remove:function (name, value, options) {
|
139
152
|
var set = this.get(name)
|
140
153
|
if (set) {
|
141
154
|
var arr = []
|
142
|
-
$.each(set, function() {
|
155
|
+
$.each(set, function () {
|
143
156
|
if (this != value + '') {
|
144
157
|
arr.push(this)
|
145
158
|
}
|
@@ -152,7 +165,7 @@ jQuery(function($) {
|
|
152
165
|
},
|
153
166
|
|
154
167
|
//Treats the cookie as an array
|
155
|
-
contains:
|
168
|
+
contains:function (name, value) {
|
156
169
|
var set = this.get(name)
|
157
170
|
if (set) {
|
158
171
|
return $.inArray(value + '', set) > -1
|
@@ -0,0 +1,28 @@
|
|
1
|
+
/**
|
2
|
+
* Styles for the cms_attachment_manager form widget and attachment_viewer helper
|
3
|
+
*/
|
4
|
+
#assets_table {
|
5
|
+
label {
|
6
|
+
font-weight: bold;
|
7
|
+
color: #3E78C7
|
8
|
+
}
|
9
|
+
th {
|
10
|
+
font-weight: bold
|
11
|
+
}
|
12
|
+
td, th {
|
13
|
+
margin: 10px auto;
|
14
|
+
padding: 10px 15px;
|
15
|
+
text-align: center;
|
16
|
+
vertical-align: middle;
|
17
|
+
border-bottom: 1px solid #ddd;
|
18
|
+
}
|
19
|
+
}
|
20
|
+
|
21
|
+
#asset_add {
|
22
|
+
#asset_add_uploader {
|
23
|
+
visibility: none;
|
24
|
+
height: 1px;
|
25
|
+
width: 1px
|
26
|
+
}
|
27
|
+
}
|
28
|
+
|
@@ -1,13 +1,48 @@
|
|
1
1
|
module Cms
|
2
|
-
class AttachmentsController < Cms::BaseController
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
2
|
+
class AttachmentsController < Cms::BaseController
|
3
|
+
|
4
|
+
skip_before_filter :redirect_to_cms_site, :only => [:download]
|
5
|
+
skip_before_filter :login_required, :only => [:download]
|
6
|
+
skip_before_filter :cms_access_required, :only => [:download]
|
7
|
+
|
8
|
+
include ContentRenderingSupport
|
9
|
+
include Cms::Attachments::Serving
|
10
|
+
|
11
|
+
# Returns a specific version of an attachment.
|
12
|
+
# Used to display older versions in the editor interface.
|
13
|
+
def show
|
14
|
+
@attachment = Attachment.unscoped.find(params[:id])
|
15
|
+
@attachment = @attachment.as_of_version(params[:version]) if params[:version]
|
16
|
+
send_attachment(@attachment)
|
17
|
+
end
|
18
|
+
|
19
|
+
# This handles serving files for attachments that don't have a user specified path. If a path is defined,
|
20
|
+
# the ContentController#try_to_stream will handle it.
|
21
|
+
#
|
22
|
+
# Users can only download files if they have permission to view it.
|
23
|
+
def download
|
24
|
+
@attachment = Attachment.find(params[:id])
|
25
|
+
send_attachment(@attachment)
|
26
|
+
end
|
27
|
+
|
28
|
+
def create
|
29
|
+
@attachment = Attachment.new(params[:attachment])
|
30
|
+
@attachment.published = true
|
31
|
+
if @attachment.save
|
32
|
+
render :partial => 'cms/attachments/attachment_wrapper', :locals => {:attachment => @attachment}
|
33
|
+
else
|
34
|
+
#TODO: render html error string
|
35
|
+
render :inline => 'an error ocurred'
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def destroy
|
40
|
+
@attachment = Attachment.find(params[:id])
|
41
|
+
@attachment.destroy
|
42
|
+
render :json => @attachment.id
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
11
47
|
end
|
12
|
-
end
|
13
48
|
end
|
@@ -2,155 +2,156 @@ require 'cms/category_type'
|
|
2
2
|
# This is not called directly
|
3
3
|
# This is the base class for other content blocks
|
4
4
|
module Cms
|
5
|
-
class ContentBlockController < Cms::BaseController
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
end
|
19
|
-
|
20
|
-
def show
|
21
|
-
load_block_draft
|
22
|
-
render "#{template_directory}/show"
|
23
|
-
end
|
24
|
-
|
25
|
-
def new
|
26
|
-
build_block
|
27
|
-
set_default_category
|
28
|
-
render "#{template_directory}/new"
|
29
|
-
end
|
30
|
-
|
31
|
-
def create
|
32
|
-
if create_block
|
33
|
-
after_create_on_success
|
34
|
-
else
|
35
|
-
after_create_on_failure
|
5
|
+
class ContentBlockController < Cms::BaseController
|
6
|
+
|
7
|
+
layout :determine_layout
|
8
|
+
|
9
|
+
before_filter :set_toolbar_tab
|
10
|
+
|
11
|
+
helper_method :block_form, :new_block_path, :block_path, :blocks_path, :content_type
|
12
|
+
helper Cms::RenderingHelper
|
13
|
+
# Basic REST Crud Action
|
14
|
+
|
15
|
+
def index
|
16
|
+
load_blocks
|
17
|
+
render "#{template_directory}/index"
|
36
18
|
end
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
def edit
|
43
|
-
load_block_draft
|
44
|
-
render "#{template_directory}/edit"
|
45
|
-
end
|
46
|
-
|
47
|
-
def update
|
48
|
-
if update_block
|
49
|
-
after_update_on_success
|
50
|
-
else
|
51
|
-
after_update_on_failure
|
19
|
+
|
20
|
+
def show
|
21
|
+
load_block_draft
|
22
|
+
render "#{template_directory}/show"
|
52
23
|
end
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
end
|
59
|
-
|
60
|
-
def destroy
|
61
|
-
do_command("deleted") { @block.destroy }
|
62
|
-
redirect_to_first params[:_redirect_to], blocks_path
|
63
|
-
end
|
64
|
-
|
65
|
-
# Additional CMS Action
|
66
|
-
|
67
|
-
def publish
|
68
|
-
do_command("published") { @block.publish! }
|
69
|
-
redirect_to_first params[:_redirect_to], block_path(@block)
|
70
|
-
end
|
71
|
-
|
72
|
-
def revert_to
|
73
|
-
do_command("reverted to version #{params[:version]}") do
|
74
|
-
revert_block(params[:version])
|
24
|
+
|
25
|
+
def new
|
26
|
+
build_block
|
27
|
+
set_default_category
|
28
|
+
render "#{template_directory}/new"
|
75
29
|
end
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
30
|
+
|
31
|
+
def create
|
32
|
+
if create_block
|
33
|
+
after_create_on_success
|
34
|
+
else
|
35
|
+
after_create_on_failure
|
36
|
+
end
|
37
|
+
rescue Exception => @exception
|
38
|
+
raise @exception if @exception.is_a?(Cms::Errors::AccessDenied)
|
39
|
+
after_create_on_error
|
83
40
|
end
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
41
|
+
|
42
|
+
def edit
|
43
|
+
load_block_draft
|
44
|
+
render "#{template_directory}/edit"
|
45
|
+
end
|
46
|
+
|
47
|
+
def update
|
48
|
+
if update_block
|
49
|
+
after_update_on_success
|
50
|
+
else
|
51
|
+
after_update_on_failure
|
52
|
+
end
|
53
|
+
rescue ActiveRecord::StaleObjectError => @exception
|
54
|
+
after_update_on_edit_conflict
|
55
|
+
rescue Exception => @exception
|
56
|
+
raise @exception if @exception.is_a?(Cms::Errors::AccessDenied)
|
57
|
+
after_update_on_error
|
58
|
+
end
|
59
|
+
|
60
|
+
def destroy
|
61
|
+
do_command("deleted") { @block.destroy }
|
62
|
+
redirect_to_first params[:_redirect_to], blocks_path
|
63
|
+
end
|
64
|
+
|
65
|
+
# Additional CMS Action
|
66
|
+
|
67
|
+
def publish
|
68
|
+
do_command("published") { @block.publish! }
|
69
|
+
redirect_to_first params[:_redirect_to], block_path(@block)
|
70
|
+
end
|
71
|
+
|
72
|
+
def revert_to
|
73
|
+
do_command("reverted to version #{params[:version]}") do
|
74
|
+
revert_block(params[:version])
|
75
|
+
end
|
76
|
+
redirect_to_first params[:_redirect_to], block_path(@block)
|
77
|
+
end
|
78
|
+
|
79
|
+
def version
|
89
80
|
load_block
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
81
|
+
if params[:version]
|
82
|
+
@block = @block.as_of_version(params[:version])
|
83
|
+
end
|
84
|
+
render "#{template_directory}/show"
|
85
|
+
end
|
86
|
+
|
87
|
+
def versions
|
88
|
+
if model_class.versioned?
|
89
|
+
load_block
|
90
|
+
render "#{template_directory}/versions"
|
91
|
+
else
|
92
|
+
render :text => "Not Implemented", :status => :not_implemented
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def usages
|
97
|
+
load_block_draft
|
98
|
+
@pages = @block.connected_pages.all(:order => 'name')
|
99
|
+
render "#{template_directory}/usages"
|
100
|
+
end
|
101
|
+
|
102
|
+
protected
|
103
103
|
# methods that are used to detemine what content block type we are dealing with
|
104
104
|
|
105
105
|
def content_type_name
|
106
|
-
self.class.name.sub(/Controller/,'').singularize
|
106
|
+
self.class.name.sub(/Controller/, '').singularize
|
107
107
|
end
|
108
108
|
|
109
109
|
def content_type
|
110
110
|
@content_type ||= ContentType.find_by_key(content_type_name)
|
111
|
-
end
|
111
|
+
end
|
112
112
|
|
113
113
|
def model_class
|
114
114
|
content_type.model_class
|
115
115
|
end
|
116
|
-
|
116
|
+
|
117
117
|
def model_form_name
|
118
118
|
content_type.model_class_form_name
|
119
119
|
end
|
120
|
-
|
120
|
+
|
121
121
|
# methods for loading one or a collection of blocks
|
122
|
-
|
122
|
+
|
123
123
|
def load_blocks
|
124
124
|
options = {}
|
125
125
|
if params[:section_id] && params[:section_id] != 'all'
|
126
|
-
options[:include] = {
|
126
|
+
options[:include] = {:attachments => :section_node}
|
127
127
|
options[:conditions] = ["#{Namespacing.prefix("section_nodes")}.ancestry = ?", Section.find(params[:section_id]).ancestry_path]
|
128
128
|
end
|
129
|
-
options[:page] = params[:page]
|
129
|
+
options[:page] = params[:page]
|
130
130
|
options[:order] = model_class.default_order if model_class.respond_to?(:default_order)
|
131
131
|
options[:order] = params[:order] unless params[:order].blank?
|
132
|
+
|
132
133
|
scope = model_class.respond_to?(:list) ? model_class.list : model_class
|
133
134
|
@blocks = scope.searchable? ? scope.search(params[:search]).paginate(options) : scope.paginate(options)
|
134
135
|
check_permissions
|
135
136
|
end
|
136
|
-
|
137
|
+
|
137
138
|
def load_block
|
138
139
|
@block = model_class.find(params[:id])
|
139
140
|
check_permissions
|
140
141
|
end
|
141
|
-
|
142
|
+
|
142
143
|
def load_block_draft
|
143
144
|
@block = model_class.find(params[:id])
|
144
145
|
@block = @block.as_of_draft_version if model_class.versioned?
|
145
146
|
check_permissions
|
146
147
|
end
|
147
|
-
|
148
|
+
|
148
149
|
# path related methods - available in the view as helpers
|
149
|
-
|
150
|
+
|
150
151
|
def new_block_path(block, options={})
|
151
152
|
cms_new_path_for(block, options)
|
152
153
|
end
|
153
|
-
|
154
|
+
|
154
155
|
def block_path(block, action=nil)
|
155
156
|
path = []
|
156
157
|
path << engine_for(block)
|
@@ -158,31 +159,34 @@ class ContentBlockController < Cms::BaseController
|
|
158
159
|
path.concat path_elements_for(block)
|
159
160
|
path
|
160
161
|
end
|
161
|
-
|
162
|
+
|
162
163
|
def blocks_path(options={})
|
163
|
-
cms_index_path_for(@
|
164
|
+
cms_index_path_for(@content_type.model_class, options)
|
164
165
|
end
|
165
166
|
|
166
167
|
# This is the partial that will be used in the form
|
167
168
|
def block_form
|
168
169
|
@content_type.form
|
169
170
|
end
|
170
|
-
|
171
|
-
|
172
|
-
|
171
|
+
|
172
|
+
|
173
173
|
def build_block
|
174
|
-
|
174
|
+
begin
|
175
|
+
@block = model_class.new(params[model_form_name])
|
176
|
+
ensure
|
177
|
+
# Recover from an Exception thrown during binding of parameters to model class
|
178
|
+
# Need to make sure @block exists for form helpers to correctly generate paths
|
179
|
+
@block = model_class.new unless @block
|
180
|
+
end
|
175
181
|
check_permissions
|
176
182
|
end
|
177
183
|
|
178
184
|
def set_default_category
|
179
185
|
if @last_block = model_class.last
|
180
186
|
@block.category = @last_block.category if @block.respond_to?(:category=)
|
181
|
-
end
|
187
|
+
end
|
182
188
|
end
|
183
|
-
|
184
|
-
# create related methods
|
185
|
-
|
189
|
+
|
186
190
|
def create_block
|
187
191
|
build_block
|
188
192
|
@block.save
|
@@ -203,10 +207,22 @@ class ContentBlockController < Cms::BaseController
|
|
203
207
|
end
|
204
208
|
|
205
209
|
def after_create_on_error
|
206
|
-
|
210
|
+
log_complete_stacktrace(@exception)
|
207
211
|
after_create_on_failure
|
208
212
|
end
|
209
213
|
|
214
|
+
def after_update_on_error
|
215
|
+
log_complete_stacktrace(@exception)
|
216
|
+
after_update_on_failure
|
217
|
+
end
|
218
|
+
|
219
|
+
# Print the underlying stack trace to the logs for debugging.
|
220
|
+
# Should be human readable (i.e. line breaks)
|
221
|
+
# See http://stackoverflow.com/questions/228441/how-do-i-log-the-entire-trace-back-of-a-ruby-exception-using-the-default-rails-l for discussion of implementation
|
222
|
+
def log_complete_stacktrace(exception)
|
223
|
+
logger.error "#{exception.message}\n#{exception.backtrace.join("\n")}"
|
224
|
+
end
|
225
|
+
|
210
226
|
# update related methods
|
211
227
|
def update_block
|
212
228
|
load_block
|
@@ -227,10 +243,6 @@ class ContentBlockController < Cms::BaseController
|
|
227
243
|
after_update_on_failure
|
228
244
|
end
|
229
245
|
|
230
|
-
def after_update_on_error
|
231
|
-
logger.error "#{@exception.message}\n#{@exception.backtrace.join('\n')}"
|
232
|
-
after_update_on_failure
|
233
|
-
end
|
234
246
|
|
235
247
|
# methods for other actions
|
236
248
|
|
@@ -255,7 +267,7 @@ class ContentBlockController < Cms::BaseController
|
|
255
267
|
false
|
256
268
|
end
|
257
269
|
end
|
258
|
-
|
270
|
+
|
259
271
|
# Use a "whitelist" approach to access to avoid mistakes
|
260
272
|
# By default everyone can create new block and view them and their properties,
|
261
273
|
# but blocks can only be modified based on the permissions of the pages they
|
@@ -287,5 +299,5 @@ class ContentBlockController < Cms::BaseController
|
|
287
299
|
"cms/blocks"
|
288
300
|
end
|
289
301
|
|
290
|
-
end
|
302
|
+
end
|
291
303
|
end
|