hobo 1.3.0.pre16 → 1.3.0.pre18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. data/VERSION +1 -1
  2. data/app/controllers/dev_controller.rb +1 -1
  3. data/{lib/generators/hobo/front_controller/templates → app/views/dev}/summary.dryml +7 -10
  4. data/config/routes.rb +1 -1
  5. data/lib/generators/hobo/{basic/basic_generator.rb → assets/assets_generator.rb} +2 -2
  6. data/lib/generators/hobo/{basic → assets}/templates/application.css +0 -0
  7. data/lib/generators/hobo/{basic → assets}/templates/application.dryml.erb +0 -0
  8. data/lib/generators/hobo/{basic → assets}/templates/dryml-support.js +0 -0
  9. data/lib/generators/hobo/{basic → assets}/templates/dryml_taglibs_initializer.rb +0 -0
  10. data/lib/generators/hobo/{basic → assets}/templates/en_injection.yml +0 -0
  11. data/lib/generators/hobo/{basic → assets}/templates/guest.rb +0 -0
  12. data/lib/generators/hobo/front_controller/front_controller_generator.rb +1 -2
  13. data/lib/generators/hobo/i18n/templates/hobo.pt-PT.yml +5 -5
  14. data/lib/generators/hobo/model/USAGE +0 -1
  15. data/lib/generators/hobo/model/model_generator.rb +2 -1
  16. data/lib/generators/hobo/setup_wizard/setup_wizard_generator.rb +12 -12
  17. data/lib/generators/hobo/subsite.rb +1 -1
  18. data/lib/generators/hobo/subsite/subsite_generator.rb +1 -1
  19. data/lib/generators/hobo/user_mailer/templates/mailer.rb.erb +3 -10
  20. data/lib/generators/hobo/user_model/user_model_generator.rb +2 -1
  21. data/lib/hobo/controller/model.rb +1 -13
  22. data/lib/hobo/helper.rb +12 -0
  23. data/lib/hobo/model.rb +9 -1
  24. data/lib/hobo/model/view_hints.rb +102 -0
  25. data/lib/hobo/rapid/taglibs/rapid_core.dryml +8 -1
  26. data/lib/hobo/rapid/taglibs/rapid_forms.dryml +1 -1
  27. data/lib/hobo/rapid/taglibs/rapid_generics.dryml +1 -1
  28. data/lib/hobo/rapid/taglibs/rapid_i18n.dryml +1 -2
  29. data/lib/hobo/rapid/taglibs/rapid_plus.dryml +2 -2
  30. data/lib/hobo/rapid/taglibs/rapid_summary.dryml +12 -41
  31. data/test/irt/generators/admin_subsite.irt +1 -1
  32. data/test/irt/generators/{basic.irt → assets.irt} +2 -2
  33. data/test/irt/generators/front_controller.irt +1 -3
  34. data/test/irt/generators/subsite.irt +1 -1
  35. metadata +23 -27
  36. data/lib/generators/hobo/hints/hints_generator.rb +0 -12
  37. data/lib/generators/hobo/hints/templates/hints.rb.erb +0 -5
  38. data/lib/generators/hobo/hints/templates/model_injection.rb.erb +0 -36
  39. data/lib/generators/hobo/model.rb +0 -13
  40. data/lib/hobo/view_hints.rb +0 -101
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.3.0.pre16
1
+ 1.3.0.pre18
@@ -18,7 +18,7 @@ class DevController < ActionController::Base
18
18
 
19
19
  def developer_modes_only
20
20
  # Belt and braces. In addition to this check, the routes only get
21
- # defined when developer_features? is true
21
+ # defined when developer_features is true
22
22
  render :text => "Permission Denied", :status => 403 unless Rails.application.config.hobo.developer_features
23
23
  end
24
24
 
@@ -8,12 +8,11 @@
8
8
  <tr> <td>Application Name</td> <td><app-name/></td> </tr>
9
9
  <tr> <td>Application Location</td> <td><rails-root/></td> </tr>
10
10
  <tr> <td>Rails Version</td> <td><rails-version/></td> </tr>
11
- <tr> <td>Rails Location</td> <td><rails-location/></td> </tr>
12
11
  <tr> <td>Mode</td> <td><rails-env/></td> </tr>
13
12
  </table>
14
13
 
15
14
  <h3>Change Control</h3>
16
- <table class="app-summary">
15
+ <table class="app-summary">
17
16
  <tr> <th></th><th></th></tr>
18
17
  <tr> <td>Method</td> <td><cms-method/></td> </tr>
19
18
  <if test="&cms_method.strip=='git'">
@@ -25,15 +24,13 @@
25
24
  </table>
26
25
 
27
26
 
28
- <h3>Gems</h3>
27
+ <h3>Bundled Gems</h3>
29
28
  <table class="app-summary">
30
29
  <with-gems>
31
- <tr if="&first_item?"><th></th><th>Required</th><th>Installed</th><th>Status</th><th>Dependencies</th></tr>
30
+ <tr if="&first_item?"><th></th><th>Version</th><th>Dependencies</th></tr>
32
31
  <tr>
33
32
  <td><gem-name/></td>
34
- <td><gem-version-required/></td>
35
- <td><gem-version/></td>
36
- <td><gem-frozen/></td>
33
+ <td><gem-version/></td>
37
34
  <td><gem-dependencies/></td>
38
35
  </tr>
39
36
  </with-gems>
@@ -75,8 +72,8 @@
75
72
  <td><model-table-comment/></td>
76
73
  </tr>
77
74
  </with-models>
78
- </table>
79
-
75
+ </table>
76
+
80
77
  <with-models>
81
78
  <h3 if="&this.try.table_name"><model-name /></h3>
82
79
  <table class="app-summary">
@@ -102,4 +99,4 @@
102
99
  </with-models>
103
100
  </div>
104
101
  </content:>
105
- </page>
102
+ </page>
@@ -1,6 +1,6 @@
1
1
  Rails.application.routes.draw do
2
2
 
3
3
  match 'dryml/:action', :controller => 'dryml_support', :as => 'dryml_support'
4
- match 'dev/:action', :controller => 'dev', :as => 'dev_support'
4
+ match 'dev/:action', :controller => 'dev', :as => 'dev_support' if Rails.application.config.hobo.developer_features
5
5
 
6
6
  end
@@ -1,9 +1,9 @@
1
1
  module Hobo
2
- class BasicGenerator < Rails::Generators::Base
2
+ class AssetsGenerator < Rails::Generators::Base
3
3
  source_root File.expand_path('../templates', __FILE__)
4
4
 
5
5
  def self.banner
6
- "rails generate hobo:basic"
6
+ "rails generate hobo:assets"
7
7
  end
8
8
 
9
9
  def copy_rapid_files
@@ -32,9 +32,8 @@ module Hobo
32
32
  template 'controller.rb.erb', File.join('app/controllers',"#{file_path}_controller.rb")
33
33
  end
34
34
 
35
- def generate_index_and_summary
35
+ def generate_index
36
36
  template("index.dryml", File.join('app/views', file_path, "index.dryml"))
37
- template("summary.dryml", File.join('app/views', file_path, "summary.dryml"))
38
37
  end
39
38
 
40
39
  def remove_index_html
@@ -50,7 +50,7 @@
50
50
  email_address: &email_address "E-mail"
51
51
  name: "Name"
52
52
  password: "Palavra-chave"
53
- remember_me: "Recordar-se de mim"
53
+ remember_me: "Gravar Login"
54
54
  login: "Login"
55
55
  signup: "Resgistar"
56
56
  forgot_password: &forgot_password "Esqueceu-se da senha?"
@@ -63,14 +63,14 @@
63
63
  forgot_password:
64
64
  title: *forgot_password
65
65
  heading: *forgot_password
66
- text: "Introduza o seu endereço de e-mail, o mesmo com que se registou. Vamos enviar um endereço para gerar uma palavra-chave."
66
+ text: "Introduza o seu endereço de e-mail, o mesmo com que se registou. Vamos enviar uma mensagem para recuperar a palavra-chave."
67
67
  email: "E-mail"
68
68
  send: "Enviar"
69
69
 
70
70
  forgot_password_sent:
71
71
  title: "Recuperação da palavra-chave - e-mail enviado"
72
72
  heading: "Recuperação da palavra-chave - e-mail enviado"
73
- text: "Foram enviadas para o e-mail %{email_address} as instruções de como gerar uma nova palavra-chave. Se não o receber, por favor verifique o filtro de spam."
73
+ text: "Foi enviada uma mensagem para %{email_address} com as instruções de como gerar uma nova palavra-chave. Se não o receber, por favor verifique o filtro de SPAM."
74
74
 
75
75
  account_disabled:
76
76
  title: "Conta não encontrada"
@@ -119,7 +119,7 @@
119
119
  success: "O %{model} foi removido"
120
120
  signup:
121
121
  success: "Obrigado por efectuar o registo!"
122
- must_activate: "Deve ativar o seu registo antes de se identificar. Por favor, verifique na sua caixa de correio electrônico.
122
+ must_activate: "Deve ativar o seu registo antes de se identificar. Por favor, verifique na sua caixa de correio electrônico."
123
123
  login:
124
124
  success: "Está indetificado no sistema."
125
125
  error: "Não especificou um utilizador válido ({{login}}) e respectiva palavra-chave!"
@@ -178,7 +178,7 @@
178
178
 
179
179
  admin:
180
180
  subsite_name: "Administração"
181
- invite_new_user: "Invitar Novo Utilizador"
181
+ invite_new_user: "Convidar Novo Utilizador"
182
182
 
183
183
  subsite:
184
184
  back_link: "Sítio Principal"
@@ -10,7 +10,6 @@ Examples:
10
10
  Model: app/models/account.rb
11
11
  Test: test/unit/account_test.rb
12
12
  Fixtures: test/fixtures/accounts.yml
13
- Viewhints: app/viewhints/account_hints.rb
14
13
 
15
14
  $ rails generate hobo:model post title:string body:text published:boolean
16
15
 
@@ -1,10 +1,11 @@
1
1
  require 'rails/generators/active_record'
2
+ require 'generators/hobo_support/model'
2
3
 
3
4
  module Hobo
4
5
  class ModelGenerator < ActiveRecord::Generators::Base
5
6
  source_root File.expand_path('../templates', __FILE__)
6
7
 
7
- include Generators::Hobo::Model
8
+ include Generators::HoboSupport::Model
8
9
 
9
10
  end
10
11
  end
@@ -33,7 +33,7 @@ module Hobo
33
33
  :desc => "Generate migration only"
34
34
 
35
35
  class_option :migration_migrate, :type => :boolean,
36
- :desc => "Generate migration and migrate"
36
+ :desc => "Generate migration and migrate", :default => true
37
37
 
38
38
  class_option :default_locale, :type => :string,
39
39
  :desc => "Sets the default locale"
@@ -51,9 +51,9 @@ module Hobo
51
51
  def startup
52
52
  if wizard?
53
53
  say_title options[:main_title] ? 'Hobo Setup Wizard' : 'Startup'
54
- say 'Installing basic Hobo Files...'
54
+ say 'Installing Hobo assets...'
55
55
  end
56
- invoke 'hobo:basic'
56
+ invoke 'hobo:assets'
57
57
  end
58
58
 
59
59
  def choose_test_framework
@@ -78,12 +78,12 @@ module Hobo
78
78
  :update => true
79
79
  end
80
80
 
81
- def invite_only_option
81
+ def site_options
82
82
  if wizard?
83
83
  say_title 'Invite Only Option'
84
84
  return unless (@invite_only = yes_no?("Do you want to add the features for an invite only website?"))
85
- private_site = yes_no?("Do you want to prevent all access to the site to non-members?")
86
- say %( If you wish to prevent all access to some controller to non-members, add 'before_filter :login_required'
85
+ 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)")
86
+ say( %( If you wish to prevent all access to some controller to non-members, add 'before_filter :login_required'
87
87
  to the relevant controllers:
88
88
 
89
89
  include Hobo::Controller::AuthenticationSupport
@@ -92,7 +92,7 @@ to the relevant controllers:
92
92
  (note that the include statement is not required for hobo_controllers)
93
93
 
94
94
  NOTE: You might want to sign up as the administrator before adding this!
95
- ), Color::YELLOW
95
+ ), Color::YELLOW) unless private_site
96
96
  else
97
97
  @invite_only = invite_only?
98
98
  private_site = options[:private_site]
@@ -113,7 +113,7 @@ EOI
113
113
  invoke 'hobo:rapid'
114
114
  end
115
115
 
116
- def user_resource
116
+ def user_options
117
117
  if wizard?
118
118
  say_title 'User Resource'
119
119
  @user_resource_name = ask("Choose a name for the user resource [<enter>=user|<custom_name>]:", 'user')
@@ -158,10 +158,10 @@ EOI
158
158
  :invite_only => @invite_only
159
159
  end
160
160
 
161
- def migration
161
+ def generate_migration
162
162
  if wizard?
163
163
  say_title 'DB Migration'
164
- action = choose('Initial Migration: [s]kip, [g]enerate migration file only, generate and [m]igrate [s|g|m]:', /^(s|g|m)$/)
164
+ action = choose("Initial Migration: [s]kip, [g]enerate migration file only, generate and [m]igrate [s|g|m]:", /^(s|g|m)$/)
165
165
  opt = case action
166
166
  when 's'
167
167
  return say('Migration skipped!')
@@ -172,8 +172,8 @@ EOI
172
172
  end
173
173
  say action == 'g' ? 'Generating Migration...' : 'Migrating...'
174
174
  else
175
- return if options[:migration_generate].blank? && options[:migration_migrate].blank?
176
- opt = options[:migration_migrate].blank? ? {:generate => true} : {:migrate => true}
175
+ return if !options[:migration_generate] && !options[:migration_migrate]
176
+ opt = options[:migration_migrate] ? {:migrate => true} : {:generate => true}
177
177
  end
178
178
  rake 'db:setup'
179
179
  invoke 'hobo:migration', ['initial_migration'], opt
@@ -20,7 +20,7 @@ module Generators
20
20
  end
21
21
  say "Renaming app/views/taglibs/application.dryml to app/views/taglibs/front_site.dryml" \
22
22
  unless options[:quiet]
23
- FileUtils.mv('app/views/taglibs/application.dryml', "app/views/taglibs/front_site.dryml")
23
+ FileUtils.mv('app/views/taglibs/application.dryml', "app/views/taglibs/front_site.dryml") unless options[:pretend]
24
24
  copy_file "application.dryml", 'app/views/taglibs/application.dryml'
25
25
  end
26
26
 
@@ -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 [options]"
6
+ "rails generate hobo:subsite NAME [options]"
7
7
  end
8
8
 
9
9
  include Generators::Hobo::Subsite
@@ -2,31 +2,24 @@ class <%= class_name -%>Mailer < ActionMailer::Base
2
2
  default :from => "no-reply@#{host}"
3
3
 
4
4
  def forgot_password(user, key)
5
- set_variables(user, key)
5
+ @user, @key = user, key
6
6
  mail( :subject => "#{app_name} -- forgotten password",
7
7
  :to => user.email_address )
8
8
  end
9
9
 
10
10
  <% if invite_only? -%>
11
11
  def invite(user, key)
12
- set_variables(user, key)
12
+ @user, @key = user, key
13
13
  mail( :subject => "Invitation to #{app_name}",
14
14
  :to => user.email_address )
15
15
  end
16
16
 
17
17
  <% elsif options[:activation_email] %>
18
18
  def activation(user, key)
19
- set_variables(user, key)
19
+ @user, @key = user, key
20
20
  mail :subject => "#{app_name} -- activate",
21
21
  :to => user.email_address
22
22
  end
23
23
 
24
24
  <% end -%>
25
- private
26
-
27
- def set_variables(user, key)
28
- @user = user
29
- @key = key
30
- end
31
-
32
25
  end
@@ -1,3 +1,4 @@
1
+ require 'generators/hobo_support/model'
1
2
  module Hobo
2
3
  class UserModelGenerator < Rails::Generators::NamedBase
3
4
  source_root File.expand_path('../templates', __FILE__)
@@ -5,7 +6,7 @@ module Hobo
5
6
  # overrides the default
6
7
  argument :name, :type => :string, :default => 'user', :optional => true
7
8
 
8
- include Generators::Hobo::Model
9
+ include Generators::HoboSupport::Model
9
10
  include Generators::Hobo::InviteOnly
10
11
  include Generators::Hobo::ActivationEmail
11
12
 
@@ -356,9 +356,7 @@ module Hobo
356
356
  def re_render_form(default_action=nil)
357
357
  if params[:page_path]
358
358
  @invalid_record = this
359
- opt = ActionController::Routing::Routes.recognize_path(params[:page_path])
360
- controller = opt[:controller]
361
- action = opt[:action]
359
+ controller, action = controller_action_from_page_path
362
360
 
363
361
  # Hack fix for Bug 477. See also bug 489.
364
362
  if self.class.name == "#{controller.camelize}Controller" && action == "index"
@@ -399,16 +397,6 @@ module Hobo
399
397
  end
400
398
 
401
399
 
402
- def url_for_page_path
403
- url_for ActionController::Routing::Routes.recognize_path(params[:page_path])
404
- end
405
-
406
- # TODO: Get rid of this joke of an idea that fails miserably if you open another browser window.
407
- def previous_page_path
408
- session[:previous_page_path]
409
- end
410
-
411
-
412
400
  def redirect_after_submit(*args)
413
401
  options = args.extract_options!
414
402
  o = options[:redirect]
@@ -126,6 +126,18 @@ module Hobo
126
126
  end
127
127
 
128
128
 
129
+ def recognize_page_path
130
+ ActionController::Routing::Routes.recognize_path(params[:page_path])
131
+ end
132
+
133
+ def url_for_page_path(options={})
134
+ url_for recognize_page_path.merge(options)
135
+ end
136
+
137
+ def controller_action_from_page_path
138
+ recognize_page_path.values_at(:controller,:action)
139
+ end
140
+
129
141
  def _as_params(name, obj)
130
142
  if obj.is_a? Array
131
143
  obj.map {|x| _as_params("#{name}[]", x)}.join("&")
@@ -330,7 +330,15 @@ module Hobo
330
330
 
331
331
  def view_hints
332
332
  class_name = "#{name}Hints"
333
- class_name.safe_constantize or Object.class_eval("class #{class_name} < Hobo::ViewHints; end; #{class_name}")
333
+ class_name.safe_constantize or Object.class_eval("class #{class_name} < Hobo::Model::ViewHints; end; #{class_name}")
334
+ end
335
+
336
+ def children(*args)
337
+ view_hints.children *args
338
+ end
339
+
340
+ def inline_booleans(*args)
341
+ view_hints.inline_booleans *args
334
342
  end
335
343
 
336
344
  def table_exists?
@@ -0,0 +1,102 @@
1
+ module Hobo
2
+ module Model
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
102
+ end
@@ -236,6 +236,8 @@ Provides a short hand way of displaying images in public/images
236
236
 
237
237
  <!-- Renders a human readable name of a collection
238
238
 
239
+ This tag has been deprecated in favour of human-collection-name
240
+
239
241
  ### Details
240
242
 
241
243
  - Uses `this.origin_attribute` as the name.
@@ -417,7 +419,7 @@ Assuming the context is a blog post...
417
419
  <view:created_at no-wrapper/> -> June 09, 2008 15:36
418
420
  -->
419
421
  <def tag="view" attrs="inline, block, if-blank, no-wrapper, truncate"><%=
420
- raise Hobo::Error, "view of non-viewable field '#{this_field}' of #{this_parent.typed_id rescue this_parent}" unless
422
+ raise Hobo::PermissionDeniedError, "view of non-viewable field '#{this_field}' of #{this_parent.typed_id rescue this_parent}" unless
421
423
  can_view?
422
424
 
423
425
  res = if this.nil? && if_blank.nil?
@@ -644,6 +646,11 @@ that you add the keys in the correct namespaces.
644
646
 
645
647
  - capitalize: the first letter of the resulting sentence will be capitalized
646
648
 
649
+
650
+ ### Additional Notes
651
+
652
+ The "titleize" attribute is deprecated: use "capitalize" instead.
653
+
647
654
  -->
648
655
  <def tag="you" attrs="titleize, capitalize">
649
656
  <% Rails.logger.warn "'titleize' is a deprecated attribute of the 'you' tag. Please, use 'capitalize' instead." -%>
@@ -652,7 +652,7 @@ For situations where there are too many target records to practically include in
652
652
 
653
653
  -->
654
654
  <def tag="select-one" attrs="include-none, blank-message, options, sort, limit, text-method"><%
655
- raise Hobo::Error.new("Not allowed to edit #{this_field}") if !attributes[:disabled] && !can_edit?
655
+ raise Hobo::PermissionDeniedError.new("Not allowed to edit #{this_field}") if !attributes[:disabled] && !can_edit?
656
656
  blank_message ||= ht("#{this_type.name.tableize}.message.no", :default=>"(No #{this_type.model_name.human})")
657
657
  limit ||= 100
658
658
 
@@ -21,7 +21,7 @@
21
21
  <unless test="&this.member_class.nil?">
22
22
  <div class="empty-collection-message" style="#{'display:none' if !this.empty?}" param="default">
23
23
  <ht key="#{this.member_class.name.tableize}.collection.empty_message">
24
- No <collection-name lowercase/> to display
24
+ No <human-collection-name count="0"/> to display
25
25
  </ht>
26
26
  </div>
27
27
  </unless>
@@ -17,8 +17,7 @@ There is a default :count => 1
17
17
  I18n.t(k, {:default=>all_parameters.default}.merge(options)).html_safe
18
18
  %></def>
19
19
 
20
- <!-- Wrapper around ActiveModel::Name#human with added sugar.
21
- It dynamically pluralizes the human name by using the implicit model.count.
20
+ <!-- Wrapper around ActiveModel::Name#human
22
21
 
23
22
  #### Attributes
24
23
 
@@ -28,7 +28,7 @@ An [worked example](/tutorials/agility#improve_the_project_page_with_a_searchabl
28
28
  <% col = sort_columns[scope.field_path] || scope.field_path
29
29
  sort = sort_field == col && sort_direction == 'asc' ?
30
30
  "-#{col}" : col
31
- sort_url = url_for(params.merge(:sort => sort) - [:page])
31
+ sort_url = url_for_page_path(params.merge(:sort => sort) - [:page])
32
32
  col_heading_name = this.member_class.try.human_attribute_name(scope.field_name, :default=> scope.field_name.titleize) %>
33
33
 
34
34
  <th param="#{scope.field-name}-heading">
@@ -45,7 +45,7 @@ An [worked example](/tutorials/agility#improve_the_project_page_with_a_searchabl
45
45
  </table>
46
46
  <empty-collection-message param="empty-message"/>
47
47
 
48
- <page-nav param if="&this.respond_to?(:page_count) || this.respond_to?(:total_pages)"/>
48
+ <page-nav param params="&recognize_page_path.slice(:controller,:action)" if="&this.respond_to?(:page_count) || this.respond_to?(:total_pages)"/>
49
49
  </div>
50
50
  </def>
51
51
 
@@ -5,11 +5,6 @@
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
-
13
8
  <!-- `Rails.root` -->
14
9
  <def tag="rails-root">
15
10
  <%= Rails.root -%>
@@ -84,13 +79,7 @@
84
79
 
85
80
  <!-- repeats on Rails.configuration.gems, including dependent gems -->
86
81
  <def tag="with-gems">
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 -%>
82
+ <% gems = Bundler::LockfileParser.new(File.read('Gemfile.lock')).specs -%>
94
83
  <repeat with="&gems">
95
84
  <do param="default"/>
96
85
  </repeat>
@@ -101,37 +90,19 @@
101
90
  <%= this.name -%>
102
91
  </def>
103
92
 
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
-
115
93
  <!-- inside `<with-gems>`, returns the version -->
116
94
  <def tag="gem-version">
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") -%>
95
+ <%= this.version.to_s -%>
123
96
  </def>
124
97
 
125
98
  <!-- inside `<with-gems>`, returns the gem dependencies -->
126
99
  <def tag="gem-dependencies">
127
- <repeat with="&this.dependencies">
128
- <%= this.name -%><gem-version-requirement with="&this.requirement || this.version_requirements" />
129
- </repeat>
100
+ <%= this.dependencies(&it.to_s).safe_join('<br>'.html_safe) -%>
130
101
  </def>
131
102
 
132
103
  <!-- repeats on the plugins used by the application -->
133
104
  <def tag="with-plugins">
134
- <% plugins = Rails.configuration.plugin_loader.new(Hobo.rails_initializer).plugins %>
105
+ <% plugins = Rails.application.railties.plugins %>
135
106
  <repeat with="&plugins">
136
107
  <do param="default" />
137
108
  </repeat>
@@ -139,31 +110,31 @@
139
110
 
140
111
  <!-- within `<with-plugins>`, returns the plugin name -->
141
112
  <def tag="plugin-name">
142
- <%= this.name -%>
113
+ <%= this.name.to_s -%>
143
114
  </def>
144
115
 
145
116
  <!-- within `<with-plugins>`, returns the plugin location (directory) -->
146
117
  <def tag="plugin-location">
147
- <%= this.directory -%>
118
+ <%= this.root.to_s -%>
148
119
  </def>
149
120
 
150
121
  <def tag="plugin-git-clean">
151
- <git-clean dir="&this.directory"/>
122
+ <git-clean dir="&this.root.to_s"/>
152
123
  </def>
153
124
 
154
125
  <def tag="plugin-git-version">
155
- <git-version dir="&this.directory"/>
126
+ <git-version dir="&this.root.to_s"/>
156
127
  </def>
157
128
 
158
129
  <!-- within `<with-plugins>`, try and determine the method that was used to install the plugin. Returns "braid", "symlink", "git-submodule" or "other" -->
159
130
  <def tag="plugin-method">
160
131
  <%=
161
132
  braids = File.open("#{Rails.root}/.braids") {|f| YAML::load(f) } rescue {}
162
- if !braids[this.directory.gsub(Rails.root+"/", "")].nil?
133
+ if !braids[this.root.to_s.gsub(Rails.root+"/", "")].nil?
163
134
  "braid"
164
- elsif File.lstat(this.directory).symlink?
135
+ elsif File.lstat(this.root.to_s).symlink?
165
136
  "symlink"
166
- elsif File.exist?(this.directory+"/.git")
137
+ elsif File.exist?(this.root.to_s+"/.git")
167
138
  "git-submodule"
168
139
  else
169
140
  "other"
@@ -281,7 +252,7 @@
281
252
  <!-- 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. -->
282
253
 
283
254
  <def tag="model-column-comment" attrs="model">
284
- <%= this.try.comment || model.try.field_specs.try.get(this.name).try.comment -%>
255
+ <%= this.try.comment || model.try.field_specs.try.get(this.name).try.first.try.comment -%>
285
256
  </def>
286
257
 
287
258
  <!-- given a model, repeats on the associations -->
@@ -1,7 +1,7 @@
1
1
  require File.expand_path('../helper.rb', __FILE__)
2
2
 
3
3
 
4
- invoke 'hobo:basic', %w[ -q ]
4
+ invoke 'hobo:assets', %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:basic invoke"
5
- invoke 'hobo:basic', %w(-q)
4
+ desc "hobo:assets invoke"
5
+ invoke 'hobo:assets', %w(-q)
6
6
 
7
7
  files_exist? %w[ app/views/taglibs/application.dryml
8
8
  public/stylesheets/application.css
@@ -7,8 +7,7 @@ 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
11
- app/views/front/summary.dryml ]
10
+ app/views/front/index.dryml ]
12
11
  test_value_eql? true
13
12
 
14
13
  desc "public/index.html removed"
@@ -20,7 +19,6 @@ desc "front_controller.rb content matches"
20
19
  file_include? 'app/controllers/front_controller.rb',
21
20
  'hobo_controller',
22
21
  'def index',
23
- 'def summary',
24
22
  'def search'
25
23
  test_value_eql? true
26
24
 
@@ -21,7 +21,7 @@ eval_file '../partials/_subsite_taglib_noopt.rb'
21
21
 
22
22
  git_reset_app
23
23
 
24
- invoke 'hobo:basic', %w[ -q ]
24
+ invoke 'hobo:assets', %w[ -q ]
25
25
  invoke 'hobo:subsite', %w[ subs -q --make-front-site]
26
26
  desc "Subsite with make-front-site files exist"
27
27
  files_exist? %w[ app/views/taglibs/front_site.dryml
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hobo
3
3
  version: !ruby/object:Gem::Version
4
- hash: -1637175965
4
+ hash: -1637175967
5
5
  prerelease: true
6
6
  segments:
7
7
  - 1
8
8
  - 3
9
9
  - 0
10
- - pre16
11
- version: 1.3.0.pre16
10
+ - pre18
11
+ version: 1.3.0.pre18
12
12
  platform: ruby
13
13
  authors:
14
14
  - Tom Locke
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-11-08 00:00:00 -04:00
19
+ date: 2010-11-19 00:00:00 -04:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -59,13 +59,13 @@ dependencies:
59
59
  requirements:
60
60
  - - "="
61
61
  - !ruby/object:Gem::Version
62
- hash: -1637175965
62
+ hash: -1637175967
63
63
  segments:
64
64
  - 1
65
65
  - 3
66
66
  - 0
67
- - pre16
68
- version: 1.3.0.pre16
67
+ - pre18
68
+ version: 1.3.0.pre18
69
69
  type: :runtime
70
70
  version_requirements: *id003
71
71
  - !ruby/object:Gem::Dependency
@@ -76,13 +76,13 @@ dependencies:
76
76
  requirements:
77
77
  - - "="
78
78
  - !ruby/object:Gem::Version
79
- hash: -1637175965
79
+ hash: -1637175967
80
80
  segments:
81
81
  - 1
82
82
  - 3
83
83
  - 0
84
- - pre16
85
- version: 1.3.0.pre16
84
+ - pre18
85
+ version: 1.3.0.pre18
86
86
  type: :runtime
87
87
  version_requirements: *id004
88
88
  - !ruby/object:Gem::Dependency
@@ -93,13 +93,13 @@ dependencies:
93
93
  requirements:
94
94
  - - "="
95
95
  - !ruby/object:Gem::Version
96
- hash: -1637175965
96
+ hash: -1637175967
97
97
  segments:
98
98
  - 1
99
99
  - 3
100
100
  - 0
101
- - pre16
102
- version: 1.3.0.pre16
101
+ - pre18
102
+ version: 1.3.0.pre18
103
103
  type: :runtime
104
104
  version_requirements: *id005
105
105
  - !ruby/object:Gem::Dependency
@@ -162,6 +162,7 @@ files:
162
162
  - VERSION
163
163
  - app/controllers/dev_controller.rb
164
164
  - app/controllers/dryml_support_controller.rb
165
+ - app/views/dev/summary.dryml
165
166
  - bin/hobo
166
167
  - config/initializers/inflections.rb
167
168
  - config/routes.rb
@@ -177,13 +178,13 @@ files:
177
178
  - lib/generators/hobo/admin_subsite/templates/admin_tag_injection.erb
178
179
  - lib/generators/hobo/admin_subsite/templates/controller.rb.erb
179
180
  - lib/generators/hobo/admin_subsite/templates/users_index.dryml
180
- - lib/generators/hobo/basic/basic_generator.rb
181
- - lib/generators/hobo/basic/templates/application.css
182
- - lib/generators/hobo/basic/templates/application.dryml.erb
183
- - lib/generators/hobo/basic/templates/dryml-support.js
184
- - lib/generators/hobo/basic/templates/dryml_taglibs_initializer.rb
185
- - lib/generators/hobo/basic/templates/en_injection.yml
186
- - lib/generators/hobo/basic/templates/guest.rb
181
+ - lib/generators/hobo/assets/assets_generator.rb
182
+ - lib/generators/hobo/assets/templates/application.css
183
+ - lib/generators/hobo/assets/templates/application.dryml.erb
184
+ - lib/generators/hobo/assets/templates/dryml-support.js
185
+ - lib/generators/hobo/assets/templates/dryml_taglibs_initializer.rb
186
+ - lib/generators/hobo/assets/templates/en_injection.yml
187
+ - lib/generators/hobo/assets/templates/guest.rb
187
188
  - lib/generators/hobo/controller.rb
188
189
  - lib/generators/hobo/controller/controller_generator.rb
189
190
  - lib/generators/hobo/controller/templates/controller.rb.erb
@@ -191,10 +192,6 @@ files:
191
192
  - lib/generators/hobo/front_controller/front_controller_generator.rb
192
193
  - lib/generators/hobo/front_controller/templates/controller.rb.erb
193
194
  - lib/generators/hobo/front_controller/templates/index.dryml
194
- - lib/generators/hobo/front_controller/templates/summary.dryml
195
- - lib/generators/hobo/hints/hints_generator.rb
196
- - lib/generators/hobo/hints/templates/hints.rb.erb
197
- - lib/generators/hobo/hints/templates/model_injection.rb.erb
198
195
  - lib/generators/hobo/i18n/i18n_generator.rb
199
196
  - lib/generators/hobo/i18n/templates/app.en.yml
200
197
  - lib/generators/hobo/i18n/templates/app.es-DO.yml
@@ -205,7 +202,6 @@ files:
205
202
  - lib/generators/hobo/i18n/templates/hobo.it.yml
206
203
  - lib/generators/hobo/i18n/templates/hobo.pt-PT.yml
207
204
  - lib/generators/hobo/invite_only.rb
208
- - lib/generators/hobo/model.rb
209
205
  - lib/generators/hobo/model/USAGE
210
206
  - lib/generators/hobo/model/model_generator.rb
211
207
  - lib/generators/hobo/model/templates/model_injection.rb.erb
@@ -296,6 +292,7 @@ files:
296
292
  - lib/hobo/model/scopes/apply_scopes.rb
297
293
  - lib/hobo/model/scopes/automatic_scopes.rb
298
294
  - lib/hobo/model/user.rb
295
+ - lib/hobo/model/view_hints.rb
299
296
  - lib/hobo/rapid/generators/rapid/cards.dryml.erb
300
297
  - lib/hobo/rapid/generators/rapid/forms.dryml.erb
301
298
  - lib/hobo/rapid/generators/rapid/pages.dryml.erb
@@ -317,10 +314,9 @@ files:
317
314
  - lib/hobo/rapid/taglibs/rapid_user_pages.dryml
318
315
  - lib/hobo/routes.rb
319
316
  - lib/hobo/undefined.rb
320
- - lib/hobo/view_hints.rb
321
317
  - test/doctest/hobo/hobo_helper.rdoctest
322
318
  - test/irt/generators/admin_subsite.irt
323
- - test/irt/generators/basic.irt
319
+ - test/irt/generators/assets.irt
324
320
  - test/irt/generators/controller.irt
325
321
  - test/irt/generators/front_controller.irt
326
322
  - test/irt/generators/helper.rb
@@ -1,12 +0,0 @@
1
- module Hobo
2
- class HintsGenerator < Rails::Generators::NamedBase
3
- source_root File.expand_path('../templates', __FILE__)
4
-
5
- check_class_collision :suffix => 'Hints'
6
-
7
- def generate_hints
8
- template 'hints.rb.erb', File.join("app/viewhints", "#{file_path}_hints.rb")
9
- end
10
-
11
- end
12
- end
@@ -1,5 +0,0 @@
1
- class <%= class_name %>Hints < Hobo::ViewHints
2
-
3
- # children :primary_collection1, :aside_collection1, :aside_collection2
4
-
5
- end
@@ -1,36 +0,0 @@
1
-
2
- hobo_model # Don't put anything above this
3
-
4
- fields do
5
- <% for attribute in field_attributes -%>
6
- <%= "%-#{max_attribute_length}s" % attribute.name %> :<%= attribute.type %>
7
- <% end -%>
8
- timestamps
9
- end
10
-
11
- <% for bt in bts -%>
12
- belongs_to :<%= bt %>
13
- <% end -%>
14
- <%= "\n" unless bts.empty? -%>
15
- <% for hm in hms -%>
16
- has_many :<%= hm %>, :dependent => :destroy
17
- <% end -%>
18
- <%= "\n" unless hms.empty? -%>
19
- # --- Permissions --- #
20
-
21
- def create_permitted?
22
- acting_user.administrator?
23
- end
24
-
25
- def update_permitted?
26
- acting_user.administrator?
27
- end
28
-
29
- def destroy_permitted?
30
- acting_user.administrator?
31
- end
32
-
33
- def view_permitted?(field)
34
- true
35
- end
36
-
@@ -1,13 +0,0 @@
1
- require 'generators/hobo_support/model'
2
- module Generators
3
- module Hobo
4
- Model = classy_module do
5
- include Generators::HoboSupport::Model
6
-
7
- def generate_hint_file
8
- invoke 'hobo:hints', [name]
9
- end
10
-
11
- end
12
- end
13
- end
@@ -1,101 +0,0 @@
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