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 @@
1
+ <!-- Global taglib - these tags are shared across all subsites -->
@@ -0,0 +1,5 @@
1
+ class <%= subsite_name %>::<%= subsite_name %>SiteController < ApplicationController
2
+
3
+ hobo_controller
4
+
5
+ end
@@ -0,0 +1,13 @@
1
+ <!-- Tag definitions for the <%= subsite_name %> subsite -->
2
+
3
+ <% if options[:rapid] -%>
4
+ <include src="rapid" plugin="hobo"/>
5
+
6
+ <include src="taglibs/auto/<%= file_name %>/rapid/cards"/>
7
+ <include src="taglibs/auto/<%= file_name %>/rapid/pages"/>
8
+ <include src="taglibs/auto/<%= file_name %>/rapid/forms"/>
9
+
10
+ <set-theme name="clean"/>
11
+ <% end -%>
12
+
13
+ <def tag="app-name"><%= app_name %></def>
@@ -0,0 +1,30 @@
1
+ class HoboUserModelGenerator < Rails::Generator::NamedBase
2
+
3
+ def manifest
4
+ record do |m|
5
+ # Check for class naming collisions.
6
+ m.class_collisions class_path, class_name, "#{class_name}Test"
7
+
8
+ # Model, test, and fixture directories.
9
+ m.directory File.join('app/models', class_path)
10
+ m.directory File.join('test/unit', class_path)
11
+ m.directory File.join('test/fixtures', class_path)
12
+ mailer_dir = File.join("app/views", class_path[0..-2], "#{file_name.singularize}_mailer")
13
+ m.directory mailer_dir
14
+
15
+ # Model class, unit test, and fixtures.
16
+ m.template 'model.rb', File.join('app/models', class_path, "#{file_name}.rb")
17
+ m.template 'unit_test.rb', File.join('test/unit', class_path, "#{file_name}_test.rb")
18
+ m.template 'fixtures.yml', File.join('test/fixtures', class_path, "#{table_name}.yml")
19
+
20
+ m.template 'mailer.rb', File.join('app/models', class_path, "#{file_name}_mailer.rb")
21
+ m.template 'forgot_password.erb', File.join(mailer_dir, "forgot_password.erb")
22
+ end
23
+ end
24
+
25
+ protected
26
+ def banner
27
+ "Usage: #{$0} #{spec.name} ModelName"
28
+ end
29
+
30
+ end
@@ -0,0 +1,10 @@
1
+ <%%= @user %>,
2
+
3
+ If you have forgotton your password for <%%= @app_name %>, you can chose
4
+ a new one by clicking on this link:
5
+
6
+ <%%= user_reset_password_url :host => @host, :id => @user, :key => @key %>
7
+
8
+ Thanks very much,
9
+
10
+ The <%%= @app_name %> team.
@@ -0,0 +1,14 @@
1
+ class UserMailer < ActionMailer::Base
2
+
3
+ def forgot_password(user, key)
4
+ host = Hobo::Controller.request_host
5
+ app_name = Hobo::Controller.app_name || host
6
+ @subject = "#{app_name} -- forgotten password"
7
+ @body = { :user => user, :key => key, :host => host, :app_name => app_name }
8
+ @recipients = user.email_address
9
+ @from = "no-reply@#{host}"
10
+ @sent_on = Time.now
11
+ @headers = {}
12
+ end
13
+
14
+ end
@@ -0,0 +1,55 @@
1
+ class <%= class_name %> < ActiveRecord::Base
2
+
3
+ hobo_user_model # Don't put anything above this
4
+
5
+ fields do
6
+ username :string, :login => true, :name => true
7
+ email_address :email_address
8
+ administrator :boolean, :default => false
9
+ timestamps
10
+ end
11
+
12
+ # This gives admin rights to the first sign-up.
13
+ # Just remove it if you don't want that
14
+ before_create { |user| user.administrator = true if count == 0 }
15
+
16
+
17
+ # --- Signup lifecycle --- #
18
+
19
+ lifecycle do
20
+
21
+ initial_state :active
22
+
23
+ create :anybody, :signup,
24
+ :params => [:username, :email_address, :password, :password_confirmation],
25
+ :become => :active, :if => proc {|_, u| u.guest?}
26
+
27
+ transition :nobody, :request_password_reset, { :active => :active } do
28
+ UserMailer.deliver_forgot_password(self, lifecycle.generate_key)
29
+ end
30
+
31
+ transition :with_key, :reset_password, { :active => :active },
32
+ :update => [ :password, :password_confirmation ]
33
+
34
+ end
35
+
36
+
37
+ # --- Hobo Permissions --- #
38
+
39
+ def creatable_by?(creator)
40
+ creator.administrator? || !administrator
41
+ end
42
+
43
+ def updatable_by?(updater, new)
44
+ updater.administrator? || (updater == self && only_changed_fields?(new, :password, :password_confirmation))
45
+ end
46
+
47
+ def deletable_by?(deleter)
48
+ deleter.administrator?
49
+ end
50
+
51
+ def viewable_by?(viewer, field)
52
+ true
53
+ end
54
+
55
+ end
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/destroy'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::Base.use_component_sources! [:rubygems, :test_unit]
14
+ RubiGen::Scripts::Destroy.new.run(ARGV)
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/generate'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::Base.use_component_sources! [:rubygems, :test_unit]
14
+ RubiGen::Scripts::Generate.new.run(ARGV)
@@ -5,7 +5,7 @@
5
5
 
6
6
  <def tag="wrap" attrs="tag, when, parameter">
7
7
  <% parameter ||= :default %>
8
- <%= when_ ? send(tag, attributes, { parameter.to_sym => parameters[:default] }) : parameter.default %>
8
+ <%= when_ ? send(tag, attributes, { parameter.to_sym => parameters[:default] }) : parameters.default %>
9
9
  </def>
10
10
 
11
11
 
@@ -18,14 +18,13 @@
18
18
  <def tag="repeat" attrs="even-odd, join">
19
19
  <if><%=
20
20
  if even_odd
21
- map_this do
22
- klass = [attributes[:class], cycle("even", "odd")].compact.join(' ')
23
- element(even_odd, attributes.merge(:class => klass, "hobo-model-id" => dom_id(this)), parameters.default)
21
+ context_map do
22
+ klass = [attributes[:class], model_id_class, cycle("even", "odd")].compact.join(' ')
23
+ element(even_odd, attributes.merge(:class => klass), parameters.default)
24
24
  end.join(join)
25
25
  else
26
- scope.new_scope do
27
- scope[:even_odd] = "odd"
28
- map_this do
26
+ scope.new_scope :even_odd => "odd" do
27
+ context_map do
29
28
  res = parameters.default
30
29
  scope.even_odd = scope.even_odd == "even" ? "odd" : "even"
31
30
  res
@@ -8,7 +8,7 @@
8
8
  <include src="rapid_navigation"/>
9
9
  <include src="rapid_plus"/>
10
10
  <include src="rapid_generics"/>
11
-
11
+ <include src="rapid_lifecycles"/>
12
12
 
13
13
  <def tag="field-list" attrs="tag">
14
14
  <% tag ||= scope.in_form ? "input" : "view" %>
@@ -29,26 +29,8 @@
29
29
 
30
30
  <def tag="item"><% scope.items << parameters.default %></def>
31
31
 
32
- <def tag="nil-view"><%= scope.nil_view || "(Not Available)" %></def>
33
32
 
34
- <def tag="ul" attrs="empty">
35
- <% if all_parameters.li? # don't use dryml if, because it will mess up <ul/><else> %>
36
- <if test="&empty || all_parameters[:head] || all_parameters[:foot] || !this.empty?">
37
- <% element "ul", attributes do %>
38
- <do param="head"/>
39
- <repeat>
40
- <li param if="&can_view?" class="#{scope.even_odd} #{this_type.name.underscore.dasherize}"
41
- merge-attrs="&{'hobo-model-id' => dom_id(this)} if this.respond_to?(:typed_id)">
42
- <do param="default"><a/></do>
43
- </li>
44
- </repeat>
45
- <do param="foot"/>
46
- <% end %>
47
- </if>
48
- <% else %>
49
- <%= element("ul", attributes, all_parameters.default) %>
50
- <% end %>
51
- </def>
33
+ <def tag="nil-view"><%= scope.nil_view || "(Not Available)" %></def>
52
34
 
53
35
 
54
36
  <def tag="table" attrs="fields, field-tag, empty">
@@ -70,8 +52,7 @@
70
52
  <tbody>
71
53
  <repeat>
72
54
  <tr param if="&can_view?"
73
- class="#{scope.even_odd} #{this_type.name.underscore}"
74
- hobo-model-id="#{dom_id(this)}">
55
+ class="#{scope.even_odd} #{this_type.name.underscore} #{model_id_class}">
75
56
  <if test="&fields">
76
57
  <with-fields merge-attrs="&all_attributes & attrs_for(:with_fields)" force-all>
77
58
  <td param="#{this_field.to_s.sub('?', '').gsub('.', '-')}-view"><call-tag tag="&field_tag"/></td>
@@ -101,14 +82,15 @@
101
82
  </def>
102
83
 
103
84
 
104
- <def tag="hobo-rapid-javascripts" attrs="tiny-mce"><%=
105
- res = '<script type="text/javascript">var hoboParts = {};'
85
+ <def tag="hobo-rapid-javascripts"><%=
86
+ res = 'var hoboParts = {};'
106
87
  # FIXME: This should interrogate the model-router - not the models
107
- unless Hobo.all_models.empty?
88
+ unless Hobo::Model.all_models.empty?
108
89
  # Tell JS code how to pluralize names, unless they follow the simple rule
109
- names = Hobo.all_models.map do |m|
110
- "#{m}: '#{m.pluralize}'" unless m.pluralize == m + 's'
111
- end.compact
90
+ names = Hobo::Model.all_models.map do |m|
91
+ m = m.name.underscore
92
+ "#{m}: '#{m.pluralize}'" unless m.pluralize == m + 's'
93
+ end.compact
112
94
  res << "var pluralisations = {#{names * ', '}}; "
113
95
  end
114
96
  base = [base_url, subsite].compact.join("/")
@@ -116,21 +98,6 @@
116
98
  if request_forgery_protection_token
117
99
  res << "; formAuthToken = { name: '#{request_forgery_protection_token}', value: '#{form_authenticity_token}' }"
118
100
  end
119
- res << "</script>"
120
-
121
- if tiny_mce
122
- res += javascript_include_tag("tiny_mce/tiny_mce_src") + %{
123
- <script type="text/javascript">
124
- tinyMCE.init({ mode: "textareas", editor_selector: "tiny-mce",
125
- plugins: 'save',
126
- theme_advanced_buttons1 : "bold, italic, separator, " +
127
- "bullist, outdent, indent, separator, " +
128
- "undo, redo, separator, link, unlink",
129
- theme_advanced_buttons2 : "",
130
- theme_advanced_buttons3 : ""
131
- });
132
- </script>}
133
- end
134
101
  res
135
102
  %></def>
136
103
 
@@ -146,16 +113,15 @@
146
113
  count
147
114
  elsif this.is_a? Class and this < ActiveRecord::Base
148
115
  this.name.pluralize.titleize
149
- elsif this.respond_to?(:name) && can_view?(this, :name)
150
- view(merge_attrs(attributes, {:field => 'name'}))
151
- elsif this.respond_to?(:title) && can_view?(this, :title)
152
- view(merge_attrs(attributes, {:field => 'title'}))
116
+ elsif (name_attr = this.class.try.name_attribute) && can_view?(this, name_attr)
117
+ view(merge_attrs(attributes, {:field => name_attr}))
153
118
  elsif can_view?(this)
154
119
  this.to_s
155
120
  end
156
121
  end
157
122
  %></def>
158
123
 
124
+
159
125
  <def tag="type-name" attrs="type, plural, lowercase, dasherize"><%=
160
126
  type ||= (this if this.is_a?(Class)) || this.try.member_class || this.class
161
127
 
@@ -166,16 +132,16 @@
166
132
  %></def>
167
133
 
168
134
 
169
- <def tag="name-for-collection" attrs="singular, lowercase"><%=
135
+ <def tag="collection-name" attrs="singular, lowercase, dasherize"><%=
170
136
  name = (attr = this.try.origin_attribute and attr.to_s) || type_name(:plural => true)
171
137
  name = name.titleize
172
138
  name = name.singularize if singular
173
139
  name = name.downcase if lowercase
140
+ name = name.underscore.gsub('_', '-') if dasherize
174
141
  name
175
142
  %></def>
176
143
 
177
144
 
178
-
179
145
  <def tag="a" attrs="action, to, params, query-params, href, format, subsite"><%=
180
146
  content = parameters.default
181
147
 
@@ -183,7 +149,7 @@
183
149
 
184
150
  if href || attributes[:name]
185
151
  # Regular link
186
- href += "?" + params.map { |n, v| "#{n}=#{v}" }.join('&') if params
152
+ href += "?" + params.map { |n, v| "#{n}=#{v}" }.join('&') if !params.blank?
187
153
  element(:a, attributes.update(:href => href), content)
188
154
  else
189
155
  target = to || this
@@ -249,14 +215,12 @@
249
215
 
250
216
  if view_tag == "view" # i.e. it didn't find a type specific tag
251
217
  if this.respond_to?(:to_html)
252
- this.to_html
218
+ this.to_html(scope.xmldoctype)
253
219
  else
254
- raise HoboError, "Cannot view: #{this.inspect} (field is #{this_field}, type is #{this.class})"
220
+ this.to_s
255
221
  end
256
222
  else
257
- attrs = add_classes(attributes, "view", type_and_field)
258
- id = dom_id
259
- attrs['hobo-model-id'] = id unless id == "nil"
223
+ attrs = add_classes(attributes, "view", type_and_field._?.dasherize, model_id_class)
260
224
 
261
225
  view_attrs = attrs_for(view_tag)
262
226
  the_view = send(view_tag, attrs & view_attrs)
@@ -272,7 +236,7 @@
272
236
  else
273
237
  wrapper = if inline
274
238
  :span
275
- elsif block || (this.class.const_defined?(:COLUMN_TYPE) && this.class::COLUMN_TYPE == :text)
239
+ elsif block || this.is_a?(HoboFields::Text)
276
240
  :div
277
241
  else
278
242
  :span
@@ -288,25 +252,27 @@
288
252
 
289
253
  <def tag="belongs-to-view"><a merge-attrs/></def>
290
254
 
291
- <def tag="has-many-view"><%= this.empty? ? "(none)" : map_this { a }.join(", ") %></def>
255
+ <def tag="has-many-view"><%= this.empty? ? "(none)" : context_map { a }.join(", ") %></def>
292
256
 
293
257
  <def tag="view" for="Date" attrs="format"><%= this && (format ? this.strftime(format) : this.to_s(:long)) %></def>
294
258
 
295
259
  <def tag="view" for="Time" attrs="format"><%= this && (format ? this.strftime(format) : this.to_s(:long)) %></def>
296
260
 
261
+ <def tag="view" for="ActiveSupport::TimeWithZone" attrs="format"><%= this && (format ? this.strftime(format) : this.to_s(:long)) %></def>
262
+
297
263
  <def tag="view" for="Numeric" attrs="format"><%= format ? format % this : this.to_s %></def>
298
264
 
299
- <def tag="view" for="string"><%= this.try.to_html || h(this).gsub("\n", "<br/>") %></def>
265
+ <def tag="view" for="string"><%= this.try.to_html(scope.xmldoctype) || h(this).gsub("\n", "<br#{scope.xmldoctype ? ' /' : ''}>") %></def>
300
266
 
301
267
  <def tag="view" for="boolean"><%= this ? 'Yes' : 'No' %></def>
302
268
 
303
269
  <def tag="view" for="ActiveRecord::Base"><a/></def>
304
270
 
305
271
 
306
- <def tag="count" attrs="label, prefix, if-any, lowercase"><%=
272
+ <def tag="count" attrs="label, prefix, if-any, lowercase"><span class="count"><%=
307
273
  raise Exception.new("asked for count of a string") if this.is_a?(String)
308
274
 
309
- c = this.try.to_int || this.try.total_entries || this.try.count || this.try.length
275
+ c = this.try.to_int || this.try.total_entries || (this.try.loaded? && this.try.length) || this.try.count || this.try.length
310
276
 
311
277
  label ||= if this.is_a?(Class)
312
278
  this.name
@@ -331,7 +297,7 @@
331
297
  main
332
298
  end
333
299
  end
334
- %></def>
300
+ %></span></def>
335
301
 
336
302
 
337
303
  <def tag="theme-stylesheet" attrs="name">
@@ -354,7 +320,7 @@ in the future - use at your own risk. -->
354
320
  </if>
355
321
  </table-for>
356
322
  <else>
357
- <p>There are no <%= this.member_class.name.titleize.pluralize.downcase %></p>
323
+ <p>No <%= this.member_class.name.titleize.pluralize.downcase %> to display</p>
358
324
  </else>
359
325
  <div>
360
326
  <create-button update="&id || part_id"/>
@@ -404,7 +370,7 @@ in the future - use at your own risk. -->
404
370
 
405
371
  <def tag="live-search">
406
372
  <div class="search">
407
- <label for="search-field">Search</label><input type="search" id="search-field" name="search-field" class="search-bhv search"/>
373
+ <label for="search-field">Search</label><input type="search" class="live-search"/>
408
374
  <spinner id="search-spinner"/>
409
375
  </div>
410
376
  <section class="hidden" id="search-results-panel">
@@ -415,22 +381,25 @@ in the future - use at your own risk. -->
415
381
 
416
382
 
417
383
  <def tag="a-or-an" attrs="word"><%=
418
- (word =~ /^[aeiouh]/i ? "an " : "a ") + word
384
+ (word =~ /^[aeiou]/i ? "an " : "a ") + word
419
385
  %></def>
420
386
 
421
387
 
422
388
  <def tag="A-or-An" attrs="word"><%=
423
- (word =~ /^[aeiouh]/i ? "An " : "A ") + word
389
+ (word =~ /^[aeiou]/i ? "An " : "A ") + word
424
390
  %></def>
425
391
 
426
392
 
427
393
  <def tag="filter-menu" attrs="param-name, options, no-filter">
428
394
  <% no_filter ||= "All" %>
429
395
  <form action="&request.request_uri" method="get" class="filter-menu">
430
- <hidden-field name="filter-parameter" value="&param_name"/>
431
- <select-menu name="&param_name" options="&options" selected="&params[param_name.gsub('-', '_')]" first-option="&no_filter" merge-params/>
396
+ <div>
397
+ <input type="hidden" name="filter-parameter" value="&param_name"/>
398
+ <select-menu name="&param_name" options="&options" selected="&params[param_name.gsub('-', '_')]" first-option="&no_filter" merge-params/>
399
+ </div>
432
400
  </form>
433
401
  </def>
434
402
 
435
403
 
436
404
  <def tag="comma-list" attrs="separator"><%= this.join(separator || ", ") %></def>
405
+