typus 3.0.2 → 3.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +20 -9
- data/Gemfile.lock +93 -65
- data/MIT-LICENSE +1 -1
- data/README.md +61 -0
- data/Rakefile +5 -0
- data/app/controllers/admin/account_controller.rb +7 -10
- data/app/controllers/admin/base_controller.rb +16 -1
- data/app/controllers/admin/resources_controller.rb +270 -159
- data/app/controllers/admin/session_controller.rb +8 -9
- data/app/helpers/admin/base_helper.rb +13 -28
- data/app/helpers/admin/dashboard_helper.rb +4 -10
- data/app/helpers/admin/file_preview_helper.rb +70 -0
- data/app/helpers/admin/filters_helper.rb +64 -45
- data/app/helpers/admin/form_helper.rb +37 -62
- data/app/helpers/admin/relationships_helper.rb +63 -78
- data/app/helpers/admin/resources_helper.rb +10 -31
- data/app/helpers/admin/search_helper.rb +6 -9
- data/app/helpers/admin/sidebar_helper.rb +15 -20
- data/app/helpers/admin/table_helper.rb +79 -170
- data/app/mailers/admin/mailer.rb +1 -1
- data/app/views/admin/account/forgot_password.html.erb +2 -2
- data/app/views/admin/account/new.html.erb +8 -4
- data/app/views/admin/base/user_guide.html.erb +85 -0
- data/app/views/admin/dashboard/_sidebar.html.erb +3 -1
- data/app/views/admin/dashboard/show.html.erb +2 -2
- data/app/views/admin/dashboard/styles.html.erb +2 -2
- data/app/views/admin/helpers/_apps.html.erb +5 -4
- data/app/views/admin/helpers/_file_preview.html.erb +3 -0
- data/app/views/admin/helpers/_header.html.erb +3 -3
- data/app/views/admin/helpers/_login_info.html.erb +2 -2
- data/app/views/admin/helpers/dashboard/_applications.html.erb +6 -9
- data/app/views/admin/helpers/dashboard/_resources.html.erb +2 -3
- data/app/views/admin/helpers/filters/_filters.html.erb +1 -1
- data/app/views/admin/helpers/resources/_display_link_to_previous.html.erb +1 -1
- data/app/views/admin/helpers/resources/_errors.html.erb +10 -0
- data/app/views/admin/helpers/search/_search.html.erb +1 -1
- data/app/views/admin/helpers/sidebar/_sidebar.html.erb +6 -3
- data/app/views/admin/helpers/table/_table.html.erb +17 -5
- data/app/views/admin/mailer/reset_password_link.text.erb +2 -2
- data/app/views/admin/resources/_form.html.erb +3 -12
- data/app/views/admin/resources/edit.html.erb +7 -5
- data/app/views/admin/resources/index.html.erb +13 -18
- data/app/views/admin/resources/new.html.erb +4 -4
- data/app/views/admin/resources/show.html.erb +9 -13
- data/app/views/admin/session/new.html.erb +8 -4
- data/app/views/admin/templates/_belongs_to.html.erb +1 -1
- data/app/views/admin/templates/_boolean.html.erb +2 -2
- data/app/views/admin/templates/_date.html.erb +2 -2
- data/app/views/admin/templates/_datetime.html.erb +2 -2
- data/app/views/admin/templates/_file.html.erb +3 -19
- data/app/views/admin/templates/_has_n.html.erb +4 -4
- data/app/views/admin/templates/_has_one.html.erb +14 -0
- data/app/views/admin/templates/_password.html.erb +2 -2
- data/app/views/admin/templates/_profile_sidebar.html.erb +3 -0
- data/app/views/admin/templates/_relate_form.html.erb +2 -1
- data/app/views/admin/templates/_selector.html.erb +1 -1
- data/app/views/admin/templates/_string.html.erb +6 -6
- data/app/views/admin/templates/_text.html.erb +11 -4
- data/app/views/admin/templates/_time.html.erb +2 -2
- data/app/views/admin/templates/_tree.html.erb +1 -1
- data/app/views/layouts/admin/base.html.erb +7 -6
- data/app/views/layouts/admin/session.html.erb +4 -14
- data/config/{available_locales/ca_models.yml → locales/typus.ca.models.yml} +5 -4
- data/config/locales/typus.ca.yml +81 -0
- data/config/{available_locales/de_models.yml → locales/typus.de.models.yml} +6 -2
- data/config/locales/typus.de.yml +80 -0
- data/config/locales/typus.el.models.yml +17 -0
- data/config/locales/typus.el.yml +82 -0
- data/config/{available_locales/es_models.yml → locales/typus.es.models.yml} +9 -4
- data/config/locales/typus.es.yml +82 -0
- data/config/{available_locales/fr_models.yml → locales/typus.fr.models.yml} +8 -3
- data/config/locales/typus.fr.yml +87 -0
- data/config/{available_locales/hu_models.yml → locales/typus.hu.models.yml} +6 -2
- data/config/locales/typus.hu.yml +80 -0
- data/config/{available_locales/it_models.yml → locales/typus.it.models.yml} +7 -4
- data/config/locales/typus.it.yml +89 -0
- data/config/{available_locales/language_models.yml.template → locales/typus.locale.models.yml.template} +8 -4
- data/config/locales/typus.locale.yml.template +81 -0
- data/config/{available_locales/pt-BR_models.yml → locales/typus.pt-BR.models.yml} +6 -2
- data/config/locales/typus.pt-BR.yml +80 -0
- data/config/{available_locales/ru_models.yml → locales/typus.ru.models.yml} +6 -2
- data/config/locales/typus.ru.yml +80 -0
- data/config/locales/typus.zh-CN.models.yml +17 -0
- data/config/locales/typus.zh-CN.yml +79 -0
- data/config/routes.rb +11 -7
- data/lib/generators/templates/config/initializers/typus.rb +8 -5
- data/lib/generators/templates/config/initializers/typus_resources.rb +0 -3
- data/lib/generators/templates/config/typus/README +6 -6
- data/lib/generators/templates/config/typus/typus.yml +5 -5
- data/lib/generators/templates/controller.rb +1 -1
- data/lib/generators/templates/migration.rb +1 -0
- data/lib/generators/templates/public/admin/javascripts/application.js +0 -4
- data/lib/generators/templates/public/admin/javascripts/jquery-1.4.4.min.js +167 -0
- data/lib/generators/templates/public/admin/javascripts/jquery.application.js +16 -0
- data/lib/generators/templates/public/admin/javascripts/jquery.rails.js +50 -22
- data/lib/generators/templates/public/admin/stylesheets/screen.css +43 -34
- data/lib/generators/templates/public/admin/vendor/fancybox/fancy_loading.png +0 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/jquery.easing-1.3.pack.js +32 -32
- data/lib/generators/templates/public/admin/vendor/fancybox/{jquery.fancybox-1.3.1.css → jquery.fancybox-1.3.4.css} +359 -363
- data/lib/generators/templates/public/admin/vendor/fancybox/jquery.fancybox-1.3.4.js +1156 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/jquery.fancybox-1.3.4.pack.js +46 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/jquery.mousewheel-3.0.4.pack.js +14 -0
- data/lib/generators/typus/assets_generator.rb +23 -0
- data/lib/generators/typus/controller_generator.rb +29 -0
- data/lib/generators/typus/migration_generator.rb +39 -20
- data/lib/generators/typus/typus_generator.rb +17 -57
- data/lib/generators/typus/views_generator.rb +2 -6
- data/lib/support/active_record.rb +8 -20
- data/lib/support/fake_user.rb +6 -1
- data/lib/support/hash.rb +1 -2
- data/lib/support/object.rb +4 -17
- data/lib/support/string.rb +34 -3
- data/lib/tasks/typus.rake +1 -1
- data/lib/typus.rb +60 -48
- data/lib/typus/actions.rb +27 -0
- data/lib/typus/authentication/base.rb +3 -4
- data/lib/typus/authentication/http_basic.rb +1 -1
- data/lib/typus/authentication/none.rb +1 -1
- data/lib/typus/authentication/session.rb +53 -108
- data/lib/typus/configuration.rb +13 -11
- data/lib/typus/filters.rb +12 -0
- data/lib/typus/format.rb +9 -13
- data/lib/typus/i18n.rb +30 -0
- data/lib/typus/orm/active_record.rb +97 -194
- data/lib/typus/orm/active_record/search.rb +91 -0
- data/lib/typus/resources.rb +6 -10
- data/lib/typus/user.rb +20 -40
- data/lib/typus/version.rb +1 -1
- metadata +77 -231
- data/CHANGELOG +0 -102
- data/README.rdoc +0 -48
- data/app/helpers/admin/preview_helper.rb +0 -46
- data/app/views/admin/helpers/_preview.html.erb +0 -13
- data/app/views/admin/templates/_has_many.html.erb +0 -22
- data/config/available_locales/ca.yml +0 -122
- data/config/available_locales/de.yml +0 -122
- data/config/available_locales/es.yml +0 -122
- data/config/available_locales/fr.yml +0 -127
- data/config/available_locales/hu.yml +0 -122
- data/config/available_locales/it.yml +0 -132
- data/config/available_locales/language.yml.template +0 -120
- data/config/available_locales/pt-BR.yml +0 -122
- data/config/available_locales/ru.yml +0 -122
- data/lib/generators/templates/functional_test.rb +0 -10
- data/lib/generators/templates/model.rb +0 -8
- data/lib/generators/templates/public/admin/images/ui-icons.png +0 -0
- data/lib/generators/templates/public/admin/javascripts/jquery-1.4.2.min.js +0 -154
- data/lib/generators/templates/public/admin/vendor/fancybox/jquery.fancybox-1.3.1.js +0 -1077
- data/lib/generators/templates/public/admin/vendor/fancybox/jquery.fancybox-1.3.1.pack.js +0 -44
- data/lib/generators/templates/public/admin/vendor/fancybox/jquery.mousewheel-3.0.2.pack.js +0 -13
- data/lib/typus/pagination.rb +0 -18
- data/test/factories.rb +0 -43
- data/test/fixtures/config/broken/application.yml +0 -68
- data/test/fixtures/config/broken/application_roles.yml +0 -20
- data/test/fixtures/config/broken/empty.yml +0 -0
- data/test/fixtures/config/broken/empty_roles.yml +0 -0
- data/test/fixtures/config/broken/undefined.yml +0 -3
- data/test/fixtures/config/broken/undefined_roles.yml +0 -6
- data/test/fixtures/config/default/typus.yml +0 -13
- data/test/fixtures/config/default/typus_roles.yml +0 -2
- 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/fixtures/config/locales/es.yml +0 -10
- data/test/fixtures/config/namespaced/application.yml +0 -5
- data/test/fixtures/config/namespaced/application_roles.yml +0 -2
- data/test/fixtures/config/ordered/001_roles.yml +0 -2
- data/test/fixtures/config/ordered/002_roles.yml +0 -2
- data/test/fixtures/config/unordered/app_one_roles.yml +0 -2
- data/test/fixtures/config/unordered/app_two_roles.yml +0 -2
- data/test/fixtures/config/working/application.yml +0 -73
- data/test/fixtures/config/working/application_roles.yml +0 -24
- data/test/fixtures/config/working/typus.yml +0 -13
- data/test/fixtures/config/working/typus_roles.yml +0 -2
- data/test/fixtures/rails_app/Rakefile +0 -7
- data/test/fixtures/rails_app/app/controllers/admin/assets_controller.rb +0 -2
- data/test/fixtures/rails_app/app/controllers/admin/categories_controller.rb +0 -2
- data/test/fixtures/rails_app/app/controllers/admin/comments_controller.rb +0 -2
- data/test/fixtures/rails_app/app/controllers/admin/pages_controller.rb +0 -2
- data/test/fixtures/rails_app/app/controllers/admin/pictures_controller.rb +0 -2
- data/test/fixtures/rails_app/app/controllers/admin/posts_controller.rb +0 -2
- data/test/fixtures/rails_app/app/controllers/admin/status_controller.rb +0 -2
- data/test/fixtures/rails_app/app/controllers/admin/typus_users_controller.rb +0 -2
- data/test/fixtures/rails_app/app/controllers/admin/watch_dog_controller.rb +0 -2
- data/test/fixtures/rails_app/app/controllers/application_controller.rb +0 -3
- data/test/fixtures/rails_app/app/models/asset.rb +0 -5
- data/test/fixtures/rails_app/app/models/category.rb +0 -11
- data/test/fixtures/rails_app/app/models/comment.rb +0 -6
- data/test/fixtures/rails_app/app/models/custom_user.rb +0 -2
- data/test/fixtures/rails_app/app/models/delayed/task.rb +0 -5
- data/test/fixtures/rails_app/app/models/page.rb +0 -5
- data/test/fixtures/rails_app/app/models/picture.rb +0 -6
- data/test/fixtures/rails_app/app/models/post.rb +0 -21
- data/test/fixtures/rails_app/app/models/typus_user.rb +0 -8
- data/test/fixtures/rails_app/app/models/view.rb +0 -5
- data/test/fixtures/rails_app/app/views/admin/categories/_form.html.erb +0 -1
- data/test/fixtures/rails_app/app/views/admin/dashboard/_sidebar.html.erb +0 -1
- data/test/fixtures/rails_app/app/views/admin/mailer/reset_password_link.text.erb +0 -6
- data/test/fixtures/rails_app/app/views/admin/posts/_edit.html.erb +0 -1
- data/test/fixtures/rails_app/app/views/admin/posts/_index.html.erb +0 -1
- data/test/fixtures/rails_app/app/views/admin/posts/_new.html.erb +0 -1
- data/test/fixtures/rails_app/app/views/admin/posts/_show.html.erb +0 -1
- data/test/fixtures/rails_app/app/views/admin/posts/_sidebar.html.erb +0 -1
- data/test/fixtures/rails_app/app/views/admin/resources/_sidebar.html.erb +0 -1
- data/test/fixtures/rails_app/app/views/admin/status/index.html.erb +0 -1
- data/test/fixtures/rails_app/app/views/admin/templates/_datepicker.html.erb +0 -1
- data/test/fixtures/rails_app/config.ru +0 -4
- data/test/fixtures/rails_app/config/application.rb +0 -53
- data/test/fixtures/rails_app/config/boot.rb +0 -13
- data/test/fixtures/rails_app/config/database.yml +0 -14
- data/test/fixtures/rails_app/config/environment.rb +0 -5
- data/test/fixtures/rails_app/config/environments/test.rb +0 -34
- data/test/fixtures/rails_app/config/initializers/secret_token.rb +0 -7
- data/test/fixtures/rails_app/config/initializers/session_store.rb +0 -8
- data/test/fixtures/rails_app/config/initializers/typus.rb +0 -6
- data/test/fixtures/rails_app/config/routes.rb +0 -5
- data/test/fixtures/rails_app/config/typus/application.yml +0 -79
- data/test/fixtures/rails_app/config/typus/application_roles.yml +0 -25
- data/test/fixtures/rails_app/config/typus/typus.yml +0 -12
- data/test/fixtures/rails_app/config/typus/typus_roles.yml +0 -2
- data/test/fixtures/rails_app/db/test.sqlite3 +0 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101012213057.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101012213132.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101012213234.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101012213506.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101012215057.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101012215217.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101012215415.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101012215443.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101012215509.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101012215528.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101012215551.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101012215615.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101012215640.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101012215714.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101012215744.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101012215814.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101012215836.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101012215906.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101012220659.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101012221043.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101012221258.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101012222558.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101012222752.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101012222848.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101012223433.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101012223535.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101012224003.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101012224052.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101012224109.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101012224139.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101012224205.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101012224243.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101012225119.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013063215.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013063300.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013063352.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013063427.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013063448.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013063530.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013063559.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013063646.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013063737.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013063822.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013063837.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013063919.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013063939.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013063952.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013064220.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013064253.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013064318.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013064404.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013064452.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013064536.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013064652.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013064845.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013065023.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013065137.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013065713.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013065954.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013070057.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013070116.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013070156.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013070349.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013070429.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013070448.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013070514.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013070709.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013070745.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013070809.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013070905.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013070955.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013071116.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013071209.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013071335.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013071632.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013071643.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013071735.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013071749.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013072030.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013072050.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013072108.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013072713.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013072751.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013072912.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101013074546.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101018180512.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101018183359.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101018183608.csv +0 -2
- data/test/fixtures/rails_app/tmp/export-posts-20101018183759.csv +0 -2
- data/test/functional/admin/account_controller_test.rb +0 -90
- data/test/functional/admin/assets_controller_test.rb +0 -55
- data/test/functional/admin/categories_controller_test.rb +0 -62
- data/test/functional/admin/comments_controller_test.rb +0 -21
- data/test/functional/admin/dashboard_controller_test.rb +0 -138
- data/test/functional/admin/posts_controller_test.rb +0 -548
- data/test/functional/admin/session_controller_test.rb +0 -85
- data/test/functional/admin/status_controller_test.rb +0 -46
- data/test/functional/admin/typus_users_controller_test.rb +0 -159
- data/test/helpers/admin/base_helper_test.rb +0 -67
- data/test/helpers/admin/dashboard_helper_test.rb +0 -19
- data/test/helpers/admin/form_helper_test.rb +0 -117
- data/test/helpers/admin/resources_helper_test.rb +0 -64
- data/test/helpers/admin/sidebar_helper_test.rb +0 -274
- data/test/helpers/admin/table_helper_test.rb +0 -219
- data/test/integration/login_test.rb +0 -13
- data/test/integration_test_helper.rb +0 -21
- data/test/lib/support/active_record_test.rb +0 -86
- data/test/lib/support/array_test.rb +0 -11
- data/test/lib/support/hash_test.rb +0 -11
- data/test/lib/support/string_test.rb +0 -39
- data/test/lib/typus/active_record_test.rb +0 -451
- data/test/lib/typus/configuration_test.rb +0 -52
- data/test/lib/typus/resource_test.rb +0 -17
- data/test/lib/typus/routes_test.rb +0 -29
- data/test/lib/typus_test.rb +0 -107
- data/test/schema.rb +0 -100
- data/test/test_helper.rb +0 -16
- data/test/unit/admin/mailer_test.rb +0 -32
- data/test/unit/typus_user_roles_test.rb +0 -105
- data/test/unit/typus_user_test.rb +0 -142
- data/typus.gemspec +0 -25
data/lib/support/hash.rb
CHANGED
data/lib/support/object.rb
CHANGED
@@ -1,22 +1,9 @@
|
|
1
1
|
class Object
|
2
2
|
|
3
|
-
|
4
|
-
#
|
5
|
-
|
6
|
-
|
7
|
-
#
|
8
|
-
# We define this method to define the value only once:
|
9
|
-
#
|
10
|
-
# _t("Hello World!")
|
11
|
-
#
|
12
|
-
# Note that interpolation still works ...
|
13
|
-
#
|
14
|
-
# _t("Hello %{world}!", :world => @world)
|
15
|
-
#
|
16
|
-
def _t(msg, *args)
|
17
|
-
options = args.extract_options!
|
18
|
-
options[:default] = msg
|
19
|
-
I18n.t(msg, options)
|
3
|
+
# Probably there's a better way to verify if a model responds to an STI
|
4
|
+
# pattern.
|
5
|
+
def self.is_sti?
|
6
|
+
superclass.superclass == ActiveRecord::Base
|
20
7
|
end
|
21
8
|
|
22
9
|
end
|
data/lib/support/string.rb
CHANGED
@@ -4,12 +4,43 @@ class String
|
|
4
4
|
split(",").map { |x| x.strip }
|
5
5
|
end
|
6
6
|
|
7
|
-
def remove_prefix
|
8
|
-
|
7
|
+
def remove_prefix
|
8
|
+
split("/")[1..-1].join("/")
|
9
9
|
end
|
10
10
|
|
11
11
|
def extract_class
|
12
|
-
remove_prefix.
|
12
|
+
remove_prefix.classify.typus_constantize
|
13
|
+
end
|
14
|
+
|
15
|
+
def typus_constantize
|
16
|
+
Typus::Configuration.models_constantized[self]
|
17
|
+
end
|
18
|
+
|
19
|
+
def action_mapper
|
20
|
+
case self
|
21
|
+
when "index" then :list
|
22
|
+
when "new", "create", "edit", "update" then :form
|
23
|
+
else self
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def acl_action_mapper
|
28
|
+
case self
|
29
|
+
when "new", "create"
|
30
|
+
"create"
|
31
|
+
when "index", "show"
|
32
|
+
"read"
|
33
|
+
when "edit", "update", "position", "toggle", "relate", "unrelate", "detach"
|
34
|
+
"update"
|
35
|
+
when "destroy", "trash"
|
36
|
+
"delete"
|
37
|
+
else
|
38
|
+
self
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def to_resource
|
43
|
+
self.underscore.pluralize
|
13
44
|
end
|
14
45
|
|
15
46
|
end
|
data/lib/tasks/typus.rake
CHANGED
@@ -4,7 +4,7 @@ namespace :typus do
|
|
4
4
|
task :roles => :environment do
|
5
5
|
Typus::Configuration.roles.each do |role|
|
6
6
|
puts "#{role.first.capitalize} role has access to:"
|
7
|
-
role.last.each { |
|
7
|
+
role.last.each { |k, v| puts "- #{k}: #{v}" }
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
data/lib/typus.rb
CHANGED
@@ -7,19 +7,25 @@ require "support/object"
|
|
7
7
|
require "support/string"
|
8
8
|
|
9
9
|
require "typus/engine"
|
10
|
+
require "typus/i18n"
|
10
11
|
require "typus/orm/active_record"
|
11
12
|
require "typus/user"
|
13
|
+
require "typus/version"
|
12
14
|
|
13
|
-
require
|
15
|
+
require "render_inheritable"
|
16
|
+
require "will_paginate"
|
14
17
|
|
15
18
|
autoload :FakeUser, "support/fake_user"
|
16
19
|
|
17
20
|
module Typus
|
18
21
|
|
19
22
|
autoload :Configuration, "typus/configuration"
|
20
|
-
autoload :Pagination, "typus/pagination"
|
21
23
|
autoload :Resources, "typus/resources"
|
22
24
|
|
25
|
+
autoload :Actions, "typus/actions"
|
26
|
+
autoload :Filters, "typus/filters"
|
27
|
+
autoload :Format, "typus/format"
|
28
|
+
|
23
29
|
module Authentication
|
24
30
|
autoload :Base, "typus/authentication/base"
|
25
31
|
autoload :None, "typus/authentication/none"
|
@@ -51,28 +57,48 @@ module Typus
|
|
51
57
|
mattr_accessor :username
|
52
58
|
@@username = "admin"
|
53
59
|
|
60
|
+
##
|
61
|
+
# Pagination options
|
62
|
+
#
|
63
|
+
mattr_accessor :pagination
|
64
|
+
@@pagination = { :previous_label => "← " + Typus::I18n.t("Previous"),
|
65
|
+
:next_label => Typus::I18n.t("Next") + " →" }
|
66
|
+
|
54
67
|
##
|
55
68
|
# Define a password.
|
56
69
|
#
|
57
|
-
# Used as default password for http and
|
70
|
+
# Used as default password for http and advanced authentication.
|
58
71
|
#
|
59
72
|
mattr_accessor :password
|
60
73
|
@@password = "columbia"
|
61
74
|
|
62
75
|
##
|
63
|
-
# Configure the e-mail address which will be shown in Admin::Mailer.
|
64
|
-
#
|
65
|
-
# When `nil`, the `forgot_password` will be disabled.
|
76
|
+
# Configure the e-mail address which will be shown in Admin::Mailer. If not
|
77
|
+
# set `forgot_password` feature is disabled.
|
66
78
|
#
|
67
79
|
mattr_accessor :mailer_sender
|
68
80
|
@@mailer_sender = nil
|
69
81
|
|
82
|
+
##
|
83
|
+
# Define `paperclip` attachment styles.
|
84
|
+
#
|
85
|
+
|
70
86
|
mattr_accessor :file_preview
|
71
87
|
@@file_preview = :medium
|
72
88
|
|
73
89
|
mattr_accessor :file_thumbnail
|
74
90
|
@@file_thumbnail = :thumb
|
75
91
|
|
92
|
+
##
|
93
|
+
# Define `dragonfly` attachment styles.
|
94
|
+
#
|
95
|
+
|
96
|
+
mattr_accessor :image_preview_size
|
97
|
+
@@image_preview_size = 'x450'
|
98
|
+
|
99
|
+
mattr_accessor :image_thumb_size
|
100
|
+
@@image_thumb_size = '75x75#'
|
101
|
+
|
76
102
|
##
|
77
103
|
# Defines the default relationship table.
|
78
104
|
#
|
@@ -88,73 +114,62 @@ module Typus
|
|
88
114
|
mattr_accessor :user_fk
|
89
115
|
@@user_fk = "typus_user_id"
|
90
116
|
|
91
|
-
mattr_accessor :available_locales
|
92
|
-
@@available_locales = [:en]
|
93
|
-
|
94
117
|
class << self
|
95
118
|
|
96
119
|
# Default way to setup typus. Run `rails generate typus` to create a fresh
|
97
120
|
# initializer with all configuration values.
|
98
121
|
def setup
|
99
122
|
yield self
|
100
|
-
|
101
|
-
|
102
|
-
def root
|
103
|
-
(File.dirname(__FILE__) + "/../").chomp("/lib/../")
|
123
|
+
reload!
|
104
124
|
end
|
105
125
|
|
106
126
|
def applications
|
107
|
-
Typus::Configuration.config.
|
127
|
+
Typus::Configuration.config.map { |i| i.last["application"] }.compact.uniq.sort
|
108
128
|
end
|
109
129
|
|
110
130
|
# Lists modules of an application.
|
111
131
|
def application(name)
|
112
|
-
Typus::Configuration.config.
|
132
|
+
Typus::Configuration.config.map { |i| i.first if i.last["application"] == name }.compact.uniq.sort
|
113
133
|
end
|
114
134
|
|
115
135
|
# Lists models from the configuration file.
|
116
136
|
def models
|
117
|
-
Typus::Configuration.config
|
137
|
+
if config = Typus::Configuration.config
|
138
|
+
config.map { |i| i.first }.sort
|
139
|
+
else
|
140
|
+
[]
|
141
|
+
end
|
118
142
|
end
|
119
143
|
|
120
144
|
# Lists resources, which are tableless models.
|
121
145
|
def resources
|
122
|
-
Typus::Configuration.roles
|
123
|
-
|
124
|
-
|
146
|
+
if roles = Typus::Configuration.roles
|
147
|
+
roles.keys.map do |key|
|
148
|
+
Typus::Configuration.roles[key].keys
|
149
|
+
end.flatten.sort.uniq.delete_if { |x| models.include?(x) }
|
150
|
+
else
|
151
|
+
[]
|
152
|
+
end
|
125
153
|
end
|
126
154
|
|
127
155
|
# Lists models under <tt>app/models</tt>.
|
128
156
|
def detect_application_models
|
129
157
|
model_dir = Rails.root.join("app/models")
|
130
|
-
Dir.chdir(model_dir)
|
131
|
-
models = Dir["**/*.rb"]
|
132
|
-
end
|
158
|
+
Dir.chdir(model_dir) { Dir["**/*.rb"] }
|
133
159
|
end
|
134
160
|
|
135
161
|
def locales
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
"pt-BR" => "Portuguese",
|
148
|
-
"ru" => "Russian",
|
149
|
-
"it" => "Italiano" }
|
150
|
-
mapping.default = "Unknown"
|
151
|
-
return mapping
|
152
|
-
end
|
153
|
-
|
154
|
-
def detect_locales
|
155
|
-
available_locales.each do |locale|
|
156
|
-
I18n.load_path += Dir[File.join(Typus.root, "config", "available_locales", "#{locale}*")]
|
157
|
-
end
|
162
|
+
{ "Català" => "ca",
|
163
|
+
"German" => "de",
|
164
|
+
"Greek" => "el",
|
165
|
+
"English" => "en",
|
166
|
+
"Español" => "es",
|
167
|
+
"Français" => "fr",
|
168
|
+
"Magyar" => "hu",
|
169
|
+
"Italiano" => "It",
|
170
|
+
"Portuguese" => "pt-BR",
|
171
|
+
"Russian" => "ru",
|
172
|
+
"中文" => "zh-CN" }
|
158
173
|
end
|
159
174
|
|
160
175
|
def application_models
|
@@ -166,17 +181,14 @@ module Typus
|
|
166
181
|
end
|
167
182
|
|
168
183
|
def user_class
|
169
|
-
user_class_name.
|
184
|
+
user_class_name.typus_constantize
|
170
185
|
end
|
171
186
|
|
172
187
|
def reload!
|
173
188
|
Typus::Configuration.roles!
|
174
189
|
Typus::Configuration.config!
|
175
|
-
detect_locales
|
176
190
|
end
|
177
191
|
|
178
192
|
end
|
179
193
|
|
180
194
|
end
|
181
|
-
|
182
|
-
Typus.reload!
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Typus
|
2
|
+
|
3
|
+
module Actions
|
4
|
+
|
5
|
+
protected
|
6
|
+
|
7
|
+
def add_action(*args)
|
8
|
+
options = args.extract_options!
|
9
|
+
@actions ||= []
|
10
|
+
@actions << options
|
11
|
+
end
|
12
|
+
|
13
|
+
def prepend_action(*args)
|
14
|
+
options = args.extract_options!
|
15
|
+
@actions ||= []
|
16
|
+
@actions = @actions.unshift(options)
|
17
|
+
end
|
18
|
+
|
19
|
+
def append_action(*args)
|
20
|
+
options = args.extract_options!
|
21
|
+
@actions ||= []
|
22
|
+
@actions = @actions.concat([options])
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
@@ -4,8 +4,8 @@ module Typus
|
|
4
4
|
|
5
5
|
module Base
|
6
6
|
|
7
|
-
def
|
8
|
-
@
|
7
|
+
def admin_user
|
8
|
+
@admin_user
|
9
9
|
end
|
10
10
|
|
11
11
|
def authenticate; end
|
@@ -13,8 +13,7 @@ module Typus
|
|
13
13
|
def check_if_user_can_perform_action_on_resources; end
|
14
14
|
def check_if_user_can_perform_action_on_resource; end
|
15
15
|
def check_resource_ownership; end
|
16
|
-
def
|
17
|
-
def check_ownership_of_referal_item; end
|
16
|
+
def check_resources_ownership; end
|
18
17
|
def set_attributes_on_create; end
|
19
18
|
def set_attributes_on_update; end
|
20
19
|
def reload_locales; end
|
@@ -9,7 +9,7 @@ module Typus
|
|
9
9
|
include Base
|
10
10
|
|
11
11
|
def authenticate
|
12
|
-
@
|
12
|
+
@admin_user = FakeUser.new
|
13
13
|
authenticate_or_request_with_http_basic(Typus.admin_title) do |user_name, password|
|
14
14
|
user_name == Typus.username && password == Typus.password
|
15
15
|
end
|
@@ -10,7 +10,7 @@ module Typus
|
|
10
10
|
|
11
11
|
def authenticate
|
12
12
|
if session[:typus_user_id]
|
13
|
-
|
13
|
+
admin_user
|
14
14
|
else
|
15
15
|
back_to = request.env['PATH_INFO'] unless [admin_dashboard_path, admin_path].include?(request.env['PATH_INFO'])
|
16
16
|
redirect_to new_admin_session_path(:back_to => back_to)
|
@@ -19,64 +19,17 @@ module Typus
|
|
19
19
|
|
20
20
|
#--
|
21
21
|
# Return the current user. If role does not longer exist on the
|
22
|
-
# system
|
22
|
+
# system admin_user will be signed out from Typus.
|
23
23
|
#++
|
24
|
-
def
|
24
|
+
def admin_user
|
25
|
+
@admin_user ||= Typus.user_class.find_by_id(session[:typus_user_id])
|
25
26
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
raise _t("Role does no longer exists.")
|
30
|
-
end
|
31
|
-
|
32
|
-
unless @current_user.status
|
33
|
-
back_to = (request.env['REQUEST_URI'] == admin_dashboard_path) ? nil : request.env['REQUEST_URI']
|
34
|
-
raise _t("Typus user has been disabled.")
|
27
|
+
if !@admin_user || !Typus::Configuration.roles.has_key?(@admin_user.role) || !@admin_user.status
|
28
|
+
session[:typus_user_id] = nil
|
29
|
+
redirect_to new_admin_session_path
|
35
30
|
end
|
36
31
|
|
37
|
-
|
38
|
-
|
39
|
-
return @current_user
|
40
|
-
|
41
|
-
rescue Exception => error
|
42
|
-
session[:typus_user_id] = nil
|
43
|
-
redirect_to new_admin_session_path(:back_to => back_to), :notice => error.message
|
44
|
-
end
|
45
|
-
|
46
|
-
#--
|
47
|
-
# Action is available on: edit, update, toggle and destroy
|
48
|
-
#++
|
49
|
-
def check_if_user_can_perform_action_on_user
|
50
|
-
return unless @item.kind_of?(Typus.user_class)
|
51
|
-
|
52
|
-
message = case params[:action]
|
53
|
-
when 'edit'
|
54
|
-
# Only admin and owner of Typus User can edit.
|
55
|
-
if current_user.is_not_root? && (current_user != @item)
|
56
|
-
_t("As you're not the admin or the owner of this record you cannot edit it.")
|
57
|
-
end
|
58
|
-
when 'update'
|
59
|
-
# current_user cannot change her role.
|
60
|
-
if current_user && !(@item.role == params[@object_name][:role])
|
61
|
-
_t("You can't change your role.")
|
62
|
-
end
|
63
|
-
when 'toggle'
|
64
|
-
# Only admin can toggle typus user status, but not herself.
|
65
|
-
if current_user.is_root? && (current_user == @item)
|
66
|
-
_t("You can't toggle your status.")
|
67
|
-
elsif current_user.is_not_root?
|
68
|
-
_t("You're not allowed to toggle status.")
|
69
|
-
end
|
70
|
-
when 'destroy'
|
71
|
-
# Admin can remove anything except herself.
|
72
|
-
if current_user.is_root? && (current_user == @item)
|
73
|
-
_t("You can't remove yourself.")
|
74
|
-
elsif current_user.is_not_root?
|
75
|
-
_t("You're not allowed to remove Typus Users.")
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
redirect_to set_path, :notice => message if message
|
32
|
+
@admin_user
|
80
33
|
end
|
81
34
|
|
82
35
|
#--
|
@@ -84,24 +37,29 @@ module Typus
|
|
84
37
|
# It works on models, so its available on the `resources_controller`.
|
85
38
|
#++
|
86
39
|
def check_if_user_can_perform_action_on_resources
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
when 'destroy'
|
92
|
-
"%{current_user_role} can't delete this item."
|
93
|
-
else
|
94
|
-
"%{current_user_role} can't perform action. (%{action})"
|
95
|
-
end
|
96
|
-
|
97
|
-
message = _t(message,
|
98
|
-
:current_user_role => current_user.role.capitalize,
|
99
|
-
:action => params[:action])
|
100
|
-
|
101
|
-
unless current_user.can?(params[:action], @resource)
|
102
|
-
redirect_to set_path, :notice => message
|
40
|
+
if @item.is_a?(Typus.user_class)
|
41
|
+
check_if_user_can_perform_action_on_user
|
42
|
+
elsif admin_user.cannot?(params[:action], @resource.model_name)
|
43
|
+
not_allowed
|
103
44
|
end
|
45
|
+
end
|
104
46
|
|
47
|
+
#--
|
48
|
+
# Action is available on: edit, update, toggle and destroy
|
49
|
+
#++
|
50
|
+
def check_if_user_can_perform_action_on_user
|
51
|
+
case params[:action]
|
52
|
+
when 'edit'
|
53
|
+
not_allowed if admin_user.is_not_root? && (admin_user != @item)
|
54
|
+
when 'update'
|
55
|
+
user_profile = (admin_user.is_root? || admin_user.is_not_root?) && (admin_user == @item) && !(@item.role == params[@object_name][:role])
|
56
|
+
other_user = admin_user.is_not_root? && !(admin_user == @item)
|
57
|
+
not_allowed if (user_profile || other_user)
|
58
|
+
when 'toggle', 'destroy'
|
59
|
+
root = admin_user.is_root? && (admin_user == @item)
|
60
|
+
user = admin_user.is_not_root?
|
61
|
+
not_allowed if (root || user)
|
62
|
+
end
|
105
63
|
end
|
106
64
|
|
107
65
|
#--
|
@@ -109,13 +67,16 @@ module Typus
|
|
109
67
|
# It works on a resource: git, memcached, syslog ...
|
110
68
|
#++
|
111
69
|
def check_if_user_can_perform_action_on_resource
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
render :text => "Not allowed!", :status => :unprocessable_entity
|
70
|
+
resource = params[:controller].remove_prefix.camelize
|
71
|
+
unless admin_user.can?(params[:action], resource, { :special => true })
|
72
|
+
not_allowed
|
116
73
|
end
|
117
74
|
end
|
118
75
|
|
76
|
+
def not_allowed
|
77
|
+
render :text => "Not allowed!", :status => :unprocessable_entity
|
78
|
+
end
|
79
|
+
|
119
80
|
#--
|
120
81
|
# If item is owned by another user, we only can perform a
|
121
82
|
# show action on the item. Updated item is also blocked.
|
@@ -125,61 +86,45 @@ module Typus
|
|
125
86
|
# :relate, :unrelate ]
|
126
87
|
#++
|
127
88
|
def check_resource_ownership
|
89
|
+
if admin_user.is_not_root?
|
128
90
|
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
condition_typus_users = @item.respond_to?(Typus.relationship) && !@item.send(Typus.relationship).include?(current_user)
|
133
|
-
condition_typus_user_id = @item.respond_to?(Typus.user_fk) && !@item.owned_by?(current_user)
|
91
|
+
condition_typus_users = @item.respond_to?(Typus.relationship) && !@item.send(Typus.relationship).include?(admin_user)
|
92
|
+
condition_typus_user_id = @item.respond_to?(Typus.user_fk) && !@item.owned_by?(admin_user)
|
134
93
|
|
135
|
-
|
136
|
-
alert = _t("You don't have permission to access this item.")
|
137
|
-
redirect_to set_path, :alert => alert
|
94
|
+
not_allowed if (condition_typus_users || condition_typus_user_id)
|
138
95
|
end
|
139
|
-
|
140
96
|
end
|
141
97
|
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
condition = { Typus.user_fk => current_user }
|
151
|
-
@conditions = @resource.merge_conditions(@conditions, condition)
|
98
|
+
#--
|
99
|
+
# Show only related items it @resource has a foreign_key (Typus.user_fk)
|
100
|
+
# related to the logged user.
|
101
|
+
#++
|
102
|
+
def check_resources_ownership
|
103
|
+
if admin_user.is_not_root? && @resource.typus_user_id?
|
104
|
+
condition = { Typus.user_fk => admin_user }
|
105
|
+
@resource = @resource.where(condition)
|
152
106
|
end
|
153
|
-
|
154
|
-
end
|
155
|
-
|
156
|
-
def check_ownership_of_referal_item
|
157
|
-
return unless params[:resource] && params[:resource_id]
|
158
|
-
klass = params[:resource].classify.constantize
|
159
|
-
return if !klass.typus_user_id?
|
160
|
-
item = klass.find(params[:resource_id])
|
161
|
-
raise "You're not owner of this record." unless item.owned_by?(current_user) || current_user.is_root?
|
162
107
|
end
|
163
108
|
|
164
109
|
def set_attributes_on_create
|
165
110
|
if @resource.typus_user_id?
|
166
|
-
@item.attributes = { Typus.user_fk =>
|
111
|
+
@item.attributes = { Typus.user_fk => admin_user.id }
|
167
112
|
end
|
168
113
|
end
|
169
114
|
|
170
115
|
def set_attributes_on_update
|
171
|
-
if @resource.typus_user_id? &&
|
172
|
-
@item.update_attributes(Typus.user_fk =>
|
116
|
+
if @resource.typus_user_id? && admin_user.is_not_root?
|
117
|
+
@item.update_attributes(Typus.user_fk => admin_user.id)
|
173
118
|
end
|
174
119
|
end
|
175
120
|
|
176
121
|
#--
|
177
|
-
# Reload
|
122
|
+
# Reload admin_user when updating to see flash message in the
|
178
123
|
# correct locale.
|
179
124
|
#++
|
180
125
|
def reload_locales
|
181
126
|
if @resource.eql?(Typus.user_class)
|
182
|
-
I18n.locale =
|
127
|
+
::I18n.locale = admin_user.reload.locale
|
183
128
|
end
|
184
129
|
end
|
185
130
|
|