wee 2.0.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/TODO +31 -0
- data/benchmark.rb +37 -0
- data/demo.ru +11 -0
- data/doc/rdoc/classes/Array.html +22 -26
- data/doc/rdoc/classes/Hash.html +22 -26
- data/doc/rdoc/classes/Object.html +21 -26
- data/doc/rdoc/classes/String.html +19 -87
- data/doc/rdoc/classes/Struct.html +22 -26
- data/doc/rdoc/classes/Wee.html +75 -206
- data/doc/rdoc/classes/Wee/AnswerDecoration.html +35 -66
- data/doc/rdoc/classes/Wee/AnswerDecoration/Answer.html +28 -46
- data/doc/rdoc/classes/Wee/Application.html +63 -114
- data/doc/rdoc/classes/Wee/Application/SessionCache.html +30 -44
- data/doc/rdoc/classes/Wee/Brush.html +52 -101
- data/doc/rdoc/classes/Wee/Brush/ActionInputTag.html +29 -51
- data/doc/rdoc/classes/Wee/Brush/AnchorTag.html +44 -101
- data/doc/rdoc/classes/Wee/Brush/CheckboxTag.html +43 -76
- data/doc/rdoc/classes/Wee/Brush/FileUploadTag.html +29 -46
- data/doc/rdoc/classes/Wee/Brush/FormTag.html +48 -110
- data/doc/rdoc/classes/Wee/Brush/GenericEncodedTextBrush.html +30 -42
- data/doc/rdoc/classes/Wee/Brush/GenericSingleTagBrush.html +37 -58
- data/doc/rdoc/classes/Wee/Brush/GenericTagBrush.html +93 -210
- data/doc/rdoc/classes/Wee/Brush/GenericTextBrush.html +38 -63
- data/doc/rdoc/classes/Wee/Brush/HiddenInputTag.html +29 -45
- data/doc/rdoc/classes/Wee/Brush/ImageButtonTag.html +35 -52
- data/doc/rdoc/classes/Wee/Brush/ImageTag.html +28 -61
- data/doc/rdoc/classes/Wee/Brush/InputTag.html +34 -107
- data/doc/rdoc/classes/Wee/Brush/JavascriptTag.html +28 -54
- data/doc/rdoc/classes/Wee/Brush/Page.html +39 -73
- data/doc/rdoc/classes/Wee/Brush/PasswordInputTag.html +29 -45
- data/doc/rdoc/classes/Wee/Brush/RadioButtonTag.html +54 -98
- data/doc/rdoc/classes/Wee/Brush/RadioGroup.html +46 -84
- data/doc/rdoc/classes/Wee/Brush/SelectListTag.html +87 -187
- data/doc/rdoc/classes/Wee/Brush/SelectOptionTag.html +29 -56
- data/doc/rdoc/classes/Wee/Brush/SubmitButtonTag.html +29 -45
- data/doc/rdoc/classes/Wee/Brush/TableDataTag.html +28 -55
- data/doc/rdoc/classes/Wee/Brush/TableHeaderTag.html +28 -55
- data/doc/rdoc/classes/Wee/Brush/TableRowTag.html +56 -113
- data/doc/rdoc/classes/Wee/Brush/TableTag.html +27 -58
- data/doc/rdoc/classes/Wee/Brush/TextAreaTag.html +48 -140
- data/doc/rdoc/classes/Wee/Brush/TextInputTag.html +29 -45
- data/doc/rdoc/classes/Wee/CallAnswerMixin.html +51 -79
- data/doc/rdoc/classes/Wee/CallbackMixin.html +44 -77
- data/doc/rdoc/classes/Wee/CallbackRegistry.html +69 -125
- data/doc/rdoc/classes/Wee/Callbacks.html +43 -82
- data/doc/rdoc/classes/Wee/Component.html +142 -292
- data/doc/rdoc/classes/Wee/Decoration.html +85 -141
- data/doc/rdoc/classes/Wee/DecorationMixin.html +111 -118
- data/doc/rdoc/classes/Wee/Delegate.html +72 -115
- data/doc/rdoc/classes/Wee/DupReplaceSnapshotMixin.html +37 -54
- data/doc/rdoc/classes/Wee/ErrorResponse.html +31 -48
- data/doc/rdoc/classes/Wee/FormDecoration.html +32 -46
- data/doc/rdoc/classes/Wee/GenericResponse.html +30 -50
- data/doc/rdoc/classes/Wee/HtmlCanvas.html +209 -562
- data/doc/rdoc/classes/Wee/HtmlDocument.html +51 -91
- data/doc/rdoc/classes/Wee/HtmlWriter.html +76 -156
- data/doc/rdoc/classes/Wee/IdGenerator.html +28 -44
- data/doc/rdoc/classes/Wee/IdGenerator/Secure.html +53 -95
- data/doc/rdoc/classes/Wee/IdGenerator/Sequential.html +37 -63
- data/doc/rdoc/classes/Wee/JQuery.html +36 -64
- data/doc/rdoc/classes/Wee/LRUCache.html +94 -189
- data/doc/rdoc/classes/Wee/LRUCache/Item.html +30 -42
- data/doc/rdoc/classes/Wee/ObjectSnapshotMixin.html +37 -54
- data/doc/rdoc/classes/Wee/PageDecoration.html +48 -79
- data/doc/rdoc/classes/Wee/Presenter.html +86 -143
- data/doc/rdoc/classes/Wee/RedirectResponse.html +31 -49
- data/doc/rdoc/classes/Wee/RefreshResponse.html +34 -48
- data/doc/rdoc/classes/Wee/Renderer.html +56 -125
- data/doc/rdoc/classes/Wee/Request.html +57 -115
- data/doc/rdoc/classes/Wee/Response.html +24 -26
- data/doc/rdoc/classes/Wee/Session.html +137 -292
- data/doc/rdoc/classes/Wee/Session/AbortCallbackProcessing.html +29 -46
- data/doc/rdoc/classes/Wee/Session/MutexSerializer.html +29 -42
- data/doc/rdoc/classes/Wee/Session/Page.html +22 -21
- data/doc/rdoc/classes/Wee/Session/ThreadSerializer.html +36 -60
- data/doc/rdoc/classes/Wee/State.html +57 -105
- data/doc/rdoc/classes/Wee/State/Snapshot.html +22 -21
- data/doc/rdoc/classes/Wee/State/SnapshotIVars.html +22 -21
- data/doc/rdoc/classes/Wee/StructSnapshotMixin.html +37 -54
- data/doc/rdoc/classes/Wee/WrapperDecoration.html +42 -68
- data/doc/rdoc/created.rid +1 -1
- data/doc/rdoc/files/README_rdoc.html +26 -17
- data/doc/rdoc/files/lib/wee/application_rb.html +25 -19
- data/doc/rdoc/files/lib/wee/call_answer_rb.html +23 -12
- data/doc/rdoc/files/lib/wee/callback_rb.html +23 -12
- data/doc/rdoc/files/lib/wee/component_rb.html +25 -19
- data/doc/rdoc/files/lib/wee/decoration_rb.html +23 -15
- data/doc/rdoc/files/lib/wee/html_brushes_rb.html +23 -12
- data/doc/rdoc/files/lib/wee/html_canvas_rb.html +23 -15
- data/doc/rdoc/files/lib/wee/html_document_rb.html +23 -15
- data/doc/rdoc/files/lib/wee/html_writer_rb.html +23 -15
- data/doc/rdoc/files/lib/wee/id_generator_rb.html +24 -17
- data/doc/rdoc/files/lib/wee/jquery/jquery_rb.html +23 -12
- data/doc/rdoc/files/lib/wee/jquery_rb.html +23 -15
- data/doc/rdoc/files/lib/wee/lru_cache_rb.html +23 -12
- data/doc/rdoc/files/lib/wee/presenter_rb.html +23 -12
- data/doc/rdoc/files/lib/wee/renderer_rb.html +23 -12
- data/doc/rdoc/files/lib/wee/request_rb.html +23 -15
- data/doc/rdoc/files/lib/wee/response_rb.html +24 -17
- data/doc/rdoc/files/lib/wee/session_rb.html +26 -21
- data/doc/rdoc/files/lib/wee/state_rb.html +23 -12
- data/doc/rdoc/files/lib/wee_rb.html +37 -47
- data/doc/rdoc/fr_class_index.html +12 -86
- data/doc/rdoc/fr_file_index.html +12 -30
- data/doc/rdoc/fr_method_index.html +242 -473
- data/doc/rdoc/index.html +8 -5
- data/doc/rdoc/rdoc-style.css +119 -210
- data/examples/ObjectSpaceBrowser.rb +4 -4
- data/examples/TODO +21 -0
- data/examples/ajax.rb +6 -4
- data/examples/blog.rb +42 -0
- data/examples/demo.rb +5 -3
- data/examples/demo/calculator.rb +3 -3
- data/examples/demo/calendar.rb +4 -4
- data/examples/demo/counter.rb +2 -2
- data/examples/demo/editable_counter.rb +2 -2
- data/examples/demo/example.rb +25 -16
- data/examples/demo/window.rb +10 -3
- data/examples/hw2.rb +17 -0
- data/examples/recipe/description.rb +170 -0
- data/examples/recipe/migrations/001_create_recipes.rb +13 -0
- data/examples/recipe/model.rb +27 -0
- data/examples/recipe/models/recipe.rb +18 -0
- data/examples/recipe/recipe_editor.rb +28 -0
- data/lib/wee.rb +1 -7
- data/lib/wee/component.rb +37 -74
- data/lib/wee/decoration.rb +16 -15
- data/lib/wee/html_brushes.rb +16 -17
- data/lib/wee/presenter.rb +2 -1
- data/lib/wee/response.rb +4 -4
- data/lib/wee/session.rb +2 -2
- data/lib/wee/state.rb +2 -2
- data/test/t.rb +67 -0
- data/wee.gemspec +1 -1
- metadata +157 -167
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'sequel'
|
3
|
+
$LOAD_PATH.unshift "../../lib"
|
4
|
+
require 'wee'
|
5
|
+
|
6
|
+
DB = Sequel.postgres :database => 'cookbook', :user => 'mneumann',
|
7
|
+
:password => '', :host => '/var/run/postgresql'
|
8
|
+
|
9
|
+
require 'models/recipe'
|
10
|
+
require 'recipe_editor'
|
11
|
+
|
12
|
+
Sequel::Migrator.apply(DB, 'migrations')
|
13
|
+
|
14
|
+
class MainPage < Wee::Component
|
15
|
+
def initialize
|
16
|
+
super()
|
17
|
+
@child = add_child RecipeEditor.new(Recipe.new)
|
18
|
+
end
|
19
|
+
|
20
|
+
def render(r)
|
21
|
+
r.page.title('Recipes').with {
|
22
|
+
r.render @child
|
23
|
+
}
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
Wee.run(MainPage)
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class Recipe < Sequel::Model(:recipes)
|
2
|
+
|
3
|
+
describe :title, String
|
4
|
+
describe :instructions, String
|
5
|
+
|
6
|
+
=begin
|
7
|
+
def self.describe_title
|
8
|
+
StringDescription.new(SymbolAccessor.new(:title, :title=))
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.describe_instructions
|
12
|
+
StringDescription.new
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.describe_self
|
16
|
+
end
|
17
|
+
=end
|
18
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
class RecipeEditor < Wee::Component
|
2
|
+
def initialize(instance)
|
3
|
+
super()
|
4
|
+
@instance = instance
|
5
|
+
end
|
6
|
+
|
7
|
+
def render(r)
|
8
|
+
if @instance.new?
|
9
|
+
r.h1("New #{@instance.class}")
|
10
|
+
else
|
11
|
+
r.h1("Edit #{@instance.class}")
|
12
|
+
end
|
13
|
+
|
14
|
+
r.form do
|
15
|
+
r.text "Title"
|
16
|
+
r.break
|
17
|
+
r.text_input.value(@instance.title || '').callback{|v| @instance.title = v}
|
18
|
+
r.paragraph
|
19
|
+
|
20
|
+
r.text "Instructions"
|
21
|
+
r.break
|
22
|
+
r.text_area.callback{|v| @instance.instructions = v}.with(@instance.instructions || '')
|
23
|
+
r.paragraph
|
24
|
+
|
25
|
+
r.submit_button.value(@instance.new? ? 'Create' : 'Update').callback { @instance.save }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/lib/wee.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
module Wee
|
2
|
-
Version = "2.
|
2
|
+
Version = "2.1.0"
|
3
3
|
end
|
4
4
|
|
5
5
|
require 'rack'
|
@@ -25,12 +25,6 @@ if RUBY_VERSION >= "1.9"
|
|
25
25
|
require 'continuation'
|
26
26
|
rescue LoadError
|
27
27
|
end
|
28
|
-
unless String.instance_methods.include?(:each)
|
29
|
-
# required by Rack
|
30
|
-
class String
|
31
|
-
def each() yield self end
|
32
|
-
end
|
33
|
-
end
|
34
28
|
end
|
35
29
|
|
36
30
|
Wee::DefaultRenderer = Wee::HtmlCanvas
|
data/lib/wee/component.rb
CHANGED
@@ -13,12 +13,7 @@ module Wee
|
|
13
13
|
#
|
14
14
|
# Initializes a newly created component.
|
15
15
|
#
|
16
|
-
|
17
|
-
# +super+, before setting up anything else!
|
18
|
-
#
|
19
|
-
def initialize() # :notnew:
|
20
|
-
@decoration = self
|
21
|
-
@children = nil
|
16
|
+
def initialize
|
22
17
|
end
|
23
18
|
|
24
19
|
#
|
@@ -33,26 +28,6 @@ module Wee
|
|
33
28
|
def render(r)
|
34
29
|
end
|
35
30
|
|
36
|
-
#
|
37
|
-
# Process and invoke all callbacks specified for this component and all of
|
38
|
-
# it's child components.
|
39
|
-
#
|
40
|
-
def process_callbacks(callbacks)
|
41
|
-
callbacks.input_callbacks.each_triggered(self) do |callback, value|
|
42
|
-
callback.call(value)
|
43
|
-
end
|
44
|
-
|
45
|
-
# process callbacks of all children
|
46
|
-
each_child do |child|
|
47
|
-
child.decoration.process_callbacks(callbacks)
|
48
|
-
end
|
49
|
-
|
50
|
-
callbacks.action_callbacks.each_triggered(self) do |callback, value|
|
51
|
-
callback.call
|
52
|
-
session.send_response(nil) # prematurely end callback processing
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
31
|
#
|
57
32
|
# Take snapshots of objects that should correctly be backtracked.
|
58
33
|
#
|
@@ -65,72 +40,60 @@ module Wee
|
|
65
40
|
# <i>marshal_load</i>). Overwrite them if you want to define special
|
66
41
|
# behaviour.
|
67
42
|
#
|
68
|
-
# For example if you dynamically add children to your component, you might
|
69
|
-
# want to backtrack the children array:
|
70
|
-
#
|
71
|
-
# def backtrack(state)
|
72
|
-
# super
|
73
|
-
# backtrack_children(state)
|
74
|
-
# end
|
75
|
-
#
|
76
43
|
# By default only the decoration chain is backtracked. This is
|
77
44
|
# required to correctly backtrack called components. To disable
|
78
45
|
# backtracking of the decorations, change method
|
79
|
-
# Component#
|
46
|
+
# Component#state_decoration to a no-operation:
|
80
47
|
#
|
81
|
-
# def
|
48
|
+
# def state_decoration(s)
|
82
49
|
# # nothing here
|
83
50
|
# end
|
84
51
|
#
|
85
|
-
# [+
|
52
|
+
# [+s+]
|
86
53
|
# An object of class State
|
87
54
|
#
|
88
|
-
def
|
89
|
-
|
90
|
-
|
91
|
-
child.decoration.
|
55
|
+
def state(s)
|
56
|
+
state_decoration(s)
|
57
|
+
for child in self.children
|
58
|
+
child.decoration.state(s)
|
92
59
|
end
|
93
60
|
end
|
94
61
|
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
state.add_ivar(self, :@decoration, @decoration)
|
99
|
-
end
|
100
|
-
|
101
|
-
def backtrack_children(state)
|
102
|
-
state.add_ivar(self, :@children, (@children and @children.dup))
|
103
|
-
end
|
104
|
-
|
62
|
+
NO_CHILDREN = [].freeze
|
63
|
+
#
|
64
|
+
# Return all child components.
|
105
65
|
#
|
106
|
-
#
|
66
|
+
# *OVERWRITE* this method and return all child components
|
67
|
+
# collected in an array.
|
107
68
|
#
|
108
|
-
def
|
109
|
-
|
69
|
+
def children
|
70
|
+
return NO_CHILDREN
|
110
71
|
end
|
111
72
|
|
112
73
|
#
|
113
|
-
#
|
114
|
-
#
|
115
|
-
# class YourComponent < Wee::Component
|
116
|
-
# def initialize
|
117
|
-
# super()
|
118
|
-
# add_child ChildComponent.new
|
119
|
-
# end
|
120
|
-
# end
|
121
|
-
#
|
122
|
-
# If you dynamically add child components to a component at run-time (not in
|
123
|
-
# initialize), then you should consider to backtrack the children array (of
|
124
|
-
# course only if you want backtracking at all):
|
125
|
-
#
|
126
|
-
# def backtrack(state)
|
127
|
-
# super
|
128
|
-
# state.add(self.children)
|
129
|
-
# end
|
74
|
+
# Process and invoke all callbacks specified for this component and all of
|
75
|
+
# it's child components.
|
130
76
|
#
|
131
|
-
def
|
132
|
-
(
|
133
|
-
|
77
|
+
def process_callbacks(callbacks)
|
78
|
+
callbacks.input_callbacks.each_triggered(self) do |callback, value|
|
79
|
+
callback.call(value)
|
80
|
+
end
|
81
|
+
|
82
|
+
# process callbacks of all children
|
83
|
+
for child in self.children
|
84
|
+
child.decoration.process_callbacks(callbacks)
|
85
|
+
end
|
86
|
+
|
87
|
+
callbacks.action_callbacks.each_triggered(self) do |callback, value|
|
88
|
+
callback.call
|
89
|
+
session.send_response(nil) # prematurely end callback processing
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
protected
|
94
|
+
|
95
|
+
def state_decoration(s)
|
96
|
+
s.add_ivar(self, :@decoration, @decoration)
|
134
97
|
end
|
135
98
|
|
136
99
|
include Wee::DecorationMixin
|
data/lib/wee/decoration.rb
CHANGED
@@ -4,7 +4,7 @@ module Wee
|
|
4
4
|
|
5
5
|
#
|
6
6
|
# Abstract base class of all decorations. Forwards the methods
|
7
|
-
# #process_callbacks, #render_on and #
|
7
|
+
# #process_callbacks, #render_on and #state to the next decoration in
|
8
8
|
# the chain. Subclasses should provide special behaviour in these methods,
|
9
9
|
# otherwise the decoration does not make sense.
|
10
10
|
#
|
@@ -62,16 +62,17 @@ module Wee
|
|
62
62
|
# answer-decoration has the advantage to be able to call a component more
|
63
63
|
# than once!
|
64
64
|
#
|
65
|
-
def
|
66
|
-
@next.
|
67
|
-
|
65
|
+
def state(s)
|
66
|
+
@next.state(s)
|
67
|
+
s.add_ivar(self, :@next, @next)
|
68
68
|
end
|
69
69
|
|
70
70
|
end # class Decoration
|
71
71
|
|
72
72
|
module DecorationMixin
|
73
73
|
|
74
|
-
|
74
|
+
def decoration=(d) @decoration = d end
|
75
|
+
def decoration() @decoration || self end
|
75
76
|
|
76
77
|
#
|
77
78
|
# Iterates over all decorations (note that the component itself is excluded).
|
@@ -95,8 +96,8 @@ module Wee
|
|
95
96
|
#
|
96
97
|
def add_decoration(d)
|
97
98
|
if d.global?
|
98
|
-
d.next =
|
99
|
-
|
99
|
+
d.next = self.decoration
|
100
|
+
self.decoration = d
|
100
101
|
else
|
101
102
|
last_global = nil
|
102
103
|
each_decoration {|i|
|
@@ -108,8 +109,8 @@ module Wee
|
|
108
109
|
}
|
109
110
|
if last_global.nil?
|
110
111
|
# no global decorations specified -> add in front
|
111
|
-
d.next =
|
112
|
-
|
112
|
+
d.next = self.decoration
|
113
|
+
self.decoration = d
|
113
114
|
else
|
114
115
|
# add after last_global
|
115
116
|
d.next = last_global.next
|
@@ -127,10 +128,10 @@ module Wee
|
|
127
128
|
# decoration chain.
|
128
129
|
#
|
129
130
|
def remove_decoration(d)
|
130
|
-
if d ==
|
131
|
-
|
131
|
+
if d == self.decoration # 'd' is in front
|
132
|
+
self.decoration = d.next
|
132
133
|
else
|
133
|
-
last_decoration =
|
134
|
+
last_decoration = self.decoration
|
134
135
|
next_decoration = nil
|
135
136
|
loop do
|
136
137
|
return nil if last_decoration == self or last_decoration.nil?
|
@@ -161,7 +162,7 @@ module Wee
|
|
161
162
|
|
162
163
|
#
|
163
164
|
# A Wee::Delegate breaks the decoration chain and forwards the methods
|
164
|
-
# #process_callbacks, #render_on and #
|
165
|
+
# #process_callbacks, #render_on and #state to the corresponding *chain*
|
165
166
|
# method of it's _delegate_ component (a Wee::Component).
|
166
167
|
#
|
167
168
|
class Delegate < Decoration
|
@@ -191,9 +192,9 @@ module Wee
|
|
191
192
|
# _delegate_ component. We also take snapshots of all non-visible
|
192
193
|
# components, thus we follow the @next decoration (via super).
|
193
194
|
#
|
194
|
-
def
|
195
|
+
def state(s)
|
195
196
|
super
|
196
|
-
@delegate.decoration.
|
197
|
+
@delegate.decoration.state(s)
|
197
198
|
end
|
198
199
|
|
199
200
|
end # class Delegate
|
data/lib/wee/html_brushes.rb
CHANGED
@@ -554,27 +554,26 @@ module Wee
|
|
554
554
|
# A callback was specified. We have to wrap it inside another
|
555
555
|
# callback, as we want to perform some additional actions.
|
556
556
|
#
|
557
|
-
name(@canvas.register_callback(:input,
|
558
|
-
input = [input] unless input.kind_of?(Array)
|
559
|
-
choosen = input.map {|idx| get_item(idx) }
|
560
|
-
|
561
|
-
if @attributes.has_key?(:multiple)
|
562
|
-
@callback.call(choosen)
|
563
|
-
elsif choosen.size > 1
|
564
|
-
raise "more than one element was choosen from a not-multiple SelectListTag"
|
565
|
-
else
|
566
|
-
@callback.call(choosen.first)
|
567
|
-
end
|
568
|
-
}))
|
557
|
+
name(@canvas.register_callback(:input, method(:handler)) + "[]")
|
569
558
|
end
|
570
559
|
|
571
|
-
def
|
572
|
-
|
573
|
-
|
574
|
-
|
560
|
+
def handler(input)
|
561
|
+
choosen = input.map {|idx|
|
562
|
+
idx = Integer(idx)
|
563
|
+
raise IndexError if idx < 0 or idx > @items.size
|
564
|
+
@items[idx]
|
565
|
+
}
|
566
|
+
|
567
|
+
if @attributes.has_key?(:multiple)
|
568
|
+
@callback.call(choosen)
|
569
|
+
elsif choosen.size > 1
|
570
|
+
raise "more than one element was choosen from a not-multiple SelectListTag"
|
571
|
+
else
|
572
|
+
@callback.call(choosen.first)
|
573
|
+
end
|
575
574
|
end
|
576
575
|
|
577
|
-
protected :
|
576
|
+
protected :handler
|
578
577
|
|
579
578
|
def with
|
580
579
|
@labels ||= @items.collect {|i| i.to_s}
|
data/lib/wee/presenter.rb
CHANGED
data/lib/wee/response.rb
CHANGED
@@ -17,7 +17,7 @@ module Wee
|
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
-
class RedirectResponse <
|
20
|
+
class RedirectResponse < Response
|
21
21
|
LOCATION_HEADER = 'Location'.freeze
|
22
22
|
|
23
23
|
def initialize(location)
|
@@ -27,9 +27,9 @@ module Wee
|
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
-
class RefreshResponse <
|
30
|
+
class RefreshResponse < Response
|
31
31
|
def initialize(message, location, seconds=5)
|
32
|
-
super(%[<html>
|
32
|
+
super([%[<html>
|
33
33
|
<head>
|
34
34
|
<meta http-equiv="REFRESH" content="#{seconds};URL=#{location}">
|
35
35
|
<title>#{message}</title>
|
@@ -39,7 +39,7 @@ module Wee
|
|
39
39
|
You are being redirected to <a href="#{location}">#{location}</a>
|
40
40
|
in #{seconds} seconds.
|
41
41
|
</body>
|
42
|
-
</html>])
|
42
|
+
</html>]])
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
data/lib/wee/session.rb
CHANGED
@@ -332,8 +332,8 @@ module Wee
|
|
332
332
|
# and returns it.
|
333
333
|
#
|
334
334
|
def take_snapshot
|
335
|
-
@root_component.decoration.
|
336
|
-
return
|
335
|
+
@root_component.decoration.state(s = Wee::State.new)
|
336
|
+
return s.freeze
|
337
337
|
end
|
338
338
|
|
339
339
|
end # class Session
|
data/lib/wee/state.rb
CHANGED
@@ -4,9 +4,9 @@ module Wee
|
|
4
4
|
# This class is for backtracking the state of components (or
|
5
5
|
# decorations/presenters). Components that want an undo-facility to be
|
6
6
|
# implemented (triggered for example by a browsers back-button), have to
|
7
|
-
# overwrite the Component#
|
7
|
+
# overwrite the Component#state method. Class Wee::State simply
|
8
8
|
# represents a collection of objects from which snapshots were taken via
|
9
|
-
# methods take_snapshot.
|
9
|
+
# methods take_snapshot.
|
10
10
|
#
|
11
11
|
class State
|
12
12
|
class Snapshot < Struct.new(:object, :snapshot); end
|