nitro 0.9.5 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/ChangeLog +260 -0
- data/INSTALL +60 -0
- data/LICENSE +1 -0
- data/README +19 -20
- data/RELEASES +48 -0
- data/Rakefile +102 -92
- data/benchmark/og/bench.rb +74 -0
- data/benchmark/og/sqlite-no-prepare.1.txt +13 -0
- data/benchmark/og/sqlite-no-prepare.2.txt +13 -0
- data/benchmark/og/sqlite-prepare.1.txt +13 -0
- data/benchmark/og/sqlite-prepare.2.txt +13 -0
- data/bin/cluster +1 -1
- data/bin/nitro +3 -0
- data/bin/proto/conf/app.conf.rb +2 -10
- data/examples/README.windows +9 -0
- data/examples/blog/README +16 -4
- data/examples/blog/lib/blog.rb +3 -3
- data/examples/blog/lib/blog/controller.rb +7 -9
- data/examples/blog/root/fcgi.rb +2 -4
- data/examples/blog/root/style.xsl +4 -6
- data/examples/blog/run.rb +41 -0
- data/examples/flash/run.rb +9 -0
- data/examples/no_xsl_blog/README +0 -1
- data/examples/no_xsl_blog/conf/app.conf.rb +6 -13
- data/examples/no_xsl_blog/lib/blog.rb +2 -2
- data/examples/no_xsl_blog/lib/blog/controller.rb +6 -6
- data/examples/no_xsl_blog/root/fcgi.rb +2 -4
- data/examples/no_xsl_blog/run.rb +38 -0
- data/examples/og/mock_example.rb +0 -2
- data/examples/og/mysql_to_psql.rb +0 -2
- data/examples/og/run.rb +23 -22
- data/examples/tiny/root/fcgi.rb +2 -4
- data/examples/tiny/root/index.xhtml +21 -5
- data/examples/tiny/root/upload.xhtml +23 -0
- data/examples/tiny/run.rb +9 -0
- data/examples/wee_style/{wee.rb → run.rb} +13 -13
- data/install.rb +44 -0
- data/lib/glue/array.rb +6 -10
- data/lib/glue/attribute.rb +0 -3
- data/lib/glue/cache.rb +1 -1
- data/lib/glue/inflector.rb +5 -5
- data/lib/glue/mixins.rb +3 -12
- data/lib/glue/number.rb +1 -1
- data/lib/glue/object.rb +7 -1
- data/lib/glue/property.rb +32 -22
- data/lib/glue/string.rb +13 -75
- data/lib/glue/time.rb +2 -2
- data/lib/glue/validation.rb +7 -11
- data/lib/nitro.rb +16 -1
- data/lib/nitro/{adaptors → adapters}/cgi.rb +101 -20
- data/lib/nitro/{adaptors → adapters}/fastcgi.rb +3 -2
- data/lib/nitro/{adaptors → adapters}/webrick.rb +4 -4
- data/lib/nitro/builders/rss.rb +1 -1
- data/lib/nitro/builders/xml.rb +8 -10
- data/lib/nitro/cluster.rb +1 -1
- data/lib/nitro/conf.rb +34 -0
- data/lib/nitro/controller.rb +8 -9
- data/lib/nitro/dispatcher.rb +38 -11
- data/lib/nitro/filters.rb +1 -1
- data/lib/nitro/markup.rb +14 -1
- data/lib/nitro/render.rb +7 -10
- data/lib/nitro/runner.rb +232 -0
- data/lib/nitro/ui/pager.rb +2 -6
- data/lib/nitro/uri.rb +7 -11
- data/lib/og.rb +27 -261
- data/lib/og/adapter.rb +352 -0
- data/lib/og/adapters/mysql.rb +304 -0
- data/lib/og/adapters/psql.rb +286 -0
- data/lib/og/adapters/sqlite.rb +262 -0
- data/lib/og/backend.rb +1 -1
- data/lib/og/connection.rb +123 -87
- data/lib/og/database.rb +268 -0
- data/lib/og/meta.rb +23 -22
- data/lib/og/mock.rb +2 -3
- data/lib/xsl/base.xsl +1 -55
- data/test/glue/tc_property.rb +2 -0
- data/test/glue/tc_property_type_checking.rb +32 -0
- data/test/glue/tc_strings.rb +2 -2
- data/test/glue/tc_validation.rb +2 -0
- data/test/nitro/adapters/raw_post1.bin +0 -0
- data/test/nitro/{adaptors → adapters}/tc_cgi.rb +11 -2
- data/test/nitro/{adaptors → adapters}/tc_webrick.rb +3 -3
- data/test/nitro/builders/tc_xml.rb +14 -5
- data/test/nitro/tc_dispatcher.rb +3 -3
- data/test/nitro/tc_uri.rb +2 -4
- data/test/og/tc_lifecycle.rb +22 -25
- data/test/og/tc_sqlite.rb +87 -0
- data/test/tc_og.rb +61 -42
- metadata +67 -33
- data/examples/blog/conf/app.conf.rb +0 -52
- data/examples/blog/ctl +0 -4
- data/examples/flash/conf/app.conf.rb +0 -21
- data/examples/flash/ctl +0 -4
- data/examples/no_xsl_blog/conf/apache.conf +0 -0
- data/examples/no_xsl_blog/ctl +0 -4
- data/examples/tiny/conf/app.conf.rb +0 -17
- data/examples/tiny/ctl +0 -4
- data/lib/glue/macro.rb +0 -56
- data/lib/nitro/adaptors/runner.rb +0 -123
- data/lib/nitro/version.rb +0 -15
- data/lib/og/backends/mysql.rb +0 -370
- data/lib/og/backends/psql.rb +0 -386
- data/lib/og/backends/sqlite.rb +0 -383
- data/lib/og/version.rb +0 -9
data/examples/blog/lib/blog.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# * George Moschovitis <gm@navel.gr>
|
|
2
2
|
# (c) 2004-2005 Navel, all rights reserved.
|
|
3
|
-
# $Id: blog.rb
|
|
3
|
+
# $Id: blog.rb 259 2005-02-15 08:54:54Z gmosx $
|
|
4
4
|
|
|
5
5
|
# A simple blog to demonstrate the power of Nitro.
|
|
6
6
|
|
|
@@ -16,5 +16,5 @@ class Blog
|
|
|
16
16
|
|
|
17
17
|
end
|
|
18
18
|
|
|
19
|
-
require 'blog/model'
|
|
20
|
-
require 'blog/controller'
|
|
19
|
+
require 'lib/blog/model'
|
|
20
|
+
require 'lib/blog/controller'
|
|
@@ -6,26 +6,26 @@ require 'nitro/controller'
|
|
|
6
6
|
require 'nitro/builders/rss'
|
|
7
7
|
require 'nitro/ui/pager'
|
|
8
8
|
|
|
9
|
-
require 'blog/model'
|
|
9
|
+
require 'lib/blog/model'
|
|
10
10
|
|
|
11
11
|
# The controller of the Blog part.
|
|
12
12
|
|
|
13
13
|
class BlogController < N::Controller
|
|
14
14
|
|
|
15
15
|
before_filter :get_errors
|
|
16
|
-
|
|
16
|
+
after_filter :cache
|
|
17
17
|
|
|
18
18
|
scaffold BlogEntry, :name => 'entry', :index => true
|
|
19
19
|
scaffold Comment
|
|
20
20
|
|
|
21
21
|
def list_entry
|
|
22
|
-
@pager = UI::Pager.new('entries',
|
|
22
|
+
@pager = UI::Pager.new('entries', request, 3)
|
|
23
23
|
@entries = BlogEntry.all("ORDER BY oid DESC #{@pager.sql_limit}")
|
|
24
24
|
@pager.set(BlogEntry.count)
|
|
25
25
|
end
|
|
26
26
|
|
|
27
27
|
def new_entry
|
|
28
|
-
entry =
|
|
28
|
+
entry = request.fill(BlogEntry.new)
|
|
29
29
|
entry.author = session[:username]
|
|
30
30
|
|
|
31
31
|
unless entry.valid?
|
|
@@ -43,7 +43,7 @@ class BlogController < N::Controller
|
|
|
43
43
|
end
|
|
44
44
|
|
|
45
45
|
def new_comment
|
|
46
|
-
comment =
|
|
46
|
+
comment = request.fill(Comment.new)
|
|
47
47
|
|
|
48
48
|
unless comment.valid?
|
|
49
49
|
session[:errors] = comment.errors
|
|
@@ -60,7 +60,7 @@ class BlogController < N::Controller
|
|
|
60
60
|
end
|
|
61
61
|
|
|
62
62
|
def login
|
|
63
|
-
if password =
|
|
63
|
+
if password = request['password']
|
|
64
64
|
if password == Blog.password
|
|
65
65
|
session[:owner] = true
|
|
66
66
|
session[:username] = Blog.username
|
|
@@ -91,9 +91,7 @@ private
|
|
|
91
91
|
# Just an example.
|
|
92
92
|
|
|
93
93
|
def cache
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
Logger.info "cache (after filter example)"
|
|
94
|
+
Logger.info 'cache (after filter example)'
|
|
97
95
|
end
|
|
98
96
|
|
|
99
97
|
end
|
data/examples/blog/root/fcgi.rb
CHANGED
|
@@ -3,11 +3,9 @@
|
|
|
3
3
|
<!--
|
|
4
4
|
A Simple Shader
|
|
5
5
|
|
|
6
|
-
code:
|
|
7
6
|
* George Moschovitis <gm@navel.gr>
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
$Id: style.xsl 225 2005-01-27 12:35:07Z gmosx $
|
|
7
|
+
(c) 2004-2005 Navel, all rights reserved.
|
|
8
|
+
$Id: style.xsl 259 2005-02-15 08:54:54Z gmosx $
|
|
11
9
|
-->
|
|
12
10
|
|
|
13
11
|
<!DOCTYPE shader
|
|
@@ -88,8 +86,8 @@ $Id: style.xsl 225 2005-01-27 12:35:07Z gmosx $
|
|
|
88
86
|
<div class="block side">
|
|
89
87
|
<h2>About</h2>
|
|
90
88
|
This is a simple blog powered by <a href="http://www.navel.gr/nitro">
|
|
91
|
-
Nitro</a> Web Engine. Have a look at the source code and enjoy
|
|
92
|
-
|
|
89
|
+
Nitro</a> Web Engine. Have a look at the source code and enjoy the
|
|
90
|
+
power of Ruby.
|
|
93
91
|
<ruby>unless session[:owner]</ruby>
|
|
94
92
|
<p><a href="login">Login</a> as owner.</p>
|
|
95
93
|
<ruby>else</ruby>
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# * George Moschovitis <gm@navel.gr>
|
|
2
|
+
# (c) 2004-2005 Navel, all rights reserved.
|
|
3
|
+
# $Id: run.rb 260 2005-02-15 08:58:04Z gmosx $
|
|
4
|
+
|
|
5
|
+
Dir.chdir File.dirname(__FILE__)
|
|
6
|
+
|
|
7
|
+
require 'nitro'; include N
|
|
8
|
+
require 'og'
|
|
9
|
+
|
|
10
|
+
require 'lib/blog'
|
|
11
|
+
|
|
12
|
+
runner = Runner.new.setup
|
|
13
|
+
|
|
14
|
+
db = Og::Database.new(
|
|
15
|
+
# :address => 'localhost',
|
|
16
|
+
# :adapter => 'mysql',
|
|
17
|
+
:adapter => 'psql',
|
|
18
|
+
# :adapter => 'sqlite',
|
|
19
|
+
:database => 'blog',
|
|
20
|
+
:user => 'postgres',
|
|
21
|
+
:password => 'navelrulez',
|
|
22
|
+
:connection_count => 3
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
dispatcher = Dispatcher.new(BlogController, :xml => 'text/xml')
|
|
26
|
+
|
|
27
|
+
Rendering.shader = XSLTShader.new("#{dispatcher.root}/style.xsl",
|
|
28
|
+
RubyShader.new(
|
|
29
|
+
CompressShader.new
|
|
30
|
+
)
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
conf = Conf.new(
|
|
34
|
+
:name => 'Nitro Blog',
|
|
35
|
+
:host => 'localhost',
|
|
36
|
+
:port => 8069,
|
|
37
|
+
:dispatcher => dispatcher,
|
|
38
|
+
:db => db
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
runner.run(conf)
|
data/examples/no_xsl_blog/README
CHANGED
|
@@ -16,34 +16,27 @@ require 'blog'
|
|
|
16
16
|
include N
|
|
17
17
|
|
|
18
18
|
og = Og::Database.new(
|
|
19
|
-
:address => 'localhost',
|
|
19
|
+
# :address => 'localhost',
|
|
20
20
|
:backend => 'mysql',
|
|
21
|
+
# :backend => 'psql',
|
|
21
22
|
:database => 'blog',
|
|
22
23
|
:user => 'root',
|
|
23
24
|
:password => 'navelrulez',
|
|
25
|
+
# :user => 'postgres',
|
|
26
|
+
# :password => 'navelrulez',
|
|
24
27
|
:connection_count => 3
|
|
25
28
|
)
|
|
26
29
|
|
|
27
|
-
=begin
|
|
28
|
-
og = Og::Database.new(
|
|
29
|
-
:address => 'localhost',
|
|
30
|
-
:backend => 'psql',
|
|
31
|
-
:database => 'blog',
|
|
32
|
-
:user => 'postgres',
|
|
33
|
-
:password => 'navelrulez',
|
|
34
|
-
:connection_count => 3
|
|
35
|
-
)
|
|
36
|
-
=end
|
|
37
|
-
|
|
38
30
|
controllers = {
|
|
39
31
|
:index => BlogController
|
|
32
|
+
# mount more controllers if you need.
|
|
40
33
|
}
|
|
41
34
|
|
|
42
35
|
apis = {
|
|
43
36
|
:xml => 'text/xml'
|
|
44
37
|
}
|
|
45
38
|
|
|
46
|
-
dispatcher = Dispatcher.new(
|
|
39
|
+
dispatcher = Dispatcher.new(BlogController, :xml => 'text/xml')
|
|
47
40
|
|
|
48
41
|
$conf = {
|
|
49
42
|
:name => 'Blog sans XSLT',
|
|
@@ -6,8 +6,8 @@ require 'nitro/controller'
|
|
|
6
6
|
require 'nitro/builders/rss'
|
|
7
7
|
require 'nitro/ui/pager'
|
|
8
8
|
|
|
9
|
-
require 'blog/model'
|
|
10
|
-
require 'blog/template'
|
|
9
|
+
require 'lib/blog/model'
|
|
10
|
+
require 'lib/blog/template'
|
|
11
11
|
|
|
12
12
|
# The controller of the Blog part.
|
|
13
13
|
|
|
@@ -21,13 +21,13 @@ class BlogController < N::Controller
|
|
|
21
21
|
scaffold Comment
|
|
22
22
|
|
|
23
23
|
def list_entry
|
|
24
|
-
@pager = UI::Pager.new('entries',
|
|
24
|
+
@pager = UI::Pager.new('entries', request, 3)
|
|
25
25
|
@entries = BlogEntry.all("ORDER BY oid DESC #{@pager.sql_limit}")
|
|
26
26
|
@pager.set(BlogEntry.count)
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
def new_entry
|
|
30
|
-
entry =
|
|
30
|
+
entry = request.fill(BlogEntry.new)
|
|
31
31
|
entry.author = session[:username]
|
|
32
32
|
|
|
33
33
|
unless entry.valid?
|
|
@@ -45,7 +45,7 @@ class BlogController < N::Controller
|
|
|
45
45
|
end
|
|
46
46
|
|
|
47
47
|
def new_comment
|
|
48
|
-
comment =
|
|
48
|
+
comment = request.fill(Comment.new)
|
|
49
49
|
|
|
50
50
|
unless comment.valid?
|
|
51
51
|
session[:errors] = comment.errors
|
|
@@ -62,7 +62,7 @@ class BlogController < N::Controller
|
|
|
62
62
|
end
|
|
63
63
|
|
|
64
64
|
def login
|
|
65
|
-
if password =
|
|
65
|
+
if password = request['password']
|
|
66
66
|
if password == Blog.password
|
|
67
67
|
session[:owner] = true
|
|
68
68
|
session[:username] = Blog.username
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# * George Moschovitis <gm@navel.gr>
|
|
2
|
+
# (c) 2004-2005 Navel, all rights reserved.
|
|
3
|
+
# $Id: run.rb 260 2005-02-15 08:58:04Z gmosx $
|
|
4
|
+
|
|
5
|
+
Dir.chdir File.dirname(__FILE__)
|
|
6
|
+
|
|
7
|
+
require 'nitro'; include N
|
|
8
|
+
require 'og'
|
|
9
|
+
|
|
10
|
+
require 'lib/blog'
|
|
11
|
+
|
|
12
|
+
runner = Runner.new.setup
|
|
13
|
+
|
|
14
|
+
db = Og::Database.new(
|
|
15
|
+
# :address => 'localhost',
|
|
16
|
+
:adapter => 'mysql',
|
|
17
|
+
# :backend => 'psql',
|
|
18
|
+
:database => 'blog',
|
|
19
|
+
:user => 'root',
|
|
20
|
+
:password => 'navelrulez',
|
|
21
|
+
# :user => 'postgres',
|
|
22
|
+
# :password => 'navelrulez',
|
|
23
|
+
:connection_count => 3
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
dispatcher = Dispatcher.new(BlogController, :xml => 'text/xml')
|
|
27
|
+
|
|
28
|
+
Rendering.shader = RubyShader.new(CompressShader.new)
|
|
29
|
+
|
|
30
|
+
conf = Conf.new(
|
|
31
|
+
:name => 'Blog sans XSLT',
|
|
32
|
+
:host => 'localhost',
|
|
33
|
+
:port => 8069,
|
|
34
|
+
:dispatcher => dispatcher,
|
|
35
|
+
:db => db
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
runner.run(conf)
|
data/examples/og/mock_example.rb
CHANGED
data/examples/og/run.rb
CHANGED
|
@@ -1,22 +1,17 @@
|
|
|
1
|
-
# = Og Example
|
|
2
|
-
#
|
|
3
1
|
# A simple example to demonstrate the Og library.
|
|
4
2
|
#
|
|
5
|
-
# code:
|
|
6
3
|
# * George Moschovitis <gm@navel.gr>
|
|
7
|
-
#
|
|
8
4
|
# (c) 2004 Navel, all rights reserved.
|
|
9
|
-
# $Id: run.rb
|
|
10
|
-
|
|
11
|
-
$:.unshift File.join(File.dirname(__FILE__), '..', '..', 'lib')
|
|
5
|
+
# $Id: run.rb 256 2005-02-11 16:22:33Z gmosx $
|
|
12
6
|
|
|
13
7
|
require 'og'
|
|
14
8
|
|
|
15
9
|
# Full debug information.
|
|
10
|
+
|
|
16
11
|
$DBG = true
|
|
17
12
|
|
|
18
|
-
#
|
|
19
|
-
|
|
13
|
+
# A child class.
|
|
14
|
+
|
|
20
15
|
class Comment
|
|
21
16
|
prop_accessor :body, String
|
|
22
17
|
|
|
@@ -55,8 +50,8 @@ class User
|
|
|
55
50
|
end
|
|
56
51
|
|
|
57
52
|
|
|
58
|
-
#
|
|
59
|
-
|
|
53
|
+
# A parent class.
|
|
54
|
+
|
|
60
55
|
class Article
|
|
61
56
|
prop_accessor :title, String
|
|
62
57
|
prop_accessor :body, String
|
|
@@ -95,8 +90,8 @@ class Article
|
|
|
95
90
|
end
|
|
96
91
|
end
|
|
97
92
|
|
|
98
|
-
#
|
|
99
|
-
|
|
93
|
+
# A parent class.
|
|
94
|
+
|
|
100
95
|
class Category
|
|
101
96
|
prop_accessor :title, String
|
|
102
97
|
prop_accessor :body, String
|
|
@@ -110,20 +105,20 @@ class Category
|
|
|
110
105
|
end
|
|
111
106
|
|
|
112
107
|
|
|
113
|
-
#
|
|
114
|
-
|
|
108
|
+
# Article comment.
|
|
109
|
+
|
|
115
110
|
class ArticleComment < Comment
|
|
116
111
|
belongs_to :article, Article
|
|
117
112
|
end
|
|
118
113
|
|
|
119
|
-
#
|
|
120
|
-
|
|
114
|
+
# User comment.
|
|
115
|
+
|
|
121
116
|
class UserComment < Comment
|
|
122
117
|
belongs_to :author, User
|
|
123
118
|
end
|
|
124
119
|
|
|
125
|
-
#
|
|
126
|
-
|
|
120
|
+
# Another child class.
|
|
121
|
+
|
|
127
122
|
class Part
|
|
128
123
|
prop_accessor :name, String
|
|
129
124
|
belongs_to :article, Article
|
|
@@ -139,14 +134,20 @@ end
|
|
|
139
134
|
|
|
140
135
|
# Og configuration.
|
|
141
136
|
config = {
|
|
142
|
-
:address => "localhost",
|
|
143
137
|
:database => "test",
|
|
144
|
-
:
|
|
138
|
+
:adapter => "sqlite",
|
|
139
|
+
:connection_count => 2
|
|
140
|
+
}
|
|
141
|
+
=begin
|
|
142
|
+
config = {
|
|
143
|
+
# :address => "localhost",
|
|
144
|
+
:database => "test",
|
|
145
|
+
:adapter => "psql",
|
|
145
146
|
:user => "postgres",
|
|
146
147
|
:password => "navelrulez",
|
|
147
148
|
:connection_count => 1
|
|
148
149
|
}
|
|
149
|
-
|
|
150
|
+
|
|
150
151
|
config = {
|
|
151
152
|
:address => "localhost",
|
|
152
153
|
:database => "test",
|
data/examples/tiny/root/fcgi.rb
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<?r
|
|
6
6
|
# the code that populates the template comes here
|
|
7
7
|
|
|
8
|
-
unless name =
|
|
8
|
+
unless name = request['name']
|
|
9
9
|
name = 'World'
|
|
10
10
|
end
|
|
11
11
|
|
|
@@ -20,10 +20,7 @@
|
|
|
20
20
|
</p>
|
|
21
21
|
|
|
22
22
|
|
|
23
|
-
<strong
|
|
24
|
-
<!--
|
|
25
|
-
<p>#{context.headers.collect { |h| "#{h}<br/>" }}</p>
|
|
26
|
-
-->
|
|
23
|
+
<strong>#{Rendering.reload} Hello #{name}</strong>
|
|
27
24
|
<p>
|
|
28
25
|
<form id="my_form">
|
|
29
26
|
<strong>Enter your name:</strong>
|
|
@@ -39,4 +36,23 @@
|
|
|
39
36
|
|
|
40
37
|
<render href="include" />
|
|
41
38
|
|
|
39
|
+
<!--
|
|
40
|
+
<p>#{context.headers.collect { |h| "#{h}<br/>" }}</p>
|
|
41
|
+
<p>
|
|
42
|
+
<h3>Upload a picture</h3>
|
|
43
|
+
|
|
44
|
+
<form action="upload" method="post" enctype="multipart/form-data">
|
|
45
|
+
<p>
|
|
46
|
+
<b>Title:<b><br />
|
|
47
|
+
<input type="text" name="title" />
|
|
48
|
+
</p>
|
|
49
|
+
<p>
|
|
50
|
+
<b>File:<b><br />
|
|
51
|
+
<input type="file" name="file" />
|
|
52
|
+
</p>
|
|
53
|
+
<input type="submit" value="Upload" />
|
|
54
|
+
</form>
|
|
55
|
+
</p>
|
|
56
|
+
-->
|
|
57
|
+
|
|
42
58
|
</html>
|