wee 0.8.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (231) hide show
  1. data/ChangeLog +286 -0
  2. data/Features +185 -0
  3. data/doc/rdoc/classes/ActionView.html +107 -0
  4. data/doc/rdoc/classes/ActionView/Base.html +133 -0
  5. data/doc/rdoc/classes/Array.html +7 -59
  6. data/doc/rdoc/classes/Cache/StorageCache.html +38 -38
  7. data/doc/rdoc/classes/Cache/Strategy/CapacityBounded.html +30 -30
  8. data/doc/rdoc/classes/Cache/Strategy/LFU.html +24 -24
  9. data/doc/rdoc/classes/Cache/Strategy/LRU.html +24 -24
  10. data/doc/rdoc/classes/Cache/Strategy/Unbounded.html +24 -24
  11. data/doc/rdoc/classes/Enumerable.html +6 -6
  12. data/doc/rdoc/classes/Hash.html +120 -0
  13. data/doc/rdoc/classes/Main.html +58 -34
  14. data/doc/rdoc/classes/Object.html +12 -12
  15. data/doc/rdoc/classes/OgScaffolder.html +165 -166
  16. data/doc/rdoc/classes/OgScaffolder/Editor.html +112 -112
  17. data/doc/rdoc/classes/String.html +7 -59
  18. data/doc/rdoc/classes/Struct.html +14 -14
  19. data/doc/rdoc/classes/Wee.html +70 -6
  20. data/doc/rdoc/classes/Wee/AbstractSession.html +502 -0
  21. data/doc/rdoc/classes/Wee/AnswerDecoration.html +11 -11
  22. data/doc/rdoc/classes/Wee/Application.html +139 -84
  23. data/doc/rdoc/classes/Wee/Brush.html +21 -18
  24. data/doc/rdoc/classes/Wee/Brush/AnchorTag.html +90 -17
  25. data/doc/rdoc/classes/Wee/Brush/CheckboxTag.html +162 -0
  26. data/doc/rdoc/classes/Wee/Brush/FileUploadTag.html +7 -7
  27. data/doc/rdoc/classes/Wee/Brush/FormTag.html +41 -17
  28. data/doc/rdoc/classes/Wee/Brush/GenericEncodedTextBrush.html +12 -12
  29. data/doc/rdoc/classes/Wee/Brush/GenericSingleTagBrush.html +7 -7
  30. data/doc/rdoc/classes/Wee/Brush/GenericTagBrush.html +112 -86
  31. data/doc/rdoc/classes/Wee/Brush/GenericTextBrush.html +12 -12
  32. data/doc/rdoc/classes/Wee/Brush/HiddenInputTag.html +160 -0
  33. data/doc/rdoc/classes/Wee/Brush/ImageButtonTag.html +15 -15
  34. data/doc/rdoc/classes/Wee/Brush/ImageTag.html +21 -21
  35. data/doc/rdoc/classes/Wee/Brush/InputTag.html +14 -14
  36. data/doc/rdoc/classes/Wee/Brush/JavascriptTag.html +7 -7
  37. data/doc/rdoc/classes/Wee/Brush/Page.html +14 -14
  38. data/doc/rdoc/classes/Wee/Brush/RadioButtonTag.html +234 -0
  39. data/doc/rdoc/classes/Wee/Brush/RadioButtonTag/RadioGroup.html +207 -0
  40. data/doc/rdoc/classes/Wee/Brush/SelectListTag.html +124 -28
  41. data/doc/rdoc/classes/Wee/Brush/SelectListTag/SelectListCallback.html +7 -7
  42. data/doc/rdoc/classes/Wee/Brush/SelectOptionTag.html +7 -7
  43. data/doc/rdoc/classes/Wee/Brush/SubmitButtonTag.html +7 -7
  44. data/doc/rdoc/classes/Wee/Brush/TableDataTag.html +14 -14
  45. data/doc/rdoc/classes/Wee/Brush/TableHeaderTag.html +7 -7
  46. data/doc/rdoc/classes/Wee/Brush/TableRowTag.html +42 -42
  47. data/doc/rdoc/classes/Wee/Brush/TableTag.html +7 -7
  48. data/doc/rdoc/classes/Wee/Brush/TextAreaTag.html +48 -15
  49. data/doc/rdoc/classes/Wee/Brush/TextInputTag.html +7 -7
  50. data/doc/rdoc/classes/Wee/CallbackRegistry.html +38 -38
  51. data/doc/rdoc/classes/Wee/CallbackStream.html +18 -18
  52. data/doc/rdoc/classes/Wee/CanvasMixin.html +225 -0
  53. data/doc/rdoc/classes/Wee/Component.html +202 -201
  54. data/doc/rdoc/classes/Wee/Component/OnAnswer.html +7 -7
  55. data/doc/rdoc/classes/Wee/ComponentDispatcher.html +289 -0
  56. data/doc/rdoc/classes/Wee/ComponentRunner.html +321 -0
  57. data/doc/rdoc/classes/Wee/Context.html +63 -3
  58. data/doc/rdoc/classes/Wee/Decoration.html +45 -45
  59. data/doc/rdoc/classes/Wee/Delegate.html +30 -30
  60. data/doc/rdoc/classes/Wee/DupReplaceSnapshotMixin.html +164 -0
  61. data/doc/rdoc/classes/Wee/ErrorResponse.html +16 -16
  62. data/doc/rdoc/classes/Wee/Examples.html +114 -0
  63. data/doc/rdoc/classes/Wee/Examples/Calculator.html +319 -0
  64. data/doc/rdoc/classes/Wee/Examples/Counter.html +289 -0
  65. data/doc/rdoc/classes/Wee/Examples/EditableCounter.html +210 -0
  66. data/doc/rdoc/classes/Wee/Examples/Window.html +346 -0
  67. data/doc/rdoc/classes/Wee/FastCGIAdaptor.html +227 -0
  68. data/doc/rdoc/classes/Wee/FormDecoration.html +6 -6
  69. data/doc/rdoc/classes/Wee/GenericResponse.html +7 -7
  70. data/doc/rdoc/classes/Wee/HtmlCanvasRenderer.html +1230 -0
  71. data/doc/rdoc/classes/Wee/HtmlWriter.html +40 -40
  72. data/doc/rdoc/classes/Wee/IdGenerator.html +148 -0
  73. data/doc/rdoc/classes/Wee/LiteralMethodCallback.html +27 -14
  74. data/doc/rdoc/classes/Wee/LoginDecoration.html +261 -0
  75. data/doc/rdoc/classes/Wee/Md5IdGenerator.html +14 -14
  76. data/doc/rdoc/classes/Wee/MessageBox.html +14 -14
  77. data/doc/rdoc/classes/Wee/Nitro.html +114 -0
  78. data/doc/rdoc/classes/Wee/Nitro/ControllerClassMixin.html +192 -0
  79. data/doc/rdoc/classes/Wee/Nitro/ControllerMixin.html +345 -0
  80. data/doc/rdoc/classes/Wee/Nitro/FormTag.html +155 -0
  81. data/doc/rdoc/classes/Wee/Nitro/HtmlCanvasRenderer.html +178 -0
  82. data/doc/rdoc/classes/Wee/Page.html +4 -0
  83. data/doc/rdoc/classes/Wee/PageDecoration.html +18 -18
  84. data/doc/rdoc/classes/Wee/PagelessApplication.html +13 -11
  85. data/doc/rdoc/classes/Wee/PagelessComponentDriver.html +296 -0
  86. data/doc/rdoc/classes/Wee/PagelessRequest.html +52 -21
  87. data/doc/rdoc/classes/Wee/PagelessSession.html +130 -91
  88. data/doc/rdoc/classes/Wee/Pager.html +534 -0
  89. data/doc/rdoc/classes/Wee/Presenter.html +482 -298
  90. data/doc/rdoc/classes/Wee/Rails.html +114 -0
  91. data/doc/rdoc/classes/Wee/Rails/ControllerClassMixin.html +192 -0
  92. data/doc/rdoc/classes/Wee/Rails/ControllerMixin.html +342 -0
  93. data/doc/rdoc/classes/Wee/Rails/FormTag.html +155 -0
  94. data/doc/rdoc/classes/Wee/Rails/HtmlCanvasRenderer.html +177 -0
  95. data/doc/rdoc/classes/Wee/RedirectResponse.html +7 -7
  96. data/doc/rdoc/classes/Wee/RefreshResponse.html +7 -7
  97. data/doc/rdoc/classes/Wee/Renderer.html +208 -0
  98. data/doc/rdoc/classes/Wee/RenderingContext.html +175 -3
  99. data/doc/rdoc/classes/Wee/Request.html +197 -46
  100. data/doc/rdoc/classes/Wee/RequestHandler.html +31 -31
  101. data/doc/rdoc/classes/Wee/Response.html +44 -43
  102. data/doc/rdoc/classes/Wee/Session.html +296 -402
  103. data/doc/rdoc/classes/Wee/SimpleIdGenerator.html +14 -14
  104. data/doc/rdoc/classes/Wee/Snapshot.html +19 -19
  105. data/doc/rdoc/classes/Wee/Utils.html +22 -22
  106. data/doc/rdoc/classes/Wee/Utils/LRUCache.html +6 -6
  107. data/doc/rdoc/classes/Wee/ValueHolder.html +19 -19
  108. data/doc/rdoc/classes/Wee/WEBrickAdaptor.html +72 -46
  109. data/doc/rdoc/classes/Wee/WrapperDecoration.html +6 -6
  110. data/doc/rdoc/created.rid +1 -1
  111. data/doc/rdoc/files/INSTALL.html +1 -1
  112. data/doc/rdoc/files/README.html +8 -12
  113. data/doc/rdoc/files/lib/cache/cache_rb.html +1 -1
  114. data/doc/rdoc/files/lib/wee/abstractsession_rb.html +108 -0
  115. data/doc/rdoc/files/lib/wee/adaptors/fastcgi_rb.html +108 -0
  116. data/doc/rdoc/files/lib/wee/adaptors/nitro_rb.html +101 -0
  117. data/doc/rdoc/files/lib/wee/adaptors/rails_rb.html +101 -0
  118. data/doc/rdoc/files/lib/wee/adaptors/webrick_rb.html +1 -1
  119. data/doc/rdoc/files/lib/wee/application_rb.html +1 -1
  120. data/doc/rdoc/files/lib/wee/components/component_dispatcher_rb.html +108 -0
  121. data/doc/rdoc/files/lib/wee/components/form_decoration_rb.html +1 -1
  122. data/doc/rdoc/files/lib/wee/components/login_decoration_rb.html +101 -0
  123. data/doc/rdoc/files/lib/wee/components/messagebox_rb.html +1 -1
  124. data/doc/rdoc/files/lib/wee/components/page_decoration_rb.html +1 -1
  125. data/doc/rdoc/files/lib/wee/components/pager_rb.html +101 -0
  126. data/doc/rdoc/files/lib/wee/components/wrapper_decoration_rb.html +1 -1
  127. data/doc/rdoc/files/lib/wee/components_rb.html +4 -1
  128. data/doc/rdoc/files/lib/wee/continuation/core/component_rb.html +1 -1
  129. data/doc/rdoc/files/lib/wee/continuation/session_rb.html +1 -1
  130. data/doc/rdoc/files/lib/wee/continuation_rb.html +1 -1
  131. data/doc/rdoc/files/lib/wee/core/callback_rb.html +1 -1
  132. data/doc/rdoc/files/lib/wee/core/component_rb.html +1 -1
  133. data/doc/rdoc/files/lib/wee/core/componentrunner_rb.html +110 -0
  134. data/doc/rdoc/files/lib/wee/core/context_rb.html +101 -0
  135. data/doc/rdoc/files/lib/wee/core/decoration_rb.html +1 -1
  136. data/doc/rdoc/files/lib/wee/core/idgen_rb.html +101 -0
  137. data/doc/rdoc/files/lib/wee/core/page_rb.html +101 -0
  138. data/doc/rdoc/files/lib/wee/core/presenter_rb.html +1 -1
  139. data/doc/rdoc/files/lib/wee/core/renderer_rb.html +107 -0
  140. data/doc/rdoc/files/lib/wee/core/snapshot_rb.html +1 -1
  141. data/doc/rdoc/files/lib/wee/core/valueholder_rb.html +2 -2
  142. data/doc/rdoc/files/lib/wee/core_ext_rb.html +101 -0
  143. data/doc/rdoc/files/lib/wee/core_rb.html +7 -14
  144. data/doc/rdoc/files/lib/wee/databases/og/application_rb.html +1 -1
  145. data/doc/rdoc/files/lib/wee/databases/og/old_scaffolder_rb.html +1 -1
  146. data/doc/rdoc/files/lib/wee/databases/og/scaffolder_rb.html +1 -1
  147. data/doc/rdoc/files/lib/wee/databases/og/session_rb.html +1 -1
  148. data/doc/rdoc/files/lib/wee/databases/og_rb.html +1 -1
  149. data/doc/rdoc/files/lib/wee/examples/calculator_rb.html +107 -0
  150. data/doc/rdoc/files/lib/wee/examples/counter_rb.html +101 -0
  151. data/doc/rdoc/files/lib/wee/examples/editable_counter_rb.html +114 -0
  152. data/doc/rdoc/files/lib/wee/examples/window_rb.html +101 -0
  153. data/doc/rdoc/files/lib/wee/idgen/md5_rb.html +1 -1
  154. data/doc/rdoc/files/lib/wee/idgen/simple_rb.html +1 -1
  155. data/doc/rdoc/files/lib/wee/page_rb.html +1 -1
  156. data/doc/rdoc/files/lib/wee/pageless/application_rb.html +8 -1
  157. data/doc/rdoc/files/lib/wee/pageless/request_rb.html +1 -1
  158. data/doc/rdoc/files/lib/wee/pageless/session_rb.html +2 -1
  159. data/doc/rdoc/files/lib/wee/pageless_rb.html +1 -1
  160. data/doc/rdoc/files/lib/wee/renderer/html/brushes_rb.html +1 -1
  161. data/doc/rdoc/files/lib/wee/renderer/html/canvas_rb.html +1 -1
  162. data/doc/rdoc/files/lib/wee/renderer/html/writer_rb.html +1 -1
  163. data/doc/rdoc/files/lib/wee/request_rb.html +5 -4
  164. data/doc/rdoc/files/lib/wee/requesthandler_rb.html +1 -1
  165. data/doc/rdoc/files/lib/wee/response_rb.html +2 -1
  166. data/doc/rdoc/files/lib/wee/session_rb.html +2 -3
  167. data/doc/rdoc/files/lib/wee/skeleton/og/components/main_rb.html +1 -1
  168. data/doc/rdoc/files/lib/wee/skeleton/og/conf/db_rb.html +2 -2
  169. data/doc/rdoc/files/lib/wee/skeleton/og/models/recipe_rb.html +1 -1
  170. data/doc/rdoc/files/lib/wee/skeleton/og/run_rb.html +1 -1
  171. data/doc/rdoc/files/lib/wee/skeleton/simple/components/main_rb.html +1 -1
  172. data/doc/rdoc/files/lib/wee/skeleton/simple/run_rb.html +1 -1
  173. data/doc/rdoc/files/lib/wee/snapshot_ext_rb.html +1 -1
  174. data/doc/rdoc/files/lib/wee/template_rb.html +1 -1
  175. data/doc/rdoc/files/lib/wee/utils/autoreload_rb.html +1 -1
  176. data/doc/rdoc/files/lib/wee/utils/cache_rb.html +1 -1
  177. data/doc/rdoc/files/lib/wee/utils/helper_rb.html +1 -1
  178. data/doc/rdoc/files/lib/wee/utils_rb.html +1 -1
  179. data/doc/rdoc/files/lib/wee_rb.html +5 -3
  180. data/doc/rdoc/fr_class_index.html +34 -2
  181. data/doc/rdoc/fr_file_index.html +17 -1
  182. data/doc/rdoc/fr_method_index.html +464 -314
  183. data/examples/ajax/ajax.rb +1 -1
  184. data/examples/demo.rb +47 -0
  185. data/examples/{calendar.rb → demo/calendar.rb} +89 -97
  186. data/examples/{example.rb → demo/example.rb} +17 -97
  187. data/examples/dispatcher.rb +37 -0
  188. data/examples/draw.rb +14 -11
  189. data/examples/nitro/run.rb +42 -0
  190. data/examples/radio.rb +44 -0
  191. data/examples/test.rb +3 -27
  192. data/lib/wee.rb +15 -3
  193. data/lib/wee/adaptors/nitro.rb +154 -0
  194. data/lib/wee/adaptors/rails.rb +154 -0
  195. data/lib/wee/application.rb +22 -20
  196. data/lib/wee/components.rb +3 -0
  197. data/lib/wee/components/component_dispatcher.rb +46 -0
  198. data/lib/wee/components/login_decoration.rb +35 -0
  199. data/lib/wee/components/messagebox.rb +2 -2
  200. data/lib/wee/components/pager.rb +102 -0
  201. data/lib/wee/continuation/core/component.rb +13 -12
  202. data/lib/wee/continuation/session.rb +11 -19
  203. data/lib/wee/core.rb +8 -7
  204. data/lib/wee/core/component.rb +8 -28
  205. data/lib/wee/core/componentrunner.rb +73 -0
  206. data/lib/wee/core/context.rb +27 -0
  207. data/lib/wee/core/idgen.rb +5 -0
  208. data/lib/wee/core/page.rb +1 -0
  209. data/lib/wee/core/presenter.rb +10 -126
  210. data/lib/wee/core/renderer.rb +23 -0
  211. data/lib/wee/core_ext.rb +122 -0
  212. data/lib/wee/databases/og/scaffolder.rb +0 -1
  213. data/lib/wee/examples/calculator.rb +70 -0
  214. data/lib/wee/examples/counter.rb +33 -0
  215. data/lib/wee/examples/editable_counter.rb +31 -0
  216. data/{examples → lib/wee/examples}/window.rb +29 -23
  217. data/lib/wee/idgen/md5.rb +1 -1
  218. data/lib/wee/idgen/simple.rb +1 -1
  219. data/lib/wee/pageless/session.rb +2 -3
  220. data/lib/wee/renderer/html/brushes.rb +142 -22
  221. data/lib/wee/renderer/html/canvas.rb +57 -19
  222. data/lib/wee/response.rb +3 -2
  223. data/lib/wee/session.rb +10 -54
  224. data/lib/wee/skeleton/og/components/main.rb +5 -1
  225. data/lib/wee/skeleton/og/conf/db.rb +1 -1
  226. data/lib/wee/snapshot_ext.rb +4 -10
  227. data/lib/wee/template.rb +19 -5
  228. data/lib/wee/utils/helper.rb +2 -2
  229. metadata +90 -13
  230. data/examples/calculator.rb +0 -67
  231. data/lib/wee/context.rb +0 -2
@@ -20,7 +20,7 @@ class AjaxTest < Wee::Component
20
20
 
21
21
  def update
22
22
  send_render_response {
23
- r.text "Live-updates works! This is no. #{ @live_updates += 1}"
23
+ r.text "Live-updates works! This is no. #{ @live_updates = (@live_updates || 0) + 1 }"
24
24
  }
25
25
  end
26
26
  end
@@ -0,0 +1,47 @@
1
+ require 'wee'
2
+ require 'wee/adaptors/webrick'
3
+ require 'wee/utils'
4
+
5
+ class Demo < Wee::Component
6
+ def render
7
+ r.h1 'Wee Demos'
8
+ r.ul {
9
+ APPS.each do |name, descr, _|
10
+ r.li {
11
+ r.anchor.href("/#{ name }").with("/#{ name }: #{ descr }")
12
+ }
13
+ end
14
+ }
15
+ end
16
+ end
17
+
18
+ APPS = []
19
+ def APPS.add(name, description=nil, &block)
20
+ self << [name, description||name, block]
21
+ end
22
+
23
+ APPS.add 'demo', 'This demo application' do
24
+ Demo.new.add_decoration Wee::PageDecoration.new('Demo')
25
+ end
26
+
27
+ APPS.add 'calc', 'RPN Calculator' do
28
+ require 'wee/examples/calculator'
29
+ Wee::Examples::Calculator.new.
30
+ add_decoration(Wee::FormDecoration.new).
31
+ add_decoration(Wee::PageDecoration.new('RPN Calculator'))
32
+ end
33
+
34
+ APPS.add 'calendar', 'Calendar' do
35
+ require File.join(File.dirname(__FILE__), 'demo', 'calendar')
36
+ CustomCalendarDemo.new
37
+ end
38
+
39
+ APPS.add 'example', 'Misc Components' do
40
+ require File.join(File.dirname(__FILE__), 'demo', 'example')
41
+ MainPage.new
42
+ end
43
+
44
+ APPS.each do |name, descr, block|
45
+ Wee::WEBrickAdaptor.register("/#{ name }" => Wee::Utils.app_for(&block))
46
+ end
47
+ Wee::WEBrickAdaptor.start
@@ -1,9 +1,5 @@
1
1
  # Copyright by Kevin Howe (kh@newclear.ca)
2
2
 
3
- $LOAD_PATH.unshift << "../lib"
4
- require 'wee'
5
- require 'wee/adaptors/webrick'
6
- require 'wee/utils'
7
3
  require 'date'
8
4
 
9
5
  class Date
@@ -247,108 +243,104 @@ class MiniCalendar < Wee::Component
247
243
  end
248
244
  end
249
245
 
250
- if __FILE__ == $0
246
+ # Custom CSS styles
247
+ #
248
+ module StyleMixin
249
+ def render_styles
250
+ r.style("
251
+ a {
252
+ text-decoration: none;
253
+ }
254
+ body {
255
+ font-size : 11px;
256
+ font-family : Arial, Helvetica, sans-serif;
257
+ text-align: center;
258
+ }
259
+ td {
260
+ font-family: Arial, Helvetica, sans-serif;
261
+ font-size: 11px;
262
+ border: 1px solid;
263
+ background-color: #FFFFFF;
264
+ vertical-align: top;
265
+ text-align: center;
266
+ }
267
+ th {
268
+ font-family: Arial, Helvetica, sans-serif;
269
+ font-size: 11px;
270
+ font-style: normal;
271
+ font-weight: bold;
272
+ background-color: #BBCCFF;
273
+ border: 1px solid;
274
+ vertical-align: top;
275
+ text-align: center;
276
+ }
277
+ ")
278
+ end
279
+ end
280
+
281
+ # Calendar with custom CSS styles
282
+ #
283
+ class CustomCalendar < MiniCalendar
284
+ include StyleMixin
285
+ end
286
+
287
+ # Calendar demo
288
+ #
289
+ class CustomCalendarDemo < Wee::Component
290
+ include StyleMixin
291
+
292
+ # Holds the current chosen date
293
+ attr_accessor :date
294
+
295
+ # Initialize with a Date object (defaults to today)
296
+ #
297
+ def initialize(date=Date.today)
298
+ super()
299
+ @date = date
300
+ end
251
301
 
252
- # Custom CSS styles
302
+ # Backtrack state
253
303
  #
254
- module StyleMixin
255
- def render_styles
256
- r.style("
257
- a {
258
- text-decoration: none;
259
- }
260
- body {
261
- font-size : 11px;
262
- font-family : Arial, Helvetica, sans-serif;
263
- text-align: center;
264
- }
265
- td {
266
- font-family: Arial, Helvetica, sans-serif;
267
- font-size: 11px;
268
- border: 1px solid;
269
- background-color: #FFFFFF;
270
- vertical-align: top;
271
- text-align: center;
272
- }
273
- th {
274
- font-family: Arial, Helvetica, sans-serif;
275
- font-size: 11px;
276
- font-style: normal;
277
- font-weight: bold;
278
- background-color: #BBCCFF;
279
- border: 1px solid;
280
- vertical-align: top;
281
- text-align: center;
282
- }
283
- ")
284
- end
304
+ def backtrack_state(snap)
305
+ super
306
+ snap.add(self)
285
307
  end
286
308
 
287
- # Calendar with custom CSS styles
309
+ # Render calendar icon
288
310
  #
289
- class CustomCalendar < MiniCalendar
290
- include StyleMixin
311
+ def render_icon
312
+ icon = 'http://www.softcomplex.com/products/tigra_calendar/img/cal.gif'
313
+ r.image.src(icon).width(16).height(16).border(0).alt('Calendar')
291
314
  end
292
-
293
- # Calendar demo
315
+
316
+ # Render Calendar demo
294
317
  #
295
- class CustomCalendarDemo < Wee::Component
296
- include StyleMixin
297
-
298
- # Holds the current chosen date
299
- attr_accessor :date
300
-
301
- # Initialize with a Date object (defaults to today)
302
- #
303
- def initialize(date=Date.today)
304
- super()
305
- @date = date
306
- end
307
-
308
- # Backtrack state
309
- #
310
- def backtrack_state(snap)
311
- super
312
- snap.add(self)
313
- end
314
-
315
- # Render calendar icon
316
- #
317
- def render_icon
318
- icon = 'http://www.softcomplex.com/products/tigra_calendar/img/cal.gif'
319
- r.image.src(icon).width(16).height(16).border(0).alt('Calendar')
320
- end
321
-
322
- # Render Calendar demo
323
- #
324
- def render
325
- r.html do
326
- r.head { r.title('Calendar Demo'); render_styles }
327
- r.body do
328
- r.break
329
- r.table { r.table_row { r.table_header {
330
- r.table do
331
- r.table_row { r.table_header('Calendar Demo') }
332
- r.table_row { r.table_data {
333
- r.text_input.value(@date).attr(:date)
334
- r.space
335
- r.anchor.callback { calendar }.with { render_icon }
336
- }}
337
- end
338
- }}}
339
- end
340
- end
341
- end
342
-
343
- # Call the calendar component
344
- #
345
- def calendar()
346
- if date = call( CustomCalendar.new(@date) )
347
- @date = date
318
+ def render
319
+ r.html do
320
+ r.head { r.title('Calendar Demo'); render_styles }
321
+ r.body do
322
+ r.break
323
+ r.table { r.table_row { r.table_header {
324
+ r.table do
325
+ r.table_row { r.table_header('Calendar Demo') }
326
+ r.table_row { r.table_data {
327
+ r.text_input.value(@date).attr(:date)
328
+ r.space
329
+ r.anchor.callback { calendar }.with { render_icon }
330
+ }}
331
+ end
332
+ }}}
348
333
  end
349
334
  end
350
335
  end
336
+
337
+ # Call the calendar component
338
+ #
339
+ def calendar()
340
+ call( CustomCalendar.new(@date), :set_date)
341
+ end
351
342
 
352
- app = Wee::Utils.app_for(CustomCalendarDemo)
353
- Wee::WEBrickAdaptor.register('/app' => app).start
343
+ def set_date(date)
344
+ @date = date if date
345
+ end
354
346
  end
@@ -1,50 +1,5 @@
1
- $LOAD_PATH.unshift << "../lib"
2
- require 'wee'
3
- require 'window'
4
-
5
- class Counter < Wee::Component
6
- def initialize(cnt)
7
- super()
8
- @cnt = cnt
9
- end
10
-
11
- def backtrack_state(snap)
12
- super
13
- snap.add(self)
14
- end
15
-
16
- def dec
17
- @cnt -= 1
18
- end
19
-
20
- def inc
21
- @cnt += 1
22
- end
23
-
24
- def render
25
- r.anchor.callback { dec }.with("--")
26
- r.space; r.text(@cnt.to_s); r.space
27
- r.anchor.callback { inc }.with("++")
28
- end
29
- end
30
-
31
- class MessageBox < Wee::Component
32
- def initialize(text)
33
- super()
34
- @text = text
35
- end
36
-
37
- def render
38
- r.break
39
- r.text(@text)
40
- r.form do
41
- r.submit_button.value('OK').callback { answer true }
42
- r.space
43
- r.submit_button.value('Cancel').callback { answer false }
44
- end
45
- r.break
46
- end
47
- end
1
+ require 'wee/examples/window'
2
+ require 'wee/examples/editable_counter'
48
3
 
49
4
  class RegexpValidatedInput < Wee::Component
50
5
 
@@ -93,50 +48,17 @@ class RegexpValidatedInput < Wee::Component
93
48
 
94
49
  end
95
50
 
96
- class EditableCounter < Counter
97
-
98
- def initialize(cnt)
99
- super
100
- @show_edit_field = false
101
- end
102
-
103
- def render
104
- #r.form.callback{submit}.with do
105
- r.anchor.callback { dec }.with("--")
106
- r.space
107
-
108
- if @show_edit_field
109
- r.text_input.callback{|@cnt|}.value(@cnt).size(6)
110
- r.submit_button.callback{submit}.value('S')
111
- else
112
- r.anchor.callback{submit}.with(@cnt)
113
- end
114
-
115
- r.space
116
- r.anchor.callback{inc}.with("++")
117
- #end
118
- end
119
-
120
- def submit
121
- if @cnt.to_s !~ /^\d+$/
122
- call MessageBox.new("You entered an invalid counter! Please try again!")
123
- @cnt = 0
124
- else
125
- @show_edit_field = !@show_edit_field
126
- end
127
- @cnt = @cnt.to_i
128
- end
129
-
130
- def cnt=(val)
131
- @cnt = val
132
- end
133
-
134
- end
135
-
136
51
  class MainPage < Wee::Component
137
52
  def initialize
138
53
  super()
139
- @counters = (1..10).map {|i| Wee::Window.new("Cnt #{ i }", "#{i*10}px", EditableCounter.new(i))}
54
+ @counters = (1..10).map {|i|
55
+ Wee::Examples::Window.new {|w|
56
+ w.title = "Cnt #{ i }"
57
+ w.pos_x = "200px"
58
+ w.pos_y = "#{i*50}px"
59
+ w.child = Wee::Examples::EditableCounter.new(i)
60
+ }
61
+ }
140
62
  children.push(*@counters)
141
63
  children << (@val_inp = RegexpValidatedInput.new('Michael Neumann', /^\w+\s+\w+$/))
142
64
 
@@ -196,14 +118,12 @@ class MainPage < Wee::Component
196
118
  end
197
119
 
198
120
  def add
199
- if call(MessageBox.new("Do you really want to add '" + @text + "'?"))
200
- @arr << @text if call(MessageBox.new("Do you really really really want to add '" + @text + "'?"))
201
- end
121
+ call Wee::MessageBox.new("Do you really want to add '" + @text + "'?"), proc {|res|
122
+ if res
123
+ call Wee::MessageBox.new("Do you really really really want to add '" + @text + "'?"), proc {|res2|
124
+ @arr << @text if res2
125
+ }
126
+ end
127
+ }
202
128
  end
203
129
  end
204
-
205
- if __FILE__ == $0
206
- require 'wee/adaptors/webrick'
207
- require 'wee/utils'
208
- Wee::WEBrickAdaptor.register('/app' => Wee::Utils.app_for(MainPage)).start
209
- end
@@ -0,0 +1,37 @@
1
+ require 'wee'
2
+ require 'wee/examples/calculator'
3
+ require 'wee/examples/counter'
4
+
5
+ class Wee::Pager
6
+ def render_arrow(sym, text, tooltip=text)
7
+ index =
8
+ case sym
9
+ when :first
10
+ 0
11
+ when :prev
12
+ @current_page - 1
13
+ when :next
14
+ @current_page + 1
15
+ when :last
16
+ last_page_index
17
+ end
18
+ r.anchor.info("pager/#{ index }").callback(sym).tooltip(tooltip).with { r.encode_text(text) }
19
+ end
20
+
21
+ def render_page_num(num, current)
22
+ if current
23
+ r.bold(num+1)
24
+ else
25
+ r.anchor.info("pager/#{ num }").callback(:goto, num).with(num+1)
26
+ end
27
+ end
28
+ end
29
+
30
+ comp = Wee::ComponentDispatcher.new
31
+ comp.add_rule /calc/, Wee::Examples::Calculator.new
32
+ comp.add_rule /pager\/(\d+)/, Wee::Pager.new(50) do |comp, match|
33
+ comp.goto(Integer(match[1]))
34
+ end
35
+ comp.add_rule /(counter|)/, Wee::Examples::Counter.new
36
+
37
+ Wee.run(comp)
@@ -1,14 +1,17 @@
1
1
  $LOAD_PATH.unshift << "../lib"
2
2
  require 'wee'
3
- require 'wee/webrick'
4
- require 'wee/utils/cache'
3
+ require 'wee/adaptors/webrick'
4
+ require 'wee/utils'
5
5
  require 'GD'
6
6
 
7
7
  class MainPage < Wee::Component
8
8
 
9
9
  def initialize
10
10
  @points = []
11
- session.register_object_for_backtracking(@points)
11
+ end
12
+
13
+ def backtrack_state(snap)
14
+ snap.add(@points)
12
15
  end
13
16
 
14
17
  def create_image(points)
@@ -33,17 +36,17 @@ class MainPage < Wee::Component
33
36
  @points.clear
34
37
  end
35
38
 
36
- def process_request(context)
37
- query = context.request.unparsed_uri.split('?').last
38
- @x, @y = query.split(",").map {|i| i.to_i} if query
39
- super
40
- end
39
+ #def process_request(context)
40
+ # query = context.request.unparsed_uri.split('?').last
41
+ # @x, @y = query.split(",").map {|i| i.to_i} if query
42
+ # super
43
+ #end
41
44
 
42
45
  # TODO: move the above into method point (we need the current context,
43
46
  # Session.current_context)
44
- def draw_point
45
- @points << [@x, @y]
46
- end
47
+ #def draw_point
48
+ # @points << [@x, @y]
49
+ #end
47
50
 
48
51
  def render
49
52
  r.page.title("Draw Test").with do