hobo 1.1.0 → 1.3.0.RC
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES.txt +238 -287
- data/Rakefile +14 -31
- data/VERSION +1 -0
- data/{lib/hobo → app/controllers}/dev_controller.rb +6 -6
- data/app/controllers/dryml_support_controller.rb +13 -0
- data/{rails_generators/hobo_front_controller/templates → app/views/dev}/summary.dryml +7 -10
- data/bin/hobo +12 -144
- data/config/initializers/inflections.rb +3 -0
- data/config/routes.rb +6 -0
- data/{doctest → doctests}/hobo/lifecycles.rdoctest +40 -59
- data/{doctest → doctests/hobo}/model.rdoctest +33 -40
- data/{doctest → doctests/hobo}/multi_model_forms.rdoctest +15 -19
- data/{doctest → doctests/hobo}/scopes.rdoctest +27 -41
- data/doctests/prepare_testapp.rb +8 -0
- data/hobo.gemspec +26 -199
- data/lib/generators/hobo/activation_email.rb +11 -0
- data/lib/generators/hobo/admin_subsite/admin_subsite_generator.rb +35 -0
- data/lib/generators/hobo/admin_subsite/templates/admin.css +20 -0
- data/lib/generators/hobo/admin_subsite/templates/admin_tag_injection.erb +10 -0
- data/{rails_generators/hobo_admin_site → lib/generators/hobo/admin_subsite}/templates/application.dryml +0 -0
- data/{rails_generators/hobo_admin_site/templates/controller.rb → lib/generators/hobo/admin_subsite/templates/controller.rb.erb} +5 -5
- data/lib/generators/hobo/admin_subsite/templates/users_index.dryml +7 -0
- data/lib/generators/hobo/assets/assets_generator.rb +18 -0
- data/{rails_generators/hobo → lib/generators/hobo/assets}/templates/application.css +0 -0
- data/lib/generators/hobo/assets/templates/application.dryml.erb +9 -0
- data/{rails_generators/hobo → lib/generators/hobo/assets}/templates/dryml-support.js +2 -2
- data/lib/generators/hobo/assets/templates/dryml_taglibs_initializer.rb +1 -0
- data/lib/generators/hobo/assets/templates/en_injection.yml +19 -0
- data/{rails_generators/hobo → lib/generators/hobo/assets}/templates/guest.rb +1 -1
- data/lib/generators/hobo/controller.rb +35 -0
- data/lib/generators/hobo/controller/controller_generator.rb +6 -0
- data/lib/generators/hobo/controller/templates/controller.rb.erb +7 -0
- data/{rails_generators/hobo_front_controller → lib/generators/hobo/front_controller}/USAGE +0 -0
- data/lib/generators/hobo/front_controller/front_controller_generator.rb +55 -0
- data/{rails_generators/hobo_front_controller/templates/controller.rb → lib/generators/hobo/front_controller/templates/controller.rb.erb} +0 -0
- data/{rails_generators/hobo_front_controller → lib/generators/hobo/front_controller}/templates/index.dryml +6 -12
- data/lib/generators/hobo/i18n/i18n_generator.rb +35 -0
- data/lib/generators/hobo/i18n/templates/app.de.yml +30 -0
- data/lib/generators/hobo/i18n/templates/app.en.yml +25 -0
- data/lib/generators/hobo/i18n/templates/app.es.yml +31 -0
- data/lib/generators/hobo/i18n/templates/app.fr.yml +26 -0
- data/lib/generators/hobo/i18n/templates/app.it.yml +28 -0
- data/lib/generators/hobo/i18n/templates/app.pt-PT.yml +25 -0
- data/lib/generators/hobo/i18n/templates/app.ru.yml +24 -0
- data/lib/generators/hobo/i18n/templates/hobo.de.yml +204 -0
- data/lib/generators/hobo/i18n/templates/hobo.en.yml +195 -0
- data/lib/generators/hobo/i18n/templates/hobo.es.yml +202 -0
- data/lib/generators/hobo/i18n/templates/hobo.fr.yml +195 -0
- data/lib/generators/hobo/i18n/templates/hobo.it.yml +202 -0
- data/lib/generators/hobo/i18n/templates/hobo.pt-PT.yml +196 -0
- data/lib/generators/hobo/i18n/templates/hobo.ru.yml +200 -0
- data/lib/generators/hobo/invite_only.rb +18 -0
- data/lib/generators/hobo/model/USAGE +19 -0
- data/lib/generators/hobo/model/model_generator.rb +11 -0
- data/{rails_generators/hobo_model/templates/model.rb → lib/generators/hobo/model/templates/model_injection.rb.erb} +0 -2
- data/{rails_generators/hobo_rapid → lib/generators/hobo/rapid}/USAGE +0 -0
- data/lib/generators/hobo/rapid/rapid_generator.rb +24 -0
- data/{rails_generators/hobo_rapid → lib/generators/hobo/rapid}/templates/IE7.js +0 -0
- data/{rails_generators/hobo_rapid → lib/generators/hobo/rapid}/templates/blank.gif +0 -0
- data/{rails_generators/hobo_rapid → lib/generators/hobo/rapid}/templates/hobo-rapid.css +0 -0
- data/{rails_generators/hobo_rapid → lib/generators/hobo/rapid}/templates/hobo-rapid.js +65 -65
- data/{rails_generators/hobo_rapid → lib/generators/hobo/rapid}/templates/ie7-recalc.js +21 -21
- data/{rails_generators/hobo_rapid → lib/generators/hobo/rapid}/templates/lowpro.js +31 -31
- data/{rails_generators/hobo_rapid → lib/generators/hobo/rapid}/templates/reset.css +1 -1
- data/lib/generators/hobo/rapid/templates/themes/clean-sidemenu/public/images/100-ACD3E6-DBE1E5-H.png +0 -0
- data/lib/generators/hobo/rapid/templates/themes/clean-sidemenu/public/images/100-DBE1E5-FCFEF5-H.png +0 -0
- data/lib/generators/hobo/rapid/templates/themes/clean-sidemenu/public/images/300-3B5F87-ACD3E6-H.png +0 -0
- data/{rails_generators/hobo_rapid/templates/themes/clean → lib/generators/hobo/rapid/templates/themes/clean-sidemenu}/public/images/spinner.gif +0 -0
- data/lib/generators/hobo/rapid/templates/themes/clean-sidemenu/public/stylesheets/clean-sidemenu.css +81 -0
- data/lib/generators/hobo/rapid/templates/themes/clean-sidemenu/views/clean-sidemenu.dryml +30 -0
- data/{rails_generators/hobo_rapid → lib/generators/hobo/rapid}/templates/themes/clean/public/images/101-3B5F87-ACD3E6.png +0 -0
- data/{rails_generators/hobo_rapid → lib/generators/hobo/rapid}/templates/themes/clean/public/images/30-3E547A-242E42.png +0 -0
- data/{rails_generators/hobo_rapid → lib/generators/hobo/rapid}/templates/themes/clean/public/images/30-DBE1E5-FCFEF5.png +0 -0
- data/{rails_generators/hobo_rapid → lib/generators/hobo/rapid}/templates/themes/clean/public/images/300-ACD3E6-fff.png +0 -0
- data/{rails_generators/hobo_rapid → lib/generators/hobo/rapid}/templates/themes/clean/public/images/50-ACD3E6-fff.png +0 -0
- data/{rails_generators/hobo_rapid → lib/generators/hobo/rapid}/templates/themes/clean/public/images/fieldbg.gif +0 -0
- data/{rails_generators/hobo_rapid → lib/generators/hobo/rapid}/templates/themes/clean/public/images/pencil.png +0 -0
- data/{rails_generators/hobo_rapid → lib/generators/hobo/rapid}/templates/themes/clean/public/images/small_close.png +0 -0
- data/lib/generators/hobo/rapid/templates/themes/clean/public/images/spinner.gif +0 -0
- data/{rails_generators/hobo_rapid → lib/generators/hobo/rapid}/templates/themes/clean/public/stylesheets/clean.css +16 -16
- data/{rails_generators/hobo_rapid → lib/generators/hobo/rapid}/templates/themes/clean/public/stylesheets/rapid-ui.css +3 -3
- data/{rails_generators/hobo_rapid → lib/generators/hobo/rapid}/templates/themes/clean/views/clean.dryml +1 -1
- data/lib/generators/hobo/resource/resource_generator.rb +23 -0
- data/lib/generators/hobo/routes/USAGE +9 -0
- data/lib/generators/hobo/routes/router.rb +115 -0
- data/lib/generators/hobo/routes/routes_generator.rb +40 -0
- data/lib/generators/hobo/routes/templates/hobo_routes.rb.erb +33 -0
- data/lib/generators/hobo/setup_wizard/USAGE +4 -0
- data/lib/generators/hobo/setup_wizard/setup_wizard_generator.rb +274 -0
- data/lib/generators/hobo/subsite.rb +48 -0
- data/lib/generators/hobo/subsite/subsite_generator.rb +16 -0
- data/{rails_generators/hobo_subsite → lib/generators/hobo/subsite}/templates/application.dryml +0 -0
- data/{rails_generators/hobo_subsite/templates/controller.rb → lib/generators/hobo/subsite/templates/controller.rb.erb} +1 -1
- data/lib/generators/hobo/subsite_taglib/subsite_taglib_generator.rb +16 -0
- data/{rails_generators/hobo_admin_site/templates/site_taglib.dryml → lib/generators/hobo/subsite_taglib/templates/taglib.dryml.erb} +9 -10
- data/lib/generators/hobo/taglib.rb +12 -0
- data/lib/generators/hobo/test_framework/test_framework_generator.rb +72 -0
- data/lib/generators/hobo/test_options.rb +19 -0
- data/{rails_generators/hobo_user_controller → lib/generators/hobo/user_controller}/templates/accept_invitation.dryml +0 -0
- data/lib/generators/hobo/user_controller/templates/controller.rb.erb +31 -0
- data/lib/generators/hobo/user_controller/user_controller_generator.rb +25 -0
- data/lib/generators/hobo/user_mailer/templates/activation.erb +9 -0
- data/{rails_generators/hobo_user_model → lib/generators/hobo/user_mailer}/templates/forgot_password.erb +2 -2
- data/{rails_generators/hobo_user_model → lib/generators/hobo/user_mailer}/templates/invite.erb +2 -2
- data/lib/generators/hobo/user_mailer/templates/mailer.rb.erb +25 -0
- data/lib/generators/hobo/user_mailer/user_mailer_generator.rb +33 -0
- data/lib/generators/hobo/user_model/USAGE +12 -0
- data/{rails_generators/hobo_user_model/templates/model.rb → lib/generators/hobo/user_model/templates/model_injection.rb.erb} +40 -20
- data/lib/generators/hobo/user_model/user_model_generator.rb +23 -0
- data/lib/generators/hobo/user_resource/user_resource_generator.rb +27 -0
- data/lib/hobo.rb +29 -129
- data/lib/hobo/controller.rb +37 -47
- data/lib/hobo/controller/authentication_support.rb +109 -0
- data/lib/hobo/{model_controller.rb → controller/model.rb} +71 -79
- data/lib/hobo/{user_controller.rb → controller/user.rb} +59 -49
- data/lib/hobo/engine.rb +80 -0
- data/lib/hobo/extensions/action_controller/hobo_methods.rb +44 -0
- data/lib/hobo/extensions/action_mailer/helper.rb +38 -0
- data/lib/{action_view_extensions/helpers → hobo/extensions/action_view}/tag_helper.rb +5 -2
- data/lib/hobo/extensions/action_view/translation_helper.rb +25 -0
- data/lib/hobo/extensions/active_model/name.rb +16 -0
- data/lib/hobo/extensions/active_model/translation.rb +35 -0
- data/lib/{active_record/association_collection.rb → hobo/extensions/active_record/associations/collection.rb} +8 -17
- data/lib/{active_record/association_proxy.rb → hobo/extensions/active_record/associations/proxy.rb} +6 -7
- data/lib/hobo/extensions/active_record/associations/reflection.rb +23 -0
- data/lib/hobo/extensions/active_record/associations/scope.rb +35 -0
- data/lib/hobo/extensions/active_record/hobo_methods.rb +11 -0
- data/lib/hobo/extensions/active_record/permissions.rb +159 -0
- data/lib/hobo/extensions/active_record/relation_with_origin.rb +28 -0
- data/lib/hobo/extensions/array.rb +27 -0
- data/lib/hobo/extensions/enumerable.rb +12 -0
- data/lib/hobo/extensions/i18n.rb +17 -0
- data/lib/hobo/{hobo_helper.rb → helper.rb} +58 -31
- data/lib/hobo/helper/translations.rb +54 -0
- data/lib/hobo/helper/translations/normalizer.rb +39 -0
- data/lib/hobo/model.rb +61 -95
- data/lib/hobo/model/accessible_associations.rb +178 -0
- data/lib/hobo/{find_for.rb → model/find_for.rb} +17 -17
- data/lib/hobo/model/guest.rb +25 -0
- data/lib/hobo/model/include_in_save.rb +55 -0
- data/lib/hobo/model/lifecycles.rb +119 -0
- data/lib/hobo/model/lifecycles/actions.rb +146 -0
- data/lib/hobo/model/lifecycles/creator.rb +74 -0
- data/lib/hobo/model/lifecycles/lifecycle.rb +243 -0
- data/lib/hobo/model/lifecycles/state.rb +22 -0
- data/lib/hobo/model/lifecycles/transition.rb +70 -0
- data/lib/hobo/model/permissions.rb +448 -0
- data/lib/hobo/model/scopes.rb +38 -0
- data/lib/hobo/model/scopes/apply_scopes.rb +21 -0
- data/lib/hobo/model/scopes/automatic_scopes.rb +428 -0
- data/lib/hobo/model/user_base.rb +184 -0
- data/lib/hobo/model/view_hints.rb +123 -0
- data/{rapid_generators → lib/hobo/rapid/generators}/rapid/cards.dryml.erb +2 -2
- data/{rapid_generators → lib/hobo/rapid/generators}/rapid/forms.dryml.erb +3 -3
- data/{rapid_generators → lib/hobo/rapid/generators}/rapid/pages.dryml.erb +38 -51
- data/lib/hobo/rapid/helper.rb +166 -0
- data/{taglibs → lib/hobo/rapid/taglibs}/rapid.dryml +6 -5
- data/{taglibs → lib/hobo/rapid/taglibs}/rapid_core.dryml +286 -118
- data/{taglibs → lib/hobo/rapid/taglibs}/rapid_document_tags.dryml +2 -2
- data/{taglibs → lib/hobo/rapid/taglibs}/rapid_editing.dryml +45 -45
- data/{taglibs → lib/hobo/rapid/taglibs}/rapid_forms.dryml +190 -158
- data/{taglibs → lib/hobo/rapid/taglibs}/rapid_generics.dryml +12 -9
- data/lib/hobo/rapid/taglibs/rapid_i18n.dryml +107 -0
- data/{taglibs → lib/hobo/rapid/taglibs}/rapid_lifecycles.dryml +7 -7
- data/{taglibs → lib/hobo/rapid/taglibs}/rapid_navigation.dryml +15 -15
- data/{taglibs → lib/hobo/rapid/taglibs}/rapid_pages.dryml +37 -36
- data/{taglibs → lib/hobo/rapid/taglibs}/rapid_plus.dryml +107 -43
- data/{taglibs → lib/hobo/rapid/taglibs}/rapid_summary.dryml +28 -57
- data/{taglibs → lib/hobo/rapid/taglibs}/rapid_support.dryml +9 -9
- data/{taglibs → lib/hobo/rapid/taglibs}/rapid_user_pages.dryml +41 -40
- data/lib/hobo/routes.rb +31 -0
- data/{doctest → test/doctest}/hobo/hobo_helper.rdoctest +11 -11
- data/test/irt/generators/admin_subsite.irt +27 -0
- data/test/irt/generators/assets.irt +16 -0
- data/test/irt/generators/controller.irt +6 -0
- data/test/irt/generators/front_controller.irt +30 -0
- data/test/irt/generators/helper.rb +31 -0
- data/test/irt/generators/model.irt +28 -0
- data/test/irt/generators/partials/_account_user_model_tests.rb +21 -0
- data/test/irt/generators/partials/_accounts_users_controller_tests.rb +15 -0
- data/test/irt/generators/partials/_default_user_model_tests.rb +21 -0
- data/test/irt/generators/partials/_default_users_controller_tests.rb +16 -0
- data/test/irt/generators/partials/_house_controller_tests.rb +15 -0
- data/test/irt/generators/partials/_house_model_tests.rb +18 -0
- data/test/irt/generators/partials/_subsite_taglib_admin.rb +4 -0
- data/test/irt/generators/partials/_subsite_taglib_admin_invite_only.rb +3 -0
- data/test/irt/generators/partials/_subsite_taglib_noopt.rb +4 -0
- data/test/irt/generators/partials/_subsite_taglib_variables.rb +27 -0
- data/test/irt/generators/partials/_user_mailer_tests.rb +19 -0
- data/test/irt/generators/rapid.irt +29 -0
- data/test/irt/generators/resource.irt +8 -0
- data/test/irt/generators/subsite.irt +52 -0
- data/test/irt/generators/subsite_taglib.irt +23 -0
- data/test/irt/generators/test_framework.irt +62 -0
- data/test/irt/generators/user_controller.irt +10 -0
- data/test/irt/generators/user_mailer.irt +20 -0
- data/test/irt/generators/user_model.irt +10 -0
- data/test/irt/generators/user_resource.irt +14 -0
- data/test/irt/readme.txt +7 -0
- data/test/permissions/models/models.rb +27 -24
- data/test/permissions/test_permissions.rb +104 -104
- metadata +239 -217
- data/lib/active_record/association_reflection.rb +0 -20
- data/lib/active_record/viewhints_validations_interceptor.rb +0 -9
- data/lib/hobo/accessible_associations.rb +0 -183
- data/lib/hobo/authentication_support.rb +0 -131
- data/lib/hobo/generator.rb +0 -26
- data/lib/hobo/guest.rb +0 -25
- data/lib/hobo/include_in_save.rb +0 -55
- data/lib/hobo/lifecycles.rb +0 -137
- data/lib/hobo/lifecycles/actions.rb +0 -142
- data/lib/hobo/lifecycles/creator.rb +0 -72
- data/lib/hobo/lifecycles/lifecycle.rb +0 -249
- data/lib/hobo/lifecycles/state.rb +0 -22
- data/lib/hobo/lifecycles/transition.rb +0 -70
- data/lib/hobo/model_router.rb +0 -290
- data/lib/hobo/permissions.rb +0 -451
- data/lib/hobo/permissions/associations.rb +0 -175
- data/lib/hobo/rapid_helper.rb +0 -157
- data/lib/hobo/scopes.rb +0 -43
- data/lib/hobo/scopes/apply_scopes.rb +0 -23
- data/lib/hobo/scopes/association_proxy_extensions.rb +0 -62
- data/lib/hobo/scopes/automatic_scopes.rb +0 -421
- data/lib/hobo/scopes/named_scope_extensions.rb +0 -39
- data/lib/hobo/tasks/rails.rb +0 -4
- data/lib/hobo/translations.rb +0 -93
- data/lib/hobo/undefined_access_error.rb +0 -5
- data/lib/hobo/user.rb +0 -182
- data/lib/hobo/view_hints.rb +0 -115
- data/rails/init.rb +0 -10
- data/rails_generators/hobo/USAGE +0 -4
- data/rails_generators/hobo/hobo_generator.rb +0 -53
- data/rails_generators/hobo/templates/application.dryml +0 -1
- data/rails_generators/hobo/templates/initializer.rb +0 -2
- data/rails_generators/hobo_admin_site/USAGE +0 -16
- data/rails_generators/hobo_admin_site/hobo_admin_site_generator.rb +0 -45
- data/rails_generators/hobo_admin_site/templates/admin.css +0 -2
- data/rails_generators/hobo_admin_site/templates/users_index.dryml +0 -5
- data/rails_generators/hobo_front_controller/hobo_front_controller_generator.rb +0 -95
- data/rails_generators/hobo_front_controller/templates/functional_test.rb +0 -8
- data/rails_generators/hobo_front_controller/templates/helper.rb +0 -2
- data/rails_generators/hobo_model/USAGE +0 -25
- data/rails_generators/hobo_model/hobo_model_generator.rb +0 -43
- data/rails_generators/hobo_model/templates/fixtures.yml +0 -6
- data/rails_generators/hobo_model/templates/hints.rb +0 -7
- data/rails_generators/hobo_model/templates/unit_test.rb +0 -8
- data/rails_generators/hobo_model_controller/USAGE +0 -30
- data/rails_generators/hobo_model_controller/hobo_model_controller_generator.rb +0 -46
- data/rails_generators/hobo_model_controller/templates/controller.rb +0 -7
- data/rails_generators/hobo_model_controller/templates/functional_test.rb +0 -8
- data/rails_generators/hobo_model_controller/templates/helper.rb +0 -2
- data/rails_generators/hobo_model_resource/USAGE +0 -38
- data/rails_generators/hobo_model_resource/hobo_model_resource_generator.rb +0 -73
- data/rails_generators/hobo_model_resource/templates/controller.rb +0 -7
- data/rails_generators/hobo_model_resource/templates/functional_test.rb +0 -8
- data/rails_generators/hobo_model_resource/templates/helper.rb +0 -2
- data/rails_generators/hobo_rapid/hobo_rapid_generator.rb +0 -94
- data/rails_generators/hobo_subsite/USAGE +0 -16
- data/rails_generators/hobo_subsite/hobo_subsite_generator.rb +0 -73
- data/rails_generators/hobo_subsite/templates/site_taglib.dryml +0 -13
- data/rails_generators/hobo_user_controller/USAGE +0 -34
- data/rails_generators/hobo_user_controller/hobo_user_controller_generator.rb +0 -65
- data/rails_generators/hobo_user_controller/templates/controller.rb +0 -29
- data/rails_generators/hobo_user_controller/templates/functional_test.rb +0 -8
- data/rails_generators/hobo_user_controller/templates/helper.rb +0 -2
- data/rails_generators/hobo_user_model/USAGE +0 -16
- data/rails_generators/hobo_user_model/hobo_user_model_generator.rb +0 -46
- data/rails_generators/hobo_user_model/templates/fixtures.yml +0 -19
- data/rails_generators/hobo_user_model/templates/mailer.rb +0 -29
- data/rails_generators/hobo_user_model/templates/unit_test.rb +0 -8
- data/script/destroy +0 -14
- data/script/generate +0 -14
- data/taglibs/rapid_translations.dryml +0 -36
- data/tasks/environments.rake +0 -19
- data/tasks/hobo_tasks.rake +0 -58
- data/test/generators/test_generator_helper.rb +0 -29
- data/test/generators/test_helper.rb +0 -1
- data/test/generators/test_hobo_model_controller_generator.rb +0 -56
data/lib/hobo/engine.rb
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
require 'hobo'
|
2
|
+
require 'rails'
|
3
|
+
require 'rails/generators'
|
4
|
+
|
5
|
+
|
6
|
+
module Hobo
|
7
|
+
class Engine < Rails::Engine
|
8
|
+
|
9
|
+
ActiveSupport.on_load(:before_configuration) do
|
10
|
+
h = config.hobo = ActiveSupport::OrderedOptions.new
|
11
|
+
h.app_name = self.class.name.split('::').first.underscore.titleize
|
12
|
+
h.developer_features = Rails.env.in?(["development", "test"])
|
13
|
+
h.routes_path = Pathname.new File.expand_path('config/hobo_routes.rb', Rails.root)
|
14
|
+
h.rapid_generators_path = Pathname.new File.expand_path('lib/hobo/rapid/generators', Hobo.root)
|
15
|
+
h.auto_taglibs_path = Pathname.new File.expand_path('app/views/taglibs/auto', Rails.root)
|
16
|
+
h.read_only_file_system = !!ENV['HEROKU_TYPE']
|
17
|
+
h.show_translation_keys = false
|
18
|
+
h.dryml_only_templates = false
|
19
|
+
end
|
20
|
+
|
21
|
+
ActiveSupport.on_load(:action_controller) do
|
22
|
+
require 'hobo/extensions/action_controller/hobo_methods'
|
23
|
+
require 'hobo/extensions/action_mailer/helper'
|
24
|
+
end
|
25
|
+
|
26
|
+
ActiveSupport.on_load(:active_record) do
|
27
|
+
require 'hobo/extensions/active_record/associations/collection'
|
28
|
+
require 'hobo/extensions/active_record/associations/proxy'
|
29
|
+
require 'hobo/extensions/active_record/associations/reflection'
|
30
|
+
require 'hobo/extensions/active_record/hobo_methods'
|
31
|
+
require 'hobo/extensions/active_record/permissions'
|
32
|
+
require 'hobo/extensions/active_record/associations/scope'
|
33
|
+
require 'hobo/extensions/active_record/relation_with_origin'
|
34
|
+
require 'hobo/extensions/active_model/name'
|
35
|
+
require 'hobo/extensions/active_model/translation'
|
36
|
+
# added legacy namespace for backward compatibility
|
37
|
+
# TODO: remove the following line if Hobo::VERSION > 1.3.x
|
38
|
+
Hobo::ViewHints = Hobo::Model::ViewHints
|
39
|
+
end
|
40
|
+
|
41
|
+
ActiveSupport.on_load(:action_view) do
|
42
|
+
require 'hobo/extensions/action_view/tag_helper'
|
43
|
+
require 'hobo/extensions/action_view/translation_helper'
|
44
|
+
include Hobo::Helper::Translations::Normalizer
|
45
|
+
end
|
46
|
+
|
47
|
+
ActiveSupport.on_load(:before_initialize) do
|
48
|
+
require 'hobo/undefined'
|
49
|
+
HoboFields.never_wrap(Hobo::Undefined)
|
50
|
+
h = config.hobo
|
51
|
+
Dryml::DrymlGenerator.enable([h.rapid_generators_path], h.auto_taglibs_path)
|
52
|
+
end
|
53
|
+
|
54
|
+
initializer 'hobo.i18n' do |app|
|
55
|
+
require 'hobo/extensions/i18n' if app.config.hobo.show_translation_keys
|
56
|
+
end
|
57
|
+
|
58
|
+
initializer 'hobo.routes' do |app|
|
59
|
+
h = app.config.hobo
|
60
|
+
# generate at first boot, so no manual generation is required
|
61
|
+
unless File.exists?(h.routes_path)
|
62
|
+
raise Hobo::Error, "No #{h.routes_path} found!" if h.read_only_file_system
|
63
|
+
Rails::Generators.invoke('hobo:routes', %w[-f -q])
|
64
|
+
end
|
65
|
+
app.routes_reloader.paths << h.routes_path
|
66
|
+
app.config.to_prepare do
|
67
|
+
Rails::Generators.invoke('hobo:routes', %w[-f -q])
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
initializer 'hobo.dryml' do |app|
|
72
|
+
unless app.config.hobo.read_only_file_system
|
73
|
+
app.config.to_prepare do
|
74
|
+
Dryml::DrymlGenerator.run
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
ActionController::Base.class_eval do
|
2
|
+
|
3
|
+
def self.hobo_user_controller
|
4
|
+
include Hobo::Controller::Model
|
5
|
+
include Hobo::Controller::User
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.hobo_model_controller
|
9
|
+
include Hobo::Controller::Model
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.hobo_controller
|
13
|
+
include Hobo::Controller
|
14
|
+
end
|
15
|
+
|
16
|
+
def home_page
|
17
|
+
base_url
|
18
|
+
end
|
19
|
+
|
20
|
+
# moved here from authentication_support.rb for easy overriding
|
21
|
+
# Redirect as appropriate when an access request fails.
|
22
|
+
#
|
23
|
+
# The default action is to redirect to the login screen.
|
24
|
+
#
|
25
|
+
# Override this method in your controllers if you want to have special
|
26
|
+
# behavior in case the user is not authorized
|
27
|
+
# to access the requested action. For example, a popup window might
|
28
|
+
# simply close itself.
|
29
|
+
def access_denied(user_model)
|
30
|
+
respond_to do |accepts|
|
31
|
+
accepts.html do
|
32
|
+
store_location
|
33
|
+
redirect_to(login_url(user_model))
|
34
|
+
end
|
35
|
+
accepts.xml do
|
36
|
+
headers["Status"] = "Unauthorized"
|
37
|
+
headers["WWW-Authenticate"] = %(Basic realm="Web Password")
|
38
|
+
render :text => t("hobo.messages.unauthenticated", :default=>["Couldn't authenticate you"]), :status => '401 Unauthorized'
|
39
|
+
end
|
40
|
+
end
|
41
|
+
false
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Hobo
|
2
|
+
module MailerHelper
|
3
|
+
attr_reader :app_name, :host
|
4
|
+
|
5
|
+
def initialize(*)
|
6
|
+
super
|
7
|
+
@app_name = Rails.application.config.hobo.app_name
|
8
|
+
if self.class.default_url_options.empty?
|
9
|
+
# might be set later in the before filter so we try to set it here
|
10
|
+
d = Rails.application.config.action_mailer.default_url_options
|
11
|
+
self.class.default_url_options = d.dup if d
|
12
|
+
end
|
13
|
+
@host = self.class.default_url_options[:host]
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
module ClassMethods
|
18
|
+
def app_name
|
19
|
+
@app_name ||= Rails.application.config.hobo.app_name
|
20
|
+
end
|
21
|
+
|
22
|
+
def host
|
23
|
+
@host ||= begin
|
24
|
+
if default_url_options[:host].nil?
|
25
|
+
d = Rails.application.config.action_mailer.default_url_options
|
26
|
+
d && d[:host].dup
|
27
|
+
else
|
28
|
+
default_url_options[:host]
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
ActionMailer::Base.send :include, Hobo::MailerHelper
|
38
|
+
ActionMailer::Base.extend Hobo::MailerHelper::ClassMethods
|
@@ -1,7 +1,10 @@
|
|
1
|
-
|
1
|
+
ActionView::Helpers::TagHelper.module_eval do
|
2
|
+
|
2
3
|
alias_method :tag_without_doctype, :tag
|
4
|
+
|
3
5
|
def tag(name, options = nil, open = false, escape = true)
|
4
6
|
open = !scope.xmldoctype if defined?(scope)
|
5
7
|
tag_without_doctype(name, options, open, escape)
|
6
8
|
end
|
7
|
-
|
9
|
+
|
10
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
ActionView::Helpers::TranslationHelper.module_eval do
|
2
|
+
|
3
|
+
# simple wrapper around the translate helper
|
4
|
+
# it implements a dryml <translate> and a <t> tag
|
5
|
+
# Improved security: interpolated variables are escaped
|
6
|
+
# Improved management: when it returns a string it is always html_safe
|
7
|
+
# It assumes the base translation string is html_safe
|
8
|
+
# It removes the <span> tag when the key is missing, because it would mess up
|
9
|
+
# the dryml tags when ht or t is used in some place
|
10
|
+
|
11
|
+
def translate(key, options={})
|
12
|
+
key, options = normalize_args(key, options)
|
13
|
+
translation = I18n.translate(scope_key_by_partial(key), options.merge!(:raise => true))
|
14
|
+
if translation.respond_to?(:html_safe)
|
15
|
+
translation.html_safe
|
16
|
+
else
|
17
|
+
translation
|
18
|
+
end
|
19
|
+
rescue I18n::MissingTranslationData => e
|
20
|
+
keys = I18n.normalize_keys(e.locale, e.key, e.options[:scope]).join('.')
|
21
|
+
"[MISSING: #{keys}]"
|
22
|
+
end
|
23
|
+
alias_method :t, :translate
|
24
|
+
|
25
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
ActiveModel::Name.class_eval do
|
2
|
+
# adds a default pluralization for english
|
3
|
+
# useful to avoid to set a locale 'en' file and avoid
|
4
|
+
# to pass around pluralize calls for 'en' defaults in hobo
|
5
|
+
def human_with_en_pluralization_default(options={})
|
6
|
+
if I18n.locale.to_s.match(/^en/)
|
7
|
+
unless options[:count] == 1 || options[:count].blank?
|
8
|
+
default = ActiveSupport::Inflector.pluralize(@human)
|
9
|
+
options.merge! :default => default
|
10
|
+
end
|
11
|
+
end
|
12
|
+
human_without_en_pluralization_default(options)
|
13
|
+
end
|
14
|
+
alias_method_chain :human, :en_pluralization_default
|
15
|
+
|
16
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
ActiveModel::Translation.class_eval do
|
2
|
+
|
3
|
+
# adds a default pluralization and singularization for english
|
4
|
+
# useful to avoid to set a locale 'en' file and avoid
|
5
|
+
# to pass around pluralize calls for 'en' defaults in hobo
|
6
|
+
def human_attribute_name_with_en_pluralization_default(attribute, options={})
|
7
|
+
if I18n.locale.to_s.match(/^en/)
|
8
|
+
unless options[:count].blank? # skip default if we don't pass any count
|
9
|
+
default = options[:count] == 1 ?
|
10
|
+
attribute.to_s.singularize.humanize : # singularize possible plural attributes
|
11
|
+
attribute.to_s.pluralize.humanize
|
12
|
+
options.merge! :default => default
|
13
|
+
end
|
14
|
+
end
|
15
|
+
human_attribute_name_without_en_pluralization_default(attribute, options)
|
16
|
+
end
|
17
|
+
alias_method_chain :human_attribute_name, :en_pluralization_default
|
18
|
+
|
19
|
+
# Similar to human_name_attributes, this method retrieves the localized help string
|
20
|
+
# of an attribute if it is defined as the key "activemodel.attribute_help.<attribute_name>",
|
21
|
+
# otherwise it returns "".
|
22
|
+
def attribute_help(attribute, options = {})
|
23
|
+
defaults = lookup_ancestors.map do |klass|
|
24
|
+
:"#{self.i18n_scope}.attribute_help.#{klass.to_s.underscore}.#{attribute}"
|
25
|
+
end
|
26
|
+
|
27
|
+
defaults << :"attribute_help.#{attribute}"
|
28
|
+
defaults << options.delete(:default) if options[:default]
|
29
|
+
defaults << ''
|
30
|
+
|
31
|
+
options.reverse_merge! :count => 1, :default => defaults
|
32
|
+
I18n.translate(defaults.shift, options)
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
@@ -2,7 +2,7 @@ module ActiveRecord
|
|
2
2
|
module Associations
|
3
3
|
class AssociationCollection
|
4
4
|
|
5
|
-
include Hobo::Scopes::ApplyScopes
|
5
|
+
include Hobo::Model::Scopes::ApplyScopes
|
6
6
|
|
7
7
|
|
8
8
|
def hobo_association_collection?
|
@@ -25,24 +25,19 @@ module ActiveRecord
|
|
25
25
|
record
|
26
26
|
end
|
27
27
|
|
28
|
-
def member_class
|
29
|
-
proxy_reflection.klass
|
30
|
-
end
|
31
|
-
|
32
28
|
# DO NOT call super here - AssociationProxy's version loads the collection, and that's bad.
|
33
29
|
# TODO: this really belongs in Rails; migrate it there ASAP
|
34
30
|
def respond_to?(*args)
|
35
|
-
|
36
|
-
proxy_respond_to?(*args) || [].respond_to?(*args)
|
31
|
+
proxy_respond_to?(*args) || Array.new.respond_to?(*args)
|
37
32
|
end
|
38
33
|
|
34
|
+
# TODO: send this patch into Rails. There's no reason to load the collection just to find out it acts like an array.
|
39
35
|
def is_a?(klass)
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
end
|
36
|
+
[].is_a?(klass)
|
37
|
+
end
|
38
|
+
|
39
|
+
def member_class
|
40
|
+
proxy_reflection.klass
|
46
41
|
end
|
47
42
|
|
48
43
|
private
|
@@ -57,10 +52,6 @@ module ActiveRecord
|
|
57
52
|
end
|
58
53
|
end
|
59
54
|
|
60
|
-
def has_one_collection?
|
61
|
-
proxy_reflection.macro == :has_one
|
62
|
-
end
|
63
|
-
|
64
55
|
end
|
65
56
|
end
|
66
57
|
end
|
data/lib/{active_record/association_proxy.rb → hobo/extensions/active_record/associations/proxy.rb}
RENAMED
@@ -2,17 +2,16 @@ module ActiveRecord
|
|
2
2
|
module Associations
|
3
3
|
class AssociationProxy #:nodoc:
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
def origin
|
6
|
+
proxy_owner
|
7
|
+
end
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
def origin_attribute
|
10
|
+
proxy_reflection.name
|
11
|
+
end
|
12
12
|
|
13
13
|
private
|
14
14
|
|
15
|
-
|
16
15
|
def raise_on_type_mismatch(record)
|
17
16
|
# Don't complain if the interface type of a polymorphic association doesn't exist
|
18
17
|
klass = @reflection.klass rescue nil
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module ActiveRecord
|
2
|
+
module Reflection
|
3
|
+
class AssociationReflection
|
4
|
+
|
5
|
+
alias_method :association_name, :name
|
6
|
+
|
7
|
+
def klass_with_create_polymorphic_class
|
8
|
+
if options[:polymorphic]
|
9
|
+
begin
|
10
|
+
klass_without_create_polymorphic_class
|
11
|
+
rescue NameError => e
|
12
|
+
Object.class_eval "class #{e.missing_name} < ActiveRecord::Base; set_table_name '#{active_record.name.tableize}'; end"
|
13
|
+
e.missing_name.constantize
|
14
|
+
end
|
15
|
+
else
|
16
|
+
klass_without_create_polymorphic_class
|
17
|
+
end
|
18
|
+
end
|
19
|
+
alias_method_chain :klass, :create_polymorphic_class
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# Add support for :scope => :my_scope to associations
|
2
|
+
|
3
|
+
module ActiveRecord
|
4
|
+
module Associations
|
5
|
+
module ThroughAssociationScope
|
6
|
+
|
7
|
+
def construct_scope_with_scope
|
8
|
+
s = construct_scope_without_scope
|
9
|
+
s[:find][:scope] = @reflection.options[:scope]
|
10
|
+
s
|
11
|
+
end
|
12
|
+
alias_method_chain :construct_scope, :scope
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
module SpawnMethods
|
18
|
+
|
19
|
+
def apply_finder_options_with_scope(options)
|
20
|
+
scopes = []
|
21
|
+
Array.wrap(options.delete(:scope)).each do |s|
|
22
|
+
if s.is_a?(Hash)
|
23
|
+
s.each_pair{|k,v| scopes << [k,v] }
|
24
|
+
else
|
25
|
+
scopes << [s]
|
26
|
+
end
|
27
|
+
end
|
28
|
+
relation = apply_finder_options_without_scope(options)
|
29
|
+
return relation if scopes.empty?
|
30
|
+
scopes.inject(relation) {|r, s| r.send *s }
|
31
|
+
end
|
32
|
+
alias_method_chain :apply_finder_options, :scope
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
ActiveRecord::Base.class_eval do
|
2
|
+
def self.hobo_model
|
3
|
+
include Hobo::Model
|
4
|
+
fields(false) # force hobo_fields to load
|
5
|
+
end
|
6
|
+
def self.hobo_user_model
|
7
|
+
include Hobo::Model
|
8
|
+
include Hobo::Model::UserBase
|
9
|
+
end
|
10
|
+
alias_method :has_hobo_method?, :respond_to_without_attributes?
|
11
|
+
end
|
@@ -0,0 +1,159 @@
|
|
1
|
+
ActiveRecord::Associations::HasManyAssociation.class_eval do
|
2
|
+
|
3
|
+
# Helper - the user acting on the owner (if there is one)
|
4
|
+
def acting_user
|
5
|
+
@owner.acting_user if @owner.is_a?(Hobo::Model)
|
6
|
+
end
|
7
|
+
|
8
|
+
|
9
|
+
def delete_records(records)
|
10
|
+
case @reflection.options[:dependent]
|
11
|
+
when :destroy
|
12
|
+
records.each { |r| r.is_a?(Hobo::Model) ? r.user_destroy(acting_user) : r.destroy }
|
13
|
+
when :delete_all
|
14
|
+
# No destroy permission check if the :delete_all option has been chosen
|
15
|
+
@reflection.klass.delete(records.map(&:id))
|
16
|
+
else
|
17
|
+
nullify_keys(records)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
# Set the fkey used by this has_many to null on the passed records, checking for permission first if both the owner
|
23
|
+
# and record in question are Hobo models
|
24
|
+
def nullify_keys(records)
|
25
|
+
if (user = acting_user)
|
26
|
+
records.each { |r| r.user_update_attributes!(user, @reflection.primary_key_name => nil) if r.is_a?(Hobo::Model) }
|
27
|
+
end
|
28
|
+
|
29
|
+
# Normal ActiveRecord implementatin
|
30
|
+
ids = records.map { |record| record.quoted_id }.join(',')
|
31
|
+
@reflection.klass.update_all(
|
32
|
+
"#{@reflection.primary_key_name} = NULL",
|
33
|
+
"#{@reflection.primary_key_name} = #{@owner.quoted_id} AND #{@reflection.klass.primary_key} IN (#{ids})"
|
34
|
+
)
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
def insert_record(record, force = false, validate = true)
|
39
|
+
set_belongs_to_association_for(record)
|
40
|
+
if (user = acting_user) && record.is_a?(Hobo::Model)
|
41
|
+
if force
|
42
|
+
record.user_save!(user)
|
43
|
+
else
|
44
|
+
record.user_save(user, validate)
|
45
|
+
end
|
46
|
+
else
|
47
|
+
if force
|
48
|
+
record.save!
|
49
|
+
else
|
50
|
+
record.save(:validate => validate)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def viewable_by?(user, field=nil)
|
56
|
+
# view check on an example member record is not supported on associations with conditions
|
57
|
+
return true if @reflection.options[:conditions]
|
58
|
+
new_candidate.viewable_by?(user, field)
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
ActiveRecord::Associations::HasManyThroughAssociation.class_eval do
|
64
|
+
|
65
|
+
def acting_user
|
66
|
+
@owner.acting_user if @owner.is_a?(Hobo::Model)
|
67
|
+
end
|
68
|
+
|
69
|
+
|
70
|
+
def create!(attrs = nil)
|
71
|
+
klass = @reflection.klass
|
72
|
+
user = acting_user if klass < Hobo::Model
|
73
|
+
klass.transaction do
|
74
|
+
object = if attrs
|
75
|
+
klass.send(:with_scope, :create => attrs) { user ? klass.user_create!(user) : klass.create! }
|
76
|
+
else
|
77
|
+
user ? klass.user_create!(user) : klass.create!
|
78
|
+
end
|
79
|
+
self << object
|
80
|
+
object
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
|
85
|
+
def create(attrs = nil)
|
86
|
+
klass = @reflection.klass
|
87
|
+
user = acting_user if klass < Hobo::Model
|
88
|
+
klass.transaction do
|
89
|
+
object = if attrs
|
90
|
+
klass.send(:with_scope, :create => attrs) { user ? klass.user_create(user) : klass.create }
|
91
|
+
else
|
92
|
+
user ? klass.user_create(user) : klass.create
|
93
|
+
end
|
94
|
+
self << object
|
95
|
+
object
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
|
100
|
+
def insert_record(record, force=true, validate=true)
|
101
|
+
user = acting_user if record.is_a?(Hobo::Model)
|
102
|
+
if record.new_record?
|
103
|
+
if force
|
104
|
+
user ? record.user_save!(user) : record.save!
|
105
|
+
else
|
106
|
+
return false unless (user ? record.user_save(user, validate) : record.save(validate))
|
107
|
+
end
|
108
|
+
end
|
109
|
+
klass = @reflection.through_reflection.klass
|
110
|
+
@owner.send(@reflection.through_reflection.name).proxy_target <<
|
111
|
+
klass.send(:with_scope, :create => construct_join_attributes(record)) { user ? klass.user_create!(user) : klass.create! }
|
112
|
+
end
|
113
|
+
|
114
|
+
|
115
|
+
# TODO - add dependent option support
|
116
|
+
def delete_records_with_hobo_permission_check(records)
|
117
|
+
klass = @reflection.through_reflection.klass
|
118
|
+
user = acting_user
|
119
|
+
if user && records.any? { |r|
|
120
|
+
joiner = klass.where(construct_join_attributes(r)).first
|
121
|
+
joiner.is_a?(Hobo::Model) && !joiner.destroyable_by?(user)
|
122
|
+
}
|
123
|
+
raise Hobo::PermissionDeniedError, "#{@owner.class}##{proxy_reflection.name}.destroy"
|
124
|
+
end
|
125
|
+
delete_records_without_hobo_permission_check(records)
|
126
|
+
end
|
127
|
+
alias_method_chain :delete_records, :hobo_permission_check
|
128
|
+
|
129
|
+
end
|
130
|
+
|
131
|
+
ActiveRecord::Associations::AssociationCollection.class_eval do
|
132
|
+
|
133
|
+
# Helper - the user acting on the owner (if there is one)
|
134
|
+
def acting_user
|
135
|
+
@owner.acting_user if @owner.is_a?(Hobo::Model)
|
136
|
+
end
|
137
|
+
|
138
|
+
def create(attrs = {})
|
139
|
+
if attrs.is_a?(Array)
|
140
|
+
attrs.collect { |attr| create(attr) }
|
141
|
+
else
|
142
|
+
create_record(attrs) do |record|
|
143
|
+
yield(record) if block_given?
|
144
|
+
user = acting_user if record.is_a?(Hobo::Model)
|
145
|
+
user ? record.user_save(user) : record.save
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
def create!(attrs = {})
|
151
|
+
create_record(attrs) do |record|
|
152
|
+
yield(record) if block_given?
|
153
|
+
user = acting_user if record.is_a?(Hobo::Model)
|
154
|
+
user ? record.user_save!(user) : record.save!
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
end
|
159
|
+
|