nitro 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +186 -0
- data/README +40 -11
- data/RELEASES +10 -1
- data/Rakefile +5 -4
- data/bin/cluster.rb +3 -3
- data/{etc/new-project.rb → bin/new_app.rb} +1 -1
- data/examples/og/README +4 -0
- data/examples/og/run.rb +254 -0
- data/examples/simple/app.rb +3 -3
- data/examples/simple/conf/config.rb +10 -22
- data/examples/simple/conf/debug-config.rb +6 -32
- data/examples/simple/conf/live-config.rb +3 -23
- data/examples/simple/conf/requires.rb +5 -5
- data/examples/simple/env.rb +3 -4
- data/examples/simple/lib/articles/entities.rb +17 -15
- data/examples/simple/lib/articles/methods.rb +15 -15
- data/examples/simple/lib/articles/part.rb +7 -8
- data/examples/simple/root/comments.si +1 -1
- data/examples/simple/root/index.sx +1 -1
- data/examples/simple/root/view-article.sx +1 -2
- data/examples/tiny/app.rb +3 -3
- data/examples/tiny/conf/config.rb +4 -4
- data/examples/tiny/conf/requires.rb +3 -4
- data/lib/n/config.rb +50 -3
- data/lib/n/logger.rb +14 -2
- data/lib/n/og.rb +381 -0
- data/lib/n/og/backend.rb +252 -0
- data/lib/n/og/backends/mysql.rb +352 -0
- data/lib/n/og/backends/psql.rb +351 -0
- data/lib/n/og/connection.rb +253 -0
- data/lib/n/og/meta.rb +127 -0
- data/lib/n/properties.rb +6 -6
- data/lib/n/server.rb +4 -7
- data/lib/n/server/appserver.rb +58 -0
- data/lib/n/{app → server}/cluster.rb +3 -3
- data/lib/n/{app → server}/cookie.rb +3 -3
- data/lib/n/server/dispatcher.rb +55 -0
- data/lib/n/server/{filter.rb → filters.rb} +1 -1
- data/lib/n/{app → server}/filters/autologin.rb +5 -5
- data/lib/n/{app → server}/fragment.rb +3 -3
- data/lib/n/{app → server}/handlers.rb +4 -4
- data/lib/n/{app → server}/handlers/code-handler.rb +6 -6
- data/lib/n/{app → server}/handlers/page-handler.rb +9 -7
- data/lib/n/{app → server}/request.rb +8 -8
- data/lib/n/{app/request-part.rb → server/requestpart.rb} +4 -4
- data/lib/n/{app → server}/script.rb +5 -5
- data/lib/n/{app → server}/server.rb +1 -1
- data/lib/n/{app → server}/session.rb +5 -5
- data/lib/n/{app → server}/user.rb +1 -1
- data/lib/n/{app/webrick-servlet.rb → server/webrick.rb} +77 -20
- data/lib/n/shaders.rb +3 -2
- data/lib/n/std.rb +5 -32
- data/test/n/{app → server}/tc_cookie.rb +2 -2
- data/test/n/server/tc_filters.rb +38 -0
- data/test/n/{app → server}/tc_request.rb +6 -6
- data/test/n/{app → server}/tc_requestpart.rb +3 -3
- data/test/n/{app → server}/tc_session.rb +2 -2
- data/test/n/tc_og.rb +178 -0
- data/test/n/ui/tc_pager.rb +3 -3
- metadata +41 -65
- data/examples/ndb/README +0 -5
- data/examples/ndb/run.rb +0 -271
- data/lib/n/app/webrick.rb +0 -73
- data/lib/n/db.rb +0 -233
- data/lib/n/db/README +0 -232
- data/lib/n/db/connection.rb +0 -365
- data/lib/n/db/managed.rb +0 -233
- data/lib/n/db/mixins.rb +0 -279
- data/lib/n/db/mysql.rb +0 -345
- data/lib/n/db/psql.rb +0 -383
- data/lib/n/db/tools.rb +0 -106
- data/lib/n/db/utils.rb +0 -102
- data/lib/n/server/PLAYBACK.txt +0 -8
- data/lib/n/server/RESEARCH.txt +0 -13
- data/test/n/tc_db.rb +0 -223
- data/test/n/tc_db_mysql.rb +0 -241
data/examples/simple/app.rb
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
# * George Moschovitis <gm@navel.gr>
|
9
9
|
#
|
10
10
|
# (c) 2004 Navel, all rights reserved.
|
11
|
-
# $Id: app.rb
|
11
|
+
# $Id: app.rb 112 2004-10-27 10:59:55Z gmosx $
|
12
12
|
|
13
13
|
$:.unshift "simple/lib"
|
14
14
|
$:.unshift "../lib"
|
@@ -17,11 +17,11 @@ $:.unshift "../lib"
|
|
17
17
|
$DBG = true
|
18
18
|
$DBG ? (require "simple/conf/debug-config") : (require "simple/conf/live-config")
|
19
19
|
|
20
|
-
require "n/
|
20
|
+
require "n/server/webrick"
|
21
21
|
|
22
22
|
module App
|
23
23
|
|
24
|
-
class Server < N::
|
24
|
+
class Server < N::Webrick
|
25
25
|
include App::Config
|
26
26
|
end
|
27
27
|
|
@@ -8,41 +8,32 @@
|
|
8
8
|
# * George Moschovitis <gm@navel.gr>
|
9
9
|
#
|
10
10
|
# (c) 2004 Navel, all rights reserved.
|
11
|
-
# $Id: config.rb
|
11
|
+
# $Id: config.rb 124 2004-11-01 12:34:17Z gmosx $
|
12
12
|
|
13
13
|
require "n/std"
|
14
14
|
require "n/properties"
|
15
15
|
require "n/logger"
|
16
16
|
require "n/config"
|
17
|
+
require "n/og"
|
18
|
+
require "n/server/cluster"
|
19
|
+
|
20
|
+
require "simple/conf/requires"
|
17
21
|
|
18
22
|
$name = "Simple"
|
19
23
|
$root_dir = "simple/root"
|
20
24
|
|
21
|
-
# Main logger
|
22
|
-
|
23
|
-
$log = Logger.new("simple/logs/app.log", 10);
|
24
|
-
|
25
|
-
# Events logger
|
26
|
-
|
27
|
-
$elog = Logger.new("simple/logs/events.log", "weekly");
|
28
|
-
|
29
|
-
require "n/db"
|
30
|
-
require "n/app/cluster"
|
31
|
-
|
32
|
-
require "simple/conf/requires"
|
33
|
-
|
34
25
|
$srv_extension_map = {
|
35
26
|
"sx" => ["text/html",
|
36
|
-
# N::
|
37
|
-
N::
|
27
|
+
# N::AutoLoginFilter.new(
|
28
|
+
N::PageHandler.new
|
38
29
|
# )
|
39
30
|
],
|
40
31
|
"si" => ["text/html",
|
41
|
-
N::
|
32
|
+
N::PageHandler.new
|
42
33
|
],
|
43
34
|
"rx" => ["text/html",
|
44
|
-
# N::
|
45
|
-
N::
|
35
|
+
# N::AutoLoginFilter.new(
|
36
|
+
N::CodeHandler.new
|
46
37
|
# )
|
47
38
|
]
|
48
39
|
}
|
@@ -61,10 +52,7 @@ module Config
|
|
61
52
|
def initialize_sitemap
|
62
53
|
end
|
63
54
|
|
64
|
-
#
|
65
|
-
#
|
66
55
|
def initialize_shaders
|
67
|
-
# $default_shader = N::NilShader.new
|
68
56
|
$default_shader = N::Shader.new("simple", "#{$root_dir}/shader/shader.xsl")
|
69
57
|
end
|
70
58
|
|
@@ -6,47 +6,21 @@
|
|
6
6
|
# * George Moschovitis <gm@navel.gr>
|
7
7
|
#
|
8
8
|
# (c) 2004 Navel, all rights reserved.
|
9
|
-
# $Id: debug-config.rb
|
9
|
+
# $Id: debug-config.rb 118 2004-11-01 10:13:42Z gmosx $
|
10
10
|
|
11
11
|
require "simple/conf/config"
|
12
12
|
|
13
|
-
puts "DEBUG configuration\n\n"
|
14
|
-
|
15
|
-
# If set to true disables xsl caching. Usefull when debugging xsls.
|
16
|
-
|
17
|
-
$reload_xsl = true
|
18
|
-
|
19
|
-
# If set to true disables script compilation. Usefull when debugging
|
20
|
-
# statically included scripts.
|
21
|
-
|
22
|
-
$reload_scripts = true
|
23
|
-
|
24
|
-
# Logger (redirect to STDERR)
|
25
|
-
|
26
|
-
$log = Logger.new(STDERR);
|
27
|
-
$log.level = Logger::DEBUG
|
28
|
-
|
29
|
-
# Events logger
|
30
|
-
|
31
|
-
$elog = Logger.new(STDERR);
|
32
|
-
$elog.level = Logger::INFO
|
33
|
-
|
34
13
|
# Database
|
35
14
|
|
36
|
-
$
|
15
|
+
$og = N::Og.new(
|
37
16
|
:address => "localhost",
|
38
17
|
:database => "simple",
|
39
18
|
:user => "postgres",
|
40
19
|
:password => "navelrulez",
|
41
|
-
|
42
|
-
:connection_count => 5
|
20
|
+
:connection_count => 2
|
43
21
|
)
|
44
22
|
|
45
|
-
$
|
46
|
-
$
|
47
|
-
$
|
48
|
-
$srv_url = "http://#$srv_address:#$srv_port"
|
23
|
+
$og.get_connection
|
24
|
+
$og.manage(N::Article)
|
25
|
+
$og.manage(N::Comment)
|
49
26
|
|
50
|
-
# gmosx: no error page in debug mode to avoid loops when there
|
51
|
-
# is a bug in the handler code or the shader.
|
52
|
-
$error_page_url = nil
|
@@ -6,41 +6,21 @@
|
|
6
6
|
# * George Moschovitis <gm@navel.gr>
|
7
7
|
#
|
8
8
|
# (c) 2004 Navel, all rights reserved.
|
9
|
-
# $Id: live-config.rb
|
9
|
+
# $Id: live-config.rb 118 2004-11-01 10:13:42Z gmosx $
|
10
10
|
|
11
11
|
require "simple/conf/config"
|
12
12
|
|
13
|
-
puts "LIVE configuration\n\n"
|
14
|
-
|
15
|
-
# If set to true disables xsl caching. Usefull when debugging xsls.
|
16
|
-
|
17
|
-
$reload_xsl = false
|
18
|
-
|
19
|
-
# If set to true disables script compilation. Usefull when debugging
|
20
|
-
# statically included scripts.
|
21
|
-
|
22
|
-
$reload_scripts = false
|
23
|
-
|
24
13
|
# Logger
|
25
14
|
|
15
|
+
$log = Logger.new("simple/logs/app.log", 10);
|
26
16
|
$log.level = Logger::INFO
|
27
17
|
|
28
|
-
# Events logger
|
29
|
-
|
30
|
-
$elog.level = Logger::INFO
|
31
|
-
|
32
18
|
# Database
|
33
19
|
|
34
|
-
$
|
20
|
+
$og = N::Og.new(
|
35
21
|
:address => "localhost",
|
36
22
|
:database => "simple",
|
37
23
|
:user => "postgres",
|
38
24
|
:password => "navelrulez",
|
39
25
|
:connection_count => 20
|
40
26
|
)
|
41
|
-
|
42
|
-
$appsrv_address = "127.0.0.1"
|
43
|
-
$appsrv_port = 9090
|
44
|
-
$srv_url = "http://127.0.0.1:8080"
|
45
|
-
#$srv_url = "http://192.168.0.3:8080"
|
46
|
-
|
@@ -8,12 +8,12 @@
|
|
8
8
|
# * George Moschovitis <gm@navel.gr>
|
9
9
|
#
|
10
10
|
# (c) 2004 Navel, all rights reserved.
|
11
|
-
# $Id: requires.rb
|
11
|
+
# $Id: requires.rb 118 2004-11-01 10:13:42Z gmosx $
|
12
12
|
|
13
13
|
require "n/std"
|
14
14
|
require "n/properties"
|
15
15
|
|
16
|
-
require "n/
|
16
|
+
require "n/og"
|
17
17
|
require "n/l10n"
|
18
18
|
require "n/logger"
|
19
19
|
require "n/parts"
|
@@ -35,9 +35,9 @@ require "n/ui/pager"
|
|
35
35
|
require "n/ui/tabs"
|
36
36
|
require "n/ui/date-select"
|
37
37
|
|
38
|
-
require "n/
|
39
|
-
require "n/
|
40
|
-
require "n/
|
38
|
+
require "n/server/cluster"
|
39
|
+
require "n/server/handlers/page-handler"
|
40
|
+
require "n/server/handlers/code-handler"
|
41
41
|
|
42
42
|
require "articles/part"
|
43
43
|
|
data/examples/simple/env.rb
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
# * George Moschovitis <gm@navel.gr>
|
8
8
|
#
|
9
9
|
# (c) 2004 Navel, all rights reserved.
|
10
|
-
# $Id: env.rb
|
10
|
+
# $Id: env.rb 124 2004-11-01 12:34:17Z gmosx $
|
11
11
|
|
12
12
|
$:.unshift ".."
|
13
13
|
$:.unshift "simple/lib"
|
@@ -16,14 +16,13 @@ $:.unshift "../lib"
|
|
16
16
|
$DBG = true
|
17
17
|
$DBG ? (require "simple/conf/debug-config") : (require "simple/conf/live-config")
|
18
18
|
|
19
|
-
require "n/
|
20
|
-
require "n/db/tools" # very useful :)
|
19
|
+
require "n/server/server"
|
21
20
|
|
22
21
|
$drb_lm_server = "druby://:10000"
|
23
22
|
|
24
23
|
module App
|
25
24
|
|
26
|
-
class Server < N::
|
25
|
+
class Server < N::AppServer
|
27
26
|
include App::Config
|
28
27
|
end
|
29
28
|
|
@@ -1,35 +1,37 @@
|
|
1
|
-
# = Entities for the Articles part.
|
2
|
-
#
|
3
|
-
#--
|
4
1
|
# code:
|
5
|
-
# George Moschovitis <gm@navel.gr>
|
2
|
+
# * George Moschovitis <gm@navel.gr>
|
6
3
|
#
|
7
4
|
# (c) 2004 Navel, all rights reserved.
|
8
|
-
# $Id: entities.rb
|
9
|
-
#++
|
5
|
+
# $Id: entities.rb 118 2004-11-01 10:13:42Z gmosx $
|
10
6
|
|
11
7
|
module N
|
12
8
|
|
9
|
+
# gmosx: forward declaration, can we avoid this?
|
10
|
+
class Comment; end
|
11
|
+
|
13
12
|
# = Article
|
14
13
|
#
|
15
14
|
class Article
|
16
|
-
include N::Entity
|
17
|
-
include N::CreateTime
|
18
|
-
manage {
|
19
15
|
prop_accessor String, :title
|
20
16
|
prop_accessor String, :body
|
21
|
-
|
17
|
+
prop_accessor Time, :create_time
|
18
|
+
has_many N::Comment, :comments
|
19
|
+
|
20
|
+
def initialize
|
21
|
+
@create_time = Time.now
|
22
|
+
end
|
22
23
|
end
|
23
24
|
|
24
25
|
# = Comment
|
25
26
|
#
|
26
27
|
class Comment
|
27
|
-
include N::Entity
|
28
|
-
include N::Child
|
29
|
-
include N::CreateTime
|
30
|
-
manage {
|
31
28
|
prop_accessor String, :body
|
32
|
-
|
29
|
+
prop_accessor Time, :create_time
|
30
|
+
belongs_to N::Article, :article
|
31
|
+
|
32
|
+
def initialize
|
33
|
+
@create_time = Time.now
|
34
|
+
end
|
33
35
|
end
|
34
36
|
|
35
37
|
end # module
|
@@ -1,24 +1,24 @@
|
|
1
|
-
# = Methods for the Articles part.
|
2
|
-
#
|
3
|
-
#--
|
4
1
|
# code:
|
5
|
-
# George Moschovitis <gm@navel.gr>
|
2
|
+
# * George Moschovitis <gm@navel.gr>
|
6
3
|
#
|
7
4
|
# (c) 2004 Navel, all rights reserved.
|
8
|
-
# $Id: methods.rb
|
9
|
-
#++
|
5
|
+
# $Id: methods.rb 118 2004-11-01 10:13:42Z gmosx $
|
10
6
|
|
11
7
|
module P
|
12
8
|
|
9
|
+
# = ArticlesMethods
|
10
|
+
#
|
11
|
+
# Methods for the Articles part.
|
12
|
+
#
|
13
13
|
module ArticlesMethods
|
14
14
|
|
15
15
|
# Add an article
|
16
16
|
#
|
17
17
|
def add_article(request)
|
18
|
-
if request
|
18
|
+
if request["add_article"]
|
19
19
|
article = N::Article.new
|
20
20
|
request.update_entity(article)
|
21
|
-
|
21
|
+
article.save!
|
22
22
|
request.redirect("index.sx")
|
23
23
|
end
|
24
24
|
end
|
@@ -26,27 +26,27 @@ module ArticlesMethods
|
|
26
26
|
# Delete an article
|
27
27
|
#
|
28
28
|
def del_article(request)
|
29
|
-
if oid = request
|
30
|
-
|
29
|
+
if oid = request["del_article_oid"]
|
30
|
+
N::Article.delete(oid)
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
34
|
# Add a comment
|
35
35
|
#
|
36
36
|
def add_comment(request)
|
37
|
-
if pid = request
|
37
|
+
if pid = request["add_comment_pid"]
|
38
38
|
comment = N::Comment.new
|
39
|
-
comment.
|
39
|
+
comment.article = pid
|
40
40
|
request.update_entity(comment)
|
41
|
-
|
41
|
+
comment.save!
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
45
|
# Delete a comment
|
46
46
|
#
|
47
47
|
def del_comment(request)
|
48
|
-
if oid = request
|
49
|
-
|
48
|
+
if oid = request["del_comment_oid"]
|
49
|
+
N::Comment.delete(oid)
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
@@ -1,12 +1,8 @@
|
|
1
|
-
# = Simple Articles part.
|
2
|
-
#
|
3
|
-
#--
|
4
1
|
# code:
|
5
|
-
# George Moschovitis <gm@navel.gr>
|
2
|
+
# * George Moschovitis <gm@navel.gr>
|
6
3
|
#
|
7
4
|
# (c) 2004 Navel, all rights reserved.
|
8
|
-
# $Id: part.rb
|
9
|
-
#++
|
5
|
+
# $Id: part.rb 118 2004-11-01 10:13:42Z gmosx $
|
10
6
|
|
11
7
|
require "articles/lc-en"
|
12
8
|
require "articles/entities"
|
@@ -14,6 +10,10 @@ require "articles/methods"
|
|
14
10
|
|
15
11
|
module P
|
16
12
|
|
13
|
+
# = Articles
|
14
|
+
#
|
15
|
+
# A simple articles part.
|
16
|
+
#
|
17
17
|
class Articles < N::Part
|
18
18
|
extend P::ArticlesMethods
|
19
19
|
|
@@ -23,7 +23,7 @@ class Articles < N::Part
|
|
23
23
|
@name = "articles"
|
24
24
|
@title = "Articles"
|
25
25
|
@body = "Simple articles management"
|
26
|
-
@version = "$Id: part.rb
|
26
|
+
@version = "$Id: part.rb 118 2004-11-01 10:13:42Z gmosx $"
|
27
27
|
@path = ""
|
28
28
|
super
|
29
29
|
end
|
@@ -55,4 +55,3 @@ end
|
|
55
55
|
end # module
|
56
56
|
|
57
57
|
a = P::Articles.instance
|
58
|
-
|
data/examples/tiny/app.rb
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
# * George Moschovitis <gm@navel.gr>
|
9
9
|
#
|
10
10
|
# (c) 2004 Navel, all rights reserved.
|
11
|
-
# $Id: app.rb
|
11
|
+
# $Id: app.rb 112 2004-10-27 10:59:55Z gmosx $
|
12
12
|
|
13
13
|
$:.unshift "../lib"
|
14
14
|
|
@@ -16,11 +16,11 @@ $:.unshift "../lib"
|
|
16
16
|
$DBG = true
|
17
17
|
|
18
18
|
require "tiny/conf/config"
|
19
|
-
require "n/
|
19
|
+
require "n/server/webrick"
|
20
20
|
|
21
21
|
module App
|
22
22
|
|
23
|
-
class Server < N::
|
23
|
+
class Server < N::Webrick
|
24
24
|
include App::Config
|
25
25
|
end
|
26
26
|
|