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.
Files changed (278) hide show
  1. data/CHANGES.txt +238 -287
  2. data/Rakefile +14 -31
  3. data/VERSION +1 -0
  4. data/{lib/hobo → app/controllers}/dev_controller.rb +6 -6
  5. data/app/controllers/dryml_support_controller.rb +13 -0
  6. data/{rails_generators/hobo_front_controller/templates → app/views/dev}/summary.dryml +7 -10
  7. data/bin/hobo +12 -144
  8. data/config/initializers/inflections.rb +3 -0
  9. data/config/routes.rb +6 -0
  10. data/{doctest → doctests}/hobo/lifecycles.rdoctest +40 -59
  11. data/{doctest → doctests/hobo}/model.rdoctest +33 -40
  12. data/{doctest → doctests/hobo}/multi_model_forms.rdoctest +15 -19
  13. data/{doctest → doctests/hobo}/scopes.rdoctest +27 -41
  14. data/doctests/prepare_testapp.rb +8 -0
  15. data/hobo.gemspec +26 -199
  16. data/lib/generators/hobo/activation_email.rb +11 -0
  17. data/lib/generators/hobo/admin_subsite/admin_subsite_generator.rb +35 -0
  18. data/lib/generators/hobo/admin_subsite/templates/admin.css +20 -0
  19. data/lib/generators/hobo/admin_subsite/templates/admin_tag_injection.erb +10 -0
  20. data/{rails_generators/hobo_admin_site → lib/generators/hobo/admin_subsite}/templates/application.dryml +0 -0
  21. data/{rails_generators/hobo_admin_site/templates/controller.rb → lib/generators/hobo/admin_subsite/templates/controller.rb.erb} +5 -5
  22. data/lib/generators/hobo/admin_subsite/templates/users_index.dryml +7 -0
  23. data/lib/generators/hobo/assets/assets_generator.rb +18 -0
  24. data/{rails_generators/hobo → lib/generators/hobo/assets}/templates/application.css +0 -0
  25. data/lib/generators/hobo/assets/templates/application.dryml.erb +9 -0
  26. data/{rails_generators/hobo → lib/generators/hobo/assets}/templates/dryml-support.js +2 -2
  27. data/lib/generators/hobo/assets/templates/dryml_taglibs_initializer.rb +1 -0
  28. data/lib/generators/hobo/assets/templates/en_injection.yml +19 -0
  29. data/{rails_generators/hobo → lib/generators/hobo/assets}/templates/guest.rb +1 -1
  30. data/lib/generators/hobo/controller.rb +35 -0
  31. data/lib/generators/hobo/controller/controller_generator.rb +6 -0
  32. data/lib/generators/hobo/controller/templates/controller.rb.erb +7 -0
  33. data/{rails_generators/hobo_front_controller → lib/generators/hobo/front_controller}/USAGE +0 -0
  34. data/lib/generators/hobo/front_controller/front_controller_generator.rb +55 -0
  35. data/{rails_generators/hobo_front_controller/templates/controller.rb → lib/generators/hobo/front_controller/templates/controller.rb.erb} +0 -0
  36. data/{rails_generators/hobo_front_controller → lib/generators/hobo/front_controller}/templates/index.dryml +6 -12
  37. data/lib/generators/hobo/i18n/i18n_generator.rb +35 -0
  38. data/lib/generators/hobo/i18n/templates/app.de.yml +30 -0
  39. data/lib/generators/hobo/i18n/templates/app.en.yml +25 -0
  40. data/lib/generators/hobo/i18n/templates/app.es.yml +31 -0
  41. data/lib/generators/hobo/i18n/templates/app.fr.yml +26 -0
  42. data/lib/generators/hobo/i18n/templates/app.it.yml +28 -0
  43. data/lib/generators/hobo/i18n/templates/app.pt-PT.yml +25 -0
  44. data/lib/generators/hobo/i18n/templates/app.ru.yml +24 -0
  45. data/lib/generators/hobo/i18n/templates/hobo.de.yml +204 -0
  46. data/lib/generators/hobo/i18n/templates/hobo.en.yml +195 -0
  47. data/lib/generators/hobo/i18n/templates/hobo.es.yml +202 -0
  48. data/lib/generators/hobo/i18n/templates/hobo.fr.yml +195 -0
  49. data/lib/generators/hobo/i18n/templates/hobo.it.yml +202 -0
  50. data/lib/generators/hobo/i18n/templates/hobo.pt-PT.yml +196 -0
  51. data/lib/generators/hobo/i18n/templates/hobo.ru.yml +200 -0
  52. data/lib/generators/hobo/invite_only.rb +18 -0
  53. data/lib/generators/hobo/model/USAGE +19 -0
  54. data/lib/generators/hobo/model/model_generator.rb +11 -0
  55. data/{rails_generators/hobo_model/templates/model.rb → lib/generators/hobo/model/templates/model_injection.rb.erb} +0 -2
  56. data/{rails_generators/hobo_rapid → lib/generators/hobo/rapid}/USAGE +0 -0
  57. data/lib/generators/hobo/rapid/rapid_generator.rb +24 -0
  58. data/{rails_generators/hobo_rapid → lib/generators/hobo/rapid}/templates/IE7.js +0 -0
  59. data/{rails_generators/hobo_rapid → lib/generators/hobo/rapid}/templates/blank.gif +0 -0
  60. data/{rails_generators/hobo_rapid → lib/generators/hobo/rapid}/templates/hobo-rapid.css +0 -0
  61. data/{rails_generators/hobo_rapid → lib/generators/hobo/rapid}/templates/hobo-rapid.js +65 -65
  62. data/{rails_generators/hobo_rapid → lib/generators/hobo/rapid}/templates/ie7-recalc.js +21 -21
  63. data/{rails_generators/hobo_rapid → lib/generators/hobo/rapid}/templates/lowpro.js +31 -31
  64. data/{rails_generators/hobo_rapid → lib/generators/hobo/rapid}/templates/reset.css +1 -1
  65. data/lib/generators/hobo/rapid/templates/themes/clean-sidemenu/public/images/100-ACD3E6-DBE1E5-H.png +0 -0
  66. data/lib/generators/hobo/rapid/templates/themes/clean-sidemenu/public/images/100-DBE1E5-FCFEF5-H.png +0 -0
  67. data/lib/generators/hobo/rapid/templates/themes/clean-sidemenu/public/images/300-3B5F87-ACD3E6-H.png +0 -0
  68. data/{rails_generators/hobo_rapid/templates/themes/clean → lib/generators/hobo/rapid/templates/themes/clean-sidemenu}/public/images/spinner.gif +0 -0
  69. data/lib/generators/hobo/rapid/templates/themes/clean-sidemenu/public/stylesheets/clean-sidemenu.css +81 -0
  70. data/lib/generators/hobo/rapid/templates/themes/clean-sidemenu/views/clean-sidemenu.dryml +30 -0
  71. data/{rails_generators/hobo_rapid → lib/generators/hobo/rapid}/templates/themes/clean/public/images/101-3B5F87-ACD3E6.png +0 -0
  72. data/{rails_generators/hobo_rapid → lib/generators/hobo/rapid}/templates/themes/clean/public/images/30-3E547A-242E42.png +0 -0
  73. data/{rails_generators/hobo_rapid → lib/generators/hobo/rapid}/templates/themes/clean/public/images/30-DBE1E5-FCFEF5.png +0 -0
  74. data/{rails_generators/hobo_rapid → lib/generators/hobo/rapid}/templates/themes/clean/public/images/300-ACD3E6-fff.png +0 -0
  75. data/{rails_generators/hobo_rapid → lib/generators/hobo/rapid}/templates/themes/clean/public/images/50-ACD3E6-fff.png +0 -0
  76. data/{rails_generators/hobo_rapid → lib/generators/hobo/rapid}/templates/themes/clean/public/images/fieldbg.gif +0 -0
  77. data/{rails_generators/hobo_rapid → lib/generators/hobo/rapid}/templates/themes/clean/public/images/pencil.png +0 -0
  78. data/{rails_generators/hobo_rapid → lib/generators/hobo/rapid}/templates/themes/clean/public/images/small_close.png +0 -0
  79. data/lib/generators/hobo/rapid/templates/themes/clean/public/images/spinner.gif +0 -0
  80. data/{rails_generators/hobo_rapid → lib/generators/hobo/rapid}/templates/themes/clean/public/stylesheets/clean.css +16 -16
  81. data/{rails_generators/hobo_rapid → lib/generators/hobo/rapid}/templates/themes/clean/public/stylesheets/rapid-ui.css +3 -3
  82. data/{rails_generators/hobo_rapid → lib/generators/hobo/rapid}/templates/themes/clean/views/clean.dryml +1 -1
  83. data/lib/generators/hobo/resource/resource_generator.rb +23 -0
  84. data/lib/generators/hobo/routes/USAGE +9 -0
  85. data/lib/generators/hobo/routes/router.rb +115 -0
  86. data/lib/generators/hobo/routes/routes_generator.rb +40 -0
  87. data/lib/generators/hobo/routes/templates/hobo_routes.rb.erb +33 -0
  88. data/lib/generators/hobo/setup_wizard/USAGE +4 -0
  89. data/lib/generators/hobo/setup_wizard/setup_wizard_generator.rb +274 -0
  90. data/lib/generators/hobo/subsite.rb +48 -0
  91. data/lib/generators/hobo/subsite/subsite_generator.rb +16 -0
  92. data/{rails_generators/hobo_subsite → lib/generators/hobo/subsite}/templates/application.dryml +0 -0
  93. data/{rails_generators/hobo_subsite/templates/controller.rb → lib/generators/hobo/subsite/templates/controller.rb.erb} +1 -1
  94. data/lib/generators/hobo/subsite_taglib/subsite_taglib_generator.rb +16 -0
  95. data/{rails_generators/hobo_admin_site/templates/site_taglib.dryml → lib/generators/hobo/subsite_taglib/templates/taglib.dryml.erb} +9 -10
  96. data/lib/generators/hobo/taglib.rb +12 -0
  97. data/lib/generators/hobo/test_framework/test_framework_generator.rb +72 -0
  98. data/lib/generators/hobo/test_options.rb +19 -0
  99. data/{rails_generators/hobo_user_controller → lib/generators/hobo/user_controller}/templates/accept_invitation.dryml +0 -0
  100. data/lib/generators/hobo/user_controller/templates/controller.rb.erb +31 -0
  101. data/lib/generators/hobo/user_controller/user_controller_generator.rb +25 -0
  102. data/lib/generators/hobo/user_mailer/templates/activation.erb +9 -0
  103. data/{rails_generators/hobo_user_model → lib/generators/hobo/user_mailer}/templates/forgot_password.erb +2 -2
  104. data/{rails_generators/hobo_user_model → lib/generators/hobo/user_mailer}/templates/invite.erb +2 -2
  105. data/lib/generators/hobo/user_mailer/templates/mailer.rb.erb +25 -0
  106. data/lib/generators/hobo/user_mailer/user_mailer_generator.rb +33 -0
  107. data/lib/generators/hobo/user_model/USAGE +12 -0
  108. data/{rails_generators/hobo_user_model/templates/model.rb → lib/generators/hobo/user_model/templates/model_injection.rb.erb} +40 -20
  109. data/lib/generators/hobo/user_model/user_model_generator.rb +23 -0
  110. data/lib/generators/hobo/user_resource/user_resource_generator.rb +27 -0
  111. data/lib/hobo.rb +29 -129
  112. data/lib/hobo/controller.rb +37 -47
  113. data/lib/hobo/controller/authentication_support.rb +109 -0
  114. data/lib/hobo/{model_controller.rb → controller/model.rb} +71 -79
  115. data/lib/hobo/{user_controller.rb → controller/user.rb} +59 -49
  116. data/lib/hobo/engine.rb +80 -0
  117. data/lib/hobo/extensions/action_controller/hobo_methods.rb +44 -0
  118. data/lib/hobo/extensions/action_mailer/helper.rb +38 -0
  119. data/lib/{action_view_extensions/helpers → hobo/extensions/action_view}/tag_helper.rb +5 -2
  120. data/lib/hobo/extensions/action_view/translation_helper.rb +25 -0
  121. data/lib/hobo/extensions/active_model/name.rb +16 -0
  122. data/lib/hobo/extensions/active_model/translation.rb +35 -0
  123. data/lib/{active_record/association_collection.rb → hobo/extensions/active_record/associations/collection.rb} +8 -17
  124. data/lib/{active_record/association_proxy.rb → hobo/extensions/active_record/associations/proxy.rb} +6 -7
  125. data/lib/hobo/extensions/active_record/associations/reflection.rb +23 -0
  126. data/lib/hobo/extensions/active_record/associations/scope.rb +35 -0
  127. data/lib/hobo/extensions/active_record/hobo_methods.rb +11 -0
  128. data/lib/hobo/extensions/active_record/permissions.rb +159 -0
  129. data/lib/hobo/extensions/active_record/relation_with_origin.rb +28 -0
  130. data/lib/hobo/extensions/array.rb +27 -0
  131. data/lib/hobo/extensions/enumerable.rb +12 -0
  132. data/lib/hobo/extensions/i18n.rb +17 -0
  133. data/lib/hobo/{hobo_helper.rb → helper.rb} +58 -31
  134. data/lib/hobo/helper/translations.rb +54 -0
  135. data/lib/hobo/helper/translations/normalizer.rb +39 -0
  136. data/lib/hobo/model.rb +61 -95
  137. data/lib/hobo/model/accessible_associations.rb +178 -0
  138. data/lib/hobo/{find_for.rb → model/find_for.rb} +17 -17
  139. data/lib/hobo/model/guest.rb +25 -0
  140. data/lib/hobo/model/include_in_save.rb +55 -0
  141. data/lib/hobo/model/lifecycles.rb +119 -0
  142. data/lib/hobo/model/lifecycles/actions.rb +146 -0
  143. data/lib/hobo/model/lifecycles/creator.rb +74 -0
  144. data/lib/hobo/model/lifecycles/lifecycle.rb +243 -0
  145. data/lib/hobo/model/lifecycles/state.rb +22 -0
  146. data/lib/hobo/model/lifecycles/transition.rb +70 -0
  147. data/lib/hobo/model/permissions.rb +448 -0
  148. data/lib/hobo/model/scopes.rb +38 -0
  149. data/lib/hobo/model/scopes/apply_scopes.rb +21 -0
  150. data/lib/hobo/model/scopes/automatic_scopes.rb +428 -0
  151. data/lib/hobo/model/user_base.rb +184 -0
  152. data/lib/hobo/model/view_hints.rb +123 -0
  153. data/{rapid_generators → lib/hobo/rapid/generators}/rapid/cards.dryml.erb +2 -2
  154. data/{rapid_generators → lib/hobo/rapid/generators}/rapid/forms.dryml.erb +3 -3
  155. data/{rapid_generators → lib/hobo/rapid/generators}/rapid/pages.dryml.erb +38 -51
  156. data/lib/hobo/rapid/helper.rb +166 -0
  157. data/{taglibs → lib/hobo/rapid/taglibs}/rapid.dryml +6 -5
  158. data/{taglibs → lib/hobo/rapid/taglibs}/rapid_core.dryml +286 -118
  159. data/{taglibs → lib/hobo/rapid/taglibs}/rapid_document_tags.dryml +2 -2
  160. data/{taglibs → lib/hobo/rapid/taglibs}/rapid_editing.dryml +45 -45
  161. data/{taglibs → lib/hobo/rapid/taglibs}/rapid_forms.dryml +190 -158
  162. data/{taglibs → lib/hobo/rapid/taglibs}/rapid_generics.dryml +12 -9
  163. data/lib/hobo/rapid/taglibs/rapid_i18n.dryml +107 -0
  164. data/{taglibs → lib/hobo/rapid/taglibs}/rapid_lifecycles.dryml +7 -7
  165. data/{taglibs → lib/hobo/rapid/taglibs}/rapid_navigation.dryml +15 -15
  166. data/{taglibs → lib/hobo/rapid/taglibs}/rapid_pages.dryml +37 -36
  167. data/{taglibs → lib/hobo/rapid/taglibs}/rapid_plus.dryml +107 -43
  168. data/{taglibs → lib/hobo/rapid/taglibs}/rapid_summary.dryml +28 -57
  169. data/{taglibs → lib/hobo/rapid/taglibs}/rapid_support.dryml +9 -9
  170. data/{taglibs → lib/hobo/rapid/taglibs}/rapid_user_pages.dryml +41 -40
  171. data/lib/hobo/routes.rb +31 -0
  172. data/{doctest → test/doctest}/hobo/hobo_helper.rdoctest +11 -11
  173. data/test/irt/generators/admin_subsite.irt +27 -0
  174. data/test/irt/generators/assets.irt +16 -0
  175. data/test/irt/generators/controller.irt +6 -0
  176. data/test/irt/generators/front_controller.irt +30 -0
  177. data/test/irt/generators/helper.rb +31 -0
  178. data/test/irt/generators/model.irt +28 -0
  179. data/test/irt/generators/partials/_account_user_model_tests.rb +21 -0
  180. data/test/irt/generators/partials/_accounts_users_controller_tests.rb +15 -0
  181. data/test/irt/generators/partials/_default_user_model_tests.rb +21 -0
  182. data/test/irt/generators/partials/_default_users_controller_tests.rb +16 -0
  183. data/test/irt/generators/partials/_house_controller_tests.rb +15 -0
  184. data/test/irt/generators/partials/_house_model_tests.rb +18 -0
  185. data/test/irt/generators/partials/_subsite_taglib_admin.rb +4 -0
  186. data/test/irt/generators/partials/_subsite_taglib_admin_invite_only.rb +3 -0
  187. data/test/irt/generators/partials/_subsite_taglib_noopt.rb +4 -0
  188. data/test/irt/generators/partials/_subsite_taglib_variables.rb +27 -0
  189. data/test/irt/generators/partials/_user_mailer_tests.rb +19 -0
  190. data/test/irt/generators/rapid.irt +29 -0
  191. data/test/irt/generators/resource.irt +8 -0
  192. data/test/irt/generators/subsite.irt +52 -0
  193. data/test/irt/generators/subsite_taglib.irt +23 -0
  194. data/test/irt/generators/test_framework.irt +62 -0
  195. data/test/irt/generators/user_controller.irt +10 -0
  196. data/test/irt/generators/user_mailer.irt +20 -0
  197. data/test/irt/generators/user_model.irt +10 -0
  198. data/test/irt/generators/user_resource.irt +14 -0
  199. data/test/irt/readme.txt +7 -0
  200. data/test/permissions/models/models.rb +27 -24
  201. data/test/permissions/test_permissions.rb +104 -104
  202. metadata +239 -217
  203. data/lib/active_record/association_reflection.rb +0 -20
  204. data/lib/active_record/viewhints_validations_interceptor.rb +0 -9
  205. data/lib/hobo/accessible_associations.rb +0 -183
  206. data/lib/hobo/authentication_support.rb +0 -131
  207. data/lib/hobo/generator.rb +0 -26
  208. data/lib/hobo/guest.rb +0 -25
  209. data/lib/hobo/include_in_save.rb +0 -55
  210. data/lib/hobo/lifecycles.rb +0 -137
  211. data/lib/hobo/lifecycles/actions.rb +0 -142
  212. data/lib/hobo/lifecycles/creator.rb +0 -72
  213. data/lib/hobo/lifecycles/lifecycle.rb +0 -249
  214. data/lib/hobo/lifecycles/state.rb +0 -22
  215. data/lib/hobo/lifecycles/transition.rb +0 -70
  216. data/lib/hobo/model_router.rb +0 -290
  217. data/lib/hobo/permissions.rb +0 -451
  218. data/lib/hobo/permissions/associations.rb +0 -175
  219. data/lib/hobo/rapid_helper.rb +0 -157
  220. data/lib/hobo/scopes.rb +0 -43
  221. data/lib/hobo/scopes/apply_scopes.rb +0 -23
  222. data/lib/hobo/scopes/association_proxy_extensions.rb +0 -62
  223. data/lib/hobo/scopes/automatic_scopes.rb +0 -421
  224. data/lib/hobo/scopes/named_scope_extensions.rb +0 -39
  225. data/lib/hobo/tasks/rails.rb +0 -4
  226. data/lib/hobo/translations.rb +0 -93
  227. data/lib/hobo/undefined_access_error.rb +0 -5
  228. data/lib/hobo/user.rb +0 -182
  229. data/lib/hobo/view_hints.rb +0 -115
  230. data/rails/init.rb +0 -10
  231. data/rails_generators/hobo/USAGE +0 -4
  232. data/rails_generators/hobo/hobo_generator.rb +0 -53
  233. data/rails_generators/hobo/templates/application.dryml +0 -1
  234. data/rails_generators/hobo/templates/initializer.rb +0 -2
  235. data/rails_generators/hobo_admin_site/USAGE +0 -16
  236. data/rails_generators/hobo_admin_site/hobo_admin_site_generator.rb +0 -45
  237. data/rails_generators/hobo_admin_site/templates/admin.css +0 -2
  238. data/rails_generators/hobo_admin_site/templates/users_index.dryml +0 -5
  239. data/rails_generators/hobo_front_controller/hobo_front_controller_generator.rb +0 -95
  240. data/rails_generators/hobo_front_controller/templates/functional_test.rb +0 -8
  241. data/rails_generators/hobo_front_controller/templates/helper.rb +0 -2
  242. data/rails_generators/hobo_model/USAGE +0 -25
  243. data/rails_generators/hobo_model/hobo_model_generator.rb +0 -43
  244. data/rails_generators/hobo_model/templates/fixtures.yml +0 -6
  245. data/rails_generators/hobo_model/templates/hints.rb +0 -7
  246. data/rails_generators/hobo_model/templates/unit_test.rb +0 -8
  247. data/rails_generators/hobo_model_controller/USAGE +0 -30
  248. data/rails_generators/hobo_model_controller/hobo_model_controller_generator.rb +0 -46
  249. data/rails_generators/hobo_model_controller/templates/controller.rb +0 -7
  250. data/rails_generators/hobo_model_controller/templates/functional_test.rb +0 -8
  251. data/rails_generators/hobo_model_controller/templates/helper.rb +0 -2
  252. data/rails_generators/hobo_model_resource/USAGE +0 -38
  253. data/rails_generators/hobo_model_resource/hobo_model_resource_generator.rb +0 -73
  254. data/rails_generators/hobo_model_resource/templates/controller.rb +0 -7
  255. data/rails_generators/hobo_model_resource/templates/functional_test.rb +0 -8
  256. data/rails_generators/hobo_model_resource/templates/helper.rb +0 -2
  257. data/rails_generators/hobo_rapid/hobo_rapid_generator.rb +0 -94
  258. data/rails_generators/hobo_subsite/USAGE +0 -16
  259. data/rails_generators/hobo_subsite/hobo_subsite_generator.rb +0 -73
  260. data/rails_generators/hobo_subsite/templates/site_taglib.dryml +0 -13
  261. data/rails_generators/hobo_user_controller/USAGE +0 -34
  262. data/rails_generators/hobo_user_controller/hobo_user_controller_generator.rb +0 -65
  263. data/rails_generators/hobo_user_controller/templates/controller.rb +0 -29
  264. data/rails_generators/hobo_user_controller/templates/functional_test.rb +0 -8
  265. data/rails_generators/hobo_user_controller/templates/helper.rb +0 -2
  266. data/rails_generators/hobo_user_model/USAGE +0 -16
  267. data/rails_generators/hobo_user_model/hobo_user_model_generator.rb +0 -46
  268. data/rails_generators/hobo_user_model/templates/fixtures.yml +0 -19
  269. data/rails_generators/hobo_user_model/templates/mailer.rb +0 -29
  270. data/rails_generators/hobo_user_model/templates/unit_test.rb +0 -8
  271. data/script/destroy +0 -14
  272. data/script/generate +0 -14
  273. data/taglibs/rapid_translations.dryml +0 -36
  274. data/tasks/environments.rake +0 -19
  275. data/tasks/hobo_tasks.rake +0 -58
  276. data/test/generators/test_generator_helper.rb +0 -29
  277. data/test/generators/test_helper.rb +0 -1
  278. data/test/generators/test_hobo_model_controller_generator.rb +0 -56
@@ -1,6 +1,6 @@
1
1
  module Hobo
2
-
3
- module ModelController
2
+ module Controller
3
+ module Model
4
4
 
5
5
  include Hobo::Controller
6
6
 
@@ -18,7 +18,7 @@ module Hobo
18
18
  base.class_eval do
19
19
  @auto_actions ||= {}
20
20
 
21
- inheriting_cattr_reader :web_methods => [], :show_actions => [], :index_actions => [],
21
+ inheriting_cattr_reader :web_methods => [], :show_actions => [], :index_actions => [],
22
22
  :owner_actions => {}
23
23
 
24
24
  extend ClassMethods
@@ -27,13 +27,13 @@ module Hobo
27
27
  helper_method :model, :current_user
28
28
  before_filter :set_no_cache_headers
29
29
 
30
- rescue_from ActiveRecord::RecordNotFound, :with => :not_found
30
+ rescue_from ActiveRecord::RecordNotFound, :with => :not_found unless Rails.env.development?
31
31
 
32
32
  rescue_from Hobo::PermissionDeniedError, :with => :permission_denied
33
- rescue_from Hobo::Lifecycles::LifecycleKeyError, :with => :permission_denied
33
+ rescue_from Hobo::Model::Lifecycles::LifecycleKeyError, :with => :permission_denied
34
34
 
35
35
  alias_method_chain :render, :hobo_model
36
-
36
+
37
37
  end
38
38
  register_controller(base)
39
39
 
@@ -41,49 +41,54 @@ module Hobo
41
41
  end
42
42
 
43
43
  end
44
-
45
-
44
+
45
+
46
46
  def self.register_controller(controller)
47
47
  @controller_names ||= Set.new
48
48
  @controller_names << controller.name
49
49
  end
50
-
51
-
50
+
51
+
52
52
  def self.all_controllers(subsite=nil, force=false)
53
+ controller_dirs = ["#{Rails.root}/app/controllers"] + Hobo.engines.map { |e| "#{e}/app/controllers" }
54
+
53
55
  # Load every controller in app/controllers/<subsite>...
54
56
  @controllers_loaded ||= {}
55
57
  if force || !@controllers_loaded[subsite]
56
- dir = "#{RAILS_ROOT}/app/controllers#{'/' + subsite if subsite}"
57
- Dir.entries(dir).each do |f|
58
- if f =~ /^[a-zA-Z_][a-zA-Z0-9_]*_controller\.rb$/
59
- name = f.remove(/.rb$/).camelize
60
- name = "#{subsite.camelize}::#{name}" if subsite
61
- name.constantize
58
+ controller_dirs.each do |controller_dir|
59
+ dir = "#{controller_dir}#{'/' + subsite if subsite}"
60
+ if File.directory?(dir)
61
+ Dir.entries(dir).each do |f|
62
+ if f =~ /^[a-zA-Z_][a-zA-Z0-9_]*_controller\.rb$/
63
+ name = f.remove(/.rb$/).camelize
64
+ name = "#{subsite.camelize}::#{name}" if subsite
65
+ name.constantize
66
+ end
67
+ end
62
68
  end
63
69
  end
64
70
  @controllers_loaded[subsite] = true
65
71
  end
66
-
72
+
67
73
  # ...but only return the ones that registered themselves
68
74
  names = (@controller_names || []).select { |n| subsite ? n =~ /^#{subsite.camelize}::/ : n !~ /::/ }
69
-
75
+
70
76
  names.map do |name|
71
77
  name.safe_constantize || (@controller_names.delete name; nil)
72
78
  end.compact
73
79
  end
74
-
75
80
 
76
81
 
77
82
  module ClassMethods
78
83
 
79
84
  attr_writer :model
80
-
85
+
81
86
  def model_name
82
- name.demodulize.remove(/Controller$/).singularize
87
+ model.name.underscore
83
88
  end
84
-
89
+
85
90
  def model
86
- @model ||= model_name.constantize
91
+ @model ||= controller_name.camelcase.singularize.constantize
87
92
  end
88
93
 
89
94
 
@@ -227,8 +232,8 @@ module Hobo
227
232
  end
228
233
  end
229
234
  end
230
-
231
-
235
+
236
+
232
237
  def creator_page_action(name, options={}, &block)
233
238
  define_method(name) do
234
239
  creator_page_action name, options, &block
@@ -241,7 +246,7 @@ module Hobo
241
246
  do_creator_action name, options, &block
242
247
  end
243
248
  end
244
-
249
+
245
250
 
246
251
  def transtion_page_action(name, options={}, &block)
247
252
  define_method(name) do
@@ -256,7 +261,7 @@ module Hobo
256
261
  end
257
262
  end
258
263
 
259
-
264
+
260
265
  def auto_actions_for(owner, actions)
261
266
  name = model.reflections[owner].macro == :has_many ? owner.to_s.singularize : owner
262
267
 
@@ -355,17 +360,16 @@ module Hobo
355
360
 
356
361
  def re_render_form(default_action=nil)
357
362
  if params[:page_path]
358
- @invalid_record = this
359
- controller, view = Controller.controller_and_view_for(params[:page_path])
360
- view = default_action if view == Dryml::EMPTY_PAGE
363
+ @invalid_record = this
364
+ controller, action = controller_action_from_page_path
361
365
 
362
366
  # Hack fix for Bug 477. See also bug 489.
363
- if self.class.name == "#{controller.camelize}Controller" && view == "index"
367
+ if self.class.name == "#{controller.camelize}Controller" && action == "index"
364
368
  params['action'] = 'index'
365
369
  self.action_name = 'index'
366
370
  index
367
371
  else
368
- render :template => "#{controller}/#{view}"
372
+ render :template => "#{controller}/#{action}"
369
373
  end
370
374
  else
371
375
  render :action => default_action
@@ -396,19 +400,8 @@ module Hobo
396
400
  method = @this.class.view_hints.parent
397
401
  method ? @this.send(method) : nil
398
402
  end
399
-
400
-
401
- def url_for_page_path
402
- controller, view = Controller.controller_and_view_for(params[:page_path])
403
- url_for :controller => controller, :action => view
404
- end
405
403
 
406
- # TODO: Get rid of this joke of an idea that fails miserably if you open another browser window.
407
- def previous_page_path
408
- session[:previous_page_path]
409
- end
410
-
411
-
404
+
412
405
  def redirect_after_submit(*args)
413
406
  options = args.extract_options!
414
407
  o = options[:redirect]
@@ -425,7 +418,7 @@ module Hobo
425
418
  redirect_to destination_after_submit(*args)
426
419
  end
427
420
  end
428
-
421
+
429
422
 
430
423
  def response_block(&b)
431
424
  if b
@@ -451,18 +444,17 @@ module Hobo
451
444
  do_pagination = options.delete(:paginate) && finder.respond_to?(:paginate)
452
445
  finder = Array.wrap(options.delete(:scope)).inject(finder) { |a, v| a.send(*Array.wrap(v).flatten) }
453
446
 
454
- options[:order] = :default unless options[:order] || finder.send(:scope, :find)._?[:order]
447
+ options[:order] = finder.default_order unless options[:order] || finder.try.order_values.present?
455
448
 
456
449
  if do_pagination
457
450
  options.reverse_merge!(:page => params[:page] || 1)
458
- options[:order] = :created_at if options[:order] == :default
459
451
  finder.paginate(options)
460
452
  else
461
453
  finder.all(options.except(*WILL_PAGINATE_OPTIONS))
462
454
  end
463
455
  end
464
-
465
-
456
+
457
+
466
458
  def find_owner_and_association(owner_association)
467
459
  owner_name = name_of_auto_action_for(owner_association)
468
460
  refl = model.reflections[owner_association]
@@ -484,8 +476,8 @@ module Hobo
484
476
  self.this = find_or_paginate(finder, options)
485
477
  response_block(&b)
486
478
  end
487
-
488
-
479
+
480
+
489
481
  def hobo_index_for(owner, *args, &b)
490
482
  options = args.extract_options!
491
483
  owner, association = find_owner_and_association(owner)
@@ -506,8 +498,8 @@ module Hobo
506
498
  self.this = record || model.user_new(current_user)
507
499
  response_block(&b)
508
500
  end
509
-
510
-
501
+
502
+
511
503
  def hobo_new_for(owner, record=nil, &b)
512
504
  owner, association = find_owner_and_association(owner)
513
505
  self.this = record || association.user_new(current_user)
@@ -517,7 +509,7 @@ module Hobo
517
509
 
518
510
  def hobo_create(*args, &b)
519
511
  options = args.extract_options!
520
- attributes = options[:attributes] || attribute_parameters || {}
512
+ attributes = options[:attributes] || attribute_parameters || {}
521
513
  if self.this ||= args.first
522
514
  this.user_update_attributes(current_user, attributes)
523
515
  else
@@ -526,8 +518,8 @@ module Hobo
526
518
  end
527
519
  create_response(:new, options, &b)
528
520
  end
529
-
530
-
521
+
522
+
531
523
  def hobo_create_for(owner_association, *args, &b)
532
524
  options = args.extract_options!
533
525
  owner, association = find_owner_and_association(owner_association)
@@ -538,7 +530,7 @@ module Hobo
538
530
  self.this = association.new(attributes)
539
531
  this.save
540
532
  end
541
- create_response(:"new_for_#{name_of_auto_action_for(owner_association)}", options, &b)
533
+ create_response(:"new_for_#{name_of_auto_action_for(owner_association)}", options, &b)
542
534
  end
543
535
 
544
536
 
@@ -552,20 +544,20 @@ module Hobo
552
544
  create_model = type_param ? type_param.constantize : model
553
545
  create_model.user_new(current_user, attributes)
554
546
  end
555
-
556
-
547
+
548
+
557
549
  def subtype_for_create
558
- model.has_inheritance_column? && (t = params['type']) && t.in?(model.send(:subclasses).*.name) and
550
+ model.has_inheritance_column? && (t = params['type']) && t.in?(model.send(:descendants).*.name) and
559
551
  t
560
552
  end
561
-
553
+
562
554
  def flash_notice(message)
563
555
  flash[:notice] = message unless request.xhr?
564
556
  end
565
557
 
566
558
 
567
559
  def create_response(new_action, options={}, &b)
568
- flash_notice (ht( :"#{@this.class.name.pluralize.underscore}.messages.create.success", :default=>["The #{@this.class.view_hints.model_name.downcase} was created successfully"])) if valid?
560
+ flash_notice (ht( :"#{@this.class.to_s.underscore}.messages.create.success", :default=>["The #{@this.class.model_name.human} was created successfully"])) if valid?
569
561
 
570
562
  response_block(&b) or
571
563
  if valid?
@@ -579,7 +571,7 @@ module Hobo
579
571
  errors = this.errors.full_messages.join("\n")
580
572
  wants.html { re_render_form(new_action) }
581
573
  wants.js { render(:status => 500,
582
- :text => ht( :"#{this.class.name.pluralize.underscore}.messages.create.error", :errors=>errors,:default=>["Couldn't create the #{this.class.name.titleize.downcase}.\n #{errors}"])
574
+ :text => ht( :"#{this.class.to_s.underscore}.messages.create.error", :errors=>errors,:default=>["Couldn't create the #{this.class.name.titleize.downcase}.\n #{errors}"])
583
575
  )}
584
576
  end
585
577
  end
@@ -590,9 +582,9 @@ module Hobo
590
582
  options = args.extract_options!
591
583
 
592
584
  self.this ||= args.first || find_instance
593
- changes = options[:attributes] || attribute_parameters or raise RuntimeError, ht(:"hobo.messages.update.no_attribute_error", :default=>["No update specified in params"])
594
-
595
- if this.user_update_attributes(current_user, changes)
585
+ changes = options[:attributes] || attribute_parameters or raise RuntimeError, t("hobo.messages.update.no_attribute_error", :default=>["No update specified in params"])
586
+
587
+ if this.user_update_attributes(current_user, changes)
596
588
  # Ensure current_user isn't out of date
597
589
  @current_user = @this if @this == current_user
598
590
  end
@@ -603,8 +595,8 @@ module Hobo
603
595
 
604
596
 
605
597
  def update_response(in_place_edit_field=nil, options={}, &b)
606
-
607
- flash_notice (ht(:"#{@this.class.name.pluralize.underscore}.messages.update.success", :default=>["Changes to the #{@this.class.view_hints.model_name.downcase} were saved"])) if valid?
598
+
599
+ flash_notice (ht(:"#{@this.class.to_s.underscore}.messages.update.success", :default=>["Changes to the #{@this.class.model_name.human} were saved"])) if valid?
608
600
 
609
601
  response_block(&b) or
610
602
  if valid?
@@ -631,7 +623,7 @@ module Hobo
631
623
  errors = @this.errors.full_messages.join("\n")
632
624
  wants.html { re_render_form(:edit) }
633
625
  wants.js { render(:status => 500,
634
- :text => ht(:"#{@this.class.name.pluralize.underscore}.messages.update.error",:default=>["There was a problem with that change.\n#{errors}"], :errors=>errors)
626
+ :text => ht(:"#{@this.class.to_s.underscore}.messages.update.error",:default=>["There was a problem with that change.\n#{errors}"], :errors=>errors)
635
627
  ) }
636
628
  end
637
629
  end
@@ -642,7 +634,7 @@ module Hobo
642
634
  options = args.extract_options!
643
635
  self.this ||= args.first || find_instance
644
636
  this.user_destroy(current_user)
645
- flash_notice ht( :"#{model.name.pluralize.underscore}.messages.destroy.success", :default=>["The #{model.name.titleize.downcase} was deleted"])
637
+ flash_notice ht( :"#{model.to_s.underscore}.messages.destroy.success", :default=>["The #{model.name.titleize.downcase} was deleted"])
646
638
  destroy_response(options, &b)
647
639
  end
648
640
 
@@ -683,7 +675,7 @@ module Hobo
683
675
  errors = this.errors.full_messages.join("\n")
684
676
  wants.html { re_render_form(name) }
685
677
  wants.js { render(:status => 500,
686
- :text => ht(:"#{@this.class.name.pluralize.underscore}.messages.creator.error", :default=>["Couldn't do creator #{name}.\n#{errors}"], :name=>name, :errors=>errors)
678
+ :text => ht(:"#{@this.class.to_s.underscore}.messages.creator.error", :default=>["Couldn't do creator #{name}.\n#{errors}"], :name=>name, :errors=>errors)
687
679
  )}
688
680
  end
689
681
  end
@@ -725,7 +717,7 @@ module Hobo
725
717
  errors = this.errors.full_messages.join("\n")
726
718
  wants.html { re_render_form(name) }
727
719
  wants.js { render(:status => 500,
728
- :text => ht(:"#{@this.class.name.pluralize.underscore}.messages.transition.error", :default=>["Couldn't do transition #{name}.\n#{errors}"], :name=>name, :errors=>errors)
720
+ :text => ht(:"#{@this.class.to_s.underscore}.messages.transition.error", :default=>["Couldn't do transition #{name}.\n#{errors}"], :name=>name, :errors=>errors)
729
721
  )}
730
722
  end
731
723
  end
@@ -736,7 +728,7 @@ module Hobo
736
728
 
737
729
  def hobo_completions(attribute, finder, options={})
738
730
  options = options.reverse_merge(:limit => 10, :param => :query, :query_scope => "#{attribute}_contains")
739
- finder = finder.limit(options[:limit]) unless finder.send(:scope, :find, :limit)
731
+ finder = finder.limit(options[:limit]) unless finder.try.limit_value
740
732
 
741
733
  begin
742
734
  finder = finder.send(options[:query_scope], params[options[:param]])
@@ -747,7 +739,7 @@ module Hobo
747
739
  finder2 = finder.send(qscope, params[options[:param]])
748
740
  items += finder2.find(:all).select { |r| r.viewable_by?(current_user) }
749
741
  end
750
- end
742
+ end
751
743
  render :text => "<ul>\n" + items.map {|i| "<li>#{i.send(attribute)}</li>\n"}.join + "</ul>"
752
744
  end
753
745
 
@@ -774,18 +766,18 @@ module Hobo
774
766
  logger.info "Hobo: Permission Denied!"
775
767
  @permission_error = error
776
768
  if self.class.superclass.method_defined?("permission_denied")
777
- self.class.superclass.instance_method(:permission_denied).bind(self).call(error)
769
+ super
778
770
  else
779
771
  respond_to do |wants|
780
772
  wants.html do
781
- if render_tag("permission-denied-page", { }, :status => 403)
773
+ if render :permission_denied, :status => 403
782
774
  # job done
783
775
  else
784
- render :text => ht(:"hobo.messages.permission_denied", :default=>["Permission Denied"]), :status => 403
776
+ render :text => t("hobo.messages.permission_denied", :default=>["Permission Denied"]), :status => 403
785
777
  end
786
778
  end
787
779
  wants.js do
788
- render :text => ht(:"hobo.messages.permission_denied", :default=>["Permission Denied"]), :status => 403
780
+ render :text => t("hobo.messages.permission_denied", :default=>["Permission Denied"]), :status => 403
789
781
  end
790
782
  end
791
783
  end
@@ -840,5 +832,5 @@ module Hobo
840
832
  end
841
833
 
842
834
  end
843
-
835
+ end
844
836
  end
@@ -1,39 +1,38 @@
1
1
  module Hobo
2
-
3
- module UserController
2
+ module Controller
3
+ module User
4
4
 
5
5
  class << self
6
6
  def included(base)
7
7
  base.class_eval do
8
8
  extend ClassMethods
9
-
9
+
10
10
  class << self
11
11
  alias_method_chain :available_auto_actions, :user_actions
12
12
  alias_method_chain :def_auto_actions, :user_actions
13
13
  end
14
-
15
- filter_parameter_logging "password"
16
- skip_before_filter :login_required, :only => [:login, :signup, :do_signup, :forgot_password, :reset_password,
17
- :do_reset_password, :accept_invitation, :do_accept_invitation]
14
+
15
+ skip_before_filter :login_required, :only => [:login, :signup, :forgot_password, :reset_password, :do_reset_password,
16
+ :accept_invitation, :do_accept_invitation]
18
17
 
19
18
  include_taglib "rapid_user_pages", :plugin => "hobo"
20
19
 
21
20
  alias_method_chain :hobo_update, :account_flash
22
21
  end
23
-
22
+
24
23
  end
25
24
 
26
-
25
+
27
26
  end
28
-
27
+
29
28
  module ClassMethods
30
29
 
31
30
  def available_auto_actions_with_user_actions
32
- available_auto_actions_without_user_actions +
31
+ available_auto_actions_without_user_actions +
33
32
  [:login, :logout, :forgot_password, :reset_password, :account]
34
33
  end
35
34
 
36
-
35
+
37
36
  def def_auto_actions_with_user_actions
38
37
  def_auto_actions_without_user_actions
39
38
 
@@ -53,7 +52,7 @@ module Hobo
53
52
 
54
53
  private
55
54
 
56
- def hobo_login(options={})
55
+ def hobo_login(options={}, &block)
57
56
  if logged_in?
58
57
  respond_to do |wants|
59
58
  wants.html { redirect_to home_page }
@@ -62,9 +61,8 @@ module Hobo
62
61
  return
63
62
  end
64
63
 
65
- login_attr = model.login_attribute.to_s.titleize.downcase
66
- options.reverse_merge!(:success_notice => ht(:"users.messages.login.success", :default=>["You have logged in."]),
67
- :failure_notice => ht(:"users.messages.login.error", :login=>login_attr, :default=>["You did not provide a valid #{login_attr} and password."]))
64
+ login_attr = model.human_attribute_name(model.login_attribute)
65
+ options.reverse_merge!(:failure_notice => ht(:"#{model.to_s.underscore}.messages.login.error", :login=>login_attr, :default=>["You did not provide a valid #{login_attr} and password."]))
68
66
 
69
67
  if request.post?
70
68
  user = model.authenticate(params[:login], params[:password])
@@ -72,33 +70,7 @@ module Hobo
72
70
  flash[:error] = options[:failure_notice]
73
71
  hobo_ajax_response if request.xhr? && !performed?
74
72
  else
75
- old_user = current_user
76
- self.current_user = user
77
-
78
- yield if block_given?
79
-
80
- if !user.account_active?
81
- # account not activate - cancel this login
82
- self.current_user = old_user
83
- unless performed?
84
- respond_to do |wants|
85
- wants.html {render :action => :account_disabled}
86
- wants.js {hobo_ajax_response}
87
- end
88
- end
89
- else
90
- if params[:remember_me].present?
91
- current_user.remember_me
92
- create_auth_cookie
93
- end
94
- flash[:notice] ||= options[:success_notice]
95
- unless performed?
96
- respond_to do |wants|
97
- wants.html {redirect_back_or_default(options[:redirect_to] || home_page) }
98
- wants.js {hobo_ajax_response}
99
- end
100
- end
101
- end
73
+ self.sign_user_in(user, options){ yield if block_given?}
102
74
  end
103
75
  end
104
76
  end
@@ -114,7 +86,7 @@ module Hobo
114
86
  def hobo_do_signup(&b)
115
87
  do_creator_action(:signup) do
116
88
  if valid?
117
- flash[:notice] = ht(:"users.messages.signup.success", :default=>["Thanks for signing up!"])
89
+ flash[:notice] = ht(:"#{model.to_s.underscore}.messages.signup.success", :default=>["Thanks for signing up!"])
118
90
  end
119
91
  response_block(&b) or if valid?
120
92
  self.current_user = this if this.account_active?
@@ -128,7 +100,7 @@ module Hobo
128
100
 
129
101
 
130
102
  def hobo_logout(options={})
131
- options = options.reverse_merge(:notice => ht(:"users.messages.logout", :default=>["You have logged out."]),
103
+ options = options.reverse_merge(:notice => ht(:"#{model.to_s.underscore}.messages.logout", :default=>["You have logged out."]),
132
104
  :redirect_to => base_url)
133
105
 
134
106
  logout_current_user
@@ -145,7 +117,7 @@ module Hobo
145
117
  user.lifecycle.request_password_reset!(:nobody)
146
118
  end
147
119
  respond_to do |wants|
148
- wants.html { render_tag :forgot_password_email_sent_page }
120
+ wants.html { render :forgot_password_email_sent }
149
121
  wants.js { hobo_ajax_response}
150
122
  end
151
123
  end
@@ -156,7 +128,7 @@ module Hobo
156
128
  do_transition_action :reset_password do
157
129
  response_block(&b) or if valid?
158
130
  self.current_user = this
159
- flash[:notice] = ht(:"users.messages.reset_password", :default=>["Your password has been reset"])
131
+ flash[:notice] = ht(:"#{model.to_s.underscore}.messages.reset_password", :default=>["Your password has been reset"])
160
132
  respond_to do |wants|
161
133
  wants.html { redirect_to(home_page) }
162
134
  wants.js { hobo_ajax_response }
@@ -168,7 +140,7 @@ module Hobo
168
140
 
169
141
  def hobo_update_with_account_flash(*args)
170
142
  hobo_update_without_account_flash(*args) do
171
- flash[:notice] = ht(:"users.messages.update.success", :default=>["Changes to your account were saved"]) if valid? && @this == current_user
143
+ flash[:notice] = ht(:"#{model.to_s.underscore}.messages.update.success", :default=>["Changes to your account were saved"]) if valid? && @this == current_user
172
144
  yield if block_given?
173
145
  end
174
146
  end
@@ -184,6 +156,44 @@ module Hobo
184
156
  end
185
157
  end
186
158
 
187
- end
159
+ protected
160
+ # If you are authenticating user on your own call this method -
161
+ # hobo will remember signed-in user this way. Arguments:
162
+ # user - user that you want to sign in
163
+ # options - hash with messages (:success_notice, :redirect_to)
164
+ # block - (optional) will be called after assigning current_user
165
+ def sign_user_in(user, options={}, &block)
166
+ options.reverse_merge!(:success_notice => ht(:"#{model.to_s.underscore}.messages.login.success", :default=>["You have logged in."]))
167
+
168
+ old_user = current_user
169
+ self.current_user = user
170
+
171
+ yield if block_given?
188
172
 
173
+ if !user.account_active?
174
+ # account not activate - cancel this login
175
+ self.current_user = old_user
176
+ unless performed?
177
+ respond_to do |wants|
178
+ wants.html {render :action => :account_disabled}
179
+ wants.js {hobo_ajax_response}
180
+ end
181
+ end
182
+ else
183
+ if params[:remember_me].present?
184
+ current_user.remember_me
185
+ create_auth_cookie
186
+ end
187
+ flash[:notice] ||= options[:success_notice]
188
+ unless performed?
189
+ respond_to do |wants|
190
+ wants.html {redirect_back_or_default(options[:redirect_to] || home_page) }
191
+ wants.js {hobo_ajax_response}
192
+ end
193
+ end
194
+ end
195
+ end
196
+
197
+ end
198
+ end
189
199
  end