browsercms 3.1.5 → 3.3.0.beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/app/controllers/cms/base_controller.rb +3 -3
- data/app/controllers/cms/content_block_controller.rb +2 -2
- data/app/controllers/cms/content_controller.rb +5 -4
- data/app/controllers/cms/error_handling.rb +1 -1
- data/app/controllers/cms/routes_controller.rb +4 -5
- data/app/controllers/cms/section_nodes_controller.rb +1 -6
- data/app/controllers/cms/sections_controller.rb +2 -3
- data/app/controllers/cms/tasks_controller.rb +3 -0
- data/app/controllers/cms/users_controller.rb +1 -1
- data/app/helpers/cms/application_helper.rb +137 -34
- data/app/helpers/cms/form_builder.rb +33 -21
- data/app/helpers/cms/page_helper.rb +43 -10
- data/app/helpers/cms/path_helper.rb +1 -1
- data/app/helpers/cms/rendering_helper.rb +3 -4
- data/app/helpers/cms/section_nodes_helper.rb +5 -43
- data/app/models/abstract_file_block.rb +1 -16
- data/app/models/attachment.rb +57 -22
- data/app/models/category.rb +4 -4
- data/app/models/category_type.rb +2 -2
- data/app/models/cms/view_context.rb +46 -0
- data/app/models/connector.rb +7 -6
- data/app/models/content_type.rb +3 -3
- data/app/models/dynamic_view.rb +1 -1
- data/app/models/email_message.rb +2 -2
- data/app/models/file_block.rb +12 -0
- data/app/models/group.rb +4 -4
- data/app/models/group_type.rb +4 -4
- data/app/models/html_block.rb +1 -1
- data/app/models/image_block.rb +12 -0
- data/app/models/link.rb +22 -5
- data/app/models/page.rb +87 -46
- data/app/models/page_route.rb +61 -6
- data/app/models/permission.rb +1 -1
- data/app/models/portlet.rb +14 -4
- data/app/models/section.rb +48 -86
- data/app/models/section_node.rb +25 -40
- data/app/models/site.rb +1 -1
- data/app/models/tag.rb +1 -1
- data/app/models/task.rb +8 -7
- data/app/models/user.rb +2 -7
- data/app/portlets/forgot_password_portlet.rb +6 -2
- data/app/portlets/reset_password_portlet.rb +1 -1
- data/app/views/cms/blocks/_toolbar.html.erb +1 -1
- data/app/views/cms/blocks/_toolbar_for_collection.html.erb +3 -6
- data/app/views/cms/blocks/_toolbar_for_member.html.erb +3 -5
- data/app/views/cms/blocks/edit.html.erb +4 -4
- data/app/views/cms/blocks/index.html.erb +7 -7
- data/app/views/cms/blocks/new.html.erb +4 -4
- data/app/views/cms/blocks/show.html.erb +2 -2
- data/app/views/cms/blocks/usages.html.erb +2 -2
- data/app/views/cms/blocks/versions.html.erb +4 -4
- data/app/views/cms/cache/show.html.erb +2 -2
- data/app/views/cms/categories/_form.html.erb +2 -2
- data/app/views/cms/connectors/new.html.erb +6 -8
- data/app/views/cms/content/no_page.html.erb +1 -1
- data/app/views/cms/content/show.html.erb +2 -7
- data/app/views/cms/dashboard/_page_drafts.html.erb +1 -1
- data/app/views/cms/dashboard/_tasks.html.erb +1 -1
- data/app/views/cms/dashboard/index.html.erb +1 -1
- data/app/views/cms/dynamic_views/_form.html.erb +2 -2
- data/app/views/cms/dynamic_views/index.html.erb +7 -10
- data/app/views/cms/email_messages/show.html.erb +2 -2
- data/app/views/cms/file_blocks/_form.html.erb +4 -4
- data/app/views/cms/form_builder/_cms_fancy_drop_down.html.erb +2 -2
- data/app/views/cms/form_builder/_cms_file_field.html.erb +2 -2
- data/app/views/cms/form_builder/_cms_tag_list.html.erb +2 -2
- data/app/views/cms/form_builder/_cms_text_editor.html.erb +2 -2
- data/app/views/cms/groups/_form.html.erb +5 -5
- data/app/views/cms/groups/_permissions.html.erb +4 -4
- data/app/views/cms/groups/_sections.html.erb +1 -2
- data/app/views/cms/groups/index.html.erb +1 -1
- data/app/views/cms/html_blocks/render.html.erb +1 -1
- data/app/views/cms/image_blocks/_form.html.erb +4 -5
- data/app/views/cms/links/_form.html.erb +1 -1
- data/app/views/cms/links/edit.html.erb +2 -2
- data/app/views/cms/links/new.html.erb +2 -2
- data/app/views/cms/page_routes/_form.html.erb +2 -2
- data/app/views/cms/page_routes/index.html.erb +6 -9
- data/app/views/cms/page_routes/show.html.erb +5 -8
- data/app/views/cms/pages/_edit_connector.html.erb +1 -1
- data/app/views/cms/pages/_form.html.erb +3 -3
- data/app/views/cms/pages/edit.html.erb +2 -2
- data/app/views/cms/pages/new.html.erb +7 -7
- data/app/views/cms/pages/versions.html.erb +4 -4
- data/app/views/cms/redirects/_form.html.erb +2 -2
- data/app/views/cms/redirects/index.html.erb +8 -7
- data/app/views/cms/routes/index.html.erb +2 -2
- data/app/views/cms/section_nodes/_link.html.erb +3 -6
- data/app/views/cms/section_nodes/_node.html.erb +4 -13
- data/app/views/cms/section_nodes/_page.html.erb +7 -13
- data/app/views/cms/section_nodes/_section.html.erb +8 -24
- data/app/views/cms/section_nodes/_section_node.html.erb +10 -0
- data/app/views/cms/section_nodes/index.html.erb +18 -30
- data/app/views/cms/sections/_form.html.erb +4 -6
- data/app/views/cms/sections/edit.html.erb +2 -2
- data/app/views/cms/sections/index.html.erb +3 -3
- data/app/views/cms/sections/new.html.erb +3 -3
- data/app/views/cms/sessions/new.html.erb +3 -3
- data/app/views/cms/shared/_pagination.html.erb +1 -1
- data/app/views/cms/shared/error.html.erb +1 -1
- data/app/views/cms/tags/render.html.erb +2 -2
- data/app/views/cms/tasks/new.html.erb +4 -4
- data/app/views/cms/users/_form.html.erb +3 -3
- data/app/views/cms/users/_toolbar.html.erb +3 -3
- data/app/views/cms/users/change_password.html.erb +5 -5
- data/app/views/cms/users/edit.html.erb +2 -2
- data/app/views/cms/users/index.html.erb +4 -4
- data/app/views/cms/users/new.html.erb +2 -2
- data/app/views/cms/users/show.html.erb +16 -16
- data/app/views/layouts/_cms_toolbar.html.erb +5 -5
- data/app/views/layouts/_page_toolbar.html.erb +11 -11
- data/app/views/layouts/cms/_footer.erb +1 -1
- data/app/views/layouts/cms/_head.html.erb +2 -6
- data/app/views/layouts/cms/administration.html.erb +32 -32
- data/app/views/layouts/cms/content_library.html.erb +5 -5
- data/app/views/layouts/cms/toolbar.html.erb +1 -1
- data/app/views/portlets/email_page/render.html.erb +2 -2
- data/app/views/portlets/forgot_password/render.html.erb +1 -1
- data/app/views/portlets/login/render.html.erb +4 -2
- data/app/views/portlets/reset_password/render.html.erb +1 -1
- data/app/views/tests/pretend/open_with_layout.html.erb +1 -1
- data/bin/bcms +0 -0
- data/bin/bcms-upgrade +232 -0
- data/bin/browsercms +2 -2
- data/browsercms.gemspec +16 -14
- data/db/migrate/20100705083859_browsercms_3_3_0.rb +56 -0
- data/db/seeds.rb +58 -0
- data/doc/guides/html/authentication.html +448 -192
- data/doc/guides/html/build_it_yourself.html +454 -175
- data/doc/guides/html/building_modules.html +451 -220
- data/doc/guides/html/building_templates.html +448 -498
- data/doc/guides/html/content_blocks.html +450 -470
- data/doc/guides/html/customizing_browsercms.html +453 -169
- data/doc/guides/html/deployment_guide.html +443 -82
- data/doc/guides/html/files/bcmsorg.js +28 -0
- data/doc/guides/html/files/clearfix.css +8 -0
- data/doc/guides/html/files/cufon.js +7 -0
- data/doc/guides/html/files/global.css +190 -0
- data/doc/guides/html/files/helvetica.js +91 -0
- data/doc/guides/html/files/jquery.js +11 -0
- data/doc/guides/html/getting_started.html +454 -213
- data/doc/guides/html/index.html +454 -174
- data/doc/guides/html/installing_modules.html +454 -186
- data/doc/guides/html/portlets.html +451 -232
- data/doc/guides/html/user_guide.html +452 -270
- data/doc/guides/html/writing_guides.html +454 -161
- data/lib/acts_as_list.rb +1 -1
- data/lib/browsercms.rb +10 -6
- data/lib/cms/acts.rb +7 -0
- data/lib/cms/authentication.rb +4 -0
- data/lib/cms/authentication/controller.rb +1 -1
- data/lib/cms/behaviors.rb +1 -1
- data/lib/cms/behaviors/archiving.rb +2 -2
- data/lib/cms/behaviors/attaching.rb +28 -43
- data/lib/cms/behaviors/categorizing.rb +1 -1
- data/lib/cms/behaviors/connecting.rb +27 -12
- data/lib/cms/behaviors/dynamic_attributes.rb +8 -5
- data/lib/cms/behaviors/hiding.rb +2 -2
- data/lib/cms/behaviors/publishing.rb +32 -22
- data/lib/cms/behaviors/rendering.rb +41 -18
- data/lib/cms/behaviors/searching.rb +1 -1
- data/lib/cms/behaviors/soft_deleting.rb +58 -29
- data/lib/cms/behaviors/taggable.rb +1 -1
- data/lib/cms/behaviors/userstamping.rb +5 -4
- data/lib/cms/behaviors/versioning.rb +192 -111
- data/lib/cms/content_rendering_support.rb +3 -3
- data/lib/cms/date_picker.rb +23 -0
- data/lib/cms/engine.rb +46 -0
- data/lib/cms/extensions.rb +1 -1
- data/lib/cms/extensions/active_record/errors.rb +2 -2
- data/lib/cms/extensions/hash.rb +4 -2
- data/lib/cms/extensions/string.rb +7 -2
- data/lib/cms/init.rb +32 -21
- data/lib/cms/module.rb +22 -0
- data/lib/cms/module_installation.rb +38 -0
- data/lib/cms/routes.rb +127 -115
- data/lib/cms/version.rb +2 -2
- data/lib/generators/browser_cms.rb +12 -0
- data/lib/generators/browser_cms/cms/USAGE +2 -0
- data/lib/generators/browser_cms/cms/cms_generator.rb +36 -0
- data/{rails_generators/browser_cms → lib/generators/browser_cms/cms}/templates/README +0 -0
- data/{rails_generators/browser_cms_demo_site → lib/generators/browser_cms/demo_site}/USAGE +0 -0
- data/lib/generators/browser_cms/demo_site/demo_site_generator.rb +138 -0
- data/lib/generators/browser_cms/demo_site/templates/demo_site.rake +11 -0
- data/{rails_generators/browser_cms_demo_site/templates/migration.rb → lib/generators/browser_cms/demo_site/templates/migration.erb} +2 -8
- data/lib/generators/cms/content_block/USAGE +22 -0
- data/lib/generators/cms/content_block/content_block_generator.rb +55 -0
- data/{rails_generators → lib/generators/cms}/content_block/templates/_form.html.erb +0 -0
- data/{rails_generators → lib/generators/cms}/content_block/templates/content_block.rb +0 -0
- data/{rails_generators → lib/generators/cms}/content_block/templates/controller.rb +0 -0
- data/{rails_generators → lib/generators/cms}/content_block/templates/functional_test.erb +0 -0
- data/{rails_generators/content_block/templates/migration.rb → lib/generators/cms/content_block/templates/migration.erb} +1 -1
- data/{rails_generators → lib/generators/cms}/content_block/templates/render.html.erb +0 -0
- data/{rails_generators → lib/generators/cms}/content_block/templates/unit_test.erb +0 -0
- data/lib/generators/cms/install/USAGE +8 -0
- data/lib/generators/cms/install/install_generator.rb +20 -0
- data/{rails_generators → lib/generators/cms}/portlet/USAGE +3 -16
- data/lib/generators/cms/portlet/portlet_generator.rb +38 -0
- data/{rails_generators → lib/generators/cms}/portlet/templates/_form.html.erb +0 -0
- data/{rails_generators → lib/generators/cms}/portlet/templates/portlet.rb +0 -0
- data/{rails_generators → lib/generators/cms}/portlet/templates/portlet_helper.rb +0 -0
- data/{rails_generators → lib/generators/cms}/portlet/templates/render.html.erb +0 -0
- data/{rails_generators → lib/generators/cms}/portlet/templates/unit_test.erb +0 -0
- data/{rails_generators → lib/generators/cms}/template/USAGE +1 -1
- data/lib/generators/cms/template/template_generator.rb +18 -0
- data/lib/generators/cms/template/templates/template.erb +2 -0
- data/lib/generators/cms/upgrade_module/README.txt +3 -0
- data/lib/generators/cms/upgrade_module/templates/20100705083859_browsercms_3_3_0.rb +56 -0
- data/lib/generators/cms/upgrade_module/templates/README +1 -0
- data/lib/generators/cms/upgrade_module/templates/USAGE.erb +10 -0
- data/lib/generators/cms/upgrade_module/templates/build_gem.rake +5 -0
- data/lib/generators/cms/upgrade_module/templates/engine.erb +7 -0
- data/lib/generators/cms/upgrade_module/templates/gemspec.erb +25 -0
- data/lib/generators/cms/upgrade_module/templates/gitignore.erb +11 -0
- data/lib/generators/cms/upgrade_module/templates/install.erb +9 -0
- data/lib/generators/cms/upgrade_module/templates/module_file.erb +3 -0
- data/lib/generators/cms/upgrade_module/templates/routes.erb +7 -0
- data/lib/generators/cms/upgrade_module/upgrade_module_generator.rb +61 -0
- data/lib/tasks/build_gem.rake +1 -0
- data/lib/tasks/cms.rake +34 -6
- data/lib/tasks/cucumber.rake +53 -0
- data/lib/tasks/db.rake +2 -2
- data/public/javascripts/cms/application.js +144 -135
- data/public/javascripts/cms/sitemap.js +383 -357
- data/public/javascripts/jquery-ui.js +782 -591
- data/public/javascripts/jquery.cookie.js +38 -43
- data/public/javascripts/jquery.js +13 -8
- data/public/javascripts/jquery.taglist.js +7 -0
- data/public/stylesheets/cms/date_picker.css +49 -40
- data/rails/init.rb +2 -3
- data/templates/blank.rb +13 -7
- data/templates/demo.rb +15 -7
- data/templates/module.rb +12 -75
- metadata +87 -407
- data/app/helpers/cms/content_block_helper.rb +0 -27
- data/app/views/layouts/cms/thickbox.html.erb +0 -24
- data/db/migrate/20120117144039_browsercms315.rb +0 -94
- data/db/migrate/20121114172307_load_seeds.rb +0 -70
- data/lib/cms/addressable.rb +0 -83
- data/lib/cms/error_pages.rb +0 -8
- data/public/images/cms/thickbox/loadingAnimation.gif +0 -0
- data/public/images/cms/thickbox/macFFBgHack.png +0 -0
- data/public/javascripts/jquery.contextMenu.js +0 -211
- data/public/javascripts/jquery.dimensions.js +0 -119
- data/public/javascripts/jquery.thickbox.js +0 -10
- data/public/stylesheets/cms/jquery.contextMenu.css +0 -61
- data/public/stylesheets/cms/thickbox.css +0 -163
- data/rails_generators/browser_cms/USAGE +0 -2
- data/rails_generators/browser_cms/browser_cms_generator.rb +0 -35
- data/rails_generators/browser_cms_demo_site/browser_cms_demo_site_generator.rb +0 -63
- data/rails_generators/content_block/USAGE +0 -32
- data/rails_generators/content_block/content_block_generator.rb +0 -69
- data/rails_generators/portlet/portlet_generator.rb +0 -35
- data/rails_generators/template/template_generator.rb +0 -18
- data/rails_generators/template/templates/template.erb +0 -3
- data/test/custom_assertions.rb +0 -74
- data/test/factories.rb +0 -111
- data/test/factories/sitemap_factories.rb +0 -28
- data/test/fixtures/connectors.yml +0 -97
- data/test/fixtures/content_type_groups.yml +0 -13
- data/test/fixtures/content_types.yml +0 -50
- data/test/fixtures/dynamic_view_versions.yml +0 -26
- data/test/fixtures/dynamic_views.yml +0 -26
- data/test/fixtures/group_permissions.yml +0 -16
- data/test/fixtures/group_sections.yml +0 -31
- data/test/fixtures/group_type_permissions.yml +0 -11
- data/test/fixtures/group_types.yml +0 -25
- data/test/fixtures/groups.yml +0 -25
- data/test/fixtures/html_block_versions.yml +0 -67
- data/test/fixtures/html_blocks.yml +0 -63
- data/test/fixtures/page_versions.yml +0 -265
- data/test/fixtures/pages.yml +0 -85
- data/test/fixtures/permissions.yml +0 -28
- data/test/fixtures/section_nodes.yml +0 -46
- data/test/fixtures/sections.yml +0 -19
- data/test/fixtures/sites.yml +0 -9
- data/test/fixtures/user_group_memberships.yml +0 -11
- data/test/fixtures/users.yml +0 -15
- data/test/functional/cms/cache_controller_test.rb +0 -14
- data/test/functional/cms/categories_controller_test.rb +0 -25
- data/test/functional/cms/connectors_controller_test.rb +0 -60
- data/test/functional/cms/content_block_controller_test.rb +0 -120
- data/test/functional/cms/content_controller_test.rb +0 -439
- data/test/functional/cms/content_types_controller_test.rb +0 -18
- data/test/functional/cms/dashboard_controller_test.rb +0 -16
- data/test/functional/cms/dynamic_views_controller_test.rb +0 -52
- data/test/functional/cms/file_blocks_controller_test.rb +0 -52
- data/test/functional/cms/groups_controller_test.rb +0 -50
- data/test/functional/cms/home_controller_test.rb +0 -156
- data/test/functional/cms/html_blocks_controller_test.rb +0 -164
- data/test/functional/cms/image_blocks_controller_test.rb +0 -82
- data/test/functional/cms/links_controller_test.rb +0 -148
- data/test/functional/cms/pages_controller_test.rb +0 -227
- data/test/functional/cms/portlets_controller_test.rb +0 -67
- data/test/functional/cms/section_nodes_controller_test.rb +0 -112
- data/test/functional/cms/sections_controller_test.rb +0 -227
- data/test/functional/cms/sessions_controller_test.rb +0 -76
- data/test/functional/cms/toolbar_controller_test.rb +0 -64
- data/test/functional/cms/users_controller_test.rb +0 -231
- data/test/functional/tests/pretend_controller_test.rb +0 -57
- data/test/integration/cms/ckeditor_test.rb +0 -30
- data/test/integration/cms/password_management_test.rb +0 -56
- data/test/integration/login_test.rb +0 -14
- data/test/integration/sitemap_performance_test.rb +0 -26
- data/test/selenium-core/Blank.html +0 -7
- data/test/selenium-core/InjectedRemoteRunner.html +0 -8
- data/test/selenium-core/RemoteRunner.html +0 -110
- data/test/selenium-core/SeleniumLog.html +0 -109
- data/test/selenium-core/TestPrompt.html +0 -145
- data/test/selenium-core/TestRunner-splash.html +0 -55
- data/test/selenium-core/TestRunner.hta +0 -176
- data/test/selenium-core/TestRunner.html +0 -176
- data/test/selenium-core/domviewer/butmin.gif +0 -0
- data/test/selenium-core/domviewer/butplus.gif +0 -0
- data/test/selenium-core/domviewer/domviewer.css +0 -298
- data/test/selenium-core/domviewer/domviewer.html +0 -16
- data/test/selenium-core/domviewer/selenium-domviewer.js +0 -205
- data/test/selenium-core/icons/all.png +0 -0
- data/test/selenium-core/icons/continue.png +0 -0
- data/test/selenium-core/icons/continue_disabled.png +0 -0
- data/test/selenium-core/icons/pause.png +0 -0
- data/test/selenium-core/icons/pause_disabled.png +0 -0
- data/test/selenium-core/icons/selected.png +0 -0
- data/test/selenium-core/icons/step.png +0 -0
- data/test/selenium-core/icons/step_disabled.png +0 -0
- data/test/selenium-core/iedoc-core.xml +0 -1515
- data/test/selenium-core/iedoc.xml +0 -1469
- data/test/selenium-core/lib/cssQuery/cssQuery-p.js +0 -6
- data/test/selenium-core/lib/cssQuery/src/cssQuery-level2.js +0 -142
- data/test/selenium-core/lib/cssQuery/src/cssQuery-level3.js +0 -150
- data/test/selenium-core/lib/cssQuery/src/cssQuery-standard.js +0 -53
- data/test/selenium-core/lib/cssQuery/src/cssQuery.js +0 -356
- data/test/selenium-core/lib/prototype.js +0 -2006
- data/test/selenium-core/lib/scriptaculous/builder.js +0 -101
- data/test/selenium-core/lib/scriptaculous/controls.js +0 -815
- data/test/selenium-core/lib/scriptaculous/dragdrop.js +0 -915
- data/test/selenium-core/lib/scriptaculous/effects.js +0 -958
- data/test/selenium-core/lib/scriptaculous/scriptaculous.js +0 -47
- data/test/selenium-core/lib/scriptaculous/slider.js +0 -283
- data/test/selenium-core/lib/scriptaculous/unittest.js +0 -383
- data/test/selenium-core/scripts/find_matching_child.js +0 -69
- data/test/selenium-core/scripts/htmlutils.js +0 -894
- data/test/selenium-core/scripts/injection.html +0 -72
- data/test/selenium-core/scripts/js2html.js +0 -70
- data/test/selenium-core/scripts/narcissus-defs.js +0 -175
- data/test/selenium-core/scripts/narcissus-exec.js +0 -1054
- data/test/selenium-core/scripts/narcissus-parse.js +0 -1003
- data/test/selenium-core/scripts/se2html.js +0 -63
- data/test/selenium-core/scripts/selenium-api.js +0 -2409
- data/test/selenium-core/scripts/selenium-browserbot.js +0 -2203
- data/test/selenium-core/scripts/selenium-browserdetect.js +0 -150
- data/test/selenium-core/scripts/selenium-commandhandlers.js +0 -377
- data/test/selenium-core/scripts/selenium-executionloop.js +0 -175
- data/test/selenium-core/scripts/selenium-logging.js +0 -147
- data/test/selenium-core/scripts/selenium-remoterunner.js +0 -571
- data/test/selenium-core/scripts/selenium-testrunner.js +0 -1333
- data/test/selenium-core/scripts/selenium-version.js +0 -5
- data/test/selenium-core/scripts/user-extensions.js +0 -3
- data/test/selenium-core/scripts/user-extensions.js.sample +0 -75
- data/test/selenium-core/scripts/xmlextras.js +0 -153
- data/test/selenium-core/selenium-logo.png +0 -0
- data/test/selenium-core/selenium-test.css +0 -43
- data/test/selenium-core/selenium.css +0 -299
- data/test/selenium-core/xpath/dom.js +0 -428
- data/test/selenium-core/xpath/misc.js +0 -252
- data/test/selenium-core/xpath/xpath.js +0 -2223
- data/test/selenium/_login_as_cmsadmin.rsel +0 -4
- data/test/selenium/dashboard.rsel +0 -5
- data/test/selenium/html_blocks.rsel +0 -4
- data/test/selenium/login/failed_login.rsel +0 -8
- data/test/selenium/login/successful_login.rsel +0 -9
- data/test/selenium/page_templates.rsel +0 -12
- data/test/selenium/pages/edit_properties.rsel +0 -5
- data/test/selenium/site/view_home_page.rsel +0 -4
- data/test/selenium/sitemap/move_page.rsel +0 -9
- data/test/selenium/sitemap/open_section.rsel +0 -6
- data/test/selenium/sitemap/select_page.rsel +0 -12
- data/test/selenium/sitemap/select_section.rsel +0 -17
- data/test/test_helper.rb +0 -193
- data/test/test_logging.rb +0 -67
- data/test/unit/behaviors/attaching_test.rb +0 -357
- data/test/unit/behaviors/connectable_test.rb +0 -29
- data/test/unit/behaviors/dynamic_attributes_test.rb +0 -38
- data/test/unit/behaviors/publishable_test.rb +0 -84
- data/test/unit/behaviors/searching_test.rb +0 -102
- data/test/unit/behaviors/taggable_test.rb +0 -109
- data/test/unit/behaviors/versioning_test.rb +0 -36
- data/test/unit/extensions/active_record/base_test.rb +0 -10
- data/test/unit/extensions/hash_test.rb +0 -17
- data/test/unit/extensions/integer_test.rb +0 -10
- data/test/unit/helpers/application_helper_test.rb +0 -77
- data/test/unit/helpers/form_builder_test.rb +0 -36
- data/test/unit/helpers/menu_helper_test.rb +0 -242
- data/test/unit/helpers/page_helper_test.rb +0 -67
- data/test/unit/helpers/path_helper_test.rb +0 -57
- 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/sitemap_test.rb +0 -206
- data/test/unit/lib/cms_domain_support_test.rb +0 -43
- data/test/unit/lib/command_line_test.rb +0 -70
- data/test/unit/lib/content_block_test.rb +0 -203
- 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 -57
- data/test/unit/models/attachment_test.rb +0 -116
- 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_test.rb +0 -56
- data/test/unit/models/email_page_portlet_test.rb +0 -14
- data/test/unit/models/file_block_test.rb +0 -230
- data/test/unit/models/group_test.rb +0 -13
- data/test/unit/models/html_block_test.rb +0 -102
- data/test/unit/models/link_test.rb +0 -52
- data/test/unit/models/page_partial_test.rb +0 -29
- data/test/unit/models/page_route_test.rb +0 -29
- data/test/unit/models/page_template_test.rb +0 -40
- data/test/unit/models/page_test.rb +0 -792
- data/test/unit/models/permission_test.rb +0 -10
- data/test/unit/models/portlet_test.rb +0 -69
- data/test/unit/models/sections_test.rb +0 -264
- data/test/unit/models/site_test.rb +0 -50
- data/test/unit/models/task_test.rb +0 -141
- data/test/unit/models/user_test.rb +0 -352
- data/test/unit/schema_statements_test.rb +0 -41
data/app/models/content_type.rb
CHANGED
|
@@ -5,9 +5,9 @@ class ContentType < ActiveRecord::Base
|
|
|
5
5
|
validates_presence_of :content_type_group
|
|
6
6
|
before_validation :set_content_type_group
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
scope :named, lambda{|name| {:conditions => ['content_types.name = ?', name]}}
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
scope :connectable,
|
|
11
11
|
:include => :content_type_group,
|
|
12
12
|
:conditions => ['content_type_groups.name != ?', 'Categorization'],
|
|
13
13
|
:order => 'content_types.priority, content_types.name'
|
|
@@ -19,7 +19,7 @@ class ContentType < ActiveRecord::Base
|
|
|
19
19
|
# Given a 'key' like 'html_blocks' or 'portlet'
|
|
20
20
|
# Raises exception if nothing was found.
|
|
21
21
|
def self.find_by_key(key)
|
|
22
|
-
class_name = key.tableize.classify
|
|
22
|
+
class_name = key.singularize.tableize.classify
|
|
23
23
|
content_type = find_by_name(class_name)
|
|
24
24
|
if content_type.nil?
|
|
25
25
|
if class_name.constantize.ancestors.include?(Portlet)
|
data/app/models/dynamic_view.rb
CHANGED
|
@@ -3,7 +3,7 @@ class DynamicView < ActiveRecord::Base
|
|
|
3
3
|
after_save :write_file_to_disk
|
|
4
4
|
after_destroy :remove_file_from_disk
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
scope :with_file_name, lambda{|file_name|
|
|
7
7
|
conditions = {:name => nil, :format => nil, :handler => nil}
|
|
8
8
|
if file_name && (parts = file_name.split(".")).size == 3
|
|
9
9
|
conditions[:name] = parts[0]
|
data/app/models/email_message.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
class EmailMessage < ActiveRecord::Base
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
scope :undelivered, :conditions => "delivered_at is null"
|
|
4
4
|
|
|
5
5
|
validates_presence_of :recipients
|
|
6
6
|
|
|
@@ -24,7 +24,7 @@ class EmailMessage < ActiveRecord::Base
|
|
|
24
24
|
|
|
25
25
|
def deliver!
|
|
26
26
|
return false if delivered?
|
|
27
|
-
EmailMessageMailer.
|
|
27
|
+
EmailMessageMailer.email_message(self).deliver
|
|
28
28
|
update_attributes(:delivered_at => Time.now)
|
|
29
29
|
end
|
|
30
30
|
|
data/app/models/file_block.rb
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
class FileBlock < AbstractFileBlock
|
|
2
2
|
|
|
3
3
|
acts_as_content_block :belongs_to_attachment => true, :taggable => true
|
|
4
|
+
|
|
5
|
+
def set_attachment_file_path
|
|
6
|
+
if @attachment_file_path && @attachment_file_path != attachment.file_path
|
|
7
|
+
attachment.file_path = @attachment_file_path
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def set_attachment_section
|
|
12
|
+
if @attachment_section_id && @attachment_section_id != attachment.section_id
|
|
13
|
+
attachment.section_id = @attachment_section_id
|
|
14
|
+
end
|
|
15
|
+
end
|
|
4
16
|
|
|
5
17
|
def self.display_name
|
|
6
18
|
"File"
|
data/app/models/group.rb
CHANGED
|
@@ -19,11 +19,11 @@ class Group < ActiveRecord::Base
|
|
|
19
19
|
|
|
20
20
|
validates_presence_of :name
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
scope :named, lambda{|n| {:conditions => {:name => n}}}
|
|
23
|
+
scope :with_code, lambda{|c| {:conditions => {:code => c}}}
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
scope :public_groups, :include => :group_type, :conditions => ["group_types.cms_access = ?", false]
|
|
26
|
+
scope :cms_access, :include => :group_type, :conditions => ["group_types.cms_access = ?", true]
|
|
27
27
|
|
|
28
28
|
def guest?
|
|
29
29
|
group_type && group_type.guest?
|
data/app/models/group_type.rb
CHANGED
|
@@ -3,10 +3,10 @@ class GroupType < ActiveRecord::Base
|
|
|
3
3
|
has_many :group_type_permissions
|
|
4
4
|
has_many :permissions, :through => :group_type_permissions
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
scope :guest, :conditions => ["group_types.guest = ?", true]
|
|
7
|
+
scope :non_guest, :conditions => ["group_types.guest = ?", false]
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
scope :cms_access, :conditions => ["group_types.cms_access = ?", true]
|
|
10
|
+
scope :non_cms_access, :conditions => ["group_types.cms_access = ?", false]
|
|
11
11
|
|
|
12
12
|
end
|
data/app/models/html_block.rb
CHANGED
|
@@ -5,7 +5,7 @@ class HtmlBlock < ActiveRecord::Base
|
|
|
5
5
|
validates_presence_of :name
|
|
6
6
|
|
|
7
7
|
# Override of search scope from searching behavior to deal with include_body
|
|
8
|
-
|
|
8
|
+
scope :search, lambda{|search_params|
|
|
9
9
|
term = search_params.is_a?(Hash) ? search_params[:term] : search_params
|
|
10
10
|
order = search_params.is_a?(Hash) && search_params[:order] ? search_params[:order] : "html_blocks.name"
|
|
11
11
|
include_body = search_params.is_a?(Hash) ? search_params[:include_body] : false
|
data/app/models/image_block.rb
CHANGED
|
@@ -3,6 +3,18 @@ class ImageBlock < AbstractFileBlock
|
|
|
3
3
|
acts_as_content_block :versioned => { :version_foreign_key => :file_block_id },
|
|
4
4
|
:belongs_to_attachment => true, :taggable => true
|
|
5
5
|
|
|
6
|
+
def set_attachment_file_path
|
|
7
|
+
if @attachment_file_path && @attachment_file_path != attachment.file_path
|
|
8
|
+
attachment.file_path = @attachment_file_path
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def set_attachment_section
|
|
13
|
+
if @attachment_section_id && @attachment_section_id != attachment.section_id
|
|
14
|
+
attachment.section_id = @attachment_section_id
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
6
18
|
def self.display_name
|
|
7
19
|
"Image"
|
|
8
20
|
end
|
data/app/models/link.rb
CHANGED
|
@@ -1,14 +1,31 @@
|
|
|
1
1
|
class Link < ActiveRecord::Base
|
|
2
2
|
acts_as_content_block :connectable => false
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
scope :named, lambda{|name| {:conditions => ['links.name = ?', name]}}
|
|
5
|
+
|
|
6
|
+
has_one :section_node, :as => :node, :dependent => :destroy
|
|
5
7
|
|
|
6
|
-
has_one :section_node, :as => :node, :dependent => :destroy, :inverse_of => :node
|
|
7
|
-
|
|
8
8
|
validates_presence_of :name
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
def section_id
|
|
11
|
+
section ? section.id : nil
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def section
|
|
15
|
+
section_node ? section_node.section : nil
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def section_id=(sec_id)
|
|
19
|
+
self.section = Section.find(sec_id)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def section=(sec)
|
|
23
|
+
if section_node
|
|
24
|
+
section_node.move_to_end(sec)
|
|
25
|
+
else
|
|
26
|
+
build_section_node(:node => self, :section => sec)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
12
29
|
|
|
13
30
|
#needed by menu_helper
|
|
14
31
|
def path
|
data/app/models/page.rb
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
class Page < ActiveRecord::Base
|
|
2
|
-
|
|
2
|
+
|
|
3
3
|
is_archivable
|
|
4
4
|
flush_cache_on_change
|
|
5
5
|
is_hideable
|
|
@@ -11,8 +11,8 @@ class Page < ActiveRecord::Base
|
|
|
11
11
|
has_many :connectors, :order => "connectors.container, connectors.position"
|
|
12
12
|
has_many :page_routes
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
scope :named, lambda{|name| {:conditions => ['pages.name = ?', name]}}
|
|
15
|
+
scope :with_path, lambda{|path| {:conditions => ['pages.path = ?', path]}}
|
|
16
16
|
|
|
17
17
|
# This scope will accept a connectable object or a Hash. The Hash is expect to have
|
|
18
18
|
# a value for the key :connectable, which is the connectable object, and possibly
|
|
@@ -20,7 +20,7 @@ class Page < ActiveRecord::Base
|
|
|
20
20
|
# it will use the value in :version if present, otherwise it will use the version
|
|
21
21
|
# of the object. In either case of a connectable object or a Hash, if the object
|
|
22
22
|
# is not versioned, no version will be used
|
|
23
|
-
|
|
23
|
+
scope :connected_to, lambda { |b|
|
|
24
24
|
if b.is_a?(Hash)
|
|
25
25
|
obj = b[:connectable]
|
|
26
26
|
if obj.class.versioned?
|
|
@@ -32,7 +32,7 @@ class Page < ActiveRecord::Base
|
|
|
32
32
|
obj = b
|
|
33
33
|
ver = obj.class.versioned? ? obj.version : nil
|
|
34
34
|
end
|
|
35
|
-
|
|
35
|
+
|
|
36
36
|
if ver
|
|
37
37
|
{ :include => :connectors,
|
|
38
38
|
:conditions => ['connectors.connectable_id = ? and connectors.connectable_type = ? and connectors.connectable_version = ?', obj.id, obj.class.base_class.name, ver] }
|
|
@@ -41,20 +41,33 @@ class Page < ActiveRecord::Base
|
|
|
41
41
|
:conditions => ['connectors.connectable_id = ? and connectors.connectable_type = ?', obj.id, obj.class.base_class.name] }
|
|
42
42
|
end
|
|
43
43
|
}
|
|
44
|
-
|
|
45
|
-
has_one :section_node, :as => :node, :dependent => :destroy, :inverse_of => :node
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
include Addressable
|
|
49
|
-
include Addressable::DeprecatedPageAccessors
|
|
50
44
|
|
|
45
|
+
# currently_connected_to tightens the scope of connected_to by restricting to the
|
|
46
|
+
# results to matches on current versions of pages only. This renders obj versions
|
|
47
|
+
# useless, as the older objects will very likely have older versions of pages and
|
|
48
|
+
# thus return no results.
|
|
49
|
+
scope :currently_connected_to, lambda { |obj|
|
|
50
|
+
ver = obj.class.versioned? ? obj.version : nil
|
|
51
|
+
if ver
|
|
52
|
+
{ :include => :connectors,
|
|
53
|
+
:conditions => ['connectors.connectable_id = ? and connectors.connectable_type = ? and connectors.connectable_version = ? and connectors.page_version = pages.version', obj.id, obj.class.base_class.name, ver] }
|
|
54
|
+
else
|
|
55
|
+
{ :include => :connectors,
|
|
56
|
+
:conditions => ['connectors.connectable_id = ? and connectors.connectable_type = ? and connectors.page_version = pages.version', obj.id, obj.class.base_class.name] }
|
|
57
|
+
end
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
has_one :section_node, :as => :node, :dependent => :destroy
|
|
61
|
+
|
|
51
62
|
has_many :tasks
|
|
52
63
|
|
|
53
|
-
before_validation :append_leading_slash_to_path
|
|
64
|
+
before_validation :append_leading_slash_to_path, :remove_trailing_slash_from_path
|
|
54
65
|
before_destroy :delete_connectors
|
|
55
66
|
|
|
56
67
|
validates_presence_of :name, :path
|
|
57
|
-
|
|
68
|
+
|
|
69
|
+
# Paths must be unique among undeleted records
|
|
70
|
+
validates_uniqueness_of :path, :scope=>:deleted
|
|
58
71
|
validate :path_not_reserved
|
|
59
72
|
|
|
60
73
|
def after_build_new_version(new_version)
|
|
@@ -75,15 +88,22 @@ class Page < ActiveRecord::Base
|
|
|
75
88
|
end
|
|
76
89
|
end
|
|
77
90
|
end
|
|
78
|
-
|
|
91
|
+
|
|
92
|
+
# Each time a page is updated, we need to copy all connectors associated with it forward, and save
|
|
93
|
+
# them.
|
|
79
94
|
def copy_connectors(options={})
|
|
80
|
-
connectors
|
|
95
|
+
logger.debug {"Copying connectors from Page #{id} v#{options[:from_version_number]} to v#{options[:to_version_number]}." }
|
|
96
|
+
|
|
97
|
+
c_found = connectors.for_page_version(options[:from_version_number]).all(:order => "connectors.container, connectors.position")
|
|
98
|
+
logger.debug {"Found connectors #{c_found}" }
|
|
99
|
+
c_found.each do |c|
|
|
81
100
|
# The connector won't have a connectable if it has been deleted
|
|
82
101
|
# Also need to see if the draft has been deleted,
|
|
83
102
|
# in which case we are in the process of deleting it
|
|
84
103
|
if c.should_be_copied?
|
|
104
|
+
logger.debug { "Connector id=>#{c.id} should be copied." }
|
|
85
105
|
connectable = c.connectable_type.constantize.versioned? ? c.connectable.as_of_version(c.connectable_version) : c.connectable
|
|
86
|
-
|
|
106
|
+
|
|
87
107
|
version = connectable.class.versioned? ? connectable.version : nil
|
|
88
108
|
|
|
89
109
|
#If we are copying connectors from a previous version, that means we are reverting this page,
|
|
@@ -96,20 +116,26 @@ class Page < ActiveRecord::Base
|
|
|
96
116
|
connectable.revert_to(c.connectable_version)
|
|
97
117
|
version = connectable.class.versioned? ? connectable.draft.version : nil
|
|
98
118
|
end
|
|
99
|
-
|
|
100
|
-
|
|
119
|
+
|
|
120
|
+
logger.debug "When copying block #{connectable.inspect} version is '#{version}'"
|
|
121
|
+
|
|
122
|
+
new_connector = connectors.create(
|
|
101
123
|
:page_version => options[:to_version_number],
|
|
102
124
|
:connectable => connectable,
|
|
103
|
-
:connectable_version => version,
|
|
125
|
+
:connectable_version => version,
|
|
104
126
|
:container => c.container,
|
|
105
127
|
:position => c.position
|
|
106
128
|
)
|
|
129
|
+
logger.debug {"Built new connector #{new_connector}."}
|
|
107
130
|
end
|
|
108
131
|
end
|
|
109
132
|
true
|
|
110
133
|
end
|
|
111
|
-
|
|
112
|
-
|
|
134
|
+
|
|
135
|
+
# Adds a Content block to this page.
|
|
136
|
+
#
|
|
137
|
+
#
|
|
138
|
+
def create_connector(connectable, container=:main)
|
|
113
139
|
transaction do
|
|
114
140
|
raise "Connectable is nil" unless connectable
|
|
115
141
|
raise "Container is required" if container.blank?
|
|
@@ -126,6 +152,7 @@ class Page < ActiveRecord::Base
|
|
|
126
152
|
:container => container)
|
|
127
153
|
end
|
|
128
154
|
end
|
|
155
|
+
alias_method :add_content, :create_connector
|
|
129
156
|
|
|
130
157
|
def move_connector(connector, direction)
|
|
131
158
|
transaction do
|
|
@@ -156,7 +183,8 @@ class Page < ActiveRecord::Base
|
|
|
156
183
|
end
|
|
157
184
|
end
|
|
158
185
|
end
|
|
159
|
-
|
|
186
|
+
|
|
187
|
+
# Pages that get deleted should be 'disconnected' from any blocks they were associated with.
|
|
160
188
|
def delete_connectors
|
|
161
189
|
connectors.for_page_version(version).all.each{|c| c.destroy }
|
|
162
190
|
end
|
|
@@ -172,6 +200,26 @@ class Page < ActiveRecord::Base
|
|
|
172
200
|
"?"
|
|
173
201
|
end
|
|
174
202
|
|
|
203
|
+
def section_id
|
|
204
|
+
section ? section.id : nil
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
def section
|
|
208
|
+
section_node ? section_node.section : nil
|
|
209
|
+
end
|
|
210
|
+
|
|
211
|
+
def section_id=(sec_id)
|
|
212
|
+
self.section = Section.find(sec_id)
|
|
213
|
+
end
|
|
214
|
+
|
|
215
|
+
def section=(sec)
|
|
216
|
+
if section_node
|
|
217
|
+
section_node.move_to_end(sec)
|
|
218
|
+
else
|
|
219
|
+
build_section_node(:node => self, :section => sec)
|
|
220
|
+
end
|
|
221
|
+
end
|
|
222
|
+
|
|
175
223
|
def public?
|
|
176
224
|
section ? section.public? : false
|
|
177
225
|
end
|
|
@@ -187,6 +235,12 @@ class Page < ActiveRecord::Base
|
|
|
187
235
|
self.path = "/#{path}"
|
|
188
236
|
end
|
|
189
237
|
end
|
|
238
|
+
|
|
239
|
+
# remove trailing slash, unless the path is only a slash. uses capture and
|
|
240
|
+
# substition because ruby regex engine does not support lookbehind
|
|
241
|
+
def remove_trailing_slash_from_path
|
|
242
|
+
self.path.sub!(/(.+)\/+$/, '\1')
|
|
243
|
+
end
|
|
190
244
|
|
|
191
245
|
def path_not_reserved
|
|
192
246
|
if Cms.reserved_paths.include?(path)
|
|
@@ -207,25 +261,16 @@ class Page < ActiveRecord::Base
|
|
|
207
261
|
template_file_name && PageTemplate.display_name(template_file_name)
|
|
208
262
|
end
|
|
209
263
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
264
|
+
def ancestors
|
|
265
|
+
section_node.ancestors
|
|
266
|
+
end
|
|
267
|
+
|
|
213
268
|
def in_section?(section_or_section_name)
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
break
|
|
220
|
-
end
|
|
221
|
-
else
|
|
222
|
-
if a == section_or_section_name
|
|
223
|
-
found = true
|
|
224
|
-
break
|
|
225
|
-
end
|
|
226
|
-
end
|
|
227
|
-
end
|
|
228
|
-
found
|
|
269
|
+
sec = section_or_section_name.is_a?(String) ?
|
|
270
|
+
Section.first(:conditions => {:name => section_or_section_name}) :
|
|
271
|
+
section_or_section_name
|
|
272
|
+
fn = lambda{|s| s ? (s == sec || fn.call(s.parent)) : false}
|
|
273
|
+
fn.call(section)
|
|
229
274
|
end
|
|
230
275
|
|
|
231
276
|
#Returns true if the block attached to each connector in the given container are published
|
|
@@ -249,16 +294,12 @@ class Page < ActiveRecord::Base
|
|
|
249
294
|
(a[1..a.size].map{|a| a.name} + [name]).join(" / ")
|
|
250
295
|
end
|
|
251
296
|
|
|
252
|
-
# This will return the "top level section" for
|
|
297
|
+
# This will return the "top level section" for a page, which is the section directly
|
|
253
298
|
# below the root (a.k.a My Site) that this page is in. If this page is in root,
|
|
254
299
|
# then this will return root.
|
|
255
|
-
#
|
|
256
|
-
# @return [Section] The first non-root ancestor if available, root otherwise.
|
|
257
300
|
def top_level_section
|
|
258
|
-
# Cache the results of this since many projects will call it repeatly on current_page in menus.
|
|
259
|
-
return @top_level_section if @top_level_section
|
|
260
301
|
a = ancestors
|
|
261
|
-
|
|
302
|
+
(a.size > 0 && ancestors[1]) ? ancestors[1] : Section.root.first
|
|
262
303
|
end
|
|
263
304
|
|
|
264
305
|
def current_task
|
data/app/models/page_route.rb
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
# Allows Rails routes to be matched to CMS pages, allowing arbitrary code that can be executed before the page is rendered.
|
|
2
|
+
#
|
|
3
|
+
# The primary goal of this is to provide human readable (and cachable) URLs for content_blocks. For example,
|
|
4
|
+
# a single 'Article' page can have a portlet that knows how to look up and display an Article by id. By default, this
|
|
5
|
+
# would look like this:
|
|
6
|
+
# GET /article?id=120
|
|
7
|
+
#
|
|
8
|
+
# Unless the Article page is marked a 'cache enabled = false' this will cause problems. Plus that URL is ugly.
|
|
9
|
+
# With PageRoutes, you can have multiple URLs all map to the article page, like so:
|
|
10
|
+
# GET /article/2010/12/30/article-1
|
|
11
|
+
# GET /article/2011/1/18/article-2
|
|
12
|
+
# In both these cases, these URLs can be matched to a Rails Route which is linked to a page:
|
|
13
|
+
# GET /article/:year/:month/:day/:slug -> Articles Page
|
|
14
|
+
#
|
|
15
|
+
# Saving a new PageRoute will reload the Rails routes.
|
|
16
|
+
#
|
|
1
17
|
class PageRoute < ActiveRecord::Base
|
|
2
18
|
belongs_to :page
|
|
3
19
|
has_many :conditions, :class_name => "PageRouteCondition"
|
|
@@ -8,22 +24,32 @@ class PageRoute < ActiveRecord::Base
|
|
|
8
24
|
|
|
9
25
|
after_save :reload_routes
|
|
10
26
|
|
|
27
|
+
# Force Rails to reload the routes. Allows modules to call this without concern that the Rails classes are going to change again.
|
|
28
|
+
def self.reload_routes
|
|
29
|
+
Rails.application.reload_routes!
|
|
30
|
+
end
|
|
31
|
+
|
|
11
32
|
def reload_routes
|
|
12
|
-
|
|
33
|
+
PageRoute.reload_routes
|
|
13
34
|
end
|
|
14
35
|
|
|
15
36
|
def add_condition(name, value)
|
|
16
37
|
conditions.build(:name => name.to_s, :value => value.to_s)
|
|
17
38
|
end
|
|
18
|
-
|
|
39
|
+
|
|
40
|
+
# @deprecated Use add_constraint instead (matches Rails 3 syntax)
|
|
19
41
|
def add_requirement(name, value)
|
|
20
42
|
requirements.build(:name => name.to_s, :value => value.to_s)
|
|
21
43
|
end
|
|
22
|
-
|
|
44
|
+
|
|
45
|
+
alias_method :add_constraint, :add_requirement
|
|
46
|
+
|
|
47
|
+
# @deprecated Rails 3 no longer uses a 'conditions' element in its syntax for routing.
|
|
23
48
|
def conditions_map
|
|
24
49
|
conditions.inject({}){|acc, e| acc[e.name.to_sym] = e.value.to_sym; acc}
|
|
25
50
|
end
|
|
26
|
-
|
|
51
|
+
|
|
52
|
+
|
|
27
53
|
def requirements_map
|
|
28
54
|
requirements.inject({}){|acc, e| acc[e.name.to_sym] = Regexp.new(e.value); acc}
|
|
29
55
|
end
|
|
@@ -31,8 +57,33 @@ class PageRoute < ActiveRecord::Base
|
|
|
31
57
|
def route_name
|
|
32
58
|
name ? name.to_slug.gsub('-','_') : nil
|
|
33
59
|
end
|
|
34
|
-
|
|
60
|
+
|
|
61
|
+
alias_method :as, :route_name
|
|
62
|
+
|
|
63
|
+
def to
|
|
64
|
+
"cms/content#show_page_route"
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
# Returns which methods this route can be via. Defaults to [:get, :post] if not specified.
|
|
68
|
+
def via
|
|
69
|
+
found = conditions.collect(){|condition| if condition.name.to_sym == :method; condition.value.to_sym end}
|
|
70
|
+
methods = found.compact
|
|
71
|
+
if methods.empty?
|
|
72
|
+
methods << :get << :post
|
|
73
|
+
end
|
|
74
|
+
methods
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# Builds a hash which can be passed to the :constraints value in a route, like:
|
|
78
|
+
#
|
|
79
|
+
# match 'some/:pattern', :constraints => page_route.constraints()
|
|
80
|
+
def constraints
|
|
81
|
+
requirements_map
|
|
82
|
+
end
|
|
83
|
+
|
|
35
84
|
# This is used in defining the route in the ActionController::Routing
|
|
85
|
+
# Used in Rails 2 version of routing (No longer valid for rails 3)
|
|
86
|
+
# @deprecated
|
|
36
87
|
def options_map
|
|
37
88
|
m = {:controller => "cms/content", :action => "show_page_route"}
|
|
38
89
|
|
|
@@ -43,7 +94,11 @@ class PageRoute < ActiveRecord::Base
|
|
|
43
94
|
|
|
44
95
|
m
|
|
45
96
|
end
|
|
46
|
-
|
|
97
|
+
|
|
98
|
+
def page_route_id
|
|
99
|
+
self.id.to_s
|
|
100
|
+
end
|
|
101
|
+
|
|
47
102
|
# This is called by an instance of the content controller
|
|
48
103
|
# in the process of rendering a page. This will eval the code
|
|
49
104
|
# stored in this page route in the context of the controller.
|