wee 0.8.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +286 -0
- data/Features +185 -0
- data/doc/rdoc/classes/ActionView.html +107 -0
- data/doc/rdoc/classes/ActionView/Base.html +133 -0
- data/doc/rdoc/classes/Array.html +7 -59
- data/doc/rdoc/classes/Cache/StorageCache.html +38 -38
- data/doc/rdoc/classes/Cache/Strategy/CapacityBounded.html +30 -30
- data/doc/rdoc/classes/Cache/Strategy/LFU.html +24 -24
- data/doc/rdoc/classes/Cache/Strategy/LRU.html +24 -24
- data/doc/rdoc/classes/Cache/Strategy/Unbounded.html +24 -24
- data/doc/rdoc/classes/Enumerable.html +6 -6
- data/doc/rdoc/classes/Hash.html +120 -0
- data/doc/rdoc/classes/Main.html +58 -34
- data/doc/rdoc/classes/Object.html +12 -12
- data/doc/rdoc/classes/OgScaffolder.html +165 -166
- data/doc/rdoc/classes/OgScaffolder/Editor.html +112 -112
- data/doc/rdoc/classes/String.html +7 -59
- data/doc/rdoc/classes/Struct.html +14 -14
- data/doc/rdoc/classes/Wee.html +70 -6
- data/doc/rdoc/classes/Wee/AbstractSession.html +502 -0
- data/doc/rdoc/classes/Wee/AnswerDecoration.html +11 -11
- data/doc/rdoc/classes/Wee/Application.html +139 -84
- data/doc/rdoc/classes/Wee/Brush.html +21 -18
- data/doc/rdoc/classes/Wee/Brush/AnchorTag.html +90 -17
- data/doc/rdoc/classes/Wee/Brush/CheckboxTag.html +162 -0
- data/doc/rdoc/classes/Wee/Brush/FileUploadTag.html +7 -7
- data/doc/rdoc/classes/Wee/Brush/FormTag.html +41 -17
- data/doc/rdoc/classes/Wee/Brush/GenericEncodedTextBrush.html +12 -12
- data/doc/rdoc/classes/Wee/Brush/GenericSingleTagBrush.html +7 -7
- data/doc/rdoc/classes/Wee/Brush/GenericTagBrush.html +112 -86
- data/doc/rdoc/classes/Wee/Brush/GenericTextBrush.html +12 -12
- data/doc/rdoc/classes/Wee/Brush/HiddenInputTag.html +160 -0
- data/doc/rdoc/classes/Wee/Brush/ImageButtonTag.html +15 -15
- data/doc/rdoc/classes/Wee/Brush/ImageTag.html +21 -21
- data/doc/rdoc/classes/Wee/Brush/InputTag.html +14 -14
- data/doc/rdoc/classes/Wee/Brush/JavascriptTag.html +7 -7
- data/doc/rdoc/classes/Wee/Brush/Page.html +14 -14
- data/doc/rdoc/classes/Wee/Brush/RadioButtonTag.html +234 -0
- data/doc/rdoc/classes/Wee/Brush/RadioButtonTag/RadioGroup.html +207 -0
- data/doc/rdoc/classes/Wee/Brush/SelectListTag.html +124 -28
- data/doc/rdoc/classes/Wee/Brush/SelectListTag/SelectListCallback.html +7 -7
- data/doc/rdoc/classes/Wee/Brush/SelectOptionTag.html +7 -7
- data/doc/rdoc/classes/Wee/Brush/SubmitButtonTag.html +7 -7
- data/doc/rdoc/classes/Wee/Brush/TableDataTag.html +14 -14
- data/doc/rdoc/classes/Wee/Brush/TableHeaderTag.html +7 -7
- data/doc/rdoc/classes/Wee/Brush/TableRowTag.html +42 -42
- data/doc/rdoc/classes/Wee/Brush/TableTag.html +7 -7
- data/doc/rdoc/classes/Wee/Brush/TextAreaTag.html +48 -15
- data/doc/rdoc/classes/Wee/Brush/TextInputTag.html +7 -7
- data/doc/rdoc/classes/Wee/CallbackRegistry.html +38 -38
- data/doc/rdoc/classes/Wee/CallbackStream.html +18 -18
- data/doc/rdoc/classes/Wee/CanvasMixin.html +225 -0
- data/doc/rdoc/classes/Wee/Component.html +202 -201
- data/doc/rdoc/classes/Wee/Component/OnAnswer.html +7 -7
- data/doc/rdoc/classes/Wee/ComponentDispatcher.html +289 -0
- data/doc/rdoc/classes/Wee/ComponentRunner.html +321 -0
- data/doc/rdoc/classes/Wee/Context.html +63 -3
- data/doc/rdoc/classes/Wee/Decoration.html +45 -45
- data/doc/rdoc/classes/Wee/Delegate.html +30 -30
- data/doc/rdoc/classes/Wee/DupReplaceSnapshotMixin.html +164 -0
- data/doc/rdoc/classes/Wee/ErrorResponse.html +16 -16
- data/doc/rdoc/classes/Wee/Examples.html +114 -0
- data/doc/rdoc/classes/Wee/Examples/Calculator.html +319 -0
- data/doc/rdoc/classes/Wee/Examples/Counter.html +289 -0
- data/doc/rdoc/classes/Wee/Examples/EditableCounter.html +210 -0
- data/doc/rdoc/classes/Wee/Examples/Window.html +346 -0
- data/doc/rdoc/classes/Wee/FastCGIAdaptor.html +227 -0
- data/doc/rdoc/classes/Wee/FormDecoration.html +6 -6
- data/doc/rdoc/classes/Wee/GenericResponse.html +7 -7
- data/doc/rdoc/classes/Wee/HtmlCanvasRenderer.html +1230 -0
- data/doc/rdoc/classes/Wee/HtmlWriter.html +40 -40
- data/doc/rdoc/classes/Wee/IdGenerator.html +148 -0
- data/doc/rdoc/classes/Wee/LiteralMethodCallback.html +27 -14
- data/doc/rdoc/classes/Wee/LoginDecoration.html +261 -0
- data/doc/rdoc/classes/Wee/Md5IdGenerator.html +14 -14
- data/doc/rdoc/classes/Wee/MessageBox.html +14 -14
- data/doc/rdoc/classes/Wee/Nitro.html +114 -0
- data/doc/rdoc/classes/Wee/Nitro/ControllerClassMixin.html +192 -0
- data/doc/rdoc/classes/Wee/Nitro/ControllerMixin.html +345 -0
- data/doc/rdoc/classes/Wee/Nitro/FormTag.html +155 -0
- data/doc/rdoc/classes/Wee/Nitro/HtmlCanvasRenderer.html +178 -0
- data/doc/rdoc/classes/Wee/Page.html +4 -0
- data/doc/rdoc/classes/Wee/PageDecoration.html +18 -18
- data/doc/rdoc/classes/Wee/PagelessApplication.html +13 -11
- data/doc/rdoc/classes/Wee/PagelessComponentDriver.html +296 -0
- data/doc/rdoc/classes/Wee/PagelessRequest.html +52 -21
- data/doc/rdoc/classes/Wee/PagelessSession.html +130 -91
- data/doc/rdoc/classes/Wee/Pager.html +534 -0
- data/doc/rdoc/classes/Wee/Presenter.html +482 -298
- data/doc/rdoc/classes/Wee/Rails.html +114 -0
- data/doc/rdoc/classes/Wee/Rails/ControllerClassMixin.html +192 -0
- data/doc/rdoc/classes/Wee/Rails/ControllerMixin.html +342 -0
- data/doc/rdoc/classes/Wee/Rails/FormTag.html +155 -0
- data/doc/rdoc/classes/Wee/Rails/HtmlCanvasRenderer.html +177 -0
- data/doc/rdoc/classes/Wee/RedirectResponse.html +7 -7
- data/doc/rdoc/classes/Wee/RefreshResponse.html +7 -7
- data/doc/rdoc/classes/Wee/Renderer.html +208 -0
- data/doc/rdoc/classes/Wee/RenderingContext.html +175 -3
- data/doc/rdoc/classes/Wee/Request.html +197 -46
- data/doc/rdoc/classes/Wee/RequestHandler.html +31 -31
- data/doc/rdoc/classes/Wee/Response.html +44 -43
- data/doc/rdoc/classes/Wee/Session.html +296 -402
- data/doc/rdoc/classes/Wee/SimpleIdGenerator.html +14 -14
- data/doc/rdoc/classes/Wee/Snapshot.html +19 -19
- data/doc/rdoc/classes/Wee/Utils.html +22 -22
- data/doc/rdoc/classes/Wee/Utils/LRUCache.html +6 -6
- data/doc/rdoc/classes/Wee/ValueHolder.html +19 -19
- data/doc/rdoc/classes/Wee/WEBrickAdaptor.html +72 -46
- data/doc/rdoc/classes/Wee/WrapperDecoration.html +6 -6
- data/doc/rdoc/created.rid +1 -1
- data/doc/rdoc/files/INSTALL.html +1 -1
- data/doc/rdoc/files/README.html +8 -12
- data/doc/rdoc/files/lib/cache/cache_rb.html +1 -1
- data/doc/rdoc/files/lib/wee/abstractsession_rb.html +108 -0
- data/doc/rdoc/files/lib/wee/adaptors/fastcgi_rb.html +108 -0
- data/doc/rdoc/files/lib/wee/adaptors/nitro_rb.html +101 -0
- data/doc/rdoc/files/lib/wee/adaptors/rails_rb.html +101 -0
- data/doc/rdoc/files/lib/wee/adaptors/webrick_rb.html +1 -1
- data/doc/rdoc/files/lib/wee/application_rb.html +1 -1
- data/doc/rdoc/files/lib/wee/components/component_dispatcher_rb.html +108 -0
- data/doc/rdoc/files/lib/wee/components/form_decoration_rb.html +1 -1
- data/doc/rdoc/files/lib/wee/components/login_decoration_rb.html +101 -0
- data/doc/rdoc/files/lib/wee/components/messagebox_rb.html +1 -1
- data/doc/rdoc/files/lib/wee/components/page_decoration_rb.html +1 -1
- data/doc/rdoc/files/lib/wee/components/pager_rb.html +101 -0
- data/doc/rdoc/files/lib/wee/components/wrapper_decoration_rb.html +1 -1
- data/doc/rdoc/files/lib/wee/components_rb.html +4 -1
- data/doc/rdoc/files/lib/wee/continuation/core/component_rb.html +1 -1
- data/doc/rdoc/files/lib/wee/continuation/session_rb.html +1 -1
- data/doc/rdoc/files/lib/wee/continuation_rb.html +1 -1
- data/doc/rdoc/files/lib/wee/core/callback_rb.html +1 -1
- data/doc/rdoc/files/lib/wee/core/component_rb.html +1 -1
- data/doc/rdoc/files/lib/wee/core/componentrunner_rb.html +110 -0
- data/doc/rdoc/files/lib/wee/core/context_rb.html +101 -0
- data/doc/rdoc/files/lib/wee/core/decoration_rb.html +1 -1
- data/doc/rdoc/files/lib/wee/core/idgen_rb.html +101 -0
- data/doc/rdoc/files/lib/wee/core/page_rb.html +101 -0
- data/doc/rdoc/files/lib/wee/core/presenter_rb.html +1 -1
- data/doc/rdoc/files/lib/wee/core/renderer_rb.html +107 -0
- data/doc/rdoc/files/lib/wee/core/snapshot_rb.html +1 -1
- data/doc/rdoc/files/lib/wee/core/valueholder_rb.html +2 -2
- data/doc/rdoc/files/lib/wee/core_ext_rb.html +101 -0
- data/doc/rdoc/files/lib/wee/core_rb.html +7 -14
- data/doc/rdoc/files/lib/wee/databases/og/application_rb.html +1 -1
- data/doc/rdoc/files/lib/wee/databases/og/old_scaffolder_rb.html +1 -1
- data/doc/rdoc/files/lib/wee/databases/og/scaffolder_rb.html +1 -1
- data/doc/rdoc/files/lib/wee/databases/og/session_rb.html +1 -1
- data/doc/rdoc/files/lib/wee/databases/og_rb.html +1 -1
- data/doc/rdoc/files/lib/wee/examples/calculator_rb.html +107 -0
- data/doc/rdoc/files/lib/wee/examples/counter_rb.html +101 -0
- data/doc/rdoc/files/lib/wee/examples/editable_counter_rb.html +114 -0
- data/doc/rdoc/files/lib/wee/examples/window_rb.html +101 -0
- data/doc/rdoc/files/lib/wee/idgen/md5_rb.html +1 -1
- data/doc/rdoc/files/lib/wee/idgen/simple_rb.html +1 -1
- data/doc/rdoc/files/lib/wee/page_rb.html +1 -1
- data/doc/rdoc/files/lib/wee/pageless/application_rb.html +8 -1
- data/doc/rdoc/files/lib/wee/pageless/request_rb.html +1 -1
- data/doc/rdoc/files/lib/wee/pageless/session_rb.html +2 -1
- data/doc/rdoc/files/lib/wee/pageless_rb.html +1 -1
- data/doc/rdoc/files/lib/wee/renderer/html/brushes_rb.html +1 -1
- data/doc/rdoc/files/lib/wee/renderer/html/canvas_rb.html +1 -1
- data/doc/rdoc/files/lib/wee/renderer/html/writer_rb.html +1 -1
- data/doc/rdoc/files/lib/wee/request_rb.html +5 -4
- data/doc/rdoc/files/lib/wee/requesthandler_rb.html +1 -1
- data/doc/rdoc/files/lib/wee/response_rb.html +2 -1
- data/doc/rdoc/files/lib/wee/session_rb.html +2 -3
- data/doc/rdoc/files/lib/wee/skeleton/og/components/main_rb.html +1 -1
- data/doc/rdoc/files/lib/wee/skeleton/og/conf/db_rb.html +2 -2
- data/doc/rdoc/files/lib/wee/skeleton/og/models/recipe_rb.html +1 -1
- data/doc/rdoc/files/lib/wee/skeleton/og/run_rb.html +1 -1
- data/doc/rdoc/files/lib/wee/skeleton/simple/components/main_rb.html +1 -1
- data/doc/rdoc/files/lib/wee/skeleton/simple/run_rb.html +1 -1
- data/doc/rdoc/files/lib/wee/snapshot_ext_rb.html +1 -1
- data/doc/rdoc/files/lib/wee/template_rb.html +1 -1
- data/doc/rdoc/files/lib/wee/utils/autoreload_rb.html +1 -1
- data/doc/rdoc/files/lib/wee/utils/cache_rb.html +1 -1
- data/doc/rdoc/files/lib/wee/utils/helper_rb.html +1 -1
- data/doc/rdoc/files/lib/wee/utils_rb.html +1 -1
- data/doc/rdoc/files/lib/wee_rb.html +5 -3
- data/doc/rdoc/fr_class_index.html +34 -2
- data/doc/rdoc/fr_file_index.html +17 -1
- data/doc/rdoc/fr_method_index.html +464 -314
- data/examples/ajax/ajax.rb +1 -1
- data/examples/demo.rb +47 -0
- data/examples/{calendar.rb → demo/calendar.rb} +89 -97
- data/examples/{example.rb → demo/example.rb} +17 -97
- data/examples/dispatcher.rb +37 -0
- data/examples/draw.rb +14 -11
- data/examples/nitro/run.rb +42 -0
- data/examples/radio.rb +44 -0
- data/examples/test.rb +3 -27
- data/lib/wee.rb +15 -3
- data/lib/wee/adaptors/nitro.rb +154 -0
- data/lib/wee/adaptors/rails.rb +154 -0
- data/lib/wee/application.rb +22 -20
- data/lib/wee/components.rb +3 -0
- data/lib/wee/components/component_dispatcher.rb +46 -0
- data/lib/wee/components/login_decoration.rb +35 -0
- data/lib/wee/components/messagebox.rb +2 -2
- data/lib/wee/components/pager.rb +102 -0
- data/lib/wee/continuation/core/component.rb +13 -12
- data/lib/wee/continuation/session.rb +11 -19
- data/lib/wee/core.rb +8 -7
- data/lib/wee/core/component.rb +8 -28
- data/lib/wee/core/componentrunner.rb +73 -0
- data/lib/wee/core/context.rb +27 -0
- data/lib/wee/core/idgen.rb +5 -0
- data/lib/wee/core/page.rb +1 -0
- data/lib/wee/core/presenter.rb +10 -126
- data/lib/wee/core/renderer.rb +23 -0
- data/lib/wee/core_ext.rb +122 -0
- data/lib/wee/databases/og/scaffolder.rb +0 -1
- data/lib/wee/examples/calculator.rb +70 -0
- data/lib/wee/examples/counter.rb +33 -0
- data/lib/wee/examples/editable_counter.rb +31 -0
- data/{examples → lib/wee/examples}/window.rb +29 -23
- data/lib/wee/idgen/md5.rb +1 -1
- data/lib/wee/idgen/simple.rb +1 -1
- data/lib/wee/pageless/session.rb +2 -3
- data/lib/wee/renderer/html/brushes.rb +142 -22
- data/lib/wee/renderer/html/canvas.rb +57 -19
- data/lib/wee/response.rb +3 -2
- data/lib/wee/session.rb +10 -54
- data/lib/wee/skeleton/og/components/main.rb +5 -1
- data/lib/wee/skeleton/og/conf/db.rb +1 -1
- data/lib/wee/snapshot_ext.rb +4 -10
- data/lib/wee/template.rb +19 -5
- data/lib/wee/utils/helper.rb +2 -2
- metadata +90 -13
- data/examples/calculator.rb +0 -67
- data/lib/wee/context.rb +0 -2
data/examples/ajax/ajax.rb
CHANGED
data/examples/demo.rb
ADDED
@@ -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
|
-
|
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
|
-
#
|
302
|
+
# Backtrack state
|
253
303
|
#
|
254
|
-
|
255
|
-
|
256
|
-
|
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
|
-
#
|
309
|
+
# Render calendar icon
|
288
310
|
#
|
289
|
-
|
290
|
-
|
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
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
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
|
-
|
353
|
-
|
343
|
+
def set_date(date)
|
344
|
+
@date = date if date
|
345
|
+
end
|
354
346
|
end
|
@@ -1,50 +1,5 @@
|
|
1
|
-
|
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|
|
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
|
-
|
200
|
-
|
201
|
-
|
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)
|
data/examples/draw.rb
CHANGED
@@ -1,14 +1,17 @@
|
|
1
1
|
$LOAD_PATH.unshift << "../lib"
|
2
2
|
require 'wee'
|
3
|
-
require 'wee/webrick'
|
4
|
-
require 'wee/utils
|
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
|
-
|
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
|
-
|
38
|
-
|
39
|
-
|
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
|
-
|
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
|