nitro 0.9.3 → 0.9.5
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 +64 -0
- data/RELEASES +13 -0
- data/examples/blog/README +1 -1
- data/examples/blog/conf/app.conf.rb +2 -6
- data/examples/blog/conf/lhttpd.conf +1 -1
- data/examples/blog/lib/blog/controller.rb +2 -2
- data/examples/blog/root/style.css +0 -2
- data/examples/flash/conf/app.conf.rb +2 -4
- data/examples/no_xsl_blog/README +9 -0
- data/examples/no_xsl_blog/conf/app.conf.rb +5 -8
- data/examples/no_xsl_blog/conf/lhttpd.conf +1 -1
- data/examples/no_xsl_blog/lib/blog/controller.rb +2 -3
- data/examples/no_xsl_blog/lib/blog/template.rb +3 -3
- data/examples/no_xsl_blog/root/style.css +0 -2
- data/examples/og/mock_example.rb +1 -4
- data/examples/og/mysql_to_psql.rb +2 -4
- data/examples/tiny/README +1 -1
- data/examples/tiny/conf/app.conf.rb +2 -6
- data/examples/tiny/conf/lhttpd.conf +1 -1
- data/examples/wee_style/README +10 -0
- data/examples/wee_style/wee.rb +50 -0
- data/lib/glue/cache.rb +32 -34
- data/lib/glue/number.rb +3 -9
- data/lib/glue/time.rb +14 -22
- data/lib/glue/validation.rb +2 -4
- data/lib/nitro.rb +1 -3
- data/lib/nitro/adaptors/fastcgi.rb +10 -0
- data/lib/nitro/adaptors/webrick.rb +27 -11
- data/lib/nitro/builders/rss.rb +31 -11
- data/lib/nitro/builders/xhtml.rb +2 -8
- data/lib/nitro/context.rb +3 -1
- data/lib/nitro/dispatcher.rb +21 -4
- data/lib/nitro/filters.rb +12 -12
- data/lib/nitro/version.rb +1 -1
- data/lib/og/backend.rb +36 -40
- data/lib/og/backends/psql.rb +7 -7
- data/lib/og/backends/sqlite.rb +383 -0
- data/lib/og/connection.rb +34 -34
- data/lib/og/meta.rb +8 -0
- data/lib/og/version.rb +2 -4
- data/test/nitro/builders/tc_rss.rb +22 -0
- data/test/nitro/tc_dispatcher.rb +6 -1
- metadata +7 -2
data/ChangeLog
CHANGED
@@ -1,6 +1,70 @@
|
|
1
1
|
|
2
|
+
04-02-2005 George Moschovitis <gm@navel.gr>
|
3
|
+
|
4
|
+
* lib/nitro/adaptors/fastcgi.rb: convert conf to Flexob.
|
5
|
+
|
6
|
+
* lib/nitro/adaptors/webrick.rb: added REQUEST_MUTEX to temp-fix windows bug.
|
7
|
+
|
8
|
+
03-02-2005 George Moschovitis <gm@navel.gr>
|
9
|
+
|
10
|
+
* lib/glue/*: cleaned up some files.
|
11
|
+
|
12
|
+
* lib/og/*: cleaned up some files.
|
13
|
+
|
14
|
+
* lib/nitro/dispatchers.rb (#initialize): accept class as input.
|
15
|
+
|
16
|
+
* Updated all examples.
|
17
|
+
|
18
|
+
* lib/nitro/context.rb: out == XhtmlString to allow convienient
|
19
|
+
access to the programmatic rendering functionality and make
|
20
|
+
the wee example cooler.
|
21
|
+
|
22
|
+
* lib/nitro/adaptors/webrick.rb (#start): better handling of conf parameters,
|
23
|
+
better handling of logging,
|
24
|
+
autoconvert conf to Flexob if needed.
|
25
|
+
|
26
|
+
* examples/wee_style/wee.rb: implemented,
|
27
|
+
looks cool (but useles? :-))
|
28
|
+
|
29
|
+
* examples/wee_style/README: introduced.
|
30
|
+
|
31
|
+
* examples/wee_style/*: introduced wee-style example.
|
32
|
+
|
33
|
+
* examples/blog/lib/blog.rb: updated for new RSS.
|
34
|
+
|
35
|
+
* test/nitro/builders/tc_rss.rb: introduced.
|
36
|
+
|
37
|
+
* lib/nitro/builders/rss.rb: pass parameters,
|
38
|
+
(#render): now alias for render_0_9
|
39
|
+
|
40
|
+
* lib/og/meta.rb (#joins): introduced new metadata macro.
|
41
|
+
|
42
|
+
02-02-2005 George Moschovitis <gm@navel.gr>
|
43
|
+
|
44
|
+
* --- VERSION 0.9.4 ---
|
45
|
+
|
46
|
+
* lib/og/backends/sqlite.rb: introduced.
|
47
|
+
|
48
|
+
* lib/og/backends/psql.rb: minor cleanup.
|
49
|
+
|
50
|
+
* examples/blog/root/style.css: fixes for IE, more needed.
|
51
|
+
|
52
|
+
* lib/nitro/adaptors/fastcgi.rb (#handle): restore Og connection.
|
53
|
+
|
54
|
+
* lib/nitro/adaptors/webrick.rb (#handle): restore Og connection, fixes
|
55
|
+
Windows deadlock. [james_b]
|
56
|
+
|
57
|
+
* examples/no_xsl_blog/lib/blog/template.rb: fixed ruby in template (login).
|
58
|
+
|
59
|
+
* changed default port to 8069, to avoid conflicts with
|
60
|
+
other servers (8080 was too common). [james_b]
|
61
|
+
|
2
62
|
01-02-2005 George Moschovitis <gm@navel.gr>
|
3
63
|
|
64
|
+
* updated Rubyforge page, added wiki.
|
65
|
+
|
66
|
+
* --- VERSION 0.9.3 ---
|
67
|
+
|
4
68
|
* small fixes to make tests pass again.
|
5
69
|
|
6
70
|
* lib/nitro/adaptors/webrick.rb: update headers with req.meta_vars.
|
data/RELEASES
CHANGED
@@ -1,3 +1,16 @@
|
|
1
|
+
== Version 0.9.5 was released on 04/02/2005.
|
2
|
+
|
3
|
+
A bug fix release.
|
4
|
+
|
5
|
+
* Fixed nasty Windows deadlock bug.
|
6
|
+
|
7
|
+
* Experimental Wee-style example (will be updated in the next version).
|
8
|
+
|
9
|
+
* Changed default port to 8069 (8080 was to common).
|
10
|
+
|
11
|
+
* Small fixes and improvements.
|
12
|
+
|
13
|
+
|
1
14
|
== Version 0.9.3 was released on 01/02/2005.
|
2
15
|
|
3
16
|
A *very* important release. A new abstract rendering
|
data/examples/blog/README
CHANGED
@@ -7,8 +7,6 @@ $:.unshift File.join(File.dirname(__FILE__), '..', '..', '..', 'lib')
|
|
7
7
|
|
8
8
|
$DBG = true
|
9
9
|
|
10
|
-
require 'ostruct'
|
11
|
-
|
12
10
|
require 'nitro'
|
13
11
|
require 'glue/validation'
|
14
12
|
require 'og'
|
@@ -45,12 +43,10 @@ Rendering.shader = N::XSLTShader.new("#{dispatcher.root}/style.xsl",
|
|
45
43
|
|
46
44
|
Rendering.reload = :partial
|
47
45
|
|
48
|
-
conf = {
|
46
|
+
$conf = {
|
49
47
|
:name => 'Nitro Blog',
|
50
48
|
:host => 'localhost',
|
51
|
-
:port =>
|
49
|
+
:port => 8069,
|
52
50
|
:dispatcher => dispatcher,
|
53
51
|
:og => og
|
54
52
|
}
|
55
|
-
|
56
|
-
$conf = OpenStruct.new(conf)
|
@@ -104,7 +104,7 @@ url.access-deny = ( "~", ".inc" )
|
|
104
104
|
######### Options that are good to be but not neccesary to be changed #######
|
105
105
|
|
106
106
|
## bind to port (default: 80)
|
107
|
-
server.port =
|
107
|
+
server.port = 8069
|
108
108
|
|
109
109
|
## bind to localhost (default: all interfaces)
|
110
110
|
#server.bind = "grisu.home.kneschke.de"
|
@@ -39,7 +39,7 @@ class BlogController < N::Controller
|
|
39
39
|
# example of generated view
|
40
40
|
|
41
41
|
def list_entry__xml
|
42
|
-
@out << RssBuilder.render(@entries)
|
42
|
+
@out << RssBuilder.render(@entries, :description => 'Blog entries', :link => context.host_url)
|
43
43
|
end
|
44
44
|
|
45
45
|
def new_comment
|
@@ -56,7 +56,7 @@ class BlogController < N::Controller
|
|
56
56
|
# example of generated view
|
57
57
|
|
58
58
|
def list_comment__xml
|
59
|
-
@out << RssBuilder.render(@comments)
|
59
|
+
@out << RssBuilder.render(@comments, :description => 'Blog comments', :link => context.host_url)
|
60
60
|
end
|
61
61
|
|
62
62
|
def login
|
data/examples/no_xsl_blog/README
CHANGED
@@ -10,3 +10,12 @@ least you shold configure the database username/password.
|
|
10
10
|
|
11
11
|
When running on windows, the database binaries should
|
12
12
|
be in the PATH.
|
13
|
+
|
14
|
+
To see the example browse http://127.0.0.1:8069
|
15
|
+
|
16
|
+
= WARNING
|
17
|
+
|
18
|
+
This example seems to have some problems when running
|
19
|
+
with Internet Explorer 6. For the moment, please
|
20
|
+
try running it with Firefox and/or Mozilla.
|
21
|
+
|
@@ -7,8 +7,6 @@ $:.unshift File.join(File.dirname(__FILE__), '..', '..', '..', 'lib')
|
|
7
7
|
|
8
8
|
$DBG = true
|
9
9
|
|
10
|
-
require 'ostruct'
|
11
|
-
|
12
10
|
require 'nitro'
|
13
11
|
require 'glue/validation'
|
14
12
|
require 'og'
|
@@ -16,7 +14,7 @@ require 'og'
|
|
16
14
|
require 'blog'
|
17
15
|
|
18
16
|
include N
|
19
|
-
|
17
|
+
|
20
18
|
og = Og::Database.new(
|
21
19
|
:address => 'localhost',
|
22
20
|
:backend => 'mysql',
|
@@ -25,8 +23,8 @@ og = Og::Database.new(
|
|
25
23
|
:password => 'navelrulez',
|
26
24
|
:connection_count => 3
|
27
25
|
)
|
28
|
-
=end
|
29
26
|
|
27
|
+
=begin
|
30
28
|
og = Og::Database.new(
|
31
29
|
:address => 'localhost',
|
32
30
|
:backend => 'psql',
|
@@ -35,6 +33,7 @@ og = Og::Database.new(
|
|
35
33
|
:password => 'navelrulez',
|
36
34
|
:connection_count => 3
|
37
35
|
)
|
36
|
+
=end
|
38
37
|
|
39
38
|
controllers = {
|
40
39
|
:index => BlogController
|
@@ -46,12 +45,10 @@ apis = {
|
|
46
45
|
|
47
46
|
dispatcher = Dispatcher.new(controllers, apis)
|
48
47
|
|
49
|
-
conf = {
|
48
|
+
$conf = {
|
50
49
|
:name => 'Blog sans XSLT',
|
51
50
|
:host => 'localhost',
|
52
|
-
:port =>
|
51
|
+
:port => 8069,
|
53
52
|
:dispatcher => dispatcher,
|
54
53
|
:og => og
|
55
54
|
}
|
56
|
-
|
57
|
-
$conf = OpenStruct.new(conf)
|
@@ -104,7 +104,7 @@ url.access-deny = ( "~", ".inc" )
|
|
104
104
|
######### Options that are good to be but not neccesary to be changed #######
|
105
105
|
|
106
106
|
## bind to port (default: 80)
|
107
|
-
server.port =
|
107
|
+
server.port = 8069
|
108
108
|
|
109
109
|
## bind to localhost (default: all interfaces)
|
110
110
|
#server.bind = "grisu.home.kneschke.de"
|
@@ -32,7 +32,6 @@ class BlogController < N::Controller
|
|
32
32
|
|
33
33
|
unless entry.valid?
|
34
34
|
session[:errors] = entry.errors
|
35
|
-
puts '***', @context.headers.inspect, @context.referer
|
36
35
|
redirect_referer '#new_entry'
|
37
36
|
end
|
38
37
|
|
@@ -42,7 +41,7 @@ class BlogController < N::Controller
|
|
42
41
|
# example of generated view
|
43
42
|
|
44
43
|
def list_entry__xml
|
45
|
-
@out << RssBuilder.render(@entries)
|
44
|
+
@out << RssBuilder.render(@entries, :description => 'Blog entries', :link => context.host_url)
|
46
45
|
end
|
47
46
|
|
48
47
|
def new_comment
|
@@ -59,7 +58,7 @@ class BlogController < N::Controller
|
|
59
58
|
# example of generated view
|
60
59
|
|
61
60
|
def list_comment__xml
|
62
|
-
@out << RssBuilder.render(@comments)
|
61
|
+
@out << RssBuilder.render(@comments, :description => 'Blog comments', :link => context.host_url)
|
63
62
|
end
|
64
63
|
|
65
64
|
def login
|
@@ -87,11 +87,11 @@ module BlogTemplate
|
|
87
87
|
This is a simple blog powered by <a href="http://www.navel.gr/nitro">
|
88
88
|
Nitro</a> Web Engine. Have a look at the source code and enjoy
|
89
89
|
the power of Ruby.
|
90
|
-
|
90
|
+
} + unless session['owner'] then %{
|
91
91
|
<p><a href="login">Login</a> as owner.</p>
|
92
|
-
|
92
|
+
} else %{
|
93
93
|
<p><a href="logout">Logout</a>.</p>
|
94
|
-
|
94
|
+
} end + %{
|
95
95
|
|
96
96
|
<h2>Linkage</h2>
|
97
97
|
<ul>
|
data/examples/og/mock_example.rb
CHANGED
@@ -3,10 +3,8 @@
|
|
3
3
|
# A simple example to demonstrate how to mock Og.
|
4
4
|
# Very useful in test units.
|
5
5
|
#
|
6
|
-
# code:
|
7
6
|
# * George Moschovitis <gm@navel.gr>
|
8
|
-
#
|
9
|
-
# (c) 2004 Navel, all rights reserved.
|
7
|
+
# (c) 2004-2005 Navel, all rights reserved.
|
10
8
|
# $Id: run.rb 185 2004-12-10 13:29:09Z gmosx $
|
11
9
|
|
12
10
|
$:.unshift File.join(File.dirname(__FILE__), '..', '..', 'lib')
|
@@ -52,4 +50,3 @@ class SimpleTest < Test::Unit::TestCase
|
|
52
50
|
end
|
53
51
|
|
54
52
|
end
|
55
|
-
|
@@ -7,10 +7,8 @@
|
|
7
7
|
#
|
8
8
|
# Og makes it easier to switch to a REAL database :)
|
9
9
|
#
|
10
|
-
# code:
|
11
10
|
# * George Moschovitis <gm@navel.gr>
|
12
|
-
#
|
13
|
-
# (c) 2004 Navel, all rights reserved.
|
11
|
+
# (c) 2004-2005 Navel, all rights reserved.
|
14
12
|
# $Id$
|
15
13
|
|
16
14
|
raise 'WARNING, this example does not work yet, for the moment ' +
|
@@ -22,7 +20,7 @@ require 'og'
|
|
22
20
|
|
23
21
|
# An example managed object.
|
24
22
|
# Looks like an ordinary Ruby object.
|
25
|
-
|
23
|
+
|
26
24
|
class Article
|
27
25
|
prop_accessor :name, :body, String
|
28
26
|
|
data/examples/tiny/README
CHANGED
@@ -104,7 +104,7 @@ url.access-deny = ( "~", ".inc" )
|
|
104
104
|
######### Options that are good to be but not neccesary to be changed #######
|
105
105
|
|
106
106
|
## bind to port (default: 80)
|
107
|
-
server.port =
|
107
|
+
server.port = 8069
|
108
108
|
|
109
109
|
## bind to localhost (default: all interfaces)
|
110
110
|
#server.bind = "grisu.home.kneschke.de"
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# * George Moschovitis <gm@navel.gr>
|
2
|
+
# (c) 2004-2005 Navel, all rights reserved.
|
3
|
+
# $Id$
|
4
|
+
|
5
|
+
$:.unshift File.join(File.dirname(__FILE__), '..', '..', 'lib')
|
6
|
+
|
7
|
+
require 'nitro'
|
8
|
+
require 'nitro/adaptors/webrick'
|
9
|
+
|
10
|
+
include N
|
11
|
+
|
12
|
+
class Wee < Controller
|
13
|
+
|
14
|
+
def index
|
15
|
+
counter = session[:counter] || 0
|
16
|
+
|
17
|
+
(o = @out).html {
|
18
|
+
o.h1 'Hello world'
|
19
|
+
o << 'This is '
|
20
|
+
o.b { o << 'BOLD' }
|
21
|
+
o.p {
|
22
|
+
o << "Here is the counter: #{counter}"
|
23
|
+
}
|
24
|
+
o.p {
|
25
|
+
o << '<a href="inc_counter">Increase</a> the counter.'
|
26
|
+
}
|
27
|
+
o.p {
|
28
|
+
o << '<a href="reset_counter">Reset</a> the counter.'
|
29
|
+
}
|
30
|
+
}
|
31
|
+
end
|
32
|
+
|
33
|
+
def inc_counter
|
34
|
+
session[:counter] ||= 0
|
35
|
+
session[:counter] += 1
|
36
|
+
end
|
37
|
+
|
38
|
+
def reset_counter
|
39
|
+
session[:counter] = 0
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
conf = {
|
45
|
+
:host => 'localhost',
|
46
|
+
:port => 8069,
|
47
|
+
:dispatcher => Dispatcher.new(Wee)
|
48
|
+
}
|
49
|
+
|
50
|
+
Webrick.start(conf)
|
data/lib/glue/cache.rb
CHANGED
@@ -1,14 +1,10 @@
|
|
1
|
-
# code:
|
2
1
|
# * George Moschovitis <gm@navel.gr>
|
3
2
|
# * Anastasios Koutoumanos <ak@navel.gr>
|
4
|
-
#
|
5
|
-
# (c) 2004 Navel, all rights reserved.
|
3
|
+
# (c) 2004-2005 Navel, all rights reserved.
|
6
4
|
# $Id: cache.rb 202 2005-01-17 10:44:13Z gmosx $
|
7
5
|
|
8
|
-
module N
|
6
|
+
module N
|
9
7
|
|
10
|
-
# = LRUCache
|
11
|
-
#
|
12
8
|
# A cache utilizing a simple LRU (Least Recently Used) policy.
|
13
9
|
# The items managed by this cache must respond to the #key method.
|
14
10
|
# Attempts to optimize reads rather than inserts!
|
@@ -16,36 +12,38 @@ module N;
|
|
16
12
|
# LRU semantics are enforced by inserting the items in a queue.
|
17
13
|
# The lru item is always at the tail. Two special sentinels
|
18
14
|
# (head, tail) are used to simplify (?) the code.
|
19
|
-
|
15
|
+
|
20
16
|
class LRUCache < Hash
|
21
17
|
|
22
18
|
# Mix this in your class to make LRU-managable.
|
23
|
-
|
19
|
+
|
24
20
|
module Item
|
25
21
|
attr_accessor :lru_key, :lru_prev, :lru_next
|
26
22
|
end
|
27
23
|
|
28
24
|
# head-tail sentinels
|
29
|
-
|
25
|
+
|
30
26
|
class Sentinel; include Item; end
|
31
27
|
|
32
|
-
# the maximum number of items in the cache
|
28
|
+
# the maximum number of items in the cache.
|
29
|
+
|
33
30
|
attr_accessor :max_items
|
34
31
|
|
35
32
|
# the head sentinel
|
33
|
+
|
36
34
|
attr :head
|
35
|
+
|
37
36
|
# the tail sentinel, tail.prev points to the lru item.
|
37
|
+
|
38
38
|
attr :tail
|
39
39
|
|
40
|
-
#
|
41
|
-
#
|
42
40
|
def initialize(max_items)
|
43
41
|
@max_items = max_items
|
44
42
|
lru_clear()
|
45
43
|
end
|
46
44
|
|
47
|
-
# Lookup an item in the cache
|
48
|
-
|
45
|
+
# Lookup an item in the cache.
|
46
|
+
|
49
47
|
def [](key)
|
50
48
|
if item = super
|
51
49
|
return lru_touch(item)
|
@@ -53,36 +51,36 @@ class LRUCache < Hash
|
|
53
51
|
end
|
54
52
|
|
55
53
|
# The inserted item is considered mru!
|
56
|
-
|
54
|
+
|
57
55
|
def []=(key, item)
|
58
56
|
item = super
|
59
57
|
item.lru_key = key
|
60
58
|
lru_insert(item)
|
61
59
|
end
|
62
60
|
|
63
|
-
# Delete an item from the cache
|
64
|
-
|
61
|
+
# Delete an item from the cache.
|
62
|
+
|
65
63
|
def delete(key)
|
66
64
|
if item = super
|
67
65
|
lru_delete(item)
|
68
66
|
end
|
69
67
|
end
|
70
68
|
|
71
|
-
# Clear the cache
|
72
|
-
|
69
|
+
# Clear the cache.
|
70
|
+
|
73
71
|
def clear
|
74
72
|
super
|
75
73
|
lru_clear()
|
76
74
|
end
|
77
75
|
|
78
|
-
# The first (mru) element in the cache
|
79
|
-
|
76
|
+
# The first (mru) element in the cache.
|
77
|
+
|
80
78
|
def first
|
81
79
|
@head.lru_next
|
82
80
|
end
|
83
81
|
|
84
|
-
# The last (lru) element in the cache
|
85
|
-
|
82
|
+
# The last (lru) element in the cache.
|
83
|
+
|
86
84
|
def last
|
87
85
|
@tail.lru_prev
|
88
86
|
end
|
@@ -91,15 +89,15 @@ class LRUCache < Hash
|
|
91
89
|
private
|
92
90
|
|
93
91
|
# Delete an item from the lru list.
|
94
|
-
|
92
|
+
|
95
93
|
def lru_delete(item)
|
96
94
|
lru_join(item.lru_prev, item.lru_next)
|
97
95
|
return item
|
98
96
|
end
|
99
97
|
|
100
|
-
# Join two items in the lru list
|
101
|
-
# Return y to allow for chaining
|
102
|
-
|
98
|
+
# Join two items in the lru list.
|
99
|
+
# Return y to allow for chaining.
|
100
|
+
|
103
101
|
def lru_join(x, y)
|
104
102
|
x.lru_next = y
|
105
103
|
y.lru_prev = x
|
@@ -108,28 +106,28 @@ class LRUCache < Hash
|
|
108
106
|
|
109
107
|
# Append a child item to a parent item in the lru list
|
110
108
|
# (Re)inserts the child in the list.
|
111
|
-
|
109
|
+
|
112
110
|
def lru_append(parent, child)
|
113
111
|
lru_join(child, parent.lru_next)
|
114
112
|
lru_join(parent, child)
|
115
113
|
end
|
116
114
|
|
117
115
|
# Insert an item
|
118
|
-
|
116
|
+
|
119
117
|
def lru_insert(item)
|
120
118
|
delete(last.lru_key) if size() > @max_items
|
121
119
|
lru_append(@head, item)
|
122
120
|
end
|
123
121
|
|
124
122
|
# Touch an item, make mru!
|
125
|
-
# Returns the item
|
126
|
-
|
123
|
+
# Returns the item.
|
124
|
+
|
127
125
|
def lru_touch(item)
|
128
126
|
lru_append(@head, lru_delete(item))
|
129
127
|
end
|
130
128
|
|
131
|
-
# Clear the lru
|
132
|
-
|
129
|
+
# Clear the lru.
|
130
|
+
|
133
131
|
def lru_clear
|
134
132
|
@head = Sentinel.new
|
135
133
|
@tail = Sentinel.new
|
@@ -137,4 +135,4 @@ class LRUCache < Hash
|
|
137
135
|
end
|
138
136
|
end
|
139
137
|
|
140
|
-
end
|
138
|
+
end
|