wee 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. data/ChangeLog +18 -0
  2. data/doc/rdoc/classes/Enumerable.html +6 -6
  3. data/doc/rdoc/classes/Object.html +12 -12
  4. data/doc/rdoc/classes/OgScaffolder.html +53 -6
  5. data/doc/rdoc/classes/OgScaffolder/Editor.html +182 -107
  6. data/doc/rdoc/classes/String.html +12 -12
  7. data/doc/rdoc/classes/Wee/AnswerDecoration.html +9 -9
  8. data/doc/rdoc/classes/Wee/Application.html +42 -42
  9. data/doc/rdoc/classes/Wee/Brush.html +18 -18
  10. data/doc/rdoc/classes/Wee/Brush/AnchorTag.html +7 -7
  11. data/doc/rdoc/classes/Wee/Brush/FileUploadTag.html +7 -7
  12. data/doc/rdoc/classes/Wee/Brush/FormTag.html +14 -14
  13. data/doc/rdoc/classes/Wee/Brush/GenericEncodedTextBrush.html +12 -12
  14. data/doc/rdoc/classes/Wee/Brush/GenericSingleTagBrush.html +6 -6
  15. data/doc/rdoc/classes/Wee/Brush/GenericTagBrush.html +84 -84
  16. data/doc/rdoc/classes/Wee/Brush/GenericTextBrush.html +12 -12
  17. data/doc/rdoc/classes/Wee/Brush/ImageButtonTag.html +15 -15
  18. data/doc/rdoc/classes/Wee/Brush/ImageTag.html +18 -18
  19. data/doc/rdoc/classes/Wee/Brush/InputTag.html +12 -12
  20. data/doc/rdoc/classes/Wee/Brush/JavascriptTag.html +6 -6
  21. data/doc/rdoc/classes/Wee/Brush/Page.html +14 -14
  22. data/doc/rdoc/classes/Wee/Brush/SelectListTag.html +31 -23
  23. data/doc/rdoc/classes/Wee/Brush/SelectListTag/SelectListCallback.html +11 -7
  24. data/doc/rdoc/classes/Wee/Brush/SelectOptionTag.html +6 -6
  25. data/doc/rdoc/classes/Wee/Brush/SubmitButtonTag.html +7 -7
  26. data/doc/rdoc/classes/Wee/Brush/TableDataTag.html +14 -14
  27. data/doc/rdoc/classes/Wee/Brush/TableHeaderTag.html +7 -7
  28. data/doc/rdoc/classes/Wee/Brush/TableRowTag.html +36 -36
  29. data/doc/rdoc/classes/Wee/Brush/TableTag.html +6 -6
  30. data/doc/rdoc/classes/Wee/Brush/TextAreaTag.html +12 -12
  31. data/doc/rdoc/classes/Wee/Brush/TextInputTag.html +7 -7
  32. data/doc/rdoc/classes/Wee/CallbackRegistry.html +36 -36
  33. data/doc/rdoc/classes/Wee/CallbackStream.html +18 -18
  34. data/doc/rdoc/classes/Wee/Canvas.html +24 -24
  35. data/doc/rdoc/classes/Wee/Component.html +124 -124
  36. data/doc/rdoc/classes/Wee/Component/OnAnswer.html +6 -6
  37. data/doc/rdoc/classes/Wee/Decoration.html +40 -40
  38. data/doc/rdoc/classes/Wee/Delegate.html +27 -27
  39. data/doc/rdoc/classes/Wee/ErrorResponse.html +12 -12
  40. data/doc/rdoc/classes/Wee/FormDecoration.html +6 -6
  41. data/doc/rdoc/classes/Wee/GenericResponse.html +6 -6
  42. data/doc/rdoc/classes/Wee/HtmlCanvas.html +214 -214
  43. data/doc/rdoc/classes/Wee/HtmlWriter.html +40 -40
  44. data/doc/rdoc/classes/Wee/LiteralMethodCallback.html +12 -12
  45. data/doc/rdoc/classes/Wee/Md5IdGenerator.html +12 -12
  46. data/doc/rdoc/classes/Wee/MessageBox.html +12 -12
  47. data/doc/rdoc/classes/Wee/PageDecoration.html +18 -18
  48. data/doc/rdoc/classes/Wee/PagelessApplication.html +6 -6
  49. data/doc/rdoc/classes/Wee/PagelessRequest.html +12 -12
  50. data/doc/rdoc/classes/Wee/PagelessSession.html +24 -24
  51. data/doc/rdoc/classes/Wee/Presenter.html +85 -85
  52. data/doc/rdoc/classes/Wee/RedirectResponse.html +6 -6
  53. data/doc/rdoc/classes/Wee/RefreshResponse.html +6 -6
  54. data/doc/rdoc/classes/Wee/Request.html +30 -30
  55. data/doc/rdoc/classes/Wee/RequestHandler.html +31 -31
  56. data/doc/rdoc/classes/Wee/Response.html +36 -36
  57. data/doc/rdoc/classes/Wee/Session.html +104 -104
  58. data/doc/rdoc/classes/Wee/SimpleIdGenerator.html +12 -12
  59. data/doc/rdoc/classes/Wee/Snapshot.html +19 -19
  60. data/doc/rdoc/classes/Wee/Utils.html +19 -19
  61. data/doc/rdoc/classes/Wee/Utils/LRUCache.html +6 -6
  62. data/doc/rdoc/classes/Wee/ValueHolder.html +18 -18
  63. data/doc/rdoc/classes/Wee/WEBrickAdaptor.html +46 -46
  64. data/doc/rdoc/classes/Wee/WrapperDecoration.html +6 -6
  65. data/doc/rdoc/created.rid +1 -1
  66. data/doc/rdoc/files/README.html +5 -5
  67. data/doc/rdoc/files/lib/wee/core_rb.html +3 -3
  68. data/doc/rdoc/files/lib/wee/databases/og/scaffolder_rb.html +8 -1
  69. data/doc/rdoc/files/lib/wee/renderer/html/brushes_rb.html +1 -1
  70. data/doc/rdoc/fr_method_index.html +268 -264
  71. data/lib/wee.rb +1 -1
  72. data/lib/wee/databases/og/scaffolder.rb +62 -17
  73. data/lib/wee/renderer/html/brushes.rb +17 -5
  74. metadata +21 -21
data/lib/wee.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Wee
2
- Version = "0.6.0"
2
+ Version = "0.7.0"
3
3
  LibPath = File.dirname(__FILE__)
4
4
  end
5
5
 
@@ -64,12 +64,11 @@ class OgScaffolder < Wee::Component
64
64
  end
65
65
 
66
66
  def edit(obj)
67
- call Editor.new(obj).add_decoration(Wee::FormDecoration.new)
67
+ call editor_for(obj)
68
68
  end
69
69
 
70
70
  def add
71
- call Editor.new(@domain_class.new, "Create").
72
- add_decoration(Wee::FormDecoration.new)
71
+ call editor_for(@domain_class.new)
73
72
  end
74
73
 
75
74
  def destroy(obj)
@@ -84,37 +83,54 @@ class OgScaffolder < Wee::Component
84
83
  def domain_objects
85
84
  @domain_class.all || []
86
85
  end
86
+
87
+ def editor_class
88
+ Editor
89
+ end
90
+
91
+ def editor_for(obj)
92
+ editor_class.new(obj).add_decoration(Wee::FormDecoration.new)
93
+ end
87
94
  end
88
95
 
89
96
  class OgScaffolder::Editor < Wee::Component
90
97
 
91
- def initialize(domain_object, action="Edit")
98
+ def initialize(domain_object)
92
99
  super()
93
100
  @domain_object = domain_object
94
- @action = action
95
101
  end
96
102
 
97
103
  def render
98
104
  render_header
99
105
  each_property {|prop|
100
- render_property(prop) unless prop.name == 'oid'
106
+ unless prop.name == 'oid'
107
+ render_label(prop)
108
+ render_property(prop)
109
+ end
101
110
  }
102
111
  render_buttons
103
112
  end
104
113
 
105
114
  def render_header
106
- r.h1 "#{ @action } #{ @domain_object.class }"
115
+ action =
116
+ if @domain_object.oid.nil?
117
+ "Create"
118
+ else
119
+ "Edit"
120
+ end
121
+
122
+ r.h1 "#{ action } #{ @domain_object.class }"
107
123
  end
108
124
 
109
125
  def render_property(prop)
110
- render_label(prop)
111
-
112
126
  if prop.klass.ancestors.include?(Numeric)
113
127
  render_numeric(prop)
114
128
  elsif prop.klass.ancestors.include?(String)
115
129
  render_string(prop)
116
130
  elsif prop.klass.ancestors.include?(TrueClass)
117
131
  render_bool(prop)
132
+ elsif prop.klass.ancestors.include?(Date)
133
+ render_date(prop)
118
134
  end
119
135
  end
120
136
 
@@ -131,11 +147,25 @@ class OgScaffolder::Editor < Wee::Component
131
147
  end
132
148
 
133
149
  def render_bool(prop)
134
- selected = [ get_value_of(prop) ? true : false ]
150
+ selected = get_value_of(prop) ? true : false
135
151
  r.select_list([true, false]).labels(["Yes", "No"]).selected(selected).
136
- callback {|choosen| set_value_of(prop, choosen.first) }
152
+ callback {|choosen| set_value_of(prop, choosen) }
137
153
  end
138
154
 
155
+ require 'date'
156
+ def render_date(prop)
157
+ t = get_value_of(prop) || Time.now
158
+
159
+ m = Date::MONTHS.invert
160
+ months = (1..12).map {|i| m[i].capitalize}
161
+ r.select_list((t.year-10 .. t.year+10).to_a).selected(t.year).callback {|year| set_date_of(prop, year, :year) }
162
+ r.space
163
+ r.select_list((1..12).to_a).labels(months).selected(t.month).callback {|month| set_date_of(prop, month, :month) }
164
+ r.space
165
+ r.select_list((1..31).to_a).selected(t.day).callback {|day| set_date_of(prop, day, :day) }
166
+ end
167
+
168
+
139
169
  def render_buttons
140
170
  r.paragraph
141
171
  r.submit_button.value('Save').callback(:save)
@@ -155,6 +185,15 @@ class OgScaffolder::Editor < Wee::Component
155
185
  @domain_object.class.__props.each(&block)
156
186
  end
157
187
 
188
+ def save
189
+ @domain_object.save!
190
+ answer @domain_object
191
+ end
192
+
193
+ def cancel
194
+ answer nil
195
+ end
196
+
158
197
  def get_value_of(prop)
159
198
  @domain_object.send(prop.symbol)
160
199
  end
@@ -163,12 +202,18 @@ class OgScaffolder::Editor < Wee::Component
163
202
  @domain_object.send(prop.symbol.to_s + "=", value)
164
203
  end
165
204
 
166
- def save
167
- @domain_object.save!
168
- answer @domain_object
205
+ def set_date_of(prop, val, pos)
206
+ v = get_value_of(prop) || Date.new
207
+ new_date = [v.year, v.month, v.day]
208
+ pos =
209
+ case pos
210
+ when :year then 0
211
+ when :month then 1
212
+ when :day then 2
213
+ else raise
214
+ end
215
+ new_date[pos] = val
216
+ set_value_of(prop, Date.new(*new_date))
169
217
  end
170
218
 
171
- def cancel
172
- answer nil
173
- end
174
219
  end
@@ -340,24 +340,36 @@ class Brush::SelectListTag < Brush::GenericTagBrush
340
340
  if choosen.size > 1 and not is_multiple
341
341
  raise "choosen more than one element from a non-multiple select list"
342
342
  end
343
- callback.call(choosen)
343
+ if is_multiple
344
+ callback.call(choosen)
345
+ else
346
+ callback.call(choosen.first)
347
+ end
344
348
  end
345
349
  end
346
350
 
347
351
  def with
348
352
  @labels ||= @items.collect { |i| i.to_s }
349
- @selected ||= Array.new
353
+
354
+ is_multiple = @attributes.has_key?('multiple')
350
355
 
351
356
  if @callback
352
357
  # A callback was specified. We have to wrap it inside a
353
358
  # SelectListCallback object as we want to perform some
354
359
  # additional actions.
355
- __input_callback(SelectListCallback.new(@callback, @items, @attributes.has_key?('multiple')))
360
+ __input_callback(SelectListCallback.new(@callback, @items, is_multiple))
356
361
  end
357
362
 
358
363
  super do
359
- @items.each_index do |i|
360
- @canvas.option.value(i).selected(@selected.include?(@items[i])).with(@labels[i])
364
+ if is_multiple
365
+ @selected ||= Array.new
366
+ @items.each_index {|i|
367
+ @canvas.option.value(i).selected(@selected.include?(@items[i])).with(@labels[i])
368
+ }
369
+ else
370
+ @items.each_index {|i|
371
+ @canvas.option.value(i).selected(@selected == @items[i]).with(@labels[i])
372
+ }
361
373
  end
362
374
  end
363
375
  end
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.4
3
3
  specification_version: 1
4
4
  name: wee
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.6.0
7
- date: 2005-01-31
6
+ version: 0.7.0
7
+ date: 2005-02-01
8
8
  summary: Wee is a framework for building highly dynamic web applications.
9
9
  require_paths:
10
10
  - lib
@@ -33,8 +33,8 @@ files:
33
33
  - bin
34
34
  - benchmark
35
35
  - examples
36
- - Rakefile
37
36
  - wee.gemspec
37
+ - Rakefile
38
38
  - TODO
39
39
  - INSTALL
40
40
  - ChangeLog
@@ -99,19 +99,19 @@ files:
99
99
  - doc/rdoc/files/lib/wee/response_rb.html
100
100
  - doc/rdoc/files/lib/wee/html_canvas_rb.html
101
101
  - doc/rdoc/files/lib/wee/html_writer_rb.html
102
- - doc/rdoc/files/lib/wee/application_rb.html
103
102
  - doc/rdoc/files/lib/wee/pageless_rb.html
103
+ - doc/rdoc/files/lib/wee/application_rb.html
104
104
  - doc/rdoc/files/lib/wee/presenter_rb.html
105
105
  - doc/rdoc/files/lib/wee/state_registry_rb.html
106
106
  - doc/rdoc/files/lib/wee/continuation_rb.html
107
107
  - doc/rdoc/files/lib/wee/holder_rb.html
108
108
  - doc/rdoc/files/lib/wee/session_rb.html
109
109
  - doc/rdoc/files/lib/wee/context_rb.html
110
- - doc/rdoc/files/lib/wee/webrick_rb.html
111
- - doc/rdoc/files/lib/wee/idgen_rb.html
112
110
  - doc/rdoc/files/lib/wee/requesthandler_rb.html
113
- - doc/rdoc/files/lib/wee/stuff_rb.html
111
+ - doc/rdoc/files/lib/wee/idgen_rb.html
112
+ - doc/rdoc/files/lib/wee/webrick_rb.html
114
113
  - doc/rdoc/files/lib/wee/decoration_rb.html
114
+ - doc/rdoc/files/lib/wee/stuff_rb.html
115
115
  - doc/rdoc/files/lib/wee/request_rb.html
116
116
  - doc/rdoc/files/lib/wee/components/wrapper_decoration_rb.html
117
117
  - doc/rdoc/files/lib/wee/components/form_decoration_rb.html
@@ -127,8 +127,8 @@ files:
127
127
  - doc/rdoc/files/lib/wee/pageless/session_rb.html
128
128
  - doc/rdoc/files/lib/wee/pageless/request_rb.html
129
129
  - doc/rdoc/files/lib/wee/renderer/html
130
- - doc/rdoc/files/lib/wee/renderer/html/brushes_rb.html
131
130
  - doc/rdoc/files/lib/wee/renderer/html/canvas_rb.html
131
+ - doc/rdoc/files/lib/wee/renderer/html/brushes_rb.html
132
132
  - doc/rdoc/files/lib/wee/renderer/html/writer_rb.html
133
133
  - doc/rdoc/files/lib/wee/continuation/core
134
134
  - doc/rdoc/files/lib/wee/continuation/session_rb.html
@@ -154,9 +154,9 @@ files:
154
154
  - doc/rdoc/files/lib/wee/idgen/md5_rb.html
155
155
  - doc/rdoc/files/lib/wee/databases/og
156
156
  - doc/rdoc/files/lib/wee/databases/og_rb.html
157
+ - doc/rdoc/files/lib/wee/databases/og/old_scaffolder_rb.html
157
158
  - doc/rdoc/files/lib/wee/databases/og/application_rb.html
158
159
  - doc/rdoc/files/lib/wee/databases/og/session_rb.html
159
- - doc/rdoc/files/lib/wee/databases/og/old_scaffolder_rb.html
160
160
  - doc/rdoc/files/lib/wee/databases/og/scaffolder_rb.html
161
161
  - doc/rdoc/files/lib/wee/utils/autoreload_rb.html
162
162
  - doc/rdoc/files/lib/wee/utils/helper_rb.html
@@ -185,44 +185,44 @@ files:
185
185
  - doc/rdoc/classes/Wee/Session.html
186
186
  - doc/rdoc/classes/Wee/Page.html
187
187
  - doc/rdoc/classes/Wee/Helper.html
188
- - doc/rdoc/classes/Wee/SimpleIdGenerator.html
189
188
  - doc/rdoc/classes/Wee/RefreshResponse.html
189
+ - doc/rdoc/classes/Wee/SimpleIdGenerator.html
190
190
  - doc/rdoc/classes/Wee/GenericResponse.html
191
191
  - doc/rdoc/classes/Wee/PageDecoration.html
192
192
  - doc/rdoc/classes/Wee/RequestHandler.html
193
193
  - doc/rdoc/classes/Wee/Decoration.html
194
- - doc/rdoc/classes/Wee/AnswerDecoration.html
194
+ - doc/rdoc/classes/Wee/WEBrickAdaptor.html
195
195
  - doc/rdoc/classes/Wee/MessageBox.html
196
196
  - doc/rdoc/classes/Wee/Response.html
197
197
  - doc/rdoc/classes/Wee/Snapshot.html
198
- - doc/rdoc/classes/Wee/HtmlWriter.html
199
- - doc/rdoc/classes/Wee/WEBrickAdaptor.html
200
- - doc/rdoc/classes/Wee/PagelessRequest.html
201
198
  - doc/rdoc/classes/Wee/CallbackStream.html
199
+ - doc/rdoc/classes/Wee/HtmlWriter.html
200
+ - doc/rdoc/classes/Wee/PagelessApplication.html
201
+ - doc/rdoc/classes/Wee/AnswerDecoration.html
202
202
  - doc/rdoc/classes/Wee/StateRegistry.html
203
203
  - doc/rdoc/classes/Wee/Delegate.html
204
204
  - doc/rdoc/classes/Wee/ValueHolder.html
205
205
  - doc/rdoc/classes/Wee/FormDecoration.html
206
206
  - doc/rdoc/classes/Wee/Canvas.html
207
- - doc/rdoc/classes/Wee/RedirectResponse.html
207
+ - doc/rdoc/classes/Wee/PagelessRequest.html
208
208
  - doc/rdoc/classes/Wee/StateHolder.html
209
- - doc/rdoc/classes/Wee/PagelessApplication.html
209
+ - doc/rdoc/classes/Wee/RedirectResponse.html
210
210
  - doc/rdoc/classes/Wee/RenderingContext.html
211
211
  - doc/rdoc/classes/Wee/Brush.html
212
212
  - doc/rdoc/classes/Wee/Context.html
213
213
  - doc/rdoc/classes/Wee/CallbackRegistry.html
214
214
  - doc/rdoc/classes/Wee/ErrorPage.html
215
+ - doc/rdoc/classes/Wee/Request.html
215
216
  - doc/rdoc/classes/Wee/LiteralMethodCallback.html
216
217
  - doc/rdoc/classes/Wee/WrapperDecoration.html
217
- - doc/rdoc/classes/Wee/Request.html
218
218
  - doc/rdoc/classes/Wee/Callback.html
219
219
  - doc/rdoc/classes/Wee/MethodCallback.html
220
- - doc/rdoc/classes/Wee/Utils.html
221
220
  - doc/rdoc/classes/Wee/HtmlCanvas.html
221
+ - doc/rdoc/classes/Wee/Utils.html
222
222
  - doc/rdoc/classes/Wee/Component.html
223
223
  - doc/rdoc/classes/Wee/Application.html
224
- - doc/rdoc/classes/Wee/Presenter.html
225
224
  - doc/rdoc/classes/Wee/PagelessSession.html
225
+ - doc/rdoc/classes/Wee/Presenter.html
226
226
  - doc/rdoc/classes/Wee/ErrorResponse.html
227
227
  - doc/rdoc/classes/Wee/Md5IdGenerator.html
228
228
  - doc/rdoc/classes/Wee/Utils/LRUCache.html
@@ -322,9 +322,9 @@ files:
322
322
  - lib/wee/idgen/md5.rb
323
323
  - lib/wee/databases/og
324
324
  - lib/wee/databases/og.rb
325
- - lib/wee/databases/og/old_scaffolder.rb
326
325
  - lib/wee/databases/og/application.rb
327
326
  - lib/wee/databases/og/session.rb
327
+ - lib/wee/databases/og/old_scaffolder.rb
328
328
  - lib/wee/databases/og/scaffolder.rb
329
329
  - lib/wee/core/component.rb
330
330
  - lib/wee/core/snapshot.rb
@@ -339,8 +339,8 @@ files:
339
339
  - lib/wee/pageless/session.rb
340
340
  - lib/wee/pageless/request.rb
341
341
  - lib/wee/renderer/html
342
- - lib/wee/renderer/html/brushes.rb
343
342
  - lib/wee/renderer/html/canvas.rb
343
+ - lib/wee/renderer/html/brushes.rb
344
344
  - lib/wee/renderer/html/writer.rb
345
345
  - lib/wee/continuation/core
346
346
  - lib/wee/continuation/session.rb