• R/O
  • SSH
  • HTTPS

tenarai: 提交


Commit MetaInfo

修訂60 (tree)
時間2008-03-22 20:55:58
作者junkikuchi

Log Message

updated.

Change Summary

差異

--- trunk/Rakefile (revision 59)
+++ trunk/Rakefile (revision 60)
@@ -70,10 +70,37 @@
7070 :class => 'Content',
7171 :row => {
7272 'title' => 'admin',
73- 'body' => 'admin',
73+ 'body' => '',
7474 },
7575 :relation => {'view' => 'view:resource.admin.user'},
7676 },
77+ {
78+ :name => 'admin.new_user',
79+ :class => 'Content',
80+ :row => {
81+ 'title' => 'new user',
82+ 'body' => '',
83+ },
84+ :relation => {'view' => 'view:resource.admin.user.new'},
85+ },
86+ {
87+ :name => 'admin.list',
88+ :class => 'Content',
89+ :row => {
90+ 'title' => 'user list',
91+ 'body' => '',
92+ },
93+ :relation => {'view' => 'view:resource.admin.user.list'},
94+ },
95+ {
96+ :name => 'admin.list.user',
97+ :class => 'Content',
98+ :row => {
99+ 'title' => 'user detail',
100+ 'body' => '',
101+ },
102+ :relation => {'view' => 'view:resource.admin.user.detail'},
103+ },
77104
78105 {
79106 :name => 'skelton',
@@ -110,6 +137,21 @@
110137 :class => 'View',
111138 :row => {'name' => 'user'},
112139 },
140+ {
141+ :name => 'resource.admin.user.list',
142+ :class => 'View',
143+ :row => {'name' => 'list'},
144+ },
145+ {
146+ :name => 'resource.admin.user.new',
147+ :class => 'View',
148+ :row => {'name' => 'user'},
149+ },
150+ {
151+ :name => 'resource.admin.user.detail',
152+ :class => 'View',
153+ :row => {'name' => 'user'},
154+ },
113155
114156 {
115157 :name => 'resource.skelton',
@@ -154,12 +196,15 @@
154196 :relation => {'view' => 'view:resource'},
155197 :preference => {
156198 'box.text.text_align' => 'left',
199+ 'box.size.width' => '900px',
200+ 'box.margin.margin_right' => 'auto',
201+ 'box.margin.margin_left' => 'auto',
157202 }
158203 },
159204
160205 {
161206 :name => 'session.user.content.view.html.login',
162- :class => 'Widget',
207+ :class => 'Widget::Panel',
163208 :row => {},
164209 :relation => {'view' => 'view:resource.login'},
165210 :preference => {}
@@ -185,15 +230,11 @@
185230 :row => {},
186231 :relation => {'view' => 'view:resource.login'},
187232 :preference => {
188- 'box.margin.margin_top' => '10px',
189- 'box.margin.margin_right' => '10px',
190- 'box.margin.margin_bottom' => '10px',
191- 'box.margin.margin_left' => '10px',
233+ 'box.margin.margin_top' => '10px',
234+ 'box.margin.margin_bottom' => '10px',
192235 'box.padding.padding_top' => '10px',
193- 'box.padding.padding_right' => '10px',
194236 'box.padding.padding_bottom' => '10px',
195- 'box.padding.padding_left' => '10px',
196- 'box.border.border_bottom' => 'solid 3px blue',
237+ 'box.border.border_bottom' => 'solid 3px blue',
197238 }
198239 },
199240 {
@@ -233,7 +274,7 @@
233274
234275 {
235276 :name => 'session.user.content.view.html.admin',
236- :class => 'Widget',
277+ :class => 'Widget::Panel',
237278 :row => {},
238279 :relation => {'view' => 'view:resource.admin'},
239280 :preference => {}
@@ -253,15 +294,11 @@
253294 :row => {},
254295 :relation => {'view' => 'view:resource.admin'},
255296 :preference => {
256- 'box.margin.margin_top' => '10px',
257- 'box.margin.margin_right' => '10px',
258- 'box.margin.margin_bottom' => '10px',
259- 'box.margin.margin_left' => '10px',
297+ 'box.margin.margin_top' => '10px',
298+ 'box.margin.margin_bottom' => '10px',
260299 'box.padding.padding_top' => '10px',
261- 'box.padding.padding_right' => '10px',
262300 'box.padding.padding_bottom' => '10px',
263- 'box.padding.padding_left' => '10px',
264- 'box.border.border_bottom' => 'solid 3px blue',
301+ 'box.border.border_bottom' => 'solid 3px blue',
265302 }
266303 },
267304 {
@@ -296,6 +333,14 @@
296333 },
297334
298335 {
336+ :name => 'session.user.content.view.html.admin.bd.tab',
337+ :class => 'Widget::Content::Tab',
338+ :row => {},
339+ :relation => {'view' => 'view:resource.admin.user'},
340+ :preference => {
341+ }
342+ },
343+ {
299344 :name => 'session.user.content.view.html.admin.bd.user',
300345 :class => 'Widget::UserAdmin',
301346 :row => {},
@@ -305,9 +350,40 @@
305350 :name => 'session.user.content.view.html.admin.bd.user.list',
306351 :class => 'Widget::UserAdmin::List',
307352 :row => {},
308- :relation => {'view' => 'view:resource.admin.user'},
309- :preference => {}
353+ :relation => {'view' => 'view:resource.admin.user.list'},
354+ :preference => {
355+ 'box.size.width' => '900px',
356+ 'head.background.background_color' => 'silver',
357+ 'head.padding.padding_top' => '5px',
358+ 'head.padding.padding_right' => '5px',
359+ 'head.padding.padding_bottom' => '5px',
360+ 'head.padding.padding_left' => '5px',
361+ 'body.padding.padding_top' => '5px',
362+ 'body.padding.padding_right' => '5px',
363+ 'body.padding.padding_bottom' => '5px',
364+ 'body.padding.padding_left' => '5px',
365+ }
310366 },
367+ {
368+ :name => 'session.user.content.view.html.admin.bd.user.new',
369+ :class => 'Widget::UserAdmin::Form',
370+ :row => {},
371+ :relation => {'view' => 'view:resource.admin.user.new'},
372+ :preference => {
373+ 'box.size.width' => '900px',
374+ 'preference.form.type' => 'new',
375+ }
376+ },
377+ {
378+ :name => 'session.user.content.view.html.admin.bd.user.detail',
379+ :class => 'Widget::UserAdmin::Form',
380+ :row => {},
381+ :relation => {'view' => 'view:resource.admin.user.detail'},
382+ :preference => {
383+ 'box.size.width' => '900px',
384+ 'preference.form.type' => 'edit',
385+ }
386+ },
311387
312388 =begin
313389 {
--- trunk/lib/tenarai/css.rb (revision 59)
+++ trunk/lib/tenarai/css.rb (revision 60)
@@ -6,7 +6,7 @@
66
77 module Tenarai
88 class CSS < Container
9- class Style < Hash
9+ class Selecter < Hash
1010 attr_reader :name
1111
1212 def initialize(name)
@@ -26,8 +26,9 @@
2626 end
2727 end
2828
29- def initialize(&block)
29+ def initialize(param={}, &block)
3030 super()
31+ @indent = (param[:indent] || 2).to_i
3132 block.call(self) if block_given?
3233 end
3334
@@ -35,7 +36,7 @@
3536 obj = if key?(selecter)
3637 fetch(selecter)
3738 else
38- self << Style.new(selecter)
39+ self << Selecter.new(selecter)
3940 end
4041
4142 style.each do |key, val|
@@ -47,12 +48,14 @@
4748 obj
4849 end
4950
50- def to_s(indent=2)
51+ def to_s(indent=nil)
52+ _indent = if indent.nil? then @indent else indent.to_i end
53+
5154 inject([]) do |ret, val|
52- s = val.to_s(indent)
55+ s = val.to_s(_indent)
5356 ret << s unless s.empty?
5457 ret
55- end.join(if indent == 0 then ' ' else "\n\n" end)
58+ end.join(if _indent == 0 then ' ' else "\n\n" end)
5659 end
5760
5861 alias :to_css :to_s
--- trunk/lib/tenarai/xml.rb (revision 59)
+++ trunk/lib/tenarai/xml.rb (revision 60)
@@ -6,8 +6,9 @@
66
77 module Tenarai
88 class XML < ArrayTree
9- def initialize(&block)
10- super
9+ def initialize(param={}, &block)
10+ super()
11+ @indent = (param[:indent] || 2).to_i
1112 block.call(self) if block_given?
1213 end
1314
@@ -51,8 +52,8 @@
5152 end
5253 end
5354
54- def to_s(indent=2)
55- Render.new(self, indent).to_s
55+ def to_s(indent=nil)
56+ Render.new(self, if indent.nil? then @indent else indent.to_i end).to_s
5657 end
5758
5859 alias :to_xml :to_s
--- trunk/webapp/Widget/UserAdmin/Form.rb (nonexistent)
+++ trunk/webapp/Widget/UserAdmin/Form.rb (revision 60)
@@ -0,0 +1,92 @@
1+#
2+# Copyright (C) 2008 Jun Kikuchi <kikuchi@bonnou.com>
3+#
4+
5+Tenarai::ClassLoader.load_class('Widget::UserAdmin')
6+
7+class Widget
8+ class UserAdmin
9+ class Form < ::Widget
10+ extend Tenarai::ClassLoader
11+
12+ preference_css 'box'
13+ preference_css 'msg', 'p'
14+ preference_css 'label', 'label'
15+ preference_css 'input', 'input[type="text"]', 'input[type="password"]'
16+ preference_css 'submit', 'input[type="submit"]'
17+
18+ preference 'preference' do |pref|
19+ pref.group('form') do |form|
20+ form.edit 'type' do |type|
21+ type.value = 'new'
22+ end
23+ end
24+ end
25+
26+ def form_type
27+ if preference.preference.form.type.value == 'edit'
28+ :edit
29+ else
30+ :new
31+ end
32+ end
33+ private :form_type
34+
35+ def post(service, query={})
36+ if form_type == :new
37+ resource.new(query)
38+ else
39+ resource.content.name = query['name']
40+ resource.content.password = query['password']
41+ resource.content.save
42+ end
43+ end
44+
45+ def render_html(xml, builder)
46+ name = if form_type == :new
47+ ''
48+ else
49+ resource.content.name
50+ end
51+
52+ xml.tag('div', 'id' => html_id) do |div|
53+ div.tag('form', 'method' => 'post', 'action' => url) do |form|
54+ form.tag('p') do |p|
55+ p.text(@msg)
56+ end if @msg
57+
58+ form.tag('div') do |div|
59+ div.tag('label') do |label|
60+ label.text('User Name:')
61+ label.tag(
62+ 'input',
63+ 'type' => 'text',
64+ 'name' => html_id('name'),
65+ 'value' => name
66+ )
67+ end
68+ div.tag('br')
69+
70+ div.tag('label') do |label|
71+ label.text('Password:')
72+ label.tag(
73+ 'input',
74+ 'type' => 'password',
75+ 'name' => html_id('password'),
76+ 'value' => ''
77+ )
78+ end
79+ div.tag('br')
80+
81+ div.tag(
82+ 'input',
83+ 'type' => 'submit',
84+ 'name' => html_id('submit')
85+ )
86+ end
87+ end
88+ end
89+ end
90+ end
91+ end
92+end
--- trunk/webapp/Widget/UserAdmin/List.rb (revision 59)
+++ trunk/webapp/Widget/UserAdmin/List.rb (revision 60)
@@ -9,26 +9,31 @@
99 class List < ::Widget
1010 extend Tenarai::ClassLoader
1111
12- preference_css 'box'
12+ preference_css 'box', 'table'
1313 preference_css 'head', 'thead th'
1414 preference_css 'body', 'tbody td'
15+ preference_css 'col_id', '.id'
16+ preference_css 'col_name', '.name'
17+ preference_css 'col_active', '.active'
1518
1619 def render_html(xml, builder, content=nil)
20+ xml.text(path.map do |v| v.class.name end.join(' > '))
21+
1722 xml.tag('div', 'id' => html_id) do |div|
1823 div.tag('table') do |table|
1924 table.tag('thead') do |th|
2025 th.tag('tr') do |th|
21- th.tag('th').text('id')
22- th.tag('th').text('name')
23- th.tag('th').text('active')
26+ th.tag('th', 'class' => 'id').text('id')
27+ th.tag('th', 'class' => 'name').text('name')
28+ th.tag('th', 'class' => 'active').text('active')
2429 end
2530 end
2631 table.tag('tbody') do |tb|
2732 resource.each do |user|
2833 tb.tag('tr') do |th|
29- th.tag('td').text(user.id)
30- th.tag('td').text(user.name)
31- th.tag('td').text(user.active)
34+ th.tag('td', 'class' => 'id').text(user.id)
35+ th.tag('td', 'class' => 'name').tag('a', 'href' => resource.url(user.id)).text(user.name)
36+ th.tag('td', 'class' => 'active').text(user.active)
3237 end
3338 end
3439 end
--- trunk/webapp/Widget/UserAdmin.rb (revision 59)
+++ trunk/webapp/Widget/UserAdmin.rb (revision 60)
@@ -8,6 +8,30 @@
88 class UserAdmin < Resource
99 extend Tenarai::ClassLoader
1010
11+ resource 'Widget::Content'
12+
13+ def _build_url(param, _resource, _query)
14+ if view.path.size == 1
15+ _resource.unshift([build_url(param)].join(','))
16+ else
17+ _query[html_id] = [build_url(param)].join(',')
18+ end
19+
20+ if resource.nil?
21+ @service
22+ else
23+ resource
24+ end._build_url(
25+ [if c = resource.content.node.map.shift then c.id else nil end],
26+ _resource,
27+ _query
28+ )
29+ end
30+
31+ def init(id=nil)
32+ @content = service.model['user'].fetch(id)
33+ end
34+
1135 def new(row)
1236 u = ::User.new(@service.model['user'])
1337 u.name = row['name']
--- trunk/webapp/Widget.rb (revision 59)
+++ trunk/webapp/Widget.rb (revision 60)
@@ -145,17 +145,8 @@
145145 self.class.fetch_resource(self)
146146 end
147147
148- def _build_url(param, _resource, _query)
149- if parent.nil?
150- @service
151- else
152- parent
153- end._build_url([], _resource, _query)
154- end
155-
156148 def url(*param, &block)
157- #resource.url(*param, &block)
158- parent.url(*param, &block)
149+ resource.url(*param, &block)
159150 end
160151
161152 def init(*param)
--- trunk/webapp/Resource.rb (revision 59)
+++ trunk/webapp/Resource.rb (revision 60)
@@ -26,15 +26,17 @@
2626 end
2727
2828 def _build_url(param, _resource, _query)
29- _param = [build_url(param)].join(',')
30-
3129 if view.path.size == 1
32- _resource.unshift(_param)
30+ _resource.unshift([build_url(param)].join(','))
3331 else
34- _query[html_id] = _param
32+ _query[html_id] = [build_url(param)].join(',')
3533 end
3634
37- super
35+ if resource.nil?
36+ @service
37+ else
38+ resource
39+ end._build_url([], _resource, _query)
3840 end
3941
4042 def url(*param, &block)
Show on old repository browser