ramaze 2010.06.18 → 2011.01

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. data/.gitignore +1 -0
  2. data/MANIFEST +9 -16
  3. data/README.md +37 -30
  4. data/Rakefile +5 -1
  5. data/TODO.md +19 -0
  6. data/doc/AUTHORS +5 -1
  7. data/doc/CHANGELOG +3553 -3272
  8. data/doc/tutorial/todolist.html +1512 -1512
  9. data/examples/app/blog/app.rb +2 -0
  10. data/examples/app/todolist/controller/init.rb +1 -2
  11. data/examples/app/wiktacular/mkd/main/2007-07-20_19-21-12.mkd +1 -1
  12. data/examples/app/wiktacular/mkd/main/2007-07-20_19-23-10.mkd +1 -1
  13. data/examples/app/wiktacular/mkd/main/2007-07-20_19-45-07.mkd +1 -1
  14. data/examples/app/wiktacular/mkd/main/current.mkd +1 -1
  15. data/examples/app/wiktacular/mkd/testing/2007-07-20_16-43-46.mkd +1 -1
  16. data/examples/app/wiktacular/mkd/testing/2007-07-20_19-43-50.mkd +2 -2
  17. data/examples/app/wiktacular/mkd/testing/2007-07-21_18-47-08.mkd +16 -16
  18. data/examples/app/wiktacular/mkd/testing/2007-07-21_18-47-54.mkd +16 -16
  19. data/examples/app/wiktacular/mkd/testing/current.mkd +16 -16
  20. data/lib/proto/model/init.rb +1 -1
  21. data/lib/proto/public/js/jquery.js +2034 -1095
  22. data/lib/proto/start.rb +2 -0
  23. data/lib/proto/view/index.xhtml +3 -3
  24. data/lib/ramaze.rb +1 -2
  25. data/lib/ramaze/cache.rb +1 -0
  26. data/lib/ramaze/cache/sequel.rb +131 -37
  27. data/lib/ramaze/controller.rb +1 -0
  28. data/lib/ramaze/gestalt.rb +75 -46
  29. data/lib/ramaze/helper.rb +1 -0
  30. data/lib/ramaze/helper/auth.rb +38 -4
  31. data/lib/ramaze/helper/blue_form.rb +498 -78
  32. data/lib/ramaze/helper/cache.rb +2 -2
  33. data/lib/ramaze/helper/csrf.rb +225 -0
  34. data/lib/ramaze/helper/erector.rb +67 -9
  35. data/lib/ramaze/helper/flash.rb +4 -2
  36. data/lib/ramaze/helper/gestalt.rb +2 -0
  37. data/lib/ramaze/helper/gravatar.rb +1 -1
  38. data/lib/ramaze/helper/localize.rb +4 -0
  39. data/lib/ramaze/helper/send_file.rb +30 -0
  40. data/lib/ramaze/helper/thread.rb +5 -0
  41. data/lib/ramaze/helper/user.rb +4 -3
  42. data/lib/ramaze/helper/xhtml.rb +87 -8
  43. data/lib/ramaze/log.rb +13 -0
  44. data/lib/ramaze/log/analogger.rb +15 -5
  45. data/lib/ramaze/log/growl.rb +28 -13
  46. data/lib/ramaze/log/hub.rb +12 -4
  47. data/lib/ramaze/log/informer.rb +28 -11
  48. data/lib/ramaze/log/knotify.rb +7 -2
  49. data/lib/ramaze/log/logger.rb +12 -4
  50. data/lib/ramaze/log/logging.rb +40 -14
  51. data/lib/ramaze/log/rotatinginformer.rb +47 -23
  52. data/lib/ramaze/log/syslog.rb +37 -31
  53. data/lib/ramaze/log/xosd.rb +7 -4
  54. data/lib/ramaze/middleware_compiler.rb +2 -2
  55. data/lib/ramaze/snippets/fiber.rb +63 -63
  56. data/lib/ramaze/snippets/ramaze/lru_hash.rb +1 -1
  57. data/lib/ramaze/tool/bin.rb +1 -1
  58. data/lib/ramaze/version.rb +1 -1
  59. data/lib/ramaze/view.rb +4 -4
  60. data/lib/ramaze/view/erector.rb +88 -13
  61. data/ramaze.gemspec +65 -65
  62. data/spec/ramaze/bin/ramaze.rb +1 -1
  63. data/spec/ramaze/cache/localmemcache.rb +20 -12
  64. data/spec/ramaze/cache/sequel.rb +19 -19
  65. data/spec/ramaze/helper/blue_form.rb +549 -257
  66. data/spec/ramaze/helper/csrf.rb +109 -0
  67. data/spec/ramaze/helper/httpdigest.rb +31 -29
  68. data/spec/ramaze/helper/user.rb +1 -1
  69. data/spec/ramaze/helper/xhtml.rb +17 -0
  70. data/spec/ramaze/log/growl.rb +34 -0
  71. data/spec/ramaze/log/informer.rb +1 -0
  72. data/spec/ramaze/view/erector.rb +49 -71
  73. data/spec/ramaze/view/erector/external_view.erector +5 -0
  74. data/spec/ramaze/view/erector/index.erector +5 -0
  75. data/spec/ramaze/view/erector/layout.erector +13 -3
  76. data/spec/ramaze/view/erector/tables.erector +23 -0
  77. data/spec/ramaze/view/erector/view.erector +6 -0
  78. data/tasks/git.rake +2 -2
  79. metadata +133 -176
  80. data/examples/helpers/form_with_sequel.rb +0 -24
  81. data/examples/helpers/nitro_form.rb +0 -23
  82. data/lib/ramaze/helper/form.rb +0 -133
  83. data/lib/ramaze/helper/nitroform.rb +0 -14
  84. data/lib/ramaze/helper/pager.rb +0 -367
  85. data/lib/ramaze/helper/partial.rb +0 -100
  86. data/lib/ramaze/helper/sequel.rb +0 -55
  87. data/lib/ramaze/helper/sequel_form.rb +0 -284
  88. data/lib/vendor/etag.rb +0 -22
  89. data/spec/ramaze/helper/form.rb +0 -360
  90. data/spec/ramaze/helper/pager.rb +0 -96
  91. data/spec/ramaze/helper/sequel_form.rb +0 -94
  92. data/spec/ramaze/view/erector/external.erector +0 -1
  93. data/spec/ramaze/view/erector/invoke_helper_method.erector +0 -1
  94. data/spec/ramaze/view/erector/strict_xhtml.erector +0 -3
  95. data/spec/ramaze/view/erector/sum.erector +0 -1
@@ -1,360 +0,0 @@
1
- # Copyright (c) 2009 Michael Fellinger m.fellinger@gmail.com
2
- # All files in this distribution are subject to the terms of the Ruby license.
3
-
4
- require File.expand_path('../../../../spec/helper', __FILE__)
5
-
6
- spec_requires 'hpricot'
7
-
8
- class SpecHelperForm < Ramaze::Controller
9
- map '/'
10
- helper :form
11
-
12
- def text
13
- form_text('Username', :username, request[:username])
14
- end
15
-
16
- def checkbox
17
- form_checkbox('Administrator', :admin, request[:admin])
18
- end
19
-
20
- def password
21
- form_password('Password', :password)
22
- end
23
-
24
- def textarea
25
- form_textarea('Text', :text, request[:text])
26
- end
27
-
28
- def file
29
- form_file('File', :file)
30
- end
31
-
32
- def hidden
33
- form_hidden(:secret, request[:secret])
34
- end
35
-
36
- def select_array
37
- languages = %w[ English German Japanese ]
38
- form_select('Languages', :languages, languages)
39
- end
40
-
41
- def select_array_size
42
- languages = %w[ English German Japanese ]
43
- form_select('Languages', :languages, languages, :size => 5)
44
- end
45
-
46
- def select_array_multiple
47
- languages = %w[ English German Japanese ]
48
- form_select('Languages', :languages, languages, :multiple => 1)
49
- end
50
-
51
- def select_array_selected
52
- languages = %w[ English German Japanese ]
53
- form_select('Languages', :languages, languages, :selected => 'German')
54
- end
55
-
56
- def select_hash
57
- languages = {'English' => 'en', 'German' => 'de', 'Japanese' => 'ja'}
58
- form_select('Languages', :languages, languages)
59
- end
60
- end
61
-
62
- describe Ramaze::Helper::Form do
63
- behaves_like :rack_test
64
-
65
- it 'provides empty text input' do
66
- got = get('/text')
67
-
68
- doc = Hpricot(got.body)
69
- label, input = doc.at(:label), doc.at(:input)
70
-
71
- label.attributes.to_hash.should == {'for' => 'form-username'}
72
- label.inner_text.should == 'Username:'
73
-
74
- input.attributes.to_hash.should == {
75
- 'id' => 'form-username',
76
- 'type' => 'text',
77
- 'name' => 'username',
78
- 'value' => '',
79
- 'tabindex' => '1'
80
- }
81
- end
82
-
83
- it 'provides filled text input' do
84
- got = get('/text?username=manveru')
85
-
86
- doc = Hpricot(got.body)
87
- label, input = doc.at(:label), doc.at(:input)
88
-
89
- label.attributes.to_hash.should == {'for' => 'form-username'}
90
- label.inner_text.should == 'Username:'
91
-
92
- input.attributes.to_hash.should == {
93
- 'id' => 'form-username',
94
- 'type' => 'text',
95
- 'name' => 'username',
96
- 'value' => 'manveru',
97
- 'tabindex' => '1'}
98
- end
99
-
100
- it 'provides unchecked checkbox input' do
101
- got = get('/checkbox')
102
-
103
- doc = Hpricot(got.body)
104
- label, input = doc.at(:label), doc.at(:input)
105
-
106
- label.attributes.to_hash.should == {'for' => 'form-admin'}
107
- label.inner_text.should == 'Administrator:'
108
-
109
- input.attributes.to_hash.should == {
110
- 'id' => 'form-admin',
111
- 'type' => 'checkbox',
112
- 'name' => 'admin',
113
- 'tabindex' => '1'}
114
- end
115
-
116
- it 'provides checked checkbox input' do
117
- got = get('/checkbox?admin=true')
118
-
119
- doc = Hpricot(got.body)
120
- label, input = doc.at(:label), doc.at(:input)
121
-
122
- label.attributes.to_hash.should == {'for' => 'form-admin'}
123
- label.inner_text.should == 'Administrator:'
124
-
125
- input.attributes.to_hash.should == {
126
- 'id' => 'form-admin',
127
- 'type' => 'checkbox',
128
- 'name' => 'admin',
129
- 'checked' => 'checked',
130
- 'tabindex' => '1'}
131
- end
132
-
133
- it 'provides password input' do
134
- got = get('/password')
135
-
136
- doc = Hpricot(got.body)
137
- label, input = doc.at(:label), doc.at(:input)
138
-
139
- label.attributes.to_hash.should == {'for' => 'form-password'}
140
- label.inner_text.should == 'Password:'
141
-
142
- input.attributes.to_hash.should == {
143
- 'id' => 'form-password',
144
- 'type' => 'password',
145
- 'name' => 'password',
146
- 'tabindex' => '1'}
147
- end
148
-
149
- it 'provides empty textarea' do
150
- got = get('/textarea')
151
-
152
- doc = Hpricot(got.body)
153
- label, textarea = doc.at(:label), doc.at(:textarea)
154
-
155
- label.attributes.to_hash.should == {'for' => 'form-text'}
156
- label.inner_text.should == 'Text:'
157
-
158
- textarea.inner_text.should == ''
159
- textarea.attributes.to_hash.should == {
160
- 'id' => 'form-text',
161
- 'name' => 'text',
162
- 'tabindex' => '1'}
163
- end
164
-
165
- it 'provides filled textarea' do
166
- got = get('/textarea?text=foobar')
167
-
168
- doc = Hpricot(got.body)
169
- label, textarea = doc.at(:label), doc.at(:textarea)
170
-
171
- label.attributes.to_hash.should == {'for' => 'form-text'}
172
- label.inner_text.should == 'Text:'
173
-
174
- textarea.inner_text.should == 'foobar'
175
- textarea.attributes.to_hash.should == {
176
- 'id' => 'form-text',
177
- 'name' => 'text',
178
- 'tabindex' => '1'}
179
- end
180
-
181
- it 'provides file upload input' do
182
- got = get('/file')
183
-
184
- doc = Hpricot(got.body)
185
- label, input = doc.at(:label), doc.at(:input)
186
-
187
- label.attributes.to_hash.should == {'for' => 'form-file'}
188
- label.inner_text.should == 'File:'
189
-
190
- input.inner_text.should == ''
191
- input.attributes.to_hash.should == {
192
- 'id' => 'form-file',
193
- 'name' => 'file',
194
- 'tabindex' => '1',
195
- 'type' => 'file'}
196
- end
197
-
198
- it 'provides empty hidden input' do
199
- got = get('/hidden')
200
-
201
- doc = Hpricot(got.body)
202
- label, input = doc.at(:label), doc.at(:input)
203
-
204
- label.should.be.nil
205
-
206
- input.inner_text.should == ''
207
- input.attributes.to_hash.should == {
208
- 'name' => 'secret',
209
- 'type' => 'hidden',
210
- 'value' => ''}
211
- end
212
-
213
- it 'provides filled hidden input' do
214
- got = get('/hidden?secret=fish')
215
-
216
- doc = Hpricot(got.body)
217
- label, input = doc.at(:label), doc.at(:input)
218
-
219
- label.should.be.nil
220
-
221
- input.inner_text.should == ''
222
- input.attributes.to_hash.should == {
223
- 'name' => 'secret',
224
- 'type' => 'hidden',
225
- 'value' => 'fish'}
226
- end
227
-
228
- it 'provides array select' do
229
- got = get('/select_array')
230
- doc = Hpricot(got.body)
231
-
232
- label, select = doc.at(:label), doc.at(:select)
233
-
234
- label.attributes.to_hash.should == {'for' => 'form-languages'}
235
- label.inner_text.should == 'Languages:'
236
-
237
- select.attributes.to_hash.should == {
238
- 'id' => 'form-languages',
239
- 'name' => 'languages',
240
- 'size' => '1',
241
- 'tabindex' => '1'}
242
-
243
- options = select/:option
244
- options.map{|o| [o.inner_text, o.attributes.to_hash] }.
245
- should == [['English', {'value' => 'English'}],
246
- ['German', {'value' => 'German'}],
247
- ['Japanese', {'value' => 'Japanese'}]]
248
- end
249
-
250
- it 'provides sized array select' do
251
- got = get('/select_array_size')
252
- doc = Hpricot(got.body)
253
-
254
- label, select = doc.at(:label), doc.at(:select)
255
-
256
- label.attributes.to_hash.should == {'for' => 'form-languages'}
257
- label.inner_text.should == 'Languages:'
258
-
259
- select.attributes.to_hash.should == {
260
- 'id' => 'form-languages',
261
- 'name' => 'languages',
262
- 'size' => '5',
263
- 'tabindex' => '1'}
264
-
265
- options = select/:option
266
- options.map{|o| [o.inner_text, o.attributes.to_hash] }.
267
- should == [['English', {'value' => 'English'}],
268
- ['German', {'value' => 'German'}],
269
- ['Japanese', {'value' => 'Japanese'}]]
270
- end
271
-
272
- it 'provides multiple array select' do
273
- got = get('/select_array_multiple')
274
- doc = Hpricot(got.body)
275
-
276
- label, select = doc.at(:label), doc.at(:select)
277
-
278
- label.attributes.to_hash.should == {'for' => 'form-languages'}
279
- label.inner_text.should == 'Languages:'
280
-
281
- select.attributes.to_hash.should == {
282
- 'id' => 'form-languages',
283
- 'multiple' => 'multiple',
284
- 'name' => 'languages',
285
- 'size' => '1',
286
- 'tabindex' => '1'}
287
-
288
- options = select/:option
289
- options.map{|o| [o.inner_text, o.attributes.to_hash] }.
290
- should == [['English', {'value' => 'English'}],
291
- ['German', {'value' => 'German'}],
292
- ['Japanese', {'value' => 'Japanese'}]]
293
- end
294
-
295
- it 'provides preselected array select' do
296
- got = get('/select_array_selected')
297
- doc = Hpricot(got.body)
298
-
299
- label, select = doc.at(:label), doc.at(:select)
300
-
301
- label.attributes.to_hash.should == {'for' => 'form-languages'}
302
- label.inner_text.should == 'Languages:'
303
-
304
- select.attributes.to_hash.should == {
305
- 'id' => 'form-languages',
306
- 'name' => 'languages',
307
- 'size' => '1',
308
- 'tabindex' => '1'}
309
-
310
- options = select/:option
311
- options.map{|o| [o.inner_text, o.attributes.to_hash] }.
312
- should == [['English', {'value' => 'English'}],
313
- ['German', {'value' => 'German', 'selected' => 'selected'}],
314
- ['Japanese', {'value' => 'Japanese'}]]
315
- end
316
-
317
- it 'provides hash select' do
318
- got = get('/select_hash')
319
- doc = Hpricot(got.body)
320
-
321
- label, select = doc.at(:label), doc.at(:select)
322
-
323
- label.attributes.to_hash.should == {'for' => 'form-languages'}
324
- label.inner_text.should == 'Languages:'
325
-
326
- select.attributes.to_hash.should == {
327
- 'id' => 'form-languages',
328
- 'name' => 'languages',
329
- 'size' => '1',
330
- 'tabindex' => '1'}
331
-
332
- options = select/:option
333
- options.map{|o| [o.inner_text, o.attributes.to_hash] }.sort.
334
- should == [['English', {'value' => 'en'}],
335
- ['German', {'value' => 'de'}],
336
- ['Japanese', {'value' => 'ja'}]]
337
- end
338
-
339
- it 'provides hash select' do
340
- got = get('/select_hash')
341
- doc = Hpricot(got.body)
342
-
343
- label, select = doc.at(:label), doc.at(:select)
344
-
345
- label.attributes.to_hash.should == {'for' => 'form-languages'}
346
- label.inner_text.should == 'Languages:'
347
-
348
- select.attributes.to_hash.should == {
349
- 'id' => 'form-languages',
350
- 'name' => 'languages',
351
- 'size' => '1',
352
- 'tabindex' => '1'}
353
-
354
- options = select/:option
355
- options.map{|o| [o.inner_text, o.attributes.to_hash] }.sort.
356
- should == [['English', {'value' => 'en'}],
357
- ['German', {'value' => 'de'}],
358
- ['Japanese', {'value' => 'ja'}]]
359
- end
360
- end
@@ -1,96 +0,0 @@
1
- # Copyright (c) 2009 Michael Fellinger m.fellinger@gmail.com
2
- # All files in this distribution are subject to the terms of the Ruby license.
3
-
4
- require File.expand_path('../../../../spec/helper', __FILE__)
5
- spec_require 'hpricot'
6
-
7
- module Og
8
- class Mock
9
- def initialize(*a); @a = a; end
10
- def all(o) @a[(o[:offset]||0),o[:limit]] end
11
- def count(*a) @a.size end
12
- alias reload all
13
- end
14
- module Mixin; end
15
- module Collection; end
16
- end
17
-
18
- class TCPagerController < Ramaze::Controller
19
- map '/'
20
- helper :pager
21
-
22
- def page
23
- stuff = [1, 2, 3, 4, 5, 6, 7, 8, 9]
24
-
25
- items, pager = paginate(stuff, :limit => 2)
26
-
27
- items.inspect
28
- end
29
- end
30
-
31
- shared 'pager' do
32
- behaves_like :rack_test
33
- extend Ramaze::Helper::Pager
34
-
35
- def pager_key
36
- Ramaze::Pager.trait[:key]
37
- end
38
-
39
- # Used internally in Pager to get parameters like: ?_page=1
40
- def request
41
- req = Object.new
42
- def req.params
43
- {Ramaze::Pager.trait[:key] => 1}
44
- end
45
- req
46
- end
47
-
48
- before do
49
- @items, @pager = paginate(@stuff, :limit => 2)
50
- end
51
-
52
- it 'should be paginated' do
53
- get('/page').body.should == [1, 2].inspect
54
- get('/page?_page=2').body.should == [3, 4].inspect
55
- end
56
-
57
- it "should report the number of articles as Pager#total_count" do
58
- @pager.total_count.should.equal 5
59
- end
60
-
61
- it "should return the same number of items as passed to :per_page" do
62
- @items.size.should.equal 2
63
- end
64
-
65
- it "should link to other pages" do
66
- # mock the action
67
- action = '/page'
68
- def action.node; TCPagerController; end
69
- def action.name; self; end
70
- Ramaze::Current.actions = [action]
71
-
72
- @pager.should.not.be.nil
73
- @pager.navigation.should.not.be.nil
74
-
75
- page = Hpricot(@pager.navigation)
76
- (page / 'a').size.should == 4
77
- end
78
- end
79
-
80
- describe "Array Pager" do
81
- @stuff = (1..5).to_a
82
-
83
- behaves_like "pager"
84
- end
85
-
86
- describe "OgPager" do
87
- @stuff = Og::Mock.new(1,2,3,4,5).extend(Og::Mixin)
88
-
89
- behaves_like "pager"
90
- end
91
-
92
- describe "OgCollectionPager" do
93
- @stuff = Og::Mock.new(1,2,3,4,5).extend(Og::Collection)
94
-
95
- behaves_like "pager"
96
- end