nitro 0.11.0 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +150 -0
- data/README +1 -1
- data/RELEASES +89 -0
- data/Rakefile +3 -3
- data/{AUTHORS → doc/AUTHORS} +0 -0
- data/{LICENSE → doc/LICENSE} +0 -0
- data/doc/bugs.txt +2 -1
- data/examples/README.windows +2 -2
- data/examples/blog/lib/blog/controller.rb +9 -8
- data/examples/blog/log/apache.error_log +71 -0
- data/{lib/xsl → examples/blog/root}/base.xsl +0 -0
- data/examples/blog/root/error.xhtml +56 -0
- data/examples/blog/root/index.xhtml +2 -2
- data/examples/blog/root/recent_posts.xhtml +1 -1
- data/examples/blog/root/style.xsl +4 -4
- data/examples/blog/run.rb +1 -2
- data/examples/no_xsl_blog/root/index.xhtml +2 -2
- data/examples/no_xsl_blog/root/recent_posts.xhtml +1 -1
- data/examples/why_wiki/run.rb +19 -19
- data/lib/nitro.rb +2 -21
- data/lib/nitro/adapters/webrick.rb +19 -3
- data/lib/nitro/context.rb +15 -1
- data/lib/nitro/controller.rb +84 -49
- data/lib/nitro/dispatcher.rb +30 -6
- data/lib/nitro/markup.rb +4 -2
- data/lib/nitro/render.rb +15 -11
- data/lib/nitro/routing.rb +33 -0
- data/lib/nitro/runner.rb +38 -3
- data/lib/nitro/scaffold.rb +7 -4
- data/lib/nitro/shaders.rb +11 -4
- data/lib/nitro/template.rb +140 -0
- data/lib/og.rb +25 -11
- data/lib/og/adapter.rb +141 -7
- data/lib/og/adapters/mysql.rb +41 -3
- data/lib/og/adapters/oracle.rb +4 -3
- data/lib/og/adapters/psql.rb +3 -3
- data/lib/og/adapters/sqlite.rb +3 -3
- data/lib/og/connection.rb +5 -1
- data/lib/og/database.rb +26 -12
- data/lib/og/enchant.rb +50 -16
- data/lib/og/meta.rb +15 -15
- data/lib/og/observer.rb +53 -0
- data/test/glue/tc_property_type_checking.rb +3 -0
- data/test/nitro/tc_controller.rb +1 -1
- data/test/nitro/tc_dispatcher.rb +1 -1
- data/test/nitro/tc_template.rb +32 -0
- data/test/og/tc_many_to_many.rb +62 -0
- data/test/og/tc_observer.rb +85 -0
- data/test/tc_og.rb +16 -2
- metadata +12 -14
- data/bin/cluster +0 -218
- data/examples/why_wiki/wiki.yml +0 -6
- data/examples/wiki.yml +0 -1
- data/lib/nitro/ui/select.rb +0 -40
- data/lib/nitro/ui/sitemap.rb +0 -183
- data/test/nitro/ui/tc_sitemap.rb +0 -37
data/examples/why_wiki/wiki.yml
DELETED
data/examples/wiki.yml
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
--- {}
|
data/lib/nitro/ui/select.rb
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
# code:
|
2
|
-
# * George Moschovitis <gm@navel.gr>
|
3
|
-
#
|
4
|
-
# (c) 2004 Navel, all rights reserved.
|
5
|
-
# $Id: select.rb 99 2004-10-22 09:50:28Z gmosx $
|
6
|
-
|
7
|
-
module N; module UI
|
8
|
-
|
9
|
-
class Select
|
10
|
-
|
11
|
-
# Generalized select. Dont create the enclosing selects to
|
12
|
-
# be flexible.
|
13
|
-
# Example:
|
14
|
-
#
|
15
|
-
# <select name="param" onchange="submit()">
|
16
|
-
# #{N::UI::Select.render_options(
|
17
|
-
# paramvalue,
|
18
|
-
# [-1, 1, 2, 3],
|
19
|
-
# ["-- Enter Options --", "Man", "Woman", "None"]
|
20
|
-
# )}
|
21
|
-
# </select>
|
22
|
-
#
|
23
|
-
def self.render_options(paramvalue, values, options)
|
24
|
-
str = ""
|
25
|
-
|
26
|
-
values.each_with_index { |val, idx|
|
27
|
-
if paramvalue == val
|
28
|
-
str << %{<option value="#{val}" selected="1">#{options[idx]}</option>}
|
29
|
-
else
|
30
|
-
str << %{<option value="#{val}">#{options[idx]}</option>}
|
31
|
-
end
|
32
|
-
}
|
33
|
-
|
34
|
-
return str
|
35
|
-
end
|
36
|
-
|
37
|
-
end
|
38
|
-
|
39
|
-
end; end # module
|
40
|
-
|
data/lib/nitro/ui/sitemap.rb
DELETED
@@ -1,183 +0,0 @@
|
|
1
|
-
# * George Moschovitis <gm@navel.gr>
|
2
|
-
# (c) 2004-2005 Navel, all rights reserved.
|
3
|
-
# $Id: sitemap.rb 229 2005-01-27 12:55:29Z gmosx $
|
4
|
-
|
5
|
-
require "glue/hash"
|
6
|
-
|
7
|
-
module N
|
8
|
-
|
9
|
-
# A single page in the page map.
|
10
|
-
|
11
|
-
class SitePage
|
12
|
-
# the uri for this page
|
13
|
-
attr_accessor :uri
|
14
|
-
# the real uri to this page calculated by the page overloader)
|
15
|
-
attr_accessor :real_uri
|
16
|
-
# the realm this page belongs to
|
17
|
-
attr_accessor :realm
|
18
|
-
# the shader for this page, overrided the shader calculated
|
19
|
-
# by the engine
|
20
|
-
attr_accessor :shader
|
21
|
-
attr_accessor :level
|
22
|
-
# title of the page
|
23
|
-
attr_accessor :title
|
24
|
-
# description of the page
|
25
|
-
attr_accessor :description
|
26
|
-
attr_accessor :parent, :children
|
27
|
-
attr_accessor :flag
|
28
|
-
|
29
|
-
# the realm this page belongs to, typically the part name.
|
30
|
-
# put symbols in this variable
|
31
|
-
attr_accessor :realm
|
32
|
-
|
33
|
-
def initialize(uri, title = nil, parent = nil, realm = nil)
|
34
|
-
@uri, @title, @parent = uri, title, parent
|
35
|
-
|
36
|
-
# inherit realm from parent if exists
|
37
|
-
if parent and parent.realm
|
38
|
-
@realm = parent.realm
|
39
|
-
else
|
40
|
-
@realm = realm
|
41
|
-
end
|
42
|
-
|
43
|
-
@children = []
|
44
|
-
@parent.children << self if parent
|
45
|
-
|
46
|
-
# gmosx: is this good?
|
47
|
-
# automatically add to the sitemap.
|
48
|
-
$sitemap << self
|
49
|
-
end
|
50
|
-
|
51
|
-
# Return string representation
|
52
|
-
#
|
53
|
-
def to_s
|
54
|
-
return @title
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
# = SiteMap
|
59
|
-
#
|
60
|
-
# Encapsulates the page structure and additional metadata.
|
61
|
-
#
|
62
|
-
# === TODO:
|
63
|
-
#
|
64
|
-
# move out of the UI namespace.
|
65
|
-
# include url remapping functionality.
|
66
|
-
#
|
67
|
-
# === Design
|
68
|
-
#
|
69
|
-
# Unlike the original version, this is presentation agnostic, and
|
70
|
-
# greatly simplified.
|
71
|
-
#
|
72
|
-
# === Todo:
|
73
|
-
#
|
74
|
-
# - support strings as titles.
|
75
|
-
# - add support to read the map from a config file.
|
76
|
-
# - rename to appmap ?
|
77
|
-
# - Use a second class in the UI namespace for rendering
|
78
|
-
# related stuff?
|
79
|
-
#
|
80
|
-
class SiteMap < N::SafeHash
|
81
|
-
|
82
|
-
# The root page for this sitemap
|
83
|
-
attr_accessor :root
|
84
|
-
|
85
|
-
# The separator used when creating paths
|
86
|
-
attr_accessor :separator
|
87
|
-
|
88
|
-
def initialize(separator = " > ")
|
89
|
-
super
|
90
|
-
@separator = separator
|
91
|
-
end
|
92
|
-
|
93
|
-
def << (page)
|
94
|
-
self[page.uri] = page
|
95
|
-
unless page.parent
|
96
|
-
@root = page
|
97
|
-
page.realm = :root
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
# Path as array of pages
|
102
|
-
#
|
103
|
-
def path(uri)
|
104
|
-
return nil unless uri
|
105
|
-
|
106
|
-
if page = self[uri]
|
107
|
-
res = Array.new;
|
108
|
-
|
109
|
-
res << page
|
110
|
-
while page = page.parent
|
111
|
-
res.unshift(page)
|
112
|
-
end
|
113
|
-
|
114
|
-
return res
|
115
|
-
else
|
116
|
-
Logger.warn "The uri #{uri} is not registered in the SiteMap!"
|
117
|
-
end
|
118
|
-
|
119
|
-
return nil
|
120
|
-
end
|
121
|
-
|
122
|
-
# Calculates the linked path to the given uri.
|
123
|
-
#
|
124
|
-
def linked_path(uri, lc = nil, args = nil)
|
125
|
-
if the_path = path(uri)
|
126
|
-
i = -1
|
127
|
-
j, s = 0, the_path.size()
|
128
|
-
return the_path.collect { |p|
|
129
|
-
j += 1
|
130
|
-
if p.title.is_a?(String)
|
131
|
-
j == s ? p.title : %|<a href="#{p.uri}">#{p.title}</a>|
|
132
|
-
elsif p.title.is_a?(Symbol)
|
133
|
-
j == s ? lc[p.title] : %|<a href="#{p.uri}">#{lc[p.title]}</a>|
|
134
|
-
else
|
135
|
-
i += 1
|
136
|
-
title, qs = p.title.call(args[i])
|
137
|
-
j == s ? title : %|<a href="#{p.uri}#{qs}">#{title}</a>|
|
138
|
-
end
|
139
|
-
}.join(@separator)
|
140
|
-
|
141
|
-
else
|
142
|
-
return nil
|
143
|
-
end
|
144
|
-
end
|
145
|
-
|
146
|
-
# Calculates the path to the given uri.
|
147
|
-
#
|
148
|
-
def str_path(uri, lc = nil, args = nil)
|
149
|
-
if the_path = path(uri)
|
150
|
-
i = -1
|
151
|
-
return the_path.collect { |p|
|
152
|
-
if p.title.is_a?(String)
|
153
|
-
p.title
|
154
|
-
elsif p.title.is_a?(Symbol)
|
155
|
-
lc[p.title]
|
156
|
-
else
|
157
|
-
i += 1
|
158
|
-
p.title.call(args[i])[0]
|
159
|
-
end
|
160
|
-
}.join(@separator)
|
161
|
-
else
|
162
|
-
return nil
|
163
|
-
end
|
164
|
-
end
|
165
|
-
|
166
|
-
# Returns a String representation of the Sitemap.
|
167
|
-
#
|
168
|
-
def to_s
|
169
|
-
str = "#{root}"
|
170
|
-
arr = []
|
171
|
-
self.each_pair { |page, title|
|
172
|
-
arr << "#{title}: #{page}"
|
173
|
-
}
|
174
|
-
return "#{str} {" + arr.join(",") + "}"
|
175
|
-
end
|
176
|
-
|
177
|
-
end
|
178
|
-
|
179
|
-
end # module
|
180
|
-
|
181
|
-
# the default sitemap.
|
182
|
-
$sitemap = N::SiteMap.new
|
183
|
-
|
data/test/nitro/ui/tc_sitemap.rb
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
# :nodoc: all
|
2
|
-
|
3
|
-
require "test/unit"
|
4
|
-
|
5
|
-
require "glue/logger"
|
6
|
-
|
7
|
-
require "nitro/ui/sitemap"
|
8
|
-
|
9
|
-
class TC_N_SiteMap < Test::Unit::TestCase
|
10
|
-
include N
|
11
|
-
|
12
|
-
def setup
|
13
|
-
$n0 = SitePage.new "/index.sx", "Joy", nil, realm = "main-realm"
|
14
|
-
$n1 = SitePage.new "/id/index.sx", "Id", $n0
|
15
|
-
$n2 = SitePage.new "/id/page.sx", "My page", $n1
|
16
|
-
$n1 = SitePage.new "/id/login.sx", "Login", $n0
|
17
|
-
end
|
18
|
-
|
19
|
-
def teardown
|
20
|
-
$sitemap = nil
|
21
|
-
end
|
22
|
-
|
23
|
-
def test_all
|
24
|
-
assert_equal(3, $sitemap.path("/id/page.sx").size())
|
25
|
-
|
26
|
-
# bug: wrong order
|
27
|
-
assert_equal("Joy > Id > My page", $sitemap.str_path("/id/page.sx"))
|
28
|
-
|
29
|
-
# bug: wrong hrefs
|
30
|
-
assert_equal('<a href="/index.sx">Joy</a> > <a href="/id/index.sx">Id</a> > My page', $sitemap.linked_path("/id/page.sx"))
|
31
|
-
|
32
|
-
# bug: realm should be inherited from parent
|
33
|
-
setup
|
34
|
-
assert_equal($n2.realm, $n1.realm)
|
35
|
-
end
|
36
|
-
|
37
|
-
end
|