nitro 0.15.0 → 0.16.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +218 -0
- data/INSTALL +3 -0
- data/README +4 -2
- data/Rakefile +150 -8
- data/benchmark/bench.rb +1 -1
- data/doc/AUTHORS +2 -8
- data/doc/RELEASES +63 -1
- data/examples/ajax/controller.rb +2 -2
- data/examples/ajax/public/index.xhtml +3 -1
- data/examples/ajax/run.rb +3 -3
- data/examples/blog/README +8 -0
- data/examples/blog/cache/entriesadmintrue +3 -0
- data/examples/blog/run.rb +38 -40
- data/examples/blog/src/blog.rb +2 -1
- data/examples/blog/src/controller.rb +40 -20
- data/examples/blog/src/mailer.rb +2 -2
- data/examples/blog/src/models/blog.rb +2 -1
- data/examples/blog/src/models/content.rb +4 -33
- data/examples/blog/src/views/error.xhtml +1 -1
- data/examples/blog/src/xsl/style.xsl +1 -1
- data/examples/blog/test/tc_blog.rb +43 -0
- data/examples/flash/run.rb +2 -2
- data/examples/no_xsl_blog/lib/blog.rb +1 -1
- data/examples/no_xsl_blog/lib/blog/controller.rb +26 -17
- data/examples/no_xsl_blog/lib/blog/model.rb +3 -3
- data/examples/no_xsl_blog/lib/blog/template.rb +1 -1
- data/examples/no_xsl_blog/lib/content.rb +3 -7
- data/examples/no_xsl_blog/run.rb +34 -34
- data/examples/tiny/public/deep/dir/hello.xhtml +2 -0
- data/examples/tiny/run.rb +2 -2
- data/examples/wee_style/run.rb +5 -3
- data/examples/why_wiki/run.rb +5 -3
- data/install.rb +1 -1
- data/lib/nitro.rb +10 -9
- data/lib/nitro/adapters/cgi.rb +27 -2
- data/lib/nitro/adapters/fastcgi.rb +6 -2
- data/lib/nitro/adapters/webrick.rb +11 -9
- data/lib/nitro/buffering.rb +2 -2
- data/lib/nitro/builders/atom.rb +78 -0
- data/lib/nitro/builders/form.rb +2 -2
- data/lib/nitro/builders/rss.rb +4 -4
- data/lib/nitro/builders/table.rb +2 -2
- data/lib/nitro/builders/xhtml.rb +5 -8
- data/lib/nitro/builders/xml.rb +38 -14
- data/lib/nitro/caching.rb +2 -2
- data/lib/nitro/caching/actions.rb +2 -2
- data/lib/nitro/caching/fragments.rb +2 -2
- data/lib/nitro/caching/invalidation.rb +2 -28
- data/lib/nitro/caching/output.rb +3 -3
- data/lib/nitro/caching/stores.rb +4 -4
- data/lib/nitro/conf.rb +11 -6
- data/lib/nitro/context.rb +2 -2
- data/lib/nitro/controller.rb +12 -7
- data/lib/nitro/cookie.rb +2 -2
- data/lib/nitro/dispatcher.rb +33 -40
- data/lib/nitro/environment.rb +1 -1
- data/lib/nitro/localization.rb +5 -7
- data/lib/nitro/mail.rb +2 -2
- data/lib/nitro/markup.rb +5 -5
- data/lib/nitro/output.rb +2 -2
- data/lib/nitro/part.rb +8 -5
- data/lib/nitro/render.rb +46 -45
- data/lib/nitro/request.rb +7 -6
- data/lib/nitro/response.rb +14 -5
- data/lib/nitro/routing.rb +2 -2
- data/lib/nitro/runner.rb +57 -17
- data/lib/nitro/scaffold.rb +14 -8
- data/lib/nitro/session.rb +7 -4
- data/lib/nitro/session/drb.rb +2 -2
- data/lib/nitro/session/drbserver.rb +2 -2
- data/lib/nitro/session/memory.rb +2 -2
- data/lib/nitro/shaders.rb +8 -7
- data/lib/nitro/simple.rb +4 -1
- data/lib/nitro/template.rb +8 -8
- data/lib/nitro/testing.rb +6 -0
- data/lib/nitro/testing/assertions.rb +102 -0
- data/lib/nitro/testing/context.rb +52 -0
- data/lib/nitro/testing/testcase.rb +55 -0
- data/lib/nitro/ui/pager.rb +3 -3
- data/lib/nitro/ui/popup.rb +8 -13
- data/lib/nitro/ui/tabs.rb +4 -10
- data/lib/nitro/uri.rb +7 -7
- data/proto/doc/README +1 -0
- data/proto/public/cgi.rb +5 -0
- data/proto/run.rb +2 -4
- data/test/nitro/adapters/tc_cgi.rb +1 -1
- data/test/nitro/adapters/tc_webrick.rb +1 -2
- data/test/nitro/builders/tc_atom.rb +26 -0
- data/test/nitro/builders/tc_rss.rb +3 -2
- data/test/nitro/builders/tc_table.rb +1 -1
- data/test/nitro/builders/tc_xhtml.rb +4 -3
- data/test/nitro/builders/tc_xml.rb +7 -7
- data/test/nitro/tc_context.rb +1 -1
- data/test/nitro/tc_controller.rb +5 -3
- data/test/nitro/tc_dispatcher.rb +19 -18
- data/test/nitro/tc_localization.rb +1 -1
- data/test/nitro/tc_mail.rb +1 -1
- data/test/nitro/tc_session.rb +1 -1
- data/test/nitro/tc_template.rb +1 -1
- data/test/nitro/tc_uri.rb +3 -4
- data/test/nitro/ui/tc_pager.rb +7 -7
- data/test/public/blog/inc1.xhtml +2 -0
- data/test/public/blog/inc2.xhtml +1 -0
- data/test/public/blog/list.xhtml +3 -0
- metadata +180 -203
- data/examples/blog/cache/entriesadmin +0 -12
- data/lib/nitro/cluster.rb +0 -218
- data/lib/nitro/component.rb +0 -15
- data/lib/nitro/filters.rb +0 -215
- data/lib/nitro/ui/date-select.rb +0 -69
- data/test/nitro/tc_filters.rb +0 -111
data/lib/nitro/session/drb.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# * George Moschovitis <gm@navel.gr>
|
2
2
|
# (c) 2004-2005 Navel, all rights reserved.
|
3
|
-
# $Id: drb.rb
|
3
|
+
# $Id: drb.rb 1 2005-04-11 11:04:30Z gmosx $
|
4
4
|
|
5
5
|
require 'drb'
|
6
6
|
|
@@ -9,7 +9,7 @@ require 'nitro/session'
|
|
9
9
|
|
10
10
|
Logger.debug 'Using Drb sessions.'
|
11
11
|
|
12
|
-
module
|
12
|
+
module Nitro
|
13
13
|
|
14
14
|
class Session
|
15
15
|
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
# * George Moschovitis <gm@navel.gr>
|
4
4
|
# (c) 2004-2005 Navel, all rights reserved.
|
5
|
-
# $Id: drbserver.rb
|
5
|
+
# $Id: drbserver.rb 1 2005-04-11 11:04:30Z gmosx $
|
6
6
|
|
7
7
|
require 'drb'
|
8
8
|
require 'optparse'
|
@@ -49,7 +49,7 @@ rescue OptionParser::InvalidOption
|
|
49
49
|
exit
|
50
50
|
end
|
51
51
|
|
52
|
-
sessions =
|
52
|
+
sessions = Glue::SafeHash.new
|
53
53
|
|
54
54
|
if debug
|
55
55
|
|
data/lib/nitro/session/memory.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
# * George Moschovitis <gm@navel.gr>
|
2
2
|
# (c) 2004-2005 Navel, all rights reserved.
|
3
|
-
# $Id: memory.rb
|
3
|
+
# $Id: memory.rb 1 2005-04-11 11:04:30Z gmosx $
|
4
4
|
|
5
5
|
require 'glue/hash'
|
6
6
|
|
7
7
|
Logger.debug 'Using In-Memory sessions.'
|
8
8
|
|
9
|
-
module
|
9
|
+
module Nitro
|
10
10
|
|
11
11
|
Session.store = SafeHash.new
|
12
12
|
|
data/lib/nitro/shaders.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
# George Moschovitis <gm@navel.gr>
|
2
2
|
# (c) 2004-2005 Navel, all rights reserved.
|
3
|
-
# $Id: shaders.rb
|
3
|
+
# $Id: shaders.rb 1 2005-04-11 11:04:30Z gmosx $
|
4
4
|
|
5
5
|
require 'nitro/template'
|
6
6
|
|
7
|
-
module
|
7
|
+
module Nitro
|
8
8
|
|
9
9
|
# A shader defines a transformation-pipeline that tansforms
|
10
10
|
# the .xhtml files to actual ruby code ready for evaluation
|
@@ -59,7 +59,6 @@ class RubyShader < Shader
|
|
59
59
|
|
60
60
|
# Convert the xhtml script to actual Ruby code, ready
|
61
61
|
# to be evaluated.
|
62
|
-
#
|
63
62
|
#--
|
64
63
|
# Investigate:
|
65
64
|
# perhaps xl:href should be used to be XLink compatible?
|
@@ -107,8 +106,10 @@ class XSLTShader < Shader
|
|
107
106
|
attr :mtime
|
108
107
|
|
109
108
|
def initialize(xsl_filename, next_stage = nil)
|
109
|
+
|
110
110
|
# leave this require here. only inlcude the xslt
|
111
111
|
# library if the project needs it.
|
112
|
+
|
112
113
|
require "xml/xslt"
|
113
114
|
|
114
115
|
@name = File.basename(xsl_filename, '.*')
|
@@ -123,7 +124,7 @@ class XSLTShader < Shader
|
|
123
124
|
parse_xsl()
|
124
125
|
@xslt.xml = text
|
125
126
|
hash += @name
|
126
|
-
|
127
|
+
Logger.debug "Applying xsl '#{@xsl_filename}' to template" if $DBG
|
127
128
|
process_next(hash, xslt.serve)
|
128
129
|
end
|
129
130
|
|
@@ -165,7 +166,7 @@ class MorphingShader < Shader
|
|
165
166
|
# <tag if="x">..</tag>
|
166
167
|
# <tag unless="x">..</tag>
|
167
168
|
|
168
|
-
text.gsub!(/<(\w*?)([^>]*?)(if|unless)="(.*?)"(.*?)>(.*?)<\/\1>/m) do |match|
|
169
|
+
text.gsub!(/<(\w*?)([^>]*?)(if|unless)=["|'](.*?)["|'](.*?)>(.*?)<\/\1>/m) do |match|
|
169
170
|
%{<?r #$3 #$4 ?>
|
170
171
|
<#$1#$2#$5>#$6</#$1>
|
171
172
|
<?r end ?>}
|
@@ -173,7 +174,7 @@ class MorphingShader < Shader
|
|
173
174
|
|
174
175
|
# <tag times="x">..</tag>
|
175
176
|
|
176
|
-
text.gsub!(/<(\w*?)([^>]*?)times="(.*?)"(.*?)>(.*?)<\/\1>/m) do |match|
|
177
|
+
text.gsub!(/<(\w*?)([^>]*?)times=["|'](.*?)["|'](.*?)>(.*?)<\/\1>/m) do |match|
|
177
178
|
%{<?r #$3.times do ?>
|
178
179
|
<#$1#$2#$4>#$5</#$1>
|
179
180
|
<?r end ?>}
|
@@ -181,7 +182,7 @@ class MorphingShader < Shader
|
|
181
182
|
|
182
183
|
# <tag each="x">..</tag>
|
183
184
|
|
184
|
-
text.gsub!(/<(\w*?)([^>]*?)each="(.*?)"(.*?)>(.*?)<\/\1>/m) do |match|
|
185
|
+
text.gsub!(/<(\w*?)([^>]*?)each=["|'](.*?)["|'](.*?)>(.*?)<\/\1>/m) do |match|
|
185
186
|
%{<?r for #$3 ?>
|
186
187
|
<#$1#$2#$4>#$5</#$1>
|
187
188
|
<?r end ?>}
|
data/lib/nitro/simple.rb
CHANGED
@@ -3,6 +3,9 @@ require 'nitro/controller'
|
|
3
3
|
# A simple controller, only handles templates.
|
4
4
|
# Useful to implement php/asp/jsp style applications.
|
5
5
|
# Dispatcher uses this as the default Controller.
|
6
|
+
#--
|
7
|
+
# gmosx, FIXME: this is a nasty hack, remove!
|
8
|
+
#++
|
6
9
|
|
7
|
-
class SimpleController <
|
10
|
+
class SimpleController < Nitro::Controller;
|
8
11
|
end
|
data/lib/nitro/template.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
# * George Moschovitis <gm@navel.gr>
|
2
2
|
# (c) 2004-2005 Navel, all rights reserved.
|
3
|
-
# $Id: template.rb
|
3
|
+
# $Id: template.rb 9 2005-04-13 00:08:20Z nasis $
|
4
4
|
|
5
5
|
require 'glue/flexob'
|
6
6
|
|
7
|
-
module
|
7
|
+
module Nitro
|
8
8
|
|
9
9
|
# A template is a text file with embeded Ruby code. The template
|
10
10
|
# processor converts the original text file to ruby code and
|
@@ -41,7 +41,7 @@ module TemplateMixin
|
|
41
41
|
# Example:
|
42
42
|
# <?include href="root/myfile.sx" ?>
|
43
43
|
|
44
|
-
text.gsub!(/<\?include href="(.*?)"(.*)\?>/) do |match|
|
44
|
+
text.gsub!(/<\?include href=["|'](.*?)["|'](.*)\?>/) do |match|
|
45
45
|
text = File.read("#{base_dir}/#$1")
|
46
46
|
text.gsub!(/<\?xml.*\?>/, '')
|
47
47
|
text.gsub!(/<\/?root(.*?)>/m, ' ');
|
@@ -51,22 +51,22 @@ module TemplateMixin
|
|
51
51
|
# Transform include instructions <include href="xxx" />
|
52
52
|
# must be transformed before the processinc instructions.
|
53
53
|
# Useful to include fragments cached on disk
|
54
|
-
|
54
|
+
#
|
55
55
|
# gmosx, FIXME: NOT TESTED! test and add caching.
|
56
56
|
# add load_statically_included fixes.
|
57
57
|
|
58
|
-
text.gsub!(/<include href="(.*?)"(.*)(.?)\/>/) do |match|
|
58
|
+
text.gsub!(/<include href=["|'](.*?)["|'](.*)(.?)\/>/) do |match|
|
59
59
|
"<?r File.read( '\#\{@dispatcher.root\}/#$1' ?>"
|
60
60
|
end
|
61
61
|
|
62
62
|
# xform render/inject instructions <render href="xxx" />
|
63
63
|
# must be transformed before the processinc instructions.
|
64
64
|
|
65
|
-
text.gsub!(/<inject href="(.*?)"(.*)(.?)\/>/) do |match|
|
65
|
+
text.gsub!(/<inject href=["|'](.*?)["|'](.*)(.?)\/>/) do |match|
|
66
66
|
"<?r render '/#$1' ?>"
|
67
67
|
end
|
68
68
|
|
69
|
-
text.gsub!(/<render href="(.*?)"(.*)(.?)\/>/) do |match|
|
69
|
+
text.gsub!(/<render href=["|'](.*?)["|'](.*)(.?)\/>/) do |match|
|
70
70
|
"<?r render '/#$1' ?>"
|
71
71
|
end
|
72
72
|
|
@@ -93,7 +93,7 @@ module TemplateMixin
|
|
93
93
|
|
94
94
|
text.gsub!(/%>/, "\n#{buffer} << %^")
|
95
95
|
text.gsub!(/<%/, "^\n")
|
96
|
-
|
96
|
+
|
97
97
|
# Alterative versions of interpolation.
|
98
98
|
# (very useful in xsl stylesheets)
|
99
99
|
|
@@ -0,0 +1,102 @@
|
|
1
|
+
# * George Moschovitis <gm@navel.gr>
|
2
|
+
# (c) 2004-2005 Navel, all rights reserved.
|
3
|
+
# $Id: assertions.rb 1 2005-04-11 11:04:30Z gmosx $
|
4
|
+
|
5
|
+
require 'test/unit'
|
6
|
+
require 'test/unit/assertions'
|
7
|
+
require 'rexml/document'
|
8
|
+
|
9
|
+
module Test::Unit::Assertions
|
10
|
+
|
11
|
+
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
12
|
+
# :section: General assertions.
|
13
|
+
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
14
|
+
|
15
|
+
def assert_status_ok(msg = nil)
|
16
|
+
msg = format_msg("Status not ok", msg)
|
17
|
+
assert_block(msg) { @context.status_ok? }
|
18
|
+
end
|
19
|
+
|
20
|
+
def assert_output_match(re, msg = nil)
|
21
|
+
msg = format_msg("Rendered output does not match '#{re}'", msg)
|
22
|
+
assert_block(msg) { @context.out =~ Regexp.new(re) }
|
23
|
+
end
|
24
|
+
alias_method :assert_output_contains, :assert_output_match
|
25
|
+
|
26
|
+
def assert_output_no_match(re, msg = nil)
|
27
|
+
msg = format_msg("Rendered output matches '#{re}'", msg)
|
28
|
+
assert_block(msg) { @context.out =~ Regexp.new(re) }
|
29
|
+
end
|
30
|
+
alias_method :assert_output_contains_no, :assert_output_no_match
|
31
|
+
|
32
|
+
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
33
|
+
# :section: Session related assertions.
|
34
|
+
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
35
|
+
|
36
|
+
def assert_session_has(key, msg = nil)
|
37
|
+
msg = format_msg("Object '#{key}' not found in session", msg)
|
38
|
+
assert_block(msg) { @context.session[key] }
|
39
|
+
end
|
40
|
+
|
41
|
+
def assert_session_has_no(key, msg = nil)
|
42
|
+
msg = format_msg("Unexpected object '#{key}' found in session", msg)
|
43
|
+
assert_block(msg) { !@context.session[key] }
|
44
|
+
end
|
45
|
+
alias_method :assert_session_has_not, :assert_session_has_no
|
46
|
+
|
47
|
+
def assert_session_equal(key, value, msg = nil)
|
48
|
+
msg = format_msg("The value of session object '#{key}' is '#{@context.session[key]}' but was expected '#{value}'", msg)
|
49
|
+
assert_block(msg) { @context.session[key] == value }
|
50
|
+
end
|
51
|
+
|
52
|
+
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
53
|
+
# :section: Cookies related assertions.
|
54
|
+
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
55
|
+
|
56
|
+
def assert_has_cookie(name, msg = nil)
|
57
|
+
msg = format_msg("Cookie '#{name}' not found", msg)
|
58
|
+
assert_block(msg) { @context.response_cookie(name) }
|
59
|
+
end
|
60
|
+
|
61
|
+
def assert_has_no_cookie(name, msg = nil)
|
62
|
+
msg = format_msg("Unexpected cookie '#{name}' found", msg)
|
63
|
+
assert_block(msg) { !@context.response_cookie(name) }
|
64
|
+
end
|
65
|
+
|
66
|
+
def assert_cookie_equal(name, value, msg = nil)
|
67
|
+
unless cookie = @context.response_cookie(name)
|
68
|
+
msg = format_msg("Cookie '#{name}' not found", msg)
|
69
|
+
assert_block(msg) { false }
|
70
|
+
end
|
71
|
+
msg = format_msg("The value of cookie '#{name}' is '#{cookie.value}' but was expected '#{value}'", msg)
|
72
|
+
assert_block(msg) { cookie.value == value }
|
73
|
+
end
|
74
|
+
|
75
|
+
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
76
|
+
# :section: Template related assertions.
|
77
|
+
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
78
|
+
|
79
|
+
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
80
|
+
# :section: Redirection assertions.
|
81
|
+
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
82
|
+
|
83
|
+
def assert_redirect(msg = nil)
|
84
|
+
msg = format_msg("No redirection (status = #{@context.status})", msg)
|
85
|
+
assert_block(msg) { @context.redirect? }
|
86
|
+
end
|
87
|
+
|
88
|
+
def assert_no_redirect(msg = nil)
|
89
|
+
msg = format_msg("Unexpected redirection (location = '#{@context.response_headers['location']}')", msg)
|
90
|
+
assert_block(msg) { !@context.redirect? }
|
91
|
+
end
|
92
|
+
|
93
|
+
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
94
|
+
# :section: Utility methods
|
95
|
+
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
96
|
+
|
97
|
+
def format_msg(message, extra) # :nodoc:
|
98
|
+
extra += ', ' if extra
|
99
|
+
return "#{extra}#{message}"
|
100
|
+
end
|
101
|
+
|
102
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# * George Moschovitis <gm@navel.gr>
|
2
|
+
# (c) 2004-2005 Navel, all rights reserved.
|
3
|
+
# $Id: context.rb 1 2005-04-11 11:04:30Z gmosx $
|
4
|
+
|
5
|
+
require 'test/unit'
|
6
|
+
require 'test/unit/assertions'
|
7
|
+
require 'rexml/document'
|
8
|
+
|
9
|
+
require 'nitro/context'
|
10
|
+
|
11
|
+
module Nitro
|
12
|
+
|
13
|
+
# Override the default Request implementation
|
14
|
+
# to include methods useful for testing.
|
15
|
+
|
16
|
+
module Request
|
17
|
+
end
|
18
|
+
|
19
|
+
# Override the default Response implementation
|
20
|
+
# to include methods useful for testing.
|
21
|
+
|
22
|
+
module Response
|
23
|
+
|
24
|
+
def status_ok?
|
25
|
+
@status == 200
|
26
|
+
end
|
27
|
+
|
28
|
+
def redirect?
|
29
|
+
(300..399).include?(@status)
|
30
|
+
end
|
31
|
+
|
32
|
+
def redirect_url
|
33
|
+
@response_headers['location']
|
34
|
+
end
|
35
|
+
|
36
|
+
def response_cookie(name)
|
37
|
+
return nil unless @response_cookies
|
38
|
+
@response_cookies.find { |c| c.name == name }
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
# Override the default Response implementation
|
44
|
+
# to include methods useful for testing.
|
45
|
+
|
46
|
+
class Context
|
47
|
+
def session
|
48
|
+
@session || @session = {}
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# * George Moschovitis <gm@navel.gr>
|
2
|
+
# (c) 2004-2005 Navel, all rights reserved.
|
3
|
+
# $Id: testcase.rb 1 2005-04-11 11:04:30Z gmosx $
|
4
|
+
|
5
|
+
require 'test/unit'
|
6
|
+
require 'test/unit/assertions'
|
7
|
+
require 'rexml/document'
|
8
|
+
|
9
|
+
require 'glue'
|
10
|
+
require 'glue/logger'
|
11
|
+
require 'nitro/conf'
|
12
|
+
require 'nitro/testing/context'
|
13
|
+
|
14
|
+
module Test::Unit
|
15
|
+
|
16
|
+
class TestCase
|
17
|
+
include Nitro
|
18
|
+
|
19
|
+
attr_accessor :conf
|
20
|
+
attr_accessor :context
|
21
|
+
|
22
|
+
def handle(path, request = {}, session = nil, headers = {})
|
23
|
+
@conf ||= Conf.new({})
|
24
|
+
@conf.public_root ||= File.join(File.dirname(__FILE__), '..', 'public')
|
25
|
+
@conf.template_root ||= File.join(File.dirname(__FILE__), '..', 'public')
|
26
|
+
|
27
|
+
begin
|
28
|
+
Og.db.get_connection if defined?(Og) and Og.db
|
29
|
+
|
30
|
+
context = Context.new(@conf)
|
31
|
+
|
32
|
+
# context.in = StringIO.new(req.body || "")
|
33
|
+
|
34
|
+
context.params = request
|
35
|
+
context.headers ||= headers
|
36
|
+
context.session = session if session
|
37
|
+
|
38
|
+
context.headers['REQUEST_URI'] = path
|
39
|
+
# CgiUtils.parse_params(context)
|
40
|
+
# CgiUtils.parse_cookies(context)
|
41
|
+
|
42
|
+
context.render(path)
|
43
|
+
|
44
|
+
@context = context
|
45
|
+
|
46
|
+
return context
|
47
|
+
ensure
|
48
|
+
Og.db.put_connection if defined?(Og) and Og.db
|
49
|
+
end
|
50
|
+
end
|
51
|
+
alias_method :process, :handle
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
data/lib/nitro/ui/pager.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
# * George Moschovitis <gm@navel.gr>
|
2
2
|
# (c) 2004-2005 Navel, all rights reserved.
|
3
|
-
# $Id: pager.rb
|
3
|
+
# $Id: pager.rb 1 2005-04-11 11:04:30Z gmosx $
|
4
4
|
|
5
5
|
require 'nitro/uri'
|
6
6
|
|
7
|
-
module
|
7
|
+
module Nitro; module UI
|
8
8
|
|
9
9
|
# Displays a collection of entitities in multiple pages.
|
10
10
|
#
|
@@ -198,7 +198,7 @@ class Pager < Array
|
|
198
198
|
#
|
199
199
|
def target_uri(page)
|
200
200
|
params = {"__pg#{@name}" => page}
|
201
|
-
return
|
201
|
+
return UriUtils.update_query_string(@request.uri.to_s, params)
|
202
202
|
end
|
203
203
|
|
204
204
|
end
|
data/lib/nitro/ui/popup.rb
CHANGED
@@ -1,20 +1,16 @@
|
|
1
|
-
# code:
|
2
1
|
# * George Moschovitis <gm@navel.gr>
|
3
|
-
#
|
4
|
-
#
|
5
|
-
# $Id: popup.rb 99 2004-10-22 09:50:28Z gmosx $
|
2
|
+
# (c) 2004-2005 Navel, all rights reserved.
|
3
|
+
# $Id: popup.rb 1 2005-04-11 11:04:30Z gmosx $
|
6
4
|
|
7
|
-
module
|
5
|
+
module Nitro
|
8
6
|
|
9
|
-
# = Popup
|
10
|
-
#
|
11
7
|
# Display a popup window.
|
12
|
-
|
8
|
+
|
13
9
|
class Popup
|
14
10
|
|
15
11
|
# Emit the needed javascript.
|
16
12
|
# Alternatively use this code: <script src="/r/js/std.js">#{}</script>
|
17
|
-
|
13
|
+
|
18
14
|
def self.script
|
19
15
|
%[
|
20
16
|
function newWin(url, name, w, h, scroll) {
|
@@ -30,17 +26,16 @@ function newWin(url, name, w, h, scroll) {
|
|
30
26
|
end
|
31
27
|
|
32
28
|
# gmosx: keep the leading / to be IE friendly.
|
33
|
-
|
29
|
+
|
34
30
|
def self.onclick(uri, width, height, title = "Popup", type="PAGE", options = "scrollbars=yes,resizable", container = "/p/glue/popup.sx")
|
35
31
|
%[javascript: var pwl = (screen.width - #{width}) / 2; var pwt = (screen.height - #{height}) / 2; window.open('#{container}?uri=#{uri};type=#{type}', '#{title}', 'width=#{width},height=#{height},top='+pwt+',left='+pwl+', #{options}'); return false"]
|
36
32
|
end
|
37
33
|
|
38
34
|
# gmosx: keep the leading / to be IE friendly.
|
39
|
-
|
35
|
+
|
40
36
|
def self.link(uri, width, height, link = "link", title = "Popup", type="PAGE", options = "scrollbars=yes,resizable", container = "/p/glue/popup.sx")
|
41
37
|
%[<a href="#" onclick="#{self.onclick(uri, width, height, title, type, options, container)}">#{link}</a>]
|
42
38
|
end
|
43
39
|
end
|
44
40
|
|
45
|
-
end
|
46
|
-
|
41
|
+
end
|