hobo 1.3.0.pre29 → 1.3.0.pre31

Sign up to get free protection for your applications and to get access to all the features.
Files changed (30) hide show
  1. data/VERSION +1 -1
  2. data/app/controllers/dev_controller.rb +1 -1
  3. data/lib/generators/hobo/i18n/templates/hobo.de.yml +1 -1
  4. data/lib/generators/hobo/i18n/templates/hobo.en.yml +4 -4
  5. data/lib/generators/hobo/i18n/templates/hobo.es.yml +1 -1
  6. data/lib/generators/hobo/i18n/templates/hobo.it.yml +1 -1
  7. data/lib/generators/hobo/i18n/templates/hobo.pt-PT.yml +2 -2
  8. data/lib/generators/hobo/i18n/templates/hobo.ru.yml +1 -1
  9. data/lib/generators/hobo/rapid/templates/themes/clean-sidemenu/views/clean-sidemenu.dryml +1 -1
  10. data/lib/generators/hobo/setup_wizard/setup_wizard_generator.rb +1 -1
  11. data/lib/generators/hobo/user_controller/templates/controller.rb.erb +4 -2
  12. data/lib/hobo.rb +9 -4
  13. data/lib/hobo/controller.rb +6 -0
  14. data/lib/hobo/controller/authentication_support.rb +1 -1
  15. data/lib/hobo/controller/model.rb +12 -7
  16. data/lib/hobo/extensions/active_record/hobo_methods.rb +1 -1
  17. data/lib/hobo/extensions/i18n.rb +1 -0
  18. data/lib/hobo/helper.rb +4 -3
  19. data/lib/hobo/model.rb +2 -2
  20. data/lib/hobo/model/permissions.rb +1 -3
  21. data/lib/hobo/model/scopes/apply_scopes.rb +1 -1
  22. data/lib/hobo/model/{user.rb → user_base.rb} +1 -1
  23. data/lib/hobo/rapid/generators/rapid/pages.dryml.erb +4 -4
  24. data/lib/hobo/rapid/helper.rb +4 -1
  25. data/lib/hobo/rapid/taglibs/rapid_core.dryml +6 -6
  26. data/lib/hobo/rapid/taglibs/rapid_forms.dryml +3 -3
  27. data/lib/hobo/rapid/taglibs/rapid_i18n.dryml +2 -2
  28. data/lib/hobo/rapid/taglibs/rapid_pages.dryml +3 -2
  29. data/lib/hobo/rapid/taglibs/rapid_plus.dryml +25 -6
  30. metadata +6 -6
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.3.0.pre29
1
+ 1.3.0.pre31
@@ -5,7 +5,7 @@ class DevController < ActionController::Base
5
5
  before_filter :developer_modes_only
6
6
 
7
7
  def set_current_user
8
- model = params[:model] || Hobo::Model::User.default_user_model
8
+ model = params[:model] || Hobo::Model::UserBase.default_user_model
9
9
  self.current_user = if params[:login]
10
10
  model.where(model.login_attribute => params[:login]).first
11
11
  else
@@ -140,7 +140,7 @@ de:
140
140
  current_password_is_not_correct: "ist nicht korrekt"
141
141
  you_are_site_admin: "Sie sind jetzt der Administrator"
142
142
  you_signed_up: "Sie haben sich angemeldet"
143
- no: "Kein %{model}-Objekt gefunden."
143
+ none: "Kein %{model}-Objekt gefunden."
144
144
  confirm: "Sind Sie sich sicher?"
145
145
 
146
146
  # default hobo collection translation
@@ -63,7 +63,7 @@ en:
63
63
  forgot_password_sent:
64
64
  title: "Forgotten password - E-mail sent"
65
65
  heading: "Forgotten password - E-mail sent"
66
- text: "An e-mail with instructions on how you generate a new password has been sent to %{email_address}. If you don't receive this e-mail please check your spamfilter."
66
+ text: "An e-mail with instructions on how to generate a new password has been sent to %{email_address}. If you don't receive this e-mail please check your spam folder."
67
67
 
68
68
  account_disabled_page:
69
69
  title: "Account disabled"
@@ -131,15 +131,15 @@ en:
131
131
  current_password_is_not_correct: "is not correct"
132
132
  you_are_site_admin: "You are now the site administrator"
133
133
  you_signed_up: "You have signed up"
134
- no: "No %{model} available."
134
+ none: "No %{model} available."
135
135
  confirm: "Are you sure?"
136
136
 
137
137
  # default hobo collection translation
138
138
  collection:
139
139
  count: &collection_count
140
140
  zero: &no_model "No %{model}"
141
- one: "There is only one %{model} at the moment"
142
- other: "There are already %{count} %{model}"
141
+ one: "There is one %{model}."
142
+ other: "There are %{count} %{model}."
143
143
  # you can use the following to completely override the collection heading
144
144
  # be aware that you will loose the automatic Your <collection> / Jom's <collection>
145
145
  # default output for User models
@@ -138,7 +138,7 @@ es:
138
138
  current_password_is_not_correct: "no está correcta"
139
139
  you_are_site_admin: "Ahora usted es el administrador del sitio."
140
140
  you_signed_up: "Usted se inscribió."
141
- no: "No hay %{model} disponibles."
141
+ none: "No hay %{model} disponibles."
142
142
  confirm: "¿Está seguro?"
143
143
 
144
144
  # default hobo collection translation
@@ -137,7 +137,7 @@ it:
137
137
  current_password_is_not_correct: "non è esatta"
138
138
  you_are_site_admin: "Adesso sei amministratore del sito."
139
139
  you_signed_up: "Ti sei iscritto."
140
- no: "Nessun record %{model} disponibile."
140
+ none: "Nessun record %{model} disponibile."
141
141
  confirm: "Sei sicuro?"
142
142
 
143
143
  # default hobo collection translation
@@ -121,7 +121,7 @@
121
121
  success: "Obrigado por efectuar o registo!"
122
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
- success: "Está indetificado no sistema."
124
+ success: "Está identificado no sistema."
125
125
  error: "Não especificou um utilizador válido ({{login}}) e respectiva palavra-chave!"
126
126
  logout: "Saiu do sistema."
127
127
  reset_password: "A sua palavra-chave foi apagada."
@@ -132,7 +132,7 @@
132
132
  current_password_is_not_correct: "não está correta."
133
133
  you_are_site_admin: "Agora é o administrador do site"
134
134
  you_signed_up: "Acabou de se registar"
135
- no: "Nenhum #{model} disponível."
135
+ none: "Nenhum #{model} disponível."
136
136
  confirm: "Tem a certeza?"
137
137
 
138
138
  # default hobo collection translation
@@ -136,7 +136,7 @@ ru:
136
136
  current_password_is_not_correct: "неправильно"
137
137
  you_are_site_admin: "Вы получили права администратора сайта."
138
138
  you_signed_up: "Вы зарегестрировались."
139
- no: "Нет доступных %{model}ей."
139
+ none: "Нет доступных %{model}ей."
140
140
  confirm: "Вы уверены?"
141
141
 
142
142
  # default hobo collection translation
@@ -9,7 +9,7 @@
9
9
 
10
10
  <header: class="sidemenu" param>
11
11
  <live-search param if="&defined_route? :site_search"/>
12
- <account-nav if="&login_url(Hobo::Model::User.default_user_model)" param/>
12
+ <account-nav if="&login_url(Hobo::Model::UserBase.default_user_model)" param/>
13
13
  <h1 param="app-name"><a href="#{base_url}/"><app-name/></a></h1>
14
14
  </header:>
15
15
 
@@ -113,7 +113,7 @@ NOTE: You might want to sign up as the administrator before adding this!
113
113
  end
114
114
  inject_into_file 'app/controllers/application_controller.rb', <<EOI, :after => "protect_from_forgery\n" if private_site
115
115
  include Hobo::Controller::AuthenticationSupport
116
- before_filter :except => [:login, :forgot_password, :accept_invitation, :do_accept_invitation] do
116
+ before_filter :except => [:login, :forgot_password, :accept_invitation, :do_accept_invitation, :reset_password] do
117
117
  login_required unless #{@user_resource_name.camelize}.count == 0
118
118
  end
119
119
  EOI
@@ -17,8 +17,10 @@ class <%= class_name %>Controller < ApplicationController
17
17
 
18
18
  def do_accept_invitation
19
19
  do_transition_action :accept_invitation do
20
- self.current_user = this
21
- flash[:notice] = t("hobo.messages.you_signed_up", :default=>"You have signed up")
20
+ if this.valid?
21
+ self.current_user = this
22
+ flash[:notice] = t("hobo.messages.you_signed_up", :default=>"You have signed up")
23
+ end
22
24
  end
23
25
  end
24
26
  <% end -%>
data/lib/hobo.rb CHANGED
@@ -25,7 +25,7 @@ module Hobo
25
25
 
26
26
  class << self
27
27
 
28
- attr_accessor :current_theme
28
+ attr_accessor :current_theme, :engines
29
29
 
30
30
  def raw_js(s)
31
31
  RawJs.new(s)
@@ -64,13 +64,18 @@ module Hobo
64
64
 
65
65
  def subsites
66
66
  # Any directory inside app/controllers defines a subsite
67
- @subsites ||= Dir["#{Rails.root}/app/controllers/*"].map do |f|
68
- File.basename(f) if File.directory?(f)
69
- end.compact
67
+ app_dirs = ["#{Rails.root}/app"] + Hobo.engines.map { |e| "#{e}/app" }
68
+ @subsites ||= app_dirs.map do |app|
69
+ Dir["#{app}/controllers/*"].map do |f|
70
+ File.basename(f) if File.directory?(f)
71
+ end.compact
72
+ end.flatten
70
73
  end
71
74
 
72
75
  end
73
76
 
77
+ self.engines = []
78
+
74
79
  end
75
80
 
76
81
  require 'hobo/engine'
@@ -98,6 +98,12 @@ module Hobo
98
98
  end
99
99
 
100
100
 
101
+ # dryml does not use layouts
102
+ def action_has_layout?
103
+ false
104
+ end
105
+
106
+
101
107
  def dryml_context
102
108
  @this
103
109
  end
@@ -38,7 +38,7 @@ module Hobo
38
38
  # skip_before_filter :login_required
39
39
  #
40
40
  def login_required(user_model=nil)
41
- auth_model = user_model || Hobo::Model::User.default_user_model
41
+ auth_model = user_model || Hobo::Model::UserBase.default_user_model
42
42
  if current_user.guest?
43
43
  username, passwd = get_auth_data
44
44
  self.current_user = auth_model.authenticate(username, passwd) || nil if username && passwd && auth_model
@@ -50,15 +50,21 @@ module Hobo
50
50
 
51
51
 
52
52
  def self.all_controllers(subsite=nil, force=false)
53
+ controller_dirs = ["#{Rails.root}/app/controllers"] + Hobo.engines.map { |e| "#{e}/app/controllers" }
54
+
53
55
  # Load every controller in app/controllers/<subsite>...
54
56
  @controllers_loaded ||= {}
55
57
  if force || !@controllers_loaded[subsite]
56
- dir = "#{Rails.root}/app/controllers#{'/' + subsite if subsite}"
57
- Dir.entries(dir).each do |f|
58
- if f =~ /^[a-zA-Z_][a-zA-Z0-9_]*_controller\.rb$/
59
- name = f.remove(/.rb$/).camelize
60
- name = "#{subsite.camelize}::#{name}" if subsite
61
- name.constantize
58
+ controller_dirs.each do |controller_dir|
59
+ dir = "#{controller_dir}#{'/' + subsite if subsite}"
60
+ if File.directory?(dir)
61
+ Dir.entries(dir).each do |f|
62
+ if f =~ /^[a-zA-Z_][a-zA-Z0-9_]*_controller\.rb$/
63
+ name = f.remove(/.rb$/).camelize
64
+ name = "#{subsite.camelize}::#{name}" if subsite
65
+ name.constantize
66
+ end
67
+ end
62
68
  end
63
69
  end
64
70
  @controllers_loaded[subsite] = true
@@ -73,7 +79,6 @@ module Hobo
73
79
  end
74
80
 
75
81
 
76
-
77
82
  module ClassMethods
78
83
 
79
84
  attr_writer :model
@@ -5,7 +5,7 @@ ActiveRecord::Base.class_eval do
5
5
  end
6
6
  def self.hobo_user_model
7
7
  include Hobo::Model
8
- include Hobo::Model::User
8
+ include Hobo::Model::UserBase
9
9
  end
10
10
  alias_method :has_hobo_method?, :respond_to_without_attributes?
11
11
  end
@@ -3,6 +3,7 @@ I18n.module_eval do
3
3
 
4
4
  def translate_with_show_keys(key, options = {})
5
5
  translation = translate_without_show_keys(key, options)
6
+ return translation unless translation.is_a?(String)
6
7
  keys = normalize_keys(locale, key, options[:scope]).join('.')
7
8
  "[#{keys}]" + translation
8
9
  end
data/lib/hobo/helper.rb CHANGED
@@ -343,19 +343,19 @@ module Hobo
343
343
 
344
344
 
345
345
  # Login url for a given user record or user class
346
- def forgot_password_url(user_class=Hobo::Model::User.default_user_model)
346
+ def forgot_password_url(user_class=Hobo::Model::UserBase.default_user_model)
347
347
  send("#{user_class.name.underscore}_forgot_password_url") rescue nil
348
348
  end
349
349
 
350
350
 
351
351
  # Login url for a given user record or user class
352
- def login_url(user_class=Hobo::Model::User.default_user_model)
352
+ def login_url(user_class=Hobo::Model::UserBase.default_user_model)
353
353
  send("#{user_class.name.underscore}_login_url") rescue nil
354
354
  end
355
355
 
356
356
 
357
357
  # Sign-up url for a given user record or user class
358
- def signup_url(user_class=Hobo::Model::User.default_user_model)
358
+ def signup_url(user_class=Hobo::Model::UserBase.default_user_model)
359
359
  send("#{user_class.name.underscore}_signup_url") rescue nil
360
360
  end
361
361
 
@@ -395,6 +395,7 @@ module Hobo
395
395
  options = args.extract_options!
396
396
  target = args.empty? || args.first.is_a?(Symbol) ? this : args.shift
397
397
  action = args.first
398
+ return false if action.nil? && target.try.new_record?
398
399
 
399
400
  if target.respond_to?(:member_class) && (origin = target.try.origin)
400
401
  klass = origin.class
data/lib/hobo/model.rb CHANGED
@@ -142,7 +142,7 @@ module Hobo
142
142
  self.creator_attribute = name.to_sym if options.delete(:creator)
143
143
  validate = options.delete(:validate) {true}
144
144
 
145
- #FIXME - this should be in Hobo::Model::User
145
+ #FIXME - this should be in Hobo::Model::UserBase
146
146
  send(:login_attribute=, name.to_sym, validate) if options.delete(:login) && respond_to?(:login_attribute=)
147
147
  end
148
148
 
@@ -357,7 +357,7 @@ module Hobo
357
357
 
358
358
 
359
359
  def to_url_path
360
- "#{self.class.to_url_path}/#{to_param}" unless new_record?
360
+ "#{self.class.to_url_path}/#{to_param}"
361
361
  end
362
362
 
363
363
 
@@ -19,8 +19,6 @@ module Hobo
19
19
  attr_accessor :acting_user, :origin, :origin_attribute
20
20
 
21
21
  bool_attr_accessor :exempt_from_edit_checks
22
-
23
- define_callbacks :after_user_new
24
22
  end
25
23
  end
26
24
 
@@ -48,7 +46,7 @@ module Hobo
48
46
  r.set_creator user
49
47
  yield r if block_given?
50
48
  r.user_view(user)
51
- r.with_acting_user(user) { r.send :run_callbacks, :after_user_new }
49
+ r.with_acting_user(user) { r.try.after_user_new }
52
50
  end
53
51
  end
54
52
 
@@ -4,7 +4,7 @@ module Hobo
4
4
  module ApplyScopes
5
5
 
6
6
  def apply_scopes(scopes)
7
- result = self
7
+ result = scoped
8
8
  scopes.each_pair do |scope, arg|
9
9
  if arg.is_a?(Array)
10
10
  result = result.send(scope, *arg) unless arg.first.blank?
@@ -2,7 +2,7 @@ require 'digest/sha1'
2
2
 
3
3
  module Hobo
4
4
  module Model
5
- module User
5
+ module UserBase
6
6
 
7
7
  @user_models = []
8
8
 
@@ -33,7 +33,7 @@ model_key = model.to_s.underscore
33
33
  </h2>
34
34
 
35
35
  <p param="count" if>
36
- <ht key="<%= model_key %>.collection.count" count="&this.size">
36
+ <ht key="<%= model_key %>.collection.count" count="&collection_count">
37
37
  <count summary/>
38
38
  </ht>
39
39
  </p>
@@ -110,7 +110,7 @@ edit_link = linkable?(:edit)
110
110
  main_content = model.primary_content_attribute
111
111
  show_fields = standard_fields(:belongs_to).*.to_s - [model.name_attribute, main_content, creator, back_link, *boolean_fields].*.to_s
112
112
 
113
- is_user_model = model < Hobo::Model::User
113
+ is_user_model = model < Hobo::Model::UserBase
114
114
 
115
115
  collection = model.view_hints.primary_children
116
116
  if collection
@@ -273,7 +273,7 @@ owner_model = model.reflections[owner].klass
273
273
  linkable_owner = linkable?(owner_model, :show)
274
274
  owner_tag = linkable_owner ? "a" : "name"
275
275
 
276
- owner_is_user = owner_model < Hobo::Model::User
276
+ owner_is_user = owner_model < Hobo::Model::UserBase
277
277
 
278
278
  owner = model.reflections[owner].macro == :has_many ? owner.to_s.singularize : owner.to_s
279
279
  -%>
@@ -306,7 +306,7 @@ new_link = :new.in?(actions)
306
306
  </h3>
307
307
  <% end -%>
308
308
  <p param="count" if>
309
- <ht key="<%= model_key %>.collection.count" count="&this.size">
309
+ <ht key="<%= model_key %>.collection.count" count="&collection_count">
310
310
  <count summary/>
311
311
  </ht>
312
312
  </p>
@@ -102,7 +102,10 @@ module Hobo
102
102
  s.gsub(' ', '&nbsp;')
103
103
  end
104
104
 
105
-
105
+ # returns the number of items in the collection. See LH #889
106
+ def collection_count
107
+ this.try.to_int || this.try.total_entries || (this.try.loaded? && this.try.length) || this.try.count || this.try.length
108
+ end
106
109
 
107
110
 
108
111
  def in_place_editor(attributes, this=nil)
@@ -368,7 +368,7 @@ Or a new page if the context is a class:
368
368
 
369
369
  content = name if content.blank?
370
370
 
371
- href = object_url(target, action, (params || {}).merge(:subsite => subsite))
371
+ href = object_url(target, action, (params || {}).merge(:subsite => subsite)) unless (action.nil? && target.try.new_record?)
372
372
  if href.nil?
373
373
  # This target is registered with Hobo::Routes as not linkable
374
374
  content
@@ -472,13 +472,13 @@ Assuming the context is a blog post...
472
472
  <def tag="links-for-collection"><%= this.empty? ? "(none)" : context_map { a }.safe_join(", ") %></def>
473
473
 
474
474
  <!-- Renders `this` in localized :default format. `format` can be a symbol representing a locale key or a standard format string (see strftime) -->
475
- <def tag="view" for="Date" attrs="format"><%= this && (format||= :default) && I18n.backend.localize(I18n.locale, this, format) %></def>
475
+ <def tag="view" for="date" attrs="format"><%= this && (format||= :default) && I18n.backend.localize(I18n.locale, this, format) %></def>
476
476
 
477
477
  <!-- Renders `this` in localized :default format. `format` can be a symbol representing a Time::DATE_FORMATS or a standard format string (see strftime) -->
478
- <def tag="view" for="Time" attrs="format"><%= this && (format||= :time) && (format.is_a?(Symbol) ? this.to_s(format) : this.strftime(format) ) %></def>
478
+ <def tag="view" for="time" attrs="format"><%= this && (format||= :time) && (format.is_a?(Symbol) ? this.to_s(format) : this.strftime(format) ) %></def>
479
479
 
480
480
  <!-- Renders `this` in localized :default format. `format` can be a symbol representing a locale key or a standard format string (see strftime) -->
481
- <def tag="view" for="ActiveSupport::TimeWithZone" attrs="format"><%= this && (format||= :default) && I18n.backend.localize(I18n.locale, this, format) %></def>
481
+ <def tag="view" for="datetime" attrs="format"><%= this && (format||= :default) && I18n.backend.localize(I18n.locale, this, format) %></def>
482
482
 
483
483
  <!-- Renders localized `number_with_delimiter this`, or `format % this` if the `format` attribute is given -->
484
484
  <def tag="view" for="Numeric" attrs="format"><%= format ? format % this : number_with_delimiter(this) %></def>
@@ -564,7 +564,7 @@ You can pass a summary attribute, which will generate a complete localized sente
564
564
  raise Exception.new("asked for count of a string") if this.is_a?(String)
565
565
  Rails.logger.warn('The "prefix" attribute is deprecated: please, use a locale string') unless prefix.blank?
566
566
 
567
- c = this.try.to_int || this.try.total_entries || (this.try.loaded? && this.try.length) || this.try.count || this.try.length
567
+ c = collection_count
568
568
 
569
569
  # generated label will be pluralized
570
570
  label ||= case
@@ -772,7 +772,7 @@ Notes
772
772
 
773
773
  <!-- Development mode only - a menu to change the `current_user` -->
774
774
  <def tag="dev-user-changer">
775
- <set user="&Hobo::Model::User.default_user_model"/>
775
+ <set user="&Hobo::Model::UserBase.default_user_model"/>
776
776
  <select-menu if="&user && Rails.env.development?"
777
777
  first-option="#{t('hobo.dev_user_changer.guest', {:default=>'Guest'})}" options="&user.all(:limit => 30).*.login"
778
778
  onchange="location.href = '#{dev_support_path :action=>:set_current_user}?login=' + encodeURIComponent(this.options[this.selectedIndex].value)"
@@ -573,7 +573,7 @@ All the standard ajax attributes *except the callbacks* are supported (see the m
573
573
 
574
574
  -->
575
575
  <def tag="delete-button" attrs="label, update, in-place, image, confirm, fade, subsite"><%=
576
- in_place = false if in_place.nil? && this == @this && request.method == :get
576
+ in_place = false if in_place.nil? && this == @this && request.method.downcase == "get"
577
577
  url = object_url(this, :method => :delete, :subsite => subsite)
578
578
  if (Dryml.last_if = url && can_delete?)
579
579
  attributes = attributes.merge(if image
@@ -659,7 +659,7 @@ For situations where there are too many target records to practically include in
659
659
  -->
660
660
  <def tag="select-one" attrs="include-none, blank-message, options, sort, limit, text-method"><%
661
661
  raise Hobo::PermissionDeniedError.new("Not allowed to edit #{this_field}") if !attributes[:disabled] && !can_edit?
662
- blank_message ||= ht("#{this_type.name.underscore}.message.no", :default=>"(No #{this_type.model_name.human})")
662
+ blank_message ||= ht("#{this_type.name.underscore}.messages.none", :default=>"No #{this_type.model_name.human} available.")
663
663
  limit ||= 100
664
664
 
665
665
  options ||= begin
@@ -785,7 +785,7 @@ If you wish to set `min-chars` to 0, you will require this [patch to controls.js
785
785
  <!-- Renders a localized list of error messages following a form submission. Expects the errors to be in `this.errors`. Renders nothing if there are no errors.
786
786
  -->
787
787
  <def tag="error-messages">
788
- <section class="error-messages" merge-attrs if="&this.errors.length > 0">
788
+ <section class="error-messages" merge-attrs if="&this.errors.size > 0">
789
789
  <h2 param="heading">
790
790
  <t key="activerecord.errors.template.header" model="&this.class.model_name.human" count="&this.errors.size">
791
791
  <%= model = this.class.model_name.human
@@ -42,7 +42,7 @@
42
42
  <!-- Used to localize and pluralize collection names.
43
43
  A collection name is a special case of an attribute name, (indeed you should store the collection names as attribute names in the locale files), so this tag internally uses human_attribute_name to return them.
44
44
 
45
- With the `your` attribute and in the special case the context is a Hobo::Model::User instance it automatically embeds the `your` tag funtionality. (note: :name is added by default as an interpolable variable)
45
+ With the `your` attribute and in the special case the context is a Hobo::Model::UserMixin instance it automatically embeds the `your` tag funtionality. (note: :name is added by default as an interpolable variable)
46
46
 
47
47
  ### Attributes
48
48
 
@@ -96,7 +96,7 @@ With the `your` attribute and in the special case the context is a Hobo::Model::
96
96
  # prepare symbolized attributes for merging
97
97
  attrs = {}
98
98
  all_attributes.each_pair{|k,v| attrs[k.to_sym] = v} -%>
99
- <% if your && belong_class < Hobo::Model::User && this.kind_of?(Hobo::Model::User) && I18n.locale == :en -%>
99
+ <% if your && belong_class < Hobo::Model::UserBase && this.kind_of?(Hobo::Model::UserBase) && I18n.locale == :en -%>
100
100
  <your key="&collection" merge-attrs="&{:name=>this.name}.merge(attrs)" capitalize>
101
101
  <%= belong_class.human_attribute_name(collection.to_sym, attrs) %>
102
102
  </your>
@@ -24,7 +24,7 @@ The easiest way to see what this tag does is to look at the source.
24
24
  </do>
25
25
 
26
26
  <do param="scripts">
27
- <javascript param name="prototype, effects, dragdrop, controls, lowpro, hobo-rapid"/>
27
+ <javascript param name="prototype, effects, dragdrop, controls, rails, lowpro, hobo-rapid"/>
28
28
  <if-ie version="lt IE 7" param="fix-ie6">
29
29
  <javascript name="IE7"/>
30
30
  <javascript name="ie7-recalc"/>
@@ -32,13 +32,14 @@ The easiest way to see what this tag does is to look at the source.
32
32
  <do param="custom-scripts"/>
33
33
  <javascript param="application-javascript" name="application"/>
34
34
  </do>
35
+ <%= csrf_meta_tag %>
35
36
  </head>
36
37
 
37
38
  <body param>
38
39
  <set-scoped flash-rendered="&false">
39
40
  <ajax-progress param/>
40
41
  <header class="page-header" param>
41
- <account-nav if="&login_url(Hobo::Model::User.default_user_model)" param/>
42
+ <account-nav if="&login_url(Hobo::Model::UserBase.default_user_model)" param/>
42
43
  <h1 param="app-name"><a href="#{base_url}/"><app-name/></a></h1>
43
44
  <live-search param if="&defined_route? :site_search"/>
44
45
  <main-nav current="&title" param/>
@@ -171,16 +171,35 @@ See [Filtering stories by status](/tutorials/agility#filtering_stories_by_status
171
171
  - `options` - an array of options or an array of arrays (useful for localized apps) for the menu.
172
172
  It can be omitted if you provide the options as an array or array of arrays in the locale file.
173
173
  - `no-filter` - The text of the first option which indicates no filter is in effect. Defaults to 'All'
174
+ - `first-value` - the value to be used with the first option. Typically not used,
175
+ meaning the option has a blank value.
176
+ - model - the model name (optional: needed if you use the "activerecord.attributes" namespace.
174
177
 
175
178
  ### I18n
176
179
 
177
- It lookups the options attributes in filter_menu.#{param_name}.options.
180
+ It lookups the options attributes in "activerecord.attributes.#{model}.filter_menu.#{param\_name}.options"
181
+ with fallback to "filter_menu.#{param_name}.options".
178
182
  The passed options are used as a default in case the lookup fails.
179
- Besides the "tags.filter_menu.default.no_filter" key is used as default of the attribute "no-filter"
183
+ Besides the "activerecord.attributes.#{model}.filter_menu.#{param_name}.no_filter" or
184
+ "tags.filter_menu.default.no_filter" key is used as default of the attribute "no-filter"
180
185
  (or "All" if no default is found)
181
186
 
182
187
  ### I18n Example
183
188
 
189
+
190
+ es:
191
+ activerecord:
192
+ attributes:
193
+ <model_name>:
194
+ filter_menu:
195
+ period:
196
+ no_filter: Todos Períodos
197
+ options:
198
+ - [ "Hoy", "today" ]
199
+ - [ "Ayer", "yesterday" ]
200
+
201
+ or
202
+
184
203
  es:
185
204
  tags:
186
205
  filter_menu:
@@ -209,16 +228,16 @@ Besides the "tags.filter_menu.default.no_filter" key is used as default of the a
209
228
  </select>
210
229
 
211
230
  -->
212
- <def tag="filter-menu" attrs="param-name, options, no-filter, id">
213
- <% opt = t("tags.filter_menu.#{param_name}.options", :default=>'')
231
+ <def tag="filter-menu" attrs="model, param-name, options, no-filter, id, first-value">
232
+ <% opt = t("activerecord.attributes.#{model}.filter_menu.#{param_name}.options", :default=>[:"tags.filter_menu.#{param_name}.options"])
214
233
  options = opt unless opt.blank?
215
- no_filter = t("tags.filter_menu.#{param_name}.no_filter", :default=>[:"tags.filter_menu.default.no_filter", no_filter, "All"]) %>
234
+ no_filter = t("activerecord.attributes.#{model}.filter_menu.#{param_name}.no_filter", :default=>[:"tags.filter_menu.#{param_name}.no_filter", :"tags.filter_menu.default.no_filter", no_filter, "All"]) %>
216
235
  <form action="&request.fullpath" method="get" class="filter-menu" merge-attrs="id">
217
236
  <div>
218
237
  <% opt = options.first.kind_of?(Array) ? options.*.last : options
219
238
  selected = opt.detect {|o| o.to_s==params[param_name.gsub('-', '_')] } %>
220
239
  <select-menu name="&param_name" options="&options" selected="&selected"
221
- first-option="&no_filter" key="&param_name" merge-params/>
240
+ first-option="&no_filter" first-value="&first_value" key="&param_name" merge-params/>
222
241
  </div>
223
242
  </form>
224
243
  </def>
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: hobo
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease: 6
5
- version: 1.3.0.pre29
5
+ version: 1.3.0.pre31
6
6
  platform: ruby
7
7
  authors:
8
8
  - Tom Locke
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-03-05 00:00:00 -04:00
13
+ date: 2011-03-29 00:00:00 -04:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -43,7 +43,7 @@ dependencies:
43
43
  requirements:
44
44
  - - "="
45
45
  - !ruby/object:Gem::Version
46
- version: 1.3.0.pre29
46
+ version: 1.3.0.pre31
47
47
  type: :runtime
48
48
  version_requirements: *id003
49
49
  - !ruby/object:Gem::Dependency
@@ -54,7 +54,7 @@ dependencies:
54
54
  requirements:
55
55
  - - "="
56
56
  - !ruby/object:Gem::Version
57
- version: 1.3.0.pre29
57
+ version: 1.3.0.pre31
58
58
  type: :runtime
59
59
  version_requirements: *id004
60
60
  - !ruby/object:Gem::Dependency
@@ -65,7 +65,7 @@ dependencies:
65
65
  requirements:
66
66
  - - "="
67
67
  - !ruby/object:Gem::Version
68
- version: 1.3.0.pre29
68
+ version: 1.3.0.pre31
69
69
  type: :runtime
70
70
  version_requirements: *id005
71
71
  - !ruby/object:Gem::Dependency
@@ -260,7 +260,7 @@ files:
260
260
  - lib/hobo/model/scopes.rb
261
261
  - lib/hobo/model/scopes/apply_scopes.rb
262
262
  - lib/hobo/model/scopes/automatic_scopes.rb
263
- - lib/hobo/model/user.rb
263
+ - lib/hobo/model/user_base.rb
264
264
  - lib/hobo/model/view_hints.rb
265
265
  - lib/hobo/rapid/generators/rapid/cards.dryml.erb
266
266
  - lib/hobo/rapid/generators/rapid/forms.dryml.erb