hobo 1.3.0.RC4 → 1.3.0.pre10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (155) hide show
  1. data/CHANGES.txt +234 -282
  2. data/Rakefile +3 -3
  3. data/VERSION +1 -1
  4. data/app/controllers/dev_controller.rb +2 -2
  5. data/bin/hobo +3 -3
  6. data/config/routes.rb +1 -1
  7. data/doctests/hobo/lifecycles.rdoctest +1 -0
  8. data/doctests/hobo/model.rdoctest +5 -0
  9. data/doctests/hobo/multi_model_forms.rdoctest +5 -4
  10. data/doctests/hobo/scopes.rdoctest +8 -11
  11. data/doctests/prepare_testapp.rb +1 -2
  12. data/hobo.gemspec +2 -2
  13. data/lib/generators/hobo/admin_subsite/admin_subsite_generator.rb +11 -5
  14. data/lib/generators/hobo/admin_subsite/templates/admin.css +2 -20
  15. data/lib/generators/hobo/admin_subsite/templates/admin_tag_injection.erb +1 -3
  16. data/lib/generators/hobo/admin_subsite/templates/controller.rb.erb +5 -5
  17. data/lib/generators/hobo/admin_subsite/templates/users_index.dryml +1 -3
  18. data/lib/generators/hobo/basic/basic_generator.rb +17 -0
  19. data/lib/generators/hobo/{assets → basic}/templates/application.css +0 -0
  20. data/lib/generators/hobo/{assets → basic}/templates/application.dryml.erb +1 -1
  21. data/lib/generators/hobo/{assets → basic}/templates/dryml-support.js +2 -2
  22. data/lib/generators/hobo/{assets → basic}/templates/en_injection.yml +0 -0
  23. data/lib/generators/hobo/{assets → basic}/templates/guest.rb +0 -0
  24. data/lib/generators/hobo/controller.rb +1 -6
  25. data/lib/generators/hobo/front_controller/front_controller_generator.rb +3 -2
  26. data/{app/views/dev → lib/generators/hobo/front_controller/templates}/summary.dryml +10 -7
  27. data/lib/generators/hobo/hints/hints_generator.rb +12 -0
  28. data/lib/generators/hobo/hints/templates/hints.rb.erb +5 -0
  29. data/lib/generators/hobo/hints/templates/model_injection.rb.erb +36 -0
  30. data/lib/generators/hobo/i18n/i18n_generator.rb +9 -1
  31. data/lib/generators/hobo/i18n/templates/app.en.yml +1 -1
  32. data/lib/generators/hobo/i18n/templates/app.es-DO.yml +24 -0
  33. data/lib/generators/hobo/i18n/templates/app.it.yml +1 -5
  34. data/lib/generators/hobo/i18n/templates/app.pt-PT.yml +0 -1
  35. data/lib/generators/hobo/i18n/templates/default_count_injection.rb +10 -0
  36. data/lib/generators/hobo/i18n/templates/hobo.en.yml +10 -26
  37. data/lib/generators/hobo/i18n/templates/{hobo.es.yml → hobo.es-DO.yml} +10 -27
  38. data/lib/generators/hobo/i18n/templates/hobo.it.yml +4 -20
  39. data/lib/generators/hobo/i18n/templates/hobo.pt-PT.yml +9 -25
  40. data/lib/generators/hobo/model.rb +13 -0
  41. data/lib/generators/hobo/model/USAGE +3 -2
  42. data/lib/generators/hobo/model/model_generator.rb +1 -2
  43. data/lib/generators/hobo/rapid/rapid_generator.rb +0 -2
  44. data/lib/generators/hobo/rapid/templates/hobo-rapid.js +93 -78
  45. data/lib/generators/hobo/rapid/templates/ie7-recalc.js +21 -21
  46. data/lib/generators/hobo/rapid/templates/lowpro.js +31 -31
  47. data/lib/generators/hobo/rapid/templates/reset.css +1 -1
  48. data/lib/generators/hobo/rapid/templates/themes/clean/public/stylesheets/clean.css +16 -17
  49. data/lib/generators/hobo/rapid/templates/themes/clean/public/stylesheets/rapid-ui.css +3 -3
  50. data/lib/generators/hobo/rapid/templates/themes/clean/views/clean.dryml +1 -1
  51. data/lib/generators/hobo/resource/resource_generator.rb +1 -1
  52. data/lib/generators/hobo/routes/router.rb +4 -4
  53. data/lib/generators/hobo/routes/routes_generator.rb +1 -12
  54. data/lib/generators/hobo/routes/templates/hobo_routes.rb.erb +1 -1
  55. data/lib/generators/hobo/setup_wizard/setup_wizard_generator.rb +43 -88
  56. data/lib/generators/hobo/subsite.rb +5 -18
  57. data/lib/generators/hobo/subsite/subsite_generator.rb +1 -1
  58. data/lib/generators/hobo/subsite/templates/controller.rb.erb +1 -1
  59. data/lib/generators/hobo/subsite_taglib/templates/taglib.dryml.erb +2 -2
  60. data/lib/generators/hobo/test_framework/test_framework_generator.rb +7 -7
  61. data/lib/generators/hobo/user_controller/templates/controller.rb.erb +3 -8
  62. data/lib/generators/hobo/user_mailer/templates/activation.erb +2 -2
  63. data/lib/generators/hobo/user_mailer/templates/forgot_password.erb +2 -2
  64. data/lib/generators/hobo/user_mailer/templates/invite.erb +2 -2
  65. data/lib/generators/hobo/user_mailer/templates/mailer.rb.erb +17 -10
  66. data/lib/generators/hobo/user_mailer/user_mailer_generator.rb +1 -1
  67. data/lib/generators/hobo/user_model/USAGE +9 -2
  68. data/lib/generators/hobo/user_model/user_model_generator.rb +1 -2
  69. data/lib/hobo.rb +7 -13
  70. data/lib/hobo/controller.rb +14 -21
  71. data/lib/hobo/controller/authentication_support.rb +23 -1
  72. data/lib/hobo/controller/model.rb +53 -48
  73. data/lib/hobo/controller/{user_base.rb → user.rb} +36 -47
  74. data/lib/hobo/engine.rb +11 -25
  75. data/lib/hobo/extensions/action_controller/hobo_methods.rb +1 -25
  76. data/lib/hobo/extensions/active_model/translation.rb +1 -1
  77. data/lib/hobo/extensions/active_record/{associations/collection.rb → association_collection.rb} +3 -12
  78. data/lib/hobo/extensions/active_record/{associations/proxy.rb → association_proxy.rb} +7 -6
  79. data/lib/hobo/extensions/active_record/association_reflection.rb +19 -0
  80. data/lib/hobo/extensions/active_record/hobo_methods.rb +1 -1
  81. data/lib/hobo/extensions/active_record/scopes.rb +31 -0
  82. data/lib/hobo/extensions/array.rb +1 -13
  83. data/lib/hobo/helper.rb +6 -27
  84. data/lib/hobo/helper/translations.rb +90 -39
  85. data/lib/hobo/model.rb +20 -72
  86. data/lib/hobo/model/lifecycles.rb +11 -12
  87. data/lib/hobo/model/lifecycles/lifecycle.rb +4 -12
  88. data/lib/hobo/model/lifecycles/transition.rb +0 -1
  89. data/lib/hobo/model/permissions.rb +3 -2
  90. data/lib/hobo/model/scopes/apply_scopes.rb +1 -1
  91. data/lib/hobo/model/scopes/automatic_scopes.rb +80 -78
  92. data/lib/hobo/model/{user_base.rb → user.rb} +7 -9
  93. data/lib/hobo/rapid/generators/rapid/cards.dryml.erb +2 -2
  94. data/lib/hobo/rapid/generators/rapid/forms.dryml.erb +4 -5
  95. data/lib/hobo/rapid/generators/rapid/pages.dryml.erb +27 -26
  96. data/lib/hobo/rapid/helper.rb +5 -10
  97. data/lib/hobo/rapid/taglibs/rapid.dryml +1 -1
  98. data/lib/hobo/rapid/taglibs/rapid_core.dryml +42 -72
  99. data/lib/hobo/rapid/taglibs/rapid_document_tags.dryml +2 -2
  100. data/lib/hobo/rapid/taglibs/rapid_editing.dryml +16 -36
  101. data/lib/hobo/rapid/taglibs/rapid_forms.dryml +49 -87
  102. data/lib/hobo/rapid/taglibs/rapid_generics.dryml +2 -2
  103. data/lib/hobo/rapid/taglibs/rapid_i18n.dryml +75 -50
  104. data/lib/hobo/rapid/taglibs/rapid_lifecycles.dryml +5 -7
  105. data/lib/hobo/rapid/taglibs/rapid_navigation.dryml +2 -2
  106. data/lib/hobo/rapid/taglibs/rapid_pages.dryml +7 -8
  107. data/lib/hobo/rapid/taglibs/rapid_plus.dryml +43 -66
  108. data/lib/hobo/rapid/taglibs/rapid_summary.dryml +45 -16
  109. data/lib/hobo/rapid/taglibs/rapid_translations.dryml +36 -0
  110. data/lib/hobo/rapid/taglibs/rapid_user_pages.dryml +8 -8
  111. data/lib/hobo/routes.rb +23 -22
  112. data/lib/hobo/view_hints.rb +101 -0
  113. data/test/irt/generators/admin_subsite.irt +1 -1
  114. data/test/irt/generators/{assets.irt → basic.irt} +2 -2
  115. data/test/irt/generators/front_controller.irt +4 -2
  116. data/test/irt/generators/partials/_subsite_taglib_variables.rb +1 -1
  117. data/test/irt/generators/subsite.irt +1 -1
  118. data/test/permissions/test_permissions.rb +103 -103
  119. metadata +108 -69
  120. data/lib/generators/hobo/admin_subsite/USAGE +0 -25
  121. data/lib/generators/hobo/admin_subsite/templates/application.dryml +0 -1
  122. data/lib/generators/hobo/assets/USAGE +0 -5
  123. data/lib/generators/hobo/assets/assets_generator.rb +0 -18
  124. data/lib/generators/hobo/assets/templates/dryml_taglibs_initializer.rb +0 -1
  125. data/lib/generators/hobo/controller/USAGE +0 -3
  126. data/lib/generators/hobo/i18n/USAGE +0 -3
  127. data/lib/generators/hobo/i18n/templates/app.de.yml +0 -30
  128. data/lib/generators/hobo/i18n/templates/app.es.yml +0 -31
  129. data/lib/generators/hobo/i18n/templates/app.fr.yml +0 -26
  130. data/lib/generators/hobo/i18n/templates/app.nb.yml +0 -25
  131. data/lib/generators/hobo/i18n/templates/app.ru.yml +0 -24
  132. data/lib/generators/hobo/i18n/templates/hobo.de.yml +0 -204
  133. data/lib/generators/hobo/i18n/templates/hobo.fr.yml +0 -195
  134. data/lib/generators/hobo/i18n/templates/hobo.nb.yml +0 -198
  135. data/lib/generators/hobo/i18n/templates/hobo.ru.yml +0 -200
  136. data/lib/generators/hobo/rapid/templates/themes/clean-sidemenu/public/images/100-ACD3E6-DBE1E5-H.png +0 -0
  137. data/lib/generators/hobo/rapid/templates/themes/clean-sidemenu/public/images/100-DBE1E5-FCFEF5-H.png +0 -0
  138. data/lib/generators/hobo/rapid/templates/themes/clean-sidemenu/public/images/300-3B5F87-ACD3E6-H.png +0 -0
  139. data/lib/generators/hobo/rapid/templates/themes/clean-sidemenu/public/images/spinner.gif +0 -0
  140. data/lib/generators/hobo/rapid/templates/themes/clean-sidemenu/public/stylesheets/clean-sidemenu.css +0 -81
  141. data/lib/generators/hobo/rapid/templates/themes/clean-sidemenu/views/clean-sidemenu.dryml +0 -30
  142. data/lib/generators/hobo/resource/USAGE +0 -39
  143. data/lib/generators/hobo/subsite/USAGE +0 -24
  144. data/lib/generators/hobo/subsite_taglib/USAGE +0 -4
  145. data/lib/generators/hobo/test_framework/USAGE +0 -2
  146. data/lib/generators/hobo/user_controller/USAGE +0 -3
  147. data/lib/generators/hobo/user_mailer/USAGE +0 -2
  148. data/lib/generators/hobo/user_resource/USAGE +0 -10
  149. data/lib/hobo/extensions/action_view/translation_helper.rb +0 -25
  150. data/lib/hobo/extensions/active_record/associations/reflection.rb +0 -23
  151. data/lib/hobo/extensions/active_record/associations/scope.rb +0 -35
  152. data/lib/hobo/extensions/active_record/relation_with_origin.rb +0 -32
  153. data/lib/hobo/extensions/i18n.rb +0 -17
  154. data/lib/hobo/helper/translations/normalizer.rb +0 -39
  155. data/lib/hobo/model/view_hints.rb +0 -123
@@ -5,6 +5,11 @@
5
5
  <%= Rails.version -%>
6
6
  </def>
7
7
 
8
+ <!-- returns "vendor" or "gem" -->
9
+ <def tag="rails-location">
10
+ <%= Rails.vendor_rails? ? "vendor" : "gem" -%>
11
+ </def>
12
+
8
13
  <!-- `Rails.root` -->
9
14
  <def tag="rails-root">
10
15
  <%= Rails.root -%>
@@ -34,18 +39,18 @@
34
39
  <!-- the git version currently in use -->
35
40
  <def tag="git-version" attrs="dir">
36
41
  <% dir=Rails.root if dir.blank? -%>
37
- <%= Dir.chdir(dir) {`git rev-parse --verify HEAD --short=7`} -%>
42
+ <%= Dir.chdir(dir) {`git rev-list "HEAD^..HEAD" --abbrev-commit --abbrev=7`} -%>
38
43
  </def>
39
44
 
40
- <!-- returns 'clean' if there are no modified or added files, 'dirty' otherwise. -->
45
+ <!-- returns 'clean' if there are no modified files, 'modified' otherwise. -->
41
46
  <def tag="git-clean" attrs="dir">
42
47
  <% dir=Rails.root if dir.blank? -%>
43
- <%= Dir.chdir(dir) {`git status -s`}.blank? ? "clean" : "dirty" -%>
48
+ <%= Dir.chdir(dir) {`git ls-files -m`}.blank? ? "clean" : "modified" -%>
44
49
  </def>
45
50
 
46
51
  <!-- the time & date of the last commit -->
47
52
  <def tag="git-last-commit-time">
48
- <%= `git log -1 --format=%cD` -%>
53
+ <%= `git log "HEAD^..HEAD" --pretty=format:%cD` -%>
49
54
  </def>
50
55
 
51
56
  <!-- calls `git-clean` or `svn-clean` as appropriate. `svn-clean` not yet written. -->
@@ -79,7 +84,13 @@
79
84
 
80
85
  <!-- repeats on Rails.configuration.gems, including dependent gems -->
81
86
  <def tag="with-gems">
82
- <% gems = Bundler::LockfileParser.new(File.read('Gemfile.lock')).specs -%>
87
+ <% gems = ActiveSupport::OrderedHash.new -%>
88
+ <% Rails.configuration.gems.each do |gem|
89
+ gems[name] ||= gem
90
+ gem.dependencies.each do |dep|
91
+ gems[dep] ||= dep
92
+ end
93
+ end -%>
83
94
  <repeat with="&gems">
84
95
  <do param="default"/>
85
96
  </repeat>
@@ -90,19 +101,37 @@
90
101
  <%= this.name -%>
91
102
  </def>
92
103
 
104
+ <def tag="gem-version-requirement">
105
+ <unless test="this.nil?"><%=
106
+ this.requirements.map{|l| l.first+l.second.to_s}.join(",")
107
+ -%></unless>
108
+ </def>
109
+
110
+ <!-- inside `<with-gems>`, returns the version required -->
111
+ <def tag="gem-version-required">
112
+ <gem-version-requirement:version-requirements />
113
+ </def>
114
+
93
115
  <!-- inside `<with-gems>`, returns the version -->
94
116
  <def tag="gem-version">
95
- <%= this.version.to_s -%>
117
+ <%= this.specification.version.to_s -%>
118
+ </def>
119
+
120
+ <!-- inside `<with-gems>`, returns 'frozen', 'installed' or 'missing' -->
121
+ <def tag="gem-frozen">
122
+ <%= this.frozen? ? "frozen" : (this.installed? ? "installed" : "missing") -%>
96
123
  </def>
97
124
 
98
125
  <!-- inside `<with-gems>`, returns the gem dependencies -->
99
126
  <def tag="gem-dependencies">
100
- <%= this.dependencies(&it.to_s).safe_join('<br>'.html_safe) -%>
127
+ <repeat with="&this.dependencies">
128
+ <%= this.name -%><gem-version-requirement with="&this.requirement || this.version_requirements" />
129
+ </repeat>
101
130
  </def>
102
131
 
103
132
  <!-- repeats on the plugins used by the application -->
104
133
  <def tag="with-plugins">
105
- <% plugins = Rails.application.railties.plugins %>
134
+ <% plugins = Rails.configuration.plugin_loader.new(Hobo.rails_initializer).plugins %>
106
135
  <repeat with="&plugins">
107
136
  <do param="default" />
108
137
  </repeat>
@@ -110,31 +139,31 @@
110
139
 
111
140
  <!-- within `<with-plugins>`, returns the plugin name -->
112
141
  <def tag="plugin-name">
113
- <%= this.name.to_s -%>
142
+ <%= this.name -%>
114
143
  </def>
115
144
 
116
145
  <!-- within `<with-plugins>`, returns the plugin location (directory) -->
117
146
  <def tag="plugin-location">
118
- <%= this.root.to_s -%>
147
+ <%= this.directory -%>
119
148
  </def>
120
149
 
121
150
  <def tag="plugin-git-clean">
122
- <git-clean dir="&this.root.to_s"/>
151
+ <git-clean dir="&this.directory"/>
123
152
  </def>
124
153
 
125
154
  <def tag="plugin-git-version">
126
- <git-version dir="&this.root.to_s"/>
155
+ <git-version dir="&this.directory"/>
127
156
  </def>
128
157
 
129
158
  <!-- within `<with-plugins>`, try and determine the method that was used to install the plugin. Returns "braid", "symlink", "git-submodule" or "other" -->
130
159
  <def tag="plugin-method">
131
160
  <%=
132
161
  braids = File.open("#{Rails.root}/.braids") {|f| YAML::load(f) } rescue {}
133
- if !braids[this.root.to_s.gsub(Rails.root.to_s+"/", "")].nil?
162
+ if !braids[this.directory.gsub(Rails.root+"/", "")].nil?
134
163
  "braid"
135
- elsif File.lstat(this.root.to_s).symlink?
164
+ elsif File.lstat(this.directory).symlink?
136
165
  "symlink"
137
- elsif File.exist?(this.root.to_s+"/.git")
166
+ elsif File.exist?(this.directory+"/.git")
138
167
  "git-submodule"
139
168
  else
140
169
  "other"
@@ -252,7 +281,7 @@
252
281
  <!-- given a column in the context and the model as an attribute, returns the comment for the column. It returns the SQL comment if that is available (using the activerecord-comments plugin). If that is not available, it returns the HoboFields comment. -->
253
282
 
254
283
  <def tag="model-column-comment" attrs="model">
255
- <%= this.try.comment || model.try.field_specs.try.get(this.name).try.first.try.comment -%>
284
+ <%= this.try.comment || model.try.field_specs.try.get(this.name).try.comment -%>
256
285
  </def>
257
286
 
258
287
  <!-- given a model, repeats on the associations -->
@@ -0,0 +1,36 @@
1
+ <!-- Rapid Translations contains the tags that assist with internationalization. -->
2
+
3
+ <!--
4
+
5
+ Uses RoR native I18n.translate.
6
+
7
+ Adds some conventions for easier hobo translation.
8
+
9
+ 1. Assumes the first part of the key to be a model name (e.g.: users.index.title -> user)
10
+ 2. Tries to translate the model by lookup for: (e.g.: user-> activerecord.models.user)
11
+ 3. Adds a default fallback to the beginning of the fallback chain by replacing the first part of the key with "hobo" and using the translated model name as additional attribute. This allows us to have default translations (e.g.: hobo.index.title: "{{model}} Index")
12
+
13
+ Is also used as a tag in the dryml-view files. The syntax is:
14
+
15
+ <ht key="my.app">My Application</ht>
16
+
17
+ Will lookup the "my.app"-key for your locale and replaces the "My Application" content if found.
18
+
19
+ <ht key="my" app="Program">My Application</ht>
20
+
21
+ Will look up both the "my"- and "app"-key for your locale, and replaces the "My Application" with the "my"-key contents (interpolated using the "app"-key.
22
+
23
+ sample.no.yml-file:
24
+
25
+ "no":
26
+ my: "Mitt {{app}}"
27
+
28
+ The output should be: Mitt Program
29
+
30
+ Otherwise with features as the ht method, step 1, 2 and 3 above.
31
+
32
+ For more information, see the [manual](/manual/i18n)
33
+ -->
34
+ <def tag="ht">
35
+ <% # this tag is actually implemented in translations.rb. This file is for documentation only! -%>
36
+ </def>
@@ -39,7 +39,7 @@
39
39
  </labelled-item>
40
40
  </labelled-item-list>
41
41
  <div param="actions">
42
- <submit label="#{t 'hobo.actions.login', :default=>['Log in'] }" param/><if test="&signup_url" class='nav-item'>
42
+ <submit label="#{I18n.t 'hobo.actions.login', :default=>['Log in'] }" param/><if test="&signup_url" class='nav-item'>
43
43
  <t key="hobo.support.or">or</t> <a param="signup" href="&signup_url"><t key="hobo.login.signup">Sign up</t></a></if>
44
44
  </div>
45
45
  </form>
@@ -48,7 +48,7 @@
48
48
  <!-- Simple log-in page -->
49
49
  <def tag="login-page">
50
50
  <% remember_me = true if remember_me.nil? %>
51
- <simple-page title="#{t 'hobo.login.title', :default=>['Log in'] }" merge>
51
+ <simple-page title="#{I18n.t 'hobo.login.title', :default=>['Log in'] }" merge>
52
52
 
53
53
  <body: class="login-page" param/>
54
54
 
@@ -69,7 +69,7 @@
69
69
  <!-- The page that initiates the forgotten password process. Contains a single text-input where the user can provide
70
70
  their email address -->
71
71
  <def tag="forgot-password-page">
72
- <simple-page title="#{t 'hobo.forgot_password.title', :default=>['Forgotten Password'] }" merge>
72
+ <simple-page title="#{I18n.t 'hobo.forgot_password.title', :default=>['Forgotten Password'] }" merge>
73
73
 
74
74
  <body: class="forgot-password-page" param/>
75
75
 
@@ -92,7 +92,7 @@
92
92
  </labelled-item>
93
93
  </labelled-item-list>
94
94
  <div param="actions">
95
- <submit label="#{t 'hobo.actions.send', :default=>['Send'] }" param/>
95
+ <submit label="#{I18n.t 'hobo.actions.send', :default=>['Send'] }" param/>
96
96
  </div>
97
97
  </form>
98
98
  </section>
@@ -105,7 +105,7 @@
105
105
  entered is in our records". This is to avoid a privacy concern that the forgotten-password mechanism can be otherwise used to tell
106
106
  if a given email is associated with an account or not. -->
107
107
  <def tag="forgot-password-email-sent-page">
108
- <simple-page title="#{t 'hobo.forgot_password_sent.title', :default=>['Forgotten Password - Sent'] }" merge>
108
+ <simple-page title="#{I18n.t 'hobo.forgot_password_sent.title', :default=>['Forgotten Password - Sent'] }" merge>
109
109
  <body: class="forgot-password-page" param/>
110
110
 
111
111
  <content: param>
@@ -132,7 +132,7 @@ if a given email is associated with an account or not. -->
132
132
  <!-- The page that is displayed on attempting to log in to an account that has been disabled. -->
133
133
  <def tag="account-disabled-page">
134
134
 
135
- <simple-page title="#{t 'hobo.account_disabled_page.title', :default=>['Account Disabled'] }" merge>
135
+ <simple-page title="#{I18n.t 'hobo.account_disabled_page.title', :default=>['Account Disabled'] }" merge>
136
136
 
137
137
  <body: class="account-disabled-page" param/>
138
138
 
@@ -153,7 +153,7 @@ if a given email is associated with an account or not. -->
153
153
  <!-- Basic account page that provides the ability for the user to change their email address and password. -->
154
154
  <def tag="account-page">
155
155
 
156
- <page title="#{t 'hobo.account_page.title', :default=>['Your Account'] }" merge>
156
+ <page title="#{I18n.t 'hobo.account_page.title', :default=>['Your Account'] }" merge>
157
157
 
158
158
  <body: class="user-account-page #{type_name}" param/>
159
159
 
@@ -171,7 +171,7 @@ if a given email is associated with an account or not. -->
171
171
  </field-list>
172
172
 
173
173
  <div class="actions" param="actions">
174
- <submit label="#{t 'hobo.actions.save_account', :default=>'Save'}" param/>
174
+ <submit label="#{I18n.t 'hobo.actions.save_account', :default=>'Save'}" param/>
175
175
  </div>
176
176
  </form>
177
177
  </section>
@@ -1,31 +1,32 @@
1
1
  module Hobo
2
- module Routes
3
- extend self
2
+ class Routes
3
+ class << self
4
4
 
5
- def reset_linkables
6
- @linkable_keys = Set.new
7
- end
5
+ def reset_linkables
6
+ @linkable_keys = Set.new
7
+ end
8
8
 
9
- def linkable_key(klass, action, options)
10
- subsite = options[:subsite] || options['subsite']
11
- method = options[:method] || options['method'] || :get
12
- [ subsite, klass.name, action, method ].join('/')
13
- end
9
+ def linkable_key(klass, action, options)
10
+ subsite = options[:subsite] || options['subsite']
11
+ method = options[:method] || options['method'] || :get
12
+ [ subsite, klass.name, action, method ].join('/')
13
+ end
14
14
 
15
- def linkable!(klass, action, options={})
16
- @linkable_keys << linkable_key(klass, action, options)
17
- end
15
+ def linkable!(klass, action, options={})
16
+ @linkable_keys << linkable_key(klass, action, options)
17
+ end
18
18
 
19
- def linkable?(klass, action, options={})
20
- @linkable_keys.member? linkable_key(klass, action, options)
21
- end
19
+ def linkable?(klass, action, options={})
20
+ @linkable_keys.member? linkable_key(klass, action, options)
21
+ end
22
22
 
23
- def models_with(wanted_action)
24
- @linkable_keys.map do |k|
25
- subsite, class_name, action, method = k.split('/')
26
- (action == wanted_action.to_s) ? class_name.constantize : nil
27
- end.compact
28
- end
23
+ def models_with(wanted_action)
24
+ @linkable_keys.map do |k|
25
+ subsite, class_name, action, method = k.split('/')
26
+ (action == wanted_action) ? class_name.constantize : nil
27
+ end.compact
28
+ end
29
29
 
30
+ end
30
31
  end
31
32
  end
@@ -0,0 +1,101 @@
1
+ module Hobo
2
+
3
+ class ViewHints
4
+
5
+ def self.setter(name, default=nil, &block)
6
+ ivname = name.to_s.remove(/\?$/)
7
+ metaclass.send :define_method, name do |*args|
8
+ if args.empty?
9
+ val = instance_variable_get("@#{ivname}")
10
+ if val.nil?
11
+ val = default.is_a?(Proc) ? instance_eval(&default) : default
12
+ instance_variable_set("@#{ivname}", val)
13
+ end
14
+ val
15
+ else
16
+ arg = if block
17
+ instance_exec(*args, &block)
18
+ else
19
+ args.first
20
+ end
21
+ instance_variable_set("@#{ivname}", arg)
22
+ end
23
+ end
24
+ end
25
+
26
+ setter :children, [] do |*args|
27
+ # Setting children also gives a default parent using the reverse association
28
+ child_model = model.reflections[args.first].klass
29
+ if child_model.view_hints.parent.nil? and !child_model.view_hints.parent_defined
30
+ parent = model.reverse_reflection(args.first)
31
+ child_model.view_hints.parent(parent.name, :undefined => true) if parent
32
+ end
33
+ args
34
+ end
35
+
36
+ setter :parent, nil do |*args|
37
+ options = args.extract_options!
38
+ parent_defined(true) unless options[:undefined]
39
+ args.first
40
+ end
41
+
42
+ setter :parent_defined, nil
43
+
44
+ setter :paginate?, proc { !sortable? }
45
+
46
+ setter :sortable?, proc { defined?(ActiveRecord::Acts::List::InstanceMethods) &&
47
+ model < ActiveRecord::Acts::List::InstanceMethods &&
48
+ model.new.try.scope_condition == "1 = 1" }
49
+
50
+ setter :inline_booleans, [] do |*args|
51
+ if args[0] == true
52
+ model.columns.select { |c| c.type == :boolean }.*.name
53
+ else
54
+ args.*.to_s
55
+ end
56
+ end
57
+
58
+ # Accessors
59
+
60
+ class << self
61
+
62
+ def _name
63
+ @_name ||= name.sub(/Hints$/, '')
64
+ end
65
+
66
+ def model
67
+ @model ||= _name.constantize
68
+ end
69
+
70
+ def primary_children
71
+ children.first
72
+ end
73
+
74
+ def secondary_children
75
+ children.rest
76
+ end
77
+
78
+
79
+ ##### LEGACY METHODS TO REMOVE #####
80
+
81
+ def model_name(*)
82
+ raise NotImplementedError, "ViewHints.model_name is no longer supported, please use model.model_name.human and set a the activerecord.models.<model_name> key in a locale file"
83
+ end
84
+
85
+ def model_name_plural(*)
86
+ raise NotImplementedError, "ViewHints.model_name_plural is no longer supported, please use model.model_name.human(:count => n) and set a the activerecord.models.<model_name> key in a locale file"
87
+ end
88
+
89
+ def field_name(*)
90
+ raise NotImplementedError, "ViewHints.field_name is no longer supported, please use model..human_attribute_name and set a the activerecord.attributes.<model_name>.<field_name> key in a locale file"
91
+ end
92
+
93
+ def field_names(*)
94
+ raise NotImplementedError, "ViewHints.field_names is no longer supported, please set the activerecord.attributes.<model_name>.<field_name> keys in a locale file"
95
+ end
96
+
97
+ end
98
+
99
+ end
100
+
101
+ end
@@ -1,7 +1,7 @@
1
1
  require File.expand_path('../helper.rb', __FILE__)
2
2
 
3
3
 
4
- invoke 'hobo:assets', %w[ -q ]
4
+ invoke 'hobo:basic', %w[ -q ]
5
5
  invoke 'hobo:admin_subsite', %w[ -q ]
6
6
  desc "Admin Subsite files exist"
7
7
  files_exist? %w[ app/controllers/admin/admin_site_controller.rb
@@ -1,8 +1,8 @@
1
1
  require File.expand_path('../helper.rb', __FILE__)
2
2
 
3
3
 
4
- desc "hobo:assets invoke"
5
- invoke 'hobo:assets', %w(-q)
4
+ desc "hobo:basic invoke"
5
+ invoke 'hobo:basic', %w(-q)
6
6
 
7
7
  files_exist? %w[ app/views/taglibs/application.dryml
8
8
  public/stylesheets/application.css
@@ -7,7 +7,8 @@ files_exist? %w[ app/controllers/front_controller.rb
7
7
  app/helpers/front_helper.rb
8
8
  test/unit/helpers/front_helper_test.rb
9
9
  test/functional/front_controller_test.rb
10
- app/views/front/index.dryml ]
10
+ app/views/front/index.dryml
11
+ app/views/front/summary.dryml ]
11
12
  test_value_eql? true
12
13
 
13
14
  desc "public/index.html removed"
@@ -19,12 +20,13 @@ desc "front_controller.rb content matches"
19
20
  file_include? 'app/controllers/front_controller.rb',
20
21
  'hobo_controller',
21
22
  'def index',
23
+ 'def summary',
22
24
  'def search'
23
25
  test_value_eql? true
24
26
 
25
27
 
26
28
  desc "Routes added"
27
29
  file_include? 'config/routes.rb',
28
- %(match 'search' => 'front#search', :as => 'site_search'),
30
+ %(match 'search' => 'front#search', :as => 'search'),
29
31
  %(root :to => 'front#index')
30
32
  test_value_eql? true
@@ -1,6 +1,6 @@
1
1
  tags = %(<!-- Tag definitions for the subs subsite -->
2
2
 
3
- <include src="rapid" gem="hobo"/>
3
+ <include src="rapid" plugin="hobo"/>
4
4
 
5
5
  <include src="taglibs/auto/subs/rapid/cards"/>
6
6
  <include src="taglibs/auto/subs/rapid/pages"/>