hobo 1.3.0.pre20 → 1.3.0.pre21
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.
- data/VERSION +1 -1
- data/lib/generators/hobo/setup_wizard/setup_wizard_generator.rb +1 -1
- data/lib/generators/hobo/test_framework/test_framework_generator.rb +1 -1
- data/lib/hobo/controller/model.rb +1 -1
- data/lib/hobo/extensions/action_view/translation_helper.rb +14 -7
- data/lib/hobo/helper/translations.rb +3 -25
- data/lib/hobo/helper/translations/normalizer.rb +39 -0
- data/lib/hobo/rapid/taglibs/rapid_forms.dryml +1 -1
- data/lib/hobo/rapid/taglibs/rapid_navigation.dryml +1 -1
- metadata +14 -13
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.3.0.
|
1
|
+
1.3.0.pre21
|
@@ -151,7 +151,7 @@ EOI
|
|
151
151
|
:invite_only => @invite_only,
|
152
152
|
:activation_email => @activation_email,
|
153
153
|
:admin_subsite_name => @admin_subsite_name
|
154
|
-
|
154
|
+
return unless @invite_only
|
155
155
|
say "Installing admin subsite..."
|
156
156
|
invoke 'hobo:admin_subsite', [@admin_subsite_name],
|
157
157
|
:user_resource_name => @user_resource_name,
|
@@ -42,7 +42,7 @@ private
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def setup_rspec
|
45
|
-
gem 'rspec-rails', '>= 2.0.0
|
45
|
+
gem 'rspec-rails', '>= 2.0.0', :group => [:test, :development]
|
46
46
|
@should_update = true
|
47
47
|
return unless options[:update]
|
48
48
|
@finalize_hooks << lambda {say "Finalizing rspec installation..."; invoke 'rspec:install'}
|
@@ -590,7 +590,7 @@ module Hobo
|
|
590
590
|
|
591
591
|
def update_response(in_place_edit_field=nil, options={}, &b)
|
592
592
|
|
593
|
-
flash_notice (ht(:"#{@this.class.
|
593
|
+
flash_notice (ht(:"#{@this.class.to_s.underscore}.messages.update.success", :default=>["Changes to the #{@this.class.model_name.human} were saved"])) if valid?
|
594
594
|
|
595
595
|
response_block(&b) or
|
596
596
|
if valid?
|
@@ -1,18 +1,25 @@
|
|
1
1
|
ActionView::Helpers::TranslationHelper.module_eval do
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
#
|
6
|
-
#
|
7
|
-
|
3
|
+
include Hobo::Helper::Translations::Normalizer
|
4
|
+
|
5
|
+
# simple wrapper around the translate helper
|
6
|
+
# it implements a dryml <translate> and a <t> tag
|
7
|
+
# Improved security: interpolated variables are escaped
|
8
|
+
# Improved management: when it returns a string it is always html_safe
|
9
|
+
# It assumes the base translation string is html_safe
|
10
|
+
# It removes the <span> tag when the key is missing, because it would mess up
|
11
|
+
# the dryml tags when ht or t is used in some place
|
12
|
+
|
13
|
+
def translate(key, options={})
|
14
|
+
key, options = normalize_args(key, options)
|
8
15
|
translation = I18n.translate(scope_key_by_partial(key), options.merge!(:raise => true))
|
9
|
-
if
|
16
|
+
if translation.respond_to?(:html_safe)
|
10
17
|
translation.html_safe
|
11
18
|
else
|
12
19
|
translation
|
13
20
|
end
|
14
21
|
rescue I18n::MissingTranslationData => e
|
15
|
-
keys = I18n.normalize_keys(
|
22
|
+
keys = I18n.normalize_keys(e.locale, e.key, e.options[:scope]).join('.')
|
16
23
|
"[MISSING: #{keys}]"
|
17
24
|
end
|
18
25
|
alias_method :t, :translate
|
@@ -2,14 +2,7 @@ module Hobo
|
|
2
2
|
module Helper
|
3
3
|
module Translations
|
4
4
|
|
5
|
-
|
6
|
-
# it implements a dryml <translate> and a <t> tag
|
7
|
-
|
8
|
-
def translate(*args)
|
9
|
-
key, options = normalize_args(*args)
|
10
|
-
super key.to_sym, options
|
11
|
-
end
|
12
|
-
alias_method :t, :translate
|
5
|
+
include Normalizer
|
13
6
|
|
14
7
|
=begin
|
15
8
|
|
@@ -46,7 +39,7 @@ en:
|
|
46
39
|
model_name = keys.shift
|
47
40
|
model_class = begin model_name.camelize.constantize; rescue; end
|
48
41
|
unless model_class && model_class < ActiveRecord::Base
|
49
|
-
raise Hobo::I18nError, %(wrong model name: "#{model_name}" (extracted from translation key). You might want to use the translate/t tag/method instead.)
|
42
|
+
raise Hobo::I18nError, %(wrong model name: "#{model_name}" (extracted from translation key: "#{key}"). You might want to use the translate/t tag/method instead.)
|
50
43
|
end
|
51
44
|
options[:default].unshift("hobo.#{keys.join(".")}".to_sym)
|
52
45
|
options[:model] = model_class.model_name.human(:count=>options[:count]||1)
|
@@ -54,22 +47,7 @@ en:
|
|
54
47
|
end
|
55
48
|
alias_method :ht, :hobo_translate
|
56
49
|
|
57
|
-
|
58
|
-
|
59
|
-
def normalize_args(key, options={})
|
60
|
-
if (key.class == Hash) # called as a tag
|
61
|
-
if key.has_key?(:default) && !key[:default].blank?
|
62
|
-
Rails.logger.warn "hobo-i18n: 'default' should not be used as an attribute on *translate tags. If used, then you need to make sure that the tags inner-contents are not used. These are normally treated as defaults automatically, but if there is a default attribute then that inner-content will be hidden from this method - and will not be replaced with the translation found."
|
63
|
-
end
|
64
|
-
defaults = options[:default]
|
65
|
-
options = key
|
66
|
-
key = options.delete(:key)
|
67
|
-
# Set options[:default] to complete the tag-argument-conversion process.
|
68
|
-
options[:default] = defaults.call(options) if defaults.class == Proc
|
69
|
-
end
|
70
|
-
options[:default] = Array.wrap options[:default]
|
71
|
-
[key, options]
|
72
|
-
end
|
50
|
+
|
73
51
|
|
74
52
|
end
|
75
53
|
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'active_support/core_ext/string/output_safety'
|
2
|
+
module Hobo
|
3
|
+
module Helper
|
4
|
+
module Translations
|
5
|
+
module Normalizer
|
6
|
+
|
7
|
+
private
|
8
|
+
|
9
|
+
def normalize_args(key, options={})
|
10
|
+
if (key.class == Hash) # called as a tag
|
11
|
+
if key.has_key?(:default) && !key[:default].blank?
|
12
|
+
Rails.logger.warn "hobo-i18n: 'default' should not be used as an attribute on *translate tags. If used, then you need to make sure that the tags inner-contents are not used. These are normally treated as defaults automatically, but if there is a default attribute then that inner-content will be hidden from this method - and will not be replaced with the translation found."
|
13
|
+
end
|
14
|
+
defaults = options[:default]
|
15
|
+
options = key
|
16
|
+
key = options.delete(:key)
|
17
|
+
# Set options[:default] to complete the tag-argument-conversion process.
|
18
|
+
options[:default] = defaults.call(options) if defaults.class == Proc
|
19
|
+
end
|
20
|
+
escape_options(options)
|
21
|
+
options[:default] = Array.wrap options[:default]
|
22
|
+
[key, options]
|
23
|
+
end
|
24
|
+
|
25
|
+
def escape_options(options)
|
26
|
+
options.each_pair do |k,v|
|
27
|
+
options[k] = case v
|
28
|
+
when Array
|
29
|
+
v.map {|i| i.respond_to?(:html_safe) ? ERB::Util.html_escape(i) : i}
|
30
|
+
else
|
31
|
+
v.respond_to?(:html_safe) ? ERB::Util.html_escape(v) : v
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -653,7 +653,7 @@ For situations where there are too many target records to practically include in
|
|
653
653
|
-->
|
654
654
|
<def tag="select-one" attrs="include-none, blank-message, options, sort, limit, text-method"><%
|
655
655
|
raise Hobo::PermissionDeniedError.new("Not allowed to edit #{this_field}") if !attributes[:disabled] && !can_edit?
|
656
|
-
blank_message ||= ht("#{this_type.name.
|
656
|
+
blank_message ||= ht("#{this_type.name.underscore}.message.no", :default=>"(No #{this_type.model_name.human})")
|
657
657
|
limit ||= 100
|
658
658
|
|
659
659
|
options ||= begin
|
@@ -89,7 +89,7 @@ This is a simple tag - just look at the source if you need to know more detail.
|
|
89
89
|
<ul class="navigation account-nav" param>
|
90
90
|
<li if="&Rails.env.development?" param="dev-user-changer"><dev-user-changer/></li>
|
91
91
|
<if test="&logged_in?">
|
92
|
-
<li class='nav-item' param="logged-in-as"><a to="¤t_user"><t key="hobo.actions.
|
92
|
+
<li class='nav-item' param="logged-in-as"><a to="¤t_user"><t key="hobo.actions.logged_in_as" name="&name">Logged in as <name/></t></a></li>
|
93
93
|
<li class='nav-item' param="account"><a action="account"><t key="hobo.actions.account">Account</t></a></li>
|
94
94
|
<li class='nav-item' param="log-out"><a href="&logout_url"><t key="hobo.actions.logout">Log out</t></a></li>
|
95
95
|
</if>
|
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: -
|
4
|
+
hash: -1637108441
|
5
5
|
prerelease: true
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 3
|
9
9
|
- 0
|
10
|
-
-
|
11
|
-
version: 1.3.0.
|
10
|
+
- pre21
|
11
|
+
version: 1.3.0.pre21
|
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-
|
19
|
+
date: 2010-11-24 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: -
|
62
|
+
hash: -1637108441
|
63
63
|
segments:
|
64
64
|
- 1
|
65
65
|
- 3
|
66
66
|
- 0
|
67
|
-
-
|
68
|
-
version: 1.3.0.
|
67
|
+
- pre21
|
68
|
+
version: 1.3.0.pre21
|
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: -
|
79
|
+
hash: -1637108441
|
80
80
|
segments:
|
81
81
|
- 1
|
82
82
|
- 3
|
83
83
|
- 0
|
84
|
-
-
|
85
|
-
version: 1.3.0.
|
84
|
+
- pre21
|
85
|
+
version: 1.3.0.pre21
|
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: -
|
96
|
+
hash: -1637108441
|
97
97
|
segments:
|
98
98
|
- 1
|
99
99
|
- 3
|
100
100
|
- 0
|
101
|
-
-
|
102
|
-
version: 1.3.0.
|
101
|
+
- pre21
|
102
|
+
version: 1.3.0.pre21
|
103
103
|
type: :runtime
|
104
104
|
version_requirements: *id005
|
105
105
|
- !ruby/object:Gem::Dependency
|
@@ -278,6 +278,7 @@ files:
|
|
278
278
|
- lib/hobo/extensions/i18n.rb
|
279
279
|
- lib/hobo/helper.rb
|
280
280
|
- lib/hobo/helper/translations.rb
|
281
|
+
- lib/hobo/helper/translations/normalizer.rb
|
281
282
|
- lib/hobo/model.rb
|
282
283
|
- lib/hobo/model/accessible_associations.rb
|
283
284
|
- lib/hobo/model/find_for.rb
|