padrino-helpers 0.9.6 → 0.9.7
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/README.rdoc +19 -19
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/lib/padrino-helpers.rb +6 -6
- data/lib/padrino-helpers/asset_tag_helpers.rb +132 -110
- data/lib/padrino-helpers/form_builder/abstract_form_builder.rb +1 -1
- data/lib/padrino-helpers/form_builder/standard_form_builder.rb +2 -2
- data/lib/padrino-helpers/form_helpers.rb +66 -66
- data/lib/padrino-helpers/format_helpers.rb +29 -29
- data/lib/padrino-helpers/locale/de.yml +3 -3
- data/lib/padrino-helpers/locale/en.yml +7 -7
- data/lib/padrino-helpers/locale/it.yml +3 -3
- data/lib/padrino-helpers/number_helpers.rb +23 -23
- data/lib/padrino-helpers/output_helpers.rb +31 -31
- data/lib/padrino-helpers/render_helpers.rb +4 -4
- data/lib/padrino-helpers/tag_helpers.rb +11 -11
- data/lib/padrino-helpers/translation_helpers.rb +2 -2
- data/padrino-helpers.gemspec +5 -5
- data/test/fixtures/markup_app/views/capture_concat.erb +1 -1
- data/test/fixtures/markup_app/views/capture_concat.haml +1 -2
- data/test/fixtures/markup_app/views/content_for.erb +3 -3
- data/test/fixtures/markup_app/views/content_for.haml +2 -2
- data/test/fixtures/markup_app/views/content_tag.erb +1 -1
- data/test/fixtures/markup_app/views/content_tag.haml +1 -1
- data/test/fixtures/markup_app/views/form_for.erb +1 -1
- data/test/fixtures/markup_app/views/form_for.haml +2 -2
- data/test/fixtures/markup_app/views/form_tag.erb +1 -1
- data/test/fixtures/render_app/app.rb +2 -2
- data/test/fixtures/render_app/views/template/_user.haml +1 -1
- data/test/helper.rb +0 -4
- data/test/test_asset_tag_helpers.rb +27 -10
- data/test/test_form_builder.rb +18 -10
- data/test/test_form_helpers.rb +8 -4
- data/test/test_tag_helpers.rb +0 -1
- metadata +5 -5
@@ -3,7 +3,7 @@ module Padrino
|
|
3
3
|
module TranslationHelpers
|
4
4
|
##
|
5
5
|
# Delegates to I18n.translate with no additional functionality.
|
6
|
-
#
|
6
|
+
#
|
7
7
|
def translate(*args)
|
8
8
|
I18n.translate(*args)
|
9
9
|
end
|
@@ -11,7 +11,7 @@ module Padrino
|
|
11
11
|
|
12
12
|
##
|
13
13
|
# Delegates to I18n.localize with no additional functionality.
|
14
|
-
#
|
14
|
+
#
|
15
15
|
def localize(*args)
|
16
16
|
I18n.localize(*args)
|
17
17
|
end
|
data/padrino-helpers.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{padrino-helpers}
|
8
|
-
s.version = "0.9.
|
8
|
+
s.version = "0.9.7"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Padrino Team", "Nathan Esquenazi", "Davide D'Agostino", "Arthur Chiu"]
|
12
|
-
s.date = %q{2010-03-
|
12
|
+
s.date = %q{2010-03-22}
|
13
13
|
s.description = %q{Tag helpers, asset helpers, form helpers, form builders and many more helpers for padrino}
|
14
14
|
s.email = %q{padrinorb@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -84,14 +84,14 @@ Gem::Specification.new do |s|
|
|
84
84
|
s.specification_version = 3
|
85
85
|
|
86
86
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
87
|
-
s.add_runtime_dependency(%q<padrino-core>, ["= 0.9.
|
87
|
+
s.add_runtime_dependency(%q<padrino-core>, ["= 0.9.7"])
|
88
88
|
s.add_development_dependency(%q<haml>, [">= 2.2.1"])
|
89
89
|
s.add_development_dependency(%q<shoulda>, [">= 2.10.3"])
|
90
90
|
s.add_development_dependency(%q<mocha>, [">= 0.9.7"])
|
91
91
|
s.add_development_dependency(%q<rack-test>, [">= 0.5.0"])
|
92
92
|
s.add_development_dependency(%q<webrat>, [">= 0.5.1"])
|
93
93
|
else
|
94
|
-
s.add_dependency(%q<padrino-core>, ["= 0.9.
|
94
|
+
s.add_dependency(%q<padrino-core>, ["= 0.9.7"])
|
95
95
|
s.add_dependency(%q<haml>, [">= 2.2.1"])
|
96
96
|
s.add_dependency(%q<shoulda>, [">= 2.10.3"])
|
97
97
|
s.add_dependency(%q<mocha>, [">= 0.9.7"])
|
@@ -99,7 +99,7 @@ Gem::Specification.new do |s|
|
|
99
99
|
s.add_dependency(%q<webrat>, [">= 0.5.1"])
|
100
100
|
end
|
101
101
|
else
|
102
|
-
s.add_dependency(%q<padrino-core>, ["= 0.9.
|
102
|
+
s.add_dependency(%q<padrino-core>, ["= 0.9.7"])
|
103
103
|
s.add_dependency(%q<haml>, [">= 2.2.1"])
|
104
104
|
s.add_dependency(%q<shoulda>, [">= 2.10.3"])
|
105
105
|
s.add_dependency(%q<mocha>, [">= 0.9.7"])
|
@@ -1,11 +1,11 @@
|
|
1
1
|
<% content_for :demo do %>
|
2
2
|
<h1>This is content yielded from a content_for</h1>
|
3
3
|
<% end %>
|
4
|
-
|
4
|
+
|
5
5
|
<div class='demo'><%= yield_content :demo %></div>
|
6
|
-
|
6
|
+
|
7
7
|
<% content_for :demo2 do |fname, lname| %>
|
8
8
|
<h1>This is content yielded with name <%= fname + " " + lname %></h1>
|
9
9
|
<% end %>
|
10
|
-
|
10
|
+
|
11
11
|
<div class='demo2'><%= yield_content :demo2, "Johnny", "Smith" %></div>
|
@@ -1,9 +1,9 @@
|
|
1
1
|
- content_for :demo do
|
2
2
|
%h1 This is content yielded from a content_for
|
3
|
-
|
3
|
+
|
4
4
|
.demo= yield_content :demo
|
5
5
|
|
6
6
|
- content_for :demo2 do |fname, lname|
|
7
7
|
%h1 This is content yielded with name #{fname + " " + lname}
|
8
|
-
|
8
|
+
|
9
9
|
.demo2= yield_content :demo2, "Johnny", "Smith"
|
@@ -15,7 +15,7 @@
|
|
15
15
|
= f.file_field :photo, :class => 'user-photo'
|
16
16
|
%p
|
17
17
|
= f.label :about, :caption => "About Me: "
|
18
|
-
= f.text_area :about, :class => 'user-about'
|
18
|
+
= f.text_area :about, :class => 'user-about'
|
19
19
|
%p
|
20
20
|
= f.label :gender, :caption => "Your gender: "
|
21
21
|
= f.radio_button :gender, :value => 'male'
|
@@ -42,6 +42,6 @@
|
|
42
42
|
= f.select_block :state, :options => ['California', 'Texas'], :class => 'selector'
|
43
43
|
= f.submit_block "Create", { :class => 'button' }
|
44
44
|
= f.image_submit_block "buttons/ok.png", { :class => 'image' }
|
45
|
-
|
45
|
+
|
46
46
|
- form_for :markup_user, '/third_demo', :id => 'demo3', :method => 'get' do |f|
|
47
47
|
= f.text_field_block :username
|
@@ -24,7 +24,7 @@
|
|
24
24
|
<%= text_field_tag :username, :value => params[:username], :id => 'the_username' %>
|
25
25
|
</p>
|
26
26
|
<p>
|
27
|
-
<%= label_tag :password, :class => 'first' %>
|
27
|
+
<%= label_tag :password, :class => 'first' %>
|
28
28
|
<%= password_field_tag :password, :value => params[:password] %>
|
29
29
|
</p>
|
30
30
|
<p>
|
@@ -14,12 +14,12 @@ class RenderDemo < Padrino::Application
|
|
14
14
|
get '/partial/object' do
|
15
15
|
partial 'template/user', :object => RenderUser.new('John'), :locals => { :extra => "bar" }
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
# partial with collection
|
19
19
|
get '/partial/collection' do
|
20
20
|
partial 'template/user', :collection => [RenderUser.new('John'), RenderUser.new('Billy')], :locals => { :extra => "bar" }
|
21
21
|
end
|
22
|
-
|
22
|
+
|
23
23
|
# partial with locals
|
24
24
|
get '/partial/locals' do
|
25
25
|
partial 'template/user', :locals => { :user => RenderUser.new('John'), :extra => "bar" }
|
data/test/helper.rb
CHANGED
@@ -109,20 +109,27 @@ class TestAssetTagHelpers < Test::Unit::TestCase
|
|
109
109
|
|
110
110
|
context 'for #image_tag method' do
|
111
111
|
should "display image tag absolute link with no options" do
|
112
|
-
|
112
|
+
time = stop_time_for_test
|
113
|
+
assert_has_tag('img', :src => "/absolute/pic.gif?#{time.to_i}") { image_tag('/absolute/pic.gif') }
|
113
114
|
end
|
114
115
|
should "display image tag absolute link with specified uri root" do
|
116
|
+
time = stop_time_for_test
|
115
117
|
self.class.stubs(:uri_root).returns("/blog")
|
116
|
-
assert_has_tag('img', :src => "/blog/images/relative/pic.gif") { image_tag('relative/pic.gif') }
|
118
|
+
assert_has_tag('img', :src => "/blog/images/relative/pic.gif?#{time.to_i}") { image_tag('relative/pic.gif') }
|
117
119
|
end
|
118
120
|
should "display image tag relative link with options" do
|
119
|
-
|
121
|
+
time = stop_time_for_test
|
122
|
+
assert_has_tag('img.photo', :src => "/images/relative/pic.gif?#{time.to_i}") {
|
123
|
+
image_tag('relative/pic.gif', :class => 'photo') }
|
120
124
|
end
|
121
125
|
should "display image tag uri link with options" do
|
126
|
+
time = stop_time_for_test
|
122
127
|
assert_has_tag('img.photo', :src => "http://demo.org/pic.gif") { image_tag('http://demo.org/pic.gif', :class => 'photo') }
|
123
128
|
end
|
124
129
|
should "display image tag relative link with incorrect spacing" do
|
125
|
-
|
130
|
+
time = stop_time_for_test
|
131
|
+
assert_has_tag('img.photo', :src => "/images/relative/pic.gif?#{time.to_i}") {
|
132
|
+
image_tag(' relative/ pic.gif ', :class => 'photo') }
|
126
133
|
end
|
127
134
|
end
|
128
135
|
|
@@ -202,24 +209,34 @@ class TestAssetTagHelpers < Test::Unit::TestCase
|
|
202
209
|
assert_has_tag('script', :src => "http://google.com/lib.js") { actual_html }
|
203
210
|
end
|
204
211
|
end
|
205
|
-
|
212
|
+
|
206
213
|
context "for #favicon_tag method" do
|
207
214
|
should "display favicon" do
|
208
215
|
time = stop_time_for_test
|
209
216
|
actual_html = favicon_tag('icons/favicon.png')
|
210
|
-
assert_has_tag('link', :rel => 'icon', :type => 'image/png', :href =>
|
217
|
+
assert_has_tag('link', :rel => 'icon', :type => 'image/png', :href => "/images/icons/favicon.png?#{time.to_i}") { actual_html }
|
211
218
|
end
|
212
219
|
should "match type with file ext" do
|
213
220
|
time = stop_time_for_test
|
214
221
|
actual_html = favicon_tag('favicon.ico')
|
215
|
-
assert_has_tag('link', :rel => 'icon', :type => 'image/ico', :href =>
|
222
|
+
assert_has_tag('link', :rel => 'icon', :type => 'image/ico', :href => "/images/favicon.ico?#{time.to_i}") { actual_html }
|
216
223
|
end
|
217
224
|
should "allow option overrides" do
|
218
225
|
time = stop_time_for_test
|
219
226
|
actual_html = favicon_tag('favicon.png', :type => 'image/ico')
|
220
|
-
assert_has_tag('link', :rel => 'icon', :type => 'image/ico', :href =>
|
227
|
+
assert_has_tag('link', :rel => 'icon', :type => 'image/ico', :href => "/images/favicon.png?#{time.to_i}") { actual_html }
|
228
|
+
end
|
229
|
+
end
|
230
|
+
|
231
|
+
context 'for #feed_tag method' do
|
232
|
+
should "generate correctly link tag for rss" do
|
233
|
+
assert_has_tag('link', :type => 'application/rss+xml', :rel => 'alternate', :href => "/blog/post.rss", :title => 'rss') { feed_tag :rss, "/blog/post.rss" }
|
234
|
+
end
|
235
|
+
should "generate correctly link tag for atom" do
|
236
|
+
assert_has_tag('link', :type => 'application/atom+xml', :rel => 'alternate', :href => "/blog/post.atom", :title => 'atom') { feed_tag :atom, "/blog/post.atom" }
|
237
|
+
end
|
238
|
+
should "override options" do
|
239
|
+
assert_has_tag('link', :type => 'my-type', :rel => 'my-rel', :href => "/blog/post.rss", :title => 'my-title') { feed_tag :rss, "/blog/post.rss", :type => "my-type", :rel => "my-rel", :title => "my-title" }
|
221
240
|
end
|
222
|
-
|
223
241
|
end
|
224
|
-
|
225
242
|
end
|
data/test/test_form_builder.rb
CHANGED
@@ -33,7 +33,7 @@ class TestFormBuilder < Test::Unit::TestCase
|
|
33
33
|
assert_has_tag('form input', :type => 'text', :name => 'markup_user[username]') { actual_html }
|
34
34
|
assert_has_tag('form input[type=hidden]', :name => '_method', :count => 0) { actual_html } # no method action field
|
35
35
|
end
|
36
|
-
|
36
|
+
|
37
37
|
should "display correct form html for namespaced object" do
|
38
38
|
actual_html = form_for(Outer::UserAccount.new, '/register', :method => 'post') { |f| f.text_field :username }
|
39
39
|
assert_has_tag('form', :action => '/register', :method => 'post') { actual_html }
|
@@ -445,26 +445,30 @@ class TestFormBuilder < Test::Unit::TestCase
|
|
445
445
|
end
|
446
446
|
|
447
447
|
context 'for #image_submit method' do
|
448
|
+
setup do
|
449
|
+
@stamp = stop_time_for_test.to_i
|
450
|
+
end
|
451
|
+
|
448
452
|
should "display correct image submit button html with no options" do
|
449
453
|
actual_html = standard_builder.image_submit('buttons/ok.png')
|
450
|
-
assert_has_tag('input[type=image]', :src => "/images/buttons/ok.png") { actual_html }
|
454
|
+
assert_has_tag('input[type=image]', :src => "/images/buttons/ok.png?#{@stamp}") { actual_html }
|
451
455
|
end
|
452
456
|
|
453
457
|
should "display correct image submit button html" do
|
454
458
|
actual_html = standard_builder.image_submit('/system/ok.png', :class => 'large')
|
455
|
-
assert_has_tag('input.large[type=image]', :src => "/system/ok.png") { actual_html }
|
459
|
+
assert_has_tag('input.large[type=image]', :src => "/system/ok.png?#{@stamp}") { actual_html }
|
456
460
|
end
|
457
461
|
|
458
462
|
should "display correct image submit button in haml" do
|
459
463
|
visit '/haml/form_for'
|
460
|
-
assert_have_selector '#demo input', :type => 'image', :id => 'image-button', :src =>
|
461
|
-
assert_have_selector '#demo2 input', :type => 'image', :class => 'image', :src => "/images/buttons/ok.png"
|
464
|
+
assert_have_selector '#demo input', :type => 'image', :id => 'image-button', :src => "/images/buttons/post.png?#{@stamp}"
|
465
|
+
assert_have_selector '#demo2 input', :type => 'image', :class => 'image', :src => "/images/buttons/ok.png?#{@stamp}"
|
462
466
|
end
|
463
467
|
|
464
468
|
should "display correct image submit button in erb" do
|
465
469
|
visit '/erb/form_for'
|
466
|
-
assert_have_selector '#demo input', :type => 'image', :id => 'image-button', :src =>
|
467
|
-
assert_have_selector '#demo2 input', :type => 'image', :class => 'image', :src => "/images/buttons/ok.png"
|
470
|
+
assert_have_selector '#demo input', :type => 'image', :id => 'image-button', :src => "/images/buttons/post.png?#{@stamp}"
|
471
|
+
assert_have_selector '#demo2 input', :type => 'image', :class => 'image', :src => "/images/buttons/ok.png?#{@stamp}"
|
468
472
|
end
|
469
473
|
end
|
470
474
|
|
@@ -614,19 +618,23 @@ class TestFormBuilder < Test::Unit::TestCase
|
|
614
618
|
end
|
615
619
|
|
616
620
|
context 'for #image_submit_block method' do
|
621
|
+
setup do
|
622
|
+
@stamp = stop_time_for_test.to_i
|
623
|
+
end
|
624
|
+
|
617
625
|
should "display correct image submit block html" do
|
618
626
|
actual_html = standard_builder.image_submit_block("buttons/ok.png", :class => 'large')
|
619
|
-
assert_has_tag('p input.large[type=image]', :src =>
|
627
|
+
assert_has_tag('p input.large[type=image]', :src => "/images/buttons/ok.png?#{@stamp}") { actual_html }
|
620
628
|
end
|
621
629
|
|
622
630
|
should "display correct image submit block in haml" do
|
623
631
|
visit '/haml/form_for'
|
624
|
-
assert_have_selector '#demo2 p input', :type => 'image', :class => 'image', :src =>
|
632
|
+
assert_have_selector '#demo2 p input', :type => 'image', :class => 'image', :src => "/images/buttons/ok.png?#{@stamp}"
|
625
633
|
end
|
626
634
|
|
627
635
|
should "display correct image submit block in erb" do
|
628
636
|
visit '/erb/form_for'
|
629
|
-
assert_have_selector '#demo2 p input', :type => 'image', :class => 'image', :src =>
|
637
|
+
assert_have_selector '#demo2 p input', :type => 'image', :class => 'image', :src => "/images/buttons/ok.png?#{@stamp}"
|
630
638
|
end
|
631
639
|
end
|
632
640
|
end
|
data/test/test_form_helpers.rb
CHANGED
@@ -390,24 +390,28 @@ class TestFormHelpers < Test::Unit::TestCase
|
|
390
390
|
end
|
391
391
|
|
392
392
|
context 'for #image_submit_tag method' do
|
393
|
+
setup do
|
394
|
+
@stamp = stop_time_for_test.to_i
|
395
|
+
end
|
396
|
+
|
393
397
|
should "display image submit tag in ruby with relative path" do
|
394
398
|
actual_html = image_submit_tag('buttons/ok.png', :class => 'success')
|
395
|
-
assert_has_tag(:input, :type => 'image', :class => "success", :src =>
|
399
|
+
assert_has_tag(:input, :type => 'image', :class => "success", :src => "/images/buttons/ok.png?#{@stamp}") { actual_html }
|
396
400
|
end
|
397
401
|
|
398
402
|
should "display image submit tag in ruby with absolute path" do
|
399
403
|
actual_html = image_submit_tag('/system/ok.png', :class => 'success')
|
400
|
-
assert_has_tag(:input, :type => 'image', :class => "success", :src =>
|
404
|
+
assert_has_tag(:input, :type => 'image', :class => "success", :src => "/system/ok.png?#{@stamp}") { actual_html }
|
401
405
|
end
|
402
406
|
|
403
407
|
should "display image submit tag in erb" do
|
404
408
|
visit '/erb/form_tag'
|
405
|
-
assert_have_selector 'form.advanced-form input[type=image]', :count => 1, :src => "/images/buttons/submit.png"
|
409
|
+
assert_have_selector 'form.advanced-form input[type=image]', :count => 1, :src => "/images/buttons/submit.png?#{@stamp}"
|
406
410
|
end
|
407
411
|
|
408
412
|
should "display image submit tag in haml" do
|
409
413
|
visit '/haml/form_tag'
|
410
|
-
assert_have_selector 'form.advanced-form input[type=image]', :count => 1, :src => "/images/buttons/submit.png"
|
414
|
+
assert_have_selector 'form.advanced-form input[type=image]', :count => 1, :src => "/images/buttons/submit.png?#{@stamp}"
|
411
415
|
end
|
412
416
|
end
|
413
417
|
|
data/test/test_tag_helpers.rb
CHANGED
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 9
|
8
|
-
-
|
9
|
-
version: 0.9.
|
8
|
+
- 7
|
9
|
+
version: 0.9.7
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Padrino Team
|
@@ -17,7 +17,7 @@ autorequire:
|
|
17
17
|
bindir: bin
|
18
18
|
cert_chain: []
|
19
19
|
|
20
|
-
date: 2010-03-
|
20
|
+
date: 2010-03-22 00:00:00 -07:00
|
21
21
|
default_executable:
|
22
22
|
dependencies:
|
23
23
|
- !ruby/object:Gem::Dependency
|
@@ -30,8 +30,8 @@ dependencies:
|
|
30
30
|
segments:
|
31
31
|
- 0
|
32
32
|
- 9
|
33
|
-
-
|
34
|
-
version: 0.9.
|
33
|
+
- 7
|
34
|
+
version: 0.9.7
|
35
35
|
type: :runtime
|
36
36
|
version_requirements: *id001
|
37
37
|
- !ruby/object:Gem::Dependency
|