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
@@ -7,4 +7,4 @@
7
7
  <stylesheet name="application" param="app-stylesheet"/>
8
8
  </stylesheets:>
9
9
  </old-page>
10
- </extend>
10
+ </extend>
@@ -16,7 +16,7 @@ module Hobo
16
16
  def generate_hobo_model
17
17
  # is there any better way to pass attributes?
18
18
  attr = attributes.map{|a| "#{a.name}:#{a.type}"}
19
- invoke 'hobo:model', [name, attr], options
19
+ invoke 'hobo:model', [name.singularize, attr], options
20
20
  end
21
21
 
22
22
  end
@@ -9,7 +9,7 @@ module Generators
9
9
  attr_reader :subsite, :controller, :model, :record, :records
10
10
 
11
11
  def initialize(subsite, controller)
12
- raise ::Hobo::Error, "#{controller} is not a Hobo::Controller::Model" unless controller < ::Hobo::Controller::Model
12
+ raise "#{controller} is not a Hobo::Controller::Model" unless controller < ::Hobo::Controller::Model
13
13
  @subsite = subsite
14
14
  @controller = controller
15
15
  @model = controller.model
@@ -34,7 +34,7 @@ module Generators
34
34
  routes << link("put '#{records}/:id/#{transition}(.:format)' => '#{records}#do_#{transition}', :as => 'do_#{record}_#{transition}'", transition, :put)
35
35
  routes << link("get '#{records}/:id/#{transition}(.:format)' => '#{records}##{transition}', :as => '#{record}_#{transition}'", transition)
36
36
  end
37
- routes.compact.uniq
37
+ routes.compact
38
38
  end
39
39
 
40
40
  def resource_routes
@@ -53,7 +53,7 @@ module Generators
53
53
  routes = []
54
54
  controller.owner_actions.each_pair do |owner, actions|
55
55
  collection_refl = model.reverse_reflection(owner)
56
- raise ::Hobo::Error, "Hob routing error -- can't find reverse association for #{model}##{owner} " +
56
+ raise Hobo::Error, "Hob routing error -- can't find reverse association for #{model}##{owner} " +
57
57
  "(e.g. the :has_many that corresponds to a :belongs_to)" if collection_refl.nil?
58
58
  collection = collection_refl.name
59
59
  owner_class = model.reflections[owner].klass.name.underscore
@@ -92,7 +92,7 @@ module Generators
92
92
  end
93
93
 
94
94
  def user_routes
95
- return [] unless controller < ::Hobo::Controller::UserBase
95
+ return [] unless controller < ::Hobo::Controller::User
96
96
  prefix = records == "users" ? "" : "#{record}_"
97
97
  [
98
98
  link("match '#{prefix}login(.:format)' => '#{records}#login', :as => '#{record}_login'", 'login'),
@@ -1,25 +1,14 @@
1
- require 'generators/hobo_support/eval_template'
2
-
3
1
  module Hobo
4
2
  class RoutesGenerator < Rails::Generators::Base
5
3
  source_root File.expand_path('../templates', __FILE__)
6
4
 
7
- include Generators::HoboSupport::EvalTemplate
8
-
9
5
  def self.banner
10
6
  "rails generate hobo:routes #{self.arguments.map(&:usage).join(' ')} [options]"
11
7
  end
12
8
 
13
9
  def generate_routes
14
10
  Hobo::Routes.reset_linkables
15
- h = Hobo::Engine.config.hobo
16
- template_name = 'hobo_routes.rb.erb'
17
- if h.read_only_file_system
18
- # just fill the @linkable_keys without writing any file
19
- eval_template template_name
20
- else
21
- template template_name, h.routes_path
22
- end
11
+ template "hobo_routes.rb.erb", Hobo::Engine.config.hobo.routes_path
23
12
  end
24
13
 
25
14
  private
@@ -17,7 +17,7 @@
17
17
  routes = gr == 'lifecycle_routes' ? router.send(gr.to_sym, subsite) : router.send(gr.to_sym) -%>
18
18
  <%- unless routes.empty? -%>
19
19
 
20
- <%= " " if subsite %><%= %(# #{gr.humanize} for controller "#{controller.controller_path}") %>
20
+ <%= " " if subsite %><%= "# #{gr.humanize} for controller :#{controller.controller_name}" %>
21
21
  <%- end -%>
22
22
  <%- for route in routes -%>
23
23
  <%= " " if subsite %><%= route %>
@@ -23,46 +23,34 @@ module Hobo
23
23
  class_option :front_controller_name, :type => :string,
24
24
  :desc => "Front Controller Name", :default => 'front'
25
25
 
26
- class_option :add_admin_subsite, :type => :boolean,
27
- :desc => "Add an Admin Subsite"
28
-
29
26
  class_option :admin_subsite_name, :type => :string,
30
27
  :desc => "Admin Subsite Name", :default => 'admin'
31
28
 
32
- class_option :make_front_site, :type => :boolean,
33
- :desc => "Rename application.dryml to front_site.dryml", :default => 'true'
34
-
35
29
  class_option :private_site, :type => :boolean,
36
- :desc => "Make the site unaccessible to non-members"
30
+ :desc => "Make the site unaccessible to non-mebers"
37
31
 
38
32
  class_option :migration_generate, :type => :boolean,
39
33
  :desc => "Generate migration only"
40
34
 
41
35
  class_option :migration_migrate, :type => :boolean,
42
- :desc => "Generate migration and migrate", :default => true
36
+ :desc => "Generate migration and migrate"
43
37
 
44
38
  class_option :default_locale, :type => :string,
45
39
  :desc => "Sets the default locale"
46
40
 
47
41
  class_option :locales, :type => :array,
48
- :desc => "Choose the locales", :default => %w[en]
42
+ :desc => "Choose the locales"
49
43
 
50
44
  class_option :git_repo, :type => :boolean,
51
45
  :desc => "Create the git repository with the initial commit"
52
46
 
53
- class_option :gitignore_auto_generated_files, :type => :boolean,
54
- :desc => "Add the auto-generated files to .gitignore", :default => true
55
-
56
- class_option :dryml_only_templates, :type => :boolean,
57
- :desc => "The application uses only dryml templates",
58
- :default => Rails.application.config.hobo.dryml_only_templates
59
47
 
60
48
  def startup
61
49
  if wizard?
62
50
  say_title options[:main_title] ? 'Hobo Setup Wizard' : 'Startup'
63
- say 'Installing Hobo assets...'
51
+ say 'Installing basic Hobo Files...'
64
52
  end
65
- invoke 'hobo:assets'
53
+ invoke 'hobo:basic'
66
54
  end
67
55
 
68
56
  def choose_test_framework
@@ -76,7 +64,7 @@ module Hobo
76
64
  fixture_replacement = ask("Type your preferred fixture replacement or <enter> for no replacement:")
77
65
  else
78
66
  # return if it is all default so no invoke is needed
79
- return if (options[:test_framework].to_s == 'test_unit' && options[:fixtures] && options[:fixture_replacement].blank?)
67
+ return if (options[:test_framework] == 'test_unit' && options[:fixtures] && options[:fixture_replacement].blank?)
80
68
  test_framework = options[:test_framework]
81
69
  fixtures = options[:fixtures]
82
70
  fixture_replacement = options[:fixture_replacement]
@@ -87,23 +75,12 @@ module Hobo
87
75
  :update => true
88
76
  end
89
77
 
90
- def user_options
91
- if wizard?
92
- say_title 'User Resource'
93
- @user_resource_name = ask("Choose a name for the user resource: [<enter>=user|<custom_name>]", 'user')
94
- @activation_email = @invite_only ? false : yes_no?("Do you want to send an activation email to activate the user?")
95
- else
96
- @user_resource_name = options[:user_resource_name]
97
- @activation_email = options[:activation_email]
98
- end
99
- end
100
-
101
- def site_options
78
+ def invite_only_option
102
79
  if wizard?
103
80
  say_title 'Invite Only Option'
104
81
  return unless (@invite_only = yes_no?("Do you want to add the features for an invite only website?"))
105
- private_site = yes_no?("Do you want to prevent all access to the site to non-members?\n(Choose 'y' only if ALL your site will be private, choose 'n' if at least one controller will be public)")
106
- say( %( If you wish to prevent all access to some controller to non-members, add 'before_filter :login_required'
82
+ private_site = yes_no?("Do you want to prevent all access to the site to non-members?")
83
+ say %( If you wish to prevent all access to some controller to non-members, add 'before_filter :login_required'
107
84
  to the relevant controllers:
108
85
 
109
86
  include Hobo::Controller::AuthenticationSupport
@@ -112,34 +89,19 @@ to the relevant controllers:
112
89
  (note that the include statement is not required for hobo_controllers)
113
90
 
114
91
  NOTE: You might want to sign up as the administrator before adding this!
115
- ), Color::YELLOW) unless private_site
92
+ ), Color::YELLOW
116
93
  else
117
94
  @invite_only = invite_only?
118
95
  private_site = options[:private_site]
119
96
  end
120
97
  inject_into_file 'app/controllers/application_controller.rb', <<EOI, :after => "protect_from_forgery\n" if private_site
121
98
  include Hobo::Controller::AuthenticationSupport
122
- before_filter :except => [:login, :forgot_password, :accept_invitation, :do_accept_invitation, :reset_password,
123
- :do_reset_password] do
124
- login_required unless #{@user_resource_name.camelize}.count == 0
99
+ before_filter :except => :login do
100
+ login_required unless User.count == 0
125
101
  end
126
102
  EOI
127
103
  end
128
104
 
129
- def dryml_only_templates_option
130
- if wizard?
131
- say_title 'Templates Option'
132
- dryml_only_templates = yes_no?("Will your application use only hobo/dryml web page templates?\n(Choose 'n' only if you also plan to use plain rails/erb web page templates)")
133
- else
134
- dryml_only_templates = options[:dryml_only_templates]
135
- end
136
- if dryml_only_templates
137
- remove_file 'app/views/layouts/application.html.erb'
138
- remove_file 'app/helpers/application_helper.rb'
139
- environment "\n config.hobo.dryml_only_templates = true\n"
140
- end
141
- end
142
-
143
105
  def rapid
144
106
  if wizard?
145
107
  say_title 'Hobo Rapid'
@@ -148,10 +110,21 @@ EOI
148
110
  invoke 'hobo:rapid'
149
111
  end
150
112
 
113
+ def user_resource
114
+ if wizard?
115
+ say_title 'User Resource'
116
+ @user_resource_name = ask("Choose a name for the user resource [<enter>=user|<custom_name>]:", 'user')
117
+ @activation_email = @invite_only ? false : yes_no?("Do you want to send an activation email to activate the user?")
118
+ else
119
+ @user_resource_name = options[:user_resource_name]
120
+ @activation_email = options[:activation_email]
121
+ end
122
+ end
123
+
151
124
  def front_controller
152
125
  if wizard?
153
126
  say_title 'Front Controller'
154
- front_controller_name = ask("Choose a name for the front controller: [<enter>=front|<custom_name>]", 'front')
127
+ front_controller_name = ask("Choose a name for the front controller [<enter>=front|<custom_name>]:", 'front')
155
128
  say "Installing #{front_controller_name} controller..."
156
129
  else
157
130
  front_controller_name = options[:front_controller_name]
@@ -160,17 +133,12 @@ EOI
160
133
  end
161
134
 
162
135
  def admin_subsite
136
+ return unless @invite_only
163
137
  if wizard?
164
138
  say_title 'Admin Subsite'
165
- if @invite_only || (@add_admin_subsite = yes_no?("Do you want an admin subsite?"))
166
- @admin_subsite_name = ask("Choose a name for the admin subsite: [<enter>=admin|<custom_name>]", 'admin')
167
- @make_front_site = yes_no?("Do you want to use a separate front_site.dryml?")
168
- end
139
+ @admin_subsite_name = ask("Choose a name for the admin subsite [<enter>=admin|<custom_name>]:", 'admin')
169
140
  else
170
- if @invite_only || (@add_admin_subsite = options[:add_admin_subsite])
171
- @admin_subsite_name = options[:admin_subsite_name]
172
- @make_front_site = options[:make_front_site]
173
- end
141
+ @admin_subsite_name = options[:admin_subsite_name]
174
142
  end
175
143
  end
176
144
 
@@ -180,19 +148,17 @@ EOI
180
148
  :invite_only => @invite_only,
181
149
  :activation_email => @activation_email,
182
150
  :admin_subsite_name => @admin_subsite_name
183
- if @invite_only || @add_admin_subsite
184
- say "Installing admin subsite..."
185
- invoke 'hobo:admin_subsite', [@admin_subsite_name],
186
- :user_resource_name => @user_resource_name,
187
- :invite_only => @invite_only,
188
- :make_front_site => @make_front_site
189
- end
151
+
152
+ say "Installing admin subsite..."
153
+ invoke 'hobo:admin_subsite', [@admin_subsite_name],
154
+ :user_resource_name => @user_resource_name,
155
+ :invite_only => @invite_only
190
156
  end
191
157
 
192
- def generate_migration
158
+ def migration
193
159
  if wizard?
194
160
  say_title 'DB Migration'
195
- action = choose("Initial Migration: [s]kip, [g]enerate migration file only, generate and [m]igrate: [s|g|m]", /^(s|g|m)$/)
161
+ action = choose('Initial Migration: [s]kip, [g]enerate migration file only, generate and [m]igrate [s|g|m]:', /^(s|g|m)$/)
196
162
  opt = case action
197
163
  when 's'
198
164
  return say('Migration skipped!')
@@ -203,8 +169,8 @@ EOI
203
169
  end
204
170
  say action == 'g' ? 'Generating Migration...' : 'Migrating...'
205
171
  else
206
- return if !options[:migration_generate] && !options[:migration_migrate]
207
- opt = options[:migration_migrate] ? {:migrate => true} : {:generate => true}
172
+ return if options[:migration_generate].blank? && options[:migration_migrate].blank?
173
+ opt = options[:migration_migrate].blank? ? {:generate => true} : {:migrate => true}
208
174
  end
209
175
  rake 'db:setup'
210
176
  invoke 'hobo:migration', ['initial_migration'], opt
@@ -219,8 +185,8 @@ EOI
219
185
  $1
220
186
  end
221
187
  say "The Hobo supported locales are #{supported_locales * ' '} (please, contribute to more translations)"
222
- locales = ask("Type the locales (space separated) you want to add to your application or <enter> for 'en':", 'en').split(/\s/)
223
- unless locales.size == 1 && locales.first == 'en'
188
+ locales = ask "Type the locales (space separated) you want to add to your application or <enter> for 'en':", 'en'
189
+ unless locales == 'en'
224
190
  default_locale = ask "Do you want to set a default locale? Type the locale or <enter> to skip:"
225
191
  end
226
192
  else
@@ -231,35 +197,24 @@ EOI
231
197
  default_locale.gsub!(/\:/, '')
232
198
  environment "config.i18n.default_locale = #{default_locale.to_sym.inspect}"
233
199
  end
234
- ls = (locales - %w[en]).map {|l| ":#{l}" }
235
- lstr = ls.to_sentence
236
- invoke 'hobo:i18n', locales
237
- say(<<STR , Color::YELLOW) unless ls.empty?
238
- NOTICE: You should manually install in 'config/locales' also the official Rails locale #{ls.size==1 ? 'file' : 'files'} for #{lstr} that your application will use.
239
- Official rails I18n URLs:
240
- - Readme: https://github.com/svenfuchs/rails-i18n/blob/master/README.md
241
- - locale dir: https://github.com/svenfuchs/rails-i18n/tree/master/rails/locale/
242
- STR
200
+ invoke 'hobo:i18n', locales.split
201
+ say( "NOTICE: You should manually install in 'config/locales' also the official Rails locale file(s) that your application will use.", Color::YELLOW) unless locales == 'en'
243
202
  end
244
203
 
245
204
  def git_repo
246
205
  if wizard?
247
206
  say_title 'Git Repository'
248
207
  return unless yes_no?("Do you want to initialize a git repository now?")
249
- gitignore_auto_generated = yes_no? "Do you want git to ignore the auto-generated files?\n(Choose 'n' only if you are planning to deploy on a read-only File System like Heroku)"
250
208
  say 'Initializing git repository...'
251
209
  else
252
210
  return unless options[:git_repo]
253
- gitignore_auto_generated = options[:gitignore_auto_generated_files]
254
- end
255
- if gitignore_auto_generated
256
- hobo_routes_rel_path = Hobo::Engine.config.hobo.routes_path.relative_path_from Rails.root
257
- append_file '.gitignore', "app/views/taglibs/auto/**/*\n#{hobo_routes_rel_path}\n"
258
211
  end
212
+ hobo_routes_rel_path = Hobo::Engine.config.hobo.routes_path.relative_path_from Rails.root
213
+ append_file '.gitignore', "app/views/taglibs/auto/**/*\n#{hobo_routes_rel_path}\n"
259
214
  git :init
260
215
  git :add => '.'
261
216
  git :commit => '-m "initial commit"'
262
- say("NOTICE: If you change the config.hobo.routes_path, you should update the .gitignore file accordingly.", Color::YELLOW) if gitignore_auto_generated
217
+ say "NOTICE: If you change the config.hobo.routes_path, you should update the .gitignore file accordingly.", Color::YELLOW
263
218
  end
264
219
 
265
220
  def finalize
@@ -1,14 +1,4 @@
1
1
  require 'fileutils'
2
- require 'thor/parser/option'
3
-
4
- # we want the option :make_front_site required even if it is boolean
5
- # Thor does not allow it, so we patch it
6
- class Thor
7
- class Option
8
- def validate!; end
9
- end
10
- end
11
-
12
2
  module Generators
13
3
  module Hobo
14
4
  Subsite = classy_module do
@@ -17,11 +7,10 @@ module Generators
17
7
  include Generators::Hobo::Taglib
18
8
 
19
9
  class_option :make_front_site,
20
- :type => :boolean,
21
- :required => true,
22
- :desc => "Rename application.dryml to front_site.dryml"
10
+ :type => :boolean,
11
+ :desc => "Rename application.dryml to front_site.dryml"
23
12
 
24
- # check_class_collision :suffix => 'SiteController'
13
+ check_class_collision :suffix => 'SiteController'
25
14
 
26
15
  def move_and_generate_files
27
16
  if options[:make_front_site]
@@ -31,10 +20,8 @@ module Generators
31
20
  end
32
21
  say "Renaming app/views/taglibs/application.dryml to app/views/taglibs/front_site.dryml" \
33
22
  unless options[:quiet]
34
- unless options[:pretend]
35
- FileUtils.mv('app/views/taglibs/application.dryml', "app/views/taglibs/front_site.dryml")
36
- copy_file "application.dryml", 'app/views/taglibs/application.dryml'
37
- end
23
+ FileUtils.mv('app/views/taglibs/application.dryml', "app/views/taglibs/front_site.dryml")
24
+ copy_file "application.dryml", 'app/views/taglibs/application.dryml'
38
25
  end
39
26
 
40
27
  template "controller.rb.erb", File.join('app/controllers', file_name, "#{file_name}_site_controller.rb")
@@ -3,7 +3,7 @@ module Hobo
3
3
  source_root File.expand_path('../templates', __FILE__)
4
4
 
5
5
  def self.banner
6
- "rails generate hobo:subsite NAME [options]"
6
+ "rails generate hobo:subsite [options]"
7
7
  end
8
8
 
9
9
  include Generators::Hobo::Subsite
@@ -1,5 +1,5 @@
1
1
  class <%= subsite_name %>::<%= subsite_name %>SiteController < ApplicationController
2
2
 
3
3
  hobo_controller
4
-
4
+
5
5
  end
@@ -1,6 +1,6 @@
1
1
  <!-- Tag definitions for the <%= file_name %> subsite -->
2
2
 
3
- <include src="rapid" gem="hobo"/>
3
+ <include src="rapid" plugin="hobo"/>
4
4
 
5
5
  <include src="taglibs/auto/<%= file_name %>/rapid/cards"/>
6
6
  <include src="taglibs/auto/<%= file_name %>/rapid/pages"/>
@@ -16,7 +16,7 @@
16
16
  <stylesheet name="<%= file_name %>"/>
17
17
  </append-stylesheets:>
18
18
  <footer:>
19
- <a href="#{base_url}/"><t key="hobo.subsite.back_link">View Site</t></a>
19
+ <a href="#{base_url}/">View Site</a> |
20
20
  </footer:>
21
21
  </old-page>
22
22
  </extend>
@@ -42,10 +42,10 @@ private
42
42
  end
43
43
 
44
44
  def setup_rspec
45
- gem 'rspec-rails', '>= 2.5.0', :group => [:test, :development]
45
+ gem 'rspec-rails', '>= 2.0.0.beta.10', :group => :test
46
46
  @should_update = true
47
47
  return unless options[:update]
48
- @finalize_hooks << lambda {say "Finalizing rspec installation..."; system 'rails g rspec:install'}
48
+ @finalize_hooks << lambda {say "Finalizing rspec installation..."; invoke 'rspec:install'}
49
49
  end
50
50
 
51
51
  def setup_shoulda
@@ -60,11 +60,11 @@ private
60
60
 
61
61
  def add_generators_block
62
62
  n = name == 'rspec_with_shoulda' ? 'rspec' : name
63
- block = "\n config.generators do |g|"
64
- block << "\n g.test_framework :#{n}, :fixtures => #{options[:fixtures].inspect}" if !options[:fixtures] || name != 'test_unit'
65
- block << "\n g.fallbacks[:#{n}] = :test_unit" unless name == 'test_unit'
66
- block << "\n g.fixture_replacement = :#{options[:fixture_replacement]}" unless options[:fixture_replacement].blank?
67
- block << "\n end\n"
63
+ block = " config.generators do |g|"
64
+ block << "\n g.test_framework :#{n}, :fixtures => #{options[:fixtures].inspect}" if !options[:fixtures] || name != 'test_unit'
65
+ block << "\n g.fallbacks[:#{n}] = :test_unit" unless name == 'test_unit'
66
+ block << "\n g.fixture_replacement => :#{options[:fixture_replacement]}" unless options[:fixture_replacement].blank?
67
+ block << "\n end"
68
68
  environment block
69
69
  end
70
70