uzuuzu-core 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/.redcar/tags +145 -0
- data/Gemfile +10 -6
- data/Gemfile.lock +14 -10
- data/VERSION +1 -1
- data/lib/uzuuzu-core.rb +5 -1
- data/lib/uzuuzu/controller/admin.rb +11 -0
- data/lib/uzuuzu/controller/contents.rb +11 -0
- data/lib/uzuuzu/controller/crud.rb +235 -0
- data/lib/uzuuzu/controller/css.rb +11 -0
- data/lib/uzuuzu/controller/error.rb +11 -0
- data/lib/uzuuzu/controller/index.rb +25 -0
- data/lib/uzuuzu/controller/initialize.rb +52 -0
- data/lib/uzuuzu/controller/javascript.rb +11 -0
- data/lib/uzuuzu/controller/oauth.rb +10 -0
- data/lib/uzuuzu/controller/openid.rb +40 -0
- data/lib/uzuuzu/controller/page.rb +14 -0
- data/lib/uzuuzu/controller/plugin.rb +11 -0
- data/lib/uzuuzu/controller/user.rb +22 -0
- data/lib/uzuuzu/controller/view/admin/index.xhtml +0 -0
- data/lib/uzuuzu/controller/view/crud/destroy.rhtml +28 -0
- data/lib/uzuuzu/controller/view/crud/edit.rhtml +52 -0
- data/lib/uzuuzu/controller/view/crud/index.rhtml +45 -0
- data/lib/uzuuzu/controller/view/crud/new.rhtml +48 -0
- data/lib/uzuuzu/controller/view/crud/show.rhtml +47 -0
- data/lib/uzuuzu/controller/view/error/404.tenjin +0 -0
- data/lib/uzuuzu/controller/view/initialize/step1.xhtml +30 -0
- data/lib/uzuuzu/controller/view/initialize/step2.xhtml +1 -0
- data/lib/uzuuzu/controller/view/initialize/step3.xhtml +0 -0
- data/lib/uzuuzu/controller/view/openid/index.xhtml +14 -0
- data/lib/uzuuzu/controller/view/page.xhtml +17 -0
- data/lib/uzuuzu/controller/view/user/entry.xhtml +13 -0
- data/lib/uzuuzu/fixture/layout.yaml +110 -0
- data/lib/uzuuzu/helper/controller.rb +135 -0
- data/lib/uzuuzu/helper/fixture.rb +9 -0
- data/lib/uzuuzu/helper/localize.rb +15 -0
- data/lib/uzuuzu/helper/renderer.rb +158 -0
- data/lib/uzuuzu/helper/route.rb +62 -0
- data/lib/uzuuzu/helper/uzuuzu_page.rb +61 -0
- data/lib/uzuuzu/helper/xhtml.rb +44 -0
- data/lib/uzuuzu/model/.DS_Store +0 -0
- data/lib/uzuuzu/model/remote_user.rb +70 -0
- data/lib/uzuuzu/uzuuzu-core.rb +10 -1
- data/lib/uzuuzu/wrapper/application.rb +282 -0
- data/lib/uzuuzu/wrapper/controller.rb +28 -80
- data/lib/uzuuzu/wrapper/datastore.rb +17 -0
- data/lib/uzuuzu/wrapper/environments.rb +129 -0
- data/lib/uzuuzu/wrapper/helper.rb +13 -0
- data/lib/uzuuzu/wrapper/lang/en.yaml +19 -0
- data/lib/uzuuzu/wrapper/lang/ja.yaml +19 -0
- data/lib/uzuuzu/wrapper/logger.rb +95 -21
- data/lib/uzuuzu/wrapper/object.rb +9 -0
- data/lib/uzuuzu/wrapper/request.rb +26 -0
- data/lib/uzuuzu/wrapper/response.rb +16 -0
- data/lib/uzuuzu/wrapper/uzuuzu.rb +26 -146
- data/uzuuzu-core.gemspec +71 -14
- metadata +104 -15
File without changes
|
@@ -0,0 +1,30 @@
|
|
1
|
+
<?xml version="1.0" ?>
|
2
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
|
3
|
+
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
4
|
+
<html xmlns="http://www.w3.org/1999/xhtml">
|
5
|
+
<head>
|
6
|
+
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
7
|
+
<meta http-equiv="Content-Style-Type" content="text/css" />
|
8
|
+
<meta http-equiv="expires" content="-1" />
|
9
|
+
<title>初期設定 - UzuUzu</title>
|
10
|
+
#{css_for 'jquery-ui'}
|
11
|
+
#{js_for 'jquery', 'jquery-ui'}
|
12
|
+
</head>
|
13
|
+
<body>
|
14
|
+
<div id="openid_index">
|
15
|
+
<p>
|
16
|
+
#{uzuuzu_string(:openid_message)}
|
17
|
+
</p>
|
18
|
+
<form method="post" action="#{UzuUzu::OpenidController.r(:openid_begin)}">
|
19
|
+
<p>
|
20
|
+
#{uzuuzu_string(:openid_url)}:
|
21
|
+
<input type="text" name="url" />
|
22
|
+
</p>
|
23
|
+
<p>
|
24
|
+
<input type="submit" value="#{uzuuzu_string(:login)}"/>
|
25
|
+
</p>
|
26
|
+
</form>
|
27
|
+
</div>
|
28
|
+
</body>
|
29
|
+
</html>
|
30
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
|
File without changes
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<div id="openid_index">
|
2
|
+
<p>
|
3
|
+
#{uzuuzu_string(:openid_message)}
|
4
|
+
</p>
|
5
|
+
<form method="post" action="#{rs(:openid_begin)}">
|
6
|
+
<p>
|
7
|
+
#{uzuuzu_string(:openid_url)}:
|
8
|
+
<input type="text" name="url" />
|
9
|
+
</p>
|
10
|
+
<p>
|
11
|
+
<input type="submit" value="#{uzuuzu_string(:login)}"/>
|
12
|
+
</p>
|
13
|
+
</form>
|
14
|
+
</div>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<?xml version="1.0" ?>
|
2
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
|
3
|
+
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
4
|
+
<html xmlns="http://www.w3.org/1999/xhtml">
|
5
|
+
<head>
|
6
|
+
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
7
|
+
<meta http-equiv="Content-Style-Type" content="text/css" />
|
8
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
9
|
+
<meta http-equiv="expires" content="-1" />
|
10
|
+
<title>#{@uzuuzu_title} - #{@info.title}</title>
|
11
|
+
#{css_for @uzuuzu_css}
|
12
|
+
#{js_for @uzuuzu_js}
|
13
|
+
</head>
|
14
|
+
<body >
|
15
|
+
#{@uzuuzu_body}
|
16
|
+
</body>
|
17
|
+
</html>
|
@@ -0,0 +1,13 @@
|
|
1
|
+
|
2
|
+
<div id="user_entry">
|
3
|
+
<p>#{uzuuzu_string(:user_entry)}"</p>
|
4
|
+
<form method="post" action="#{rs(:entry, @user.id)}">
|
5
|
+
<p>
|
6
|
+
#{uzuuzu_string(:user_entry_name)}:
|
7
|
+
<input id="username" name="username" type="text" />
|
8
|
+
</p>
|
9
|
+
<p>
|
10
|
+
<input type="submit" value="#{uzuuzu_string(:entry)}"/>
|
11
|
+
</p>
|
12
|
+
</form>
|
13
|
+
</div>
|
@@ -0,0 +1,110 @@
|
|
1
|
+
---
|
2
|
+
- :id: 1
|
3
|
+
:name: contents_only
|
4
|
+
:format: Etanni
|
5
|
+
:body: |-
|
6
|
+
<div id="contents">
|
7
|
+
#{@uzuuzu_contents}
|
8
|
+
</div>
|
9
|
+
- :id: 2
|
10
|
+
:name: noside
|
11
|
+
:format: Etanni
|
12
|
+
:body: |-
|
13
|
+
<div id="contents">
|
14
|
+
#{@uzuuzu_contents}
|
15
|
+
</div>
|
16
|
+
<div id="header">
|
17
|
+
#{@uzuuzu_header}
|
18
|
+
</div>
|
19
|
+
<div id="footer">
|
20
|
+
#{@uzuuzu_footer}
|
21
|
+
</div>
|
22
|
+
- :id: 3
|
23
|
+
:name: left
|
24
|
+
:format: Etanni
|
25
|
+
:body: |-
|
26
|
+
<div id="contents">
|
27
|
+
#{@uzuuzu_contents}
|
28
|
+
</div>
|
29
|
+
<div id="left">
|
30
|
+
#{@uzuuzu_left}
|
31
|
+
</div>
|
32
|
+
<div id="header">
|
33
|
+
#{@uzuuzu_header}
|
34
|
+
</div>
|
35
|
+
<div id="footer">
|
36
|
+
#{@uzuuzu_footer}
|
37
|
+
</div>
|
38
|
+
- :id: 4
|
39
|
+
:name: right
|
40
|
+
:format: Etanni
|
41
|
+
:body: |-
|
42
|
+
<div id="contents">
|
43
|
+
#{@uzuuzu_contents}
|
44
|
+
</div>
|
45
|
+
<div id="right">
|
46
|
+
#{@uzuuzu_right}
|
47
|
+
</div>
|
48
|
+
<div id="header">
|
49
|
+
#{@uzuuzu_header}
|
50
|
+
</div>
|
51
|
+
<div id="footer">
|
52
|
+
#{@uzuuzu_footer}
|
53
|
+
</div>
|
54
|
+
- :id: 5
|
55
|
+
:name: side
|
56
|
+
:format: Etanni
|
57
|
+
:body: |-
|
58
|
+
<div id="contents">
|
59
|
+
#{@uzuuzu_contents}
|
60
|
+
</div>
|
61
|
+
<div id="left">
|
62
|
+
#{@uzuuzu_left}
|
63
|
+
</div>
|
64
|
+
<div id="right">
|
65
|
+
#{@uzuuzu_right}
|
66
|
+
</div>
|
67
|
+
<div id="header">
|
68
|
+
#{@uzuuzu_header}
|
69
|
+
</div>
|
70
|
+
<div id="footer">
|
71
|
+
#{@uzuuzu_footer}
|
72
|
+
</div>
|
73
|
+
- :id: 6
|
74
|
+
:name: left2
|
75
|
+
:format: Etanni
|
76
|
+
:body: |-
|
77
|
+
<div id="contents">
|
78
|
+
#{@uzuuzu_contents}
|
79
|
+
</div>
|
80
|
+
<div id="left">
|
81
|
+
#{@uzuuzu_left}
|
82
|
+
</div>
|
83
|
+
<div id="left2">
|
84
|
+
#{@uzuuzu_right}
|
85
|
+
</div>
|
86
|
+
<div id="header">
|
87
|
+
#{@uzuuzu_header}
|
88
|
+
</div>
|
89
|
+
<div id="footer">
|
90
|
+
#{@uzuuzu_footer}
|
91
|
+
</div>
|
92
|
+
- :id: 7
|
93
|
+
:name: right2
|
94
|
+
:format: Etanni
|
95
|
+
:body: |-
|
96
|
+
<div id="contents">
|
97
|
+
#{@uzuuzu_contents}
|
98
|
+
</div>
|
99
|
+
<div id="right">
|
100
|
+
#{@uzuuzu_left}
|
101
|
+
</div>
|
102
|
+
<div id="right2">
|
103
|
+
#{@uzuuzu_right}
|
104
|
+
</div>
|
105
|
+
<div id="header">
|
106
|
+
#{@uzuuzu_header}
|
107
|
+
</div>
|
108
|
+
<div id="footer">
|
109
|
+
#{@uzuuzu_footer}
|
110
|
+
</div>
|
@@ -0,0 +1,135 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
module UzuUzu
|
4
|
+
#
|
5
|
+
#
|
6
|
+
#
|
7
|
+
module Helper
|
8
|
+
#
|
9
|
+
#
|
10
|
+
#
|
11
|
+
module Controller
|
12
|
+
#
|
13
|
+
#
|
14
|
+
#
|
15
|
+
def application
|
16
|
+
@_application
|
17
|
+
end
|
18
|
+
#
|
19
|
+
#
|
20
|
+
#
|
21
|
+
def request
|
22
|
+
@_request
|
23
|
+
end
|
24
|
+
|
25
|
+
#
|
26
|
+
#
|
27
|
+
#
|
28
|
+
def response
|
29
|
+
@_response
|
30
|
+
end
|
31
|
+
|
32
|
+
#
|
33
|
+
#
|
34
|
+
#
|
35
|
+
def action
|
36
|
+
@_action
|
37
|
+
end
|
38
|
+
|
39
|
+
#
|
40
|
+
#
|
41
|
+
#
|
42
|
+
def query
|
43
|
+
@_query
|
44
|
+
end
|
45
|
+
|
46
|
+
#
|
47
|
+
#
|
48
|
+
#
|
49
|
+
def route
|
50
|
+
@_route
|
51
|
+
end
|
52
|
+
|
53
|
+
#
|
54
|
+
#
|
55
|
+
#
|
56
|
+
def info
|
57
|
+
@_info ||= UzuUzu::Info.uniq
|
58
|
+
end
|
59
|
+
|
60
|
+
#
|
61
|
+
#
|
62
|
+
#
|
63
|
+
def session
|
64
|
+
request.session
|
65
|
+
end
|
66
|
+
|
67
|
+
#
|
68
|
+
#
|
69
|
+
#
|
70
|
+
def logger
|
71
|
+
UzuUzu.logger
|
72
|
+
end
|
73
|
+
|
74
|
+
#
|
75
|
+
#
|
76
|
+
#
|
77
|
+
def memcache
|
78
|
+
UzuUzu.memcache
|
79
|
+
end
|
80
|
+
|
81
|
+
#
|
82
|
+
#
|
83
|
+
#
|
84
|
+
def remote_user
|
85
|
+
nil
|
86
|
+
end
|
87
|
+
|
88
|
+
#
|
89
|
+
#
|
90
|
+
#
|
91
|
+
def h(s)
|
92
|
+
Rack::Utils.escape(s)
|
93
|
+
end
|
94
|
+
|
95
|
+
#
|
96
|
+
#
|
97
|
+
#
|
98
|
+
def u(s)
|
99
|
+
Rack::Utils.unescape(s)
|
100
|
+
end
|
101
|
+
|
102
|
+
#
|
103
|
+
#
|
104
|
+
#
|
105
|
+
def admin?
|
106
|
+
if remote_user
|
107
|
+
remote_user.admin?
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
#
|
112
|
+
#
|
113
|
+
#
|
114
|
+
def mime_type(type, value=nil)
|
115
|
+
return type if type.nil? || type.to_s.include?('/')
|
116
|
+
type = ".#{type}" unless type.to_s[0] == ?.
|
117
|
+
return Rack::Mime.mime_type(type, nil) if value.nil?
|
118
|
+
Rack::Mime::MIME_TYPES[type] = value
|
119
|
+
end
|
120
|
+
|
121
|
+
#
|
122
|
+
#
|
123
|
+
#
|
124
|
+
def query_string(query_options={})
|
125
|
+
return "" if query_options.blank?
|
126
|
+
query_string = []
|
127
|
+
query_options do |key, value|
|
128
|
+
query_string << "#{key}=#{value}"
|
129
|
+
end
|
130
|
+
return "" if query_string.blank?
|
131
|
+
"?#{query_string.join('&')}"
|
132
|
+
end
|
133
|
+
end # Controller
|
134
|
+
end # Helper
|
135
|
+
end # UzuUzu
|
@@ -0,0 +1,158 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
module UzuUzu
|
4
|
+
module Helper
|
5
|
+
module Renderer
|
6
|
+
module ExtendClass
|
7
|
+
def render(action, options={})
|
8
|
+
_request, _response, _controller, _action, _query, _route = UzuUzu.current.get_thread_by_di
|
9
|
+
browser = Rack::Test::Session.new(Rack::MockSession.new(UzuUzu.current))
|
10
|
+
browser.get self.url_for(action, options)
|
11
|
+
browser.last_response.body
|
12
|
+
UzuUzu.current.di_thread(_request, _response, _controller, _action, _query, _route)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.included(clazz)
|
17
|
+
clazz.extend ExtendClass
|
18
|
+
end
|
19
|
+
#
|
20
|
+
#
|
21
|
+
#
|
22
|
+
def respond(string, mime=nil, status=200)
|
23
|
+
response.status = 200
|
24
|
+
response["Content-Type"] = mime_type(mime) || mime unless mime.nil?
|
25
|
+
response.write string
|
26
|
+
throw :finish
|
27
|
+
end
|
28
|
+
|
29
|
+
def respond_to
|
30
|
+
return unless block_given?
|
31
|
+
response.status = 200
|
32
|
+
contents = yield(request.wish)
|
33
|
+
respond(contents, request.wish) if contents and response.successful?
|
34
|
+
end
|
35
|
+
|
36
|
+
#
|
37
|
+
#
|
38
|
+
#
|
39
|
+
def render(view, options={}, locals={}, &block)
|
40
|
+
view_path = nil
|
41
|
+
catch(:view_finded) do
|
42
|
+
Tilt.mappings.each_key do |key|
|
43
|
+
self.application.views.each do |view_route|
|
44
|
+
_view_path = "#{view_route}#{self.route}/#{view}.#{key}"
|
45
|
+
if ::File.file?(_view_path)
|
46
|
+
view_path = _view_path
|
47
|
+
throw :view_finded
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
if view_path.blank?
|
53
|
+
return nil
|
54
|
+
end
|
55
|
+
render_file(view_path, options={}, locals={}, &block)
|
56
|
+
end
|
57
|
+
|
58
|
+
#
|
59
|
+
#
|
60
|
+
#
|
61
|
+
def render_engine(view_string, engine=UzuUzu.engine, options={}, locals={}, &block)
|
62
|
+
template = Tilt[engine].new { |t| view_string }
|
63
|
+
contents = template.render(self, locals, &block)
|
64
|
+
unless options.blank?
|
65
|
+
layout = options[:layout] || options['layout']
|
66
|
+
unless layout.blank?
|
67
|
+
wrap_layout(layout, contents, options, locals)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
contents
|
71
|
+
end
|
72
|
+
#
|
73
|
+
#
|
74
|
+
#
|
75
|
+
def render_file(view_path, options={}, locals={}, &block)
|
76
|
+
if ::File.file?(view_path)
|
77
|
+
view_string = ::File.respond_to?(:binread) ? ::File.binread(view_path) : ::File.read(view_path)
|
78
|
+
render_engine(view_string, ::File.extname(view_path), options, locals, &block)
|
79
|
+
else
|
80
|
+
raise ArgmentError.new("file not found : #{view_path}")
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
#
|
85
|
+
#
|
86
|
+
#
|
87
|
+
def wrap_layout(layout, contents, options={}, locals={})
|
88
|
+
if ::File.file?(layout)
|
89
|
+
template = Tilt.new(layout)
|
90
|
+
contents = template.render(self, locals.merge({:contents => contents})){contents}
|
91
|
+
end
|
92
|
+
contents
|
93
|
+
end
|
94
|
+
|
95
|
+
def send_file()
|
96
|
+
|
97
|
+
end
|
98
|
+
|
99
|
+
def send_binary()
|
100
|
+
|
101
|
+
end
|
102
|
+
|
103
|
+
#
|
104
|
+
#
|
105
|
+
#
|
106
|
+
def redirect(uri, options={})
|
107
|
+
if not uri =~ /^https?:\/\//
|
108
|
+
abs_uri = "#{request.scheme}://#{request.host}"
|
109
|
+
|
110
|
+
if request.scheme == 'https' && request.port != 443 ||
|
111
|
+
request.scheme == 'http' && request.port != 80
|
112
|
+
abs_uri << ":#{request.port}"
|
113
|
+
end
|
114
|
+
uri = (abs_uri << uri)
|
115
|
+
end
|
116
|
+
uri << query_string(options)
|
117
|
+
response.redirect(uri)
|
118
|
+
throw :finish
|
119
|
+
end # redirect
|
120
|
+
|
121
|
+
#
|
122
|
+
#
|
123
|
+
#
|
124
|
+
def last_modified(time)
|
125
|
+
return unless time
|
126
|
+
if time.respond_to?(:to_time)
|
127
|
+
time = time.to_time
|
128
|
+
else
|
129
|
+
time = Time.parse(time.to_s)
|
130
|
+
end
|
131
|
+
response['Last-Modified'] = time.httpdate
|
132
|
+
if Time.httpdate(request.env['HTTP_IF_MODIFIED_SINCE']).to_i >= time.to_i
|
133
|
+
response.status = 304
|
134
|
+
throw :finish
|
135
|
+
end
|
136
|
+
end # last_modified
|
137
|
+
|
138
|
+
#
|
139
|
+
#
|
140
|
+
#
|
141
|
+
def etag(value, kind=:strong)
|
142
|
+
raise TypeError, ":strong or :weak expected" if ![:strong,:weak].include?(kind)
|
143
|
+
value = '"%s"' % value
|
144
|
+
value = 'W/' + value if kind == :weak
|
145
|
+
response['ETag'] = value
|
146
|
+
|
147
|
+
# Conditional GET check
|
148
|
+
if etags = env['HTTP_IF_NONE_MATCH']
|
149
|
+
etags = etags.split(/\s*,\s*/)
|
150
|
+
if etags.include?(value) || etags.include?('*')
|
151
|
+
response.status = 304
|
152
|
+
throw :finish
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end # etag
|
156
|
+
end # Renderer
|
157
|
+
end # Helper
|
158
|
+
end # UzuUzu
|