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,19 @@
|
|
1
|
+
ActionController::Base.send :class_eval do
|
2
|
+
protected
|
3
|
+
def redirect_to_with_ajax *args
|
4
|
+
if request.xhr? or request.format == 'js'
|
5
|
+
preserve_flash_for_ajax_page_update
|
6
|
+
render :inline => "window.location = '#{url_for *args}';", :layout => 'application'
|
7
|
+
else
|
8
|
+
redirect_to_without_ajax *args
|
9
|
+
end
|
10
|
+
end
|
11
|
+
alias_method_chain :redirect_to, :ajax
|
12
|
+
|
13
|
+
private
|
14
|
+
def preserve_flash_for_ajax_page_update
|
15
|
+
# save flash.now (that are marked as used) with ajax redirect
|
16
|
+
used = flash_without_ajax.instance_variable_get '@used'
|
17
|
+
used.clear
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
ActionView::Helpers::JavaScriptHelper.class_eval do
|
2
|
+
def javascript_cdata_section_with_defer content
|
3
|
+
if defer_static_scripts?
|
4
|
+
unless Thread.current[:deferred_static_scripts_called]
|
5
|
+
content = <<END
|
6
|
+
deferred_static_scripts.push(function(){
|
7
|
+
|
8
|
+
#{content}
|
9
|
+
|
10
|
+
});
|
11
|
+
END
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
javascript_cdata_section_without_defer content
|
16
|
+
end
|
17
|
+
alias_method_chain :javascript_cdata_section, :defer
|
18
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# asset_path
|
2
|
+
ActionView::Helpers::AssetTagHelper.class_eval do
|
3
|
+
private
|
4
|
+
def compute_public_path_with_global_prefix *args, &block
|
5
|
+
tmp = ActionController::Base.relative_url_root
|
6
|
+
begin
|
7
|
+
ActionController::Base.relative_url_root = ActionController::Base._relative_url_root
|
8
|
+
compute_public_path_without_global_prefix *args, &block
|
9
|
+
ensure
|
10
|
+
ActionController::Base.relative_url_root = tmp
|
11
|
+
end
|
12
|
+
end
|
13
|
+
alias_method_chain :compute_public_path, :global_prefix
|
14
|
+
end
|
15
|
+
|
16
|
+
#
|
17
|
+
# Recognition
|
18
|
+
# delete global_path_prefix from path before rails recognition
|
19
|
+
ActionController::Routing::RouteSet.send :class_eval do
|
20
|
+
def recognize_path_with_global_prefix path, environment={}
|
21
|
+
prefix_params = {}
|
22
|
+
new_path = path.clone
|
23
|
+
ActionController::Base.global_path_prefix.each do |name|
|
24
|
+
new_path.gsub! /\A\/.+?#{GLOBAL_PATH_PREFIX_DELIMITER}#{name}/ do |value|
|
25
|
+
prefix_params[name] = CGI.unescape value[1..-(name.size + GLOBAL_PATH_PREFIX_DELIMITER.size + 1)]
|
26
|
+
""
|
27
|
+
end
|
28
|
+
end
|
29
|
+
params = recognize_path_without_global_prefix new_path, environment
|
30
|
+
return params.reverse_merge prefix_params
|
31
|
+
end
|
32
|
+
alias_method_chain :recognize_path, :global_prefix
|
33
|
+
end
|
@@ -0,0 +1,105 @@
|
|
1
|
+
#
|
2
|
+
# link_to without form creating mess
|
3
|
+
# and link_to with ajax support
|
4
|
+
#
|
5
|
+
String.send :class_eval do
|
6
|
+
attr_accessor :_url_format
|
7
|
+
end
|
8
|
+
|
9
|
+
ActionController::UrlRewriter.send :class_eval do
|
10
|
+
def rewrite(options = {})
|
11
|
+
url = rewrite_url(options)
|
12
|
+
|
13
|
+
# needed for link_to with ajax
|
14
|
+
url._url_format = options[:format] if options[:format]
|
15
|
+
url
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
ActionView::Helpers::UrlHelper.send :class_eval do
|
20
|
+
AJAX_FORMATS = ['js', 'json']
|
21
|
+
|
22
|
+
def url_for(options = {})
|
23
|
+
options ||= {}
|
24
|
+
url = case options
|
25
|
+
when String
|
26
|
+
escape = true
|
27
|
+
options
|
28
|
+
when Hash
|
29
|
+
options = { :only_path => options[:host].nil? }.update(options.symbolize_keys)
|
30
|
+
escape = options.key?(:escape) ? options.delete(:escape) : true
|
31
|
+
@controller.send(:url_for, options)
|
32
|
+
when :back
|
33
|
+
escape = false
|
34
|
+
@controller.request.env["HTTP_REFERER"] || 'javascript:history.back()'
|
35
|
+
else
|
36
|
+
escape = false
|
37
|
+
polymorphic_path(options)
|
38
|
+
end
|
39
|
+
|
40
|
+
# changes begins here
|
41
|
+
if escape
|
42
|
+
_url_format = url._url_format
|
43
|
+
url = escape_once(url)
|
44
|
+
url._url_format = _url_format
|
45
|
+
end
|
46
|
+
url
|
47
|
+
end
|
48
|
+
|
49
|
+
def link_to(*args, &block)
|
50
|
+
if block_given?
|
51
|
+
options = args.first || {}
|
52
|
+
html_options = args.second
|
53
|
+
concat(link_to(capture(&block), options, html_options))
|
54
|
+
else
|
55
|
+
name = args.first
|
56
|
+
options = args.second || {}
|
57
|
+
html_options = args.third
|
58
|
+
|
59
|
+
url = url_for(options)
|
60
|
+
|
61
|
+
# html_options
|
62
|
+
html_options ||= {}
|
63
|
+
html_options = html_options.stringify_keys
|
64
|
+
|
65
|
+
html_options['ajax'] ||= (url._url_format and AJAX_FORMATS.include? url._url_format.to_s)
|
66
|
+
|
67
|
+
href = html_options['href']
|
68
|
+
convert_options_to_javascript!(html_options, url)
|
69
|
+
tag_options = tag_options(html_options)
|
70
|
+
|
71
|
+
href_attr = "href=\"#{url}\"" unless href
|
72
|
+
"<a #{href_attr}#{tag_options}>#{name || url}</a>"
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
private
|
77
|
+
def convert_options_to_javascript!(html_options, url = '')
|
78
|
+
confirm, ajax = html_options.delete("confirm"), (html_options.delete('ajax') || false)
|
79
|
+
|
80
|
+
method, href = html_options.delete("method"), html_options['href']
|
81
|
+
|
82
|
+
onclick = if ajax
|
83
|
+
method ||= :get
|
84
|
+
%{$(this).link_to({method: '#{method}', ajax: true}); return false;}
|
85
|
+
elsif method
|
86
|
+
%{$(this).link_to({method: '#{method}'}); return false;}
|
87
|
+
else
|
88
|
+
nil
|
89
|
+
end
|
90
|
+
|
91
|
+
if onclick and ActionController::Base.defer_static_scripts?
|
92
|
+
html_options['class'] ||= ""
|
93
|
+
end
|
94
|
+
|
95
|
+
if confirm
|
96
|
+
onclick = if onclick
|
97
|
+
"if (#{confirm_javascript_function(confirm)}) { #{onclick} };return false;"
|
98
|
+
else
|
99
|
+
"return #{confirm_javascript_function(confirm)};"
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
html_options["onclick"] = onclick if onclick
|
104
|
+
end
|
105
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# Merges default_scopes and accepts blocks
|
2
|
+
if defined?(ActiveRecord)
|
3
|
+
ActiveRecord::Base.class_eval do
|
4
|
+
class << self
|
5
|
+
def default_scoping
|
6
|
+
hash_poser = HashPoser.new do
|
7
|
+
hashes = merged_default_scopes.collect do |scope|
|
8
|
+
scope = scope.is_a?(Proc) ? scope.call : scope
|
9
|
+
scope[:create] ||= {}
|
10
|
+
scope
|
11
|
+
end
|
12
|
+
|
13
|
+
merged = hashes.inject({}, :deep_merge)
|
14
|
+
{ :find => merged, :create => (merged[:conditions] || {})}
|
15
|
+
end
|
16
|
+
[hash_poser]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# By default Rails optimizes named routes and doesn't adds default_url_options, so we fix this.
|
2
|
+
ActionController::Base.send :helper_method, :default_url_options
|
3
|
+
|
4
|
+
ActionController::Routing::Optimisation::PositionalArguments.send :class_eval do
|
5
|
+
def guard_conditions_with_def_url_opt
|
6
|
+
guard_conditions_without_def_url_opt << "default_url_options(nil).blank?"
|
7
|
+
end
|
8
|
+
alias_method_chain :guard_conditions, :def_url_opt
|
9
|
+
end
|
10
|
+
|
11
|
+
ActionController::Routing::Optimisation::PositionalArgumentsWithAdditionalParams.send :class_eval do
|
12
|
+
def guard_conditions_with_def_url_opt
|
13
|
+
guard_conditions_without_def_url_opt << "default_url_options(nil).blank?"
|
14
|
+
end
|
15
|
+
alias_method_chain :guard_conditions, :def_url_opt
|
16
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
Addressable::URI.class_eval do
|
2
|
+
def request_uri
|
3
|
+
return nil if self.absolute? && self.scheme !~ /^https?$/
|
4
|
+
return (
|
5
|
+
(self.path != "" ? self.path : "/") +
|
6
|
+
(self.query ? "?#{self.query}" : "")
|
7
|
+
)
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.normalize_host host
|
11
|
+
host.gsub(/^www\./, "")
|
12
|
+
end
|
13
|
+
|
14
|
+
def normalized_host
|
15
|
+
host ? host : host.gsub(/^www\./, '')
|
16
|
+
end
|
17
|
+
|
18
|
+
# Delete 'nil' keys
|
19
|
+
def query_values_with_skip_nil= options
|
20
|
+
to_delete = []
|
21
|
+
options.each{|k, v| to_delete << k if v.nil?}
|
22
|
+
to_delete.each{|k| options.delete k}
|
23
|
+
|
24
|
+
self.query_values_without_skip_nil = options
|
25
|
+
end
|
26
|
+
alias_method_chain :query_values=, :skip_nil
|
27
|
+
|
28
|
+
|
29
|
+
# Override original to fix:
|
30
|
+
# - extra '?' sign (/some_path?) if there's empty but not-nil query
|
31
|
+
def to_s
|
32
|
+
@uri_string ||= (begin
|
33
|
+
uri_string = ""
|
34
|
+
uri_string << "#{self.scheme}:" if self.scheme != nil
|
35
|
+
uri_string << "//#{self.authority}" if self.authority != nil
|
36
|
+
uri_string << self.path.to_s
|
37
|
+
uri_string << "?#{self.query}" unless self.query.blank?
|
38
|
+
uri_string << "##{self.fragment}" if self.fragment != nil
|
39
|
+
if uri_string.respond_to?(:force_encoding)
|
40
|
+
uri_string.force_encoding(Encoding::UTF_8)
|
41
|
+
end
|
42
|
+
uri_string
|
43
|
+
end)
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# Converts any non standart fname.yml file in /config folder into FNAME constant with loaded YAML content wrapped into SafeHash.
|
2
|
+
config_dir = "#{RAILS_ROOT}/config/"
|
3
|
+
files = Dir.glob("#{config_dir}*.yml")
|
4
|
+
ignore = ["asset_packages\\.yml", "\\..+\\."].collect{|expr| Regexp.new expr}
|
5
|
+
files.delete_if{|fname| ignore.any?{|template| template =~ fname}}
|
6
|
+
files.delete_if{|fname| /^[a-zA-Z0-9_]+\.yml$/ !~ fname.sub(config_dir, '')}
|
7
|
+
|
8
|
+
files.each do |fname|
|
9
|
+
const = fname.sub(config_dir, '').sub('.yml', '').upcase
|
10
|
+
|
11
|
+
setting = if (data = YAML.load_file(fname)).is_a? Hash
|
12
|
+
SafeHash.new data
|
13
|
+
else
|
14
|
+
data
|
15
|
+
end
|
16
|
+
|
17
|
+
Object.const_set const, setting
|
18
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module RailsExt
|
2
|
+
class << self
|
3
|
+
def create_public_symlinks! root = RAILS_ROOT
|
4
|
+
public_rails_ext_path = File.expand_path "#{File.dirname __FILE__}/../../../public/rails_ext"
|
5
|
+
raise "File #{public_rails_ext_path} don't exist!" unless File.exist? public_rails_ext_path
|
6
|
+
public_rails_path = File.expand_path "#{root}/public/rails_ext"
|
7
|
+
|
8
|
+
system "ln -nfs #{public_rails_ext_path} #{public_rails_path}"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
ActionController::Base.class_eval do
|
2
|
+
def self.defer_static_scripts
|
3
|
+
before_filter :defer_static_scripts
|
4
|
+
end
|
5
|
+
|
6
|
+
def defer_static_scripts
|
7
|
+
Thread.current[:deferred_static_scripts_called] = false
|
8
|
+
Thread.current[:defer_static_scripts] = (request.xhr? or request.format == 'js') ? false : true
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.defer_static_scripts?
|
12
|
+
!!Thread.current[:defer_static_scripts]
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
ActionView::Base.class_eval do
|
17
|
+
def defer_static_scripts?
|
18
|
+
ActionController::Base.defer_static_scripts?
|
19
|
+
end
|
20
|
+
|
21
|
+
def initialize_deferred_static_scripts
|
22
|
+
return "" unless defer_static_scripts?
|
23
|
+
not_deferred_static_script do
|
24
|
+
javascript_tag "var deferred_static_scripts = [];"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def not_deferred_static_script &block
|
29
|
+
before = Thread.current[:defer_static_scripts]
|
30
|
+
begin
|
31
|
+
Thread.current[:defer_static_scripts] = false
|
32
|
+
block.call
|
33
|
+
ensure
|
34
|
+
Thread.current[:defer_static_scripts] = before
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def call_deferred_static_scripts
|
39
|
+
return "" unless defer_static_scripts?
|
40
|
+
Thread.current[:deferred_static_scripts_called] = true
|
41
|
+
content = <<END
|
42
|
+
$.each(deferred_static_scripts, function(){this()});
|
43
|
+
deferred_static_scripts = [];
|
44
|
+
END
|
45
|
+
not_deferred_static_script do
|
46
|
+
javascript_tag content
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
# Load mail configuration if not in test environment
|
2
|
+
if RAILS_ENV != 'test'
|
3
|
+
filename = "#{RAILS_ROOT}/config/email.yml"
|
4
|
+
if File.exist? filename
|
5
|
+
email_settings = YAML::load(File.open(filename))
|
6
|
+
ActionMailer::Base.smtp_settings = email_settings[RAILS_ENV] unless email_settings[RAILS_ENV].nil?
|
7
|
+
end
|
8
|
+
end
|
@@ -0,0 +1,143 @@
|
|
1
|
+
begin
|
2
|
+
Globalize # should be defined
|
3
|
+
|
4
|
+
# Russian pluralization
|
5
|
+
I18n.backend.add_pluralizer :ru, lambda{|n|
|
6
|
+
# Правило плюрализации для русского языка, взято из CLDR, http://unicode.org/cldr/
|
7
|
+
#
|
8
|
+
#
|
9
|
+
# Russian language pluralization rules, taken from CLDR project, http://unicode.org/cldr/
|
10
|
+
#
|
11
|
+
# one -> n mod 10 is 1 and n mod 100 is not 11;
|
12
|
+
# few -> n mod 10 in 2..4 and n mod 100 not in 12..14;
|
13
|
+
# many -> n mod 10 is 0 or n mod 10 in 5..9 or n mod 100 in 11..14;
|
14
|
+
# other -> everything else
|
15
|
+
#
|
16
|
+
# Пример
|
17
|
+
#
|
18
|
+
# :one = 1, 21, 31, 41, 51, 61...
|
19
|
+
# :few = 2-4, 22-24, 32-34...
|
20
|
+
# :many = 0, 5-20, 25-30, 35-40...
|
21
|
+
# :other = 1.31, 2.31, 5.31...
|
22
|
+
n % 10 == 1 && n % 100 != 11 ? :one : [2, 3, 4].include?(n % 10) && ![12, 13, 14].include?(n % 100) ? :few : n % 10 == 0 || [5, 6, 7, 8, 9].include?(n % 10) || [11, 12, 13, 14].include?(n % 100) ? :many : :other
|
23
|
+
}
|
24
|
+
|
25
|
+
# t() and t_scope()
|
26
|
+
list = [Object, ActionController::Base, ActionView::Base, ActionMailer::Base]
|
27
|
+
list << ActiveRecord::Base if defined?(ActiveRecord)
|
28
|
+
list.each do |aclass|
|
29
|
+
aclass.class_eval do
|
30
|
+
|
31
|
+
# def self.t_scope_value; end # hack, becouse of rails method_missing magic it causes error
|
32
|
+
# def t_scope_value; end # hack, becouse of rails method_missing magic it causes error
|
33
|
+
#
|
34
|
+
# def self.t_scope *scopes
|
35
|
+
# class_inheritable_accessor :t_scope_value unless respond_to? :t_scope_value
|
36
|
+
# self.t_scope_value = scopes.collect{|scope| scope + "_scope"}
|
37
|
+
# end
|
38
|
+
|
39
|
+
# finding translation in all class hierarchy
|
40
|
+
# def t message, params = {}
|
41
|
+
# # begin
|
42
|
+
# # p([message, respond_to(:t_scope_value)])
|
43
|
+
# # rescue
|
44
|
+
# # p([self.t_scope_value])
|
45
|
+
# # end
|
46
|
+
#
|
47
|
+
# result = nil
|
48
|
+
#
|
49
|
+
# aclass = self.is_a?(Class) ? self : self.class
|
50
|
+
# list = aclass.ancestors
|
51
|
+
# list.unshift self unless self.is_a?(Class) # hack for ActionView and ActionMailer
|
52
|
+
#
|
53
|
+
# catch :found do
|
54
|
+
# list.each do |c|
|
55
|
+
# t_scope = begin
|
56
|
+
# c.respond_to(:t_scope_value)
|
57
|
+
# rescue NameError # hack for rails method_missing magic
|
58
|
+
# begin
|
59
|
+
# c.t_scope_value
|
60
|
+
# rescue NoMethodError
|
61
|
+
# nil
|
62
|
+
# end
|
63
|
+
# end
|
64
|
+
#
|
65
|
+
# next unless t_scope
|
66
|
+
#
|
67
|
+
# t_scope.each do |ts|
|
68
|
+
# begin
|
69
|
+
# result = I18n.t "#{ts}.#{message}", params.merge(:raise => true)
|
70
|
+
# rescue I18n::MissingTranslationData
|
71
|
+
# end
|
72
|
+
# throw :found if result
|
73
|
+
# end
|
74
|
+
# end
|
75
|
+
# end
|
76
|
+
#
|
77
|
+
# result ||= I18n.t message, params
|
78
|
+
# result.to_s # Globalize2 uses Translation::Static instead of String
|
79
|
+
# end
|
80
|
+
|
81
|
+
def t *args
|
82
|
+
# Globalize2 uses Translation::Static instead of String
|
83
|
+
I18n.t(*args).to_s
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
# ActionController::Base.class_eval do
|
90
|
+
# # Becouse we need to transfer @t_scope also to View
|
91
|
+
# def initialize_with_t_scope *args, &block
|
92
|
+
# initialize_without_t_scope *args, &block
|
93
|
+
# t_scope = self.class.t_scope_value
|
94
|
+
# @t_scope_value = t_scope if t_scope
|
95
|
+
# end
|
96
|
+
# alias_method_chain :initialize, :t_scope
|
97
|
+
# end
|
98
|
+
|
99
|
+
ActionView::Base.class_eval do
|
100
|
+
# def t_scope_value
|
101
|
+
# controller.class.t_scope_value if controller.class.respond_to? :t_scope_value
|
102
|
+
# end
|
103
|
+
end
|
104
|
+
|
105
|
+
ActionMailer::Base.class_eval do
|
106
|
+
# def t_scope_value
|
107
|
+
# controller.class.t_scope_value if controller.class.respond_to? :t_scope_value
|
108
|
+
# end
|
109
|
+
# def t_scope scope
|
110
|
+
# raise 'stub! use the same'
|
111
|
+
# @t_scope = scope
|
112
|
+
# @body[:t_scope] = @t_scope
|
113
|
+
# end
|
114
|
+
end
|
115
|
+
|
116
|
+
# Prepare locale in Controller
|
117
|
+
# module ActionController
|
118
|
+
# module Acts
|
119
|
+
# module Localized
|
120
|
+
# def self.included(base)
|
121
|
+
# base.extend(ClassMethods)
|
122
|
+
# end
|
123
|
+
#
|
124
|
+
# module ClassMethods
|
125
|
+
# def acts_as_localized
|
126
|
+
# include ActionController::Acts::Localized::InstanceMethods
|
127
|
+
#
|
128
|
+
# before_filter :prepare_locale
|
129
|
+
# end
|
130
|
+
# end
|
131
|
+
#
|
132
|
+
# module InstanceMethods
|
133
|
+
# def prepare_locale
|
134
|
+
# I18n.locale = params[:l] unless params[:l].blank?
|
135
|
+
# end
|
136
|
+
# end
|
137
|
+
# end
|
138
|
+
# end
|
139
|
+
# end
|
140
|
+
# ActionController::Base.send :include, ActionController::Acts::Localized
|
141
|
+
# rescue NameError
|
142
|
+
# puts "i18n_helper (from rails_commons) disabled"
|
143
|
+
end
|
@@ -0,0 +1,104 @@
|
|
1
|
+
require 'singleton'
|
2
|
+
|
3
|
+
class SafeHash < BlankSlate
|
4
|
+
attr_reader :hash
|
5
|
+
|
6
|
+
def initialize hash = {}
|
7
|
+
reinitialize hash
|
8
|
+
end
|
9
|
+
|
10
|
+
def []= key, value
|
11
|
+
value = SafeHash.new value if value.is_a? Hash
|
12
|
+
@hash[key.to_s] = value
|
13
|
+
end
|
14
|
+
|
15
|
+
def include? key
|
16
|
+
@hash.include? key.to_s
|
17
|
+
end
|
18
|
+
|
19
|
+
def [] key, *args
|
20
|
+
key = key.to_s
|
21
|
+
if key.last == '!'
|
22
|
+
key = key[0..key.size-2]
|
23
|
+
if (result = @hash[key]).eql? nil
|
24
|
+
raise "No key #{key}"
|
25
|
+
else
|
26
|
+
result
|
27
|
+
end
|
28
|
+
elsif key.last == '?'
|
29
|
+
key = key[0..key.size-2]
|
30
|
+
@hash.include? key
|
31
|
+
elsif (result = @hash[key]).eql? nil
|
32
|
+
if args.empty?
|
33
|
+
SafeNil.instance
|
34
|
+
else
|
35
|
+
return *args
|
36
|
+
end
|
37
|
+
else
|
38
|
+
result
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def reinitialize hash
|
43
|
+
@hash = {}
|
44
|
+
hash.each do |k, v|
|
45
|
+
v = SafeHash.new v if v.is_a? Hash
|
46
|
+
@hash[k.to_s] = v
|
47
|
+
end
|
48
|
+
# @hash.freeze
|
49
|
+
end
|
50
|
+
|
51
|
+
def method_missing m, *args
|
52
|
+
self[m, *args]
|
53
|
+
end
|
54
|
+
|
55
|
+
def to_yaml *args
|
56
|
+
@hash.to_yaml *args
|
57
|
+
end
|
58
|
+
|
59
|
+
def inspect
|
60
|
+
@hash.inspect
|
61
|
+
end
|
62
|
+
|
63
|
+
def to_h
|
64
|
+
@hash
|
65
|
+
end
|
66
|
+
|
67
|
+
class SafeNil < BlankSlate
|
68
|
+
include Singleton
|
69
|
+
|
70
|
+
def [] key, *args
|
71
|
+
if key.to_s.last == '!'
|
72
|
+
raise "No key #{key}"
|
73
|
+
elsif args.empty?
|
74
|
+
SafeNil.instance
|
75
|
+
else
|
76
|
+
return *args
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def method_missing m, *args
|
81
|
+
self[m, *args]
|
82
|
+
end
|
83
|
+
|
84
|
+
def include? key
|
85
|
+
false
|
86
|
+
end
|
87
|
+
|
88
|
+
def to_b
|
89
|
+
false
|
90
|
+
end
|
91
|
+
|
92
|
+
def to_yaml *args
|
93
|
+
nil.to_yaml *args
|
94
|
+
end
|
95
|
+
|
96
|
+
def to_h
|
97
|
+
{}
|
98
|
+
end
|
99
|
+
|
100
|
+
def inspect
|
101
|
+
nil.inspect
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'rails_ext/basic'
|
2
|
+
|
3
|
+
require 'rails_ext/micelaneous/safe_hash'
|
4
|
+
require 'rails_ext/micelaneous/config_files'
|
5
|
+
|
6
|
+
require 'rails_ext/micelaneous/defer_static_javascripts'
|
7
|
+
require 'rails_ext/hacks/defer_static_javascripts'
|
8
|
+
|
9
|
+
require 'rails_ext/micelaneous/email_config'
|
10
|
+
|
11
|
+
require 'rails_ext/micelaneous/rails_require'
|
12
|
+
|
13
|
+
require 'rails_ext/micelaneous/create_public_symlinks'
|
14
|
+
|
15
|
+
require 'addressable/uri'
|
16
|
+
require 'rails_ext/micelaneous/addressable_uri'
|
17
|
+
::Uri = Addressable::URI
|