nitro 0.26.0 → 0.27.0
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 +312 -0
- data/INSTALL +3 -1
- data/ProjectInfo +6 -9
- data/README +32 -5
- data/Rakefile +5 -1
- data/bin/nitrogen +3 -60
- data/doc/MIGRATION +24 -0
- data/doc/RELEASES +141 -0
- data/doc/lhttpd.txt +3 -0
- data/lib/glue/magick.rb +38 -0
- data/lib/glue/thumbnails.rb +3 -0
- data/lib/glue/webfile.rb +137 -0
- data/lib/nitro.rb +1 -1
- data/lib/nitro/adapter/acgi.rb +235 -0
- data/lib/nitro/adapter/cgi.rb +16 -17
- data/lib/nitro/adapter/scgi.rb +4 -4
- data/lib/nitro/adapter/webrick.rb +9 -2
- data/lib/nitro/cgi.rb +49 -49
- data/lib/nitro/cgi/response.rb +4 -0
- data/lib/nitro/cgi/stream.rb +7 -7
- data/lib/nitro/cgi/utils.rb +2 -1
- data/lib/nitro/compiler.rb +47 -4
- data/lib/nitro/compiler/elements.rb +40 -20
- data/lib/nitro/compiler/layout.rb +21 -0
- data/lib/nitro/compiler/localization.rb +3 -1
- data/lib/nitro/compiler/markup.rb +2 -0
- data/lib/nitro/compiler/morphing.rb +16 -4
- data/lib/nitro/compiler/script.rb +109 -0
- data/lib/nitro/context.rb +10 -10
- data/lib/nitro/dispatcher.rb +4 -2
- data/lib/nitro/element.rb +107 -26
- data/lib/nitro/element/{java_script.rb → javascript.rb} +7 -1
- data/lib/nitro/flash.rb +4 -1
- data/lib/nitro/helper.rb +15 -0
- data/lib/nitro/helper/benchmark.rb +8 -2
- data/lib/nitro/helper/form.rb +3 -3
- data/lib/nitro/helper/form/controls.rb +131 -29
- data/lib/nitro/helper/{dojo.rb → form/test.xhtml} +0 -0
- data/lib/nitro/helper/javascript.rb +69 -59
- data/lib/nitro/helper/{scriptaculous.rb → javascript/dojo.rb} +0 -0
- data/lib/nitro/helper/javascript/morphing.rb +163 -0
- data/lib/nitro/helper/javascript/prototype.rb +96 -0
- data/lib/nitro/helper/javascript/scriptaculous.rb +18 -0
- data/lib/nitro/helper/layout.rb +42 -0
- data/lib/nitro/helper/table.rb +190 -27
- data/lib/nitro/{adapter → helper}/wee.rb +9 -3
- data/lib/nitro/render.rb +23 -17
- data/lib/nitro/scaffolding.rb +19 -2
- data/lib/nitro/server.rb +4 -8
- data/lib/nitro/server/runner.rb +28 -6
- data/lib/nitro/session.rb +7 -7
- data/lib/nitro_and_og.rb +2 -0
- data/proto/public/Makefile.acgi +40 -0
- data/proto/public/acgi.c +138 -0
- data/proto/public/js/builder.js +7 -3
- data/proto/public/js/controls.js +32 -12
- data/proto/public/js/dragdrop.js +4 -3
- data/proto/public/js/effects.js +111 -62
- data/proto/public/js/scriptaculous.js +10 -13
- data/proto/public/js/slider.js +88 -31
- data/proto/public/scaffold/new.xhtml +2 -2
- data/setup.rb +1585 -0
- data/src/part/admin.rb +6 -0
- data/src/part/admin/controller.rb +3 -3
- data/src/part/admin/skin.rb +1 -8
- data/test/nitro/adapter/tc_webrick.rb +2 -0
- data/test/nitro/tc_controller_aspect.rb +1 -1
- data/test/nitro/tc_element.rb +5 -6
- data/test/nitro/tc_table.rb +66 -0
- metadata +277 -271
- data/doc/architecture.txt +0 -2
- data/doc/bugs.txt +0 -15
- data/doc/tutorial.txt +0 -26
- data/install.rb +0 -37
- data/lib/nitro/compiler/script_generator.rb +0 -14
- data/lib/nitro/compiler/shaders.rb +0 -206
- data/lib/nitro/helper/prototype.rb +0 -49
- data/lib/nitro/scaffold/relations.rb +0 -54
data/doc/architecture.txt
DELETED
data/doc/bugs.txt
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
= Bugs
|
2
|
-
|
3
|
-
=== Important
|
4
|
-
|
5
|
-
* multipart handling in fcgi adapter.
|
6
|
-
* filter code attached multiple times?
|
7
|
-
|
8
|
-
=== Security
|
9
|
-
|
10
|
-
* you can get the xthml files in the WEBrick adapter.
|
11
|
-
|
12
|
-
=== Small
|
13
|
-
|
14
|
-
* not correct content type in blog syndication.
|
15
|
-
* tc_property_type_checking does not pass when run with rake test.
|
data/doc/tutorial.txt
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
= Tutorial
|
2
|
-
|
3
|
-
Nitro is an elegant and efficient web application framework.
|
4
|
-
In the spirit of Ruby, Nitro supports multiple programming paradigms
|
5
|
-
and does not force design decisions to the developer. Nitro
|
6
|
-
provides an elegant solution to all problems.
|
7
|
-
|
8
|
-
This tutorial presents a step by step guide for building
|
9
|
-
a simple blog using Nitro.
|
10
|
-
|
11
|
-
== Install Nitro and Og.
|
12
|
-
|
13
|
-
Nitro is distributed as a RubyGem or an archived file (tar.gz or zip)
|
14
|
-
distribution. The latest release
|
15
|
-
|
16
|
-
== Create new app directory structure
|
17
|
-
|
18
|
-
== Create the homepage
|
19
|
-
|
20
|
-
== Create the models
|
21
|
-
|
22
|
-
class BlogEntry
|
23
|
-
end
|
24
|
-
|
25
|
-
== Create the controller
|
26
|
-
|
data/install.rb
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'rbconfig'
|
4
|
-
require 'ftools'
|
5
|
-
|
6
|
-
dst_dir = Config::CONFIG['sitelibdir']
|
7
|
-
|
8
|
-
Dir.chdir('lib') do
|
9
|
-
Dir['**/*.rb'].each do |file|
|
10
|
-
File.mkpath File.join(dst_dir, File.dirname(file)), true
|
11
|
-
File.install file, File.join(dst_dir, file), 0644, true
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
puts %{
|
16
|
-
|
17
|
-
|
18
|
-
---
|
19
|
-
Congratulations, you have successfully installed Nitro!
|
20
|
-
The libraries where installed in '#{dst_dir}'.
|
21
|
-
|
22
|
-
You probably need to install the Glue and Og libraries
|
23
|
-
as well. (http://nitro.rubyforge.org)
|
24
|
-
|
25
|
-
To verify that everything works correctly, try to run the tiny
|
26
|
-
example by issuing:
|
27
|
-
|
28
|
-
$ cd exampes/tiny
|
29
|
-
$ ruby run.rb
|
30
|
-
|
31
|
-
at the command line.
|
32
|
-
|
33
|
-
Enjoy the magic of Nitro!
|
34
|
-
}
|
35
|
-
|
36
|
-
# * George Moschovitis <gm@navel.gr>
|
37
|
-
|
@@ -1,206 +0,0 @@
|
|
1
|
-
require 'nitro/template'
|
2
|
-
require 'nitro/compiler/elements'
|
3
|
-
|
4
|
-
module Nitro
|
5
|
-
|
6
|
-
# A shader defines a transformation-pipeline that tansforms
|
7
|
-
# the .xhtml files to actual ruby code ready for evaluation
|
8
|
-
# (compilation) by the engine.
|
9
|
-
#
|
10
|
-
# Shaders employ a folded-filter design.
|
11
|
-
#--
|
12
|
-
# TODO: pipeline stage mixin to be reused in filters too.
|
13
|
-
#++
|
14
|
-
|
15
|
-
class Shader
|
16
|
-
|
17
|
-
# the next stage in the Shader pipeline.
|
18
|
-
|
19
|
-
attr :next_stage
|
20
|
-
|
21
|
-
def initialize(next_stage = nil)
|
22
|
-
@next_stage = next_stage
|
23
|
-
end
|
24
|
-
|
25
|
-
# Process the text and optionally update the hash.
|
26
|
-
# The hash is a short, unique representation of the
|
27
|
-
# input text, typically used as a caching key.
|
28
|
-
|
29
|
-
def process(hash, text)
|
30
|
-
process_next(hash, text)
|
31
|
-
end
|
32
|
-
|
33
|
-
# Set the next stage of the pipeline.
|
34
|
-
|
35
|
-
def << (next_stage = nil)
|
36
|
-
@next_stage = next_stage
|
37
|
-
return self
|
38
|
-
end
|
39
|
-
|
40
|
-
# Process the next stage of the pipeline.
|
41
|
-
|
42
|
-
def process_next(hash, text)
|
43
|
-
if @next_stage
|
44
|
-
return @next_stage.process(hash, text)
|
45
|
-
else
|
46
|
-
return hash, text
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
# Convert the xhtml script to actual Ruby code, ready
|
52
|
-
# to be evaluated.
|
53
|
-
|
54
|
-
class RubyShader < Shader
|
55
|
-
include TemplateMixin
|
56
|
-
|
57
|
-
# Convert the xhtml script to actual Ruby code, ready
|
58
|
-
# to be evaluated.
|
59
|
-
#--
|
60
|
-
# Investigate:
|
61
|
-
# perhaps xl:href should be used to be XLink compatible?
|
62
|
-
#++
|
63
|
-
|
64
|
-
def process(hash, text)
|
65
|
-
text = compile_template(text)
|
66
|
-
process_next(hash, text)
|
67
|
-
end
|
68
|
-
|
69
|
-
# Loads and statically includes a file.
|
70
|
-
|
71
|
-
def load_statically_included(filename)
|
72
|
-
Logger.debug "Statically including '#{filename}'" if $DBG
|
73
|
-
|
74
|
-
text = File.read(filename)
|
75
|
-
text.gsub!(/<\?xml.*\?>/, '')
|
76
|
-
text.gsub!(/<\/?root(.*?)>/m, ' ');
|
77
|
-
|
78
|
-
return text
|
79
|
-
end
|
80
|
-
|
81
|
-
end
|
82
|
-
|
83
|
-
# Apply an XSL transformation to the script code.
|
84
|
-
# There is no need to keep post xsl. I can reuse the
|
85
|
-
# same xsl by calling transform again.
|
86
|
-
|
87
|
-
class XSLTShader < Shader
|
88
|
-
|
89
|
-
# The name
|
90
|
-
|
91
|
-
attr :name
|
92
|
-
|
93
|
-
# The xslt filename.
|
94
|
-
|
95
|
-
attr :xsl_filename
|
96
|
-
|
97
|
-
# The xslt transformer.
|
98
|
-
|
99
|
-
attr :xslt
|
100
|
-
|
101
|
-
# Last modified time of the xslt.
|
102
|
-
|
103
|
-
attr :mtime
|
104
|
-
|
105
|
-
def initialize(xsl_filename, next_stage = nil)
|
106
|
-
|
107
|
-
# leave this require here. only inlcude the xslt
|
108
|
-
# library if the project needs it.
|
109
|
-
|
110
|
-
require "xml/xslt"
|
111
|
-
|
112
|
-
@name = File.basename(xsl_filename, '.*')
|
113
|
-
@xsl_filename = xsl_filename
|
114
|
-
@xslt = XML::XSLT.new
|
115
|
-
@next_stage = next_stage
|
116
|
-
end
|
117
|
-
|
118
|
-
# Transform the given text.
|
119
|
-
|
120
|
-
def process(hash, text)
|
121
|
-
parse_xsl()
|
122
|
-
@xslt.xml = text
|
123
|
-
hash += @name
|
124
|
-
Logger.debug "Applying xsl '#{@xsl_filename}' to template" if $DBG
|
125
|
-
process_next(hash, xslt.serve)
|
126
|
-
end
|
127
|
-
|
128
|
-
private
|
129
|
-
|
130
|
-
# Parse the xsl.
|
131
|
-
|
132
|
-
def parse_xsl
|
133
|
-
Logger.debug "Parsing xsl '#{@xsl_filename}'" if $DBG
|
134
|
-
@mtime = File.mtime(@xsl_filename)
|
135
|
-
@xslt.xsl = File.read(@xsl_filename)
|
136
|
-
end
|
137
|
-
|
138
|
-
end
|
139
|
-
|
140
|
-
# Compress the inline xhtml. Does not touch the ruby code.
|
141
|
-
|
142
|
-
class CompressShader < Shader
|
143
|
-
|
144
|
-
# Compress the inline xhtml. Does not touch the ruby code.
|
145
|
-
|
146
|
-
def process(hash, text)
|
147
|
-
text.gsub!(/\@out \<\< \%\^(.*?)\^/m) do |match|
|
148
|
-
c = $1.gsub(/^(\s*)/m, '').squeeze(" \t").tr("\n", '').tr("\t", ' ')
|
149
|
-
"@out << %{#{c}}"
|
150
|
-
end
|
151
|
-
|
152
|
-
process_next(hash, text)
|
153
|
-
end
|
154
|
-
|
155
|
-
end
|
156
|
-
|
157
|
-
# MorphingShader
|
158
|
-
|
159
|
-
class MorphingShader < Shader
|
160
|
-
|
161
|
-
def process(hash, text)
|
162
|
-
|
163
|
-
# <tag if="x">..</tag>
|
164
|
-
# <tag unless="x">..</tag>
|
165
|
-
|
166
|
-
text.gsub!(/<(\w*?)([^>]*?)(if|unless)=["|'](.*?)["|'](.*?)>(.*?)<\/\1>/m) do |match|
|
167
|
-
%{<?r #$3 #$4 ?>
|
168
|
-
<#$1#$2#$5>#$6</#$1>
|
169
|
-
<?r end ?>}
|
170
|
-
end
|
171
|
-
|
172
|
-
# <tag times="x">..</tag>
|
173
|
-
|
174
|
-
text.gsub!(/<(\w*?)([^>]*?)times=["|'](.*?)["|'](.*?)>(.*?)<\/\1>/m) do |match|
|
175
|
-
%{<?r #$3.times do ?>
|
176
|
-
<#$1#$2#$4>#$5</#$1>
|
177
|
-
<?r end ?>}
|
178
|
-
end
|
179
|
-
|
180
|
-
# <tag each="x">..</tag>
|
181
|
-
|
182
|
-
text.gsub!(/<(\w*?)([^>]*?)each=["|'](.*?)["|'](.*?)>(.*?)<\/\1>/m) do |match|
|
183
|
-
%{<?r for #$3 ?>
|
184
|
-
<#$1#$2#$4>#$5</#$1>
|
185
|
-
<?r end ?>}
|
186
|
-
end
|
187
|
-
|
188
|
-
process_next(hash, text)
|
189
|
-
end
|
190
|
-
|
191
|
-
end
|
192
|
-
|
193
|
-
# ElementsShader
|
194
|
-
|
195
|
-
class ElementsShader < Shader
|
196
|
-
|
197
|
-
def process(hash, text)
|
198
|
-
text = ElementProcessor.render(text)
|
199
|
-
process_next(hash, text)
|
200
|
-
end
|
201
|
-
|
202
|
-
end
|
203
|
-
|
204
|
-
end
|
205
|
-
|
206
|
-
# * George Moschovitis <gm@navel.gr>
|
@@ -1,49 +0,0 @@
|
|
1
|
-
module Nitro
|
2
|
-
|
3
|
-
module PrototypeHelper
|
4
|
-
|
5
|
-
def remote_function()
|
6
|
-
end
|
7
|
-
|
8
|
-
#--
|
9
|
-
# TODO: resolve html
|
10
|
-
#++
|
11
|
-
|
12
|
-
class JavascriptGenerator
|
13
|
-
attr_accessor :buffer
|
14
|
-
|
15
|
-
def initialize
|
16
|
-
@buffer = ''
|
17
|
-
end
|
18
|
-
|
19
|
-
# html = A string or a symbol to an action for rendering.
|
20
|
-
#--
|
21
|
-
# TODO: resolve html.
|
22
|
-
#++
|
23
|
-
|
24
|
-
def insert_html(id, html, options = {})
|
25
|
-
position = options.fetch(:where, :before)
|
26
|
-
record "new Insertion.#{position.to_s.camelize}(#{id.inspect}, #{html.inspect})"
|
27
|
-
end
|
28
|
-
|
29
|
-
def replace_html(id, html, options = {})
|
30
|
-
record "Element.update(#{id.inspect}, #{html.inspect})"
|
31
|
-
end
|
32
|
-
|
33
|
-
private
|
34
|
-
|
35
|
-
def record(code)
|
36
|
-
code = "#{line.to_s.chomp.gsub /\;$/, ''};"
|
37
|
-
@buffer << code
|
38
|
-
return code
|
39
|
-
end
|
40
|
-
|
41
|
-
end
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
end
|
46
|
-
|
47
|
-
end
|
48
|
-
|
49
|
-
# * George Moschovitis <gm@navel.gr>
|
@@ -1,54 +0,0 @@
|
|
1
|
-
require 'nitro/scaffold'
|
2
|
-
|
3
|
-
module Nitro::Scaffolding
|
4
|
-
|
5
|
-
# A collection of scaffolding helper for Og relations.
|
6
|
-
|
7
|
-
module Og
|
8
|
-
|
9
|
-
private
|
10
|
-
|
11
|
-
# Scaffold the relations of an Og managed object.
|
12
|
-
|
13
|
-
def scaffold_relations(obj)
|
14
|
-
end
|
15
|
-
|
16
|
-
# Scaffold a +belongs_to+ relation.
|
17
|
-
|
18
|
-
def belongs_to_editor(obj, rel, options)
|
19
|
-
entities = rel.target_class.all
|
20
|
-
labels = entities.map { |e| e.to_s }
|
21
|
-
values = entities.map { |e| e.oid }
|
22
|
-
element(
|
23
|
-
label(rel.name),
|
24
|
-
%{
|
25
|
-
<select id="#{rel.name}" name="#{rel.name}">
|
26
|
-
#{options(:labels => labels, :values => values, :selected => 1)}
|
27
|
-
</select>
|
28
|
-
}
|
29
|
-
)
|
30
|
-
end
|
31
|
-
|
32
|
-
# Scaffold a +has_many+ relation.
|
33
|
-
|
34
|
-
def has_many_editor(obj, rel, options)
|
35
|
-
entities = obj.send(rel.target_plural_name)
|
36
|
-
unless entities.empty?
|
37
|
-
str = entities.inject('') do |acc, e|
|
38
|
-
acc << "<tr><td>#{e.to_edit_link(@base)}</td></tr>"
|
39
|
-
end
|
40
|
-
str = "<table>#{str}</table>"
|
41
|
-
else
|
42
|
-
str = 'No entities found.<br /><br />'
|
43
|
-
end
|
44
|
-
element(
|
45
|
-
label(rel.name) + ' <a href="#">Add</a>',
|
46
|
-
%{
|
47
|
-
#{str}
|
48
|
-
}
|
49
|
-
)
|
50
|
-
end
|
51
|
-
|
52
|
-
end
|
53
|
-
|
54
|
-
end
|