nitro 0.4.1 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/AUTHORS +9 -1
- data/ChangeLog +107 -1
- data/README +1 -1
- data/RELEASES +14 -0
- data/Rakefile +73 -28
- data/bin/cluster.rb +2 -2
- data/examples/blog/app.rb +2 -2
- data/examples/blog/config.rb +14 -15
- data/examples/blog/lib/blog.rb +13 -20
- data/examples/blog/root/entry_form.xhtml +0 -1
- data/examples/blog/root/m/rss.gif +0 -0
- data/examples/blog/root/style.css +17 -0
- data/examples/blog/root/style.xsl +17 -5
- data/examples/blog/root/view_entry.xml +12 -0
- data/examples/og/run.rb +2 -3
- data/examples/tiny/config.rb +7 -8
- data/lib/glue.rb +52 -0
- data/lib/{nitro/utils → glue}/array.rb +2 -2
- data/lib/{nitro/utils → glue}/cache.rb +2 -2
- data/lib/{nitro/utils → glue}/hash.rb +2 -2
- data/lib/glue/inflector.rb +91 -0
- data/lib/{nitro → glue}/logger.rb +1 -1
- data/lib/{nitro/macros.rb → glue/macro.rb} +1 -1
- data/lib/{nitro → glue}/mixins.rb +3 -4
- data/lib/{nitro/utils → glue}/number.rb +3 -3
- data/lib/{nitro/utils → glue}/pool.rb +2 -2
- data/lib/{nitro/properties.rb → glue/property.rb} +8 -8
- data/lib/{nitro/utils → glue}/string.rb +3 -2
- data/lib/{nitro/utils → glue}/time.rb +3 -3
- data/lib/nitro.rb +2 -43
- data/lib/nitro/application.rb +2 -2
- data/lib/nitro/builders/rss.rb +43 -0
- data/lib/nitro/config.rb +13 -4
- data/lib/nitro/{utils/html.rb → html.rb} +2 -2
- data/lib/nitro/{utils/http.rb → http.rb} +1 -1
- data/lib/nitro/{utils/mail.rb → mail.rb} +1 -1
- data/lib/nitro/scaffold.rb +80 -0
- data/lib/nitro/server/appserver.rb +2 -2
- data/lib/nitro/server/cluster.rb +2 -2
- data/lib/nitro/server/dispatcher.rb +2 -5
- data/lib/nitro/server/filters/autologin.rb +2 -2
- data/lib/nitro/server/fragment.rb +5 -5
- data/lib/nitro/server/handlers.rb +3 -3
- data/lib/nitro/server/render.rb +145 -22
- data/lib/nitro/server/request.rb +7 -7
- data/lib/nitro/server/requestpart.rb +4 -4
- data/lib/nitro/server/script.rb +4 -4
- data/lib/nitro/server/server.rb +2 -2
- data/lib/nitro/server/session.rb +4 -4
- data/lib/nitro/server/webrick.rb +2 -2
- data/lib/nitro/service.rb +2 -1
- data/lib/nitro/sitemap.rb +3 -3
- data/lib/nitro/{utils/uri.rb → uri.rb} +3 -3
- data/lib/nitro/version.rb +2 -2
- data/lib/og.rb +8 -8
- data/lib/og/backends/mysql.rb +16 -12
- data/lib/og/backends/psql.rb +6 -2
- data/lib/og/connection.rb +4 -4
- data/lib/og/meta.rb +7 -1
- data/lib/og/version.rb +8 -0
- data/lib/xsl/base.xsl +10 -0
- data/test/{n/utils → glue}/tc_cache.rb +3 -3
- data/test/{n/utils → glue}/tc_hash.rb +2 -3
- data/test/{n/utils/tc_number.rb → glue/tc_numbers.rb} +3 -4
- data/test/{n → glue}/tc_properties.rb +2 -2
- data/test/glue/tc_strings.rb +103 -0
- data/test/{n → nitro}/server/tc_cookie.rb +0 -0
- data/test/{n → nitro}/server/tc_filters.rb +0 -0
- data/test/{n → nitro}/server/tc_request.rb +1 -1
- data/test/{n → nitro}/server/tc_requestpart.rb +0 -0
- data/test/{n → nitro}/server/tc_session.rb +0 -0
- data/test/{n → nitro}/tc_events.rb +0 -0
- data/test/{n/utils → nitro}/tc_html.rb +1 -1
- data/test/{n/utils → nitro}/tc_http.rb +1 -1
- data/test/{n → nitro}/tc_sitemap.rb +1 -1
- data/test/{n/utils → nitro}/tc_uri.rb +1 -1
- data/test/{n → nitro}/ui/tc_pager.rb +1 -1
- data/test/{n/tc_og.rb → tc_og.rb} +5 -2
- metadata +48 -44
- data/examples/blog/log/app.log +0 -117
- data/examples/tiny/log/app.log +0 -23
- data/lib/nitro/utils/gfx.rb +0 -107
- data/lib/nitro/utils/template.rb +0 -36
- data/test/n/utils/tc_strings.rb +0 -104
@@ -7,7 +7,7 @@ code:
|
|
7
7
|
* George Moschovitis <gm@navel.gr>
|
8
8
|
|
9
9
|
(c) 2004 Navel, all rights reserved.
|
10
|
-
$Id: style.xsl
|
10
|
+
$Id: style.xsl 167 2004-11-23 14:03:10Z gmosx $
|
11
11
|
-->
|
12
12
|
|
13
13
|
<!DOCTYPE shader
|
@@ -43,7 +43,8 @@ $Id: style.xsl 149 2004-11-13 19:52:32Z gmosx $
|
|
43
43
|
|
44
44
|
<base href="#$srv_url/" />
|
45
45
|
<link href="/style.css" rel="stylesheet" type="text/css" media="screen" />
|
46
|
-
|
46
|
+
<link rel="alternate" type="application/rss+xml" title="Latest Entries" href="#$srv_url/rest/list_entry" />
|
47
|
+
<link rel="alternate" type="application/rss+xml" title="Latest Comments" href="#$srv_url/rest/list_comment" />
|
47
48
|
<xsl:apply-templates select="x:cell[@id='head']"/>
|
48
49
|
</head>
|
49
50
|
</xsl:template>
|
@@ -66,6 +67,7 @@ $Id: style.xsl 149 2004-11-13 19:52:32Z gmosx $
|
|
66
67
|
<html>
|
67
68
|
<xsl:call-template name="x:head" />
|
68
69
|
<body>
|
70
|
+
|
69
71
|
<div id="page">
|
70
72
|
|
71
73
|
<xsl:call-template name="x:header" />
|
@@ -98,19 +100,29 @@ $Id: style.xsl 149 2004-11-13 19:52:32Z gmosx $
|
|
98
100
|
<li><a target="_new" href="http://www.w3c.org">W3 Consortium</a></li>
|
99
101
|
</ul>
|
100
102
|
|
103
|
+
<br />
|
104
|
+
<ul class="rss">
|
105
|
+
<li><a href="rest/list_entry">Latest entries</a></li>
|
106
|
+
<li><a href="rest/list_comment">Latest comments</a></li>
|
107
|
+
</ul>
|
108
|
+
|
101
109
|
<br />
|
102
110
|
<p>
|
103
|
-
powered by <b><a href="http://www.navel.gr/nitro">Nitro</a></b
|
104
|
-
|
111
|
+
powered by <b><a href="http://www.navel.gr/nitro">Nitro</a></b>
|
112
|
+
<br />
|
113
|
+
skin from <a href="http://www.blogger.com">Blogger.com</a>
|
105
114
|
</p>
|
106
115
|
</div>
|
107
116
|
|
108
117
|
<div class="clear">.</div>
|
109
118
|
|
110
119
|
<xsl:apply-templates select="x:cell[@id='bottom']" />
|
111
|
-
|
120
|
+
|
112
121
|
<xsl:call-template name="x:footer" />
|
113
122
|
</div>
|
123
|
+
|
124
|
+
<xsl:call-template name="x:rendering-errors" />
|
125
|
+
|
114
126
|
</body>
|
115
127
|
</html>
|
116
128
|
</xsl:template>
|
@@ -0,0 +1,12 @@
|
|
1
|
+
<?xml version="1.0"?>
|
2
|
+
|
3
|
+
<entry>
|
4
|
+
<title>#{@entry.title}</title>
|
5
|
+
<date>#{@entry.create_time.strftime('%B %e, %G')}</date>
|
6
|
+
<body>#{@entry.body}</body>
|
7
|
+
<comments>
|
8
|
+
<?r for comment in @entry.comments ?>
|
9
|
+
<comment>#{comment.body}</comment>
|
10
|
+
<?r end ?>
|
11
|
+
</comments>
|
12
|
+
</entry>
|
data/examples/og/run.rb
CHANGED
@@ -6,12 +6,11 @@
|
|
6
6
|
# * George Moschovitis <gm@navel.gr>
|
7
7
|
#
|
8
8
|
# (c) 2004 Navel, all rights reserved.
|
9
|
-
# $Id: run.rb
|
9
|
+
# $Id: run.rb 167 2004-11-23 14:03:10Z gmosx $
|
10
10
|
|
11
11
|
$:.unshift "../../lib"
|
12
12
|
|
13
|
-
require "
|
14
|
-
require "nitro/logger"
|
13
|
+
require "glue/logger"
|
15
14
|
require "og"
|
16
15
|
|
17
16
|
# Full debug information.
|
data/examples/tiny/config.rb
CHANGED
@@ -8,18 +8,17 @@
|
|
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 167 2004-11-23 14:03:10Z gmosx $
|
12
12
|
|
13
13
|
require "nitro"
|
14
|
-
require "
|
14
|
+
require "glue/logger"
|
15
15
|
require "nitro/config"
|
16
16
|
|
17
|
-
require "
|
18
|
-
require "
|
19
|
-
require "
|
20
|
-
require "
|
21
|
-
require "nitro/
|
22
|
-
require "nitro/utils/gfx"
|
17
|
+
require "glue/number"
|
18
|
+
require "glue/string"
|
19
|
+
require "glue/array"
|
20
|
+
require "glue/hash"
|
21
|
+
require "nitro/html"
|
23
22
|
|
24
23
|
require "nitro/server/webrick"
|
25
24
|
|
data/lib/glue.rb
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
# = Glue
|
2
|
+
#
|
3
|
+
# General libraries used by various projects.
|
4
|
+
#
|
5
|
+
# code:
|
6
|
+
# * George Moschovitis <gm@navel.gr>
|
7
|
+
#
|
8
|
+
# (c) 2004 Navel, all rights reserved.
|
9
|
+
# $Id$
|
10
|
+
|
11
|
+
require "English"
|
12
|
+
require "pp"
|
13
|
+
|
14
|
+
require 'glue/property'
|
15
|
+
|
16
|
+
class NilClass
|
17
|
+
# quite usefull for error tolerant apps.
|
18
|
+
# a bit dangerous? Will have to rethink this.
|
19
|
+
#
|
20
|
+
def empty?
|
21
|
+
return true
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
class Class
|
26
|
+
#--
|
27
|
+
# gmosx: is this really needed?
|
28
|
+
#++
|
29
|
+
def to_i()
|
30
|
+
return self.hash()
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
module Kernel
|
35
|
+
# pretty prints an exception/error object
|
36
|
+
# usefull for helpfull debug messages
|
37
|
+
#
|
38
|
+
# Input:
|
39
|
+
# The Exception/StandardError object
|
40
|
+
#
|
41
|
+
# Output:
|
42
|
+
# the pretty printed string
|
43
|
+
#
|
44
|
+
def pp_exception(ex)
|
45
|
+
return %{#{ex.message}\n\tBACKTRACE:\n\t#{ex.backtrace.join("\n\t")}\n\tLOGGED FROM:\n\t#{caller[0]}}
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
# predefine some comonly used objects
|
51
|
+
|
52
|
+
EMPTY_STRING = ""
|
@@ -2,11 +2,11 @@
|
|
2
2
|
# * George Moschovitis <gm@navel.gr>
|
3
3
|
#
|
4
4
|
# (c) 2002-2003 Navel, all rights reserved.
|
5
|
-
# $Id: array.rb
|
5
|
+
# $Id: array.rb 165 2004-11-18 12:04:04Z gmosx $
|
6
6
|
|
7
7
|
require "sync"
|
8
8
|
|
9
|
-
module
|
9
|
+
module G
|
10
10
|
|
11
11
|
# == SafeArray
|
12
12
|
#
|
@@ -2,11 +2,11 @@
|
|
2
2
|
# * George Moschovitis <gm@navel.gr>
|
3
3
|
#
|
4
4
|
# (c) 2004 Navel, all rights reserved.
|
5
|
-
# $Id: hash.rb
|
5
|
+
# $Id: hash.rb 167 2004-11-23 14:03:10Z gmosx $
|
6
6
|
|
7
7
|
require "sync"
|
8
8
|
|
9
|
-
module
|
9
|
+
module G;
|
10
10
|
|
11
11
|
# == SafeHash
|
12
12
|
#
|
@@ -0,0 +1,91 @@
|
|
1
|
+
# Code from RubyOnRailes (http://www.rubyonrails.com)
|
2
|
+
# Copyright (c) 2004 David Heinemeier Hansson.
|
3
|
+
#
|
4
|
+
|
5
|
+
module G
|
6
|
+
|
7
|
+
# The Inflector transforms words from singular to plural, class names to table names, modulized class names to ones without,
|
8
|
+
# and class names to foreign keys.
|
9
|
+
#
|
10
|
+
module Inflector
|
11
|
+
extend self
|
12
|
+
|
13
|
+
def pluralize(word)
|
14
|
+
result = word.dup
|
15
|
+
plural_rules.each do |(rule, replacement)|
|
16
|
+
break if result.gsub!(rule, replacement)
|
17
|
+
end
|
18
|
+
return result
|
19
|
+
end
|
20
|
+
|
21
|
+
def singularize(word)
|
22
|
+
result = word.dup
|
23
|
+
singular_rules.each do |(rule, replacement)|
|
24
|
+
break if result.gsub!(rule, replacement)
|
25
|
+
end
|
26
|
+
return result
|
27
|
+
end
|
28
|
+
|
29
|
+
def camelize(lower_case_and_underscored_word)
|
30
|
+
lower_case_and_underscored_word.gsub(/(^|_)(.)/){$2.upcase}
|
31
|
+
end
|
32
|
+
|
33
|
+
def underscore(camel_cased_word)
|
34
|
+
camel_cased_word.gsub(/([A-Z]+)([A-Z])/,'\1_\2').gsub(/([a-z])([A-Z])/,'\1_\2').downcase
|
35
|
+
end
|
36
|
+
|
37
|
+
def demodulize(class_name_in_module)
|
38
|
+
class_name_in_module.gsub(/^.*::/, '')
|
39
|
+
end
|
40
|
+
|
41
|
+
def foreign_key(class_name, separate_class_name_and_id_with_underscore = true)
|
42
|
+
Inflector.underscore(Inflector.demodulize(class_name)) +
|
43
|
+
(separate_class_name_and_id_with_underscore ? "_id" : "id")
|
44
|
+
end
|
45
|
+
|
46
|
+
# Convert a class to a name.
|
47
|
+
#
|
48
|
+
def name(klass)
|
49
|
+
Inflector.underscore(Inflector.demodulize(klass.to_s))
|
50
|
+
end
|
51
|
+
|
52
|
+
# Convert a class to a name in plural
|
53
|
+
#
|
54
|
+
def plural_name(klass)
|
55
|
+
Inflector.pluralize(Inflector.underscore(Inflector.demodulize(klass.to_s)))
|
56
|
+
end
|
57
|
+
|
58
|
+
private
|
59
|
+
def plural_rules #:doc:
|
60
|
+
[
|
61
|
+
[/(x|ch|ss)$/, '\1es'], # search, switch, fix, box, process, address
|
62
|
+
[/([^aeiouy]|qu)y$/, '\1ies'], # query, ability, agency
|
63
|
+
[/(?:([^f])fe|([lr])f)$/, '\1\2ves'], # half, safe, wife
|
64
|
+
[/sis$/, 'ses'], # basis, diagnosis
|
65
|
+
[/([ti])um$/, '\1a'], # datum, medium
|
66
|
+
[/person$/, 'people'], # person, salesperson
|
67
|
+
[/man$/, 'men'], # man, woman, spokesman
|
68
|
+
[/child$/, 'children'], # child
|
69
|
+
[/s$/, 's'], # no change (compatibility)
|
70
|
+
[/$/, 's']
|
71
|
+
]
|
72
|
+
end
|
73
|
+
|
74
|
+
def singular_rules #:doc:
|
75
|
+
[
|
76
|
+
[/(x|ch|ss)es$/, '\1'],
|
77
|
+
[/([^aeiouy]|qu)ies$/, '\1y'],
|
78
|
+
[/([lr])ves$/, '\1f'],
|
79
|
+
[/([^f])ves$/, '\1fe'],
|
80
|
+
[/(analy|ba|diagno|parenthe|progno|synop|the)ses$/, '\1sis'],
|
81
|
+
[/([ti])a$/, '\1um'],
|
82
|
+
[/people$/, 'person'],
|
83
|
+
[/men$/, 'man'],
|
84
|
+
[/status$/, 'status'],
|
85
|
+
[/children$/, 'child'],
|
86
|
+
[/s$/, '']
|
87
|
+
]
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
end # module
|
@@ -4,17 +4,16 @@
|
|
4
4
|
# entities.
|
5
5
|
#
|
6
6
|
# code:
|
7
|
-
# George Moschovitis <gm@navel.gr>
|
7
|
+
# * George Moschovitis <gm@navel.gr>
|
8
8
|
#
|
9
9
|
# (c) 2004 Navel, all rights reserved.
|
10
10
|
# $Id$
|
11
11
|
|
12
|
-
module
|
12
|
+
module G;
|
13
13
|
|
14
14
|
# = Expirable
|
15
15
|
#
|
16
|
-
# Generic expiring functionality mixin.
|
17
|
-
# for entities.
|
16
|
+
# Generic expiring functionality mixin.
|
18
17
|
#
|
19
18
|
module Expirable
|
20
19
|
attr_accessor :expires
|
@@ -2,16 +2,16 @@
|
|
2
2
|
# * George Moschovitis <gm@navel.gr>
|
3
3
|
#
|
4
4
|
# (c) 2004 Navel, all rights reserved.
|
5
|
-
# $Id: number.rb
|
5
|
+
# $Id: number.rb 167 2004-11-23 14:03:10Z gmosx $
|
6
6
|
|
7
|
-
module
|
7
|
+
module G;
|
8
8
|
|
9
9
|
# = NumberUtils
|
10
10
|
#
|
11
11
|
# === Design:
|
12
12
|
#
|
13
13
|
# Implement as a module to avoid class polution. You can
|
14
|
-
# still Ruby's advanced features to include the module in your
|
14
|
+
# still use Ruby's advanced features to include the module in your
|
15
15
|
# class. Passing the object to act upon allows to check for nil,
|
16
16
|
# which isn't possible if you use self.
|
17
17
|
#
|
@@ -2,12 +2,12 @@
|
|
2
2
|
# * George Moschovitis <gm@navel.gr>
|
3
3
|
#
|
4
4
|
# (c) 2004 Navel, all rights reserved.
|
5
|
-
# $Id: pool.rb
|
5
|
+
# $Id: pool.rb 167 2004-11-23 14:03:10Z gmosx $
|
6
6
|
|
7
7
|
require "thread"
|
8
8
|
require "monitor"
|
9
9
|
|
10
|
-
module
|
10
|
+
module G
|
11
11
|
|
12
12
|
# = Pool
|
13
13
|
#
|
@@ -5,12 +5,12 @@
|
|
5
5
|
# * Elias Karakoulakis <ekarak@ktismata.com>
|
6
6
|
#
|
7
7
|
# (c) 2004 Navel, all rights reserved.
|
8
|
-
# $Id:
|
8
|
+
# $Id: property.rb 167 2004-11-23 14:03:10Z gmosx $
|
9
9
|
|
10
|
-
require "
|
11
|
-
require "
|
10
|
+
require "glue/array"
|
11
|
+
require "glue/hash"
|
12
12
|
|
13
|
-
module
|
13
|
+
module G
|
14
14
|
|
15
15
|
# = Property
|
16
16
|
#
|
@@ -108,9 +108,9 @@ class Module
|
|
108
108
|
}
|
109
109
|
end
|
110
110
|
|
111
|
-
@__props =
|
111
|
+
@__props = G::SafeArray.new() unless @__props
|
112
112
|
|
113
|
-
property =
|
113
|
+
property = G::Property.new(symbol, klass, meta)
|
114
114
|
|
115
115
|
reader = meta[:reader] || true
|
116
116
|
writer = writer || meta[:writer] || false
|
@@ -265,7 +265,7 @@ class Module
|
|
265
265
|
# Attach metadata
|
266
266
|
#
|
267
267
|
def meta(key, val)
|
268
|
-
@__meta =
|
268
|
+
@__meta = G::SafeHash.new unless @__meta
|
269
269
|
|
270
270
|
@__meta[key] = [] unless @__meta[key]
|
271
271
|
|
@@ -280,7 +280,7 @@ class Module
|
|
280
280
|
def inherit_meta(mod = superclass)
|
281
281
|
# concat props.
|
282
282
|
if mod.__props
|
283
|
-
@__props =
|
283
|
+
@__props = G::SafeArray.new unless @__props
|
284
284
|
|
285
285
|
mod.__props.each { |p|
|
286
286
|
__add_prop(p)
|
@@ -4,11 +4,11 @@
|
|
4
4
|
# * Elias Karakoulakis <ekarak@ktismata.com>
|
5
5
|
#
|
6
6
|
# (c) 2004 Navel, all rights reserved.
|
7
|
-
# $Id: string.rb
|
7
|
+
# $Id: string.rb 165 2004-11-18 12:04:04Z gmosx $
|
8
8
|
|
9
9
|
require "uri"
|
10
10
|
|
11
|
-
module
|
11
|
+
module G;
|
12
12
|
|
13
13
|
# = StringUtils
|
14
14
|
#
|
@@ -221,3 +221,4 @@ module StringUtils
|
|
221
221
|
end
|
222
222
|
|
223
223
|
end # module
|
224
|
+
|
@@ -2,13 +2,13 @@
|
|
2
2
|
# * George Moschovitis <gm@navel.gr>
|
3
3
|
#
|
4
4
|
# (c) 2004 Navel, all rights reserved.
|
5
|
-
# $Id: time.rb
|
5
|
+
# $Id: time.rb 167 2004-11-23 14:03:10Z gmosx $
|
6
6
|
|
7
7
|
require "time.rb"
|
8
8
|
|
9
|
-
module
|
9
|
+
module G;
|
10
10
|
|
11
|
-
# =
|
11
|
+
# = Time
|
12
12
|
#
|
13
13
|
# General time utilities collection
|
14
14
|
#
|