crystal-ext 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Rakefile +66 -0
- data/lib/abstract_interface/controller_helper.rb +30 -0
- data/lib/abstract_interface/form_builders/abstract_form_builder.rb +79 -0
- data/lib/abstract_interface/form_builders/themed_form_builder.rb +46 -0
- data/lib/abstract_interface/form_builders/themed_form_tag_builder.rb +13 -0
- data/lib/abstract_interface/haml_builder.rb +56 -0
- data/lib/abstract_interface/model_stub.rb +20 -0
- data/lib/abstract_interface/support.rb +56 -0
- data/lib/abstract_interface/theme.rb +37 -0
- data/lib/abstract_interface/view_builder.rb +158 -0
- data/lib/abstract_interface/view_helper.rb +31 -0
- data/lib/abstract_interface.rb +78 -0
- data/lib/common_interface/MIT-LICENSE +20 -0
- data/lib/common_interface/README.md +51 -0
- data/lib/common_interface/app/controllers/theme_controller.rb +65 -0
- data/lib/common_interface/app/controllers/theme_site_controller.rb +2 -0
- data/lib/common_interface/app/views/layouts/theme.html.erb +1 -0
- data/lib/common_interface/app/views/layouts/theme.js.erb +11 -0
- data/lib/common_interface/app/views/theme/_dialog.html.haml +7 -0
- data/lib/common_interface/app/views/theme/_popup.html.haml +4 -0
- data/lib/common_interface/app/views/theme/aspects.html.haml +32 -0
- data/lib/common_interface/app/views/theme/basic.html.haml +123 -0
- data/lib/common_interface/app/views/theme/dialog.js.erb +1 -0
- data/lib/common_interface/app/views/theme/folder.html.haml +45 -0
- data/lib/common_interface/app/views/theme/help.html.haml +7 -0
- data/lib/common_interface/app/views/theme/index.html.haml +24 -0
- data/lib/common_interface/app/views/theme/items.html.haml +91 -0
- data/lib/common_interface/app/views/theme/list.html.haml +23 -0
- data/lib/common_interface/app/views/theme/page/_folder.html.haml +10 -0
- data/lib/common_interface/app/views/theme/page/_note.html.haml +4 -0
- data/lib/common_interface/app/views/theme/page/_toolbar.html.haml +5 -0
- data/lib/common_interface/app/views/theme/page.html.haml +19 -0
- data/lib/common_interface/app/views/theme/popup.js.erb +1 -0
- data/lib/common_interface/app/views/theme/selector.html.haml +38 -0
- data/lib/common_interface/app/views/theme/style.html.erb +113 -0
- data/lib/common_interface/app/views/theme/tmp.html.erb +31 -0
- data/lib/common_interface/app/views/theme/user.html.haml +16 -0
- data/lib/common_interface/app/views/theme_shared/_comments.html.haml +11 -0
- data/lib/common_interface/app/views/theme_shared/_core_tools.html.haml +6 -0
- data/lib/common_interface/app/views/theme_shared/_line_previews.html.haml +39 -0
- data/lib/common_interface/app/views/theme_shared/_paginator.html.haml +7 -0
- data/lib/common_interface/app/views/theme_shared/_tools.html.haml +27 -0
- data/lib/common_interface/app/views/theme_shared/_top_navigation_bottom.html.haml +32 -0
- data/lib/common_interface/app/views/theme_site/blog.html.haml +13 -0
- data/lib/common_interface/app/views/theme_site/home.html.haml +9 -0
- data/lib/common_interface/app/views/theme_site/post.html.haml +11 -0
- data/lib/common_interface/app/views/theme_site/style.html.haml +9 -0
- data/lib/common_interface/app/views/themes/default/_application_t.html.haml +29 -0
- data/lib/common_interface/app/views/themes/default/_help_t.html.haml +1 -0
- data/lib/common_interface/app/views/themes/default/aspects/_comment_t.html.haml +14 -0
- data/lib/common_interface/app/views/themes/default/aspects/_controls_t.html.haml +3 -0
- data/lib/common_interface/app/views/themes/default/aspects/_details_t.html.haml +6 -0
- data/lib/common_interface/app/views/themes/default/aspects/_discussion_t.html.haml +9 -0
- data/lib/common_interface/app/views/themes/default/aspects/_paginator_t.html.haml +8 -0
- data/lib/common_interface/app/views/themes/default/aspects/_tag_selector_t.html.haml +11 -0
- data/lib/common_interface/app/views/themes/default/basic/_bottom_panel_t.html.haml +9 -0
- data/lib/common_interface/app/views/themes/default/basic/_dialog_t.html.haml +1 -0
- data/lib/common_interface/app/views/themes/default/basic/_divider_t.html.haml +2 -0
- data/lib/common_interface/app/views/themes/default/basic/_html_t.html.haml +1 -0
- data/lib/common_interface/app/views/themes/default/basic/_inplace_t.html.haml +1 -0
- data/lib/common_interface/app/views/themes/default/basic/_message_t.html.haml +3 -0
- data/lib/common_interface/app/views/themes/default/basic/_more_t.html.haml +5 -0
- data/lib/common_interface/app/views/themes/default/basic/_narrow_t.html.haml +1 -0
- data/lib/common_interface/app/views/themes/default/basic/_navigation_t.html.haml +9 -0
- data/lib/common_interface/app/views/themes/default/basic/_popup_t.html.haml +1 -0
- data/lib/common_interface/app/views/themes/default/basic/_text_t.html.haml +1 -0
- data/lib/common_interface/app/views/themes/default/basic/_title_t.html.haml +3 -0
- data/lib/common_interface/app/views/themes/default/basic/_tool_t.html.haml +4 -0
- data/lib/common_interface/app/views/themes/default/basic/_top_panel_t.html.haml +18 -0
- data/lib/common_interface/app/views/themes/default/components/_basic_list_item_t.html.haml +4 -0
- data/lib/common_interface/app/views/themes/default/components/_basic_list_t.html.haml +1 -0
- data/lib/common_interface/app/views/themes/default/components/_table_row_t.html.haml +5 -0
- data/lib/common_interface/app/views/themes/default/components/_table_t.html.haml +12 -0
- data/lib/common_interface/app/views/themes/default/components/_tabs_item_t.html.haml +4 -0
- data/lib/common_interface/app/views/themes/default/components/_tabs_t.html.haml +4 -0
- data/lib/common_interface/app/views/themes/default/components/_toolbar_t.html.haml +14 -0
- data/lib/common_interface/app/views/themes/default/forms/_begin_t.html.erb +3 -0
- data/lib/common_interface/app/views/themes/default/forms/_end_t.html.erb +3 -0
- data/lib/common_interface/app/views/themes/default/forms/_errors_t.html.haml +5 -0
- data/lib/common_interface/app/views/themes/default/forms/_field_t.html.haml +19 -0
- data/lib/common_interface/app/views/themes/default/forms/_line_t.html.haml +6 -0
- data/lib/common_interface/app/views/themes/default/items/_file_t.html.haml +19 -0
- data/lib/common_interface/app/views/themes/default/items/_folder_t.html.haml +23 -0
- data/lib/common_interface/app/views/themes/default/items/_line_t.html.haml +34 -0
- data/lib/common_interface/app/views/themes/default/items/_list_item_t.html.haml +16 -0
- data/lib/common_interface/app/views/themes/default/items/_list_t.html.haml +35 -0
- data/lib/common_interface/app/views/themes/default/items/_note_t.html.haml +16 -0
- data/lib/common_interface/app/views/themes/default/items/_page_t.html.haml +29 -0
- data/lib/common_interface/app/views/themes/default/items/_selector_t.html.haml +18 -0
- data/lib/common_interface/app/views/themes/default/items/_thumb_t.html.haml +12 -0
- data/lib/common_interface/app/views/themes/default/items/_user_t.html.haml +12 -0
- data/lib/common_interface/app/views/themes/default/layout_templates/_dashboard_t.html.haml +1 -0
- data/lib/common_interface/app/views/themes/default/layout_templates/_default_t.html.haml +11 -0
- data/lib/common_interface/app/views/themes/default/metadata.rb +117 -0
- data/lib/common_interface/app/views/themes/simple_organization/_application_js_t.html.erb +12 -0
- data/lib/common_interface/app/views/themes/simple_organization/_application_t.html.erb +45 -0
- data/lib/common_interface/app/views/themes/simple_organization/_help_t.html.erb +1 -0
- data/lib/common_interface/app/views/themes/simple_organization/aspects/_comment_t.html.haml +21 -0
- data/lib/common_interface/app/views/themes/simple_organization/aspects/_discussion_t.html.haml +14 -0
- data/lib/common_interface/app/views/themes/simple_organization/aspects/_paginator_t.html.haml +5 -0
- data/lib/common_interface/app/views/themes/simple_organization/aspects/_tag_selector_t.html.haml +10 -0
- data/lib/common_interface/app/views/themes/simple_organization/basic/_bottom_panel_t.html.erb +12 -0
- data/lib/common_interface/app/views/themes/simple_organization/basic/_divider_t.html.erb +3 -0
- data/lib/common_interface/app/views/themes/simple_organization/basic/_message_t.html.erb +7 -0
- data/lib/common_interface/app/views/themes/simple_organization/basic/_more_t.html.haml +5 -0
- data/lib/common_interface/app/views/themes/simple_organization/basic/_navigation_t.html.erb +15 -0
- data/lib/common_interface/app/views/themes/simple_organization/basic/_text_t.html.haml +1 -0
- data/lib/common_interface/app/views/themes/simple_organization/basic/_tool_t.html.erb +9 -0
- data/lib/common_interface/app/views/themes/simple_organization/basic/_top_panel_t.html.erb +14 -0
- data/lib/common_interface/app/views/themes/simple_organization/items/_line_t.html.haml +17 -0
- data/lib/common_interface/app/views/themes/simple_organization/items/_note_t.html.haml +16 -0
- data/lib/common_interface/app/views/themes/simple_organization/items/_selector_t.html.haml +11 -0
- data/lib/common_interface/app/views/themes/simple_organization/layout_templates/_default_t.html.erb +20 -0
- data/lib/common_interface/app/views/themes/simple_organization/layout_templates/_home_t.html.erb +14 -0
- data/lib/common_interface/app/views/themes/simple_organization/metadata.rb +193 -0
- data/lib/common_interface/asset_packages.yml +89 -0
- data/lib/common_interface/init.rb +21 -0
- data/lib/common_interface/lib/common_interface_helper.rb +49 -0
- data/lib/common_interface/public/common_interface/images/img1.jpg +0 -0
- data/lib/common_interface/public/common_interface/images/img1_200.jpg +0 -0
- data/lib/common_interface/public/common_interface/images/img1_icon.jpg +0 -0
- data/lib/common_interface/public/common_interface/images/img1_thumb.jpg +0 -0
- data/lib/common_interface/public/common_interface/images/img2.jpg +0 -0
- data/lib/common_interface/public/common_interface/images/img2_200.jpg +0 -0
- data/lib/common_interface/public/common_interface/images/img2_icon.jpg +0 -0
- data/lib/common_interface/public/common_interface/images/img2_thumb.jpg +0 -0
- data/lib/common_interface/public/common_interface/images/img3.jpg +0 -0
- data/lib/common_interface/public/common_interface/images/img3_200.jpg +0 -0
- data/lib/common_interface/public/common_interface/images/img3_icon.jpg +0 -0
- data/lib/common_interface/public/common_interface/images/img3_thumb.jpg +0 -0
- data/lib/common_interface/public/common_interface/images/video_icon.png +0 -0
- data/lib/common_interface/public/common_interface/js/aspects.js +0 -0
- data/lib/common_interface/public/common_interface/js/basic.js +229 -0
- data/lib/common_interface/public/common_interface/js/files_upload.js +115 -0
- data/lib/common_interface/public/common_interface/js/items.js +118 -0
- data/lib/common_interface/public/common_interface/js/style.js +50 -0
- data/lib/common_interface/public/common_interface/lib/jquery.elastic.js +117 -0
- data/lib/common_interface/public/common_interface/lib/jquery.fancybox/blank.gif +0 -0
- data/lib/common_interface/public/common_interface/lib/jquery.fancybox/fancy_close.png +0 -0
- data/lib/common_interface/public/common_interface/lib/jquery.fancybox/fancy_loading.png +0 -0
- data/lib/common_interface/public/common_interface/lib/jquery.fancybox/fancy_nav_left.png +0 -0
- data/lib/common_interface/public/common_interface/lib/jquery.fancybox/fancy_nav_right.png +0 -0
- data/lib/common_interface/public/common_interface/lib/jquery.fancybox/fancy_shadow_e.png +0 -0
- data/lib/common_interface/public/common_interface/lib/jquery.fancybox/fancy_shadow_n.png +0 -0
- data/lib/common_interface/public/common_interface/lib/jquery.fancybox/fancy_shadow_ne.png +0 -0
- data/lib/common_interface/public/common_interface/lib/jquery.fancybox/fancy_shadow_nw.png +0 -0
- data/lib/common_interface/public/common_interface/lib/jquery.fancybox/fancy_shadow_s.png +0 -0
- data/lib/common_interface/public/common_interface/lib/jquery.fancybox/fancy_shadow_se.png +0 -0
- data/lib/common_interface/public/common_interface/lib/jquery.fancybox/fancy_shadow_sw.png +0 -0
- data/lib/common_interface/public/common_interface/lib/jquery.fancybox/fancy_shadow_w.png +0 -0
- data/lib/common_interface/public/common_interface/lib/jquery.fancybox/fancy_title_left.png +0 -0
- data/lib/common_interface/public/common_interface/lib/jquery.fancybox/fancy_title_main.png +0 -0
- data/lib/common_interface/public/common_interface/lib/jquery.fancybox/fancy_title_over.png +0 -0
- data/lib/common_interface/public/common_interface/lib/jquery.fancybox/fancy_title_right.png +0 -0
- data/lib/common_interface/public/common_interface/lib/jquery.fancybox/fancybox-x.png +0 -0
- data/lib/common_interface/public/common_interface/lib/jquery.fancybox/fancybox-y.png +0 -0
- data/lib/common_interface/public/common_interface/lib/jquery.fancybox/fancybox.png +0 -0
- data/lib/common_interface/public/common_interface/lib/jquery.fancybox/jquery.easing-1.3.pack.js +72 -0
- data/lib/common_interface/public/common_interface/lib/jquery.fancybox/jquery.fancybox-1.3.1.js +1077 -0
- data/lib/common_interface/public/common_interface/lib/jquery.fancybox/jquery.fancybox.css +363 -0
- data/lib/common_interface/public/common_interface/lib/jquery.fancybox/jquery.fancybox.js +44 -0
- data/lib/common_interface/public/common_interface/lib/jquery.fancybox/jquery.mousewheel-3.0.2.pack.js +13 -0
- data/lib/common_interface/public/common_interface/lib/jquery.form.js +660 -0
- data/lib/common_interface/public/common_interface/lib/jquery.hoverIntent.js +111 -0
- data/lib/common_interface/public/common_interface/lib/jquery.jgrowl/jquery.jgrowl.css +128 -0
- data/lib/common_interface/public/common_interface/lib/jquery.jgrowl/jquery.jgrowl.js +307 -0
- data/lib/common_interface/public/common_interface/lib/jquery.js +4376 -0
- data/lib/common_interface/public/common_interface/lib/jquery.json.js +178 -0
- data/lib/common_interface/public/common_interface/lib/jquery.swfupload/cancel.png +0 -0
- data/lib/common_interface/public/common_interface/lib/jquery.swfupload/jquery.swfupload.js +64 -0
- data/lib/common_interface/public/common_interface/lib/jquery.swfupload/style.css +8 -0
- data/lib/common_interface/public/common_interface/lib/jquery.swfupload/swfupload/swfupload.js +980 -0
- data/lib/common_interface/public/common_interface/lib/jquery.swfupload/swfupload/swfupload.queue.js +98 -0
- data/lib/common_interface/public/common_interface/lib/jquery.swfupload/swfupload/swfupload.swf +0 -0
- data/lib/common_interface/public/common_interface/lib/jquery.swfupload/swfupload/wdp_buttons_upload_61x22.png +0 -0
- data/lib/common_interface/public/common_interface/lib/jquery.template.js +255 -0
- data/lib/common_interface/public/common_interface/lib/jquery.ui/images/ui-bg_diagonals-thick_18_b81900_40x40.png +0 -0
- data/lib/common_interface/public/common_interface/lib/jquery.ui/images/ui-bg_diagonals-thick_20_666666_40x40.png +0 -0
- data/lib/common_interface/public/common_interface/lib/jquery.ui/images/ui-bg_flat_10_000000_40x100.png +0 -0
- data/lib/common_interface/public/common_interface/lib/jquery.ui/images/ui-bg_glass_100_f6f6f6_1x400.png +0 -0
- data/lib/common_interface/public/common_interface/lib/jquery.ui/images/ui-bg_glass_100_fdf5ce_1x400.png +0 -0
- data/lib/common_interface/public/common_interface/lib/jquery.ui/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/lib/common_interface/public/common_interface/lib/jquery.ui/images/ui-bg_gloss-wave_35_f6a828_500x100.png +0 -0
- data/lib/common_interface/public/common_interface/lib/jquery.ui/images/ui-bg_highlight-soft_100_eeeeee_1x100.png +0 -0
- data/lib/common_interface/public/common_interface/lib/jquery.ui/images/ui-bg_highlight-soft_75_ffe45c_1x100.png +0 -0
- data/lib/common_interface/public/common_interface/lib/jquery.ui/images/ui-icons_222222_256x240.png +0 -0
- data/lib/common_interface/public/common_interface/lib/jquery.ui/images/ui-icons_228ef1_256x240.png +0 -0
- data/lib/common_interface/public/common_interface/lib/jquery.ui/images/ui-icons_ef8c08_256x240.png +0 -0
- data/lib/common_interface/public/common_interface/lib/jquery.ui/images/ui-icons_ffd27a_256x240.png +0 -0
- data/lib/common_interface/public/common_interface/lib/jquery.ui/images/ui-icons_ffffff_256x240.png +0 -0
- data/lib/common_interface/public/common_interface/lib/jquery.ui/jquery.ui.css +406 -0
- data/lib/common_interface/public/common_interface/lib/jquery.ui/jquery.ui.js +71 -0
- data/lib/common_interface/public/common_interface/themes/default/_aspects.scss +58 -0
- data/lib/common_interface/public/common_interface/themes/default/_basic.scss +228 -0
- data/lib/common_interface/public/common_interface/themes/default/_components.scss +151 -0
- data/lib/common_interface/public/common_interface/themes/default/_custom_reset.scss +12 -0
- data/lib/common_interface/public/common_interface/themes/default/_elastic.scss +72 -0
- data/lib/common_interface/public/common_interface/themes/default/_items.scss +88 -0
- data/lib/common_interface/public/common_interface/themes/default/_mixins.scss +39 -0
- data/lib/common_interface/public/common_interface/themes/default/_special.scss +34 -0
- data/lib/common_interface/public/common_interface/themes/default/_variables.scss +15 -0
- data/lib/common_interface/public/common_interface/themes/default/_yui_reset.scss +127 -0
- data/lib/common_interface/public/common_interface/themes/default/elastic.js +307 -0
- data/lib/common_interface/public/common_interface/themes/default/elastic.print.css +8 -0
- data/lib/common_interface/public/common_interface/themes/default/reset.css +157 -0
- data/lib/common_interface/public/common_interface/themes/default/reset.scss +5 -0
- data/lib/common_interface/public/common_interface/themes/default/style.css +580 -0
- data/lib/common_interface/public/common_interface/themes/default/style.js +84 -0
- data/lib/common_interface/public/common_interface/themes/default/style.scss +11 -0
- data/lib/common_interface/public/common_interface/themes/simple_organization/_fixes.scss +130 -0
- data/lib/common_interface/public/common_interface/themes/simple_organization/_original.scss +852 -0
- data/lib/common_interface/public/common_interface/themes/simple_organization/img/comment-arrow.gif +0 -0
- data/lib/common_interface/public/common_interface/themes/simple_organization/img/comment-gravatar.gif +0 -0
- data/lib/common_interface/public/common_interface/themes/simple_organization/img/comment-reply.gif +0 -0
- data/lib/common_interface/public/common_interface/themes/simple_organization/img/logo-small.gif +0 -0
- data/lib/common_interface/public/common_interface/themes/simple_organization/img/logo.gif +0 -0
- data/lib/common_interface/public/common_interface/themes/simple_organization/img/main-two-columns-left.gif +0 -0
- data/lib/common_interface/public/common_interface/themes/simple_organization/img/main-two-columns.gif +0 -0
- data/lib/common_interface/public/common_interface/themes/simple_organization/img/sample-event.jpg +0 -0
- data/lib/common_interface/public/common_interface/themes/simple_organization/img/sample-gravatar.gif +0 -0
- data/lib/common_interface/public/common_interface/themes/simple_organization/img/sample-image.jpg +0 -0
- data/lib/common_interface/public/common_interface/themes/simple_organization/img/sample-thumbnail.jpg +0 -0
- data/lib/common_interface/public/common_interface/themes/simple_organization/original/archives.html +389 -0
- data/lib/common_interface/public/common_interface/themes/simple_organization/original/comments.html +486 -0
- data/lib/common_interface/public/common_interface/themes/simple_organization/original/empty-page.html +107 -0
- data/lib/common_interface/public/common_interface/themes/simple_organization/original/img/comment-arrow.gif +0 -0
- data/lib/common_interface/public/common_interface/themes/simple_organization/original/img/comment-gravatar.gif +0 -0
- data/lib/common_interface/public/common_interface/themes/simple_organization/original/img/comment-reply.gif +0 -0
- data/lib/common_interface/public/common_interface/themes/simple_organization/original/img/logo-small.gif +0 -0
- data/lib/common_interface/public/common_interface/themes/simple_organization/original/img/logo.gif +0 -0
- data/lib/common_interface/public/common_interface/themes/simple_organization/original/img/main-two-columns-left.gif +0 -0
- data/lib/common_interface/public/common_interface/themes/simple_organization/original/img/main-two-columns.gif +0 -0
- data/lib/common_interface/public/common_interface/themes/simple_organization/original/img/sample-event.jpg +0 -0
- data/lib/common_interface/public/common_interface/themes/simple_organization/original/img/sample-gravatar.gif +0 -0
- data/lib/common_interface/public/common_interface/themes/simple_organization/original/img/sample-image.jpg +0 -0
- data/lib/common_interface/public/common_interface/themes/simple_organization/original/img/sample-thumbnail.jpg +0 -0
- data/lib/common_interface/public/common_interface/themes/simple_organization/original/index.html +307 -0
- data/lib/common_interface/public/common_interface/themes/simple_organization/original/left-sidebar.html +307 -0
- data/lib/common_interface/public/common_interface/themes/simple_organization/original/no-subnavigation.html +290 -0
- data/lib/common_interface/public/common_interface/themes/simple_organization/original/single-column.html +209 -0
- data/lib/common_interface/public/common_interface/themes/simple_organization/original/style-demo.html +355 -0
- data/lib/common_interface/public/common_interface/themes/simple_organization/original/style.css +658 -0
- data/lib/common_interface/public/common_interface/themes/simple_organization/style.css +965 -0
- data/lib/common_interface/public/common_interface/themes/simple_organization/style.scss +2 -0
- data/lib/common_interface/public/common_interface/themes/simple_organization/tmp/comments.html +486 -0
- data/lib/common_interface/public/common_interface/themes/simple_organization/tmp/tmp.html +307 -0
- data/lib/common_interface/spec/controllers/theme_controller_spec.rb +50 -0
- data/lib/common_interface/spec/spec.opts +4 -0
- data/lib/common_interface/spec/spec_helper.rb +1 -0
- data/lib/common_interface/tmp/html.html +39 -0
- data/lib/common_interface/tmp/js.js +78 -0
- data/lib/mongo_mapper_ext/db_config.rb +76 -0
- data/lib/mongo_mapper_ext/hacks/fixes.rb +32 -0
- data/lib/mongo_mapper_ext/hacks/time_measuring.rb +44 -0
- data/lib/mongo_mapper_ext/micelaneous.rb +9 -0
- data/lib/mongo_mapper_ext/migrate.rake +33 -0
- data/lib/mongo_mapper_ext/migration.rb +108 -0
- data/lib/mongo_mapper_ext/mongo_mapper.rb +25 -0
- data/lib/mongo_mapper_ext/plugins/attributes_cache.rb +22 -0
- data/lib/mongo_mapper_ext/plugins/default_scope.rb +76 -0
- data/lib/mongo_mapper_ext/plugins/micelaneous.rb +81 -0
- data/lib/mongo_mapper_ext/spec_helper.rb +10 -0
- data/lib/mongo_mapper_ext/view_helpers.rb +10 -0
- data/lib/mongo_mapper_ext.rb +29 -0
- data/lib/rails_ext/README.markdown +13 -0
- data/lib/rails_ext/action_controller/global_path_prefix.rb +56 -0
- data/lib/rails_ext/action_controller/micelaneous.rb +118 -0
- data/lib/rails_ext/action_controller/persistent_params.rb +96 -0
- data/lib/rails_ext/action_controller/redirect_helper.rb +14 -0
- data/lib/rails_ext/action_controller/reload_page.rb +7 -0
- data/lib/rails_ext/action_controller.rb +19 -0
- data/lib/rails_ext/action_view/common_helper.rb +96 -0
- data/lib/rails_ext/action_view/ruby_template.rb +13 -0
- data/lib/rails_ext/action_view.rb +5 -0
- data/lib/rails_ext/active_record/merge_default_scope/hash_poser.rb +40 -0
- data/lib/rails_ext/active_record/merge_default_scope.rb +16 -0
- data/lib/rails_ext/active_record/micelaneous.rb +14 -0
- data/lib/rails_ext/active_record.rb +7 -0
- data/lib/rails_ext/active_support/micelaneous.rb +7 -0
- data/lib/rails_ext/active_support.rb +1 -0
- data/lib/rails_ext/asset_packager/action_view.rb +47 -0
- data/lib/rails_ext/asset_packager/asset_packager.rb +112 -0
- data/lib/rails_ext/asset_packager/jsmin.rb +205 -0
- data/lib/rails_ext/asset_packager/tasks.rb +27 -0
- data/lib/rails_ext/asset_packager.rb +4 -0
- data/lib/rails_ext/basic/handy_environment.rb +45 -0
- data/lib/rails_ext/basic/user_error.rb +12 -0
- data/lib/rails_ext/basic.rb +6 -0
- data/lib/rails_ext/hacks/ajax_flash.rb +9 -0
- data/lib/rails_ext/hacks/ajax_redirect_to.rb +19 -0
- data/lib/rails_ext/hacks/defer_static_javascripts.rb +18 -0
- data/lib/rails_ext/hacks/global_path_prefix.rb +33 -0
- data/lib/rails_ext/hacks/link_to.rb +105 -0
- data/lib/rails_ext/hacks/merge_default_scope.rb +20 -0
- data/lib/rails_ext/hacks/persistent_params.rb +16 -0
- data/lib/rails_ext/hacks/rjs_layout.rb +2 -0
- data/lib/rails_ext/micelaneous/addressable_uri.rb +45 -0
- data/lib/rails_ext/micelaneous/config_files.rb +18 -0
- data/lib/rails_ext/micelaneous/create_public_symlinks.rb +11 -0
- data/lib/rails_ext/micelaneous/defer_static_javascripts.rb +50 -0
- data/lib/rails_ext/micelaneous/email_config.rb +8 -0
- data/lib/rails_ext/micelaneous/i18n_helper.rb +143 -0
- data/lib/rails_ext/micelaneous/rails_require.rb +4 -0
- data/lib/rails_ext/micelaneous/safe_hash.rb +104 -0
- data/lib/rails_ext/micelaneous.rb +17 -0
- data/lib/rails_ext/public/rails_ext/rails_ext.css +2 -0
- data/lib/rails_ext/public/rails_ext/rails_ext.js +283 -0
- data/lib/rails_ext/spec/mongo_mapper_ext/micelaneous_plugin_spec.rb +56 -0
- data/lib/rails_ext/spec/mongo_mapper_ext/micelaneous_spec.rb +51 -0
- data/lib/rails_ext/spec/mongo_mapper_ext/mongo_mapper_migration_spec.rb +76 -0
- data/lib/rails_ext/spec/mongo_mapper_ext/scope_spec.rb +125 -0
- data/lib/rails_ext/spec/rails_ext/haml_builder_spec.rb +136 -0
- data/lib/rails_ext/spec/rails_ext/safe_hash_spec.rb +71 -0
- data/lib/rails_ext/spec/spec.opts +3 -0
- data/lib/sunspot/mongo_mapper/adapters.rb +79 -0
- data/lib/sunspot/mongo_mapper/searchable.rb +409 -0
- data/lib/sunspot/spec_helper.rb +11 -0
- data/readme.md +1 -0
- data/spec/mongo_mapper_ext/micelaneous_plugin_spec.rb +56 -0
- data/spec/mongo_mapper_ext/micelaneous_spec.rb +51 -0
- data/spec/mongo_mapper_ext/mongo_mapper_migration_spec.rb +76 -0
- data/spec/mongo_mapper_ext/scope_spec.rb +125 -0
- data/spec/rails_ext/haml_builder_spec.rb +136 -0
- data/spec/rails_ext/safe_hash_spec.rb +71 -0
- data/spec/spec.opts +4 -0
- metadata +405 -0
@@ -0,0 +1,108 @@
|
|
1
|
+
module MongoMapper::Migration
|
2
|
+
class MigrationDefinition
|
3
|
+
def upgrade &block
|
4
|
+
if block
|
5
|
+
@upgrade = block
|
6
|
+
else
|
7
|
+
@upgrade
|
8
|
+
end
|
9
|
+
end
|
10
|
+
alias_method :up, :upgrade
|
11
|
+
|
12
|
+
def downgrade &block
|
13
|
+
if block
|
14
|
+
@downgrade = block
|
15
|
+
else
|
16
|
+
@downgrade
|
17
|
+
end
|
18
|
+
end
|
19
|
+
alias_method :down, :downgrade
|
20
|
+
end
|
21
|
+
|
22
|
+
class Logger
|
23
|
+
attr_accessor :enabled
|
24
|
+
|
25
|
+
def initialize enabled = true
|
26
|
+
self.enabled = enabled
|
27
|
+
end
|
28
|
+
|
29
|
+
def info message
|
30
|
+
puts message if enabled
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
class << self
|
35
|
+
def logger= logger
|
36
|
+
@logger = logger ? logger : Logger.new(false)
|
37
|
+
end
|
38
|
+
|
39
|
+
def logger; @logger ||= Logger.new end
|
40
|
+
|
41
|
+
def define database_alias, version, &block
|
42
|
+
database_alias = database_alias.to_s
|
43
|
+
|
44
|
+
version.should! :be_a, Integer
|
45
|
+
definition = MigrationDefinition.new
|
46
|
+
block.call definition
|
47
|
+
definitions[database_alias][version] = definition
|
48
|
+
end
|
49
|
+
|
50
|
+
def update database_alias, version
|
51
|
+
database_alias = database_alias.to_s
|
52
|
+
db = MongoMapper.databases[database_alias]
|
53
|
+
|
54
|
+
if metadata(db).version == version
|
55
|
+
logger.info "Database '#{database_alias}' already is of #{version} version, no migration needed."
|
56
|
+
return false
|
57
|
+
else
|
58
|
+
logger.info "Migration for '#{database_alias}' Database:"
|
59
|
+
end
|
60
|
+
|
61
|
+
increase_db_version database_alias, db while metadata(db).version < version
|
62
|
+
decrease_db_version database_alias, db while metadata(db).version > version
|
63
|
+
true
|
64
|
+
end
|
65
|
+
|
66
|
+
def metadata db
|
67
|
+
col = db.collection 'db_metadata'
|
68
|
+
metadata = (col.find_one || {:version => 0}).to_openobject
|
69
|
+
end
|
70
|
+
|
71
|
+
def definitions
|
72
|
+
@definitions ||= Hash.new{|h, k| h[k] = []}
|
73
|
+
end
|
74
|
+
|
75
|
+
protected
|
76
|
+
def increase_db_version database_alias, db
|
77
|
+
m = metadata(db)
|
78
|
+
migration = definitions[database_alias][m.version + 1]
|
79
|
+
raise "No upgrade for version #{m.version + 1} of '#{database_alias}' Database!" unless migration and migration.up
|
80
|
+
|
81
|
+
migration.up.call db
|
82
|
+
|
83
|
+
m.version += 1
|
84
|
+
update_metadata db, m
|
85
|
+
|
86
|
+
logger.info "Database '#{database_alias}' upgraded to version #{m.version}."
|
87
|
+
end
|
88
|
+
|
89
|
+
def decrease_db_version database_alias, db
|
90
|
+
m = metadata(db)
|
91
|
+
migration = definitions[database_alias][m.version]
|
92
|
+
raise "No downgrade for version #{m.version} of '#{database_alias}' Database!" unless migration and migration.down
|
93
|
+
|
94
|
+
migration.down.call db
|
95
|
+
|
96
|
+
m.version -= 1
|
97
|
+
update_metadata db, m
|
98
|
+
|
99
|
+
logger.info "Database '#{database_alias}' downgraded to version #{m.version}."
|
100
|
+
end
|
101
|
+
|
102
|
+
|
103
|
+
def update_metadata db, metadata
|
104
|
+
col = db.collection 'db_metadata'
|
105
|
+
col.save metadata.to_hash
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
MongoMapper.class_eval do
|
2
|
+
class << self
|
3
|
+
|
4
|
+
def logger
|
5
|
+
# return @logger ||= Logger.new(nil) if defined?(Spec)
|
6
|
+
unless @logger
|
7
|
+
@logger = if "irb" == $0
|
8
|
+
Logger.new(STDOUT)
|
9
|
+
else
|
10
|
+
if defined?(Rails)
|
11
|
+
Rails.test? ? Logger.new(nil) : Rails.logger
|
12
|
+
else
|
13
|
+
Logger.new(STDOUT)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
@logger
|
18
|
+
end
|
19
|
+
|
20
|
+
def logger= logger
|
21
|
+
@logger = logger
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module MongoMapper
|
2
|
+
module Plugins
|
3
|
+
module AttributesCache
|
4
|
+
|
5
|
+
module InstanceMethods
|
6
|
+
def cache
|
7
|
+
@cache ||= {}
|
8
|
+
end
|
9
|
+
|
10
|
+
def clear_cache
|
11
|
+
@cache = {}
|
12
|
+
end
|
13
|
+
|
14
|
+
def reload
|
15
|
+
@cache.clear if @cache
|
16
|
+
super
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
module MongoMapper
|
2
|
+
module Plugins
|
3
|
+
module DefaultScope
|
4
|
+
|
5
|
+
module ClassMethods
|
6
|
+
def find_one options = {}
|
7
|
+
super default_scope_options.merge(options)
|
8
|
+
end
|
9
|
+
|
10
|
+
def find_many options = {}
|
11
|
+
super default_scope_options.merge(options)
|
12
|
+
end
|
13
|
+
|
14
|
+
def count options={}
|
15
|
+
super default_scope_options.merge(options)
|
16
|
+
end
|
17
|
+
|
18
|
+
def with_exclusive_scope options = {}, &block
|
19
|
+
Thread.current['mm_with_exclusive_scope'].should! :be_nil
|
20
|
+
|
21
|
+
before = Thread.current['mm_with_exclusive_scope']
|
22
|
+
begin
|
23
|
+
Thread.current['mm_with_exclusive_scope'] = options
|
24
|
+
block.call if block
|
25
|
+
ensure
|
26
|
+
Thread.current['mm_with_exclusive_scope'] = before
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def with_scope options = {}, &block
|
31
|
+
Thread.current['mm_with_exclusive_scope'].should! :be_nil
|
32
|
+
|
33
|
+
before = Thread.current['mm_with_scope']
|
34
|
+
begin
|
35
|
+
options = before.merge options if before
|
36
|
+
Thread.current['mm_with_scope'] = options
|
37
|
+
block.call if block
|
38
|
+
ensure
|
39
|
+
Thread.current['mm_with_scope'] = before
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
protected
|
44
|
+
def default_scope options = nil, &block
|
45
|
+
options.should! :be_a, [NilClass, Hash]
|
46
|
+
self.write_inheritable_attribute(:default_scope, (options || block))
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
def default_scope_options
|
51
|
+
default_scope = self.read_inheritable_attribute(:default_scope)
|
52
|
+
|
53
|
+
exclusive_options = Thread.current['mm_with_exclusive_scope']
|
54
|
+
return exclusive_options if exclusive_options
|
55
|
+
|
56
|
+
options = if default_scope
|
57
|
+
if default_scope.respond_to? :call
|
58
|
+
default_scope.call self
|
59
|
+
else
|
60
|
+
default_scope
|
61
|
+
end
|
62
|
+
else
|
63
|
+
{}
|
64
|
+
end
|
65
|
+
|
66
|
+
if scope_options = Thread.current['mm_with_scope']
|
67
|
+
options = options.merge scope_options
|
68
|
+
end
|
69
|
+
|
70
|
+
options
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
module MongoMapper
|
2
|
+
module Plugins
|
3
|
+
module Micelaneous
|
4
|
+
|
5
|
+
module InstanceMethods
|
6
|
+
def upsert *args
|
7
|
+
self.class.upsert id, *args
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
module ClassMethods
|
12
|
+
#
|
13
|
+
# Sequentiall :all for big collection
|
14
|
+
#
|
15
|
+
def all_sequentially &block
|
16
|
+
page, per_page = 1, 5
|
17
|
+
begin
|
18
|
+
results = paginate(:page => page, :per_page => per_page, :order => '_id asc')
|
19
|
+
results.each{|o| block.call o}
|
20
|
+
page += 1
|
21
|
+
end until results.blank? or results.size < per_page
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
#
|
26
|
+
# Connect to database_alias specified in config
|
27
|
+
#
|
28
|
+
def use_database database_alias
|
29
|
+
database_alias = database_alias.to_s
|
30
|
+
MongoMapper.db_config.should! :include, database_alias
|
31
|
+
|
32
|
+
self.connection MongoMapper.connections[database_alias]
|
33
|
+
set_database_name MongoMapper.db_config[database_alias]['name']
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
#
|
38
|
+
# shortcut for upsert
|
39
|
+
#
|
40
|
+
def upsert *args
|
41
|
+
collection.upsert *args
|
42
|
+
end
|
43
|
+
|
44
|
+
|
45
|
+
#
|
46
|
+
# CounterCache
|
47
|
+
# belongs_to :item, :counter_cashe => true
|
48
|
+
#
|
49
|
+
def belongs_to association_id, options={}, &extension
|
50
|
+
options.should_not! :include, :counter_cashe
|
51
|
+
if options.delete(:counter_cache) || options.delete('counter_cache')
|
52
|
+
association_id = association_id.to_s
|
53
|
+
association_key = "#{association_id}_id"
|
54
|
+
cache_attribute = "#{name.pluralize.underscore}_count"
|
55
|
+
cache_class = association_id.classify.constantize
|
56
|
+
cache_class.keys.should! :include, cache_attribute
|
57
|
+
increase_method_name = "increase_#{cache_class.name.underscore}_#{name.pluralize.underscore}_counter"
|
58
|
+
decrease_method_name = "decrease_#{cache_class.name.underscore}_#{name.pluralize.underscore}_counter"
|
59
|
+
|
60
|
+
define_method increase_method_name do
|
61
|
+
cache_class.upsert self.send(association_key), :$inc => {cache_attribute => 1}
|
62
|
+
end
|
63
|
+
protected increase_method_name
|
64
|
+
|
65
|
+
define_method decrease_method_name do
|
66
|
+
cache_class.upsert self.send(association_key), :$inc => {cache_attribute => -1}
|
67
|
+
end
|
68
|
+
protected decrease_method_name
|
69
|
+
|
70
|
+
after_create increase_method_name
|
71
|
+
after_destroy decrease_method_name
|
72
|
+
end
|
73
|
+
|
74
|
+
super association_id, options, &extension
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'mongo_mapper'
|
2
|
+
|
3
|
+
|
4
|
+
[
|
5
|
+
'hacks/fixes',
|
6
|
+
'hacks/time_measuring',
|
7
|
+
'migration',
|
8
|
+
'mongo_mapper',
|
9
|
+
'view_helpers',
|
10
|
+
'db_config',
|
11
|
+
'micelaneous',
|
12
|
+
|
13
|
+
'plugins/default_scope',
|
14
|
+
'plugins/attributes_cache',
|
15
|
+
'plugins/micelaneous',
|
16
|
+
].each do |file|
|
17
|
+
require "#{File.dirname __FILE__}/mongo_mapper_ext/#{file}"
|
18
|
+
end
|
19
|
+
|
20
|
+
module CommonPluginsAddition
|
21
|
+
def self.included(model)
|
22
|
+
model.plugin MongoMapper::Plugins::DefaultScope
|
23
|
+
model.plugin MongoMapper::Plugins::AttributesCache
|
24
|
+
model.plugin MongoMapper::Plugins::Micelaneous
|
25
|
+
|
26
|
+
model.attr_protected :id, :_id, :_type, :created_at, :updated_at
|
27
|
+
end
|
28
|
+
end
|
29
|
+
MongoMapper::Document.append_inclusions(CommonPluginsAddition)
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# Ruby on Rails extensions.
|
2
|
+
|
3
|
+
* Abstract Interface: Tool for rapid web interface creation, see [Common Interface][common_interface] - concrete realisation of Abstract Interface
|
4
|
+
* MongoMapperExt: MongoMapper extensions, Migration, Query Profiling in Log, Attributes Cache, Default Scope, BelongsTo Counter Cache
|
5
|
+
* Sunspot: Sunspot support for MongoMapper
|
6
|
+
* rails_ext - a lots of Rails hacks, mainly to add inheritance support (because there's no OOD and inheritance in Rails by default).
|
7
|
+
|
8
|
+
All these extensions should be different gems itself but right for me it's easier to deal with all of them in one place, later I'll split them.
|
9
|
+
|
10
|
+
|
11
|
+
Copyright (c) 2009 Alexey Petrushin ([http://bos-tec.com](http://bos-tec.com)), released under the MIT license.
|
12
|
+
|
13
|
+
[common_interface]: http://github.com/alexeypetrushin/common_interface
|
@@ -0,0 +1,56 @@
|
|
1
|
+
#
|
2
|
+
# Global path prefix (hack with relative_url_root)
|
3
|
+
#
|
4
|
+
GLOBAL_PATH_PREFIX_DELIMITER = '-'
|
5
|
+
ActionController::Base.send :class_eval do
|
6
|
+
def self.global_path_prefix
|
7
|
+
@global_path_prefix ||= []
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.global_path_prefix= list
|
11
|
+
@global_path_prefix = list.collect{|v| v.to_s}
|
12
|
+
end
|
13
|
+
|
14
|
+
cattr_accessor :_relative_url_root
|
15
|
+
end
|
16
|
+
ActionController::Base._relative_url_root = ActionController::Base.relative_url_root || ""
|
17
|
+
|
18
|
+
#
|
19
|
+
# Generation
|
20
|
+
#
|
21
|
+
|
22
|
+
# routes
|
23
|
+
ActionController::Base.send :class_eval do
|
24
|
+
around_filter :hack_relative_url_root
|
25
|
+
protected
|
26
|
+
|
27
|
+
# preparing relative_url_root from params
|
28
|
+
def hack_relative_url_root
|
29
|
+
begin
|
30
|
+
update_relative_url_root!
|
31
|
+
yield
|
32
|
+
ensure
|
33
|
+
ActionController::Base.relative_url_root = ActionController::Base._relative_url_root
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def update_relative_url_root!
|
38
|
+
prefix_params = []
|
39
|
+
ActionController::Base.global_path_prefix.each do |name|
|
40
|
+
unless (param = params[name]).blank?
|
41
|
+
prefix_params << [name, CGI.escape(param)]
|
42
|
+
end
|
43
|
+
end
|
44
|
+
prefix = prefix_params.collect{|name, param| "#{param}#{GLOBAL_PATH_PREFIX_DELIMITER}#{name}"}.join('/')
|
45
|
+
ActionController::Base.relative_url_root = ActionController::Base._relative_url_root + (prefix.blank? ? "" : "/" + prefix)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
#
|
50
|
+
# Usability
|
51
|
+
# allows to install a global_path_prefix to the route set by calling: map.global_path_prefix 'locale'
|
52
|
+
ActionController::Routing::RouteSet::Mapper.class_eval do
|
53
|
+
def global_path_prefix *args
|
54
|
+
ActionController::Base.global_path_prefix = args
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,118 @@
|
|
1
|
+
# Shortcut for :unprocessable_entity, head(:failed) instead of head(:unprocessable_entity)
|
2
|
+
ActionController::StatusCodes::SYMBOL_TO_STATUS_CODE[:failed] = 422
|
3
|
+
|
4
|
+
#
|
5
|
+
# url_for, used to generate url_for for string path with options and with default_url_options
|
6
|
+
#
|
7
|
+
ActionController::Base.class_eval do
|
8
|
+
protected
|
9
|
+
#
|
10
|
+
# link_to
|
11
|
+
#
|
12
|
+
def link_to text, uri
|
13
|
+
%{<a href="#{uri}">#{text}</a>}
|
14
|
+
end
|
15
|
+
|
16
|
+
#
|
17
|
+
# Bunch of small actions
|
18
|
+
#
|
19
|
+
def render_action action_or_template
|
20
|
+
args = action_or_template.to_s.split('/')
|
21
|
+
args.size.should! :be_in, 1..2
|
22
|
+
if args.size == 1
|
23
|
+
action = args.first
|
24
|
+
@the_action = action.to_sym
|
25
|
+
render :action => 'actions'
|
26
|
+
else
|
27
|
+
path, action = args
|
28
|
+
@the_action = action.to_sym
|
29
|
+
render :template => "#{path}/actions"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def the_action; @the_action end
|
34
|
+
helper_method :the_action
|
35
|
+
|
36
|
+
|
37
|
+
#
|
38
|
+
# Url from String Path
|
39
|
+
#
|
40
|
+
def url_for_path path, options = {}
|
41
|
+
unless options.delete :no_prefix
|
42
|
+
url = ActionController::Base.relative_url_root + path
|
43
|
+
else
|
44
|
+
url = path.dup
|
45
|
+
end
|
46
|
+
|
47
|
+
options = default_url_options.merge options
|
48
|
+
|
49
|
+
# Delete 'nil' parameters
|
50
|
+
to_delete = []
|
51
|
+
options.each{|k, v| to_delete << k if v.nil?}
|
52
|
+
to_delete.each{|k| options.delete k}
|
53
|
+
|
54
|
+
host = options.delete(:host) || options.delete('host')
|
55
|
+
port = options.delete(:port) || options.delete('port')
|
56
|
+
|
57
|
+
delimiter = path.include?('?') ? '&' : '?'
|
58
|
+
|
59
|
+
url << "#{delimiter}#{options.to_query}" unless options.empty?
|
60
|
+
url._url_format = options[:format] if options[:format] # hack for links with ajax support
|
61
|
+
url
|
62
|
+
|
63
|
+
if host.blank?
|
64
|
+
url
|
65
|
+
else
|
66
|
+
%{http://#{host}#{":#{port}" unless port.blank?}#{url}}
|
67
|
+
end
|
68
|
+
end
|
69
|
+
helper_method :url_for_path
|
70
|
+
|
71
|
+
|
72
|
+
#
|
73
|
+
# User Error
|
74
|
+
#
|
75
|
+
def catch_user_error
|
76
|
+
begin
|
77
|
+
yield
|
78
|
+
rescue UserError => e
|
79
|
+
flash[:error] = e.message
|
80
|
+
flash[:sticky_error] = e.message
|
81
|
+
do_not_persist_params do
|
82
|
+
if request.xhr? or request.format == 'js'
|
83
|
+
render :inline => "", :layout => 'application'
|
84
|
+
else
|
85
|
+
redirect_to default_path
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
around_filter :catch_user_error
|
91
|
+
|
92
|
+
#
|
93
|
+
# enshure domain has www. except if there's custom subdomain
|
94
|
+
#
|
95
|
+
def ensure_no_www
|
96
|
+
uri = Addressable::URI.parse request.url
|
97
|
+
if uri.host =~ /^www\./
|
98
|
+
uri.host = uri.host.sub(/^www\./, '')
|
99
|
+
redirect_to uri.to_s
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
class << self
|
104
|
+
|
105
|
+
def prepare_model aclass, opt = {}
|
106
|
+
id = opt.delete(:id) || :id
|
107
|
+
variable = opt.delete(:variable) || aclass.model_name.underscore
|
108
|
+
finder = opt.delete(:finder) || :find!
|
109
|
+
|
110
|
+
method = "prepare_#{variable}"
|
111
|
+
define_method method do
|
112
|
+
model = aclass.send finder, params[id]
|
113
|
+
instance_variable_set "@#{variable}", model
|
114
|
+
end
|
115
|
+
before_filter method, opt
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
@@ -0,0 +1,96 @@
|
|
1
|
+
ActionController::Base.send :class_eval do
|
2
|
+
protected
|
3
|
+
|
4
|
+
DO_NOT_PERSIST = ['_', '_method']
|
5
|
+
|
6
|
+
def default_url_options options = {}
|
7
|
+
persistent_params = {}
|
8
|
+
|
9
|
+
if options
|
10
|
+
options = options.stringify_keys if options
|
11
|
+
global_persistent_params = ActionController::Base.global_persistent_params
|
12
|
+
|
13
|
+
if Thread.current[:persist_params] or options.delete(:persist)
|
14
|
+
params.each do |key, value|
|
15
|
+
persist = (
|
16
|
+
(key =~ /^_/) and
|
17
|
+
!(options.include?(key) or DO_NOT_PERSIST.include?(key))
|
18
|
+
) or global_persistent_params.include?(key)
|
19
|
+
|
20
|
+
persistent_params[key] = value if persist
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# global_persistent_params.each do |key, value|
|
25
|
+
# persistent_params[key] = value unless options.include?(key)
|
26
|
+
# end
|
27
|
+
end
|
28
|
+
|
29
|
+
return persistent_params
|
30
|
+
end
|
31
|
+
|
32
|
+
def persist_params &block
|
33
|
+
before = Thread.current[:persist_params]
|
34
|
+
begin
|
35
|
+
Thread.current[:persist_params] = true
|
36
|
+
block.call
|
37
|
+
ensure
|
38
|
+
Thread.current[:persist_params] = before
|
39
|
+
end
|
40
|
+
end
|
41
|
+
helper_method :persist_params
|
42
|
+
|
43
|
+
def do_not_persist_params &block
|
44
|
+
before = Thread.current[:persist_params]
|
45
|
+
begin
|
46
|
+
Thread.current[:persist_params] = false
|
47
|
+
block.call
|
48
|
+
ensure
|
49
|
+
Thread.current[:persist_params] = before
|
50
|
+
end
|
51
|
+
end
|
52
|
+
helper_method :do_not_persist_params
|
53
|
+
|
54
|
+
# def prepare_global_persistent_params
|
55
|
+
# persistent_params = ActionController::Base.global_persistent_params
|
56
|
+
# prefix_params = ActionController::Base.global_path_prefix
|
57
|
+
# params = self.params.stringify_keys
|
58
|
+
# params.each do |key, value|
|
59
|
+
# if persistent_params.include?(key) and !prefix_params.include?(key)
|
60
|
+
# global_persistent_params[key] = value
|
61
|
+
# end
|
62
|
+
# end
|
63
|
+
# end
|
64
|
+
# def global_persistent_params
|
65
|
+
# @global_persistent_params ||= {}
|
66
|
+
# end
|
67
|
+
# before_filter :prepare_global_persistent_params
|
68
|
+
|
69
|
+
class << self
|
70
|
+
def global_persistent_params= params
|
71
|
+
@global_persistent_params = params.collect &:to_s
|
72
|
+
end
|
73
|
+
|
74
|
+
def global_persistent_params
|
75
|
+
@global_persistent_params ||= []
|
76
|
+
end
|
77
|
+
|
78
|
+
def persist_params *args
|
79
|
+
if args.empty?
|
80
|
+
around_filter :persist_params
|
81
|
+
elsif args.first.is_a? Hash
|
82
|
+
# args.first.should! :be_a, Hash
|
83
|
+
around_filter :persist_params, args.first
|
84
|
+
else
|
85
|
+
around_filter :persist_params, :only => args.first
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
# allows to install a global_persistent_params to the route set by calling: map.global_persistent_params 'locale'
|
92
|
+
ActionController::Routing::RouteSet::Mapper.class_eval do
|
93
|
+
def global_persistent_params *args
|
94
|
+
ActionController::Base.global_persistent_params = args
|
95
|
+
end
|
96
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
ActionController::Base.send :class_eval do
|
2
|
+
protected
|
3
|
+
def default_path options = {}
|
4
|
+
url_for_path SETTING.default_path!, options.merge(:no_prefix => true)
|
5
|
+
end
|
6
|
+
|
7
|
+
def return_to_path options = {}
|
8
|
+
do_not_persist_params do
|
9
|
+
url_for_path params[:_return_to] || session[:return_to] || SETTING.default_path!, options.merge(:no_prefix => true)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
helper_method :default_path, :return_to_path
|
14
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'rails_ext/basic'
|
2
|
+
|
3
|
+
require 'rails_ext/action_controller/micelaneous'
|
4
|
+
|
5
|
+
require 'rails_ext/action_controller/global_path_prefix'
|
6
|
+
require 'rails_ext/hacks/global_path_prefix'
|
7
|
+
|
8
|
+
require 'rails_ext/hacks/link_to'
|
9
|
+
|
10
|
+
require 'rails_ext/hacks/ajax_flash'
|
11
|
+
|
12
|
+
require 'rails_ext/hacks/ajax_redirect_to'
|
13
|
+
|
14
|
+
require 'rails_ext/action_controller/persistent_params'
|
15
|
+
require 'rails_ext/hacks/persistent_params'
|
16
|
+
|
17
|
+
require 'rails_ext/action_controller/redirect_helper'
|
18
|
+
|
19
|
+
require 'rails_ext/action_controller/reload_page'
|