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
data/.gitignore
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'spec/rake/spectask'
|
3
|
+
|
4
|
+
Dir.chdir File.dirname(__FILE__)
|
5
|
+
|
6
|
+
# Specs
|
7
|
+
task :default => :spec
|
8
|
+
|
9
|
+
Spec::Rake::SpecTask.new('spec') do |t|
|
10
|
+
t.spec_files = FileList["spec/**/*_spec.rb"]
|
11
|
+
t.libs = ["lib", "spec"]
|
12
|
+
end
|
13
|
+
|
14
|
+
# Gem
|
15
|
+
require 'rake/clean'
|
16
|
+
require 'rake/gempackagetask'
|
17
|
+
require 'fileutils'
|
18
|
+
|
19
|
+
spec = Gem::Specification.new do |s|
|
20
|
+
s.name = "crystal-ext"
|
21
|
+
s.version = "0.0.1"
|
22
|
+
s.summary = "Crystal Ext - Extensions for the Crystal framework"
|
23
|
+
s.description = "Crystal Ext - Extensions for the Crystal framework"
|
24
|
+
s.author = "Alexey Petrushin"
|
25
|
+
# s.email = ""
|
26
|
+
s.homepage = "http://github.com/alexeypetrushin/crystal-ext"
|
27
|
+
|
28
|
+
s.platform = Gem::Platform::RUBY
|
29
|
+
s.has_rdoc = true
|
30
|
+
# s.extra_rdoc_files = ["README.rdoc"]
|
31
|
+
|
32
|
+
# s.files = (%w{rakefile readme.md .gitignore} + Dir.glob("{app,lib,spec,.git}/**/*"))
|
33
|
+
s.files = (%w{Rakefile readme.md .gitignore} + Dir.glob("{lib,spec,git}/**/*"))
|
34
|
+
|
35
|
+
s.require_paths = ["lib"]
|
36
|
+
|
37
|
+
[
|
38
|
+
'crystal',
|
39
|
+
].each{|name| s.add_dependency(name)}
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
PACKAGE_DIR = "#{File.expand_path File.dirname(__FILE__)}/build"
|
44
|
+
|
45
|
+
Rake::GemPackageTask.new(spec) do |p|
|
46
|
+
package_dir = PACKAGE_DIR
|
47
|
+
# FileUtils.mkdir package_dir unless File.exist? package_dir
|
48
|
+
p.need_tar = true if RUBY_PLATFORM !~ /mswin/
|
49
|
+
p.need_zip = true
|
50
|
+
p.package_dir = package_dir
|
51
|
+
end
|
52
|
+
|
53
|
+
# CLEAN.include [ 'pkg', '*.gem']
|
54
|
+
|
55
|
+
task :push do
|
56
|
+
dir = Dir.chdir PACKAGE_DIR do
|
57
|
+
gem_file = Dir.glob("crystal*.gem").first
|
58
|
+
system "gem push #{gem_file}"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
task :clean do
|
63
|
+
system "rm -r #{PACKAGE_DIR}"
|
64
|
+
end
|
65
|
+
|
66
|
+
task :release => [:gem, :push, :clean]
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module AbstractInterface
|
2
|
+
module ControllerHelper
|
3
|
+
TEMPLATE_EXTENSIONS = ['html.haml', 'html.erb']
|
4
|
+
|
5
|
+
def themed_partial_exist? partial
|
6
|
+
partial = partial + "_t"
|
7
|
+
|
8
|
+
partial_fname = if pos = partial.index('/')
|
9
|
+
partial.clone.insert(pos + 1, '_')
|
10
|
+
else
|
11
|
+
"_#{partial}"
|
12
|
+
end
|
13
|
+
|
14
|
+
TEMPLATE_EXTENSIONS.any?{|ext| File.exist? "#{AbstractInterface.themes_dir}/#{current_theme.name}/#{partial_fname}.#{ext}"}
|
15
|
+
end
|
16
|
+
cache_with_params! :themed_partial_exist? unless Rails.development?
|
17
|
+
|
18
|
+
def themed_partial partial
|
19
|
+
if themed_partial_exist? partial
|
20
|
+
"/themes/#{current_theme.name}/#{partial}_t"
|
21
|
+
else
|
22
|
+
"/themes/default/#{partial}_t"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def current_theme
|
27
|
+
@current_theme ||= AbstractInterface::Theme.new
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
module AbstractInterface
|
2
|
+
module FormBuilders
|
3
|
+
module AbstractFormBuilder
|
4
|
+
|
5
|
+
attr_reader :template
|
6
|
+
|
7
|
+
def line *items
|
8
|
+
template.render :partial => template.themed_partial('forms/line'), :object => {:items => items, :delimiter => false}.to_openobject
|
9
|
+
end
|
10
|
+
|
11
|
+
def submit *args
|
12
|
+
@template.submit_tag *args
|
13
|
+
end
|
14
|
+
|
15
|
+
# def hidden_field_tag *args
|
16
|
+
# result[:hidden_fields] << @template.hidden_field_tag(*args)
|
17
|
+
# end
|
18
|
+
|
19
|
+
def line_with_delimiters *items
|
20
|
+
template.render :partial => template.themed_partial('forms/line'), :object => {:items => items, :delimiter => true}.to_openobject
|
21
|
+
end
|
22
|
+
|
23
|
+
# text_field_tag, ... xxx_tag
|
24
|
+
def method_missing name, *args, &block
|
25
|
+
options = args.extract_options!.symbolize_keys
|
26
|
+
args << options
|
27
|
+
|
28
|
+
inject_styles! options, name
|
29
|
+
|
30
|
+
input = @template.send name, *args, &block
|
31
|
+
|
32
|
+
remove_styles! options
|
33
|
+
|
34
|
+
custom_helper input, options, name, options[:object], *args
|
35
|
+
end
|
36
|
+
|
37
|
+
def error_messages *errors
|
38
|
+
if errors.size == 1 and errors.first.is_a?(Array)
|
39
|
+
custom_error_messages *errors
|
40
|
+
else
|
41
|
+
custom_error_messages errors
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def field_tag html, options = {}
|
46
|
+
custom_helper html, options, nil, options[:object]
|
47
|
+
end
|
48
|
+
|
49
|
+
protected
|
50
|
+
def custom_helper input, options, field, object, *args
|
51
|
+
# Input
|
52
|
+
options[:input] = input
|
53
|
+
|
54
|
+
# Errors
|
55
|
+
errors = options[:errors] || (object ? (object.errors.on(field) || []) : [])
|
56
|
+
errors = [errors] unless errors.is_a?(Array)
|
57
|
+
options[:errors] = errors
|
58
|
+
|
59
|
+
template.render :partial => template.themed_partial('forms/field'), :object => options.to_openobject
|
60
|
+
end
|
61
|
+
|
62
|
+
def custom_error_messages errors
|
63
|
+
errors = [errors] unless errors.is_a?(Array)
|
64
|
+
template.render :partial => template.themed_partial('forms/errors'), :object => errors
|
65
|
+
end
|
66
|
+
|
67
|
+
def inject_styles! options, name
|
68
|
+
name = name.to_s.sub(/_tag$/, "")
|
69
|
+
options[:class] ||= "";
|
70
|
+
options[:class] << " themed_input #{name}_input"
|
71
|
+
end
|
72
|
+
|
73
|
+
def remove_styles! options
|
74
|
+
options.delete :class
|
75
|
+
options.delete 'class' # sometimes it's a String
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module AbstractInterface
|
2
|
+
module FormBuilders
|
3
|
+
class ThemedFormBuilder < ActionView::Helpers::FormBuilder
|
4
|
+
include AbstractFormBuilder
|
5
|
+
|
6
|
+
helpers = field_helpers +
|
7
|
+
%w{date_select datetime_select time_select} +
|
8
|
+
%w{collection_select select country_select time_zone_select} -
|
9
|
+
%w{hidden_field fields_for submit} # Don't decorate these
|
10
|
+
|
11
|
+
helpers.each do |name|
|
12
|
+
define_method(name) do |field, *args|
|
13
|
+
options = args.extract_options!
|
14
|
+
args << options
|
15
|
+
|
16
|
+
label = if object.class.respond_to? :human_attribute_name
|
17
|
+
object.class.try(:human_attribute_name, field)
|
18
|
+
else
|
19
|
+
object.t field
|
20
|
+
end
|
21
|
+
|
22
|
+
options[:label] = label unless options.include? :label
|
23
|
+
|
24
|
+
inject_styles! options, name
|
25
|
+
|
26
|
+
input = super field, *args
|
27
|
+
|
28
|
+
remove_styles! options
|
29
|
+
|
30
|
+
custom_helper input, options, field, object, *args
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def error_messages
|
35
|
+
errors = object.errors.on(:base) || []
|
36
|
+
custom_error_messages errors
|
37
|
+
end
|
38
|
+
|
39
|
+
protected
|
40
|
+
|
41
|
+
def object
|
42
|
+
@object ||= @template.instance_variable_get "@#{@object_name}"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module AbstractInterface
|
2
|
+
class HamlBuilder < BlankSlate
|
3
|
+
def initialize template, hash = OpenObject.new
|
4
|
+
@template = template
|
5
|
+
@hash, @array = hash, []
|
6
|
+
end
|
7
|
+
|
8
|
+
def method_missing m, value = nil, &block
|
9
|
+
@hash[m] = HamlBuilder.get_input @template, value, &block
|
10
|
+
nil
|
11
|
+
end
|
12
|
+
|
13
|
+
def add value = nil, &block
|
14
|
+
@array << HamlBuilder.get_input(@template, value, &block)
|
15
|
+
nil
|
16
|
+
end
|
17
|
+
|
18
|
+
# def add_item content, opt = {}, &block
|
19
|
+
# opt[:content] = content
|
20
|
+
# opt[:content] ||= @template.capture &block if block
|
21
|
+
# add opt
|
22
|
+
# end
|
23
|
+
|
24
|
+
def get_value
|
25
|
+
!@array.empty? ? @array : @hash
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.get_input template, value, &block
|
29
|
+
value = value.is_a?(Hash) ? value.to_openobject : value
|
30
|
+
|
31
|
+
block_value = if block
|
32
|
+
if block.arity <= 0
|
33
|
+
template.should_not! :be_nil
|
34
|
+
template.capture &block
|
35
|
+
else
|
36
|
+
b = HamlBuilder.new template
|
37
|
+
block.call b
|
38
|
+
b.get_value
|
39
|
+
end
|
40
|
+
else
|
41
|
+
nil
|
42
|
+
end
|
43
|
+
|
44
|
+
if value and block_value
|
45
|
+
if block_value.is_a? Hash
|
46
|
+
value = value.merge block_value
|
47
|
+
else
|
48
|
+
raise "Invalid usage!" if value.include? :content
|
49
|
+
value.content = block_value
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
value || block_value
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Samples
|
2
|
+
class Errors < OpenObject
|
3
|
+
def on key
|
4
|
+
self[key]
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
class ThemeSample < OpenObject
|
9
|
+
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.build_stub!
|
13
|
+
s = ThemeSample.new :name => "Some Name", :active => true, :body => "Some text"
|
14
|
+
s.errors = Errors.new \
|
15
|
+
:base => ["Base Error Description", "Base Error Description 2"],
|
16
|
+
:name => ["Name Error Description 1", "Name Error Description 2"]
|
17
|
+
s
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# content_or_self
|
2
|
+
[Hash, OpenObject].each do |aclass|
|
3
|
+
aclass.class_eval do
|
4
|
+
def hash?; true end
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
NilClass.class_eval do
|
9
|
+
def content; "" end
|
10
|
+
def hash?; false end
|
11
|
+
end
|
12
|
+
|
13
|
+
String.class_eval do
|
14
|
+
def content; self end
|
15
|
+
def hash?; false end
|
16
|
+
end
|
17
|
+
|
18
|
+
# OpenObject
|
19
|
+
OpenObject.class_eval do
|
20
|
+
HTML_ATTRIBUTES = [:id, :class]
|
21
|
+
|
22
|
+
def merge_html_attributes hash
|
23
|
+
# html attributes
|
24
|
+
result = {}
|
25
|
+
HTML_ATTRIBUTES.each{|k| result[k.to_s] = self[k] if include? k}
|
26
|
+
html_attributes.each{|k, v| result[k.to_s] = v} if html_attributes?
|
27
|
+
|
28
|
+
# merging html attributes with hash
|
29
|
+
hash.each do |k, v|
|
30
|
+
k = k.to_s
|
31
|
+
if result.include?(k) and v.is_a?(String)
|
32
|
+
string = result[k].should! :be_a, [Symbol, String]
|
33
|
+
result[k] = "#{result[k]}#{v}"
|
34
|
+
else
|
35
|
+
result[k] = v
|
36
|
+
end
|
37
|
+
end
|
38
|
+
result
|
39
|
+
end
|
40
|
+
|
41
|
+
protected
|
42
|
+
def method_missing( sym, arg=nil, &blk)
|
43
|
+
type = sym.to_s[-1,1]
|
44
|
+
key = sym.to_s.sub(/[=?!]$/,'').to_sym
|
45
|
+
if type == '='
|
46
|
+
define_slot(key,arg)
|
47
|
+
elsif type == '!'
|
48
|
+
define_slot(key,arg)
|
49
|
+
self
|
50
|
+
elsif type == '?'
|
51
|
+
!self[key].blank?
|
52
|
+
else
|
53
|
+
self[key]
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module AbstractInterface
|
2
|
+
class Theme
|
3
|
+
attr_writer :name, :layout_template, :layout
|
4
|
+
def name; @name || 'default' end
|
5
|
+
def layout; @layout || 'default' end
|
6
|
+
|
7
|
+
def layout_template
|
8
|
+
if @layout_template
|
9
|
+
# Check if this template exists
|
10
|
+
exists = layout_definitions.any?{|layout_name, ld| ld['layout_template'] == @layout_template}
|
11
|
+
exists ? @layout_template : 'default'
|
12
|
+
else
|
13
|
+
layout_definition['layout_template'] || 'default'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def layout_definition
|
18
|
+
layout_definitions[layout] || layout_definitions['default'] || {}
|
19
|
+
end
|
20
|
+
|
21
|
+
def layout_definitions
|
22
|
+
if AbstractInterface.layouts_defined?
|
23
|
+
AbstractInterface.layout_definitions(name)
|
24
|
+
else
|
25
|
+
{}
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def available_layouts_names
|
30
|
+
layout_definitions.keys
|
31
|
+
end
|
32
|
+
|
33
|
+
def metadata
|
34
|
+
AbstractInterface.theme_metadata(name)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,158 @@
|
|
1
|
+
module AbstractInterface
|
2
|
+
class ViewBuilder
|
3
|
+
|
4
|
+
def self.generate_helper_methods methods
|
5
|
+
|
6
|
+
methods.each do |folder, templates|
|
7
|
+
templates.each do |template|
|
8
|
+
code = %{\
|
9
|
+
def #{template} *args, &block
|
10
|
+
render_haml_builder "#{folder}", "#{template}", *args, &block
|
11
|
+
end}
|
12
|
+
|
13
|
+
eval code, binding, __FILE__, __LINE__
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
attr_reader :template
|
21
|
+
def initialize template
|
22
|
+
@template = template
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
#
|
27
|
+
# Template methods
|
28
|
+
#
|
29
|
+
PROXY_METHODS = %w{
|
30
|
+
capture
|
31
|
+
concat
|
32
|
+
content_for
|
33
|
+
content_tag
|
34
|
+
render
|
35
|
+
themed_partial
|
36
|
+
themed_partial_exist?
|
37
|
+
themed_resource
|
38
|
+
}
|
39
|
+
PROXY_METHODS.each do |m|
|
40
|
+
delegate m, :to => :template
|
41
|
+
end
|
42
|
+
|
43
|
+
|
44
|
+
#
|
45
|
+
# Builders
|
46
|
+
#
|
47
|
+
def options *args, &block
|
48
|
+
opt = args.extract_options!
|
49
|
+
args.size.should! :be_in, 0..1
|
50
|
+
opt[:content] = args.first if args.size == 1
|
51
|
+
|
52
|
+
HamlBuilder.get_input self.template, opt, &block
|
53
|
+
# options.should! :be_a, Hash
|
54
|
+
# block.should! :be_a, Proc
|
55
|
+
# if block
|
56
|
+
# b = HamlBuilder.new self.template
|
57
|
+
# block.call b
|
58
|
+
# options.merge b.get_value
|
59
|
+
# else
|
60
|
+
# options
|
61
|
+
# end
|
62
|
+
end
|
63
|
+
|
64
|
+
#
|
65
|
+
# Forms
|
66
|
+
#
|
67
|
+
def form *args, &block
|
68
|
+
b = FormBuilders::ThemedFormTagBuilder.new self.template
|
69
|
+
|
70
|
+
options = {}.to_openobject
|
71
|
+
prepare_form! options, *args
|
72
|
+
|
73
|
+
# wrap_theme 'forms/begin', true do
|
74
|
+
concat render(:partial => themed_partial('forms/begin'), :object => options)
|
75
|
+
concat capture(b, &block)
|
76
|
+
concat render(:partial => themed_partial('forms/end'), :object => options)
|
77
|
+
# end
|
78
|
+
end
|
79
|
+
|
80
|
+
def form_for(record_or_name_or_array, *args, &proc)
|
81
|
+
raise ArgumentError, "Missing block" unless block_given?
|
82
|
+
|
83
|
+
options = args.extract_options!
|
84
|
+
|
85
|
+
case record_or_name_or_array
|
86
|
+
when String, Symbol
|
87
|
+
object_name = record_or_name_or_array
|
88
|
+
object = instance_variable_get "@#{record_or_name_or_array}"
|
89
|
+
when Array
|
90
|
+
object = record_or_name_or_array.last
|
91
|
+
object_name = ActionController::RecordIdentifier.singular_class_name(object)
|
92
|
+
self.template.apply_form_for_options!(record_or_name_or_array, options)
|
93
|
+
args.unshift object
|
94
|
+
else
|
95
|
+
object = record_or_name_or_array
|
96
|
+
object_name = ActionController::RecordIdentifier.singular_class_name(object)
|
97
|
+
self.template.apply_form_for_options!([object], options)
|
98
|
+
args.unshift object
|
99
|
+
end
|
100
|
+
|
101
|
+
# Rendering Form
|
102
|
+
renderer_options = {}.to_openobject
|
103
|
+
prepare_form! renderer_options, options.delete(:url) || {}, options.delete(:html) || {}
|
104
|
+
|
105
|
+
# wrap_theme 'forms/begin', true do
|
106
|
+
concat render(:partial => themed_partial('forms/begin'), :object => renderer_options)
|
107
|
+
|
108
|
+
options[:builder] = FormBuilders::ThemedFormBuilder
|
109
|
+
self.template.fields_for(object_name, *(args << options), &proc)
|
110
|
+
|
111
|
+
concat render(:partial => themed_partial('forms/end'), :object => renderer_options)
|
112
|
+
# end
|
113
|
+
end
|
114
|
+
|
115
|
+
|
116
|
+
private
|
117
|
+
# # We need to wrap top-level default templates (for non-existing templates for current theme) inside '_d' div.
|
118
|
+
# def wrap_theme partial, concat = false, &block
|
119
|
+
# unless themed_partial_exist? partial
|
120
|
+
# # we don't need _theme_wrapper for dialog and popup, it should be invisible
|
121
|
+
# classes = if AbstractInterface.dont_wrap_into_placeholder.include? partial
|
122
|
+
# "_d"
|
123
|
+
# else
|
124
|
+
# "_d _theme_wrapper"
|
125
|
+
# end
|
126
|
+
#
|
127
|
+
# if concat
|
128
|
+
# self.concat %{<div class="#{classes}">}
|
129
|
+
# block.call
|
130
|
+
# self.concat %{</div>}
|
131
|
+
# else
|
132
|
+
# html = block.call
|
133
|
+
# content_tag :div, html, :class => classes
|
134
|
+
# end
|
135
|
+
# else
|
136
|
+
# block.call
|
137
|
+
# end
|
138
|
+
# end
|
139
|
+
|
140
|
+
def render_haml_builder folder, template, *args, &block
|
141
|
+
opt = options *args, &block
|
142
|
+
|
143
|
+
partial = "#{folder}/#{template}"
|
144
|
+
|
145
|
+
# html = wrap_theme partial do
|
146
|
+
html = render :partial => themed_partial(partial), :object => opt
|
147
|
+
# end
|
148
|
+
|
149
|
+
block ? self.concat(html) : html
|
150
|
+
end
|
151
|
+
|
152
|
+
def prepare_form! options, *args
|
153
|
+
buff = template.form_tag *args
|
154
|
+
options[:begin] = buff
|
155
|
+
options[:end] = '</form>'
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module AbstractInterface
|
2
|
+
module ViewHelper
|
3
|
+
#
|
4
|
+
# Basic
|
5
|
+
#
|
6
|
+
def b
|
7
|
+
@b ||= AbstractInterface::ViewBuilder.new self
|
8
|
+
end
|
9
|
+
alias_method :builder, :b
|
10
|
+
|
11
|
+
def themed_resource resource
|
12
|
+
"/#{AbstractInterface.plugin_name.should_not_be!(:blank)}/themes/#{current_theme.name}/#{resource}"
|
13
|
+
end
|
14
|
+
|
15
|
+
def build_layout layout = nil
|
16
|
+
# Configuring
|
17
|
+
current_theme.layout = layout
|
18
|
+
|
19
|
+
# Rendering
|
20
|
+
current_theme.layout_definition['slots'].each do |slot_name, slots|
|
21
|
+
slots = Array(slots)
|
22
|
+
slots.each do |partial|
|
23
|
+
content_for slot_name do
|
24
|
+
render :partial => partial
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
require 'abstract_interface/haml_builder'
|
2
|
+
require 'abstract_interface/model_stub'
|
3
|
+
require 'abstract_interface/view_helper'
|
4
|
+
require 'abstract_interface/support'
|
5
|
+
|
6
|
+
ActionController::Base.class_eval do
|
7
|
+
include AbstractInterface::ControllerHelper
|
8
|
+
helper AbstractInterface::ViewHelper
|
9
|
+
|
10
|
+
helper_method :themed_partial_exist?, :themed_partial, :current_theme
|
11
|
+
end
|
12
|
+
|
13
|
+
ActionView::Base.field_error_proc = lambda do |html_tag, instance|
|
14
|
+
html_tag
|
15
|
+
end
|
16
|
+
|
17
|
+
module AbstractInterface
|
18
|
+
class << self
|
19
|
+
attr_accessor :plugin_name
|
20
|
+
attr_accessor :layout_configurations_dir
|
21
|
+
|
22
|
+
def generate_helper_methods *args
|
23
|
+
AbstractInterface::ViewBuilder.generate_helper_methods *args
|
24
|
+
end
|
25
|
+
|
26
|
+
def available_themes; @available_themes ||= [] end
|
27
|
+
|
28
|
+
# Templates that should be wrapped if it doesn't defined for current theme
|
29
|
+
# def dont_wrap_into_placeholder; @dont_wrap_into_placeholder ||= Set.new end
|
30
|
+
|
31
|
+
# TODO 3 don't cache it becouse there's a lots of text data that will be reside in memory.
|
32
|
+
def theme_metadata theme
|
33
|
+
metadata = {}
|
34
|
+
fname = "#{AbstractInterface.themes_dir}/#{theme}/metadata.rb"
|
35
|
+
if File.exist? fname
|
36
|
+
code = File.read fname
|
37
|
+
metadata = eval code
|
38
|
+
metadata.should! :be_a, Hash
|
39
|
+
end
|
40
|
+
metadata.to_openobject
|
41
|
+
end
|
42
|
+
cache_with_params! :theme_metadata unless Rails.development?
|
43
|
+
|
44
|
+
def themes_dir
|
45
|
+
"#{RAILS_ROOT}/vendor/plugins/#{AbstractInterface.plugin_name.should_not_be!(:blank)}/app/views/themes"
|
46
|
+
end
|
47
|
+
|
48
|
+
def layouts_defined?
|
49
|
+
!!layout_configurations_dir
|
50
|
+
end
|
51
|
+
|
52
|
+
def layout_definitions theme
|
53
|
+
fname = "#{layout_configurations_dir.should_not_be!(:empty)}/#{theme}.yml"
|
54
|
+
File.should! :exist?, fname
|
55
|
+
lds = YAML.load_file(fname)
|
56
|
+
validate_layout_definition!(lds, theme)
|
57
|
+
lds
|
58
|
+
end
|
59
|
+
cache_with_params! :layout_definitions unless Rails.development?
|
60
|
+
|
61
|
+
protected
|
62
|
+
def validate_layout_definition! lds, theme
|
63
|
+
lds.should! :be_a, Hash
|
64
|
+
unless lds.include?('default')
|
65
|
+
raise "No 'default' layout definition for '#{theme}' Theme (there always should be definition for 'default' layout)!"
|
66
|
+
end
|
67
|
+
lds.each do |theme_name, ld|
|
68
|
+
ld.should! :be_a, Hash
|
69
|
+
ld.should! :include, 'layout_template'
|
70
|
+
ld.should! :include, 'slots'
|
71
|
+
ld['slots'].should! :be_a, Hash
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
|
78
|
+
Rails.development{RailsExt.create_public_symlinks!} # rails_ext.css, rails_ext.js in development mode
|