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
@@ -2,16 +2,16 @@
|
|
2
2
|
# * George Moschovitis <gm@navel.gr>
|
3
3
|
#
|
4
4
|
# (c) 2004 Navel, all rights reserved.
|
5
|
-
# $Id: request.rb
|
5
|
+
# $Id: request.rb 155 2004-11-13 20:32:12Z gmosx $
|
6
6
|
|
7
7
|
require "cgi"
|
8
8
|
require "ftools"
|
9
9
|
|
10
|
-
require "
|
11
|
-
require "
|
12
|
-
require "
|
13
|
-
require "
|
14
|
-
require "
|
10
|
+
require "nitro/utils/string"
|
11
|
+
require "nitro/utils/uri"
|
12
|
+
require "nitro/utils/http"
|
13
|
+
require "nitro/server/cookie"
|
14
|
+
require "nitro/server/requestpart"
|
15
15
|
|
16
16
|
module N
|
17
17
|
|
@@ -2,15 +2,15 @@
|
|
2
2
|
# * George Moschovitis <gm@navel.gr>
|
3
3
|
#
|
4
4
|
# (c) 2004 Navel, all rights reserved.
|
5
|
-
# $Id: requestpart.rb
|
5
|
+
# $Id: requestpart.rb 155 2004-11-13 20:32:12Z gmosx $
|
6
6
|
|
7
7
|
require "cgi"
|
8
8
|
require "ftools"
|
9
9
|
|
10
|
-
require "
|
11
|
-
require "
|
12
|
-
require "
|
13
|
-
require "
|
10
|
+
require "nitro/utils/string"
|
11
|
+
require "nitro/utils/uri"
|
12
|
+
require "nitro/utils/http"
|
13
|
+
require "nitro/server/cookie"
|
14
14
|
|
15
15
|
module N
|
16
16
|
|
@@ -2,12 +2,12 @@
|
|
2
2
|
# * George Moschovitis <gm@navel.gr>
|
3
3
|
#
|
4
4
|
# (c) 2004 Navel, all rights reserved.
|
5
|
-
# $Id: script.rb
|
5
|
+
# $Id: script.rb 155 2004-11-13 20:32:12Z gmosx $
|
6
6
|
|
7
7
|
require "fileutils"
|
8
8
|
|
9
|
-
require "
|
10
|
-
require "
|
9
|
+
require "nitro/utils/cache"
|
10
|
+
require "nitro/server/fragment"
|
11
11
|
|
12
12
|
module N
|
13
13
|
|
@@ -2,13 +2,13 @@
|
|
2
2
|
# * George Moschovitis <gm@navel.gr>
|
3
3
|
#
|
4
4
|
# (c) 2004 Navel, all rights reserved.
|
5
|
-
# $Id: server.rb
|
5
|
+
# $Id: server.rb 155 2004-11-13 20:32:12Z gmosx $
|
6
6
|
|
7
7
|
require "drb"
|
8
8
|
|
9
|
-
require "
|
10
|
-
require "
|
11
|
-
require "
|
9
|
+
require "nitro/application"
|
10
|
+
require "nitro/server"
|
11
|
+
require "nitro/app/session"
|
12
12
|
|
13
13
|
module N; module App
|
14
14
|
|
@@ -2,12 +2,12 @@
|
|
2
2
|
# * George Moschovitis <gm@navel.gr>
|
3
3
|
#
|
4
4
|
# (c) 2002-2003 Navel, all rights reserved.
|
5
|
-
# $Id: session.rb
|
5
|
+
# $Id: session.rb 155 2004-11-13 20:32:12Z gmosx $
|
6
6
|
|
7
7
|
require "md5"
|
8
8
|
|
9
|
-
require "
|
10
|
-
require "
|
9
|
+
require "nitro/utils/hash"
|
10
|
+
require "nitro/server/user"
|
11
11
|
|
12
12
|
module N
|
13
13
|
|
@@ -0,0 +1,165 @@
|
|
1
|
+
# code:
|
2
|
+
# * George Moschovitis <gm@navel.gr>
|
3
|
+
#
|
4
|
+
# (c) 2004 Navel, all rights reserved.
|
5
|
+
# $Id: shaders.rb 152 2004-11-13 20:02:35Z gmosx $
|
6
|
+
|
7
|
+
module N
|
8
|
+
|
9
|
+
# = Shader
|
10
|
+
#
|
11
|
+
# The equivalent of a 3d engine shader. In essence it defines a
|
12
|
+
# transformation-pipeline that tansforms the .xhtml files to actual
|
13
|
+
# ruby code ready for evaluation (compilation) by the engine.
|
14
|
+
#
|
15
|
+
# Shaders are equivalend to the render-pipeline filters, ie they
|
16
|
+
# share their folded-filter design.
|
17
|
+
#--
|
18
|
+
# TODO: pipeline stage mixin to be reused in filters too.
|
19
|
+
#++
|
20
|
+
#
|
21
|
+
class Shader
|
22
|
+
# the next stage in the Shader pipeline.
|
23
|
+
attr :next_stage
|
24
|
+
|
25
|
+
def initialize(next_stage = nil)
|
26
|
+
@next_stage = next_stage
|
27
|
+
end
|
28
|
+
|
29
|
+
# Process the text and optionally update the hash.
|
30
|
+
# The hash is a short, unique representation of the input text,
|
31
|
+
# typically used as a caching key.
|
32
|
+
#
|
33
|
+
def process(hash, text)
|
34
|
+
process_next(hash, text)
|
35
|
+
end
|
36
|
+
|
37
|
+
# Set the next stage of the pipeline.
|
38
|
+
#
|
39
|
+
def << (next_stage = nil)
|
40
|
+
@next_stage = next_stage
|
41
|
+
return self
|
42
|
+
end
|
43
|
+
|
44
|
+
# Process the next stage of the pipeline.
|
45
|
+
#
|
46
|
+
def process_next(hash, text)
|
47
|
+
if @next_stage
|
48
|
+
return @next_stage.process(hash, text)
|
49
|
+
else
|
50
|
+
return hash, text
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
# = RubyShader
|
56
|
+
#
|
57
|
+
# Convert the xhtml script to actual Ruby code, ready to be
|
58
|
+
# evaluated.
|
59
|
+
#
|
60
|
+
class RubyShader < N::Shader
|
61
|
+
|
62
|
+
# Convert the xhtml script to actual Ruby code, ready to be
|
63
|
+
# evaluated.
|
64
|
+
#
|
65
|
+
def process(hash, text)
|
66
|
+
# strip the xml header! (interracts with the following gsub!)
|
67
|
+
text.gsub!(/<\?xml.*\?>/, "")
|
68
|
+
|
69
|
+
# xform include instructions <include href="xxx" />
|
70
|
+
# must be transformed before the processinc instructions.
|
71
|
+
text.gsub!(/<include href="(.*?)"(.*)(.?)\/>/) { |match|
|
72
|
+
"<?r render '/#$1' ?>"
|
73
|
+
}
|
74
|
+
|
75
|
+
# remove <root> elements. typically removed by xslt but lets
|
76
|
+
# play it safe.
|
77
|
+
text.gsub!(/<(\/)?root>/, '')
|
78
|
+
|
79
|
+
# xform the processing instructions, use <?r as
|
80
|
+
# a marker.
|
81
|
+
text.gsub!(/\?>/, "\n@out << %^")
|
82
|
+
text.gsub!(/<\?r /, "^\n")
|
83
|
+
|
84
|
+
# xform alternative code tags (used in xsl stylesheets)
|
85
|
+
#
|
86
|
+
text.gsub!(/<\/ruby>/, "\n@out << %^")
|
87
|
+
text.gsub!(/<ruby>/, "^\n")
|
88
|
+
|
89
|
+
text = "@out << %^" + text + "^"
|
90
|
+
|
91
|
+
process_next(hash, text)
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
95
|
+
|
96
|
+
# = XSLTShader
|
97
|
+
#
|
98
|
+
# Apply an XSL transformation to the script code.
|
99
|
+
# There is no need to keep post xsl. I can reuse the same xsl
|
100
|
+
# by calling transform again.
|
101
|
+
#
|
102
|
+
class XSLTShader < N::Shader
|
103
|
+
# The name
|
104
|
+
attr :name
|
105
|
+
# The xslt filename.
|
106
|
+
attr :xsl_filename
|
107
|
+
# The xslt transformer.
|
108
|
+
attr :xslt
|
109
|
+
# Last modified time of the xslt.
|
110
|
+
attr :mtime
|
111
|
+
|
112
|
+
def initialize(xsl_filename, next_stage = nil)
|
113
|
+
# leave this require here. only inlcude the xslt
|
114
|
+
# library if the project needs it.
|
115
|
+
require "xml/xslt"
|
116
|
+
|
117
|
+
@name = File.basename(xsl_filename, '.*')
|
118
|
+
@xsl_filename = xsl_filename
|
119
|
+
@xslt = XML::XSLT.new
|
120
|
+
@next_stage = next_stage
|
121
|
+
end
|
122
|
+
|
123
|
+
# Transform the given text
|
124
|
+
#
|
125
|
+
def process(hash, text)
|
126
|
+
parse_xsl()
|
127
|
+
@xslt.xml = text
|
128
|
+
hash += @name
|
129
|
+
|
130
|
+
process_next(hash, xslt.serve)
|
131
|
+
end
|
132
|
+
|
133
|
+
private
|
134
|
+
|
135
|
+
# Parse the xsl.
|
136
|
+
#
|
137
|
+
def parse_xsl
|
138
|
+
$log.debug "Parsing xsl '#{@xsl_filename}'" if $DBG
|
139
|
+
@mtime = File.mtime(@xsl_filename)
|
140
|
+
@xslt.xsl = File.read(@xsl_filename)
|
141
|
+
end
|
142
|
+
|
143
|
+
end
|
144
|
+
|
145
|
+
# = CompressShader
|
146
|
+
#
|
147
|
+
# Compress the inline xhtml. Does not touch the ruby code.
|
148
|
+
#
|
149
|
+
class CompressShader < N::Shader
|
150
|
+
|
151
|
+
# Compress the inline xhtml. Does not touch the ruby code.
|
152
|
+
#
|
153
|
+
def process(hash, text)
|
154
|
+
text.gsub!(/\@out \<\< \%\^(.*?)\^/m) do |match|
|
155
|
+
c = $1.gsub(/^(\s*)/m, '').squeeze(" \t").tr("\n", '').tr("\t", ' ')
|
156
|
+
"@out << %{#{c}}"
|
157
|
+
end
|
158
|
+
|
159
|
+
process_next(hash, text)
|
160
|
+
end
|
161
|
+
|
162
|
+
end
|
163
|
+
|
164
|
+
end # module
|
165
|
+
|
@@ -0,0 +1,175 @@
|
|
1
|
+
# code:
|
2
|
+
# * George Moschovitis <gm@navel.gr>
|
3
|
+
#
|
4
|
+
# (c) 2004 Navel, all rights reserved.
|
5
|
+
# $Id: webrick.rb 155 2004-11-13 20:32:12Z gmosx $
|
6
|
+
|
7
|
+
require "webrick"
|
8
|
+
|
9
|
+
require "nitro/server/appserver"
|
10
|
+
require "nitro/server/dispatcher"
|
11
|
+
require "nitro/server/render"
|
12
|
+
|
13
|
+
# Override WEBrick to suit our needs.
|
14
|
+
# Did I mention that WEBrick SUCKS ?
|
15
|
+
#
|
16
|
+
module WEBrick
|
17
|
+
|
18
|
+
class HTTPRequest
|
19
|
+
|
20
|
+
# Allow external setting of cookies.
|
21
|
+
#
|
22
|
+
def cookies=(val)
|
23
|
+
@cookies = val
|
24
|
+
end
|
25
|
+
|
26
|
+
# Allow external setting of query.
|
27
|
+
#
|
28
|
+
def set_query(query_string)
|
29
|
+
@query_string = query_string
|
30
|
+
@query = WEBrick::HTTPUtils::parse_query(query_string)
|
31
|
+
end
|
32
|
+
|
33
|
+
# Return the referer to this resource. For the initial page in the
|
34
|
+
# clickstream there is no referer, set "/" by default.
|
35
|
+
#
|
36
|
+
def referer
|
37
|
+
return @header["referer"].shift || "/"
|
38
|
+
end
|
39
|
+
alias_method :referrer, :referer
|
40
|
+
|
41
|
+
# Populate an object from request parameters.
|
42
|
+
# This is a truly dangerous method.
|
43
|
+
#
|
44
|
+
EXCLUDED_PARAMETERS = %w{ oid name }
|
45
|
+
def fill(obj, name = nil)
|
46
|
+
# if an object is passed create an instance.
|
47
|
+
obj = obj.new if obj.is_a?(Class)
|
48
|
+
|
49
|
+
@query.each do |param, val|
|
50
|
+
begin
|
51
|
+
# gmosx: DO NOT escape by default !!!
|
52
|
+
if not EXCLUDED_PARAMETERS.include?(param)
|
53
|
+
obj.send("__force_#{param}", val)
|
54
|
+
end
|
55
|
+
rescue NameError
|
56
|
+
next
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
return obj
|
61
|
+
end
|
62
|
+
alias_method :populate, :fill
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
end # module
|
67
|
+
|
68
|
+
module N
|
69
|
+
|
70
|
+
# = WebrickServer
|
71
|
+
#
|
72
|
+
# The Application Server. Handles dynamic requests in a web application.
|
73
|
+
# Dont keepalive (or use a VERY SMALL keepalive). Typically this server
|
74
|
+
# is used along with a standard http server that handles static
|
75
|
+
# resources like images, css.
|
76
|
+
#
|
77
|
+
# Used temporarily unitl we build our own app server.
|
78
|
+
#
|
79
|
+
class WebrickServer < N::AppServer
|
80
|
+
include WEBrick
|
81
|
+
|
82
|
+
# the integrated webrick server.
|
83
|
+
attr_accessor :webrick
|
84
|
+
|
85
|
+
def initialize(name = "WebrickServer")
|
86
|
+
super
|
87
|
+
end
|
88
|
+
|
89
|
+
# Start the application server.
|
90
|
+
#
|
91
|
+
def start
|
92
|
+
Socket.do_not_reverse_lookup = true # patch for OS X
|
93
|
+
|
94
|
+
accesslog = WEBrick::BasicLog::new("/dev/null")
|
95
|
+
referer = WEBrick::BasicLog::new("/dev/null")
|
96
|
+
|
97
|
+
@webrick = WEBrick::HTTPServer.new(
|
98
|
+
:BindAddress => $appsrv_address,
|
99
|
+
:Port => $appsrv_port,
|
100
|
+
:DocumentRoot => $root_dir,
|
101
|
+
:AccessLog => [
|
102
|
+
[accesslog, AccessLog::COMMON_LOG_FORMAT],
|
103
|
+
[referer, AccessLog::REFERER_LOG_FORMAT]
|
104
|
+
]
|
105
|
+
)
|
106
|
+
|
107
|
+
@webrick.mount('/', N::WebrickDispatcher)
|
108
|
+
|
109
|
+
trap("INT") { @webrick.shutdown }
|
110
|
+
@webrick.start
|
111
|
+
end
|
112
|
+
|
113
|
+
# Stop the application server.
|
114
|
+
#
|
115
|
+
def stop
|
116
|
+
@webrick.stop
|
117
|
+
end
|
118
|
+
|
119
|
+
end
|
120
|
+
|
121
|
+
# = WebrickDispatcher
|
122
|
+
#
|
123
|
+
class WebrickDispatcher < WEBrick::HTTPServlet::AbstractServlet
|
124
|
+
include N::Dispatcher
|
125
|
+
|
126
|
+
def initialize(server)
|
127
|
+
# Handles static resources. Useful when running a standalone
|
128
|
+
# webrick server.
|
129
|
+
@file_handler = WEBrick::HTTPServlet::FileHandler.new(server, $root_dir, {:FancyIndexing => true })
|
130
|
+
end
|
131
|
+
|
132
|
+
def do_GET(request, response)
|
133
|
+
path = request.request_uri.path
|
134
|
+
|
135
|
+
# rationalize cookies, WEBrick just SUCKS!!
|
136
|
+
tmp = {}
|
137
|
+
request.cookies.each { |c|
|
138
|
+
tmp[c.name] = c
|
139
|
+
}
|
140
|
+
request.cookies = tmp
|
141
|
+
|
142
|
+
if path =~ /\./
|
143
|
+
@file_handler.do_GET(request, response)
|
144
|
+
else
|
145
|
+
process(request, response)
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
alias :do_POST :do_GET
|
150
|
+
|
151
|
+
|
152
|
+
# Create session
|
153
|
+
#
|
154
|
+
def create_session(request, response)
|
155
|
+
session = nil
|
156
|
+
|
157
|
+
if cookie = request.cookies[N::Session::COOKIE_NAME]
|
158
|
+
session = $sessions[cookie.value]
|
159
|
+
end
|
160
|
+
|
161
|
+
unless session
|
162
|
+
$log.debug 'Creating new session.' if $DBG
|
163
|
+
# no session cookie or stale session (garbage collected).
|
164
|
+
session_id = N::Session.calculate_id()
|
165
|
+
cookie = WEBrick::Cookie.new(N::Session::COOKIE_NAME, session_id)
|
166
|
+
response.cookies << cookie
|
167
|
+
session = $sessions[session_id] = N::Session.new(session_id)
|
168
|
+
end
|
169
|
+
|
170
|
+
return session
|
171
|
+
end
|
172
|
+
|
173
|
+
end
|
174
|
+
|
175
|
+
end # module
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# code:
|
2
|
+
# * George Moschovitis <gm@navel.gr>
|
3
|
+
#
|
4
|
+
# (c) 2004 Navel, all rights reserved.
|
5
|
+
# $Id: service.rb 155 2004-11-13 20:32:12Z gmosx $
|
6
|
+
|
7
|
+
require 'nitro/server/render'
|
8
|
+
|
9
|
+
module N
|
10
|
+
|
11
|
+
# = Service
|
12
|
+
#
|
13
|
+
# An Application Server service.
|
14
|
+
#
|
15
|
+
class Service
|
16
|
+
include N::Render
|
17
|
+
|
18
|
+
# The base path of the service, essentially the mount point.
|
19
|
+
attr :base_path
|
20
|
+
end
|
21
|
+
|
22
|
+
class Methods
|
23
|
+
end
|
24
|
+
|
25
|
+
end # module
|