adva_cms 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/NOTES +132 -0
- data/README.md +29 -0
- data/Rakefile +2 -0
- data/adva_cms.gemspec +22 -0
- data/app/assets/images/adva_cms/admin/header_bg.png +0 -0
- data/app/assets/images/adva_cms/admin/section_menu_bg.png +0 -0
- data/app/assets/images/adva_cms/admin/tab_action_active.png +0 -0
- data/app/assets/images/adva_cms/admin/tab_main_active.png +0 -0
- data/app/assets/images/adva_cms/admin/tab_sidebar_active.png +0 -0
- data/app/assets/images/adva_cms/admin/tab_top_active.png +0 -0
- data/app/assets/images/adva_cms/asset_selected.png +0 -0
- data/app/assets/images/adva_cms/avatar.gif +0 -0
- data/app/assets/images/adva_cms/filter-bg.png +0 -0
- data/app/assets/images/adva_cms/icons/accept.png +0 -0
- data/app/assets/images/adva_cms/icons/add.png +0 -0
- data/app/assets/images/adva_cms/icons/arrow_cross.png +0 -0
- data/app/assets/images/adva_cms/icons/arrow_cross_2.png +0 -0
- data/app/assets/images/adva_cms/icons/arrow_cross_3.png +0 -0
- data/app/assets/images/adva_cms/icons/arrow_up_down.png +0 -0
- data/app/assets/images/adva_cms/icons/assets/audio.png +0 -0
- data/app/assets/images/adva_cms/icons/assets/doc.png +0 -0
- data/app/assets/images/adva_cms/icons/assets/pdf.png +0 -0
- data/app/assets/images/adva_cms/icons/assets/video.png +0 -0
- data/app/assets/images/adva_cms/icons/attach.png +0 -0
- data/app/assets/images/adva_cms/icons/bin.png +0 -0
- data/app/assets/images/adva_cms/icons/bin_closed.png +0 -0
- data/app/assets/images/adva_cms/icons/bin_empty.png +0 -0
- data/app/assets/images/adva_cms/icons/bullet_black.png +0 -0
- data/app/assets/images/adva_cms/icons/bullet_delete.png +0 -0
- data/app/assets/images/adva_cms/icons/bullet_error.png +0 -0
- data/app/assets/images/adva_cms/icons/bullet_go.png +0 -0
- data/app/assets/images/adva_cms/icons/bullet_red.png +0 -0
- data/app/assets/images/adva_cms/icons/bullet_white.png +0 -0
- data/app/assets/images/adva_cms/icons/bullet_yellow.png +0 -0
- data/app/assets/images/adva_cms/icons/cancel.png +0 -0
- data/app/assets/images/adva_cms/icons/comment.gif +0 -0
- data/app/assets/images/adva_cms/icons/comment.png +0 -0
- data/app/assets/images/adva_cms/icons/comment_add.png +0 -0
- data/app/assets/images/adva_cms/icons/comment_blue.gif +0 -0
- data/app/assets/images/adva_cms/icons/comment_delete.png +0 -0
- data/app/assets/images/adva_cms/icons/comment_edit.png +0 -0
- data/app/assets/images/adva_cms/icons/comment_yellow.gif +0 -0
- data/app/assets/images/adva_cms/icons/cross.png +0 -0
- data/app/assets/images/adva_cms/icons/delete.png +0 -0
- data/app/assets/images/adva_cms/icons/eye.png +0 -0
- data/app/assets/images/adva_cms/icons/favorites.png +0 -0
- data/app/assets/images/adva_cms/icons/help.png +0 -0
- data/app/assets/images/adva_cms/icons/hourglass.png +0 -0
- data/app/assets/images/adva_cms/icons/icon_attachment.gif +0 -0
- data/app/assets/images/adva_cms/icons/icon_padlock.gif +0 -0
- data/app/assets/images/adva_cms/icons/link.png +0 -0
- data/app/assets/images/adva_cms/icons/lock.png +0 -0
- data/app/assets/images/adva_cms/icons/magnifier.png +0 -0
- data/app/assets/images/adva_cms/icons/minus.gif +0 -0
- data/app/assets/images/adva_cms/icons/page_add.png +0 -0
- data/app/assets/images/adva_cms/icons/page_delete.png +0 -0
- data/app/assets/images/adva_cms/icons/page_edit.png +0 -0
- data/app/assets/images/adva_cms/icons/page_favorites.png +0 -0
- data/app/assets/images/adva_cms/icons/page_go.png +0 -0
- data/app/assets/images/adva_cms/icons/page_green.png +0 -0
- data/app/assets/images/adva_cms/icons/page_red.png +0 -0
- data/app/assets/images/adva_cms/icons/page_white_add.png +0 -0
- data/app/assets/images/adva_cms/icons/page_white_delete.png +0 -0
- data/app/assets/images/adva_cms/icons/page_white_edit.png +0 -0
- data/app/assets/images/adva_cms/icons/page_white_go.png +0 -0
- data/app/assets/images/adva_cms/icons/page_white_link.png +0 -0
- data/app/assets/images/adva_cms/icons/page_white_magnify.png +0 -0
- data/app/assets/images/adva_cms/icons/pencil.png +0 -0
- data/app/assets/images/adva_cms/icons/star.png +0 -0
- data/app/assets/images/adva_cms/icons/stop.png +0 -0
- data/app/assets/images/adva_cms/icons/tag_green.png +0 -0
- data/app/assets/images/adva_cms/icons/tick.png +0 -0
- data/app/assets/images/adva_cms/icons/zoom.png +0 -0
- data/app/assets/images/adva_cms/indicator.gif +0 -0
- data/app/assets/images/adva_cms/preview.png +0 -0
- data/app/assets/images/adva_cms/rails.png +0 -0
- data/app/assets/images/adva_cms/sortable_tree/drag.png +0 -0
- data/app/assets/images/adva_cms/theme_selected.png +0 -0
- data/app/assets/javascripts/admin.js +1 -0
- data/app/assets/javascripts/adva_cms/admin/jquery.admin.js +23 -0
- data/app/assets/javascripts/adva_cms/admin/jquery.article.js +22 -0
- data/app/assets/javascripts/adva_cms/admin/jquery.cached_pages.js +14 -0
- data/app/assets/javascripts/adva_cms/admin/jquery.table_tree.js +7 -0
- data/app/assets/javascripts/adva_cms/application.js +14 -0
- data/app/assets/javascripts/adva_cms/base.js +4 -0
- data/app/assets/javascripts/adva_cms/cookie.js +49 -0
- data/app/assets/javascripts/adva_cms/jquery.common.js +41 -0
- data/app/assets/javascripts/adva_cms/jquery.dates.js +51 -0
- data/app/assets/javascripts/adva_cms/jquery.flash.js +57 -0
- data/app/assets/javascripts/adva_cms/jquery.roles.js +25 -0
- data/app/assets/javascripts/adva_cms/jquery/jquery-lowpro.js +224 -0
- data/app/assets/javascripts/adva_cms/jquery/jquery.qtip.js +2085 -0
- data/app/assets/javascripts/adva_cms/jquery/jquery.table_tree.js +307 -0
- data/app/assets/javascripts/adva_cms/jquery/jquery.tablednd_0_5.js +386 -0
- data/app/assets/javascripts/adva_cms/json.js +139 -0
- data/app/assets/stylesheets/admin.css +1 -0
- data/app/assets/stylesheets/adva_cms/admin.css +16 -0
- data/app/assets/stylesheets/adva_cms/admin/alternate/common.css +76 -0
- data/app/assets/stylesheets/adva_cms/admin/alternate/forms.css +121 -0
- data/app/assets/stylesheets/adva_cms/admin/alternate/header.css +125 -0
- data/app/assets/stylesheets/adva_cms/admin/alternate/layout.css +103 -0
- data/app/assets/stylesheets/adva_cms/admin/alternate/lists.css +153 -0
- data/app/assets/stylesheets/adva_cms/admin/alternate/sidebar.css +65 -0
- data/app/assets/stylesheets/adva_cms/admin/alternate/top.css +123 -0
- data/app/assets/stylesheets/adva_cms/admin/common.css +76 -0
- data/app/assets/stylesheets/adva_cms/admin/content.css +11 -0
- data/app/assets/stylesheets/adva_cms/admin/forms.css +116 -0
- data/app/assets/stylesheets/adva_cms/admin/header.css +114 -0
- data/app/assets/stylesheets/adva_cms/admin/helptip.css +35 -0
- data/app/assets/stylesheets/adva_cms/admin/layout.css +56 -0
- data/app/assets/stylesheets/adva_cms/admin/lists.css +152 -0
- data/app/assets/stylesheets/adva_cms/admin/projection.css +118 -0
- data/app/assets/stylesheets/adva_cms/admin/reset.css +25 -0
- data/app/assets/stylesheets/adva_cms/admin/screen/top.css +8 -0
- data/app/assets/stylesheets/adva_cms/admin/sidebar.css +67 -0
- data/app/assets/stylesheets/adva_cms/admin/themes.css +49 -0
- data/app/assets/stylesheets/adva_cms/admin/top.css +83 -0
- data/app/assets/stylesheets/adva_cms/admin/users.css +40 -0
- data/app/assets/stylesheets/adva_cms/common.css +49 -0
- data/app/assets/stylesheets/adva_cms/default.css +201 -0
- data/app/assets/stylesheets/adva_cms/forms.css +60 -0
- data/app/assets/stylesheets/adva_cms/jquery/alternate/jquery.tooltip.css +13 -0
- data/app/assets/stylesheets/adva_cms/jquery/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/app/assets/stylesheets/adva_cms/jquery/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/app/assets/stylesheets/adva_cms/jquery/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/app/assets/stylesheets/adva_cms/jquery/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/app/assets/stylesheets/adva_cms/jquery/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/app/assets/stylesheets/adva_cms/jquery/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/app/assets/stylesheets/adva_cms/jquery/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/app/assets/stylesheets/adva_cms/jquery/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/app/assets/stylesheets/adva_cms/jquery/images/ui-icons_222222_256x240.png +0 -0
- data/app/assets/stylesheets/adva_cms/jquery/images/ui-icons_2e83ff_256x240.png +0 -0
- data/app/assets/stylesheets/adva_cms/jquery/images/ui-icons_454545_256x240.png +0 -0
- data/app/assets/stylesheets/adva_cms/jquery/images/ui-icons_888888_256x240.png +0 -0
- data/app/assets/stylesheets/adva_cms/jquery/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/app/assets/stylesheets/adva_cms/jquery/jquery-ui.css +406 -0
- data/app/assets/stylesheets/adva_cms/jquery/jquery.tooltip.css +10 -0
- data/app/assets/stylesheets/adva_cms/layout/login.css +8 -0
- data/app/assets/stylesheets/adva_cms/layout/simple.css +8 -0
- data/app/assets/stylesheets/adva_cms/menu.css +129 -0
- data/app/assets/stylesheets/adva_cms/reset.css +25 -0
- data/app/controllers/admin/base_controller.rb +101 -0
- data/app/controllers/admin/categories_controller.rb +3 -0
- data/app/controllers/admin/install_controller.rb +61 -0
- data/app/controllers/admin/page/articles_controller.rb +150 -0
- data/app/controllers/admin/page/categories_controller.rb +62 -0
- data/app/controllers/admin/page/contents_controller.rb +52 -0
- data/app/controllers/admin/page/links_controller.rb +69 -0
- data/app/controllers/admin/pages_controller.rb +2 -0
- data/app/controllers/admin/plugins_controller.rb +40 -0
- data/app/controllers/admin/sections_controller.rb +91 -0
- data/app/controllers/admin/sites_controller.rb +99 -0
- data/app/controllers/articles_controller.rb +81 -0
- data/app/controllers/base_controller.rb +82 -0
- data/app/helpers/admin/base_helper.rb +106 -0
- data/app/helpers/base_helper.rb +56 -0
- data/app/helpers/content_helper.rb +90 -0
- data/app/helpers/resource_helper.rb +127 -0
- data/app/models/article.rb +40 -0
- data/app/models/categorization.rb +4 -0
- data/app/models/category.rb +60 -0
- data/app/models/content.rb +155 -0
- data/app/models/event.rb +34 -0
- data/app/models/link.rb +4 -0
- data/app/models/page.rb +36 -0
- data/app/models/section.rb +126 -0
- data/app/models/site.rb +104 -0
- data/app/views/admin/cached_pages/_filter.html.erb +8 -0
- data/app/views/admin/cached_pages/destroy.js.erb +18 -0
- data/app/views/admin/cached_pages/index.html.erb +26 -0
- data/app/views/admin/install/confirmation.html.erb +10 -0
- data/app/views/admin/install/index.html.erb +38 -0
- data/app/views/admin/page/articles/_form.html.erb +40 -0
- data/app/views/admin/page/articles/_options.html.erb +20 -0
- data/app/views/admin/page/articles/edit.html.erb +15 -0
- data/app/views/admin/page/articles/new.html.erb +12 -0
- data/app/views/admin/page/categories/edit.html.erb +22 -0
- data/app/views/admin/page/categories/index.html.erb +23 -0
- data/app/views/admin/page/categories/new.html.erb +19 -0
- data/app/views/admin/page/contents/index.html.erb +40 -0
- data/app/views/admin/page/links/_form.html.erb +26 -0
- data/app/views/admin/page/links/_options.html.erb +23 -0
- data/app/views/admin/page/links/edit.html.erb +12 -0
- data/app/views/admin/page/links/new.html.erb +12 -0
- data/app/views/admin/plugins/_form.html.erb +11 -0
- data/app/views/admin/plugins/index.html.erb +16 -0
- data/app/views/admin/plugins/show.html.erb +43 -0
- data/app/views/admin/sections/_form.html.haml +20 -0
- data/app/views/admin/sections/edit.html.haml +6 -0
- data/app/views/admin/sections/index.html.erb +27 -0
- data/app/views/admin/sections/new.html.erb +29 -0
- data/app/views/admin/sections/settings/_page.html.haml +10 -0
- data/app/views/admin/shared/_header.html.erb +18 -0
- data/app/views/admin/shared/_language_select.html.erb +6 -0
- data/app/views/admin/shared/_section.html.erb +8 -0
- data/app/views/admin/shared/_section_summary.html.erb +23 -0
- data/app/views/admin/shared/_section_tree.html.erb +23 -0
- data/app/views/admin/sites/_email_notifications.html.erb +9 -0
- data/app/views/admin/sites/_form.html.erb +15 -0
- data/app/views/admin/sites/_recent_users.html.erb +11 -0
- data/app/views/admin/sites/_sections.html.erb +10 -0
- data/app/views/admin/sites/_unapproved_comments.html.erb +10 -0
- data/app/views/admin/sites/edit.html.erb +4 -0
- data/app/views/admin/sites/index.html.erb +21 -0
- data/app/views/admin/sites/multi_sites_disabled.html.erb +11 -0
- data/app/views/admin/sites/new.html.erb +21 -0
- data/app/views/admin/sites/show.html.erb +16 -0
- data/app/views/categories/_checkboxes.html.erb +12 -0
- data/app/views/layouts/admin.html.haml +50 -0
- data/app/views/layouts/default.html.erb +38 -0
- data/app/views/layouts/simple.html.erb +22 -0
- data/app/views/pages/articles/index.html.erb +10 -0
- data/app/views/pages/articles/show.html.erb +17 -0
- data/app/views/shared/_flash.html.erb +3 -0
- data/app/views/shared/_footer.html.erb +4 -0
- data/app/views/shared/_menu.html.erb +10 -0
- data/app/views/shared/_sidebar.html.erb +19 -0
- data/app/views/shared/messages/insufficient_permissions.html.erb +4 -0
- data/config/environment.rb +21 -0
- data/config/initializers/has_options.rb +2 -0
- data/config/initializers/has_permalink.rb +27 -0
- data/config/initializers/mailer.rb +12 -0
- data/config/initializers/menus.rb +184 -0
- data/config/initializers/roles.rb +91 -0
- data/config/initializers/settings.rb +26 -0
- data/config/initializers/site.rb +5 -0
- data/config/initializers/translations_are_a_pain.rb +9 -0
- data/config/locales/en.yml +1295 -0
- data/config/routes.rb +47 -0
- data/db/migrate/20080401000001_create_sites_table.rb +28 -0
- data/db/migrate/20080401000002_create_sections_table.rb +25 -0
- data/db/migrate/20080401000003_create_contents_table.rb +35 -0
- data/db/migrate/20080401000004_create_categories_table.rb +17 -0
- data/db/migrate/20080401000005_create_category_assignments.rb +12 -0
- data/db/migrate/20080401000006_create_taggable_tables.rb +26 -0
- data/db/migrate/20080710000000_create_plugin_configs.rb +13 -0
- data/db/migrate/20080715131051_plugin_owner_column.rb +13 -0
- data/db/migrate/20081208161500_add_content_type_to_join_tables.rb +10 -0
- data/db/migrate/20090216114034_rename_category_assignment_to_categorization.rb +13 -0
- data/db/migrate/20090305123429_move_sections_to_pages.rb +9 -0
- data/db/migrate/20090519132700_add_published_at_to_sections.rb +10 -0
- data/db/migrate/20090702085459_create_section_translations.rb +9 -0
- data/db/migrate/20090702200226_create_category_translations.rb +9 -0
- data/db/migrate/20090707171100_upgrade_paperclip_paths.rb +31 -0
- data/db/migrate/20090709111934_add_email_notification_to_site.rb +12 -0
- data/db/migrate/20091026000906_add_nesting_to_articles.rb +26 -0
- data/db/migrate/20140721000000_add_title_to_contents.rb +7 -0
- data/lib/adva_cms.rb +50 -0
- data/lib/adva_cms/version.rb +3 -0
- data/lib/core_ext.rb +7 -0
- data/lib/extensible_forms.rb +283 -0
- data/lib/has_options.rb +46 -0
- data/lib/html_diff.rb +48 -0
- data/lib/rails_ext.rb +15 -0
- data/lib/rails_ext/action_controller/cacheable_flash.rb +30 -0
- data/lib/rails_ext/action_controller/content_for_assignments.rb +105 -0
- data/lib/rails_ext/action_controller/default_params.rb +19 -0
- data/lib/rails_ext/action_controller/event_helper.rb +18 -0
- data/lib/rails_ext/action_controller/page_caching.rb +23 -0
- data/lib/rails_ext/action_controller/render_with_error_proc.rb +46 -0
- data/lib/rails_ext/action_controller/responds_to_parent.rb +46 -0
- data/lib/rails_ext/action_controller/url_for_returning.rb +12 -0
- data/lib/rails_ext/active_record/exists.rb +5 -0
- data/lib/rails_ext/active_record/sti_instantiation.rb +35 -0
- data/lib/rails_ext/active_record/sticky_changes.rb +30 -0
- data/lib/rails_ext/railties/plugin.rb +58 -0
- data/lib/rails_ext/railties/plugin_configuration.rb +72 -0
- data/lib/rails_ext/railties/plugin_initializers.rb +25 -0
- data/lib/registry.rb +49 -0
- data/lib/tasks/adva_cms.rake +178 -0
- data/lib/tasks/translation.rake +69 -0
- data/lib/time_hacks.rb +57 -0
- data/lib/webrat_patch.rb +11 -0
- data/locale/rails/fr.yml +123 -0
- data/test/NOTES +56 -0
- data/test/contexts.rb +365 -0
- data/test/fixtures.rb +190 -0
- data/test/fixtures/templates/alternative_templates/index.html.erb +1 -0
- data/test/fixtures/templates/context_templates_test/index.html.erb +1 -0
- data/test/fixtures/templates/context_templates_test/show.html.erb +0 -0
- data/test/fixtures/templates/layouts/alternative.html.erb +0 -0
- data/test/fixtures/templates/layouts/default.html.erb +0 -0
- data/test/fixtures/templates/menu/shared/_menu.html.erb +8 -0
- data/test/functional/admin/articles_controller_test.rb +329 -0
- data/test/functional/admin/base_controller_test.rb +68 -0
- data/test/functional/admin/cached_pages_controller_test.rb +66 -0
- data/test/functional/admin/categories_controller_test.rb +164 -0
- data/test/functional/admin/cells_controller_spec.rb +32 -0
- data/test/functional/admin/install_controller_test.rb +89 -0
- data/test/functional/admin/plugins_controller_test.rb +93 -0
- data/test/functional/admin/sections_controller_test.rb +201 -0
- data/test/functional/admin/sites_controller_test.rb +240 -0
- data/test/functional/asset_tag_expansions_test.rb +82 -0
- data/test/functional/base_controller_test.rb +73 -0
- data/test/functional/page_articles_controller_test.rb +168 -0
- data/test/functional/page_articles_routes_test.rb +73 -0
- data/test/integration/admin/cached_pages_test.rb +43 -0
- data/test/integration/admin/categories_test.rb +66 -0
- data/test/integration/admin/custom_templates_test.rb +42 -0
- data/test/integration/admin/filtering_articles_test.rb +32 -0
- data/test/integration/admin/plugins.rb +32 -0
- data/test/integration/admin/section_article_test.rb +150 -0
- data/test/integration/admin/section_test.rb +88 -0
- data/test/integration/admin/sites_test.rb +48 -0
- data/test/integration/installation_test.rb +109 -0
- data/test/integration/page_article_comment_test.rb +51 -0
- data/test/integration/page_article_test.rb +87 -0
- data/test/integration/section_index_test.rb +37 -0
- data/test/javascript/assets/jquery-lowpro.js +224 -0
- data/test/javascript/assets/jquery-ui.js +298 -0
- data/test/javascript/assets/jquery.js +4376 -0
- data/test/javascript/assets/testrunner.js +815 -0
- data/test/javascript/assets/testsuite.css +120 -0
- data/test/javascript/lib/jstest.rb +588 -0
- data/test/javascript/templates/test_case.erb +33 -0
- data/test/plugins/adva_context_templates/context_templates_test.rb +138 -0
- data/test/plugins/adva_post_ping/controller/integration_test.rb +78 -0
- data/test/plugins/adva_post_ping/post_ping_test.rb +94 -0
- data/test/plugins/adva_url_history/article_test.rb +94 -0
- data/test/plugins/adva_url_history/init_url_history.rb +18 -0
- data/test/plugins/adva_url_history/section_test.rb +49 -0
- data/test/test_helper.rb +75 -0
- data/test/test_helper/clear_directories.rb +16 -0
- data/test/test_helper/ensure_single_site_mode.rb +10 -0
- data/test/test_helper/extensions/cacheable_flash.rb +14 -0
- data/test/test_helper/extensions/cronjob.rb +11 -0
- data/test/test_helper/extensions/even_test_log.rb +21 -0
- data/test/test_helper/extensions/integration_test.rb +78 -0
- data/test/test_helper/extensions/matchy.rb +365 -0
- data/test/test_helper/extensions/matchy_adva_cms.rb +441 -0
- data/test/test_helper/extensions/rails_patch.rb +40 -0
- data/test/test_helper/extensions/rr.rb +7 -0
- data/test/test_helper/extensions/test_unit.rb +35 -0
- data/test/test_helper/extensions/with_sugar.rb +166 -0
- data/test/test_helper/parse_options.rb +18 -0
- data/test/test_helper/setup_db_transaction.rb +15 -0
- data/test/test_helper/setup_webrat.rb +9 -0
- data/test/test_helper/test_server/init.rb +15 -0
- data/test/unit/helpers/admin/base_helper_test.rb +139 -0
- data/test/unit/helpers/base_helper_spec.rb +54 -0
- data/test/unit/helpers/base_helper_test.rb +165 -0
- data/test/unit/helpers/content_helper_test.rb +127 -0
- data/test/unit/helpers/resource_helper_test.rb +180 -0
- data/test/unit/i18n_test.rb +22 -0
- data/test/unit/lib/cells_ext_spec.rb +96 -0
- data/test/unit/lib/extensible_forms_test.rb +362 -0
- data/test/unit/lib/menu_test.rb +119 -0
- data/test/unit/lib/rails_ext/content_for_assignments_test.rb +75 -0
- data/test/unit/lib/rails_ext/plugin_configuration_test.rb +40 -0
- data/test/unit/lib/rails_ext/sticky_changes_test.rb +33 -0
- data/test/unit/lib/registry_test.rb +91 -0
- data/test/unit/lib/routing_filter/routing_filter_categories_spec.rb +63 -0
- data/test/unit/lib/routing_filter/routing_filter_categories_test.rb +159 -0
- data/test/unit/lib/routing_filter/routing_filter_locale_spec.rb +73 -0
- data/test/unit/lib/routing_filter/routing_filter_root_blog_archive_spec.rb +40 -0
- data/test/unit/lib/routing_filter/routing_filter_root_section_articles_spec.rb +48 -0
- data/test/unit/lib/routing_filter/routing_filter_root_wikipages_spec.rb +40 -0
- data/test/unit/lib/routing_filter/routing_filter_sections_spec.rb +143 -0
- data/test/unit/lib/routing_filter/routing_filter_sections_test.rb +32 -0
- data/test/unit/lib/routing_filter/routing_filter_sets_test.rb +86 -0
- data/test/unit/models/article_test.rb +191 -0
- data/test/unit/models/category_test.rb +68 -0
- data/test/unit/models/content_test.rb +409 -0
- data/test/unit/models/counter_test.rb +43 -0
- data/test/unit/models/event_test.rb +41 -0
- data/test/unit/models/nested_categories_test.rb +34 -0
- data/test/unit/models/page_test.rb +63 -0
- data/test/unit/models/section_test.rb +315 -0
- data/test/unit/models/site_test.rb +199 -0
- data/test/unit/observers/activities_article_observer_test.rb +42 -0
- data/vendor/gems/belongs_to_cacheable/.gitignore +17 -0
- data/vendor/gems/belongs_to_cacheable/Gemfile +4 -0
- data/vendor/gems/belongs_to_cacheable/LICENSE +22 -0
- data/vendor/gems/belongs_to_cacheable/README.md +29 -0
- data/vendor/gems/belongs_to_cacheable/Rakefile +2 -0
- data/vendor/gems/belongs_to_cacheable/belongs_to_cacheable.gemspec +22 -0
- data/vendor/gems/belongs_to_cacheable/init.rb +1 -0
- data/vendor/gems/belongs_to_cacheable/lib/active_record/belongs_to_cacheable.rb +77 -0
- data/vendor/gems/belongs_to_cacheable/lib/belongs_to_cacheable.rb +3 -0
- data/vendor/gems/belongs_to_cacheable/lib/belongs_to_cacheable/version.rb +3 -0
- data/vendor/gems/belongs_to_cacheable/spec/belongs_to_cacheable_spec.rb +52 -0
- data/vendor/gems/belongs_to_cacheable/spec/spec_helper.rb +50 -0
- data/vendor/gems/filtered_column/.gitignore +17 -0
- data/vendor/gems/filtered_column/Gemfile +4 -0
- data/vendor/gems/filtered_column/LICENSE +22 -0
- data/vendor/gems/filtered_column/README +4 -0
- data/vendor/gems/filtered_column/README.md +29 -0
- data/vendor/gems/filtered_column/Rakefile +23 -0
- data/vendor/gems/filtered_column/filtered_column.gemspec +17 -0
- data/vendor/gems/filtered_column/lib/filtered_column.rb +17 -0
- data/vendor/gems/filtered_column/lib/filtered_column/filters/base.rb +28 -0
- data/vendor/gems/filtered_column/lib/filtered_column/filters/smartypants_filter.rb +14 -0
- data/vendor/gems/filtered_column/lib/filtered_column/filters/textile_filter.rb +13 -0
- data/vendor/gems/filtered_column/lib/filtered_column/macros/base.rb +25 -0
- data/vendor/gems/filtered_column/lib/filtered_column/mixin.rb +46 -0
- data/vendor/gems/filtered_column/lib/filtered_column/processor.rb +52 -0
- data/vendor/gems/filtered_column/lib/filtered_column/version.rb +3 -0
- data/vendor/gems/filtered_column/tasks/filtered_column_tasks.rake +4 -0
- data/vendor/gems/filtered_column/test/abstract_unit.rb +73 -0
- data/vendor/gems/filtered_column/test/filtered_column_test.rb +53 -0
- data/vendor/gems/filtered_column/test/macro_filter_test.rb +23 -0
- data/vendor/gems/has_counter/.gitignore +17 -0
- data/vendor/gems/has_counter/Gemfile +4 -0
- data/vendor/gems/has_counter/LICENSE +22 -0
- data/vendor/gems/has_counter/MIT-LICENSE +20 -0
- data/vendor/gems/has_counter/README.markdown +64 -0
- data/vendor/gems/has_counter/README.md +29 -0
- data/vendor/gems/has_counter/Rakefile +2 -0
- data/vendor/gems/has_counter/db/migrate/20080601194338_create_counters_table.rb.rb +13 -0
- data/vendor/gems/has_counter/has_counter.gemspec +17 -0
- data/vendor/gems/has_counter/lib/active_record/has_counter.rb +64 -0
- data/vendor/gems/has_counter/lib/counter.rb +23 -0
- data/vendor/gems/has_counter/lib/has_counter.rb +4 -0
- data/vendor/gems/has_counter/lib/has_counter/version.rb +3 -0
- data/vendor/gems/has_counter/spec/has_counter.spec.log +0 -0
- data/vendor/gems/has_counter/spec/has_counter.sqlite3.db +0 -0
- data/vendor/gems/has_counter/spec/has_counter_spec.rb +55 -0
- data/vendor/gems/has_counter/spec/spec_helper.rb +117 -0
- data/vendor/gems/has_filter/.gitignore +17 -0
- data/vendor/gems/has_filter/Gemfile +4 -0
- data/vendor/gems/has_filter/LICENSE +22 -0
- data/vendor/gems/has_filter/README.md +29 -0
- data/vendor/gems/has_filter/Rakefile +2 -0
- data/vendor/gems/has_filter/app/assets/images/has_filter/filter_add.png +0 -0
- data/vendor/gems/has_filter/app/assets/images/has_filter/filter_button_left.png +0 -0
- data/vendor/gems/has_filter/app/assets/images/has_filter/filter_button_right.png +0 -0
- data/vendor/gems/has_filter/app/assets/images/has_filter/filter_remove.png +0 -0
- data/vendor/gems/has_filter/app/assets/javascripts/has_filter/filter.js +35 -0
- data/vendor/gems/has_filter/app/assets/javascripts/has_filter/jquery.filter.js +23 -0
- data/vendor/gems/has_filter/app/assets/stylesheets/has_filter/alternate/filter.css +102 -0
- data/vendor/gems/has_filter/app/assets/stylesheets/has_filter/filter.css +100 -0
- data/vendor/gems/has_filter/app/helpers/filter_helper.rb +3 -0
- data/vendor/gems/has_filter/has_filter.gemspec +17 -0
- data/vendor/gems/has_filter/init.rb +3 -0
- data/vendor/gems/has_filter/lib/has_filter.rb +22 -0
- data/vendor/gems/has_filter/lib/has_filter/active_record/act_macro.rb +102 -0
- data/vendor/gems/has_filter/lib/has_filter/filter.rb +17 -0
- data/vendor/gems/has_filter/lib/has_filter/filter/base.rb +67 -0
- data/vendor/gems/has_filter/lib/has_filter/filter/categorized.rb +24 -0
- data/vendor/gems/has_filter/lib/has_filter/filter/chain.rb +45 -0
- data/vendor/gems/has_filter/lib/has_filter/filter/set.rb +80 -0
- data/vendor/gems/has_filter/lib/has_filter/filter/state.rb +25 -0
- data/vendor/gems/has_filter/lib/has_filter/filter/tagged.rb +22 -0
- data/vendor/gems/has_filter/lib/has_filter/filter/text.rb +55 -0
- data/vendor/gems/has_filter/lib/has_filter/version.rb +3 -0
- data/vendor/gems/has_filter/test/db/setup.rb +45 -0
- data/vendor/gems/has_filter/test/db/test.sqlite3.db +0 -0
- data/vendor/gems/has_filter/test/fixtures.rb +15 -0
- data/vendor/gems/has_filter/test/has_filter/filter_chain_test.rb +41 -0
- data/vendor/gems/has_filter/test/has_filter/filter_scopes_test.rb +102 -0
- data/vendor/gems/has_filter/test/has_filter/filter_tags_test.rb +113 -0
- data/vendor/gems/has_filter/test/has_filter/integration.rb +15 -0
- data/vendor/gems/has_filter/test/has_filter/scopes_test.rb +48 -0
- data/vendor/gems/has_filter/test/log/test.log +34346 -0
- data/vendor/gems/has_filter/test/models.rb +23 -0
- data/vendor/gems/has_filter/test/templates/has_filter/test/index.html.erb +5 -0
- data/vendor/gems/has_filter/test/test_helper.rb +66 -0
- data/vendor/gems/simple_taggable/.gitignore +17 -0
- data/vendor/gems/simple_taggable/Gemfile +4 -0
- data/vendor/gems/simple_taggable/LICENSE +22 -0
- data/vendor/gems/simple_taggable/README +24 -0
- data/vendor/gems/simple_taggable/README.md +29 -0
- data/vendor/gems/simple_taggable/Rakefile +2 -0
- data/vendor/gems/simple_taggable/lib/simple_taggable.rb +153 -0
- data/vendor/gems/simple_taggable/lib/simple_taggable/version.rb +3 -0
- data/vendor/gems/simple_taggable/lib/tag.rb +31 -0
- data/vendor/gems/simple_taggable/lib/tag_list.rb +90 -0
- data/vendor/gems/simple_taggable/lib/tagging.rb +8 -0
- data/vendor/gems/simple_taggable/simple_taggable.gemspec +17 -0
- data/vendor/gems/simple_taggable/test/db/schema.rb +41 -0
- data/vendor/gems/simple_taggable/test/db/simple_taggable.sqlite3.db +0 -0
- data/vendor/gems/simple_taggable/test/fixtures/magazine.rb +3 -0
- data/vendor/gems/simple_taggable/test/fixtures/magazines.yml +2 -0
- data/vendor/gems/simple_taggable/test/fixtures/photo.rb +8 -0
- data/vendor/gems/simple_taggable/test/fixtures/photos.yml +19 -0
- data/vendor/gems/simple_taggable/test/fixtures/post.rb +5 -0
- data/vendor/gems/simple_taggable/test/fixtures/posts.yml +27 -0
- data/vendor/gems/simple_taggable/test/fixtures/subscription.rb +4 -0
- data/vendor/gems/simple_taggable/test/fixtures/subscriptions.yml +3 -0
- data/vendor/gems/simple_taggable/test/fixtures/taggings.yml +112 -0
- data/vendor/gems/simple_taggable/test/fixtures/tags.yml +14 -0
- data/vendor/gems/simple_taggable/test/fixtures/user.rb +6 -0
- data/vendor/gems/simple_taggable/test/fixtures/users.yml +5 -0
- data/vendor/gems/simple_taggable/test/log/simple_taggable.log +1614 -0
- data/vendor/gems/simple_taggable/test/simple_taggable_test.rb +226 -0
- data/vendor/gems/simple_taggable/test/tag_list_test.rb +105 -0
- data/vendor/gems/simple_taggable/test/test_helper.rb +80 -0
- data/vendor/gems/table_builder/.gitignore +17 -0
- data/vendor/gems/table_builder/Gemfile +4 -0
- data/vendor/gems/table_builder/LICENSE +22 -0
- data/vendor/gems/table_builder/README.md +29 -0
- data/vendor/gems/table_builder/Rakefile +2 -0
- data/vendor/gems/table_builder/lib/table_builder.rb +27 -0
- data/vendor/gems/table_builder/lib/table_builder/body.rb +28 -0
- data/vendor/gems/table_builder/lib/table_builder/cell.rb +21 -0
- data/vendor/gems/table_builder/lib/table_builder/column.rb +26 -0
- data/vendor/gems/table_builder/lib/table_builder/foot.rb +6 -0
- data/vendor/gems/table_builder/lib/table_builder/head.rb +16 -0
- data/vendor/gems/table_builder/lib/table_builder/row.rb +40 -0
- data/vendor/gems/table_builder/lib/table_builder/rows.rb +26 -0
- data/vendor/gems/table_builder/lib/table_builder/table.rb +75 -0
- data/vendor/gems/table_builder/lib/table_builder/tag.rb +58 -0
- data/vendor/gems/table_builder/lib/table_builder/version.rb +3 -0
- data/vendor/gems/table_builder/table_builder.gemspec +17 -0
- data/vendor/gems/table_builder/test/fixtures/templates/table_all.html.erb +20 -0
- data/vendor/gems/table_builder/test/fixtures/templates/table_auto_body.html.erb +3 -0
- data/vendor/gems/table_builder/test/fixtures/templates/table_auto_columns.html.erb +1 -0
- data/vendor/gems/table_builder/test/fixtures/templates/table_simple.html.erb +7 -0
- data/vendor/gems/table_builder/test/table_builder/table_test.rb +230 -0
- data/vendor/gems/table_builder/test/test_helper.rb +49 -0
- data/vendor/gems/tags/.gitignore +17 -0
- data/vendor/gems/tags/Gemfile +4 -0
- data/vendor/gems/tags/LICENSE +22 -0
- data/vendor/gems/tags/README.md +29 -0
- data/vendor/gems/tags/Rakefile +2 -0
- data/vendor/gems/tags/lib/breadcrumbs.rb +13 -0
- data/vendor/gems/tags/lib/menu.rb +179 -0
- data/vendor/gems/tags/lib/menu/builder.rb +74 -0
- data/vendor/gems/tags/lib/tags.rb +7 -0
- data/vendor/gems/tags/lib/tags/tag.rb +125 -0
- data/vendor/gems/tags/lib/tags/version.rb +3 -0
- data/vendor/gems/tags/tags.gemspec +17 -0
- data/vendor/gems/tags/test/tags/menu_test.rb +173 -0
- data/vendor/gems/tags/test/tags/tag_test.rb +13 -0
- data/vendor/gems/tags/test/test_helper.rb +18 -0
- data/vendor/gems/xss_terminate/.gitignore +17 -0
- data/vendor/gems/xss_terminate/Gemfile +4 -0
- data/vendor/gems/xss_terminate/LICENSE +22 -0
- data/vendor/gems/xss_terminate/MIT-LICENSE +20 -0
- data/vendor/gems/xss_terminate/README +94 -0
- data/vendor/gems/xss_terminate/README.md +29 -0
- data/vendor/gems/xss_terminate/Rakefile +23 -0
- data/vendor/gems/xss_terminate/lib/html5lib_sanitize.rb +2453 -0
- data/vendor/gems/xss_terminate/lib/rails_sanitize.rb +8 -0
- data/vendor/gems/xss_terminate/lib/xss_terminate.rb +141 -0
- data/vendor/gems/xss_terminate/lib/xss_terminate/version.rb +3 -0
- data/vendor/gems/xss_terminate/tasks/xss_terminate_tasks.rake +7 -0
- data/vendor/gems/xss_terminate/test/models/comment.rb +5 -0
- data/vendor/gems/xss_terminate/test/models/entry.rb +7 -0
- data/vendor/gems/xss_terminate/test/models/message.rb +3 -0
- data/vendor/gems/xss_terminate/test/models/person.rb +5 -0
- data/vendor/gems/xss_terminate/test/models/review.rb +5 -0
- data/vendor/gems/xss_terminate/test/schema.rb +34 -0
- data/vendor/gems/xss_terminate/test/setup_test.rb +16 -0
- data/vendor/gems/xss_terminate/test/xss_terminate_test.rb +50 -0
- data/vendor/gems/xss_terminate/xss_terminate.gemspec +17 -0
- metadata +744 -0
@@ -0,0 +1,29 @@
|
|
1
|
+
# TableBuilder
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'table_builder'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install table_builder
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require "table_builder/version"
|
2
|
+
|
3
|
+
require 'action_view/helpers/tag_helper'
|
4
|
+
|
5
|
+
require 'table_builder/tag'
|
6
|
+
require 'table_builder/cell'
|
7
|
+
require 'table_builder/row'
|
8
|
+
require 'table_builder/rows'
|
9
|
+
require 'table_builder/body'
|
10
|
+
require 'table_builder/head'
|
11
|
+
require 'table_builder/foot'
|
12
|
+
require 'table_builder/column'
|
13
|
+
require 'table_builder/table'
|
14
|
+
|
15
|
+
module TableBuilder
|
16
|
+
mattr_accessor :options
|
17
|
+
self.options = {
|
18
|
+
:alternate_rows => true,
|
19
|
+
:i18n_scope => nil
|
20
|
+
}
|
21
|
+
|
22
|
+
def table_for(collection = [], options = {}, &block)
|
23
|
+
Table.new(self, collection, options, &block).render
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
TableBuilder.options[:i18n_scope] = :adva
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module TableBuilder
|
2
|
+
class Body < Rows
|
3
|
+
self.tag_name = :tbody
|
4
|
+
|
5
|
+
include ActionView::RecordIdentifier
|
6
|
+
|
7
|
+
def row(options = {}, &block)
|
8
|
+
table.collection.each_with_index do |record, ix|
|
9
|
+
super(record, options_for_record(record, ix, options))
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
protected
|
14
|
+
|
15
|
+
def build
|
16
|
+
row do |row, record|
|
17
|
+
row.cell *table.columns.map { |column| record.send(column.attribute_name) }
|
18
|
+
end if @rows.empty?
|
19
|
+
end
|
20
|
+
|
21
|
+
def options_for_record(record, ix, options = {})
|
22
|
+
options = options.dup
|
23
|
+
options[:id] = dom_id(record) if record.respond_to?(:new_record?)
|
24
|
+
add_class!(options, 'alternate') if ix % 2 == 1
|
25
|
+
options
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module TableBuilder
|
2
|
+
class Cell < Tag
|
3
|
+
self.level = 3
|
4
|
+
|
5
|
+
attr_reader :content
|
6
|
+
|
7
|
+
def initialize(parent, content = nil, options = {})
|
8
|
+
super(parent, options)
|
9
|
+
@content = content
|
10
|
+
options[:colspan] = table.columns.size if options[:colspan] == :all
|
11
|
+
end
|
12
|
+
|
13
|
+
def render
|
14
|
+
super content.try(:html_safe)
|
15
|
+
end
|
16
|
+
|
17
|
+
def tag_name
|
18
|
+
parent.head? ? :th : :td
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module TableBuilder
|
2
|
+
class Column
|
3
|
+
attr_reader :name, :options
|
4
|
+
|
5
|
+
def initialize(table, name, options = {})
|
6
|
+
@table = table
|
7
|
+
@name = name
|
8
|
+
@value = options.delete(:value)
|
9
|
+
@options = options.dup || {}
|
10
|
+
@options[:class] ||= name
|
11
|
+
end
|
12
|
+
|
13
|
+
def content
|
14
|
+
name.is_a?(Symbol) ? translate(name) : name
|
15
|
+
end
|
16
|
+
|
17
|
+
def translate(content)
|
18
|
+
scope = [TableBuilder.options[:i18n_scope], @table.collection_name, :columns].compact
|
19
|
+
I18n.t(content, :scope => scope)
|
20
|
+
end
|
21
|
+
|
22
|
+
def attribute_name
|
23
|
+
name.to_s.underscore
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module TableBuilder
|
2
|
+
class Head < Rows
|
3
|
+
self.level = 1
|
4
|
+
self.tag_name = :thead
|
5
|
+
|
6
|
+
protected
|
7
|
+
|
8
|
+
def build
|
9
|
+
row = Row.new(self, options)
|
10
|
+
table.columns.each do |column|
|
11
|
+
row.cell(column.content.try(:html_safe), column.options.reverse_merge(:scope => 'col'))
|
12
|
+
end
|
13
|
+
@rows << row
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module TableBuilder
|
2
|
+
class Row < Tag
|
3
|
+
self.level = 2
|
4
|
+
self.tag_name = :tr
|
5
|
+
|
6
|
+
def initialize(parent, record = nil, options = {}, &block)
|
7
|
+
super(parent, options)
|
8
|
+
|
9
|
+
@parent = parent
|
10
|
+
@cells = []
|
11
|
+
@block = block
|
12
|
+
|
13
|
+
yield(*[self, record].compact) if block_given?
|
14
|
+
end
|
15
|
+
|
16
|
+
def cell(*contents)
|
17
|
+
options = contents.last.is_a?(Hash) ? contents.pop : {}
|
18
|
+
add_class!(options, current_column_class) if parent.is_a?(Body)
|
19
|
+
contents.each do |content|
|
20
|
+
@cells << Cell.new(self, content, options)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def render
|
25
|
+
super @cells.map(&:render).join
|
26
|
+
end
|
27
|
+
|
28
|
+
protected
|
29
|
+
|
30
|
+
def alternate(options)
|
31
|
+
options[:class] ||= ''
|
32
|
+
options[:class] = options[:class].split(' ').push('alternate').join(' ')
|
33
|
+
end
|
34
|
+
|
35
|
+
def current_column_class
|
36
|
+
column = table.columns[@cells.size]
|
37
|
+
column && column.options[:class] || ''
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module TableBuilder
|
2
|
+
class Rows < Tag
|
3
|
+
self.level = 1
|
4
|
+
|
5
|
+
attr_reader :rows
|
6
|
+
|
7
|
+
def initialize(parent, options = {})
|
8
|
+
super
|
9
|
+
@rows = []
|
10
|
+
end
|
11
|
+
|
12
|
+
def empty?
|
13
|
+
@rows.empty?
|
14
|
+
end
|
15
|
+
|
16
|
+
def row(*args, &block)
|
17
|
+
options = args.extract_options!
|
18
|
+
@rows << Row.new(self, args.shift, options, &block)
|
19
|
+
end
|
20
|
+
|
21
|
+
def render
|
22
|
+
build if respond_to?(:build)
|
23
|
+
super(@rows.map(&:render).join)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
module TableBuilder
|
2
|
+
class Table < Tag
|
3
|
+
self.level = 0
|
4
|
+
self.tag_name = :table
|
5
|
+
|
6
|
+
attr_reader :body, :head, :foot, :collection, :columns
|
7
|
+
|
8
|
+
def initialize(view = nil, collection = [], options = {})
|
9
|
+
@view = view
|
10
|
+
@collection = collection
|
11
|
+
@columns = []
|
12
|
+
@collection_name = options.delete(:collection_name)
|
13
|
+
|
14
|
+
super(nil, options.reverse_merge(:id => collection_name, :class => "#{collection_name} list"))
|
15
|
+
|
16
|
+
yield(self) if block_given?
|
17
|
+
end
|
18
|
+
|
19
|
+
['head', 'body', 'foot'].each do |name|
|
20
|
+
class_eval <<-code
|
21
|
+
def #{name} # def head
|
22
|
+
@#{name} ||= #{name.classify}.new(self) # @head ||= Head.new(self)
|
23
|
+
end # end
|
24
|
+
code
|
25
|
+
end
|
26
|
+
|
27
|
+
def column(*names)
|
28
|
+
options = names.last.is_a?(Hash) ? names.pop : {}
|
29
|
+
names.each do |name|
|
30
|
+
@columns << Column.new(self, name, options)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def empty(*args, &block)
|
35
|
+
@empty = (args << block).compact
|
36
|
+
end
|
37
|
+
|
38
|
+
def row(*args, &block)
|
39
|
+
body.row(*args, &block)
|
40
|
+
end
|
41
|
+
|
42
|
+
def collection_class
|
43
|
+
# @collection.first.class.base_class
|
44
|
+
@collection.first.class
|
45
|
+
end
|
46
|
+
|
47
|
+
def collection_name
|
48
|
+
@collection_name ||= collection_class.name.tableize.gsub('/', '_').gsub('rails_', '')
|
49
|
+
end
|
50
|
+
|
51
|
+
def render
|
52
|
+
(@collection.empty? && @empty) ? render_empty : begin
|
53
|
+
column(*collection_attribute_names) if @columns.empty?
|
54
|
+
super do |html|
|
55
|
+
html << head.render
|
56
|
+
html << body.render
|
57
|
+
html << foot.render if @foot && !@foot.empty?
|
58
|
+
end.html_safe
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def render_empty
|
63
|
+
@empty.insert(1, @empty.pop.call) if @empty.last.respond_to?(:call)
|
64
|
+
content_tag(*@empty)
|
65
|
+
end
|
66
|
+
|
67
|
+
protected
|
68
|
+
|
69
|
+
def collection_attribute_names
|
70
|
+
record = @collection.first
|
71
|
+
names = record.respond_to?(:attribute_names) ? record.attribute_names : []
|
72
|
+
names.map(&:titleize)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
module TableBuilder
|
2
|
+
class Tag
|
3
|
+
class << self
|
4
|
+
attr_accessor :level, :tag_name
|
5
|
+
end
|
6
|
+
|
7
|
+
def level
|
8
|
+
self.class.level
|
9
|
+
end
|
10
|
+
|
11
|
+
def tag_name
|
12
|
+
self.class.tag_name
|
13
|
+
end
|
14
|
+
|
15
|
+
include ActionView::Helpers::TagHelper
|
16
|
+
|
17
|
+
attr_reader :options, :parent
|
18
|
+
|
19
|
+
def initialize(parent = nil, options = {})
|
20
|
+
@parent = parent
|
21
|
+
@options = options
|
22
|
+
end
|
23
|
+
|
24
|
+
def collection_class
|
25
|
+
table.collection_class
|
26
|
+
end
|
27
|
+
|
28
|
+
def collection_name
|
29
|
+
table.collection_name
|
30
|
+
end
|
31
|
+
|
32
|
+
def table
|
33
|
+
is_a?(Table) ? self : parent.try(:table)
|
34
|
+
end
|
35
|
+
|
36
|
+
def head?
|
37
|
+
is_a?(Head) || !!parent.try(:head?)
|
38
|
+
end
|
39
|
+
|
40
|
+
def render(content = nil)
|
41
|
+
yield(content = '') if content.nil? && block_given?
|
42
|
+
content = content.html_safe
|
43
|
+
content_tag(tag_name, content, options)
|
44
|
+
end
|
45
|
+
|
46
|
+
def add_class(klass)
|
47
|
+
add_class!(options, klass)
|
48
|
+
end
|
49
|
+
|
50
|
+
protected
|
51
|
+
def add_class!(options, klass)
|
52
|
+
unless klass.blank?
|
53
|
+
options[:class] ||= ''
|
54
|
+
options[:class] = options[:class].split(' ').push(klass).join(' ')
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/table_builder/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Micah Geisel"]
|
6
|
+
gem.email = ["micah@botandrose.com"]
|
7
|
+
gem.description = %q{TODO: Write a gem description}
|
8
|
+
gem.summary = %q{TODO: Write a gem summary}
|
9
|
+
gem.homepage = ""
|
10
|
+
|
11
|
+
gem.files = `git ls-files`.split($\)
|
12
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
|
+
gem.name = "table_builder"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = TableBuilder::VERSION
|
17
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<% table_for @articles do |table|
|
2
|
+
table.column :id, :title
|
3
|
+
table.column 'Action', :class => 'action'
|
4
|
+
|
5
|
+
table.head.row do |row|
|
6
|
+
row.cell "total: #{row.table.collection.size}", :colspan => :all, :class => 'total'
|
7
|
+
end
|
8
|
+
|
9
|
+
table.row do |row, record|
|
10
|
+
row.cell record.id, record.title
|
11
|
+
row.cell 'action'
|
12
|
+
end
|
13
|
+
|
14
|
+
table.foot.row do |row|
|
15
|
+
row.cell 'foo'
|
16
|
+
end
|
17
|
+
|
18
|
+
table.empty :p, 'no records!', :class => 'empty'
|
19
|
+
end %>
|
20
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
<% table_for @articles %>
|
@@ -0,0 +1,230 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/../test_helper"
|
2
|
+
|
3
|
+
module TableBuilder
|
4
|
+
class TagTest < Test::Unit::TestCase
|
5
|
+
def test_render
|
6
|
+
tag = Tag.new
|
7
|
+
tag.tag_name = 'foo'
|
8
|
+
html = tag.render { |html| html << 'bar' }
|
9
|
+
assert_html html, 'foo', 'bar'
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
class CellTest < Test::Unit::TestCase
|
14
|
+
def test_render
|
15
|
+
html = Cell.new(Row.new(Table.new), 'foo').render
|
16
|
+
assert_html html, 'td', 'foo'
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_picks_th_when_contained_in_head
|
20
|
+
html = Cell.new(Row.new(Head.new(Table.new)), 'foo').render
|
21
|
+
assert_html html, 'th', 'foo'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
class RowTest < Test::Unit::TestCase
|
26
|
+
include TableTestHelper
|
27
|
+
|
28
|
+
def test_render
|
29
|
+
row = build_body_row
|
30
|
+
row.cell 'foo'
|
31
|
+
assert_html row.render, 'tr td', 'foo'
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
class HeadTest < Test::Unit::TestCase
|
36
|
+
include TableTestHelper
|
37
|
+
|
38
|
+
def test_adds_a_column_headers_row
|
39
|
+
head = build_table.head
|
40
|
+
assert_html head.render, 'thead' do
|
41
|
+
assert_select 'tr th[scope=col]', 'foo'
|
42
|
+
assert_select 'tr th[scope=col]', 'bar'
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_column_html_options
|
47
|
+
head = build_table(build_column('foo', :class => 'foo')).head
|
48
|
+
assert_html head.render, 'th[scope=col]', 'foo'
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_translates_head_cell_content
|
52
|
+
TableBuilder.options[:i18n_scope] = 'foo'
|
53
|
+
head = build_table(build_column(:foo)).head
|
54
|
+
assert_html head.render, 'th', 'translation missing: en, foo, strings, columns, foo'
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_head_with_total_row
|
58
|
+
head = build_table.head
|
59
|
+
head.row { |r| r.cell "foo", :colspan => :all }
|
60
|
+
assert_html head.render, 'thead tr th[colspan=2]', 'foo'
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
class BodyTest < Test::Unit::TestCase
|
65
|
+
include TableTestHelper
|
66
|
+
|
67
|
+
def test_render
|
68
|
+
body = build_table.body
|
69
|
+
body.row { |row, record| row.cell(record) }
|
70
|
+
assert_html body.render, 'tbody' do
|
71
|
+
assert_select 'tr td', 'foo'
|
72
|
+
assert_select 'tr[class=alternate] td', 'bar'
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def test_cell_html_options
|
77
|
+
body = build_table.body
|
78
|
+
body.row { |row, record| row.cell(record, :class => 'baz') }
|
79
|
+
assert_html body.render, 'td[class=baz]', 'foo'
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
class TableTest < Test::Unit::TestCase
|
84
|
+
def test_render_basic
|
85
|
+
table = Table.new %w(a b) do |table|
|
86
|
+
table.column('a'); table.column('b')
|
87
|
+
table.row { |row, record| row.cell(record); row.cell(record) }
|
88
|
+
end
|
89
|
+
assert_html table.render, 'table[id=strings][class=list]' do
|
90
|
+
assert_select 'thead tr th[scope=col]', 'a'
|
91
|
+
assert_select 'tbody tr td', 'a'
|
92
|
+
assert_select 'tbody tr[class=alternate] td', 'b'
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def test_render_calling_column_and_cell_shortcuts
|
97
|
+
table = Table.new %w(a b) do |table|
|
98
|
+
table.column 'a', 'b'
|
99
|
+
table.row { |row, record| row.cell record, record }
|
100
|
+
end
|
101
|
+
assert_html table.render, 'table[id=strings][class=list]' do
|
102
|
+
assert_select 'thead tr th[scope=col]', 'a'
|
103
|
+
assert_select 'tbody tr td', 'a'
|
104
|
+
assert_select 'tbody tr[class=alternate] td', 'b'
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
def test_block_can_access_view_helpers_and_instance_variables
|
109
|
+
@foo = 'foo'
|
110
|
+
table = Table.new %w(a) do |table|
|
111
|
+
table.column 'a'
|
112
|
+
table.row { |row, record, index| row.cell @foo + bar }
|
113
|
+
end
|
114
|
+
html = ''
|
115
|
+
assert_nothing_raised { html = table.render }
|
116
|
+
assert_match %r(foobar), html
|
117
|
+
end
|
118
|
+
|
119
|
+
def test_column_html_class_inherits_to_tbody_cells
|
120
|
+
table = Table.new %w(a) do |table|
|
121
|
+
table.column 'a', :class => 'foo'
|
122
|
+
table.row { |row, record, index| row.cell 'bar' }
|
123
|
+
end
|
124
|
+
assert_html table.render, 'tbody tr td[class=foo]', 'bar'
|
125
|
+
end
|
126
|
+
|
127
|
+
def test_table_collection_name
|
128
|
+
assert_equal 'objects', Table.new([Object.new]).collection_name
|
129
|
+
end
|
130
|
+
|
131
|
+
protected
|
132
|
+
|
133
|
+
def bar
|
134
|
+
'bar'
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
class Record
|
139
|
+
attr_reader :id, :title
|
140
|
+
def initialize(id, title); @id = id; @title = title; end
|
141
|
+
def attribute_names; ['id', 'title']; end
|
142
|
+
end
|
143
|
+
|
144
|
+
class RenderTest < ActionView::TestCase
|
145
|
+
def setup
|
146
|
+
articles = [Record.new(1, 'foo'), Record.new(2, 'bar')]
|
147
|
+
@view = ActionView::Base.new([File.dirname(__FILE__) + '/../fixtures/templates'], { :articles => articles })
|
148
|
+
@view.extend(TableBuilder)
|
149
|
+
TableBuilder.options[:i18n_scope] = :test
|
150
|
+
I18n.backend.send :merge_translations,
|
151
|
+
:en, :test => { :'table_builder_records' => { :columns => { :id => 'ID', :title => 'Title' } } }
|
152
|
+
end
|
153
|
+
|
154
|
+
def test_render_simple
|
155
|
+
html = @view.render(:file => 'table_simple')
|
156
|
+
assert_html html, 'table[id=table_builder_records][class=list]' do
|
157
|
+
assert_select 'thead tr' do
|
158
|
+
assert_select 'th[scope=col]', 'ID'
|
159
|
+
assert_select 'th[scope=col]', 'Title'
|
160
|
+
end
|
161
|
+
assert_select 'tbody' do
|
162
|
+
assert_select 'tr' do
|
163
|
+
assert_select 'td', '1'
|
164
|
+
assert_select 'td', 'foo'
|
165
|
+
end
|
166
|
+
assert_select 'tr[class=alternate]' do
|
167
|
+
assert_select 'td', '2'
|
168
|
+
assert_select 'td', 'bar'
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
def test_render_auto_body
|
175
|
+
assert_equal @view.render(:file => 'table_simple'), @view.render(:file => 'table_auto_body')
|
176
|
+
end
|
177
|
+
|
178
|
+
def test_render_auto_columns
|
179
|
+
html = @view.render(:file => 'table_auto_columns')
|
180
|
+
assert_html html, 'table[id=table_builder_records][class=list]' do
|
181
|
+
assert_select 'thead tr' do
|
182
|
+
assert_select 'th[scope=col]', 'Id'
|
183
|
+
assert_select 'th[scope=col]', 'Title'
|
184
|
+
end
|
185
|
+
assert_select 'tbody' do
|
186
|
+
assert_select 'tr' do
|
187
|
+
assert_select 'td', '1'
|
188
|
+
assert_select 'td', 'foo'
|
189
|
+
end
|
190
|
+
assert_select 'tr[class=alternate]' do
|
191
|
+
assert_select 'td', '2'
|
192
|
+
assert_select 'td', 'bar'
|
193
|
+
end
|
194
|
+
end
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
def test_render_all
|
199
|
+
html = @view.render(:file => 'table_all')
|
200
|
+
assert_html html, 'table[id=table_builder_records][class=list]' do
|
201
|
+
assert_select 'thead tr' do
|
202
|
+
assert_select 'th[colspan=2][class=total]', 'total: 2'
|
203
|
+
end
|
204
|
+
assert_select 'thead tr' do
|
205
|
+
assert_select 'th[scope=col]', 'ID'
|
206
|
+
assert_select 'th[scope=col]', 'Title'
|
207
|
+
assert_select 'th[scope=col][class=action]', 'Action'
|
208
|
+
end
|
209
|
+
assert_select 'tbody' do
|
210
|
+
assert_select 'tr' do
|
211
|
+
assert_select 'td', '1'
|
212
|
+
assert_select 'td', 'foo'
|
213
|
+
end
|
214
|
+
assert_select 'tr[class=alternate]' do
|
215
|
+
assert_select 'td', '2'
|
216
|
+
assert_select 'td', 'bar'
|
217
|
+
end
|
218
|
+
end
|
219
|
+
assert_select 'tfoot tr td', 'foo'
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
def test_render_all_with_empty
|
224
|
+
view = ActionView::Base.new([File.dirname(__FILE__) + '/../fixtures/templates'], { :articles => [] })
|
225
|
+
view.extend(TableBuilder)
|
226
|
+
html = view.render(:file => 'table_all')
|
227
|
+
assert_html html, 'p[class=empty]', 'no records!'
|
228
|
+
end
|
229
|
+
end
|
230
|
+
end
|