hobo 0.7.5 → 0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (212) hide show
  1. data/{hobo_files/plugin/CHANGES.txt → CHANGES.txt} +391 -0
  2. data/Manifest +146 -0
  3. data/{hobo_files/plugin/README → README} +0 -0
  4. data/bin/hobo +13 -26
  5. data/dryml_generators/rapid/cards.dryml.erb +55 -0
  6. data/dryml_generators/rapid/forms.dryml.erb +43 -0
  7. data/dryml_generators/rapid/pages.dryml.erb +284 -0
  8. data/hobo.gemspec +168 -0
  9. data/init.rb +9 -0
  10. data/lib/action_view_extensions/helpers/tag_helper.rb +7 -0
  11. data/lib/active_record/association_collection.rb +54 -0
  12. data/{hobo_files/plugin/lib → lib}/active_record/association_proxy.rb +12 -4
  13. data/{hobo_files/plugin/lib → lib}/active_record/association_reflection.rb +7 -1
  14. data/{hobo_files/plugin/lib → lib}/extensions/test_case.rb +17 -17
  15. data/{hobo_files/plugin/lib → lib}/hobo.rb +193 -100
  16. data/{hobo_files/plugin/lib → lib}/hobo/authentication_support.rb +8 -8
  17. data/{hobo_files/plugin/lib → lib}/hobo/bundle.rb +90 -89
  18. data/{hobo_files/plugin/lib → lib}/hobo/composite_model.rb +21 -21
  19. data/{hobo_files/plugin/lib → lib}/hobo/controller.rb +38 -25
  20. data/{hobo_files/plugin/lib → lib}/hobo/dev_controller.rb +10 -6
  21. data/lib/hobo/dryml.rb +167 -0
  22. data/{hobo_files/plugin/lib → lib}/hobo/dryml/dryml_builder.rb +28 -25
  23. data/lib/hobo/dryml/dryml_generator.rb +210 -0
  24. data/{hobo_files/plugin/lib → lib}/hobo/dryml/dryml_support_controller.rb +1 -1
  25. data/lib/hobo/dryml/parser.rb +3 -0
  26. data/{hobo_files/plugin/lib → lib}/hobo/dryml/parser/attribute.rb +6 -6
  27. data/{hobo_files/plugin/lib → lib}/hobo/dryml/parser/base_parser.rb +16 -16
  28. data/lib/hobo/dryml/parser/document.rb +57 -0
  29. data/{hobo_files/plugin/lib → lib}/hobo/dryml/parser/element.rb +7 -7
  30. data/{hobo_files/plugin/lib → lib}/hobo/dryml/parser/elements.rb +9 -9
  31. data/{hobo_files/plugin/lib → lib}/hobo/dryml/parser/source.rb +3 -3
  32. data/{hobo_files/plugin/lib → lib}/hobo/dryml/parser/text.rb +3 -3
  33. data/{hobo_files/plugin/lib → lib}/hobo/dryml/parser/tree_parser.rb +3 -3
  34. data/{hobo_files/plugin/lib → lib}/hobo/dryml/part_context.rb +26 -26
  35. data/{hobo_files/plugin/lib → lib}/hobo/dryml/scoped_variables.rb +15 -15
  36. data/{hobo_files/plugin/lib → lib}/hobo/dryml/tag_parameters.rb +10 -10
  37. data/{hobo_files/plugin/lib → lib}/hobo/dryml/taglib.rb +43 -37
  38. data/{hobo_files/plugin/lib → lib}/hobo/dryml/template.rb +290 -208
  39. data/{hobo_files/plugin/lib → lib}/hobo/dryml/template_environment.rb +173 -115
  40. data/{hobo_files/plugin/lib → lib}/hobo/dryml/template_handler.rb +19 -24
  41. data/lib/hobo/find_for.rb +95 -0
  42. data/{hobo_files/plugin/lib → lib}/hobo/generator.rb +2 -1
  43. data/{hobo_files/plugin/lib → lib}/hobo/guest.rb +12 -4
  44. data/{hobo_files/plugin/lib → lib}/hobo/hobo_helper.rb +146 -117
  45. data/lib/hobo/include_in_save.rb +43 -0
  46. data/lib/hobo/lifecycles.rb +94 -0
  47. data/lib/hobo/lifecycles/actions.rb +73 -0
  48. data/lib/hobo/lifecycles/creator.rb +76 -0
  49. data/lib/hobo/lifecycles/lifecycle.rb +205 -0
  50. data/lib/hobo/lifecycles/state.rb +23 -0
  51. data/lib/hobo/lifecycles/transition.rb +66 -0
  52. data/{hobo_files/plugin/lib → lib}/hobo/model.rb +306 -217
  53. data/{hobo_files/plugin/lib → lib}/hobo/model_controller.rb +342 -213
  54. data/{hobo_files/plugin/lib → lib}/hobo/model_router.rb +151 -120
  55. data/{hobo_files/plugin/lib → lib}/hobo/model_support.rb +9 -9
  56. data/{hobo_files/plugin/lib → lib}/hobo/rapid_helper.rb +30 -23
  57. data/{hobo_files/plugin/lib → lib}/hobo/scopes.rb +22 -68
  58. data/{hobo_files/plugin/lib → lib}/hobo/scopes/apply_scopes.rb +5 -5
  59. data/lib/hobo/scopes/association_proxy_extensions.rb +47 -0
  60. data/{hobo_files/plugin/lib → lib}/hobo/scopes/automatic_scopes.rb +104 -79
  61. data/lib/hobo/scopes/named_scope_extensions.rb +27 -0
  62. data/{hobo_files/plugin/lib → lib}/hobo/static_tags +1 -11
  63. data/{hobo_files/plugin/lib → lib}/hobo/undefined.rb +1 -1
  64. data/{hobo_files/plugin/lib → lib}/hobo/undefined_access_error.rb +0 -0
  65. data/{hobo_files/plugin/lib → lib}/hobo/user.rb +27 -25
  66. data/{hobo_files/plugin/lib → lib}/hobo/user_controller.rb +80 -34
  67. data/{hobo_files/plugin/generators → rails_generators}/hobo/hobo_generator.rb +7 -7
  68. data/rails_generators/hobo/templates/application.css +0 -0
  69. data/{hobo_files/plugin/generators → rails_generators}/hobo/templates/application.dryml +0 -2
  70. data/{hobo_files/plugin/generators → rails_generators}/hobo/templates/dryml-support.js +0 -0
  71. data/{hobo_files/plugin/generators → rails_generators}/hobo/templates/guest.rb +0 -0
  72. data/rails_generators/hobo/templates/initializer.rb +9 -0
  73. data/{hobo_files/plugin/generators → rails_generators}/hobo_front_controller/USAGE +0 -0
  74. data/{hobo_files/plugin/generators → rails_generators}/hobo_front_controller/hobo_front_controller_generator.rb +1 -3
  75. data/{hobo_files/plugin/generators → rails_generators}/hobo_front_controller/templates/controller.rb +1 -1
  76. data/{hobo_files/plugin/generators → rails_generators}/hobo_front_controller/templates/functional_test.rb +0 -0
  77. data/{hobo_files/plugin/generators → rails_generators}/hobo_front_controller/templates/helper.rb +0 -0
  78. data/rails_generators/hobo_front_controller/templates/index.dryml +25 -0
  79. data/{hobo_files/plugin/generators → rails_generators}/hobo_model/USAGE +0 -0
  80. data/{hobo_files/plugin/generators → rails_generators}/hobo_model/hobo_model_generator.rb +0 -0
  81. data/{hobo_files/plugin/generators → rails_generators}/hobo_model/templates/fixtures.yml +0 -0
  82. data/{hobo_files/plugin/generators → rails_generators}/hobo_model/templates/model.rb +0 -0
  83. data/{hobo_files/plugin/generators → rails_generators}/hobo_model/templates/unit_test.rb +0 -0
  84. data/{hobo_files/plugin/generators → rails_generators}/hobo_model_controller/USAGE +0 -0
  85. data/{hobo_files/plugin/generators → rails_generators}/hobo_model_controller/hobo_model_controller_generator.rb +0 -7
  86. data/{hobo_files/plugin/generators → rails_generators}/hobo_model_controller/templates/controller.rb +0 -0
  87. data/{hobo_files/plugin/generators → rails_generators}/hobo_model_controller/templates/functional_test.rb +0 -0
  88. data/{hobo_files/plugin/generators → rails_generators}/hobo_model_controller/templates/helper.rb +0 -0
  89. data/{hobo_files/plugin/generators → rails_generators}/hobo_model_resource/hobo_model_resource_generator.rb +0 -0
  90. data/{hobo_files/plugin/generators → rails_generators}/hobo_model_resource/templates/controller.rb +0 -0
  91. data/{hobo_files/plugin/generators → rails_generators}/hobo_model_resource/templates/functional_test.rb +0 -0
  92. data/{hobo_files/plugin/generators → rails_generators}/hobo_model_resource/templates/helper.rb +0 -0
  93. data/{hobo_files/plugin/generators → rails_generators}/hobo_rapid/hobo_rapid_generator.rb +21 -11
  94. data/{hobo_files/plugin/generators → rails_generators}/hobo_rapid/templates/IE7.js +1 -1
  95. data/rails_generators/hobo_rapid/templates/blank.gif +0 -0
  96. data/{hobo_files/plugin/generators → rails_generators}/hobo_rapid/templates/hobo-rapid.css +0 -0
  97. data/{hobo_files/plugin/generators → rails_generators}/hobo_rapid/templates/hobo-rapid.js +175 -104
  98. data/{hobo_files/plugin/generators → rails_generators}/hobo_rapid/templates/lowpro.js +0 -0
  99. data/rails_generators/hobo_rapid/templates/nicEditorIcons.gif +0 -0
  100. data/rails_generators/hobo_rapid/templates/nicedit.js +91 -0
  101. data/{hobo_files/plugin/generators → rails_generators}/hobo_rapid/templates/reset.css +0 -0
  102. data/{hobo_files/plugin/generators → rails_generators}/hobo_rapid/templates/themes/clean/public/images/fieldbg.gif +0 -0
  103. data/{hobo_files/plugin/generators → rails_generators}/hobo_rapid/templates/themes/clean/public/images/pencil.png +0 -0
  104. data/{hobo_files/plugin/generators → rails_generators}/hobo_rapid/templates/themes/clean/public/images/small_close.png +0 -0
  105. data/{hobo_files/plugin/generators → rails_generators}/hobo_rapid/templates/themes/clean/public/images/spinner.gif +0 -0
  106. data/{hobo_files/plugin/generators → rails_generators}/hobo_rapid/templates/themes/clean/public/stylesheets/clean.css +80 -71
  107. data/{hobo_files/plugin/generators → rails_generators}/hobo_rapid/templates/themes/clean/public/stylesheets/rapid-ui.css +6 -1
  108. data/{hobo_files/plugin/generators → rails_generators}/hobo_rapid/templates/themes/clean/views/clean.dryml +4 -4
  109. data/rails_generators/hobo_subsite/hobo_subsite_generator.rb +73 -0
  110. data/rails_generators/hobo_subsite/templates/application.dryml +1 -0
  111. data/rails_generators/hobo_subsite/templates/controller.rb +5 -0
  112. data/rails_generators/hobo_subsite/templates/site_taglib.dryml +13 -0
  113. data/{hobo_files/plugin/generators → rails_generators}/hobo_user_controller/USAGE +0 -0
  114. data/{hobo_files/plugin/generators → rails_generators}/hobo_user_controller/hobo_user_controller_generator.rb +0 -0
  115. data/{hobo_files/plugin/generators → rails_generators}/hobo_user_controller/templates/controller.rb +0 -0
  116. data/{hobo_files/plugin/generators → rails_generators}/hobo_user_controller/templates/functional_test.rb +0 -0
  117. data/{hobo_files/plugin/generators → rails_generators}/hobo_user_controller/templates/helper.rb +0 -0
  118. data/{hobo_files/plugin/generators → rails_generators}/hobo_user_model/USAGE +0 -0
  119. data/rails_generators/hobo_user_model/hobo_user_model_generator.rb +30 -0
  120. data/{hobo_files/plugin/generators → rails_generators}/hobo_user_model/templates/fixtures.yml +0 -0
  121. data/rails_generators/hobo_user_model/templates/forgot_password.erb +10 -0
  122. data/rails_generators/hobo_user_model/templates/mailer.rb +14 -0
  123. data/rails_generators/hobo_user_model/templates/model.rb +55 -0
  124. data/{hobo_files/plugin/generators → rails_generators}/hobo_user_model/templates/unit_test.rb +0 -0
  125. data/script/destroy +14 -0
  126. data/script/generate +14 -0
  127. data/{hobo_files/plugin/taglibs → taglibs}/core.dryml +6 -7
  128. data/{hobo_files/plugin/taglibs → taglibs}/rapid.dryml +36 -67
  129. data/{hobo_files/plugin/taglibs → taglibs}/rapid_document_tags.dryml +7 -24
  130. data/{hobo_files/plugin/taglibs → taglibs}/rapid_editing.dryml +51 -50
  131. data/{hobo_files/plugin/taglibs → taglibs}/rapid_forms.dryml +62 -56
  132. data/taglibs/rapid_generics.dryml +33 -0
  133. data/taglibs/rapid_lifecycles.dryml +43 -0
  134. data/{hobo_files/plugin/taglibs → taglibs}/rapid_navigation.dryml +23 -23
  135. data/taglibs/rapid_pages.dryml +183 -0
  136. data/{hobo_files/plugin/taglibs → taglibs}/rapid_plus.dryml +30 -5
  137. data/{hobo_files/plugin/taglibs → taglibs}/rapid_support.dryml +3 -4
  138. data/taglibs/rapid_user_pages.dryml +179 -0
  139. data/{hobo_files/plugin/tasks → tasks}/environments.rake +0 -0
  140. data/{hobo_files/plugin/tasks → tasks}/fix_dryml.rake +0 -0
  141. data/{hobo_files/plugin/tasks → tasks}/generate_tag_reference.rb +21 -22
  142. data/tasks/hobo_tasks.rake +32 -0
  143. data/test/test_generator_helper.rb +29 -0
  144. data/test/test_helper.rb +1 -0
  145. data/test/test_hobo_model_controller_generator.rb +56 -0
  146. data/{hobo_files/plugin/uninstall.rb → uninstall.rb} +0 -0
  147. metadata +240 -225
  148. data/README.txt +0 -18
  149. data/hobo_files/plugin/LICENSE.txt +0 -22
  150. data/hobo_files/plugin/Rakefile +0 -96
  151. data/hobo_files/plugin/generators/hobo_front_controller/templates/index.dryml +0 -24
  152. data/hobo_files/plugin/generators/hobo_front_controller/templates/search.dryml +0 -19
  153. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/banner.gif +0 -0
  154. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/bkg-bodytop.gif +0 -0
  155. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/bkg-corner-01.gif +0 -0
  156. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/bkg-corner-02.gif +0 -0
  157. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/bkg-corner-03.gif +0 -0
  158. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/bkg-corner-04.gif +0 -0
  159. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/bkg-shadow-bottom.gif +0 -0
  160. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/bkg-shadow-left.gif +0 -0
  161. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/bkg-shadow-right.gif +0 -0
  162. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/bkg-shadow-top.gif +0 -0
  163. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/header-blue.gif +0 -0
  164. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/header-dblue.gif +0 -0
  165. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/header-green.gif +0 -0
  166. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/header-purple.gif +0 -0
  167. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/header-red.gif +0 -0
  168. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/logo.gif +0 -0
  169. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/plus.png +0 -0
  170. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/spinner.gif +0 -0
  171. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/txt-list-img-dblue.gif +0 -0
  172. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/txt-list-img-green.gif +0 -0
  173. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/txt-list-img-purple.gif +0 -0
  174. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/txt-list-img-red.gif +0 -0
  175. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/window-corner-01.gif +0 -0
  176. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/window-corner-02.gif +0 -0
  177. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/window-corner-03.gif +0 -0
  178. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/window-corner-04.gif +0 -0
  179. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/window-shadow-bottom.gif +0 -0
  180. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/window-shadow-left.gif +0 -0
  181. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/window-shadow-right.gif +0 -0
  182. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/window-shadow-top.gif +0 -0
  183. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/stylesheets/application.css +0 -400
  184. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/views/application.dryml +0 -96
  185. data/hobo_files/plugin/generators/hobo_user_model/hobo_user_model_generator.rb +0 -25
  186. data/hobo_files/plugin/generators/hobo_user_model/templates/model.rb +0 -56
  187. data/hobo_files/plugin/init.rb +0 -101
  188. data/hobo_files/plugin/lib/action_view_extensions/base.rb +0 -15
  189. data/hobo_files/plugin/lib/active_record/has_many_association.rb +0 -55
  190. data/hobo_files/plugin/lib/active_record/has_many_through_association.rb +0 -20
  191. data/hobo_files/plugin/lib/hobo/dryml.rb +0 -165
  192. data/hobo_files/plugin/lib/hobo/dryml/parser/document.rb +0 -53
  193. data/hobo_files/plugin/lib/hobo/scopes/association_proxy_extensions.rb +0 -33
  194. data/hobo_files/plugin/lib/hobo/scopes/defined_scope_proxy_extender.rb +0 -90
  195. data/hobo_files/plugin/lib/hobo/scopes/scope_reflection.rb +0 -18
  196. data/hobo_files/plugin/lib/hobo/scopes/scoped_proxy.rb +0 -55
  197. data/hobo_files/plugin/taglib-docs/core.markdown +0 -165
  198. data/hobo_files/plugin/taglib-docs/rapid.markdown +0 -677
  199. data/hobo_files/plugin/taglib-docs/rapid_document_tags.markdown +0 -240
  200. data/hobo_files/plugin/taglib-docs/rapid_editing.markdown +0 -418
  201. data/hobo_files/plugin/taglib-docs/rapid_forms.markdown +0 -562
  202. data/hobo_files/plugin/taglib-docs/rapid_generics.markdown +0 -187
  203. data/hobo_files/plugin/taglib-docs/rapid_navigation.markdown +0 -214
  204. data/hobo_files/plugin/taglib-docs/rapid_pages.markdown +0 -530
  205. data/hobo_files/plugin/taglib-docs/rapid_plus.markdown +0 -65
  206. data/hobo_files/plugin/taglib-docs/rapid_support.markdown +0 -50
  207. data/hobo_files/plugin/taglib-docs/rapid_user_pages.markdown +0 -129
  208. data/hobo_files/plugin/taglibs/rapid_generics.dryml +0 -117
  209. data/hobo_files/plugin/taglibs/rapid_pages.dryml +0 -359
  210. data/hobo_files/plugin/taglibs/rapid_user_pages.dryml +0 -104
  211. data/hobo_files/plugin/tasks/dump_fixtures.rake +0 -70
  212. data/hobo_files/plugin/tasks/hobo_tasks.rake +0 -17
@@ -0,0 +1,27 @@
1
+ module ActiveRecord
2
+ module NamedScope
3
+ class Scope
4
+
5
+ delegate :member_class, :to => :proxy_found
6
+
7
+ include Hobo::Scopes::ApplyScopes
8
+
9
+ def respond_to?(method)
10
+ super || scopes.include?(method) || proxy_scope.respond_to?(method)
11
+ end
12
+
13
+ private
14
+
15
+ def method_missing(method, *args, &block)
16
+ if respond_to?(method) && scopes.include?(method)
17
+ scopes[method].call(self, *args)
18
+ else
19
+ with_scope :find => proxy_options do
20
+ proxy_scope.send(method, *args, &block)
21
+ end
22
+ end
23
+ end
24
+
25
+ end
26
+ end
27
+ end
@@ -2,21 +2,17 @@ abbr
2
2
  acronym
3
3
  address
4
4
  applet
5
- area
6
5
  b
7
- base
8
6
  basefont
9
7
  bdo
10
8
  big
11
9
  blockquote
12
10
  body
13
- br
14
11
  button
15
12
  caption
16
13
  center
17
14
  cite
18
15
  code
19
- col
20
16
  colgroup
21
17
  dd
22
18
  del
@@ -29,7 +25,6 @@ em
29
25
  embed
30
26
  fieldset
31
27
  font
32
- frame
33
28
  frameset
34
29
  h1
35
30
  h2
@@ -38,21 +33,16 @@ h4
38
33
  h5
39
34
  h6
40
35
  head
41
- hr
42
- html
43
36
  i
44
37
  iframe
45
- img
46
38
  ins
47
39
  isindex
48
40
  kbd
49
41
  label
50
42
  legend
51
43
  li
52
- link
53
44
  map
54
45
  menu
55
- meta
56
46
  noframes
57
47
  noscript
58
48
  object
@@ -60,7 +50,6 @@ ol
60
50
  optgroup
61
51
  option
62
52
  p
63
- param
64
53
  pre
65
54
  q
66
55
  s
@@ -84,4 +73,5 @@ title
84
73
  tr
85
74
  tt
86
75
  u
76
+ ul
87
77
  var
@@ -34,7 +34,7 @@ module Hobo
34
34
  def method_missing(name, *args)
35
35
  raise UndefinedAccessError.new("call to: Hobo::Undefined##{name}")
36
36
  end
37
-
37
+
38
38
  undef_method :==
39
39
 
40
40
  end
@@ -3,13 +3,13 @@ require 'digest/sha1'
3
3
  module Hobo
4
4
 
5
5
  module User
6
-
6
+
7
7
  @user_models = []
8
-
8
+
9
9
  def self.default_user_model
10
10
  @user_models.first._?.constantize
11
11
  end
12
-
12
+
13
13
  AUTHENTICATION_FIELDS = [:salt, :crypted_password, :remember_token, :remember_token_expires_at]
14
14
 
15
15
  # Extend the base class with AuthenticatedUser functionality
@@ -19,18 +19,18 @@ module Hobo
19
19
  # - login token for rembering a login during multiple browser sessions
20
20
  def self.included(base)
21
21
  @user_models << base.name
22
-
22
+
23
23
  base.extend(ClassMethods)
24
24
 
25
25
  base.class_eval do
26
-
26
+
27
27
  fields do
28
28
  crypted_password :string, :limit => 40
29
29
  salt :string, :limit => 40
30
30
  remember_token :string
31
31
  remember_token_expires_at :datetime
32
32
  end
33
-
33
+
34
34
  validates_confirmation_of :password, :if => :password_required?
35
35
 
36
36
  # Virtual attributes for setting and changing the password
@@ -38,43 +38,46 @@ module Hobo
38
38
 
39
39
 
40
40
  validate :validate_current_password_when_changing_password
41
-
41
+
42
42
  before_save :encrypt_password
43
-
43
+
44
44
  never_show *AUTHENTICATION_FIELDS
45
-
45
+
46
46
  attr_protected *AUTHENTICATION_FIELDS
47
-
47
+
48
48
  password_validations
49
+
49
50
  end
50
51
  end
51
52
 
52
53
  # Additional classmethods for authentication
53
54
  module ClassMethods
54
-
55
+
55
56
  # Validation of the plaintext password
56
57
  def password_validations
57
58
  validates_length_of :password, :within => 4..40, :if => :password_required?
58
59
  end
59
-
60
+
60
61
  def login_attribute=(attr, validate=true)
61
62
  @login_attribute = attr = attr.to_sym
62
63
  unless attr == :login
63
64
  alias_attribute(:login, attr)
64
65
  declare_attr_type(:login, attr_type(attr)) if table_exists? # this breaks if the table doesn't exist
65
66
  end
66
-
67
+
67
68
  if validate
68
69
  validates_length_of attr, :within => 3..100
69
70
  validates_uniqueness_of attr, :case_sensitive => false
70
71
  end
71
72
  end
73
+
72
74
  attr_reader :login_attribute
73
75
 
76
+
74
77
  # Authenticates a user by their login name and unencrypted password. Returns the user or nil.
75
78
  def authenticate(login, password)
76
79
  u = find(:first, :conditions => ["#{@login_attribute} = ?", login]) # need to get the salt
77
-
80
+
78
81
  if u && u.authenticated?(password)
79
82
  if u.respond_to?(:last_login_at) || u.respond_to?(:login_count)
80
83
  u.last_login_at = Time.now if u.respond_to?(:last_login_at)
@@ -91,11 +94,6 @@ module Hobo
91
94
  def encrypt(password, salt)
92
95
  Digest::SHA1.hexdigest("--#{salt}--#{password}--")
93
96
  end
94
-
95
-
96
- def set_admin_on_first_user
97
- before_create { |user| user.administrator = true if count == 0 }
98
- end
99
97
 
100
98
  end
101
99
 
@@ -131,9 +129,13 @@ module Hobo
131
129
  def guest?
132
130
  false
133
131
  end
134
-
132
+
133
+ def signed_up?
134
+ true
135
+ end
136
+
135
137
  def changing_password?
136
- crypted_password? && (password || password_confirmation)
138
+ crypted_password? && (password || password_confirmation) && !lifecycle.valid_key?
137
139
  end
138
140
 
139
141
  protected
@@ -144,17 +146,17 @@ module Hobo
144
146
  self.crypted_password = encrypt(password)
145
147
  end
146
148
 
147
-
149
+
148
150
  # Is a password required for login? (or do we have an empty password?)
149
151
  def password_required?
150
152
  (crypted_password.blank? && password != nil) || !password.blank? || changing_password?
151
153
  end
152
154
 
153
-
155
+
154
156
  def validate_current_password_when_changing_password
155
- changing_password? && !authenticated?(current_password) and errors.add :current_password, "is not correct"
157
+ changing_password? && !authenticated?(current_password) and errors.add :current_password, "is not correct"
156
158
  end
157
-
159
+
158
160
  end
159
161
 
160
162
  end
@@ -4,32 +4,59 @@ module Hobo
4
4
 
5
5
  class << self
6
6
  def included(base)
7
- base.class_eval do
8
- filter_parameter_logging "password"
9
- skip_before_filter :login_required, :only => [:login, :signup]
7
+ base.class_eval do
8
+ extend ClassMethods
10
9
 
11
- include_taglib "rapid_user_pages", :plugin => "hobo"
10
+ class << self
11
+ alias_method_chain :available_auto_actions, :user_actions
12
+ alias_method_chain :def_auto_actions, :user_actions
13
+ end
12
14
 
15
+ filter_parameter_logging "password"
16
+ skip_before_filter :login_required, :only => [:login, :signup, :forgot_password, :reset_password_page, :reset_password]
17
+
18
+ include_taglib "rapid_user_pages", :plugin => "hobo"
19
+
13
20
  show_action :account
14
-
21
+
15
22
  alias_method_chain :hobo_update, :account_flash
16
23
  end
24
+
17
25
  end
26
+
27
+
18
28
  end
19
29
 
20
- def login; hobo_login; end
21
-
22
- def signup; hobo_signup; end
23
-
24
- def logout; hobo_logout; end
25
-
30
+ module ClassMethods
31
+
32
+ def available_auto_actions_with_user_actions
33
+ available_auto_actions_without_user_actions +
34
+ [:login, :signup, :logout, :forgot_password, :reset_password]
35
+ end
36
+
37
+
38
+ def def_auto_actions_with_user_actions
39
+ def_auto_actions_without_user_actions
40
+
41
+ class_eval do
42
+ def login; hobo_login; end if include_action?(:login)
43
+ def logout; hobo_logout; end if include_action?(:logout)
44
+ def do_signup; hobo_do_signup end if include_action?(:do_signup)
45
+ def forgot_password; hobo_forgot_password; end if include_action?(:forgot_password)
46
+ def do_reset_password; hobo_do_reset_password; end if include_action?(:do_reset_password)
47
+ end
48
+ end
49
+
50
+ end
51
+
52
+
26
53
  private
27
-
54
+
28
55
  def hobo_login(options={})
29
56
  login_attr = model.login_attribute.to_s.titleize.downcase
30
57
  options.reverse_merge!(:success_notice => "You have logged in.",
31
58
  :failure_notice => "You did not provide a valid #{login_attr} and password.")
32
-
59
+
33
60
  if request.post?
34
61
  user = model.authenticate(params[:login], params[:password])
35
62
  if user.nil?
@@ -37,7 +64,7 @@ module Hobo
37
64
  else
38
65
  old_user = current_user
39
66
  self.current_user = user
40
-
67
+
41
68
  # If supplied, a block can be used to test if this user is
42
69
  # allowed to log in (e.g. the account may be disabled)
43
70
  account_available = block_given? ? yield : true
@@ -58,23 +85,18 @@ module Hobo
58
85
  end
59
86
  end
60
87
 
61
-
62
- def hobo_signup(&b)
63
- if request.post?
64
- self.this = model.user_create(current_user, params[model.name.underscore])
65
- self.current_user = this if valid?
66
- response_block(&b) or
67
- if valid?
68
- flash[:notice] ||= "Thanks for signing up!"
69
- redirect_back_or_default(home_page)
70
- end
71
- else
72
- self.this = model.new
73
- yield if block_given?
88
+
89
+ def hobo_do_signup(&b)
90
+ do_creator_action(:signup) do
91
+ response_block(&b) or if valid?
92
+ self.current_user = this
93
+ flash[:notice] = "Thanks for signing up!"
94
+ redirect_back_or_default(home_page)
95
+ end
74
96
  end
75
97
  end
76
98
 
77
-
99
+
78
100
  def hobo_logout(options={})
79
101
  options = options.reverse_merge(:notice => "You have logged out.",
80
102
  :redirect_to => base_url)
@@ -84,17 +106,41 @@ module Hobo
84
106
  flash[:notice] ||= options[:notice]
85
107
  redirect_back_or_default(options[:redirect_to]) unless performed?
86
108
  end
87
-
88
-
109
+
110
+
111
+ def hobo_forgot_password
112
+ if request.post?
113
+ user = model.find_by_email_address(params[:email_address])
114
+ if user && (!block_given? || yield(user))
115
+ Hobo::Controller.request_host = request.host_with_port
116
+ Hobo::Controller.app_name = call_tag(:app_name)
117
+ user.lifecycle.request_password_reset(:nobody)
118
+ end
119
+ render_tag :forgot_password_email_sent_page
120
+ end
121
+ end
122
+
123
+
124
+ def hobo_do_reset_password(&b)
125
+ do_transition_action :reset_password do
126
+ response_block(&b) or if valid?
127
+ self.current_user = this
128
+ flash[:notice] = "Your password has been reset"
129
+ redirect_to home_page
130
+ end
131
+ end
132
+ end
133
+
134
+
89
135
  def hobo_update_with_account_flash(*args)
90
136
  hobo_update_without_account_flash(*args) do
91
137
  flash[:notice] = "Changes to your account were saved" if valid? && @this == current_user
92
138
  yield if block_given?
93
139
  end
94
140
  end
95
-
141
+
96
142
  private
97
-
143
+
98
144
  def logout_current_user
99
145
  if logged_in?
100
146
  current_user.forget_me
@@ -103,7 +149,7 @@ module Hobo
103
149
  self.current_user = nil
104
150
  end
105
151
  end
106
-
152
+
107
153
  end
108
-
154
+
109
155
  end
@@ -5,9 +5,7 @@ class HoboGenerator < Rails::Generator::Base
5
5
  routes_path = File.join(RAILS_ROOT, "config/routes.rb")
6
6
 
7
7
  route = " Hobo.add_routes(map)\n"
8
-
9
8
  route_src = File.read(routes_path)
10
-
11
9
  unless route_src.include?(route)
12
10
  head = "ActionController::Routing::Routes.draw do |map|"
13
11
  route_src.sub!(head, head + "\n\n" + route)
@@ -16,12 +14,14 @@ class HoboGenerator < Rails::Generator::Base
16
14
  end
17
15
 
18
16
  record do |m|
19
- m.directory File.join("app/views/taglibs")
20
- m.directory File.join("app/views/taglibs/themes")
21
- m.directory File.join("public/hobothemes")
17
+ m.directory File.join("app/views/taglibs")
18
+ m.directory File.join("app/views/taglibs/themes")
19
+ m.directory File.join("public/hobothemes")
22
20
  m.template "application.dryml", File.join("app/views/taglibs/application.dryml")
23
- m.file "guest.rb", File.join("app/models/guest.rb")
24
- m.file "dryml-support.js", File.join("public/javascripts/dryml-support.js")
21
+ m.file "guest.rb", File.join("app/models/guest.rb")
22
+ m.file "dryml-support.js", File.join("public/javascripts/dryml-support.js")
23
+ m.file "application.css", File.join("public/stylesheets/application.css")
24
+ m.file "initializer.rb", File.join("config/initializers/hobo.rb")
25
25
  end
26
26
  end
27
27
 
@@ -1,5 +1,3 @@
1
- <!-- Define your application-wide tags here -->
2
-
3
1
  <def tag="app-name"><%= File.basename(Dir.chdir(RAILS_ROOT) { Dir.getwd }).strip.titleize %></def>
4
2
 
5
3