nitro 0.25.0 → 0.26.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +531 -1
- data/ProjectInfo +29 -5
- data/README +1 -1
- data/doc/AUTHORS +12 -6
- data/doc/RELEASES +114 -0
- data/lib/glue/sweeper.rb +71 -0
- data/lib/nitro.rb +19 -12
- data/lib/nitro/adapter/cgi.rb +4 -0
- data/lib/nitro/adapter/webrick.rb +4 -2
- data/lib/nitro/caching.rb +1 -0
- data/lib/nitro/caching/fragments.rb +7 -1
- data/lib/nitro/caching/output.rb +6 -1
- data/lib/nitro/caching/stores.rb +13 -1
- data/lib/nitro/cgi.rb +9 -1
- data/lib/nitro/cgi/request.rb +11 -3
- data/lib/nitro/cgi/utils.rb +24 -2
- data/lib/nitro/compiler.rb +89 -63
- data/lib/nitro/compiler/cleanup.rb +16 -0
- data/lib/nitro/compiler/elements.rb +117 -0
- data/lib/nitro/compiler/markup.rb +3 -1
- data/lib/nitro/compiler/morphing.rb +203 -73
- data/lib/nitro/compiler/script_generator.rb +14 -0
- data/lib/nitro/compiler/shaders.rb +1 -1
- data/lib/nitro/context.rb +5 -6
- data/lib/nitro/controller.rb +43 -21
- data/lib/nitro/dispatcher.rb +86 -37
- data/lib/nitro/element.rb +3 -105
- data/lib/nitro/helper/benchmark.rb +3 -0
- data/lib/nitro/helper/dojo.rb +0 -0
- data/lib/nitro/helper/form.rb +85 -255
- data/lib/nitro/helper/form/controls.rb +274 -0
- data/lib/nitro/helper/javascript.rb +86 -6
- data/lib/nitro/helper/pager.rb +5 -0
- data/lib/nitro/helper/prototype.rb +49 -0
- data/lib/nitro/helper/scriptaculous.rb +0 -0
- data/lib/nitro/helper/xhtml.rb +11 -8
- data/lib/nitro/helper/xml.rb +1 -1
- data/lib/nitro/routing.rb +8 -1
- data/lib/nitro/scaffolding.rb +344 -0
- data/lib/nitro/server.rb +5 -1
- data/lib/nitro/server/runner.rb +19 -15
- data/lib/nitro/session.rb +32 -56
- data/lib/nitro/session/drbserver.rb +1 -1
- data/lib/nitro/session/file.rb +34 -15
- data/lib/nitro/session/memory.rb +13 -4
- data/lib/nitro/session/og.rb +56 -0
- data/proto/public/js/controls.js +30 -1
- data/proto/public/js/dragdrop.js +211 -146
- data/proto/public/js/effects.js +261 -399
- data/proto/public/js/prototype.js +131 -72
- data/proto/public/scaffold/edit.xhtml +10 -3
- data/proto/public/scaffold/form.xhtml +1 -7
- data/proto/public/scaffold/index.xhtml +20 -0
- data/proto/public/scaffold/list.xhtml +15 -8
- data/proto/public/scaffold/new.xhtml +10 -3
- data/proto/public/scaffold/search.xhtml +28 -0
- data/proto/public/scaffold/view.xhtml +8 -0
- data/proto/run.rb +93 -1
- data/src/part/admin.rb +4 -2
- data/src/part/admin/controller.rb +62 -28
- data/src/part/admin/skin.rb +8 -8
- data/src/part/admin/system.css +135 -0
- data/src/part/admin/template/index.xhtml +8 -12
- data/test/nitro/caching/tc_stores.rb +17 -0
- data/test/nitro/tc_caching.rb +1 -4
- data/test/nitro/tc_dispatcher.rb +22 -10
- data/test/nitro/tc_element.rb +1 -1
- data/test/nitro/tc_session.rb +23 -11
- data/test/public/blog/another/very_litle/index.xhtml +1 -0
- metadata +29 -15
- data/lib/nitro/dispatcher/general.rb +0 -62
- data/lib/nitro/dispatcher/nice.rb +0 -57
- data/lib/nitro/scaffold.rb +0 -171
- data/proto/public/index.xhtml +0 -83
- data/proto/public/js/scaffold.js +0 -74
- data/proto/public/settings.xhtml +0 -66
@@ -1,18 +1,25 @@
|
|
1
|
-
<SystemPage
|
2
|
-
|
3
|
-
<
|
4
|
-
|
1
|
+
<SystemPage>
|
2
|
+
<?r base = "#{@base}/%base%" ?>
|
3
|
+
<h1><a href="/"> Home</a> > <a href="#@base">System</a> > #{"%plural%".humanize}</h1>
|
4
|
+
<a href="#{base}/new">New %name%</a>
|
5
|
+
<p>
|
6
|
+
<form action="#{base}/search">
|
7
|
+
Search %plural%: <input type="text" name="q" /> <input type="submit" value="Search" />
|
5
8
|
</form>
|
9
|
+
</p>
|
6
10
|
<table>
|
7
|
-
<?r for obj in
|
11
|
+
<?r for obj in @list ?>
|
8
12
|
<tr>
|
9
|
-
<td width="100%"><a href="
|
13
|
+
<td width="100%"><a href="#{base}/edit/#{obj.oid}">#(obj.to_s)</a></td>
|
10
14
|
<?r if obj.respond_to?(:update_time) ?>
|
11
15
|
<td nowrap="1">#{obj.update_time.stamp(:db)}</td>
|
12
16
|
<?r end ?>
|
13
|
-
<td><a href="
|
14
|
-
<td><a href="
|
17
|
+
<td><a href="#{base}/edit/#{obj.oid}">edit</a></td>
|
18
|
+
<td><a href="#{base}/delete/#{obj.oid}" onclick="confirm('Are you sure?')">del</a></td>
|
15
19
|
</tr>
|
16
20
|
<?r end ?>
|
17
21
|
</table>
|
22
|
+
<div class="pager" if="@pager and @pager.navigation?">
|
23
|
+
#{@pager.navigation}
|
24
|
+
</div>
|
18
25
|
</SystemPage>
|
@@ -1,4 +1,11 @@
|
|
1
|
-
<SystemPage
|
2
|
-
|
3
|
-
#{
|
1
|
+
<SystemPage>
|
2
|
+
<?r base = "#{@base}/%base%" ?>
|
3
|
+
<h1><a href="/"> Home</a> > <a href="#@base">System</a> > <a href="#{base}/list">#{"%plural%".humanize}</a> > New %name%</h1>
|
4
|
+
<?r if @all ?>
|
5
|
+
<a href="#{request.uri.gsub(/\/all$/, '')}">Show editable</a>
|
6
|
+
#{form_for @obj, :action => "#{base}/save", :cancel => "#{base}/list", :all => true}
|
7
|
+
<?r else ?>
|
8
|
+
<a href="#{request.uri}/all">Show all</a>
|
9
|
+
#{form_for @obj, :action => "#{base}/save", :cancel => "#{base}/list"}
|
10
|
+
<?r end ?>
|
4
11
|
</SystemPage>
|
@@ -0,0 +1,28 @@
|
|
1
|
+
<SystemPage>
|
2
|
+
<?r base = "#{@base}/%base%" ?>
|
3
|
+
<h1><a href="/"> Home</a> > <a href="#@base">System</a> > <a href="#{base}/list">#{"%plural%".humanize}</a> > Search for '#@query'</h1>
|
4
|
+
<p>
|
5
|
+
<form action="#{base}/search">
|
6
|
+
Search %plural%: <input type="text" name="q" /> <input type="submit" value="Search" />
|
7
|
+
</form>
|
8
|
+
</p>
|
9
|
+
<?r if @list.nil? ?>
|
10
|
+
<p>Search method is not implemented for this object</p>
|
11
|
+
<?r else ?>
|
12
|
+
<table>
|
13
|
+
<?r for obj in @list ?>
|
14
|
+
<tr>
|
15
|
+
<td width="100%"><a href="#{base}/edit/#{obj.oid}">#(obj.to_s)</a></td>
|
16
|
+
<?r if obj.respond_to?(:update_time) ?>
|
17
|
+
<td nowrap="1">#{obj.update_time.stamp(:db)}</td>
|
18
|
+
<?r end ?>
|
19
|
+
<td><a href="#{base}/edit/#{obj.oid}">edit</a></td>
|
20
|
+
<td><a href="#{base}/delete/#{obj.oid}">del</a></td>
|
21
|
+
</tr>
|
22
|
+
<?r end ?>
|
23
|
+
</table>
|
24
|
+
<div class="pager" if="@pager and @pager.navigation?">
|
25
|
+
#{@pager.navigation}
|
26
|
+
</div>
|
27
|
+
<?r end ?>
|
28
|
+
</SystemPage>
|
data/proto/run.rb
CHANGED
@@ -2,4 +2,96 @@
|
|
2
2
|
|
3
3
|
require 'nitro'
|
4
4
|
|
5
|
-
|
5
|
+
# The prototype controller.
|
6
|
+
|
7
|
+
class Proto
|
8
|
+
def index
|
9
|
+
%{
|
10
|
+
<html>
|
11
|
+
<head>
|
12
|
+
<title>Nitro, Feel the magic!</title>
|
13
|
+
<style>
|
14
|
+
body { margin: 10px; background-color: #fff; color: #333; }
|
15
|
+
|
16
|
+
body, p, ol, ul, td {
|
17
|
+
font-family: verdana, arial, helvetica, sans-serif;
|
18
|
+
font-size: 12px;
|
19
|
+
line-height: 18px;
|
20
|
+
}
|
21
|
+
|
22
|
+
h1 { margin-top: 15px; margin-bottom: 45px; }
|
23
|
+
|
24
|
+
li {
|
25
|
+
margin-bottom: 7px;
|
26
|
+
}
|
27
|
+
|
28
|
+
pre {
|
29
|
+
background-color: #eee;
|
30
|
+
padding: 10px;
|
31
|
+
font-size: 11px;
|
32
|
+
}
|
33
|
+
|
34
|
+
a { color: #000; }
|
35
|
+
a:visited { color: #666; }
|
36
|
+
a:hover { color: #fff; background-color:#000; }
|
37
|
+
|
38
|
+
img { border: none; }
|
39
|
+
</style>
|
40
|
+
</head>
|
41
|
+
<body>
|
42
|
+
|
43
|
+
<a href="http://nitro.rubyforge.org" target="_blank"><img src="media/nitro.png" /></a>
|
44
|
+
|
45
|
+
<h1>You have successfully installed Nitro!</h1>
|
46
|
+
|
47
|
+
<p><b>Before you move on</b>, verify that the following conditions have been met:</p>
|
48
|
+
|
49
|
+
<ol>
|
50
|
+
<li>The log directory and the empty log files must be writable to the web server (<code>chmod -R 666 log/*</code>).</li>
|
51
|
+
<li>
|
52
|
+
The shebang line in the ctl file must reference your Ruby installation. <br/>
|
53
|
+
You might need to change it to <code>#!/usr/bin/env ruby</code> or point directly at the installation.
|
54
|
+
</li>
|
55
|
+
</ol>
|
56
|
+
|
57
|
+
<p>Have a look at the <b>examples</b>:</p>
|
58
|
+
|
59
|
+
<ol>
|
60
|
+
<li><b>examples/blog</b>: A simple Blog, featuring a nice XSLT based template.</li>
|
61
|
+
<li><b>examples/no_xsl_blog</b>: The same example without using XSLT (easier to setup under Windows).</li>
|
62
|
+
<li><b>examples/why_wiki</b>: A conversion of why_'s wiki.</li>
|
63
|
+
<li><b>examples/wee_style</b>: A Wee-style (ruby code only) example.</li>
|
64
|
+
<li><b>examples/ajax</b>: Implement Google suggest-style functionality using ajax techniques.</li>
|
65
|
+
<li><b>examples/tiny</b>: A small example to verify your installation.</li>
|
66
|
+
</ol>
|
67
|
+
|
68
|
+
<p>Here is <b>what do next</b>:</p>
|
69
|
+
|
70
|
+
<ol>
|
71
|
+
<li>Add your xhtml files in the 'public' directory. Those files are
|
72
|
+
automagically converted to controller actions by Nitro
|
73
|
+
</li>
|
74
|
+
<li>Place additional media files, css, or xsl files in the public directory.</li>
|
75
|
+
<li>Create your models and controllers.</li>
|
76
|
+
<li>Develop your application utilizing Nitro's powerful features.</li>
|
77
|
+
</ol>
|
78
|
+
|
79
|
+
<br />
|
80
|
+
|
81
|
+
<p>
|
82
|
+
<b>Having problems getting up and running?</b><br />
|
83
|
+
First try debugging it yourself by looking at the log files.
|
84
|
+
If you get stuck, post your problem to the <a href="http://rubyforge.org/mailman/listinfo/nitro-general">Nitro Mailing
|
85
|
+
List</a> at <a href="http://www.rubyforge.com">Rubyforge</a>.
|
86
|
+
</p>
|
87
|
+
|
88
|
+
<br /><br />
|
89
|
+
</body>
|
90
|
+
</html>
|
91
|
+
}
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
Nitro.run(Proto)
|
96
|
+
|
97
|
+
# * George Moschovitis <gm@navel.gr>
|
data/src/part/admin.rb
CHANGED
@@ -1,47 +1,81 @@
|
|
1
|
+
require 'nano/kernel/constant'
|
2
|
+
require 'nano/time/stamp'
|
3
|
+
|
1
4
|
require 'nitro/controller'
|
2
|
-
|
5
|
+
|
3
6
|
|
4
7
|
# Provides an automatically generated Administration
|
5
8
|
# interface.
|
6
9
|
|
7
10
|
class AdminController < Nitro::Controller
|
8
|
-
|
11
|
+
|
12
|
+
# Run a simple security check function before each action
|
13
|
+
|
14
|
+
before :check_security, :except => [ :denied ]
|
15
|
+
|
16
|
+
# scaffold all the classes
|
17
|
+
|
18
|
+
scaffold_all
|
19
|
+
|
20
|
+
# Default to views in part dir
|
9
21
|
|
10
22
|
def self.template_root
|
11
23
|
File.join(File.dirname(__FILE__), 'template')
|
12
24
|
end
|
13
25
|
|
26
|
+
# default method for controller
|
27
|
+
|
14
28
|
def index
|
15
|
-
@classes = self.class.
|
29
|
+
@classes = self.class.scaffolding_classes.keys
|
16
30
|
end
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
31
|
+
|
32
|
+
# Delete all instances of the class.
|
33
|
+
# Useful in development mode.
|
34
|
+
|
35
|
+
def delete_all(klass)
|
36
|
+
constant(klass).delete_all
|
37
|
+
redirect_to_referer
|
38
|
+
end
|
39
|
+
|
40
|
+
# Drop the schema (typically the DB tables) used to
|
41
|
+
# store the class instances.
|
42
|
+
|
43
|
+
def destroy(klass)
|
44
|
+
constant(klass).delete_all
|
45
|
+
redirect_to_referer
|
46
|
+
end
|
47
|
+
|
48
|
+
# fetch the css for this controller
|
49
|
+
# checks for a /system.css file and uses that if available
|
50
|
+
# otherwise uses system.css from the part/admin dir
|
51
|
+
|
52
|
+
def stylesheet(sheet='system')
|
53
|
+
sheet << ".css"
|
54
|
+
[Server.public_root, File.dirname(__FILE__)].each do |path|
|
55
|
+
css_file = File.join(path, sheet)
|
56
|
+
if File.exists? css_file
|
57
|
+
response.content_type = 'text/css'
|
58
|
+
@out << File.read(css_file)
|
59
|
+
raise RenderExit
|
40
60
|
end
|
41
|
-
end
|
61
|
+
end
|
62
|
+
raise "stylesheet not found"
|
63
|
+
end
|
64
|
+
alias_action :stylesheets, :stylesheet
|
65
|
+
|
66
|
+
private
|
67
|
+
|
68
|
+
# Overload in your application to suit your
|
69
|
+
# needs. The default implementation does NOT apply security
|
70
|
+
# in debug mode.The default implementation requires the
|
71
|
+
# existense of an :ADMIN key in the session, so you can
|
72
|
+
# easily integrate this in your user/roles management code.
|
42
73
|
|
74
|
+
def check_security
|
75
|
+
return true if Nitro::Runner.mode == :debug
|
76
|
+
redirect 'denied' unless session[:ADMIN]
|
43
77
|
end
|
44
78
|
|
45
79
|
end
|
46
80
|
|
47
|
-
# * George Moschovitis <gm@navel.gr>
|
81
|
+
# * George Moschovitis <gm@navel.gr>
|
data/src/part/admin/skin.rb
CHANGED
@@ -5,23 +5,23 @@ class SystemPage < Nitro::Element
|
|
5
5
|
%~
|
6
6
|
<html>
|
7
7
|
<head>
|
8
|
-
<title
|
9
|
-
<base href="\#{context.host_url}/" />
|
10
|
-
<
|
8
|
+
<title>System</title>
|
9
|
+
<base href="\#{context.host_url}\#{base}/" />
|
10
|
+
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
11
|
+
<!--
|
11
12
|
<script src="/js/behaviour.js" type="text/javascript"> </script>
|
12
13
|
<script src="/js/prototype.js" type="text/javascript"> </script>
|
13
14
|
<script src="/js/effects.js" type="text/javascript"> </script>
|
14
15
|
<script src="/js/dragdrop.js" type="text/javascript"> </script>
|
15
16
|
<script src="/js/controls.js" type="text/javascript"> </script>
|
16
|
-
|
17
|
+
-->
|
18
|
+
<link rel="stylesheet" href="stylesheet/system" type="text/css" media="screen" />
|
17
19
|
</head>
|
18
20
|
<body>
|
19
|
-
<h1
|
21
|
+
<h1>#@title</h1>
|
20
22
|
#{content}
|
21
|
-
<
|
22
|
-
Powered by <a href="http://www.nitrohq.com">Nitro</a> version #{Nitro::Version}
|
23
|
+
<p>Powered by <a href="http://www.nitrohq.com">Nitro</a> version #{Nitro::Version}</p>
|
23
24
|
</body>
|
24
|
-
<script type="text/javascript" src="js/scaffold.js" />
|
25
25
|
</html>
|
26
26
|
~
|
27
27
|
end
|
@@ -0,0 +1,135 @@
|
|
1
|
+
img {
|
2
|
+
border: none;
|
3
|
+
}
|
4
|
+
|
5
|
+
input {
|
6
|
+
border: 1px solid #ccc;
|
7
|
+
font-size: 12px;
|
8
|
+
background: #fff;
|
9
|
+
padding: 2px;
|
10
|
+
}
|
11
|
+
|
12
|
+
textarea {
|
13
|
+
border: 1px solid #ccc;
|
14
|
+
background: #fff;
|
15
|
+
padding: 2px;
|
16
|
+
}
|
17
|
+
|
18
|
+
input:hover, textarea:hover {
|
19
|
+
border: 1px solid #999;
|
20
|
+
}
|
21
|
+
|
22
|
+
input:focus, textarea:focus {
|
23
|
+
border: 1px solid #f00;
|
24
|
+
}
|
25
|
+
|
26
|
+
input.button {
|
27
|
+
color: #fff;
|
28
|
+
background: #999;
|
29
|
+
border: 1px solid #999;
|
30
|
+
font-weight: bold;
|
31
|
+
}
|
32
|
+
|
33
|
+
input.button:hover {
|
34
|
+
background: #f00;
|
35
|
+
border: 1px solid #f00;
|
36
|
+
}
|
37
|
+
|
38
|
+
select {
|
39
|
+
border: 1px solid #ccc;
|
40
|
+
}
|
41
|
+
|
42
|
+
table {
|
43
|
+
width: 100%;
|
44
|
+
border-collapse: collapse;
|
45
|
+
}
|
46
|
+
|
47
|
+
table th {
|
48
|
+
padding: 5px;
|
49
|
+
background: #eee;
|
50
|
+
border: 1px solid #ccc;
|
51
|
+
}
|
52
|
+
|
53
|
+
table td {
|
54
|
+
padding: 5px;
|
55
|
+
border: 1px solid #ccc;
|
56
|
+
}
|
57
|
+
|
58
|
+
/* --- forms --- */
|
59
|
+
|
60
|
+
form dl {
|
61
|
+
width: 100%;
|
62
|
+
margin: 0px;
|
63
|
+
}
|
64
|
+
|
65
|
+
form dt {
|
66
|
+
display: block;
|
67
|
+
margin: 0px;
|
68
|
+
margin-right: 10px;
|
69
|
+
padding-bottom: 10px;
|
70
|
+
font-weight: bold;
|
71
|
+
}
|
72
|
+
|
73
|
+
form dd {
|
74
|
+
display: block;
|
75
|
+
margin: 0px;
|
76
|
+
padding-bottom: 10px;
|
77
|
+
}
|
78
|
+
|
79
|
+
input {
|
80
|
+
border: 1px solid #ccc;
|
81
|
+
}
|
82
|
+
|
83
|
+
textarea {
|
84
|
+
width: 90%;
|
85
|
+
height: 200px;
|
86
|
+
}
|
87
|
+
|
88
|
+
/* --- pager --- */
|
89
|
+
|
90
|
+
.pager {
|
91
|
+
margin-top: 40px; margin-bottom: 50px;
|
92
|
+
border-top: 1px solid #ccc;
|
93
|
+
background-color: #f0f0f0;
|
94
|
+
}
|
95
|
+
|
96
|
+
.pager .first {
|
97
|
+
float: left;
|
98
|
+
padding: 5px;
|
99
|
+
}
|
100
|
+
|
101
|
+
.pager .previous {
|
102
|
+
float: left;
|
103
|
+
padding: 5px;
|
104
|
+
margin-left: 5px;
|
105
|
+
}
|
106
|
+
|
107
|
+
.pager .next {
|
108
|
+
float: right;
|
109
|
+
padding: 5px;
|
110
|
+
margin-right: 5px;
|
111
|
+
}
|
112
|
+
|
113
|
+
.pager .last {
|
114
|
+
float: right;
|
115
|
+
padding: 5px;
|
116
|
+
}
|
117
|
+
|
118
|
+
.pager ul {
|
119
|
+
float: left;
|
120
|
+
margin: 0px;
|
121
|
+
padding: 0px;
|
122
|
+
}
|
123
|
+
|
124
|
+
.pager li {
|
125
|
+
float: left;
|
126
|
+
display: inline;
|
127
|
+
padding: 5px;
|
128
|
+
padding-left: 10px;
|
129
|
+
padding-right: 10px;
|
130
|
+
background: none;
|
131
|
+
}
|
132
|
+
|
133
|
+
.pager li.active {
|
134
|
+
background-color: #ffa;
|
135
|
+
}
|