typus 0.9.39 → 1.0.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +104 -0
- data/Gemfile +17 -0
- data/Gemfile.lock +96 -0
- data/MIT-LICENSE +1 -1
- data/README.rdoc +45 -0
- data/Rakefile +19 -48
- data/app/controllers/admin/account_controller.rb +54 -0
- data/app/controllers/admin/dashboard_controller.rb +7 -0
- data/app/controllers/admin/resource_controller.rb +8 -0
- data/app/controllers/admin/resources_controller.rb +307 -0
- data/app/controllers/admin/session_controller.rb +38 -0
- data/app/controllers/admin_controller.rb +26 -0
- data/app/helpers/admin/dashboard_helper.rb +38 -0
- data/app/helpers/admin/filters_helper.rb +81 -0
- data/app/helpers/admin/form_helper.rb +68 -261
- data/app/helpers/admin/preview_helper.rb +48 -0
- data/app/helpers/admin/relationships_helper.rb +192 -0
- data/app/helpers/admin/resources_helper.rb +80 -0
- data/app/helpers/admin/search_helper.rb +19 -0
- data/app/helpers/admin/sidebar_helper.rb +32 -210
- data/app/helpers/admin/table_helper.rb +207 -200
- data/app/helpers/admin_helper.rb +56 -0
- data/app/mailers/admin/mailer.rb +13 -0
- data/app/models/admin/fake_user.rb +38 -0
- data/app/views/admin/account/forgot_password.html.erb +21 -0
- data/app/views/admin/account/new.html.erb +21 -0
- data/app/views/admin/dashboard/_sidebar.html.erb +3 -3
- data/app/views/admin/dashboard/show.html.erb +16 -0
- data/app/views/admin/dashboard/styles.html.erb +154 -0
- data/app/views/admin/helpers/_apps.html.erb +6 -0
- data/app/views/admin/helpers/_flash_message.html.erb +3 -0
- data/app/views/admin/helpers/_header.html.erb +7 -0
- data/app/views/admin/helpers/_login_info.html.erb +4 -0
- data/app/views/admin/helpers/_preview.html.erb +13 -0
- data/app/views/admin/helpers/dashboard/_applications.html.erb +32 -0
- data/app/views/admin/helpers/dashboard/_resources.html.erb +16 -0
- data/app/views/admin/helpers/filters/_filters.html.erb +31 -0
- data/app/views/admin/helpers/resources/_display_link_to_previous.html.erb +3 -0
- data/app/views/admin/helpers/resources/_pagination.html.erb +28 -0
- data/app/views/admin/helpers/search/_search.html.erb +12 -0
- data/app/views/admin/helpers/sidebar/_sidebar.html.erb +17 -0
- data/app/views/admin/helpers/table/_table.html.erb +22 -0
- data/app/views/{typus_mailer/reset_password_link.erb → admin/mailer/reset_password_link.text.erb} +2 -2
- data/{test/config/broken/empty.yml → app/views/admin/resources/_edit.html.erb} +0 -0
- data/app/views/admin/resources/_form.html.erb +26 -0
- data/{test/config/broken/empty_roles.yml → app/views/admin/resources/_index.html.erb} +0 -0
- data/{test/config/empty/empty_01.yml → app/views/admin/resources/_new.html.erb} +0 -0
- data/{test/config/empty/empty_01_roles.yml → app/views/admin/resources/_show.html.erb} +0 -0
- data/app/views/admin/resources/edit.html.erb +23 -21
- data/app/views/admin/resources/index.html.erb +31 -18
- data/app/views/admin/resources/new.html.erb +20 -18
- data/app/views/admin/resources/show.html.erb +29 -20
- data/app/views/admin/session/new.html.erb +26 -0
- data/app/views/admin/templates/_belongs_to.html.erb +4 -0
- data/app/views/admin/templates/_boolean.html.erb +4 -8
- data/app/views/admin/templates/_date.html.erb +9 -2
- data/app/views/admin/templates/_datetime.html.erb +9 -2
- data/app/views/admin/templates/_file.html.erb +20 -5
- data/app/views/admin/templates/_has_many.html.erb +24 -0
- data/app/views/admin/templates/_has_n.html.erb +17 -0
- data/{test/config/empty/empty_02.yml → app/views/admin/templates/_has_one.html.erb} +0 -0
- data/app/views/admin/templates/_password.html.erb +4 -2
- data/app/views/admin/templates/_relate_form.html.erb +4 -0
- data/app/views/admin/templates/_selector.html.erb +6 -18
- data/app/views/admin/templates/_string.html.erb +11 -10
- data/app/views/admin/templates/_text.html.erb +9 -2
- data/app/views/admin/templates/_time.html.erb +9 -2
- data/app/views/admin/templates/_tree.html.erb +4 -0
- data/app/views/layouts/admin/session.html.erb +44 -0
- data/app/views/layouts/admin.html.erb +45 -39
- data/config/available_locales/ca.yml +124 -0
- data/config/available_locales/ca_models.yml +16 -0
- data/config/{locales → available_locales}/de.yml +108 -89
- data/config/available_locales/de_models.yml +13 -0
- data/config/available_locales/es.yml +124 -0
- data/config/available_locales/es_models.yml +13 -0
- data/config/available_locales/fr.yml +124 -0
- data/config/available_locales/fr_models.yml +13 -0
- data/config/available_locales/hu.yml +124 -0
- data/config/available_locales/hu_models.yml +13 -0
- data/config/available_locales/it.yml +136 -0
- data/config/available_locales/it_models.yml +15 -0
- data/config/available_locales/language.yml.template +122 -0
- data/config/available_locales/language_models.yml.template +13 -0
- data/config/{locales → available_locales}/pt-BR.yml +97 -74
- data/config/available_locales/pt-BR_models.yml +13 -0
- data/config/{locales → available_locales}/ru.yml +107 -85
- data/config/available_locales/ru_models.yml +13 -0
- data/config/routes.rb +18 -11
- data/lib/generators/templates/config/initializers/typus.rb +26 -0
- data/lib/generators/templates/config/initializers/typus_authentication.rb +18 -0
- data/lib/generators/templates/config/initializers/typus_resources.rb +30 -0
- data/{generators/typus → lib/generators}/templates/config/typus/README +34 -16
- data/lib/generators/templates/config/typus/application.yml +5 -0
- data/lib/generators/templates/config/typus/application_roles.yml +6 -0
- data/lib/generators/templates/config/typus/typus.yml +17 -0
- data/lib/generators/templates/config/typus/typus_roles.yml +6 -0
- data/lib/generators/templates/controller.rb +4 -0
- data/lib/generators/templates/functional_test.rb +21 -0
- data/{generators/typus/templates/db/create_typus_users.rb → lib/generators/templates/migration.rb} +4 -4
- data/lib/generators/templates/model.rb +8 -0
- data/lib/generators/templates/model.yml +10 -0
- data/{generators/typus/templates/public/images/admin → lib/generators/templates/public/admin/images}/ui-icons.png +0 -0
- data/lib/generators/templates/public/admin/javascripts/application.js +6 -0
- data/lib/generators/templates/public/admin/javascripts/jquery-1.4.2.min.js +154 -0
- data/lib/generators/templates/public/admin/javascripts/jquery.rails.js +126 -0
- data/lib/generators/templates/public/admin/javascripts/jquery.searchField.js +91 -0
- data/lib/generators/templates/public/admin/stylesheets/application.css +11 -0
- data/lib/generators/templates/public/admin/stylesheets/screen.css +356 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/blank.gif +0 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/fancy_close.png +0 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/fancy_loading.png +0 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/fancy_nav_left.png +0 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/fancy_nav_right.png +0 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/fancy_shadow_e.png +0 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/fancy_shadow_n.png +0 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/fancy_shadow_ne.png +0 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/fancy_shadow_nw.png +0 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/fancy_shadow_s.png +0 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/fancy_shadow_se.png +0 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/fancy_shadow_sw.png +0 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/fancy_shadow_w.png +0 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/fancy_title_left.png +0 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/fancy_title_main.png +0 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/fancy_title_over.png +0 -0
- data/{generators/typus/templates/public/images/admin → lib/generators/templates/public/admin/vendor}/fancybox/fancy_title_right.png +0 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/fancybox-x.png +0 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/fancybox-y.png +0 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/fancybox.png +0 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/jquery.easing-1.3.pack.js +72 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/jquery.fancybox-1.3.1.css +363 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/jquery.fancybox-1.3.1.js +1077 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/jquery.fancybox-1.3.1.pack.js +44 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/jquery.mousewheel-3.0.2.pack.js +13 -0
- data/lib/generators/templates/view.html.erb +9 -0
- data/lib/generators/typus/migration_generator.rb +85 -0
- data/lib/generators/typus/typus_generator.rb +190 -0
- data/lib/generators/typus/views_generator.rb +27 -0
- data/lib/support/active_record.rb +60 -0
- data/lib/support/array.rb +13 -0
- data/lib/{typus → support}/hash.rb +2 -2
- data/lib/{typus → support}/object.rb +2 -2
- data/lib/support/string.rb +47 -0
- data/lib/tasks/typus.rake +19 -0
- data/lib/typus/authentication.rb +146 -40
- data/lib/typus/configuration.rb +14 -49
- data/lib/typus/engine.rb +6 -0
- data/lib/typus/format.rb +41 -18
- data/lib/typus/orm/active_record.rb +378 -0
- data/lib/typus/resources.rb +57 -0
- data/lib/typus/user.rb +54 -37
- data/lib/typus/version.rb +3 -0
- data/lib/typus.rb +118 -80
- data/lib/vendor/paginator.rb +2 -2
- data/test/factories/assets.rb +5 -0
- data/test/factories/categories.rb +3 -0
- data/test/factories/comments.rb +6 -0
- data/test/factories/pages.rb +5 -0
- data/test/factories/pictures.rb +7 -0
- data/test/factories/posts.rb +6 -0
- data/test/factories/typus_users.rb +8 -0
- data/test/{config → fixtures/config}/broken/application.yml +0 -0
- data/test/{config → fixtures/config}/broken/application_roles.yml +0 -0
- data/test/{config/empty/empty_02_roles.yml → fixtures/config/broken/empty.yml} +0 -0
- data/test/fixtures/config/broken/empty_roles.yml +0 -0
- data/test/{config → fixtures/config}/broken/undefined.yml +0 -0
- data/test/{config → fixtures/config}/broken/undefined_roles.yml +0 -0
- data/test/{config → fixtures/config}/default/typus.yml +2 -1
- data/{generators/typus/templates/config/typus → test/fixtures/config/default}/typus_roles.yml +0 -0
- data/test/fixtures/config/empty/empty_01.yml +0 -0
- data/test/fixtures/config/empty/empty_01_roles.yml +0 -0
- data/test/fixtures/config/empty/empty_02.yml +0 -0
- data/test/fixtures/config/empty/empty_02_roles.yml +0 -0
- data/test/{config → fixtures/config}/locales/es.yml +0 -0
- data/test/fixtures/config/namespaced/application.yml +5 -0
- data/test/fixtures/config/namespaced/application_roles.yml +2 -0
- data/test/{config → fixtures/config}/ordered/001_roles.yml +0 -0
- data/test/{config → fixtures/config}/ordered/002_roles.yml +0 -0
- data/test/{config → fixtures/config}/unordered/app_one_roles.yml +0 -0
- data/test/{config → fixtures/config}/unordered/app_two_roles.yml +0 -0
- data/test/fixtures/config/working/application.yml +73 -0
- data/test/fixtures/config/working/application_roles.yml +24 -0
- data/{generators/typus/templates/config/typus → test/fixtures/config/working}/typus.yml +2 -1
- data/test/{config/default → fixtures/config/working}/typus_roles.yml +0 -0
- data/test/fixtures/rails_app/README +244 -0
- data/test/fixtures/rails_app/Rakefile +7 -0
- data/test/fixtures/rails_app/app/controllers/admin/assets_controller.rb +2 -0
- data/test/fixtures/rails_app/app/controllers/admin/categories_controller.rb +2 -0
- data/test/fixtures/rails_app/app/controllers/admin/comments_controller.rb +2 -0
- data/test/fixtures/rails_app/app/controllers/admin/pages_controller.rb +2 -0
- data/test/fixtures/rails_app/app/controllers/admin/pictures_controller.rb +2 -0
- data/test/fixtures/rails_app/app/controllers/admin/posts_controller.rb +2 -0
- data/test/fixtures/rails_app/app/controllers/admin/status_controller.rb +2 -0
- data/test/fixtures/rails_app/app/controllers/admin/typus_users_controller.rb +2 -0
- data/test/fixtures/rails_app/app/controllers/admin/watch_dog_controller.rb +2 -0
- data/test/fixtures/rails_app/app/controllers/application_controller.rb +4 -0
- data/test/fixtures/rails_app/app/helpers/application_helper.rb +2 -0
- data/test/fixtures/{app → rails_app/app}/models/asset.rb +1 -1
- data/test/fixtures/{app → rails_app/app}/models/category.rb +2 -2
- data/test/fixtures/{app → rails_app/app}/models/comment.rb +1 -1
- data/test/fixtures/{app → rails_app/app}/models/custom_user.rb +1 -1
- data/test/fixtures/{app → rails_app/app}/models/delayed/task.rb +2 -2
- data/test/fixtures/rails_app/app/models/page.rb +9 -0
- data/test/fixtures/rails_app/app/models/picture.rb +6 -0
- data/test/fixtures/{app → rails_app/app}/models/post.rb +6 -6
- data/test/fixtures/rails_app/app/models/typus_user.rb +8 -0
- data/test/fixtures/{app → rails_app/app}/models/view.rb +1 -1
- data/test/fixtures/rails_app/app/views/admin/categories/_form.html.erb +1 -0
- data/test/fixtures/rails_app/app/views/admin/dashboard/_sidebar.html.erb +1 -0
- data/test/fixtures/rails_app/app/views/admin/mailer/reset_password_link.text.erb +6 -0
- data/test/fixtures/rails_app/app/views/admin/posts/_edit.html.erb +1 -0
- data/test/fixtures/rails_app/app/views/admin/posts/_index.html.erb +1 -0
- data/test/fixtures/rails_app/app/views/admin/posts/_new.html.erb +1 -0
- data/test/fixtures/rails_app/app/views/admin/posts/_show.html.erb +1 -0
- data/test/fixtures/rails_app/app/views/admin/posts/_sidebar.html.erb +1 -0
- data/test/fixtures/rails_app/app/views/admin/resources/_sidebar.html.erb +1 -0
- data/test/fixtures/rails_app/app/views/admin/status/index.html.erb +1 -0
- data/test/fixtures/rails_app/app/views/admin/templates/_datepicker.html.erb +1 -0
- data/test/fixtures/rails_app/app/views/layouts/application.html.erb +14 -0
- data/test/fixtures/rails_app/config/application.rb +50 -0
- data/test/fixtures/rails_app/config/boot.rb +13 -0
- data/test/fixtures/rails_app/config/database.yml +22 -0
- data/test/fixtures/rails_app/config/environment.rb +5 -0
- data/test/fixtures/rails_app/config/environments/development.rb +19 -0
- data/test/fixtures/rails_app/config/environments/production.rb +42 -0
- data/test/fixtures/rails_app/config/environments/test.rb +34 -0
- data/test/fixtures/rails_app/config/initializers/acts_as_list.rb +258 -0
- data/test/fixtures/rails_app/config/initializers/acts_as_tree.rb +98 -0
- data/test/fixtures/rails_app/config/initializers/backtrace_silencers.rb +7 -0
- data/test/fixtures/rails_app/config/initializers/inflections.rb +10 -0
- data/test/fixtures/rails_app/config/initializers/mime_types.rb +5 -0
- data/test/fixtures/rails_app/config/initializers/secret_token.rb +7 -0
- data/test/fixtures/rails_app/config/initializers/session_store.rb +8 -0
- data/test/fixtures/rails_app/config/initializers/typus.rb +6 -0
- data/test/fixtures/rails_app/config/locales/en.yml +5 -0
- data/test/fixtures/rails_app/config/routes.rb +8 -0
- data/test/{config/working → fixtures/rails_app/config/typus}/application.yml +11 -9
- data/test/{config/working → fixtures/rails_app/config/typus}/application_roles.yml +0 -0
- data/{generators/typus_update_schema_to_01/templates/config → test/fixtures/rails_app/config/typus}/typus.yml +0 -0
- data/test/{config/working → fixtures/rails_app/config/typus}/typus_roles.yml +0 -0
- data/test/fixtures/rails_app/config.ru +4 -0
- data/test/fixtures/rails_app/db/seeds.rb +7 -0
- data/test/fixtures/rails_app/db/test.sqlite3 +0 -0
- data/test/fixtures/rails_app/log/test.log +4268 -0
- data/test/fixtures/rails_app/public/404.html +26 -0
- data/test/fixtures/rails_app/public/422.html +26 -0
- data/test/fixtures/rails_app/public/500.html +26 -0
- data/test/fixtures/rails_app/public/favicon.ico +0 -0
- data/test/fixtures/rails_app/public/images/rails.png +0 -0
- data/test/fixtures/rails_app/public/index.html +279 -0
- data/test/fixtures/rails_app/public/javascripts/application.js +2 -0
- data/test/fixtures/rails_app/public/javascripts/controls.js +965 -0
- data/test/fixtures/rails_app/public/javascripts/dragdrop.js +974 -0
- data/test/fixtures/rails_app/public/javascripts/effects.js +1123 -0
- data/test/fixtures/rails_app/public/javascripts/prototype.js +4874 -0
- data/test/fixtures/rails_app/public/javascripts/rails.js +118 -0
- data/test/fixtures/rails_app/public/robots.txt +5 -0
- data/test/fixtures/rails_app/script/rails +9 -0
- data/test/fixtures/rails_app/tmp/export-posts-20100902120447.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20100902120700.csv +2 -0
- data/test/functional/admin/account_controller_test.rb +90 -0
- data/test/functional/admin/dashboard_controller_http_basic_test.rb +24 -0
- data/test/functional/admin/dashboard_controller_none_test.rb +18 -0
- data/test/functional/admin/dashboard_controller_test.rb +106 -0
- data/test/functional/admin/resources_controller_assets_relationships.rb +59 -0
- data/test/functional/admin/resources_controller_categories_before_test.rb +10 -0
- data/test/functional/admin/resources_controller_categories_lists_test.rb +44 -0
- data/test/functional/admin/resources_controller_categories_views_test.rb +10 -0
- data/test/functional/admin/resources_controller_comments_toggle_test.rb +21 -0
- data/test/functional/admin/{master_controller_posts_before_test.rb → resources_controller_posts_before_test.rb} +3 -3
- data/test/functional/admin/resources_controller_posts_crud_custom_test.rb +27 -0
- data/test/functional/admin/resources_controller_posts_crud_test.rb +44 -0
- data/test/functional/admin/resources_controller_posts_formats_test.rb +39 -0
- data/test/functional/admin/resources_controller_posts_forms_test.rb +58 -0
- data/test/functional/admin/resources_controller_posts_permissions_test.rb +100 -0
- data/test/functional/admin/{master_controller_posts_relationships_test.rb → resources_controller_posts_relationships_test.rb} +25 -20
- data/test/functional/admin/resources_controller_posts_roles.rb +52 -0
- data/test/functional/admin/resources_controller_posts_views_test.rb +143 -0
- data/test/functional/admin/resources_controller_tableless_resource_test.rb +51 -0
- data/test/functional/admin/resources_controller_typus_users_test.rb +159 -0
- data/test/functional/admin/session_controller_test.rb +85 -0
- data/test/helpers/admin/dashboard_helper_test.rb +42 -0
- data/test/helpers/admin/form_helper_test.rb +52 -276
- data/test/helpers/admin/resources_helper_test.rb +52 -0
- data/test/helpers/admin/sidebar_helper_test.rb +133 -224
- data/test/helpers/admin/table_helper_test.rb +136 -144
- data/test/helpers/admin_helper_test.rb +69 -0
- data/test/lib/support/active_record_test.rb +35 -0
- data/test/lib/support/array_test.rb +15 -0
- data/test/lib/support/hash_test.rb +11 -0
- data/test/lib/support/string_test.rb +48 -0
- data/test/lib/typus/active_record_test.rb +385 -0
- data/test/lib/typus/configuration_test.rb +52 -0
- data/test/lib/typus/resource_test.rb +17 -0
- data/test/lib/typus/routes_test.rb +29 -0
- data/test/lib/typus_test.rb +72 -40
- data/test/{vendor → lib/vendor}/paginator_test.rb +7 -4
- data/test/schema.rb +28 -3
- data/test/test_helper.rb +29 -0
- data/test/unit/admin/mailer_test.rb +32 -0
- data/test/unit/typus_user_roles_test.rb +69 -61
- data/test/unit/typus_user_test.rb +56 -143
- data/typus.gemspec +18 -276
- metadata +305 -231
- data/.gitignore +0 -1
- data/AUTHORS.md +0 -34
- data/CHANGES +0 -3
- data/README.md +0 -75
- data/VERSION +0 -1
- data/app/controllers/admin/master_controller.rb +0 -394
- data/app/controllers/typus_controller.rb +0 -152
- data/app/helpers/admin/master_helper.rb +0 -104
- data/app/helpers/admin/public_helper.rb +0 -27
- data/app/helpers/typus_helper.rb +0 -181
- data/app/models/typus_mailer.rb +0 -14
- data/app/models/typus_user.rb +0 -5
- data/app/views/admin/shared/_feedback.html.erb +0 -6
- data/app/views/admin/shared/_footer.html.erb +0 -2
- data/app/views/admin/shared/_pagination.html.erb +0 -28
- data/app/views/admin/templates/_tiny_mce.html.erb +0 -2
- data/app/views/layouts/typus.html.erb +0 -29
- data/app/views/typus/dashboard.html.erb +0 -9
- data/app/views/typus/recover_password.html.erb +0 -7
- data/app/views/typus/reset_password.html.erb +0 -15
- data/app/views/typus/sign_in.html.erb +0 -9
- data/app/views/typus/sign_up.html.erb +0 -7
- data/config/locales/es.yml +0 -105
- data/config/locales/fr.yml +0 -98
- data/config/locales/language.yml.template +0 -106
- data/generators/typus/templates/auto/index.html.erb +0 -11
- data/generators/typus/templates/auto/resource_controller.rb.erb +0 -15
- data/generators/typus/templates/auto/resource_controller_test.rb.erb +0 -11
- data/generators/typus/templates/auto/resources_controller.rb.erb +0 -37
- data/generators/typus/templates/config/initializers/typus.rb +0 -34
- data/generators/typus/templates/config/typus/application.yml +0 -6
- data/generators/typus/templates/config/typus/application_roles.yml +0 -23
- data/generators/typus/templates/lib/tasks/typus_tasks.rake +0 -32
- data/generators/typus/templates/public/images/admin/fancybox/fancy_closebox.png +0 -0
- data/generators/typus/templates/public/images/admin/fancybox/fancy_left.png +0 -0
- data/generators/typus/templates/public/images/admin/fancybox/fancy_progress.png +0 -0
- data/generators/typus/templates/public/images/admin/fancybox/fancy_right.png +0 -0
- data/generators/typus/templates/public/images/admin/fancybox/fancy_shadow_e.png +0 -0
- data/generators/typus/templates/public/images/admin/fancybox/fancy_shadow_n.png +0 -0
- data/generators/typus/templates/public/images/admin/fancybox/fancy_shadow_ne.png +0 -0
- data/generators/typus/templates/public/images/admin/fancybox/fancy_shadow_nw.png +0 -0
- data/generators/typus/templates/public/images/admin/fancybox/fancy_shadow_s.png +0 -0
- data/generators/typus/templates/public/images/admin/fancybox/fancy_shadow_se.png +0 -0
- data/generators/typus/templates/public/images/admin/fancybox/fancy_shadow_sw.png +0 -0
- data/generators/typus/templates/public/images/admin/fancybox/fancy_shadow_w.png +0 -0
- data/generators/typus/templates/public/images/admin/fancybox/fancy_title_left.png +0 -0
- data/generators/typus/templates/public/images/admin/fancybox/fancy_title_main.png +0 -0
- data/generators/typus/templates/public/javascripts/admin/application.js +0 -14
- data/generators/typus/templates/public/javascripts/admin/jquery-1.3.2.min.js +0 -19
- data/generators/typus/templates/public/javascripts/admin/jquery.fancybox-1.2.1.min.js +0 -9
- data/generators/typus/templates/public/stylesheets/admin/jquery.fancybox.css +0 -315
- data/generators/typus/templates/public/stylesheets/admin/reset.css +0 -68
- data/generators/typus/templates/public/stylesheets/admin/screen.css +0 -361
- data/generators/typus/typus_generator.rb +0 -191
- data/generators/typus_update_schema_to_01/templates/migration.rb +0 -11
- data/generators/typus_update_schema_to_01/typus_update_schema_to_01_generator.rb +0 -19
- data/generators/typus_update_schema_to_02/templates/migration.rb +0 -11
- data/generators/typus_update_schema_to_02/typus_update_schema_to_02_generator.rb +0 -11
- data/lib/typus/active_record.rb +0 -323
- data/lib/typus/extensions/routes.rb +0 -15
- data/lib/typus/extensions/routes_hack.rb +0 -15
- data/lib/typus/preferences.rb +0 -11
- data/lib/typus/preview.rb +0 -76
- data/lib/typus/quick_edit.rb +0 -40
- data/lib/typus/reloader.rb +0 -14
- data/lib/typus/string.rb +0 -27
- data/lib/vendor/active_record.rb +0 -15
- data/lib/vendor/rss_parser.rb +0 -20
- data/rails/init.rb +0 -3
- data/tasks/typus_tasks.rake +0 -32
- data/test/config/working/typus.yml +0 -12
- data/test/fixtures/app/controllers/admin/assets_controller.rb +0 -2
- data/test/fixtures/app/controllers/admin/categories_controller.rb +0 -2
- data/test/fixtures/app/controllers/admin/comments_controller.rb +0 -2
- data/test/fixtures/app/controllers/admin/pages_controller.rb +0 -2
- data/test/fixtures/app/controllers/admin/posts_controller.rb +0 -2
- data/test/fixtures/app/controllers/admin/status_controller.rb +0 -6
- data/test/fixtures/app/controllers/admin/typus_users_controller.rb +0 -2
- data/test/fixtures/app/controllers/admin/watch_dog_controller.rb +0 -6
- data/test/fixtures/app/models/page.rb +0 -5
- data/test/fixtures/app/views/admin/dashboard/_content.html.erb +0 -1
- data/test/fixtures/app/views/admin/dashboard/_sidebar.html.erb +0 -1
- data/test/fixtures/app/views/admin/posts/_edit.html.erb +0 -1
- data/test/fixtures/app/views/admin/posts/_index.html.erb +0 -1
- data/test/fixtures/app/views/admin/posts/_new.html.erb +0 -1
- data/test/fixtures/app/views/admin/posts/_show.html.erb +0 -1
- data/test/fixtures/app/views/admin/posts/_sidebar.html.erb +0 -1
- data/test/fixtures/app/views/admin/resources/_sidebar.html.erb +0 -1
- data/test/fixtures/app/views/admin/shared/_footer.html.erb +0 -1
- data/test/fixtures/app/views/admin/status/index.html.erb +0 -1
- data/test/fixtures/app/views/admin/templates/_datepicker.html.erb +0 -1
- data/test/fixtures/assets.yml +0 -11
- data/test/fixtures/categories.yml +0 -14
- data/test/fixtures/comments.yml +0 -27
- data/test/fixtures/pages.yml +0 -41
- data/test/fixtures/posts.yml +0 -37
- data/test/fixtures/typus_users.yml +0 -59
- data/test/functional/admin/master_controller_assets_relationships.rb +0 -66
- data/test/functional/admin/master_controller_categories_lists_test.rb +0 -64
- data/test/functional/admin/master_controller_posts_crud_test.rb +0 -97
- data/test/functional/admin/master_controller_posts_formats_test.rb +0 -53
- data/test/functional/admin/master_controller_posts_permissions_test.rb +0 -127
- data/test/functional/admin/master_controller_posts_roles.rb +0 -50
- data/test/functional/admin/master_controller_posts_toggle_test.rb +0 -35
- data/test/functional/admin/master_controller_posts_views_test.rb +0 -209
- data/test/functional/admin/master_controller_tableless_resource_test.rb +0 -36
- data/test/functional/admin/master_controller_typus_users_test.rb +0 -211
- data/test/functional/typus_controller_test.rb +0 -342
- data/test/helper.rb +0 -51
- data/test/helpers/admin/master_helper_test.rb +0 -70
- data/test/helpers/admin/public_helper_test.rb +0 -26
- data/test/helpers/typus_helper_test.rb +0 -96
- data/test/lib/active_record_test.rb +0 -377
- data/test/lib/configuration_test.rb +0 -95
- data/test/lib/hash_test.rb +0 -11
- data/test/lib/routes_test.rb +0 -71
- data/test/lib/string_test.rb +0 -55
- data/test/unit/typus_mailer_test.rb +0 -29
- data/test/unit/typus_test.rb +0 -17
- data/test/vendor/active_record_test.rb +0 -18
data/AUTHORS.md
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
Typus was designed & developed by Francesc Esplugas (fesplugas).
|
2
|
-
|
3
|
-
Special thanks to the following individuals:
|
4
|
-
|
5
|
-
* [Laia Gargallo](http://azotacalles.net): Lover & tea provider.
|
6
|
-
* [Isaac Feliu](http://www.vesne.com): Code review on first public release.
|
7
|
-
* [Lluis Folch](http://wet-floor.com): Feedback.
|
8
|
-
* [Sergio Espeja](http://github.com/spejman): Code.
|
9
|
-
* [Eadz](http://github.com/eadz): Code.
|
10
|
-
* [Anthony Underwood](http://github.com/aunderwo): Code.
|
11
|
-
* [Felipe Talavera](http://github.com/flype): Spanish translation & code.
|
12
|
-
* [Erik Tigerholm](http://github.com/eriktigerholm): Code.
|
13
|
-
* [George Guimarães](http://github.com/georgeguimaraes): Portuguese translation & code)
|
14
|
-
* [José Valim](http://github.com/josevalim): Code.
|
15
|
-
* [Luqman Amjad](http://github.com/luqman): Code.
|
16
|
-
* [Alexey Noskov](http://github.com/alno) Russian translation & code.
|
17
|
-
* [Andres Gutierres](http://github.com/andresgutgon): Bugfixes & feedback.
|
18
|
-
* [Komzák Nándor](http://github.com/rubymood): Code, bugfixes & feedback.
|
19
|
-
* [Michael Grunewalder](http://michael.grunewalder.com) : German translation.
|
20
|
-
* [Tim Harvey](http://www.timharvey.net): Code.
|
21
|
-
* [Ned Baldessin](http://github.com/nedbaldessin) : French translation & code.
|
22
|
-
* Robert Rouse: Ruby 1.9 compatibility fixes.
|
23
|
-
* [Rytis Lukoseviciu](http://rytis.net): Code.
|
24
|
-
* [WesEd Interactive](http://www.wested.org/): Code.
|
25
|
-
|
26
|
-
Somehow involved in the project
|
27
|
-
|
28
|
-
* [Yukihiro "matz" Matsumoto](http://www.rubyist.net/~matz/) creator of
|
29
|
-
[Ruby](http://ruby-lang.org/) the most beautiful programming language I've ever seen.
|
30
|
-
* [David Heinemeier Hansson](http://loudthinking.com/) for creating
|
31
|
-
[Ruby on Rails](http://rubyonrails.org/).
|
32
|
-
* [Django Admin](http://www.djangoproject.com) who inspired part of the
|
33
|
-
development, in special the templates rendering & UI.
|
34
|
-
* [Paginator](http://github.com/bruce/paginator) by [Bruce Williams](http://codefluency.com).
|
data/CHANGES
DELETED
data/README.md
DELETED
@@ -1,75 +0,0 @@
|
|
1
|
-
# Typus: Admin interface for Rails applications
|
2
|
-
|
3
|
-
**Typus** is designed for a single activity:
|
4
|
-
|
5
|
-
Trusted users editing structured content.
|
6
|
-
|
7
|
-
**Typus** doesn't try to be all the things to all the people but it's
|
8
|
-
extensible enough to match lots of use cases.
|
9
|
-
|
10
|
-
## Key Features
|
11
|
-
|
12
|
-
- Access control by users and roles.
|
13
|
-
- CRUD and custom actions for your models on a clean interface.
|
14
|
-
- Internationalized.
|
15
|
-
- Extensible and overwritable templates.
|
16
|
-
- Low memory footprint.
|
17
|
-
- Released under the MIT License.
|
18
|
-
|
19
|
-
## Links
|
20
|
-
|
21
|
-
- [Project site and documentation](http://intraducibles.com/projects/typus)
|
22
|
-
- [Plugin source](http://github.com/fesplugas/typus)
|
23
|
-
- [Mailing list](http://groups.google.com/group/typus)
|
24
|
-
- [Bug reports](http://github.com/fesplugas/typus/issues)
|
25
|
-
- [Gems](http://gemcutter.org/gems/typus)
|
26
|
-
|
27
|
-
## Impatients to see it working?
|
28
|
-
|
29
|
-
**Step 1:** Create a Rails application using a template.
|
30
|
-
|
31
|
-
$ rails example.com -m http://tr.im/typus_example
|
32
|
-
|
33
|
-
**Step 2:** Start the server.
|
34
|
-
|
35
|
-
$ cd example.com && script/server
|
36
|
-
|
37
|
-
**Step 3:** Go to the admin area (<http://0.0.0.0:3000/admin>) and enjoy it!
|
38
|
-
|
39
|
-
|
40
|
-
## Want to see a demo working?
|
41
|
-
|
42
|
-
Demo application is hosted at Heroku (<http://typus.heroku.com/>).
|
43
|
-
|
44
|
-
Use the following credentials to log in.
|
45
|
-
|
46
|
-
Email: userdemo@intraducibles.com
|
47
|
-
Password: userdemo
|
48
|
-
|
49
|
-
## Installing
|
50
|
-
|
51
|
-
Install from GitHub the latest version which it's compatible with Rails 2.3.4.
|
52
|
-
|
53
|
-
$ script/plugin install git://github.com/fesplugas/typus.git
|
54
|
-
|
55
|
-
Once `typus` is installed, run the generator to create required files and migrate your
|
56
|
-
database. (<tt>typus_users</tt> table is created)
|
57
|
-
|
58
|
-
$ script/generate typus
|
59
|
-
$ rake db:migrate
|
60
|
-
|
61
|
-
To create the first user, start the application server, go to
|
62
|
-
http://0.0.0.0:3000/admin and follow the instructions.
|
63
|
-
|
64
|
-
## Support
|
65
|
-
|
66
|
-
As an experiment we encourage you to support this project by
|
67
|
-
[donating][1] 90 € if you are a developer or studio. Donations do
|
68
|
-
allow us to spend more time working and supporting the project.
|
69
|
-
|
70
|
-
## License
|
71
|
-
|
72
|
-
Copyright © 2007-2009 Francesc Esplugas Marti, released under the
|
73
|
-
MIT license
|
74
|
-
|
75
|
-
[1]:http://intraducibles.com/projects/typus/donate
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.9.39
|
@@ -1,394 +0,0 @@
|
|
1
|
-
class Admin::MasterController < ApplicationController
|
2
|
-
|
3
|
-
skip_filter filter_chain
|
4
|
-
|
5
|
-
unloadable
|
6
|
-
|
7
|
-
layout 'admin'
|
8
|
-
|
9
|
-
include Typus::Authentication
|
10
|
-
include Typus::Format
|
11
|
-
include Typus::Preferences
|
12
|
-
include Typus::Reloader
|
13
|
-
|
14
|
-
if Typus::Configuration.options[:ssl]
|
15
|
-
include SslRequirement
|
16
|
-
ssl_required :index, :new, :create, :edit, :show, :update, :destroy, :toggle, :position, :relate, :unrelate
|
17
|
-
end
|
18
|
-
|
19
|
-
filter_parameter_logging :password
|
20
|
-
|
21
|
-
before_filter :reload_config_et_roles
|
22
|
-
|
23
|
-
before_filter :require_login
|
24
|
-
|
25
|
-
before_filter :set_typus_preferences
|
26
|
-
|
27
|
-
before_filter :set_resource
|
28
|
-
before_filter :find_item,
|
29
|
-
:only => [ :show, :edit, :update, :destroy, :toggle, :position, :relate, :unrelate ]
|
30
|
-
|
31
|
-
before_filter :check_ownership_of_item,
|
32
|
-
:only => [ :edit, :update, :destroy, :toggle, :position, :relate, :unrelate ]
|
33
|
-
|
34
|
-
before_filter :check_if_user_can_perform_action_on_user,
|
35
|
-
:only => [ :edit, :update, :toggle, :destroy ]
|
36
|
-
before_filter :check_if_user_can_perform_action_on_resource
|
37
|
-
|
38
|
-
before_filter :set_order,
|
39
|
-
:only => [ :index ]
|
40
|
-
before_filter :set_fields,
|
41
|
-
:only => [ :index, :new, :edit, :create, :update, :show ]
|
42
|
-
|
43
|
-
before_filter :set_tiny_mce,
|
44
|
-
:only => [ :new, :edit, :create, :update ]
|
45
|
-
|
46
|
-
##
|
47
|
-
# This is the main index of the model. With filters, conditions
|
48
|
-
# and more.
|
49
|
-
#
|
50
|
-
# By default application can respond_to html, csv and xml, but you
|
51
|
-
# can add your formats.
|
52
|
-
#
|
53
|
-
def index
|
54
|
-
|
55
|
-
@conditions, @joins = @resource[:class].build_conditions(params)
|
56
|
-
|
57
|
-
check_ownership_of_items if @resource[:class].typus_options_for(:only_user_items)
|
58
|
-
|
59
|
-
respond_to do |format|
|
60
|
-
format.html { generate_html }
|
61
|
-
@resource[:class].typus_export_formats.each do |f|
|
62
|
-
format.send(f) { send("generate_#{f}") }
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
rescue Exception => error
|
67
|
-
error_handler(error)
|
68
|
-
end
|
69
|
-
|
70
|
-
def new
|
71
|
-
|
72
|
-
check_ownership_of_referal_item
|
73
|
-
|
74
|
-
item_params = params.dup
|
75
|
-
%w( controller action resource resource_id back_to selected ).each do |param|
|
76
|
-
item_params.delete(param)
|
77
|
-
end
|
78
|
-
|
79
|
-
@item = @resource[:class].new(item_params.symbolize_keys)
|
80
|
-
|
81
|
-
select_template :new
|
82
|
-
|
83
|
-
end
|
84
|
-
|
85
|
-
##
|
86
|
-
# Create new items. There's an special case when we create an
|
87
|
-
# item from another item. In this case, after the item is
|
88
|
-
# created we also create the relationship between these items.
|
89
|
-
#
|
90
|
-
def create
|
91
|
-
|
92
|
-
@item = @resource[:class].new(params[:item])
|
93
|
-
|
94
|
-
if @resource[:class].typus_user_id?
|
95
|
-
@item.attributes = { Typus.user_fk => @current_user.id }
|
96
|
-
end
|
97
|
-
|
98
|
-
if @item.valid?
|
99
|
-
create_with_back_to and return if params[:back_to]
|
100
|
-
@item.save
|
101
|
-
flash[:success] = _("{{model}} successfully created.", :model => @resource[:human_name])
|
102
|
-
if @resource[:class].typus_options_for(:index_after_save)
|
103
|
-
redirect_to :action => 'index'
|
104
|
-
else
|
105
|
-
redirect_to :action => @resource[:class].typus_options_for(:default_action_on_item), :id => @item.id
|
106
|
-
end
|
107
|
-
else
|
108
|
-
select_template :new
|
109
|
-
end
|
110
|
-
|
111
|
-
end
|
112
|
-
|
113
|
-
def edit
|
114
|
-
|
115
|
-
item_params = params.dup
|
116
|
-
%w( action controller model model_id back_to id resource resource_id page ).each { |p| item_params.delete(p) }
|
117
|
-
|
118
|
-
# We assign the params passed trough the url
|
119
|
-
@item.attributes = item_params
|
120
|
-
|
121
|
-
item_params.merge!(set_conditions)
|
122
|
-
@previous, @next = @item.previous_and_next(item_params)
|
123
|
-
|
124
|
-
select_template :edit
|
125
|
-
|
126
|
-
end
|
127
|
-
|
128
|
-
def show
|
129
|
-
|
130
|
-
check_ownership_of_item and return if @resource[:class].typus_options_for(:only_user_items)
|
131
|
-
|
132
|
-
@previous, @next = @item.previous_and_next(set_conditions)
|
133
|
-
|
134
|
-
respond_to do |format|
|
135
|
-
format.html { select_template :show }
|
136
|
-
format.xml do
|
137
|
-
fields = @resource[:class].typus_fields_for(:xml).collect { |i| i.first }
|
138
|
-
render :xml => @item.to_xml(:only => fields)
|
139
|
-
end
|
140
|
-
end
|
141
|
-
|
142
|
-
end
|
143
|
-
|
144
|
-
def update
|
145
|
-
|
146
|
-
if @item.update_attributes(params[:item])
|
147
|
-
|
148
|
-
if @resource[:class].typus_user_id? && !@current_user.is_root?
|
149
|
-
@item.update_attributes Typus.user_fk => @current_user.id
|
150
|
-
end
|
151
|
-
|
152
|
-
flash[:success] = _("{{model}} successfully updated.", :model => @resource[:human_name])
|
153
|
-
path = if @resource[:class].typus_options_for(:index_after_save)
|
154
|
-
params[:back_to] ? "#{params[:back_to]}##{@resource[:self]}" : { :action => 'index' }
|
155
|
-
else
|
156
|
-
{ :action => @resource[:class].typus_options_for(:default_action_on_item), :id => @item.id, :back_to => params[:back_to] }
|
157
|
-
end
|
158
|
-
redirect_to path
|
159
|
-
|
160
|
-
else
|
161
|
-
|
162
|
-
@previous, @next = @item.previous_and_next
|
163
|
-
select_template :edit
|
164
|
-
|
165
|
-
end
|
166
|
-
|
167
|
-
end
|
168
|
-
|
169
|
-
def destroy
|
170
|
-
@item.destroy
|
171
|
-
flash[:success] = _("{{model}} successfully removed.", :model => @resource[:human_name])
|
172
|
-
redirect_to request.referer || admin_dashboard_path
|
173
|
-
rescue Exception => error
|
174
|
-
error_handler(error, params.merge(:action => 'index', :id => nil))
|
175
|
-
end
|
176
|
-
|
177
|
-
def toggle
|
178
|
-
if @resource[:class].typus_options_for(:toggle)
|
179
|
-
@item.toggle!(params[:field])
|
180
|
-
flash[:success] = _("{{model}} {{attribute}} changed.",
|
181
|
-
:model => @resource[:human_name],
|
182
|
-
:attribute => params[:field].humanize.downcase)
|
183
|
-
else
|
184
|
-
flash[:notice] = _("Toggle is disabled.")
|
185
|
-
end
|
186
|
-
redirect_to request.referer || admin_dashboard_path
|
187
|
-
end
|
188
|
-
|
189
|
-
##
|
190
|
-
# Change item position. This only works if acts_as_list is
|
191
|
-
# installed. We can then move items:
|
192
|
-
#
|
193
|
-
# params[:go] = 'move_to_top'
|
194
|
-
#
|
195
|
-
# Available positions are move_to_top, move_higher, move_lower,
|
196
|
-
# move_to_bottom.
|
197
|
-
#
|
198
|
-
def position
|
199
|
-
@item.send(params[:go])
|
200
|
-
flash[:success] = _("Record moved {{to}}.", :to => params[:go].gsub(/move_/, '').humanize.downcase)
|
201
|
-
redirect_to request.referer || admin_dashboard_path
|
202
|
-
end
|
203
|
-
|
204
|
-
##
|
205
|
-
# Relate a model object to another, this action is used only by the
|
206
|
-
# has_and_belongs_to_many and has_many relationships.
|
207
|
-
#
|
208
|
-
def relate
|
209
|
-
|
210
|
-
resource_class = params[:related][:model].constantize
|
211
|
-
resource_tableized = params[:related][:model].tableize
|
212
|
-
|
213
|
-
@item.send(resource_tableized) << resource_class.find(params[:related][:id])
|
214
|
-
|
215
|
-
flash[:success] = _("{{model_a}} related to {{model_b}}.",
|
216
|
-
:model_a => resource_class.typus_human_name,
|
217
|
-
:model_b => @resource[:human_name])
|
218
|
-
|
219
|
-
redirect_to :back
|
220
|
-
|
221
|
-
end
|
222
|
-
|
223
|
-
##
|
224
|
-
# Remove relationship between models, this action never removes items!
|
225
|
-
#
|
226
|
-
def unrelate
|
227
|
-
|
228
|
-
resource_class = params[:resource].classify.constantize
|
229
|
-
resource = resource_class.find(params[:resource_id])
|
230
|
-
|
231
|
-
if @resource[:class].
|
232
|
-
reflect_on_association(resource_class.table_name.singularize.to_sym).
|
233
|
-
try(:macro) == :has_one
|
234
|
-
attribute = resource_class.table_name.singularize
|
235
|
-
@item.update_attribute attribute, nil
|
236
|
-
else
|
237
|
-
attribute = resource_class.table_name
|
238
|
-
@item.send(attribute).delete(resource)
|
239
|
-
end
|
240
|
-
|
241
|
-
flash[:success] = _("{{model_a}} unrelated from {{model_b}}.",
|
242
|
-
:model_a => resource_class.typus_human_name,
|
243
|
-
:model_b => @resource[:human_name])
|
244
|
-
|
245
|
-
redirect_to :back
|
246
|
-
|
247
|
-
end
|
248
|
-
|
249
|
-
private
|
250
|
-
|
251
|
-
def set_resource
|
252
|
-
@resource = { :self => params[:controller].extract_resource,
|
253
|
-
:human_name => params[:controller].extract_human_name,
|
254
|
-
:class => params[:controller].extract_class }
|
255
|
-
rescue Exception => error
|
256
|
-
error_handler(error)
|
257
|
-
end
|
258
|
-
|
259
|
-
##
|
260
|
-
# Find model when performing an edit, update, destroy, relate,
|
261
|
-
# unrelate ...
|
262
|
-
#
|
263
|
-
def find_item
|
264
|
-
@item = @resource[:class].find(params[:id])
|
265
|
-
end
|
266
|
-
|
267
|
-
##
|
268
|
-
# If item is owned by another user, we only can perform a
|
269
|
-
# show action on the item. Updated item is also blocked.
|
270
|
-
#
|
271
|
-
# before_filter :check_ownership_of_item, :only => [ :edit, :update, :destroy,
|
272
|
-
# :toggle, :position,
|
273
|
-
# :relate, :unrelate ]
|
274
|
-
#
|
275
|
-
def check_ownership_of_item
|
276
|
-
|
277
|
-
# By-pass if current_user is root.
|
278
|
-
return if @current_user.is_root?
|
279
|
-
|
280
|
-
condition_typus_users = @item.respond_to?(Typus.relationship) && !@item.send(Typus.relationship).include?(@current_user)
|
281
|
-
condition_typus_user_id = @item.respond_to?(Typus.user_fk) && !@item.owned_by?(@current_user)
|
282
|
-
|
283
|
-
if condition_typus_users || condition_typus_user_id
|
284
|
-
flash[:notice] = _("You don't have permission to access this item.")
|
285
|
-
redirect_to request.referer || admin_dashboard_path
|
286
|
-
end
|
287
|
-
|
288
|
-
end
|
289
|
-
|
290
|
-
def check_ownership_of_items
|
291
|
-
|
292
|
-
# By-pass if current_user is root.
|
293
|
-
return if @current_user.is_root?
|
294
|
-
|
295
|
-
# Show only related items it @resource has a foreign_key (Typus.user_fk)
|
296
|
-
# related to the logged user.
|
297
|
-
if @resource[:class].typus_user_id?
|
298
|
-
condition = { Typus.user_fk => @current_user }
|
299
|
-
@conditions = @resource[:class].merge_conditions(@conditions, condition)
|
300
|
-
end
|
301
|
-
|
302
|
-
end
|
303
|
-
|
304
|
-
def check_ownership_of_referal_item
|
305
|
-
return unless params[:resource] && params[:resource_id]
|
306
|
-
klass = params[:resource].classify.constantize
|
307
|
-
return if !klass.typus_user_id?
|
308
|
-
item = klass.find(params[:resource_id])
|
309
|
-
raise "You're not owner of this record." unless item.owned_by?(@current_user) || @current_user.is_root?
|
310
|
-
end
|
311
|
-
|
312
|
-
def set_fields
|
313
|
-
@fields = case params[:action]
|
314
|
-
when 'index'
|
315
|
-
@resource[:class].typus_fields_for(:list)
|
316
|
-
when 'new', 'edit', 'create', 'update'
|
317
|
-
@resource[:class].typus_fields_for(:form)
|
318
|
-
else
|
319
|
-
@resource[:class].typus_fields_for(params[:action])
|
320
|
-
end
|
321
|
-
end
|
322
|
-
|
323
|
-
def set_order
|
324
|
-
params[:sort_order] ||= 'desc'
|
325
|
-
@order = params[:order_by] ? "#{@resource[:class].table_name}.#{params[:order_by]} #{params[:sort_order]}" : @resource[:class].typus_order_by
|
326
|
-
end
|
327
|
-
|
328
|
-
# If we want to display only user items, we don't want the links previous and
|
329
|
-
# next linking to records from other users.
|
330
|
-
def set_conditions
|
331
|
-
condition = @current_user.is_root? ||
|
332
|
-
!@resource[:class].typus_options_for(:only_user_items) ||
|
333
|
-
!@resource[:class].columns.map(&:name).include?(Typus.user_fk)
|
334
|
-
!condition ? { Typus.user_fk => @current_user.id } : { }
|
335
|
-
end
|
336
|
-
|
337
|
-
def set_tiny_mce
|
338
|
-
if !@resource[:class].typus_tiny_mce_fields.empty? && defined?(TinyMCE)
|
339
|
-
options = @resource[:class].typus_tiny_mce_options
|
340
|
-
self.class.class_eval { uses_tiny_mce :options => options }
|
341
|
-
end
|
342
|
-
end
|
343
|
-
|
344
|
-
def select_template(template, resource = @resource[:self])
|
345
|
-
folder = (File.exist?("app/views/admin/#{resource}/#{template}.html.erb")) ? resource : 'resources'
|
346
|
-
render "admin/#{folder}/#{template}"
|
347
|
-
end
|
348
|
-
|
349
|
-
##
|
350
|
-
# When <tt>params[:back_to]</tt> is defined this action is used.
|
351
|
-
#
|
352
|
-
# - <tt>has_and_belongs_to_many</tt> relationships.
|
353
|
-
# - <tt>has_many</tt> relationships (polymorphic ones).
|
354
|
-
#
|
355
|
-
def create_with_back_to
|
356
|
-
|
357
|
-
if params[:resource] && params[:resource_id]
|
358
|
-
resource_class = params[:resource].classify.constantize
|
359
|
-
resource_id = params[:resource_id]
|
360
|
-
resource = resource_class.find(resource_id)
|
361
|
-
association = @resource[:class].reflect_on_association(params[:resource].to_sym).macro rescue :polymorphic
|
362
|
-
else
|
363
|
-
association = :has_many
|
364
|
-
end
|
365
|
-
|
366
|
-
case association
|
367
|
-
when :belongs_to
|
368
|
-
@item.save
|
369
|
-
when :has_and_belongs_to_many
|
370
|
-
@item.save
|
371
|
-
@item.send(params[:resource]) << resource
|
372
|
-
when :has_many
|
373
|
-
@item.save
|
374
|
-
message = _("{{model}} successfully created.", :model => @resource[:human_name])
|
375
|
-
path = "#{params[:back_to]}?#{params[:selected]}=#{@item.id}"
|
376
|
-
when :polymorphic
|
377
|
-
resource.send(@item.class.name.tableize).create(params[:item])
|
378
|
-
path = "#{params[:back_to]}##{@resource[:self]}"
|
379
|
-
end
|
380
|
-
|
381
|
-
flash[:success] = message || _("{{model_a}} successfully assigned to {{model_b}}.",
|
382
|
-
:model_a => @item.class.typus_human_name,
|
383
|
-
:model_b => resource_class.name)
|
384
|
-
redirect_to path || params[:back_to]
|
385
|
-
|
386
|
-
end
|
387
|
-
|
388
|
-
def error_handler(error, path = admin_dashboard_path)
|
389
|
-
raise error unless Rails.env.production?
|
390
|
-
flash[:error] = "#{error.message} (#{@resource[:class]})"
|
391
|
-
redirect_to path
|
392
|
-
end
|
393
|
-
|
394
|
-
end
|
@@ -1,152 +0,0 @@
|
|
1
|
-
class TypusController < ApplicationController
|
2
|
-
|
3
|
-
skip_filter filter_chain
|
4
|
-
|
5
|
-
unloadable
|
6
|
-
|
7
|
-
layout :select_layout
|
8
|
-
|
9
|
-
include Typus::Authentication
|
10
|
-
include Typus::QuickEdit
|
11
|
-
include Typus::Preferences
|
12
|
-
include Typus::Reloader
|
13
|
-
|
14
|
-
if Typus::Configuration.options[:ssl]
|
15
|
-
include SslRequirement
|
16
|
-
ssl_required :sign_in, :sign_out,
|
17
|
-
:dashboard,
|
18
|
-
:recover_password, :reset_password
|
19
|
-
end
|
20
|
-
|
21
|
-
filter_parameter_logging :password
|
22
|
-
|
23
|
-
before_filter :verify_typus_users_table_schema
|
24
|
-
|
25
|
-
before_filter :reload_config_et_roles
|
26
|
-
before_filter :require_login,
|
27
|
-
:except => [ :sign_up, :sign_in, :sign_out,
|
28
|
-
:recover_password, :reset_password,
|
29
|
-
:quick_edit ]
|
30
|
-
|
31
|
-
before_filter :check_if_user_can_perform_action_on_resource_without_model,
|
32
|
-
:except => [ :sign_up, :sign_in, :sign_out,
|
33
|
-
:dashboard,
|
34
|
-
:recover_password, :reset_password,
|
35
|
-
:quick_edit ]
|
36
|
-
|
37
|
-
before_filter :recover_password_disabled?,
|
38
|
-
:only => [ :recover_password, :reset_password ]
|
39
|
-
|
40
|
-
def dashboard
|
41
|
-
begin
|
42
|
-
I18n.locale = @current_user.preferences[:locale]
|
43
|
-
flash[:notice] = _("There are not defined applications in config/typus/*.yml.") if Typus.applications.empty?
|
44
|
-
rescue
|
45
|
-
@current_user.update_attributes :preferences => { :locale => Typus::Configuration.options[:default_locale] }
|
46
|
-
retry
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
def sign_in
|
51
|
-
|
52
|
-
redirect_to admin_sign_up_path and return if Typus.user_class.count.zero?
|
53
|
-
|
54
|
-
if request.post?
|
55
|
-
if user = Typus.user_class.authenticate(params[:user][:email], params[:user][:password])
|
56
|
-
session[:typus_user_id] = user.id
|
57
|
-
redirect_to params[:back_to] || admin_dashboard_path
|
58
|
-
else
|
59
|
-
flash[:error] = _("The email and/or password you entered is invalid.")
|
60
|
-
redirect_to admin_sign_in_path
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
end
|
65
|
-
|
66
|
-
def sign_out
|
67
|
-
session[:typus_user_id] = nil
|
68
|
-
redirect_to admin_sign_in_path
|
69
|
-
end
|
70
|
-
|
71
|
-
def recover_password
|
72
|
-
if request.post?
|
73
|
-
if user = Typus.user_class.find_by_email(params[:user][:email])
|
74
|
-
ActionMailer::Base.default_url_options[:host] = request.host_with_port
|
75
|
-
TypusMailer.deliver_reset_password_link(user)
|
76
|
-
flash[:success] = _("Password recovery link sent to your email.")
|
77
|
-
redirect_to admin_sign_in_path
|
78
|
-
else
|
79
|
-
redirect_to admin_recover_password_path
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
##
|
85
|
-
# Available if Typus::Configuration.options[:recover_password] is enabled.
|
86
|
-
#
|
87
|
-
def reset_password
|
88
|
-
@user = Typus.user_class.find_by_token!(params[:token])
|
89
|
-
if request.post?
|
90
|
-
@user.password = params[:user][:password]
|
91
|
-
@user.password_confirmation = params[:user][:password_confirmation]
|
92
|
-
if @user.save
|
93
|
-
session[:typus_user_id] = @user.id
|
94
|
-
redirect_to admin_dashboard_path
|
95
|
-
else
|
96
|
-
render :action => 'reset_password'
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
def sign_up
|
102
|
-
|
103
|
-
redirect_to admin_sign_in_path and return unless Typus.user_class.count.zero?
|
104
|
-
|
105
|
-
if request.post?
|
106
|
-
|
107
|
-
password = 'columbia'
|
108
|
-
|
109
|
-
user = Typus.user_class.generate(:email => params[:user][:email],
|
110
|
-
:password => 'columbia',
|
111
|
-
:role => Typus::Configuration.options[:root])
|
112
|
-
user.status = true
|
113
|
-
|
114
|
-
if user.save
|
115
|
-
session[:typus_user_id] = user.id
|
116
|
-
flash[:notice] = _("Password set to \"{{password}}\".", :password => password)
|
117
|
-
redirect_to admin_dashboard_path
|
118
|
-
else
|
119
|
-
flash[:error] = _("That doesn't seem like a valid email address.")
|
120
|
-
end
|
121
|
-
|
122
|
-
else
|
123
|
-
|
124
|
-
flash[:notice] = _("Enter your email below to create the first user.")
|
125
|
-
|
126
|
-
end
|
127
|
-
|
128
|
-
end
|
129
|
-
|
130
|
-
private
|
131
|
-
|
132
|
-
def verify_typus_users_table_schema
|
133
|
-
|
134
|
-
unless Typus.user_class.model_fields.keys.include?(:role)
|
135
|
-
raise "Run `script/generate typus_update_schema_to_01 -f && rake db:migrate` to update database schema."
|
136
|
-
end
|
137
|
-
|
138
|
-
unless Typus.user_class.model_fields.keys.include?(:preferences)
|
139
|
-
raise "Run `script/generate typus_update_schema_to_02 -f && rake db:migrate` to update database schema."
|
140
|
-
end
|
141
|
-
|
142
|
-
end
|
143
|
-
|
144
|
-
def recover_password_disabled?
|
145
|
-
redirect_to admin_sign_in_path unless Typus::Configuration.options[:recover_password]
|
146
|
-
end
|
147
|
-
|
148
|
-
def select_layout
|
149
|
-
%w( sign_up sign_in sign_out recover_password reset_password ).include?(action_name) ? 'typus' : 'admin'
|
150
|
-
end
|
151
|
-
|
152
|
-
end
|