nitro 0.31.0 → 0.40.0
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/nitro +135 -37
- data/doc/CHANGELOG.1 +108 -108
- data/doc/CHANGELOG.2 +89 -89
- data/doc/CHANGELOG.3 +105 -105
- data/{CHANGELOG → doc/CHANGELOG.4} +509 -509
- data/doc/{AUTHORS → CONTRIBUTORS} +49 -37
- data/doc/LIBRARIES +13 -0
- data/doc/LICENSE +2 -3
- data/doc/MIGRATION +45 -0
- data/doc/RELEASES +131 -11
- data/doc/TODO +67 -0
- data/lib/glue/magick.rb +0 -3
- data/lib/glue/sweeper.rb +30 -15
- data/lib/glue/thumbnails.rb +0 -2
- data/lib/glue/webfile.rb +23 -11
- data/lib/nitro.rb +37 -44
- data/lib/nitro/adapter/cgi.rb +0 -3
- data/lib/nitro/adapter/console.rb +0 -2
- data/lib/nitro/adapter/fastcgi.rb +6 -3
- data/lib/nitro/adapter/mongrel.rb +97 -58
- data/lib/nitro/adapter/script.rb +4 -6
- data/lib/nitro/adapter/webrick.rb +33 -87
- data/lib/nitro/adapter/webrick/vcr.rb +85 -0
- data/lib/nitro/caching.rb +0 -2
- data/lib/nitro/caching/actions.rb +0 -2
- data/lib/nitro/caching/fragments.rb +0 -2
- data/lib/nitro/caching/output.rb +45 -16
- data/lib/nitro/caching/proxy.rb +49 -0
- data/lib/nitro/cgi.rb +3 -6
- data/lib/nitro/cgi/cookie.rb +0 -3
- data/lib/nitro/cgi/request.rb +67 -24
- data/lib/nitro/cgi/response.rb +0 -2
- data/lib/nitro/cgi/{sendfile.rb → send_file.rb} +7 -6
- data/lib/nitro/compiler.rb +62 -55
- data/lib/nitro/compiler/cleanup.rb +0 -3
- data/lib/nitro/compiler/elements.rb +31 -28
- data/lib/nitro/compiler/errors.rb +2 -5
- data/lib/nitro/compiler/include.rb +10 -8
- data/lib/nitro/compiler/layout.rb +0 -2
- data/lib/nitro/compiler/localization.rb +0 -2
- data/lib/nitro/compiler/markup.rb +14 -6
- data/lib/nitro/compiler/morphing.rb +1 -5
- data/lib/nitro/compiler/script.rb +2 -4
- data/lib/nitro/compiler/squeeze.rb +0 -2
- data/lib/nitro/compiler/xslt.rb +0 -2
- data/lib/nitro/context.rb +10 -5
- data/lib/nitro/control.rb +18 -0
- data/lib/nitro/control/attribute.rb +88 -0
- data/lib/nitro/control/attribute/checkbox.rb +19 -0
- data/lib/nitro/control/attribute/datetime.rb +21 -0
- data/lib/nitro/control/attribute/file.rb +20 -0
- data/lib/nitro/control/attribute/fixnum.rb +26 -0
- data/lib/nitro/control/attribute/float.rb +26 -0
- data/lib/nitro/control/attribute/options.rb +38 -0
- data/lib/nitro/control/attribute/password.rb +16 -0
- data/lib/nitro/control/attribute/text.rb +16 -0
- data/lib/nitro/control/attribute/textarea.rb +16 -0
- data/lib/nitro/control/none.rb +16 -0
- data/lib/nitro/control/relation.rb +53 -0
- data/lib/nitro/control/relation/belongs_to.rb +0 -0
- data/lib/nitro/control/relation/has_many.rb +97 -0
- data/lib/nitro/control/relation/joins_many.rb +0 -0
- data/lib/nitro/control/relation/many_to_many.rb +0 -0
- data/lib/nitro/control/relation/refers_to.rb +29 -0
- data/lib/nitro/controller.rb +7 -296
- data/lib/nitro/dispatcher.rb +72 -34
- data/lib/nitro/element.rb +36 -10
- data/lib/nitro/element/javascript.rb +0 -2
- data/lib/nitro/flash.rb +23 -10
- data/lib/nitro/global.rb +36 -11
- data/lib/nitro/helper.rb +22 -8
- data/lib/nitro/helper/benchmark.rb +0 -2
- data/lib/nitro/helper/buffer.rb +0 -3
- data/lib/nitro/helper/css.rb +12 -0
- data/lib/nitro/helper/debug.rb +1 -3
- data/lib/nitro/helper/default.rb +1 -0
- data/lib/nitro/helper/feed.rb +400 -386
- data/lib/nitro/helper/form.rb +246 -116
- data/lib/nitro/helper/javascript.rb +28 -2
- data/lib/nitro/helper/javascript/morphing.rb +0 -2
- data/lib/nitro/helper/javascript/prototype.rb +0 -2
- data/lib/nitro/helper/javascript/scriptaculous.rb +0 -1
- data/lib/nitro/helper/layout.rb +0 -2
- data/lib/nitro/helper/navigation.rb +87 -0
- data/lib/nitro/helper/pager.rb +11 -22
- data/lib/nitro/helper/table.rb +9 -32
- data/lib/nitro/helper/url.rb +104 -0
- data/lib/nitro/helper/xhtml.rb +20 -4
- data/lib/nitro/helper/xml.rb +0 -2
- data/lib/nitro/markup.rb +131 -0
- data/lib/nitro/part.rb +52 -7
- data/lib/nitro/publishable.rb +328 -0
- data/lib/nitro/render.rb +30 -61
- data/lib/nitro/router.rb +12 -4
- data/lib/nitro/sanitize.rb +48 -0
- data/lib/nitro/scaffold.rb +9 -11
- data/lib/nitro/scaffold/controller.rb +25 -0
- data/lib/nitro/scaffold/model.rb +150 -0
- data/lib/nitro/scaffolding.rb +1 -3
- data/lib/nitro/server.rb +57 -32
- data/lib/nitro/server/drb.rb +16 -2
- data/lib/nitro/server/runner.rb +80 -102
- data/lib/nitro/service.rb +0 -1
- data/lib/nitro/service/xmlrpc.rb +0 -2
- data/lib/nitro/session.rb +26 -18
- data/lib/nitro/session/drb.rb +2 -16
- data/lib/nitro/session/memory.rb +0 -2
- data/lib/nitro/template.rb +219 -0
- data/lib/nitro/test/assertions.rb +1 -3
- data/lib/nitro/test/context.rb +0 -1
- data/lib/nitro/test/testcase.rb +0 -1
- data/lib/nitro/version.rb +6 -0
- data/lib/part/admin.rb +16 -0
- data/lib/part/admin/controller.rb +19 -0
- data/lib/part/admin/helper.rb +30 -0
- data/lib/part/admin/og/controller.rb +114 -0
- data/lib/part/admin/og/customize.rb +4 -0
- data/lib/part/admin/og/template/index.xhtml +27 -0
- data/lib/part/admin/og/template/list.xhtml +38 -0
- data/lib/part/admin/og/template/search.xhtml +20 -0
- data/lib/part/admin/og/template/update.xhtml +25 -0
- data/lib/part/admin/skin.rb +207 -0
- data/lib/part/admin/template/denied.xhtml +13 -0
- data/lib/part/admin/template/index.xhtml +12 -0
- data/lib/part/admin/todo.txt +2 -0
- data/proto/public/error.xhtml +4 -2
- data/proto/run.rb +0 -2
- data/test/glue/tc_webfile.rb +1 -0
- data/test/nitro/cgi/tc_request.rb +23 -0
- data/test/nitro/helper/tc_feed.rb +0 -3
- data/test/nitro/helper/tc_navbar.rb +74 -0
- data/test/nitro/helper/tc_table.rb +2 -0
- data/test/nitro/tc_cgi.rb +72 -19
- data/test/nitro/tc_controller.rb +35 -26
- data/test/nitro/tc_controller_aspect.rb +1 -0
- data/test/nitro/tc_controller_params.rb +864 -0
- data/test/nitro/tc_dispatcher.rb +2 -2
- data/test/nitro/tc_element.rb +16 -16
- data/test/nitro/tc_flash.rb +3 -3
- data/test/nitro/tc_markup.rb +31 -0
- data/test/nitro/tc_render.rb +12 -14
- data/test/nitro/tc_session.rb +9 -7
- data/test/nitro/tc_template.rb +34 -0
- metadata +217 -198
- data/INSTALL +0 -121
- data/ProjectInfo +0 -74
- data/README +0 -555
- data/doc/apache.txt +0 -9
- data/doc/config.txt +0 -28
- data/doc/faq.txt +0 -7
- data/doc/lhttpd.txt +0 -7
- data/lib/nitro/adapter/scgi.rb +0 -239
- data/lib/nitro/helper/form/builder.rb +0 -144
- data/lib/nitro/helper/form/controls.rb +0 -389
- data/lib/nitro/helper/rss.rb +0 -72
- data/proto/conf/apache.conf +0 -51
- data/proto/public/scaffold/advanced_search.xhtml +0 -30
- data/proto/public/scaffold/edit.xhtml +0 -11
- data/proto/public/scaffold/form.xhtml +0 -1
- data/proto/public/scaffold/index.xhtml +0 -20
- data/proto/public/scaffold/list.xhtml +0 -32
- data/proto/public/scaffold/new.xhtml +0 -11
- data/proto/public/scaffold/search.xhtml +0 -29
- data/proto/public/scaffold/view.xhtml +0 -8
- data/proto/script/scgi_ctl +0 -221
- data/proto/script/scgi_service +0 -128
- data/setup.rb +0 -1585
- data/src/part/admin.rb +0 -16
- data/src/part/admin/controller.rb +0 -81
- data/src/part/admin/skin.rb +0 -21
- data/src/part/admin/system.css +0 -135
- data/src/part/admin/template/denied.xhtml +0 -1
- data/src/part/admin/template/index.xhtml +0 -43
- data/test/nitro/helper/tc_rss.rb +0 -24
@@ -0,0 +1,27 @@
|
|
1
|
+
<Page>
|
2
|
+
|
3
|
+
<SitePath>
|
4
|
+
<a href="/">#{Server.map['/'].ann.index[:title] || 'Home'}</a> /
|
5
|
+
<a href="#{AdminController.mount_point}">Admin</a> /
|
6
|
+
Og
|
7
|
+
</SitePath>
|
8
|
+
|
9
|
+
<?r
|
10
|
+
@headers = [ 'Class', 'Count', ' ', ' ', ' ', ' ', ' ' ]
|
11
|
+
@values = @classes.inject([]) do |v, c|
|
12
|
+
name = class_to_name(c)
|
13
|
+
v << [
|
14
|
+
%{<a href="#{R :list, :name, name}">#{c.name.gsub(/::/, ' ')}</a>},
|
15
|
+
c.count,
|
16
|
+
%{<a href="#{R :create, :name, name}">create</a>},
|
17
|
+
%{<a href="#{R :list, :name, name}">list</a>},
|
18
|
+
%{<a href="#{R :search, :name, name}">search</a>},
|
19
|
+
%{<a href="#{R :delete_class, :name, name}" onclick="confirm('Are you sure?')">delete</a>},
|
20
|
+
%{<a href="#{R :destroy_class, :name, name}" onclick="confirm('Are you sure?')">destroy</a>}
|
21
|
+
]
|
22
|
+
end
|
23
|
+
?>
|
24
|
+
|
25
|
+
#{table :headers => @headers, :values => @values, :alternating_rows => true, :class => :data}
|
26
|
+
|
27
|
+
</Page>
|
@@ -0,0 +1,38 @@
|
|
1
|
+
<Page>
|
2
|
+
|
3
|
+
<SitePath>
|
4
|
+
<a href="/">#{Server.map['/'].ann.index[:title] || 'Home'}</a> /
|
5
|
+
<a href="#{AdminController.mount_point}">Admin</a> /
|
6
|
+
<a href="#{OgAdminController.mount_point}">Og</a> /
|
7
|
+
<?r if action_name == 'list' ?>
|
8
|
+
#{@klass.name.gsub(/::/, ' ').plural}
|
9
|
+
<?r else ?>
|
10
|
+
Search results
|
11
|
+
<?r end ?>
|
12
|
+
</SitePath>
|
13
|
+
|
14
|
+
<?r
|
15
|
+
unless @objects.empty?
|
16
|
+
@headers = [ 'Name', ' ', ' ' ]
|
17
|
+
@values = @objects.inject([]) do |v, o|
|
18
|
+
v << [
|
19
|
+
%{<a href="#{R :update, :name, class_to_name(@klass), :oid, o.oid}">#{o}</a>},
|
20
|
+
%{<a href="#{R :update, :name, class_to_name(@klass), :oid, o.oid}">update</a>},
|
21
|
+
%{<a href="#{R :delete, :name, class_to_name(@klass), :oid, o.oid}" onclick="confirm('Are you sure?')">delete</a>}
|
22
|
+
]
|
23
|
+
end
|
24
|
+
?>
|
25
|
+
|
26
|
+
#{table :headers => @headers, :values => @values, :alternating_rows => true, :class => :data}
|
27
|
+
|
28
|
+
<div class="pager" if="@pager and @pager.navigation?">
|
29
|
+
#{@pager.navigation}
|
30
|
+
</div>
|
31
|
+
|
32
|
+
<?r else ?>
|
33
|
+
|
34
|
+
No objects.
|
35
|
+
|
36
|
+
<?r end ?>
|
37
|
+
|
38
|
+
</Page>
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<Page>
|
2
|
+
|
3
|
+
<SitePath>
|
4
|
+
<a href="/">#{Server.map['/'].ann.index[:title] || 'Home'}</a> /
|
5
|
+
<a href="#{AdminController.mount_point}">Admin</a> /
|
6
|
+
<a href="#{OgAdminController.mount_point}">Og</a> /
|
7
|
+
<a href="#{R OgAdminController, :list, :name, @obj.class}">#{@obj.class.name.gsub(/::/, ' ').plural}</a> /
|
8
|
+
Search
|
9
|
+
</SitePath>
|
10
|
+
|
11
|
+
#{form :object => @obj, :action => "#{R :search_results}", :method => :post do |f|
|
12
|
+
f.form_errors
|
13
|
+
f.hidden :object_class_name, class_to_name(@obj.class)
|
14
|
+
f.attributes
|
15
|
+
f.br
|
16
|
+
f.submit 'Search'
|
17
|
+
f.text ' or <a href="' + R(:list, :name, class_to_name(@obj.class)) + '">Cancel</a>'
|
18
|
+
end}
|
19
|
+
|
20
|
+
</Page>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
<Page>
|
2
|
+
|
3
|
+
<SitePath>
|
4
|
+
<a href="/">#{Server.map['/'].ann.index[:title] || 'Home'}</a> /
|
5
|
+
<a href="#{AdminController.mount_point}">Admin</a> /
|
6
|
+
<a href="#{OgAdminController.mount_point}">Og</a> /
|
7
|
+
<a href="#{R OgAdminController, :list, :name, @obj.class}">#{@obj.class.name.gsub(/::/, ' ').plural}</a> /
|
8
|
+
<?r if action_name == 'update' ?>
|
9
|
+
Update '#@obj'
|
10
|
+
<?r else ?>
|
11
|
+
Create new #{@obj.class.name.gsub(/::/, ' ')}
|
12
|
+
<?r end ?>
|
13
|
+
</SitePath>
|
14
|
+
|
15
|
+
#{form :object => @obj, :action => "#{R :save}", :method => :post, :enctype => "multipart/form-data" do |f|
|
16
|
+
f.form_errors
|
17
|
+
f.hidden :object_class_name, class_to_name(@obj.class)
|
18
|
+
f.attributes
|
19
|
+
f.relations
|
20
|
+
f.br
|
21
|
+
f.submit 'Save'
|
22
|
+
f.text ' or <a href="' + R(:list, :name, class_to_name(@obj.class)) + '">Cancel</a>'
|
23
|
+
end}
|
24
|
+
|
25
|
+
</Page>
|
@@ -0,0 +1,207 @@
|
|
1
|
+
module AdminSkin
|
2
|
+
|
3
|
+
class Page
|
4
|
+
|
5
|
+
def head
|
6
|
+
%~
|
7
|
+
<head>
|
8
|
+
<title>\#{sitepath}</title>
|
9
|
+
<meta name="generator" content="nitro" />
|
10
|
+
<meta name="title" content="\#{sitepath}" />
|
11
|
+
<meta name="description" content="Nitro Administration" />
|
12
|
+
<meta name="category" content="portal" />
|
13
|
+
<meta name="robots" content="index, nofollow" />
|
14
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
15
|
+
<!--
|
16
|
+
<link rel="stylesheet" href="/style.css" type="text/css" />
|
17
|
+
<link rel="alternate" type="application/rss+xml" title="Recent changes" href="\#{context.host_url}/feed" />
|
18
|
+
<script type="text/javascript" src="/js/dojo.js">
|
19
|
+
dojo.require('dojo.io.cookie');
|
20
|
+
</script>
|
21
|
+
<script type="text/javascript" src="/js/rounded_corners_lite.inc.js">//</script>
|
22
|
+
-->
|
23
|
+
#{css}
|
24
|
+
</head>
|
25
|
+
~
|
26
|
+
end
|
27
|
+
|
28
|
+
def css
|
29
|
+
%~
|
30
|
+
<style>
|
31
|
+
label {
|
32
|
+
font-weight: bold;
|
33
|
+
display: block;
|
34
|
+
}
|
35
|
+
|
36
|
+
img {
|
37
|
+
border: none;
|
38
|
+
}
|
39
|
+
|
40
|
+
input {
|
41
|
+
border: 1px solid #ccc;
|
42
|
+
font-size: 12px;
|
43
|
+
background: #fff;
|
44
|
+
padding: 2px;
|
45
|
+
}
|
46
|
+
|
47
|
+
textarea {
|
48
|
+
border: 1px solid #ccc;
|
49
|
+
background: #fff;
|
50
|
+
padding: 2px;
|
51
|
+
}
|
52
|
+
|
53
|
+
input:hover, textarea:hover {
|
54
|
+
border: 1px solid #999;
|
55
|
+
}
|
56
|
+
|
57
|
+
input:focus, textarea:focus {
|
58
|
+
border: 1px solid #f00;
|
59
|
+
}
|
60
|
+
|
61
|
+
input.button {
|
62
|
+
color: #fff;
|
63
|
+
background: #999;
|
64
|
+
border: 1px solid #999;
|
65
|
+
font-weight: bold;
|
66
|
+
}
|
67
|
+
|
68
|
+
input.button:hover {
|
69
|
+
background: #f00;
|
70
|
+
border: 1px solid #f00;
|
71
|
+
}
|
72
|
+
|
73
|
+
select {
|
74
|
+
border: 1px solid #ccc;
|
75
|
+
}
|
76
|
+
|
77
|
+
a:hover {
|
78
|
+
color: #f00;
|
79
|
+
}
|
80
|
+
|
81
|
+
/* --- forms --- */
|
82
|
+
|
83
|
+
form dl {
|
84
|
+
width: 100%;
|
85
|
+
margin: 0px;
|
86
|
+
}
|
87
|
+
|
88
|
+
form dt {
|
89
|
+
display: block;
|
90
|
+
margin: 0px;
|
91
|
+
margin-right: 10px;
|
92
|
+
padding-bottom: 10px;
|
93
|
+
font-weight: bold;
|
94
|
+
}
|
95
|
+
|
96
|
+
form dd {
|
97
|
+
display: block;
|
98
|
+
margin: 0px;
|
99
|
+
padding-bottom: 10px;
|
100
|
+
}
|
101
|
+
|
102
|
+
/* --- tables ---*/
|
103
|
+
|
104
|
+
table.data {
|
105
|
+
border-collapse: collapse;
|
106
|
+
}
|
107
|
+
|
108
|
+
.data th {
|
109
|
+
border-bottom: 1px solid #ccc;
|
110
|
+
background: #eee;
|
111
|
+
font-weight: bold;
|
112
|
+
text-align: left;
|
113
|
+
padding: 5px;
|
114
|
+
}
|
115
|
+
|
116
|
+
.data td {
|
117
|
+
border-bottom: 1px solid #ccc;
|
118
|
+
padding: 5px;
|
119
|
+
}
|
120
|
+
|
121
|
+
/* --- pager --- */
|
122
|
+
|
123
|
+
.pager {
|
124
|
+
margin-top: 40px; margin-bottom: 50px;
|
125
|
+
border-top: 1px solid #ccc;
|
126
|
+
background-color: #f0f0f0;
|
127
|
+
}
|
128
|
+
|
129
|
+
.pager .first {
|
130
|
+
float: left;
|
131
|
+
padding: 5px;
|
132
|
+
}
|
133
|
+
|
134
|
+
.pager .previous {
|
135
|
+
float: left;
|
136
|
+
padding: 5px;
|
137
|
+
margin-left: 5px;
|
138
|
+
}
|
139
|
+
|
140
|
+
.pager .next {
|
141
|
+
float: right;
|
142
|
+
padding: 5px;
|
143
|
+
margin-right: 5px;
|
144
|
+
}
|
145
|
+
|
146
|
+
.pager .last {
|
147
|
+
float: right;
|
148
|
+
padding: 5px;
|
149
|
+
}
|
150
|
+
|
151
|
+
.pager ul {
|
152
|
+
float: left;
|
153
|
+
margin: 0px;
|
154
|
+
padding: 0px;
|
155
|
+
}
|
156
|
+
|
157
|
+
.pager li {
|
158
|
+
float: left;
|
159
|
+
display: inline;
|
160
|
+
padding: 5px;
|
161
|
+
padding-left: 10px;
|
162
|
+
padding-right: 10px;
|
163
|
+
background: none;
|
164
|
+
}
|
165
|
+
|
166
|
+
.pager li.active {
|
167
|
+
background-color: #ffa;
|
168
|
+
}
|
169
|
+
|
170
|
+
.noitems {
|
171
|
+
padding: 5px;
|
172
|
+
text-align: center;
|
173
|
+
}
|
174
|
+
</style>
|
175
|
+
~
|
176
|
+
end
|
177
|
+
|
178
|
+
def footer
|
179
|
+
%~
|
180
|
+
<br /><br />
|
181
|
+
Powered by <strong><a href="http://www.nitroproject.org" target="_blank">Nitro</a></strong>.
|
182
|
+
~
|
183
|
+
end
|
184
|
+
|
185
|
+
def render
|
186
|
+
%~
|
187
|
+
<html>
|
188
|
+
#{head}
|
189
|
+
<body>
|
190
|
+
#{content}
|
191
|
+
#{footer}
|
192
|
+
</body>
|
193
|
+
</html>
|
194
|
+
~
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
class SitePath
|
199
|
+
def render
|
200
|
+
%~
|
201
|
+
<h1>#{content}</h1>
|
202
|
+
<br /><br />
|
203
|
+
~
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
207
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<Page>
|
2
|
+
|
3
|
+
<SitePath>
|
4
|
+
<a href="/">#{Server.map['/'].ann.index[:title] || 'Home'}</a> /
|
5
|
+
System / Access denied
|
6
|
+
</SitePath>
|
7
|
+
|
8
|
+
<p>
|
9
|
+
You don't have permission to access this page. Please, return
|
10
|
+
to the <a href="/">home page</a>.
|
11
|
+
</p>
|
12
|
+
|
13
|
+
</Page>
|
data/proto/public/error.xhtml
CHANGED
@@ -44,10 +44,12 @@
|
|
44
44
|
<h1>Error</h1>
|
45
45
|
|
46
46
|
<?r
|
47
|
-
|
47
|
+
response.status = 501
|
48
|
+
|
49
|
+
if Nitro.mode == :debug
|
48
50
|
require 'cgi'
|
49
51
|
?>
|
50
|
-
<?r
|
52
|
+
<?r for error, path in @context.rendering_errors ?>
|
51
53
|
<div class="path"><strong>Path:</strong> #{path}</div>
|
52
54
|
<div class="error"><strong>#{CGI.escapeHTML(error.to_s)}</strong></div>
|
53
55
|
<div class="load">
|
data/proto/run.rb
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
# Please add me!
|
@@ -10,6 +10,7 @@ class TC_Request < Test::Unit::TestCase # :nodoc: all
|
|
10
10
|
|
11
11
|
def initialize
|
12
12
|
@headers = {}
|
13
|
+
@params = {}
|
13
14
|
end
|
14
15
|
end
|
15
16
|
|
@@ -34,5 +35,27 @@ class TC_Request < Test::Unit::TestCase # :nodoc: all
|
|
34
35
|
req.instance_variable_set '@post_format', nil
|
35
36
|
req.headers['CONTENT_TYPE'] = 'text/xml'
|
36
37
|
assert req.xml_post?
|
38
|
+
|
39
|
+
req['test'] = 'hello'
|
40
|
+
assert req['test']
|
41
|
+
assert_equal 'hello', req['test']
|
42
|
+
assert req.has?('test')
|
43
|
+
|
44
|
+
assert !req.has?('phantom')
|
45
|
+
|
46
|
+
req['bug'] = nil
|
47
|
+
assert !req.has?('bug')
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_local_net?
|
51
|
+
req = DummyRequest.new
|
52
|
+
|
53
|
+
local_ips = ["192.168.1.1", "192.168.20.1", "192.168.99.1", "192.168.200.1", "192.168.21.245", "192.168.90.34", "192.168.254.254", "172.16.1.1", "172.18.1.1", "172.31.254.1", "172.21.1.254", "10.16.1.1", "10.0.1.1", "10.254.1.254", "10.192.1.192", "10.254.254.254", "10.10.10.10"]
|
54
|
+
|
55
|
+
not_local_ips = ["191.168.1.1", "192.169.20.1", "193.168.254.254", "172.15.1.1", "171.18.1.1", "172.32.0.0", "173.21.1.254", "11.16.1.1", "66.249.93.104", "72.14.221.104", "66.102.9.104", "17.254.3.183", "207.46.250.119", "207.46.130.108", "207.68.160.190", "65.54.240.126", "213.199.144.151", "65.55.238.126"]
|
56
|
+
|
57
|
+
assert_equal true, local_ips.map { |ip| req.local_net?(ip) }.all?
|
58
|
+
assert_equal true, not_local_ips.map { |ip| req.local_net?(ip) }.all?{|v|!v}
|
37
59
|
end
|
60
|
+
|
38
61
|
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'CONFIG.rb')
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'nitro/helper/navigation'
|
5
|
+
|
6
|
+
|
7
|
+
class TC_NavigationHelper < Test::Unit::TestCase # :nodoc: all
|
8
|
+
include Nitro
|
9
|
+
include NavigationHelper
|
10
|
+
FirstController = Class.new(Controller) do
|
11
|
+
def self.mount_path() "controller1" end
|
12
|
+
end
|
13
|
+
Second = Class.new(Controller) do
|
14
|
+
def self.mount_path() "controller2" end
|
15
|
+
end
|
16
|
+
MockRequest=Struct.new(:path)
|
17
|
+
attr :request
|
18
|
+
def setup
|
19
|
+
@request=MockRequest.new("controller1")
|
20
|
+
end
|
21
|
+
def check_div(text)
|
22
|
+
#offsets accomodate \n
|
23
|
+
assert_equal '<div id="navcontainer">',text[0,23]
|
24
|
+
assert_equal '</div>',text[-8,6]
|
25
|
+
end
|
26
|
+
def check_ul(text)
|
27
|
+
assert_equal '<ul id="navlist">',text[25,17]
|
28
|
+
assert_equal '</ul>',text[-14,5]
|
29
|
+
end
|
30
|
+
def test_navfor_around_html
|
31
|
+
text= menu_for(FirstController)
|
32
|
+
check_div(text)
|
33
|
+
check_ul(text)
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_navfor_inner_html_single
|
37
|
+
text= menu_for(FirstController)
|
38
|
+
text.gsub!(%r{</?(div|ul).*?>},'')
|
39
|
+
text.gsub!("\n",'')
|
40
|
+
assert_equal '<li id="active"><a href="controller1" id="current"> TC_NavigationHelper::First </a></li>',
|
41
|
+
text.strip
|
42
|
+
end
|
43
|
+
def test_navfor_inner_html_many
|
44
|
+
text = menu_for(FirstController,Second)
|
45
|
+
assert_match %r|href="controller1" id="current">| , text
|
46
|
+
assert_match %r|href="controller2">| , text
|
47
|
+
assert_match %r| TC_NavigationHelper::First | , text
|
48
|
+
assert_match %r| TC_NavigationHelper::Second |, text
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_navfor_yielding
|
52
|
+
text= menu_for(FirstController,Second) do |controller|
|
53
|
+
controller==FirstController ? 'first' : 'second'
|
54
|
+
end
|
55
|
+
assert_match %r|<a href="controller1".*first </a>|,text
|
56
|
+
assert_match %r|<a href="controller2".*second </a>|,text
|
57
|
+
end
|
58
|
+
def test_navforhash_around_html
|
59
|
+
text= menu_from_hash('path'=>'text')
|
60
|
+
check_div(text)
|
61
|
+
check_ul(text)
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_navforhash_inner_html_single
|
65
|
+
text= menu_from_hash('link'=>'text')
|
66
|
+
text.gsub!(%r{</?(div|ul).*?>},'')
|
67
|
+
text.gsub!("\n",'')
|
68
|
+
assert_equal '<li><a href="link"> text </a></li>',
|
69
|
+
text.strip
|
70
|
+
end
|
71
|
+
|
72
|
+
|
73
|
+
|
74
|
+
end
|