nitro 0.3.0 → 0.4.1
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 +284 -0
- data/{LICENCE → LICENSE} +1 -1
- data/README +13 -17
- data/RELEASES +13 -1
- data/Rakefile +1 -9
- data/bin/cluster.rb +5 -5
- data/examples/blog/README +45 -0
- data/examples/blog/apache.conf +0 -0
- data/examples/blog/app.rb +21 -0
- data/examples/blog/config.rb +88 -0
- data/examples/blog/lib/blog.rb +104 -0
- data/examples/blog/log/app.log +117 -0
- data/examples/blog/root/comments.xhtml +38 -0
- data/examples/blog/root/entry_form.xhtml +18 -0
- data/examples/blog/root/index.xhtml +43 -0
- data/examples/blog/root/login.xhtml +24 -0
- data/examples/blog/root/m/bubbles.gif +0 -0
- data/examples/blog/root/m/comments_curve.gif +0 -0
- data/examples/blog/root/m/down.gif +0 -0
- data/examples/blog/root/m/footer_bg.gif +0 -0
- data/examples/blog/root/m/garrow.gif +0 -0
- data/examples/blog/root/m/gbull.gif +0 -0
- data/examples/blog/root/m/grbull.gif +0 -0
- data/examples/blog/root/m/h1_bg.gif +0 -0
- data/examples/blog/root/m/header_bg.gif +0 -0
- data/examples/blog/root/m/obull.gif +0 -0
- data/examples/blog/root/m/page_bg.gif +0 -0
- data/examples/blog/root/m/side_title_bg.gif +0 -0
- data/examples/blog/root/m/sidebar_bg.gif +0 -0
- data/examples/blog/root/recent_posts.xhtml +14 -0
- data/examples/blog/root/style.css +201 -0
- data/examples/blog/root/style.xsl +118 -0
- data/examples/blog/root/view_entry.xhtml +29 -0
- data/examples/og/run.rb +27 -29
- data/examples/tiny/README +3 -4
- data/examples/tiny/app.rb +6 -16
- data/examples/tiny/config.rb +30 -0
- data/examples/tiny/log/app.log +23 -0
- data/examples/tiny/root/{index.sx → index.xhtml} +3 -6
- data/lib/{n/std.rb → nitro.rb} +9 -4
- data/lib/{n → nitro}/application.rb +13 -7
- data/lib/{n → nitro}/config.rb +38 -8
- data/lib/{n → nitro}/events.rb +1 -1
- data/lib/{n → nitro}/l10n.rb +1 -1
- data/lib/{n → nitro}/logger.rb +8 -8
- data/lib/{n → nitro}/macros.rb +3 -3
- data/lib/{n → nitro}/mixins.rb +1 -1
- data/lib/nitro/properties.rb +301 -0
- data/lib/{n → nitro}/server.rb +2 -2
- data/lib/{n → nitro}/server/appserver.rb +14 -5
- data/lib/{n → nitro}/server/cluster.rb +5 -5
- data/lib/{n → nitro}/server/cookie.rb +1 -1
- data/lib/nitro/server/dispatcher.rb +66 -0
- data/lib/{n → nitro}/server/filters.rb +7 -7
- data/lib/{n → nitro}/server/filters/autologin.rb +3 -3
- data/lib/{n → nitro}/server/fragment.rb +3 -3
- data/lib/{n → nitro}/server/handlers.rb +3 -3
- data/lib/nitro/server/render.rb +200 -0
- data/lib/{n → nitro}/server/request.rb +6 -6
- data/lib/{n → nitro}/server/requestpart.rb +5 -5
- data/lib/{n → nitro}/server/script.rb +3 -3
- data/lib/{n → nitro}/server/server.rb +4 -4
- data/lib/{n → nitro}/server/session.rb +3 -3
- data/lib/nitro/server/shaders.rb +165 -0
- data/lib/{n → nitro}/server/user.rb +1 -1
- data/lib/nitro/server/webrick.rb +175 -0
- data/lib/nitro/service.rb +25 -0
- data/lib/{n → nitro}/sitemap.rb +2 -2
- data/lib/{n → nitro}/ui/date-select.rb +0 -0
- data/lib/{n → nitro}/ui/pager.rb +1 -1
- data/lib/{n → nitro}/ui/popup.rb +1 -1
- data/lib/{n → nitro}/ui/select.rb +1 -1
- data/lib/{n → nitro}/ui/tabs.rb +1 -1
- data/lib/{n → nitro}/utils/array.rb +1 -1
- data/lib/{n → nitro}/utils/cache.rb +1 -1
- data/lib/{n → nitro}/utils/gfx.rb +1 -1
- data/lib/{n → nitro}/utils/hash.rb +1 -1
- data/lib/{n → nitro}/utils/html.rb +1 -1
- data/lib/{n → nitro}/utils/http.rb +1 -1
- data/lib/{n → nitro}/utils/mail.rb +1 -1
- data/lib/{n → nitro}/utils/number.rb +1 -1
- data/lib/{n → nitro}/utils/pool.rb +1 -1
- data/lib/{n → nitro}/utils/string.rb +19 -95
- data/lib/{n → nitro}/utils/template.rb +0 -0
- data/lib/{n → nitro}/utils/time.rb +1 -1
- data/lib/{n → nitro}/utils/uri.rb +3 -3
- data/lib/nitro/version.rb +11 -0
- data/lib/{n/og.rb → og.rb} +61 -31
- data/lib/{n/og → og}/backend.rb +13 -7
- data/lib/{n/og → og}/backends/mysql.rb +43 -39
- data/lib/{n/og → og}/backends/psql.rb +42 -38
- data/lib/{n/og → og}/connection.rb +21 -9
- data/lib/{n/og → og}/meta.rb +18 -12
- data/lib/xsl/base.xsl +11 -88
- data/test/n/server/tc_cookie.rb +1 -1
- data/test/n/server/tc_filters.rb +1 -1
- data/test/n/server/tc_request.rb +3 -3
- data/test/n/server/tc_requestpart.rb +2 -2
- data/test/n/server/tc_session.rb +1 -1
- data/test/n/tc_events.rb +1 -1
- data/test/n/tc_og.rb +16 -18
- data/test/n/tc_properties.rb +22 -18
- data/test/n/tc_sitemap.rb +2 -2
- data/test/n/ui/tc_pager.rb +4 -4
- data/test/n/utils/tc_cache.rb +1 -1
- data/test/n/utils/tc_hash.rb +1 -1
- data/test/n/utils/tc_html.rb +1 -1
- data/test/n/utils/tc_http.rb +1 -1
- data/test/n/utils/tc_number.rb +1 -1
- data/test/n/utils/tc_strings.rb +1 -46
- data/test/n/utils/tc_uri.rb +1 -1
- metadata +101 -108
- data/examples/simple/README +0 -42
- data/examples/simple/app.rb +0 -31
- data/examples/simple/conf/apache.conf +0 -100
- data/examples/simple/conf/config.rb +0 -72
- data/examples/simple/conf/debug-config.rb +0 -26
- data/examples/simple/conf/live-config.rb +0 -26
- data/examples/simple/conf/requires.rb +0 -43
- data/examples/simple/ctl +0 -32
- data/examples/simple/env.rb +0 -32
- data/examples/simple/install.rb +0 -12
- data/examples/simple/lib/articles/entities.rb +0 -37
- data/examples/simple/lib/articles/lc-en.rb +0 -36
- data/examples/simple/lib/articles/methods.rb +0 -55
- data/examples/simple/lib/articles/part.rb +0 -57
- data/examples/simple/root/add-article.sx +0 -15
- data/examples/simple/root/article-form.ss +0 -20
- data/examples/simple/root/comments-form.ss +0 -16
- data/examples/simple/root/comments.si +0 -30
- data/examples/simple/root/index.sx +0 -44
- data/examples/simple/root/shader/shader.xsl +0 -100
- data/examples/simple/root/shader/style.css +0 -9
- data/examples/simple/root/view-article.sx +0 -29
- data/examples/tiny/conf/config.rb +0 -62
- data/examples/tiny/conf/requires.rb +0 -33
- data/examples/tiny/ctl +0 -16
- data/lib/n/parts.rb +0 -157
- data/lib/n/properties.rb +0 -199
- data/lib/n/server/dispatcher.rb +0 -55
- data/lib/n/server/handlers/code-handler.rb +0 -182
- data/lib/n/server/handlers/page-handler.rb +0 -612
- data/lib/n/server/webrick.rb +0 -283
- data/lib/n/shaders.rb +0 -166
- data/lib/n/sync/clc.rb +0 -110
- data/lib/n/sync/handler.rb +0 -229
- data/lib/n/sync/server.rb +0 -176
- data/lib/p/README +0 -1
data/lib/{n → nitro}/sitemap.rb
RENAMED
@@ -6,9 +6,9 @@
|
|
6
6
|
# George Moschovitis <gm@navel.gr>
|
7
7
|
#
|
8
8
|
# (c) 2004 Navel, all rights reserved.
|
9
|
-
# $Id: sitemap.rb
|
9
|
+
# $Id: sitemap.rb 155 2004-11-13 20:32:12Z gmosx $
|
10
10
|
|
11
|
-
require "
|
11
|
+
require "nitro/utils/hash"
|
12
12
|
|
13
13
|
module N
|
14
14
|
|
File without changes
|
data/lib/{n → nitro}/ui/pager.rb
RENAMED
data/lib/{n → nitro}/ui/popup.rb
RENAMED
data/lib/{n → nitro}/ui/tabs.rb
RENAMED
@@ -4,7 +4,7 @@
|
|
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 152 2004-11-13 20:02:35Z gmosx $
|
8
8
|
|
9
9
|
require "uri"
|
10
10
|
|
@@ -56,7 +56,10 @@ module StringUtils
|
|
56
56
|
"�" => "w", "�" => "W", "�" => "w", "�"=>"W"
|
57
57
|
}
|
58
58
|
|
59
|
-
# Convert the input string to greeklish
|
59
|
+
# Convert the input string to greeklish.
|
60
|
+
#--
|
61
|
+
# gmosx, TODO: remove from public distribution
|
62
|
+
#++
|
60
63
|
#
|
61
64
|
def self.to_greeklish(input)
|
62
65
|
return nil unless input
|
@@ -86,13 +89,13 @@ module StringUtils
|
|
86
89
|
return nil unless string
|
87
90
|
return nil if count < 2
|
88
91
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
+
if string.size > count
|
93
|
+
cut_at = force_cutoff ? count : (string.index(' ', count-1) || count)
|
94
|
+
xstring = string.slice(0, cut_at)
|
92
95
|
return xstring.chomp(" ") + ellipsis
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
+
else
|
97
|
+
return string
|
98
|
+
end
|
96
99
|
end
|
97
100
|
|
98
101
|
# Apply a set of rules (regular expression matches) to the
|
@@ -130,7 +133,10 @@ module StringUtils
|
|
130
133
|
|
131
134
|
# Enforces a maximum width of a string inside an
|
132
135
|
# html container. If the string exceeds this maximum width
|
133
|
-
# the string gets wraped
|
136
|
+
# the string gets wraped.
|
137
|
+
#
|
138
|
+
# Not really useful, better use the CSS overflow: hidden
|
139
|
+
# functionality.
|
134
140
|
#
|
135
141
|
# === Input:
|
136
142
|
# the string to be wrapped
|
@@ -142,7 +148,7 @@ module StringUtils
|
|
142
148
|
#
|
143
149
|
# === Example:
|
144
150
|
# text = "1111111111111111111111111111111111111111111"
|
145
|
-
# text =
|
151
|
+
# text = wrap(text, 10, " ")
|
146
152
|
# p text # => "1111111111 1111111111 1111111111"
|
147
153
|
#
|
148
154
|
# See the test cases to better understand the behaviour!
|
@@ -156,70 +162,6 @@ module StringUtils
|
|
156
162
|
return wrapped_string
|
157
163
|
end
|
158
164
|
|
159
|
-
EXTENSION_REGEX = /\.(\w+)$/
|
160
|
-
|
161
|
-
# extracts the extension from a path or filename.
|
162
|
-
#
|
163
|
-
# === Input:
|
164
|
-
# the path to a file (or just a plain filename)
|
165
|
-
#
|
166
|
-
# === Output:
|
167
|
-
# the extension of the filename
|
168
|
-
# returns nil if no exception
|
169
|
-
# the extension is DOWNCASED!
|
170
|
-
#
|
171
|
-
def self.extension_from_path(path)
|
172
|
-
if md = EXTENSION_REGEX.match(path)
|
173
|
-
return md[1].downcase
|
174
|
-
else
|
175
|
-
return nil
|
176
|
-
end
|
177
|
-
end
|
178
|
-
|
179
|
-
# Extracts the (file)name from a path or filename.
|
180
|
-
#
|
181
|
-
# === Input:
|
182
|
-
# the path to a file (or just a plain filename)
|
183
|
-
#
|
184
|
-
# === Output:
|
185
|
-
# the name part of the filename (the extension is stripped)
|
186
|
-
# returns empty string if input is nil (safer?)
|
187
|
-
#
|
188
|
-
def self.filename_from_path(path)
|
189
|
-
# gmosx: "" is safer, no??? and it is logical too.
|
190
|
-
return "" unless path
|
191
|
-
parts = path.split(EXTENSION_REGEX)
|
192
|
-
return parts[0]
|
193
|
-
end
|
194
|
-
|
195
|
-
# Extracts the file part from a path or filename.
|
196
|
-
#
|
197
|
-
# === Input:
|
198
|
-
# the path to a file (or just a plain filename)
|
199
|
-
#
|
200
|
-
# === Output:
|
201
|
-
# the file part (the directory is stripped)
|
202
|
-
# returns empty string if input is nil (safer?)
|
203
|
-
#
|
204
|
-
def self.file_from_path(path)
|
205
|
-
return "" unless path
|
206
|
-
return path.split("/").slice(-1)
|
207
|
-
end
|
208
|
-
|
209
|
-
# Extracts the directory part from a path or filename.
|
210
|
-
#
|
211
|
-
# === Input:
|
212
|
-
# the path to a file (or just a plain filename)
|
213
|
-
#
|
214
|
-
# === Output:
|
215
|
-
# the directory part (the filename is stripped)
|
216
|
-
# returns empty string if input is nil (safer?)
|
217
|
-
#
|
218
|
-
def self.directory_from_path(path)
|
219
|
-
return "" unless path
|
220
|
-
return path.chomp(self.file_from_path(path)).chop()
|
221
|
-
end
|
222
|
-
|
223
165
|
# Replace dangerours chars in filenames
|
224
166
|
#
|
225
167
|
def self.rationalize_filename(filename)
|
@@ -261,29 +203,11 @@ module StringUtils
|
|
261
203
|
return string
|
262
204
|
end
|
263
205
|
|
264
|
-
# Converts unicode to ISO8859-7 (unfortunately Ruby is a little poor at i18n)
|
265
|
-
# Usefull for parsing xmls with libxml.
|
266
|
-
#
|
267
|
-
# === Input:
|
268
|
-
# the string to convert
|
269
|
-
#
|
270
|
-
# === Output:
|
271
|
-
# the converted string
|
272
|
-
#
|
273
|
-
# === TODO:
|
274
|
-
# - MORE TEST UNITS !!!!
|
275
|
-
#
|
276
|
-
def self.unicode_to_iso88597(string)
|
277
|
-
return string.to_s.unpack('U*').collect {|ch|
|
278
|
-
ch>127 ? ch-0x02d0 : ch
|
279
|
-
}.pack('C*')
|
280
|
-
end
|
281
|
-
|
282
|
-
|
283
206
|
# Screen an IP address
|
284
|
-
|
207
|
+
#--
|
285
208
|
# gmosx: copied this method from n1, check how it works!
|
286
|
-
#
|
209
|
+
# probably deprecate?
|
210
|
+
#++
|
287
211
|
def self.screen_ip_address(address)
|
288
212
|
if address
|
289
213
|
return address.split(',').collect { |hostip|
|
File without changes
|
@@ -2,12 +2,12 @@
|
|
2
2
|
# * George Moschovitis <gm@navel.gr>
|
3
3
|
#
|
4
4
|
# (c) 2004 Navel, all rights reserved.
|
5
|
-
# $Id: uri.rb
|
5
|
+
# $Id: uri.rb 155 2004-11-13 20:32:12Z gmosx $
|
6
6
|
|
7
7
|
require "uri"
|
8
8
|
require "cgi"
|
9
9
|
|
10
|
-
require "
|
10
|
+
require "nitro/utils/string"
|
11
11
|
|
12
12
|
module N
|
13
13
|
|
@@ -37,7 +37,7 @@ module UriUtils
|
|
37
37
|
if md = URI::REGEXP::REL_URI.match(escaped_uri)
|
38
38
|
|
39
39
|
path = "#{md[5]}#{md[6]}"
|
40
|
-
type =
|
40
|
+
type = File.extname(path)
|
41
41
|
query_string = md[7]
|
42
42
|
|
43
43
|
# real_path = "#{$root_dir}/#{path}"
|
data/lib/{n/og.rb → og.rb}
RENAMED
@@ -2,28 +2,15 @@
|
|
2
2
|
# * George Moschovitis <gm@navel.gr>
|
3
3
|
#
|
4
4
|
# (c) 2004 Navel, all rights reserved.
|
5
|
-
# $Id: og.rb
|
5
|
+
# $Id: og.rb 155 2004-11-13 20:32:12Z gmosx $
|
6
6
|
|
7
|
-
require "
|
8
|
-
require "
|
9
|
-
require "
|
10
|
-
require "
|
11
|
-
require "
|
7
|
+
require "nitro/properties"
|
8
|
+
require "nitro/utils/array"
|
9
|
+
require "nitro/utils/hash"
|
10
|
+
require "nitro/utils/time"
|
11
|
+
require "nitro/utils/pool"
|
12
12
|
|
13
|
-
require "
|
14
|
-
|
15
|
-
module N
|
16
|
-
|
17
|
-
# If true, only allow reading from the database. Usefull
|
18
|
-
# for maintainance.
|
19
|
-
#
|
20
|
-
$og_read_only_mode = false
|
21
|
-
|
22
|
-
# If true, the library automatically 'enchants' managed classes.
|
23
|
-
# In enchant mode, special db aware methods are added to
|
24
|
-
# managed classes and instances.
|
25
|
-
#
|
26
|
-
$og_enchant_managed_classes = true
|
13
|
+
require "og/meta"
|
27
14
|
|
28
15
|
# = Og
|
29
16
|
#
|
@@ -104,7 +91,35 @@ $og_enchant_managed_classes = true
|
|
104
91
|
# * Deserialize to OpenStruct.
|
105
92
|
# * Better documentation.
|
106
93
|
#
|
107
|
-
|
94
|
+
module Og
|
95
|
+
|
96
|
+
# If true, only allow reading from the database. Usefull
|
97
|
+
# for maintainance.
|
98
|
+
#
|
99
|
+
$og_read_only_mode = false
|
100
|
+
|
101
|
+
# If true, the library automatically 'enchants' managed classes.
|
102
|
+
# In enchant mode, special db aware methods are added to
|
103
|
+
# managed classes and instances.
|
104
|
+
#
|
105
|
+
$og_enchant_managed_classes = true
|
106
|
+
|
107
|
+
# If true, use Ruby's advanced introspection capabilities to
|
108
|
+
# automatically manage classes tha define properties.
|
109
|
+
$og_auto_manage_classes = true
|
110
|
+
|
111
|
+
# = Unmanageable
|
112
|
+
#
|
113
|
+
# Marker module. If included this in a class, the Og automanager
|
114
|
+
# ignores this class.
|
115
|
+
#
|
116
|
+
module Unmanageable; end
|
117
|
+
|
118
|
+
# = Database
|
119
|
+
#
|
120
|
+
# Encapsulates an Og Database.
|
121
|
+
#
|
122
|
+
class Database
|
108
123
|
|
109
124
|
# Managed class metadata
|
110
125
|
#
|
@@ -140,7 +155,7 @@ class Og
|
|
140
155
|
|
141
156
|
# require the backend.
|
142
157
|
backend = @config[:backend] || "psql"
|
143
|
-
require "
|
158
|
+
require "og/backends/#{backend}"
|
144
159
|
eval %{ @config[:backend] = #{backend.capitalize}Backend }
|
145
160
|
|
146
161
|
@connection_pool = N::Pool.new
|
@@ -149,7 +164,21 @@ class Og
|
|
149
164
|
$log.info "Connecting to database '#{@config[:database]}' using backend '#{backend}'."
|
150
165
|
|
151
166
|
@config[:connection_count].times do
|
152
|
-
@connection_pool <<
|
167
|
+
@connection_pool << Og::Connection.new(self)
|
168
|
+
end
|
169
|
+
|
170
|
+
if $og_auto_manage_classes
|
171
|
+
# automatically manage classes with properties and metadata.
|
172
|
+
# gmosx: Any idea how to optimize this?
|
173
|
+
classes_to_manage = []
|
174
|
+
ObjectSpace.each_object(Class) do |c|
|
175
|
+
if c.respond_to?(:__props) and c.__props
|
176
|
+
classes_to_manage << c
|
177
|
+
end
|
178
|
+
end
|
179
|
+
$log.info "Og auto manages the following classes:"
|
180
|
+
$log.info "#{classes_to_manage.inspect}"
|
181
|
+
manage_classes(*classes_to_manage)
|
153
182
|
end
|
154
183
|
end
|
155
184
|
|
@@ -215,7 +244,7 @@ class Og
|
|
215
244
|
# Register a standard Ruby class as managed.
|
216
245
|
#
|
217
246
|
def manage(klass)
|
218
|
-
return if managed?(klass)
|
247
|
+
return if managed?(klass) or klass.ancestors.include?(Og::Unmanageable)
|
219
248
|
|
220
249
|
@managed_classes[klass] = ManagedClassMeta.new(klass)
|
221
250
|
|
@@ -251,13 +280,13 @@ class Og
|
|
251
280
|
def convert(klass)
|
252
281
|
# gmosx: this check is needed to allow the developer to customize
|
253
282
|
# the sql generated for oid
|
254
|
-
|
283
|
+
Og::Utils.eval_og_oid(klass) unless klass.instance_methods.include?(:oid)
|
255
284
|
|
256
285
|
klass.class_eval %{
|
257
286
|
inherit_meta(superclass) if superclass
|
258
287
|
|
259
|
-
DBTABLE = "#{
|
260
|
-
DBSEQ = "#{
|
288
|
+
DBTABLE = "#{Og::Utils.table(klass)}"
|
289
|
+
DBSEQ = "#{Og::Utils.table(klass)}_oids_seq"
|
261
290
|
|
262
291
|
def to_i()
|
263
292
|
@oid
|
@@ -270,9 +299,9 @@ class Og
|
|
270
299
|
# Precompile some code that gets executed all the time.
|
271
300
|
# Deletion code is not precompiled, because it is not used
|
272
301
|
# as frequently.
|
273
|
-
|
274
|
-
|
275
|
-
|
302
|
+
Og::Utils.eval_og_insert(klass)
|
303
|
+
Og::Utils.eval_og_update(klass)
|
304
|
+
Og::Utils.eval_og_deserialize(klass, self)
|
276
305
|
end
|
277
306
|
|
278
307
|
# Enchant a managed class. Add useful DB related methods to the
|
@@ -359,6 +388,7 @@ class Og
|
|
359
388
|
wrap_method :load_all, "klass, extrasql = nil"
|
360
389
|
wrap_method :select, "sql, klass"
|
361
390
|
wrap_method :select_one, "sql, klass"
|
391
|
+
wrap_method :count, "sql, klass = nil"
|
362
392
|
wrap_method :delete, "obj_or_oid, klass = nil"
|
363
393
|
wrap_method :query, "sql"
|
364
394
|
wrap_method :exec, "sql"
|
@@ -370,7 +400,7 @@ class Og
|
|
370
400
|
|
371
401
|
def self.drop_db!(config)
|
372
402
|
backend = config[:backend] || "psql"
|
373
|
-
require "
|
403
|
+
require "og/backends/#{backend}"
|
374
404
|
eval %{
|
375
405
|
#{backend.capitalize}Backend.drop_db(config[:database], config[:user],
|
376
406
|
config[:password])
|