• R/O
  • SSH
  • HTTPS

tenarai: 提交


Commit MetaInfo

修訂121 (tree)
時間2008-10-18 17:10:04
作者junkikuchi

Log Message

updated.

Change Summary

差異

--- trunk/test/test_tree.rb (revision 120)
+++ trunk/test/test_tree.rb (revision 121)
@@ -115,110 +115,3 @@
115115 assert(@a3.empty?)
116116 end
117117 end
118-
119-class HashTreeTest < ArrayTreeTest
120- def setup
121- @tree = Tenarai::HashTree.new('root')
122-
123- @a = @tree << Tenarai::HashTree.new('a')
124- @b = @tree << Tenarai::HashTree.new('b')
125- @c = @tree << Tenarai::HashTree.new('c')
126-
127- @a1 = @a << Tenarai::HashTree.new('a1')
128- @a2 = @a << Tenarai::HashTree.new('a2')
129- @a3 = @a << Tenarai::HashTree.new('a3')
130- end
131-
132- def test_name_error
133- assert_raise(Tenarai::HashTree::NameError) do
134- @tree << Tenarai::HashTree.new('a.a')
135- end
136- end
137-
138- def test_duplicate_name_error
139- assert_raise(Tenarai::HashTree::DuplicateNameError) do
140- @tree << Tenarai::HashTree.new('a')
141- end
142- end
143-
144- def test_map
145- assert_equal([@a, @b, @c], @tree.map)
146-
147- assert_equal([@a1, @a2, @a3], @a.map)
148- assert_equal([], @b.map)
149- assert_equal([], @c.map)
150-
151- assert_equal([], @a1.map)
152- assert_equal([], @a2.map)
153- assert_equal([], @a3.map)
154- end
155-
156- def test_fetch
157- assert_equal(@a, @tree.fetch('a'))
158- assert_equal(@b, @tree.fetch('b'))
159- assert_equal(@c, @tree.fetch('c'))
160-
161- assert_equal(@a1, @a.fetch('a1'))
162- assert_equal(@a2, @a.fetch('a2'))
163- assert_equal(@a3, @a.fetch('a3'))
164-
165- assert_raise(Tenarai::HashTree::KeyError) do
166- @tree.fetch('d')
167- end
168-
169- assert_equal(@a, @tree['a'])
170- assert_equal(@b, @tree['b'])
171- assert_equal(@c, @tree['c'])
172-
173- assert_nil(@tree['d'])
174-
175- assert_equal(@a1, @a['a1'])
176- assert_equal(@a2, @a['a2'])
177- assert_equal(@a3, @a['a3'])
178- end
179-
180- def test_key?
181- assert(@tree.key?('a'))
182- assert(@tree.key?('b'))
183- assert(@tree.key?('c'))
184-
185- assert(!@tree.key?('root'))
186- assert(!@tree.key?('a1'))
187- assert(!@tree.key?('a2'))
188- assert(!@tree.key?('a3'))
189-
190- assert(@a.key?('a1'))
191- assert(@a.key?('a2'))
192- assert(@a.key?('a3'))
193- end
194-
195- def test_path_name
196- assert_equal('root', @tree.path_name)
197-
198- assert_equal('root.a', @a.path_name)
199- assert_equal('root.b', @b.path_name)
200- assert_equal('root.c', @c.path_name)
201-
202- assert_equal('root.a.a1', @a1.path_name)
203- assert_equal('root.a.a2', @a2.path_name)
204- assert_equal('root.a.a3', @a3.path_name)
205- end
206-
207- def test_find
208- assert_equal(@tree, @tree.find('root'))
209-
210- assert_equal(@a, @tree.find('root.a'))
211- assert_equal(@b, @tree.find('root.b'))
212- assert_equal(@c, @tree.find('root.c'))
213-
214- assert_equal(@a1, @tree.find('root.a.a1'))
215- assert_equal(@a2, @tree.find('root.a.a2'))
216- assert_equal(@a3, @tree.find('root.a.a3'))
217-
218- assert_raise(Tenarai::HashTree::KeyError) do
219- @tree.find('ROOT')
220- @tree.find('root.d')
221- @tree.find('root.a.a4')
222- end
223- end
224-end
--- trunk/init_model.rb (revision 120)
+++ trunk/init_model.rb (revision 121)
@@ -2,21 +2,9 @@
22 CONFIG[:init_model] = {
33 'service' => [
44 {
5- :name => 'index',
6- :class => 'Service',
7- :row => {'name' => 'index'},
8- :relation => {'default_view' => 'view:user.login'},
9- },
10- {
115 :name => 'admin',
126 :class => 'Service',
137 :row => {'name' => 'admin'},
14- :relation => {'default_view' => 'view:admin.login'},
15- },
16- {
17- :name => 'preview',
18- :class => 'Service',
19- :row => {'name' => 'preview'},
208 :relation => {'default_view' => 'view:admin'},
219 },
2210 ],
@@ -26,42 +14,8 @@
2614 :name => 'admin',
2715 :class => 'View',
2816 :row => {'name' => 'admin'},
29- :relation => {'resource' => 'widget:admin.session.user'},
30- },
31- {
32- :name => 'admin.login',
33- :class => 'View',
34- :row => {'name' => 'login'},
35- },
36- {
37- :name => 'admin.content',
38- :class => 'View',
39- :row => {'name' => 'content'},
40- :relation => {'resource' => 'widget:admin.session.user.doc.bd.view.widget'},
41- },
42- {
43- :name => 'admin.preview',
44- :class => 'View',
45- :row => {'name' => 'preview'},
4617 :relation => {'resource' => 'widget:admin'},
4718 },
48-
49- {
50- :name => 'user',
51- :class => 'View',
52- :row => {'name' => 'user'},
53- :relation => {'resource' => 'widget:user.session.user'},
54- },
55- {
56- :name => 'user.login',
57- :class => 'View',
58- :row => {'name' => 'login'},
59- },
60- {
61- :name => 'user.content',
62- :class => 'View',
63- :row => {'name' => 'content'},
64- },
6519 ],
6620
6721 'widget' => [
@@ -69,204 +23,140 @@
6923 :name => 'admin',
7024 :class => 'Widget::HTML',
7125 :relation => {'view' => 'view:admin'},
72- :css => {
73- 'li ul_margin_margin-left' => '15px',
74- }
7526 },
7627 {
77- :name => 'admin.session',
78- :class => 'Widget::Session',
28+ :name => 'admin.yui',
29+ :class => 'Widget::YUI',
7930 :relation => {'view' => 'view:admin'},
80- :property => {
81- :table_name => 'adminsession'
82- },
8331 },
8432 {
85- :name => 'admin.session.user',
86- :class => 'Widget::User',
33+ :name => 'admin.yui.reset_css',
34+ :class => 'Widget::YUI::ResetCSS',
8735 :relation => {'view' => 'view:admin'},
88- :property => {
89- :table_name => 'admin',
90- :login_view => :'view:admin.content',
91- :logout_view => :'view:admin.login',
92- },
9336 },
9437 {
95- :name => 'admin.session.user.reset',
96- :class => 'Widget::HTML::CSS',
38+ :name => 'admin.yui.layout',
39+ :class => 'Widget::YUI::Layout',
9740 :relation => {'view' => 'view:admin'},
41+ :css => [
42+ ['.yui-layout-unit-top_background_background-color', '#c3d9ff'],
43+ ['.yui-layout-unit-right_background_background-color', '#e1ecfe'],
44+ ['.yui-layout-unit-bottom_background_background-color', '#c3d9ff'],
45+ ['.yui-layout-unit-left_background_background-color', '#e1ecfe'],
46+ ['.yui-layout-unit .yui-resize-handle-r .yui-layout-resize-knob_background_background-color', '#c3d9ff'],
47+ ['.yui-layout-unit .yui-resize-handle-r .yui-layout-resize-knob_layout_position', 'absolute'],
48+ ['.yui-layout-unit .yui-resize-handle-r .yui-layout-resize-knob_size_height', '100%'],
49+ ['.yui-layout-unit .yui-resize-handle-r .yui-layout-resize-knob_size_width', '5px'],
50+ ['.yui-layout-unit .yui-resize-handle-r .yui-layout-resize-knob_layout_top', '0px'],
51+ ['.yui-layout-unit .yui-resize-handle-r .yui-layout-resize-knob_layout_left', '0px'],
52+ ['.yui-layout-unit .yui-resize-handle-l .yui-layout-resize-knob_background_background-color', '#c3d9ff'],
53+ ['.yui-layout-unit .yui-resize-handle-l .yui-layout-resize-knob_layout_position', 'absolute'],
54+ ['.yui-layout-unit .yui-resize-handle-l .yui-layout-resize-knob_size_height', '100%'],
55+ ['.yui-layout-unit .yui-resize-handle-l .yui-layout-resize-knob_size_width', '5px'],
56+ ['.yui-layout-unit .yui-resize-handle-l .yui-layout-resize-knob_layout_top', '0px'],
57+ ['.yui-layout-unit .yui-resize-handle-l .yui-layout-resize-knob_layout_left', '0px'],
58+ ],
9859 :property => {
99- :src => '/yui/build/reset-fonts-grids/reset-fonts-grids.css'
100- },
60+ :top_body => "'hd'",
61+ :top_height => '100',
62+
63+ :right_body => "'property'",
64+ :right_width => '200',
65+ :right_resize => 'true',
66+
67+ :bottom_body => "'ft'",
68+ :bottom_height => '50',
69+
70+ :left_body => "'selecter'",
71+ :left_width => '200',
72+ :left_resize => 'true',
73+
74+ :center_body => "'preview'"
75+ }
10176 },
10277 {
103- :name => 'admin.session.user.jquery',
104- :class => 'Widget::HTML::JavaScript',
105- :relation => {'view' => 'view:admin'},
106- :property => {
107- :src => '/jquery.js'
108- },
109- },
110- {
111- :name => 'admin.session.user.jquery-ui',
112- :class => 'Widget::HTML::JavaScript',
113- :relation => {'view' => 'view:admin'},
114- :property => {
115- :src => '/jquery-ui.js'
116- },
117- },
118- {
119- :name => 'admin.session.user.doc',
78+ :name => 'admin.doc',
12079 :class => 'Widget::Panel',
12180 :relation => {'view' => 'view:admin'},
12281 :property => {
123- :html_attr_id => 'doc3',
124- :html_attr_class => 'yui-t3'
125- },
82+ :html_attr_id => 'doc3'
83+ }
12684 },
12785 {
128- :name => 'admin.session.user.doc.hd',
86+ :name => 'admin.doc.hd',
12987 :class => 'Widget::Panel',
13088 :relation => {'view' => 'view:admin'},
13189 :property => {
13290 :html_attr_id => 'hd'
133- },
91+ }
13492 },
13593 {
136- :name => 'admin.session.user.doc.bd',
94+ :name => 'admin.doc.bd',
13795 :class => 'Widget::Panel',
13896 :relation => {'view' => 'view:admin'},
13997 :property => {
14098 :html_attr_id => 'bd'
141- },
99+ }
142100 },
143101 {
144- :name => 'admin.session.user.doc.ft',
102+ :name => 'admin.doc.bd.yui-main',
145103 :class => 'Widget::Panel',
146104 :relation => {'view' => 'view:admin'},
147105 :property => {
148- :html_attr_id => 'ft'
149- },
150- },
151-
152- {
153- :name => 'admin.session.user.doc.bd.login',
154- :class => 'Widget::User::Login',
155- :relation => {'view' => 'view:admin.login'},
156- },
157-
158- {
159- :name => 'admin.session.user.doc.bd.view',
160- :class => 'Widget::View',
161- :relation => {'view' => 'view:admin.content'},
162- },
163- {
164- :name => 'admin.session.user.doc.bd.view.widget',
165- :class => 'Widget::Widget',
166- :relation => {'view' => 'view:admin.content'},
167- },
168-
169- {
170- :name => 'admin.session.user.doc.bd.view.widget.yui-main',
171- :class => 'Widget::Panel',
172- :relation => {'view' => 'view:admin.content'},
173- :property => {
174106 :html_attr_id => 'yui-main'
175- },
107+ }
176108 },
177109 {
178- :name => 'admin.session.user.doc.bd.view.widget.yui-main.yui-b',
110+ :name => 'admin.doc.bd.yui-main.yui-b',
179111 :class => 'Widget::Panel',
180- :relation => {'view' => 'view:admin.content'},
112+ :relation => {'view' => 'view:admin'},
181113 :property => {
182114 :html_attr_class => 'yui-b'
183- },
115+ }
184116 },
185117 {
186- :name => 'admin.session.user.doc.bd.view.widget.yui-b',
118+ :name => 'admin.doc.bd.yui-main.yui-b.yui-gb',
187119 :class => 'Widget::Panel',
188- :relation => {'view' => 'view:admin.content'},
120+ :relation => {'view' => 'view:admin'},
189121 :property => {
190- :html_attr_class => 'yui-b'
191- },
192- },
193- {
194- :name => 'admin.session.user.doc.hd.logout',
195- :class => 'Widget::User::Logout',
196- :relation => {'view' => 'view:admin.content'},
197- },
198- {
199- :name => 'admin.session.user.doc.bd.view.widget.yui-b.view-tree',
200- :class => 'Widget::View::Tree',
201- :relation => {'view' => 'view:admin.content'},
202- :css => {
203- 'a.selected_background_background-color'=> 'silver',
122+ :html_attr_class => 'yui-gb'
204123 }
205124 },
206125 {
207- :name => 'admin.session.user.doc.bd.view.widget.yui-b.widget-tree',
208- :class => 'Widget::Widget::Tree',
209- :relation => {'view' => 'view:admin.content'},
210- :css => {
211- 'a.selected_background_background-color'=> 'silver',
126+ :name => 'admin.doc.bd.yui-main.yui-b.yui-gb.selecter',
127+ :class => 'Widget::Panel',
128+ :relation => {'view' => 'view:admin'},
129+ :property => {
130+ :html_attr_id => 'selecter',
131+ :html_attr_class => 'yui-u first'
212132 }
213133 },
214134 {
215- :name => 'admin.session.user.doc.bd.view.widget.yui-b.widget-property',
216- :class => 'Widget::Widget::Property',
217- :relation => {'view' => 'view:admin.content'},
218- },
219- {
220- :name => 'admin.session.user.doc.bd.view.widget.yui-b.widget-css',
221- :class => 'Widget::Widget::CSS',
222- :relation => {'view' => 'view:admin.content'},
223- },
224-
225- {
226- :name => 'admin.session.user.doc.bd.view.widget.yui-main.yui-b.preview',
227- :class => 'Widget::Widget::Preview',
228- :relation => {'view' => 'view:admin.content'},
135+ :name => 'admin.doc.bd.yui-main.yui-b.yui-gb.preview',
136+ :class => 'Widget::Panel',
137+ :relation => {'view' => 'view:admin'},
229138 :property => {
230- :preview_service => 'preview'
231- },
232- :css => {
233- '_size_width' => '100%',
234- '_size_height' => '500px',
139+ :html_attr_id => 'preview',
140+ :html_attr_class => 'yui-u'
235141 }
236142 },
237-
238143 {
239- :name => 'user',
240- :class => 'Widget::HTML',
241- :relation => {'view' => 'view:user'},
242- },
243- {
244- :name => 'user.session',
245- :class => 'Widget::Session',
246- :relation => {'view' => 'view:user'},
144+ :name => 'admin.doc.bd.yui-main.yui-b.yui-gb.property',
145+ :class => 'Widget::Panel',
146+ :relation => {'view' => 'view:admin'},
247147 :property => {
248- :table_name => 'usersession'
249- },
148+ :html_attr_id => 'property',
149+ :html_attr_class => 'yui-u'
150+ }
250151 },
251152 {
252- :name => 'user.session.user',
253- :class => 'Widget::User',
254- :relation => {'view' => 'view:user'},
153+ :name => 'admin.doc.ft',
154+ :class => 'Widget::Panel',
155+ :relation => {'view' => 'view:admin'},
255156 :property => {
256- :login_view => :'view:user.content',
257- :logout_view => :'view:user.login',
258- },
157+ :html_attr_id => 'ft'
158+ }
259159 },
260- {
261- :name => 'user.session.user.login',
262- :class => 'Widget::User::Login',
263- :relation => {'view' => 'view:user.login'},
264- },
265- {
266- :name => 'user.session.user.logout',
267- :class => 'Widget::User::Logout',
268- :relation => {'view' => 'view:user.content'},
269- },
270160 ],
271161
272162 'content' => [
@@ -284,33 +174,5 @@
284174 },
285175 ],
286176
287- 'user' => [
288- {
289- :name => 'user1',
290- :class => 'User',
291- :row => {
292- 'name' => 'user1',
293- '_password' => Tenarai::ClassLoader['User'].digest('user1!')
294- },
295- :relation => {},
296- },
297- {
298- :name => 'user2',
299- :class => 'User',
300- :row => {
301- 'name' => 'user2',
302- '_password' => Tenarai::ClassLoader['User'].digest('user2!')
303- },
304- :relation => {},
305- },
306- {
307- :name => 'user3',
308- :class => 'User',
309- :row => {
310- 'name' => 'user3',
311- '_password' => Tenarai::ClassLoader['User'].digest('user3!')
312- },
313- :relation => {},
314- },
315- ],
177+ 'user' => [],
316178 }
--- trunk/lib/tenarai/tree.rb (revision 120)
+++ trunk/lib/tenarai/tree.rb (revision 121)
@@ -57,63 +57,4 @@
5757 @list.empty?
5858 end
5959 end
60-
61- class HashTree < ArrayTree
62- PATH_SEPARATOR = '.'
63-
64- class KeyError < StandardError; end
65- class NameError < StandardError; end
66- class DuplicateNameError < StandardError; end
67-
68- attr_reader :name
69-
70- def initialize(name)
71- if name.include?(PATH_SEPARATOR)
72- raise(NameError, "`%s' can not use name." % PATH_SEPARATOR)
73- end
74-
75- super()
76- @hash = {}
77- @name = name
78- end
79-
80- def <<(tree)
81- if @hash.key? tree.name
82- raise(DuplicateNameError, "`%s' is already registered." % tree.name)
83- end
84-
85- @hash[tree.name] = tree
86- super
87- end
88-
89- def fetch(key)
90- begin
91- @hash.fetch(key)
92- rescue
93- raise KeyError
94- end
95- end
96-
97- def [](key)
98- @hash[key]
99- end
100-
101- def key?(key)
102- @hash.key?(key)
103- end
104-
105- def path_name
106- path do |node|
107- node.name
108- end.join(PATH_SEPARATOR)
109- end
110-
111- def find(path_name)
112- list = path_name.split(PATH_SEPARATOR)
113-
114- list.inject(self) do |tree, key|
115- tree.fetch(key)
116- end if @name == list.shift
117- end
118- end
11960 end
--- trunk/lib/tenarai/container.rb (revision 120)
+++ trunk/lib/tenarai/container.rb (revision 121)
@@ -2,8 +2,12 @@
22 # Copyright (C) 2007, 2008 Jun Kikuchi <kikuchi@bonnou.com>
33 #
44
5+require 'enumerator'
6+
57 module Tenarai
6- class Container < ::Array
8+ class Container
9+ include Enumerable
10+
711 class KeyError < StandardError; end
812 class DuplexNameError < StandardError; end
913
@@ -17,11 +21,8 @@
1721 end
1822 end
1923
20- attr_accessor :klass
21-
22- def initialize(klass=Tenarai::Container::Value)
23- super()
24- @klass = klass
24+ def initialize
25+ @container = []
2526 end
2627
2728 def <<(val)
@@ -28,53 +29,33 @@
2829 if key?(val.name)
2930 raise DuplexNameError, '`%s` is already registered' % val.name
3031 end
31- super([val.name, val])
32+ @container << [val.name, val]
3233 val
3334 end
3435
3536 def fetch(key)
36- k, val = assoc(key)
37+ k, val = @container.assoc(key)
3738 raise KeyError if val.nil?
3839 val
3940 end
4041
4142 def [](key)
42- k, val = assoc(key)
43+ k, val = @container.assoc(key)
4344 val
4445 end
4546
46- def []=(key, val)
47- if key?(key)
48- self[key].value = val
49- else
50- self << @klass.new(key, val)
51- end
52- end
53-
5447 def key?(key)
55- !assoc(key).nil?
48+ !@container.assoc(key).nil?
5649 end
5750
5851 def delete(key)
59- super(assoc(key))
52+ @container.delete(@container.assoc(key))
6053 end
6154
6255 def each(&block)
63- super do |key, val|
56+ @container.each do |key, val|
6457 block.call(val)
6558 end
6659 end
67-
68- def map(&block)
69- if block_given?
70- super do |key, val|
71- block.call(val)
72- end
73- else
74- super do |key, val|
75- val
76- end
77- end
78- end
7960 end
8061 end
--- trunk/lib/tenarai/db/row.rb (revision 120)
+++ trunk/lib/tenarai/db/row.rb (revision 121)
@@ -10,6 +10,7 @@
1010 class DB
1111 class Row
1212 extend Meta
13+
1314 meta[:primary_key] = PrimaryKey.new('id')
1415 meta[:class_name] = ClassName.new('class_name')
1516 meta[:column] = Container.new
@@ -25,19 +26,6 @@
2526 meta[:index] << idx
2627 end
2728
28- def meta_deep_copy(subclass, key)
29- subclass.meta[key] = Marshal.load(Marshal.dump(self.meta[key]))
30- end
31- private :meta_deep_copy
32-
33- def inherited(subclass)
34- super
35- meta_deep_copy(subclass, :primary_key)
36- meta_deep_copy(subclass, :class_name)
37- meta_deep_copy(subclass, :column)
38- meta_deep_copy(subclass, :index)
39- end
40-
4129 def create_row(class_name, table, row)
4230 eval('::' + class_name).new(table, row)
4331 end
--- trunk/lib/tenarai/meta.rb (revision 120)
+++ trunk/lib/tenarai/meta.rb (revision 121)
@@ -7,5 +7,11 @@
77 def meta
88 @meta ||= {}
99 end
10+
11+ def inherited(subclass)
12+ meta.each do |key, val|
13+ subclass.meta[key] = Marshal.load(Marshal.dump(val))
14+ end
15+ end
1016 end
1117 end
--- trunk/webapp/Widget/HTML.rb (revision 120)
+++ trunk/webapp/Widget/HTML.rb (revision 121)
@@ -58,6 +58,7 @@
5858 end
5959
6060 def render_html(head, body)
61+ super(head, body)
6162 head.tag('style', 'type' => 'text/css') do |style|
6263 style.code(Tenarai::CSS.new do |_css|
6364 @builder.view.widget.each do |val|
@@ -65,7 +66,6 @@
6566 end
6667 end.to_s)
6768 end
68- super(head, body)
6969 end
7070 end
7171 end
--- trunk/webapp/Widget/YUI/Layout.rb (nonexistent)
+++ trunk/webapp/Widget/YUI/Layout.rb (revision 121)
@@ -0,0 +1,130 @@
1+#
2+# Copyright (C) 2008 Jun Kikuchi <kikuchi@bonnou.com>
3+#
4+
5+Tenarai::ClassLoader.load_class('Widget::YUI')
6+
7+class Widget
8+ class YUI
9+ class Layout < ::Widget
10+ extend Tenarai::ClassLoader
11+
12+ property :layout_id
13+
14+ property :top_body
15+ property :top_header
16+ property :top_height
17+ property :top_resize
18+ property :top_gutter
19+ property :top_footer
20+ property :top_collapse
21+ property :top_scroll
22+ property :top_animate
23+
24+ property :right_body
25+ property :right_header
26+ property :right_width
27+ property :right_resize
28+ property :right_gutter
29+ property :right_footer
30+ property :right_collapse
31+ property :right_scroll
32+ property :right_animate
33+
34+ property :bottom_body
35+ property :bottom_header
36+ property :bottom_height
37+ property :bottom_resize
38+ property :bottom_gutter
39+ property :bottom_footer
40+ property :bottom_collapse
41+ property :bottom_scroll
42+ property :bottom_animate
43+
44+ property :left_body
45+ property :left_header
46+ property :left_width
47+ property :left_resize
48+ property :left_gutter
49+ property :left_footer
50+ property :left_collapse
51+ property :left_scroll
52+ property :left_animate
53+
54+ property :center_body
55+ property :center_header
56+ property :center_gutter
57+ property :center_footer
58+ property :center_scroll
59+
60+ css '.yui-layout-unit-top'
61+ css '.yui-layout-unit-right'
62+ css '.yui-layout-unit-bottom'
63+ css '.yui-layout-unit-left'
64+
65+ css '.yui-layout-unit .yui-resize-handle-t .yui-layout-resize-knob'
66+ css '.yui-layout-unit .yui-resize-handle-r .yui-layout-resize-knob'
67+ css '.yui-layout-unit .yui-resize-handle-b .yui-layout-resize-knob'
68+ css '.yui-layout-unit .yui-resize-handle-l .yui-layout-resize-knob'
69+
70+ def render_css(_css)
71+ css.each do |val|
72+ a = val.name.split('_')
73+ _css.selector(a.shift, a.pop => val.value)
74+ end
75+ end
76+
77+ def render_html(head, body)
78+ units = [
79+ 'top',
80+ 'right',
81+ 'bottom',
82+ 'left',
83+ 'center'
84+ ].inject([]) do |ret, pos|
85+ if body = property["#{pos}_body".intern]
86+ unit = {'position' => "'#{pos}'", 'body' => body}
87+
88+ [
89+ 'header',
90+ 'height',
91+ 'width',
92+ 'resize',
93+ 'gutter',
94+ 'footer',
95+ 'collapse',
96+ 'scroll',
97+ 'animate'
98+ ].each do |key|
99+ if val = property["#{pos}_#{key}".intern]
100+ unit[key] = val
101+ end
102+ end
103+
104+ ret << '{' + unit.sort.map do |key, val|
105+ "#{key}: #{val}"
106+ end.join(', ') + '}'
107+ end
108+
109+ ret
110+ end.join(', ')
111+
112+ head.tag('script', 'type' => 'text/javascript').code <<-END
113+new YAHOO.util.YUILoader({
114+ require: ['layout', 'resize'],
115+ onSuccess: function() {
116+ var Dom = YAHOO.util.Dom;
117+ var Event = YAHOO.util.Event;
118+
119+ Event.onDOMReady(function() {
120+ new YAHOO.widget.Layout({
121+ units: [#{units}]
122+ }).render();
123+ });
124+ }
125+}).insert();
126+ END
127+ end
128+ end
129+ end
130+end
--- trunk/webapp/Widget/YUI/ResetCSS.rb (nonexistent)
+++ trunk/webapp/Widget/YUI/ResetCSS.rb (revision 121)
@@ -0,0 +1,21 @@
1+#
2+# Copyright (C) 2008 Jun Kikuchi <kikuchi@bonnou.com>
3+#
4+
5+Tenarai::ClassLoader.load_class('Widget::YUI')
6+
7+class Widget
8+ class YUI
9+ class ResetCSS < ::Widget
10+ extend Tenarai::ClassLoader
11+
12+ def render_html(head, body)
13+ head.tag('script', 'type' => 'text/javascript').code <<-END
14+new YAHOO.util.YUILoader({
15+ require: ['reset-fonts-grids']
16+}).insert();
17+ END
18+ end
19+ end
20+ end
21+end
--- trunk/webapp/Widget/YUI.rb (nonexistent)
+++ trunk/webapp/Widget/YUI.rb (revision 121)
@@ -0,0 +1,24 @@
1+#
2+# Copyright (C) 2008 Jun Kikuchi <kikuchi@bonnou.com>
3+#
4+
5+Tenarai::ClassLoader.load_class('Widget')
6+
7+class Widget
8+ class YUI < ::Widget
9+ extend Tenarai::ClassLoader
10+
11+ YUI_BASE_DIR = 'http://yui.yahooapis.com/2.6.0/build'
12+
13+ property :src, YUI_BASE_DIR + '/yuiloader/yuiloader-min.js'
14+
15+ def render_html(head, body)
16+ head.tag(
17+ 'script',
18+ 'type' => 'text/javascript',
19+ 'src' => property[:src]
20+ ).text('')
21+ super
22+ end
23+ end
24+end
--- trunk/webapp/Widget.rb (revision 120)
+++ trunk/webapp/Widget.rb (revision 121)
@@ -46,8 +46,6 @@
4646
4747 def inherited(subclass)
4848 super
49- subclass.meta[:property] = meta[:property].clone
50- subclass.meta[:css] = meta[:css].clone
5149 subclass.meta[:resource] = subclass.name.sub(/\w+?$/, '').sub(/::+?$/, '')
5250 subclass.meta[:resource] = nil if subclass.meta[:resource].empty?
5351 end
Show on old repository browser