nitro 0.16.0 → 0.17.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +94 -1
- data/INSTALL +3 -0
- data/README +9 -1
- data/Rakefile +2 -1
- data/doc/RELEASES +183 -2
- data/examples/blog/run.rb +4 -9
- data/examples/blog/src/controller.rb +1 -5
- data/examples/blog/src/models/blog.rb +1 -5
- data/examples/blog/src/models/content.rb +0 -5
- data/examples/blog/src/views/comments.xhtml +6 -11
- data/examples/blog/src/views/index.xhtml +2 -3
- data/examples/blog/src/views/recent_posts.xhtml +1 -1
- data/examples/no_xsl_blog/lib/blog/controller.rb +1 -5
- data/examples/no_xsl_blog/lib/blog/model.rb +2 -6
- data/examples/no_xsl_blog/lib/blog.rb +0 -4
- data/examples/no_xsl_blog/lib/content.rb +7 -11
- data/examples/no_xsl_blog/public/comments.xhtml +6 -11
- data/examples/no_xsl_blog/public/index.xhtml +2 -2
- data/examples/no_xsl_blog/public/recent_posts.xhtml +1 -1
- data/examples/no_xsl_blog/run.rb +2 -9
- data/lib/nitro/adapters/cgi.rb +7 -8
- data/lib/nitro/adapters/fastcgi.rb +17 -19
- data/lib/nitro/adapters/webrick.rb +3 -3
- data/lib/nitro/buffering.rb +0 -4
- data/lib/nitro/builders/form.rb +3 -3
- data/lib/nitro/builders/rss.rb +33 -4
- data/lib/nitro/builders/xhtml.rb +1 -1
- data/lib/nitro/builders/xml.rb +1 -1
- data/lib/nitro/context.rb +0 -4
- data/lib/nitro/controller.rb +0 -4
- data/lib/nitro/dispatcher.rb +5 -5
- data/lib/nitro/element.rb +151 -0
- data/lib/nitro/part.rb +0 -4
- data/lib/nitro/render.rb +79 -40
- data/lib/nitro/request.rb +15 -4
- data/lib/nitro/scaffold.rb +2 -6
- data/lib/nitro/shaders.rb +4 -3
- data/lib/nitro/template.rb +3 -1
- data/lib/nitro.rb +7 -6
- data/proto/public/error.xhtml +1 -1
- data/proto/public/js/prototype.js +764 -0
- data/test/nitro/adapters/tc_cgi.rb +1 -0
- data/test/nitro/tc_element.rb +46 -0
- metadata +27 -6
- data/examples/blog/cache/entriesadmintrue +0 -3
@@ -1,7 +1,3 @@
|
|
1
|
-
# * George Moschovitis <gm@navel.gr>
|
2
|
-
# (c) 2004-2005 Navel, all rights reserved.
|
3
|
-
# $Id: fastcgi.rb 1 2005-04-11 11:04:30Z gmosx $
|
4
|
-
|
5
1
|
require 'cgi'
|
6
2
|
require 'fcgi'
|
7
3
|
|
@@ -28,27 +24,29 @@ class FastCGI
|
|
28
24
|
conf = Flexob.new(conf) unless conf.is_a?(Flexob)
|
29
25
|
|
30
26
|
FCGI.each do |cgi|
|
27
|
+
begin
|
28
|
+
context = Context.new(conf)
|
31
29
|
|
32
|
-
|
33
|
-
|
34
|
-
context.in = cgi.in
|
35
|
-
context.headers = cgi.env
|
36
|
-
|
37
|
-
CgiUtils.parse_params(context)
|
38
|
-
CgiUtils.parse_cookies(context)
|
39
|
-
|
40
|
-
# gmosx, TODO: move this into a filter.
|
41
|
-
Og.db.get_connection if defined?(Og) and Og.db
|
30
|
+
context.in = cgi.in
|
31
|
+
context.headers = cgi.env
|
42
32
|
|
43
|
-
|
33
|
+
CgiUtils.parse_params(context)
|
34
|
+
CgiUtils.parse_cookies(context)
|
35
|
+
|
36
|
+
# gmosx, TODO: move this into a filter.
|
37
|
+
# Og.db.get_connection if defined?(Og) and Og.db
|
44
38
|
|
45
|
-
|
39
|
+
context.render(context.path)
|
46
40
|
|
47
|
-
|
48
|
-
cgi.out.print(context.out)
|
41
|
+
# Og.db.put_connection if defined?(Og) and Og.db
|
49
42
|
|
50
|
-
|
43
|
+
cgi.out.print(CgiUtils.response_headers(context))
|
44
|
+
cgi.out.print(context.out)
|
51
45
|
|
46
|
+
cgi.finish
|
47
|
+
ensure
|
48
|
+
# Og.db.put_connection if defined?(Og) and Og.db
|
49
|
+
end
|
52
50
|
end
|
53
51
|
end
|
54
52
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# * George Moschovitis <gm@navel.gr>
|
2
2
|
# (c) 2004-2005 Navel, all rights reserved.
|
3
|
-
# $Id: webrick.rb
|
3
|
+
# $Id: webrick.rb 41 2005-05-05 14:56:40Z gmosx $
|
4
4
|
|
5
5
|
require 'webrick'
|
6
6
|
require 'stringio'
|
@@ -103,7 +103,7 @@ class WebrickAdapter < WEBrick::HTTPServlet::AbstractServlet
|
|
103
103
|
path = req.request_uri.path
|
104
104
|
|
105
105
|
# gmosx, TODO: move this into a filter.
|
106
|
-
Og.db.get_connection if defined?(Og) and Og.db
|
106
|
+
# Og.db.get_connection if defined?(Og) and Og.db
|
107
107
|
|
108
108
|
# REQUEST_MUTEX.lock
|
109
109
|
|
@@ -131,7 +131,7 @@ class WebrickAdapter < WEBrick::HTTPServlet::AbstractServlet
|
|
131
131
|
context.close
|
132
132
|
ensure
|
133
133
|
# REQUEST_MUTEX.unlock if REQUEST_MUTEX.locked?
|
134
|
-
Og.db.put_connection if defined?(Og) and Og.db
|
134
|
+
# Og.db.put_connection if defined?(Og) and Og.db
|
135
135
|
end
|
136
136
|
end
|
137
137
|
end
|
data/lib/nitro/buffering.rb
CHANGED
data/lib/nitro/builders/form.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# * George Moschovitis <gm@navel.gr>
|
2
|
-
# (c)
|
3
|
-
# $Id: form.rb
|
2
|
+
# (c) 2005 Navel, all rights reserved.
|
3
|
+
# $Id: form.rb 30 2005-04-25 12:28:02Z gmosx $
|
4
4
|
|
5
5
|
require 'glue/hash'
|
6
6
|
require 'nitro/markup'
|
@@ -18,7 +18,7 @@ module FormBuilderMixin
|
|
18
18
|
#
|
19
19
|
# <p>
|
20
20
|
# <form name="test">
|
21
|
-
# #{
|
21
|
+
# #{o.build_form(entry)}
|
22
22
|
# </form>
|
23
23
|
# </p>
|
24
24
|
|
data/lib/nitro/builders/rss.rb
CHANGED
@@ -1,10 +1,7 @@
|
|
1
|
-
# * George Moschovitis <gm@navel.gr>
|
2
|
-
# (c) 2005 Navel, all rights reserved.
|
3
|
-
# $Id: rss.rb 1 2005-04-11 11:04:30Z gmosx $
|
4
|
-
|
5
1
|
require 'rss/0.9'
|
6
2
|
|
7
3
|
require 'glue/string'
|
4
|
+
require 'nitro/builders/xml'
|
8
5
|
|
9
6
|
module Nitro
|
10
7
|
|
@@ -14,9 +11,13 @@ module Nitro
|
|
14
11
|
#
|
15
12
|
#--
|
16
13
|
# TODO: add more options here, 1.0/2.0 support and more.
|
14
|
+
# use custom version to add headers like the following.
|
15
|
+
# <?xml version="1.0" encoding="UTF-8"?>
|
16
|
+
# <?xml-stylesheet href="rss.css" type="text/css"?>
|
17
17
|
#++
|
18
18
|
|
19
19
|
module RssBuilderMixin
|
20
|
+
include XmlBuilderMixin
|
20
21
|
|
21
22
|
# === Options
|
22
23
|
#
|
@@ -55,6 +56,34 @@ module RssBuilderMixin
|
|
55
56
|
end
|
56
57
|
alias_method :build_rss, :build_rss_09
|
57
58
|
|
59
|
+
=begin
|
60
|
+
Experimental.
|
61
|
+
|
62
|
+
def build_rss(objects, options = {})
|
63
|
+
# pi! :xml, :version => '1.0', :encoding => 'UTF-8'
|
64
|
+
self << '<?xml version="1.0" encoding="UTF-8" ?>'
|
65
|
+
self << '<?xml-stylesheet href="rss.css" type="text/css" ?>'
|
66
|
+
rss(:version => '2.0',
|
67
|
+
'xmlns:dc' => 'http://purl.org/dc/elements/1.1/',
|
68
|
+
'xmlns:trackback' => 'http://madskills.com/public/xml/rss/module/trackback/') {
|
69
|
+
channel {
|
70
|
+
title 'koko'
|
71
|
+
language 'en-us'
|
72
|
+
ttl '40'
|
73
|
+
description 'hello lamer'
|
74
|
+
|
75
|
+
for obj in objects
|
76
|
+
item {
|
77
|
+
title(obj.title)
|
78
|
+
description(obj.body)
|
79
|
+
trackback :ping => 'http://www.joy.gr'
|
80
|
+
}
|
81
|
+
end
|
82
|
+
}
|
83
|
+
}
|
84
|
+
end
|
85
|
+
=end
|
86
|
+
|
58
87
|
end
|
59
88
|
|
60
89
|
# Abstract class for the RssBuilderMixin.
|
data/lib/nitro/builders/xhtml.rb
CHANGED
data/lib/nitro/builders/xml.rb
CHANGED
data/lib/nitro/context.rb
CHANGED
data/lib/nitro/controller.rb
CHANGED
data/lib/nitro/dispatcher.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# * George Moschovitis <gm@navel.gr>
|
2
2
|
# (c) 2004-2005 Navel, all rights reserved.
|
3
|
-
# $Id: dispatcher.rb
|
3
|
+
# $Id: dispatcher.rb 30 2005-04-25 12:28:02Z gmosx $
|
4
4
|
|
5
5
|
module Nitro
|
6
6
|
|
@@ -153,7 +153,7 @@ class Dispatcher
|
|
153
153
|
klass = @controllers[key]
|
154
154
|
|
155
155
|
if (:full == Rendering.reload) and context and context[:__RELOADED__].nil? and klass
|
156
|
-
|
156
|
+
#=begin
|
157
157
|
ancestors = [c = klass]
|
158
158
|
while (c = c.superclass) != Nitro::Controller
|
159
159
|
ancestors.unshift(c)
|
@@ -169,14 +169,14 @@ class Dispatcher
|
|
169
169
|
load(c::DEF_FILE)
|
170
170
|
c = Object.const_get(klass.name.intern)
|
171
171
|
end
|
172
|
-
|
173
|
-
|
172
|
+
#=end
|
173
|
+
=begin
|
174
174
|
def_file = klass::DEF_FILE
|
175
175
|
# Object.send(:remove_const, klass) rescue nil
|
176
176
|
# FIXME: also reload superclasses!
|
177
177
|
Controller.remove_subclasses
|
178
178
|
load(def_file)
|
179
|
-
|
179
|
+
=end
|
180
180
|
klass = @controllers[key] = Object.const_get(klass.name.intern)
|
181
181
|
context[:__RELOADED__] = true
|
182
182
|
end
|
@@ -0,0 +1,151 @@
|
|
1
|
+
require 'rexml/document'
|
2
|
+
require 'rexml/streamlistener'
|
3
|
+
|
4
|
+
require 'facet/string/capitalized%3F'
|
5
|
+
|
6
|
+
module Nitro
|
7
|
+
|
8
|
+
# A programmatically generated element.
|
9
|
+
#
|
10
|
+
# === Design
|
11
|
+
#
|
12
|
+
# An underscore is used for the standard attibutes to
|
13
|
+
# avoid name clashes.
|
14
|
+
#--
|
15
|
+
# TODO:
|
16
|
+
# * separate 'view' template files.
|
17
|
+
#++
|
18
|
+
|
19
|
+
class Element
|
20
|
+
# The parent of this element.
|
21
|
+
|
22
|
+
attr_accessor :_parent
|
23
|
+
|
24
|
+
# The childrens of this element.
|
25
|
+
|
26
|
+
attr_accessor :_children
|
27
|
+
|
28
|
+
# The text of this element.
|
29
|
+
|
30
|
+
attr_accessor :_text
|
31
|
+
|
32
|
+
# The view of this element.
|
33
|
+
|
34
|
+
attr_accessor :_view
|
35
|
+
|
36
|
+
def initialize(*args)
|
37
|
+
@_children = []
|
38
|
+
@_text = ''
|
39
|
+
end
|
40
|
+
|
41
|
+
def open
|
42
|
+
end
|
43
|
+
|
44
|
+
def content
|
45
|
+
# "#{@_text}#{render_children}"
|
46
|
+
@_text
|
47
|
+
end
|
48
|
+
|
49
|
+
def close
|
50
|
+
end
|
51
|
+
|
52
|
+
def render
|
53
|
+
"#{open}#{content}#{close}"
|
54
|
+
end
|
55
|
+
|
56
|
+
def render_children
|
57
|
+
str = ''
|
58
|
+
for c in @_children
|
59
|
+
str << c.render
|
60
|
+
end
|
61
|
+
|
62
|
+
return str
|
63
|
+
end
|
64
|
+
|
65
|
+
def add_child(child)
|
66
|
+
child._parent = self
|
67
|
+
@_children << child
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
# Processes a page containing elements.
|
72
|
+
|
73
|
+
class ElementProcessor # :nodoc: all
|
74
|
+
|
75
|
+
class Listener # :nodoc: all
|
76
|
+
include REXML::StreamListener
|
77
|
+
|
78
|
+
attr_accessor :buffer
|
79
|
+
attr_accessor :stack
|
80
|
+
|
81
|
+
def initialize
|
82
|
+
super
|
83
|
+
@buffer = ''
|
84
|
+
@stack = []
|
85
|
+
end
|
86
|
+
|
87
|
+
def tag_start(name, attributes)
|
88
|
+
if name.capitalized?
|
89
|
+
obj = Object.const_get(name).new
|
90
|
+
|
91
|
+
attributes.each do | k, v |
|
92
|
+
obj.instance_variable_set("@#{k}", v)
|
93
|
+
end
|
94
|
+
|
95
|
+
@stack.push [obj, @buffer]
|
96
|
+
|
97
|
+
@buffer = obj._text
|
98
|
+
@parent.add_child(obj) if @parent
|
99
|
+
@parent = obj
|
100
|
+
else # This is a static element.
|
101
|
+
attrs = []
|
102
|
+
|
103
|
+
attributes.each do | k, v |
|
104
|
+
attrs << %|#{k}="#{v}"|
|
105
|
+
end
|
106
|
+
|
107
|
+
attrs = attrs.empty? ? nil : " #{attrs.join(' ')}"
|
108
|
+
|
109
|
+
@buffer << "<#{name}#{attrs}>"
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
def tag_end(name)
|
114
|
+
if name.capitalized?
|
115
|
+
obj, @buffer = @stack.pop
|
116
|
+
@buffer << obj.render
|
117
|
+
else
|
118
|
+
@buffer << "</#{name}>"
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
def text(str)
|
123
|
+
@buffer << str
|
124
|
+
end
|
125
|
+
|
126
|
+
def instruction(name, attributes)
|
127
|
+
@buffer << "<?#{name}#{attributes}?>"
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
class << self
|
132
|
+
def parse(source)
|
133
|
+
self.new.parse(source)
|
134
|
+
end
|
135
|
+
|
136
|
+
def render(source)
|
137
|
+
self.new.render(source)
|
138
|
+
end
|
139
|
+
|
140
|
+
end
|
141
|
+
|
142
|
+
# Expand the elemens found in source.
|
143
|
+
|
144
|
+
def render(source)
|
145
|
+
listener = Listener.new
|
146
|
+
REXML::Document.parse_stream(source, listener)
|
147
|
+
return listener.buffer
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
end
|
data/lib/nitro/part.rb
CHANGED
data/lib/nitro/render.rb
CHANGED
@@ -1,7 +1,3 @@
|
|
1
|
-
# * George Moschovitis <gm@navel.gr>
|
2
|
-
# (c) 2005 Navel, all rights reserved.
|
3
|
-
# $Id: render.rb 20 2005-04-15 15:18:36Z gmosx $
|
4
|
-
|
5
1
|
require 'sync'
|
6
2
|
|
7
3
|
require 'glue/attribute'
|
@@ -12,8 +8,14 @@ require 'nitro/shaders'
|
|
12
8
|
require 'nitro/buffering'
|
13
9
|
|
14
10
|
module Nitro
|
11
|
+
|
12
|
+
# Raise this exception to stop the current action.
|
13
|
+
# Typically called to skip the template.
|
14
|
+
|
15
|
+
class ActionExit < Exception; end
|
15
16
|
|
16
|
-
# Raise this exception to stop rendering.
|
17
|
+
# Raise this exception to stop rendering altogether.
|
18
|
+
# Typically called by redirects.
|
17
19
|
|
18
20
|
class RenderExit < Exception; end
|
19
21
|
|
@@ -81,7 +83,7 @@ module Rendering
|
|
81
83
|
|
82
84
|
text = File.read(path)
|
83
85
|
hash, text = shader.process(path, text)
|
84
|
-
|
86
|
+
|
85
87
|
return text
|
86
88
|
end
|
87
89
|
|
@@ -111,20 +113,39 @@ module Rendering
|
|
111
113
|
|
112
114
|
code << Aspects.gen_advice_code(action, klass.advices, :pre)
|
113
115
|
|
114
|
-
#
|
116
|
+
# Call the action
|
115
117
|
|
116
118
|
if klass.action_methods.include?(action)
|
117
119
|
valid = true
|
118
120
|
|
119
|
-
|
121
|
+
# Annotated parameters.
|
122
|
+
|
123
|
+
if meta = klass.action_metadata[action.intern]
|
120
124
|
params = meta.params.keys
|
121
|
-
|
125
|
+
params = params.collect { |p| "@#{p} = @context['#{p}']" }
|
122
126
|
code << "#{params.join(';')}"
|
123
127
|
end
|
128
|
+
|
129
|
+
# Try to resolve action parameters.
|
130
|
+
|
131
|
+
param_count = klass.instance_method(action.intern).arity
|
124
132
|
|
125
|
-
|
126
|
-
|
127
|
-
|
133
|
+
if param_count > 0
|
134
|
+
code << %{
|
135
|
+
qs = context.query_string.split(/[&;]/)
|
136
|
+
|
137
|
+
params = []
|
138
|
+
#{param_count}.times do |i|
|
139
|
+
params << qs.shift.split(/=/).last
|
140
|
+
end
|
141
|
+
|
142
|
+
unless :stop == #{action}(*params)
|
143
|
+
}
|
144
|
+
else
|
145
|
+
code << %{
|
146
|
+
unless :stop == #{action}
|
147
|
+
}
|
148
|
+
end
|
128
149
|
end
|
129
150
|
|
130
151
|
# Try to call the template method if it exists. It is a nice
|
@@ -136,12 +157,21 @@ module Rendering
|
|
136
157
|
# template file into a template method. It is an even better
|
137
158
|
# practice to place the output related code in an external
|
138
159
|
# template file.
|
139
|
-
|
140
|
-
|
160
|
+
|
161
|
+
# Take :view metadata into account.
|
162
|
+
|
163
|
+
view = nil
|
164
|
+
if md = klass.action_metadata[action.intern]
|
165
|
+
view = md[:view]
|
166
|
+
end
|
167
|
+
view ||= action
|
168
|
+
|
169
|
+
if (template = template_for_action(template_root, view.to_s)) or
|
141
170
|
klass.instance_methods.include?("#{action}_template")
|
142
171
|
valid = true
|
172
|
+
|
143
173
|
code << %{
|
144
|
-
|
174
|
+
#{action}_template;
|
145
175
|
}
|
146
176
|
end
|
147
177
|
|
@@ -152,9 +182,14 @@ module Rendering
|
|
152
182
|
|
153
183
|
code << Aspects.gen_advice_code(action, klass.advices, :post)
|
154
184
|
|
185
|
+
if klass.action_methods.include?(action)
|
186
|
+
code << %{
|
187
|
+
end
|
188
|
+
}
|
189
|
+
end
|
190
|
+
|
155
191
|
code << %{
|
156
192
|
@action_name = @parent_action_name
|
157
|
-
|
158
193
|
redirect_referer if @out.empty?
|
159
194
|
end
|
160
195
|
}
|
@@ -169,13 +204,16 @@ module Rendering
|
|
169
204
|
|
170
205
|
# puts '---', klass, '==', code, '---'
|
171
206
|
|
172
|
-
where = "Action: #{action}"
|
173
|
-
where += ", Template: #{template}" if template
|
174
|
-
|
175
207
|
begin
|
176
|
-
|
208
|
+
# FIXME: replace with correct file, line. search for
|
209
|
+
# lines in error radius.
|
210
|
+
klass.class_eval(code, __FILE__, __LINE__)
|
177
211
|
rescue SyntaxError => e
|
178
|
-
|
212
|
+
where = "Action: #{action}"
|
213
|
+
where += ", Template: #{template}" if template
|
214
|
+
Logger.error "Action compilation error, #{where}"
|
215
|
+
Logger.error e
|
216
|
+
return false
|
179
217
|
end
|
180
218
|
end
|
181
219
|
|
@@ -192,8 +230,8 @@ end
|
|
192
230
|
|
193
231
|
module Render
|
194
232
|
|
195
|
-
# The output buffer. The output of a script/action is
|
196
|
-
# in this buffer.
|
233
|
+
# The output buffer. The output of a script/action is
|
234
|
+
# accumulated in this buffer.
|
197
235
|
|
198
236
|
attr_accessor :out
|
199
237
|
|
@@ -207,9 +245,9 @@ module Render
|
|
207
245
|
alias_method :ctx, :context
|
208
246
|
alias_method :ctx=, :context=
|
209
247
|
|
210
|
-
#
|
248
|
+
# Aliases for context.
|
211
249
|
|
212
|
-
attr_accessor :request
|
250
|
+
attr_accessor :request, :response
|
213
251
|
|
214
252
|
# An array holding the rendering errors for this
|
215
253
|
# request.
|
@@ -226,7 +264,7 @@ module Render
|
|
226
264
|
# A parent render/controller acts as the context.
|
227
265
|
|
228
266
|
def initialize(context, base = nil)
|
229
|
-
@request = @context = context
|
267
|
+
@request = @response = @context = context
|
230
268
|
@out = context.out
|
231
269
|
end
|
232
270
|
|
@@ -264,20 +302,6 @@ module Render
|
|
264
302
|
@out << '(error)'
|
265
303
|
end
|
266
304
|
|
267
|
-
# Add some text to the output buffer.
|
268
|
-
|
269
|
-
def render_text(text)
|
270
|
-
@out << text
|
271
|
-
end
|
272
|
-
|
273
|
-
#--
|
274
|
-
# FIXME: do something better to stop the redirect.
|
275
|
-
#++
|
276
|
-
|
277
|
-
def render_nothing
|
278
|
-
@out = ' '
|
279
|
-
end
|
280
|
-
|
281
305
|
private
|
282
306
|
|
283
307
|
# Send a redirect response.
|
@@ -321,6 +345,21 @@ private
|
|
321
345
|
@out
|
322
346
|
end
|
323
347
|
|
348
|
+
# Add some text to the output buffer.
|
349
|
+
|
350
|
+
def render_text(text)
|
351
|
+
@out << text
|
352
|
+
end
|
353
|
+
alias_method :print, :render_text
|
354
|
+
|
355
|
+
#--
|
356
|
+
# FIXME: do something better to stop the redirect.
|
357
|
+
#++
|
358
|
+
|
359
|
+
def render_nothing
|
360
|
+
@out = ' '
|
361
|
+
end
|
362
|
+
|
324
363
|
end
|
325
364
|
|
326
365
|
end
|
data/lib/nitro/request.rb
CHANGED
@@ -1,7 +1,3 @@
|
|
1
|
-
# * George Moschovitis <gm@navel.gr>
|
2
|
-
# (c) 2004-2005 Navel, all rights reserved.
|
3
|
-
# $Id: request.rb 9 2005-04-13 00:08:20Z nasis $
|
4
|
-
|
5
1
|
module Nitro
|
6
2
|
|
7
3
|
# Encapsulates a request. This is an abstract request
|
@@ -129,6 +125,21 @@ module Request
|
|
129
125
|
"http://#{host}"
|
130
126
|
end
|
131
127
|
|
128
|
+
# The raw data of the request.
|
129
|
+
# Useful to implement Webservices.
|
130
|
+
#--
|
131
|
+
# FIXME: better name and implementation.
|
132
|
+
#++
|
133
|
+
|
134
|
+
def raw_body
|
135
|
+
unless @raw_body
|
136
|
+
@in.rewind
|
137
|
+
@raw_body = @in.read(content_length)
|
138
|
+
end
|
139
|
+
|
140
|
+
@raw_body
|
141
|
+
end
|
142
|
+
|
132
143
|
# Lookup a query parameter.
|
133
144
|
|
134
145
|
def [](param)
|
data/lib/nitro/scaffold.rb
CHANGED
@@ -1,7 +1,3 @@
|
|
1
|
-
# * George Moschovitis <gm@navel.gr>
|
2
|
-
# (c) 2004-2005 Navel, all rights reserved.
|
3
|
-
# $Id: scaffold.rb 1 2005-04-11 11:04:30Z gmosx $
|
4
|
-
|
5
1
|
require 'glue/inflector'
|
6
2
|
|
7
3
|
module Nitro
|
@@ -32,9 +28,9 @@ module Scaffolding
|
|
32
28
|
options[:nosuffix] ? suffix = nil : suffix = "_#{name}"
|
33
29
|
|
34
30
|
# Add methods to the scaffolded class.
|
35
|
-
|
31
|
+
|
36
32
|
klass.module_eval %{
|
37
|
-
def
|
33
|
+
def to_href
|
38
34
|
"view#{suffix}?oid=\#\{@oid\}"
|
39
35
|
# "view#{suffix}/\#\{@oid\}"
|
40
36
|
end
|
data/lib/nitro/shaders.rb
CHANGED
@@ -1,8 +1,7 @@
|
|
1
|
-
#
|
2
|
-
# (c) 2004-2005 Navel, all rights reserved.
|
3
|
-
# $Id: shaders.rb 1 2005-04-11 11:04:30Z gmosx $
|
1
|
+
# $Id: shaders.rb 56 2005-05-13 14:16:47Z gmosx $
|
4
2
|
|
5
3
|
require 'nitro/template'
|
4
|
+
require 'nitro/element'
|
6
5
|
|
7
6
|
module Nitro
|
8
7
|
|
@@ -198,6 +197,8 @@ end
|
|
198
197
|
class ElementsShader < Shader
|
199
198
|
|
200
199
|
def process(hash, text)
|
200
|
+
text = ElementProcessor.render(text)
|
201
|
+
process_next(hash, text)
|
201
202
|
end
|
202
203
|
|
203
204
|
end
|
data/lib/nitro/template.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# * George Moschovitis <gm@navel.gr>
|
2
2
|
# (c) 2004-2005 Navel, all rights reserved.
|
3
|
-
# $Id: template.rb
|
3
|
+
# $Id: template.rb 30 2005-04-25 12:28:02Z gmosx $
|
4
4
|
|
5
5
|
require 'glue/flexob'
|
6
6
|
|
@@ -96,11 +96,13 @@ module TemplateMixin
|
|
96
96
|
|
97
97
|
# Alterative versions of interpolation.
|
98
98
|
# (very useful in xsl stylesheets)
|
99
|
+
# Example: #(my_val)
|
99
100
|
|
100
101
|
text.gsub!(/\#\((.*?)\)/, '#{\1}')
|
101
102
|
|
102
103
|
# Alternative for entities.
|
103
104
|
# (useful in xsl stylesheets)
|
105
|
+
# Examples: %nbsp;, %rquo;
|
104
106
|
|
105
107
|
text.gsub!(/%(\S*?);/, '&\1;')
|
106
108
|
|