nitro 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +4 -2201
- data/ChangeLog.1 +2344 -0
- data/README +4 -4
- data/RELEASES +22 -0
- data/bin/new_app.rb +17 -3
- data/bin/proto/README +34 -0
- data/bin/proto/apache.conf +1 -0
- data/bin/proto/app.rb +20 -0
- data/bin/proto/config.rb +77 -0
- data/bin/proto/root/index.xhtml +43 -0
- data/bin/proto/root/style.css +218 -0
- data/bin/proto/root/style.xsl +130 -0
- data/examples/blog/app.rb +1 -2
- data/examples/blog/config.rb +20 -18
- data/examples/blog/env.rb +22 -0
- data/examples/blog/lib/blog.rb +43 -15
- data/examples/blog/root/entry_form.xhtml +1 -1
- data/examples/blog/root/index.xhtml +5 -0
- data/examples/blog/root/login.xhtml +2 -0
- data/examples/blog/root/m/nitro.gif +0 -0
- data/examples/blog/root/style.css +83 -0
- data/examples/blog/root/style.xsl +7 -3
- data/examples/og/run.rb +41 -2
- data/examples/tiny/app.rb +1 -2
- data/examples/tiny/root/index.xhtml +8 -2
- data/examples/tiny/root/nitro-small.png +0 -0
- data/lib/glue.rb +1 -1
- data/lib/glue/property.rb +9 -3
- data/lib/nitro/application.rb +18 -1
- data/lib/nitro/builders/form.rb +84 -0
- data/lib/nitro/builders/rss.rb +4 -5
- data/lib/nitro/builders/table.rb +23 -0
- data/lib/nitro/filters.rb +157 -0
- data/lib/nitro/l10n.rb +11 -3
- data/lib/nitro/scaffold.rb +1 -1
- data/lib/nitro/server/render.rb +101 -4
- data/lib/nitro/server/shaders.rb +17 -5
- data/lib/nitro/service.rb +5 -5
- data/lib/nitro/ui/pager.rb +35 -11
- data/lib/nitro/version.rb +2 -2
- data/lib/og.rb +25 -17
- data/lib/og/backend.rb +15 -3
- data/lib/og/backends/mysql.rb +30 -3
- data/lib/og/backends/psql.rb +44 -3
- data/lib/og/meta.rb +117 -10
- data/lib/og/version.rb +1 -1
- data/lib/xsl/base.xsl +75 -6
- data/lib/xsl/ui.xsl +51 -0
- data/test/nitro/ui/tc_pager.rb +6 -0
- metadata +23 -2
@@ -0,0 +1,130 @@
|
|
1
|
+
<?xml version="1.0"?>
|
2
|
+
|
3
|
+
<!--
|
4
|
+
A Simple Shader
|
5
|
+
|
6
|
+
code:
|
7
|
+
* George Moschovitis <gm@navel.gr>
|
8
|
+
|
9
|
+
(c) 2004 Navel, all rights reserved.
|
10
|
+
$Id: style.xsl 188 2004-12-10 14:14:17Z gmosx $
|
11
|
+
-->
|
12
|
+
|
13
|
+
<!DOCTYPE shader
|
14
|
+
[
|
15
|
+
<!ENTITY nbsp "<![CDATA[ ]]>">
|
16
|
+
<!ENTITY copy "<![CDATA[©]]>">
|
17
|
+
<!ENTITY euro "<![CDATA[€]]>">
|
18
|
+
<!ENTITY laquo "<![CDATA[«]]>">
|
19
|
+
<!ENTITY raquo "<![CDATA[»]]>">
|
20
|
+
]>
|
21
|
+
|
22
|
+
<xsl:stylesheet
|
23
|
+
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
24
|
+
xmlns:xl="http://www.w3.org/1999/xlink"
|
25
|
+
xmlns:x="http://www.navel.gr/xml/shader.xsd" version="1.0"
|
26
|
+
exclude-result-prefixes="x xl">
|
27
|
+
|
28
|
+
<xsl:include href="../nitro/lib/xsl/base.xsl" />
|
29
|
+
|
30
|
+
<xsl:output method="xml" indent="yes" encoding="iso-8859-1" />
|
31
|
+
|
32
|
+
<xsl:template name="x:head">
|
33
|
+
<head>
|
34
|
+
<title>#$name</title>
|
35
|
+
<meta name="title" content="Blog" />
|
36
|
+
<meta name="description" content="Example" />
|
37
|
+
<meta name="keywords" content="nitro, example, blog" />
|
38
|
+
<meta name="category" content="example" />
|
39
|
+
<meta name="robots" content="index, follow" />
|
40
|
+
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
|
41
|
+
|
42
|
+
<xsl:apply-templates select="x:block[@id='meta']"/>
|
43
|
+
|
44
|
+
<base href="#$srv_url/" />
|
45
|
+
<link href="/style.css" rel="stylesheet" type="text/css" media="screen" />
|
46
|
+
<link rel="alternate" type="application/rss+xml" title="Latest Entries" href="#$srv_url/rest/list_entry" />
|
47
|
+
<link rel="alternate" type="application/rss+xml" title="Latest Comments" href="#$srv_url/rest/list_comment" />
|
48
|
+
<xsl:apply-templates select="x:cell[@id='head']"/>
|
49
|
+
</head>
|
50
|
+
</xsl:template>
|
51
|
+
|
52
|
+
<xsl:template name="x:header">
|
53
|
+
<div id="header">
|
54
|
+
<h1>#$name</h1>
|
55
|
+
</div>
|
56
|
+
</xsl:template>
|
57
|
+
|
58
|
+
<xsl:template name="x:footer">
|
59
|
+
<div id="footer">
|
60
|
+
</div>
|
61
|
+
</xsl:template>
|
62
|
+
|
63
|
+
<!--
|
64
|
+
can only include x:blocks, all other templates are ignored
|
65
|
+
-->
|
66
|
+
<xsl:template match="x:page">
|
67
|
+
<html>
|
68
|
+
<xsl:call-template name="x:head" />
|
69
|
+
<body>
|
70
|
+
|
71
|
+
<div id="page">
|
72
|
+
|
73
|
+
<xsl:call-template name="x:header" />
|
74
|
+
|
75
|
+
<xsl:apply-templates select="x:cell[@id='top']" />
|
76
|
+
|
77
|
+
<div class="block main">
|
78
|
+
<xsl:apply-templates select="x:cell[@id='main']" />
|
79
|
+
</div>
|
80
|
+
|
81
|
+
<div class="block side">
|
82
|
+
<h2>About</h2>
|
83
|
+
This is a simple blog powered by <a href="http://www.navel.gr/nitro">
|
84
|
+
Nitro</a> Web Engine. Have a look at the source code and enjoy
|
85
|
+
the power of Ruby.
|
86
|
+
<ruby>unless session['owner']</ruby>
|
87
|
+
<p><a href="login">Login</a> as owner.</p>
|
88
|
+
<ruby>else</ruby>
|
89
|
+
<p><a href="logout">Logout</a>.</p>
|
90
|
+
<ruby>end</ruby>
|
91
|
+
|
92
|
+
<xsl:apply-templates select="x:cell[@id='side']" />
|
93
|
+
|
94
|
+
<h2>Linkage</h2>
|
95
|
+
<ul>
|
96
|
+
<li><a target="_new" href="http://www.navel.gr">Navel Ltd</a></li>
|
97
|
+
<li><a target="_new" href="http://www.navel.gr/nitro">Nitro Web Engine</a></li>
|
98
|
+
<li><a target="_new" href="http://www.ruby-lang.org">Ruby</a></li>
|
99
|
+
<li><a target="_new" href="http://www.blogger.com">Blogger</a></li>
|
100
|
+
<li><a target="_new" href="http://www.w3c.org">W3 Consortium</a></li>
|
101
|
+
</ul>
|
102
|
+
|
103
|
+
<br />
|
104
|
+
<ul class="rss">
|
105
|
+
<li><a href="rest/list_entry">Latest entries</a></li>
|
106
|
+
<li><a href="rest/list_comment">Latest comments</a></li>
|
107
|
+
</ul>
|
108
|
+
|
109
|
+
<br />
|
110
|
+
<p>
|
111
|
+
powered by <b><a href="http://www.navel.gr/nitro">Nitro</a></b>
|
112
|
+
<br />
|
113
|
+
skin from <a href="http://www.blogger.com">Blogger.com</a>
|
114
|
+
</p>
|
115
|
+
</div>
|
116
|
+
|
117
|
+
<div class="clear">.</div>
|
118
|
+
|
119
|
+
<xsl:apply-templates select="x:cell[@id='bottom']" />
|
120
|
+
|
121
|
+
<xsl:call-template name="x:footer" />
|
122
|
+
</div>
|
123
|
+
|
124
|
+
<xsl:call-template name="x:rendering-errors" />
|
125
|
+
|
126
|
+
</body>
|
127
|
+
</html>
|
128
|
+
</xsl:template>
|
129
|
+
|
130
|
+
</xsl:stylesheet>
|
data/examples/blog/app.rb
CHANGED
@@ -8,12 +8,11 @@
|
|
8
8
|
# * George Moschovitis <gm@navel.gr>
|
9
9
|
#
|
10
10
|
# (c) 2004 Navel, all rights reserved.
|
11
|
-
# $Id: app.rb
|
11
|
+
# $Id: app.rb 185 2004-12-10 13:29:09Z gmosx $
|
12
12
|
|
13
13
|
# set to true for DEBUG mode.
|
14
14
|
$DBG = true
|
15
15
|
|
16
|
-
$LOAD_PATH.unshift "lib"
|
17
16
|
$LOAD_PATH.unshift "../../lib"
|
18
17
|
|
19
18
|
require "config"
|
data/examples/blog/config.rb
CHANGED
@@ -11,30 +11,32 @@
|
|
11
11
|
# * George Moschovitis <gm@navel.gr>
|
12
12
|
#
|
13
13
|
# (c) 2004 Navel, all rights reserved.
|
14
|
-
# $Id: config.rb
|
14
|
+
# $Id: config.rb 185 2004-12-10 13:29:09Z gmosx $
|
15
15
|
|
16
|
-
require
|
17
|
-
require
|
18
|
-
require
|
16
|
+
require 'nitro'
|
17
|
+
require 'glue/logger'
|
18
|
+
require 'nitro/config'
|
19
19
|
|
20
|
-
require
|
21
|
-
require
|
22
|
-
require
|
23
|
-
require
|
24
|
-
require
|
20
|
+
require 'og'
|
21
|
+
require 'nitro/l10n'
|
22
|
+
require 'nitro/events'
|
23
|
+
require 'glue/mixins'
|
24
|
+
require 'nitro/sitemap'
|
25
25
|
|
26
|
-
require
|
27
|
-
require
|
28
|
-
require
|
29
|
-
require
|
30
|
-
require
|
26
|
+
require 'glue/number'
|
27
|
+
require 'glue/string'
|
28
|
+
require 'glue/array'
|
29
|
+
require 'glue/hash'
|
30
|
+
require 'nitro/html'
|
31
31
|
|
32
|
-
require
|
33
|
-
require
|
32
|
+
require 'nitro/server/webrick'
|
33
|
+
require 'nitro/server/shaders'
|
34
34
|
|
35
|
-
require
|
35
|
+
require 'nitro/builders/form'
|
36
36
|
|
37
|
-
|
37
|
+
require 'lib/blog'
|
38
|
+
|
39
|
+
$name = 'Nitro Blog'
|
38
40
|
|
39
41
|
$blog_username = 'George Moschovitis'
|
40
42
|
$blog_password = 'navelrulez'
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# = Environment injection.
|
2
|
+
#
|
3
|
+
# Require this file in your script to gain access to the full
|
4
|
+
# AppServer environment. Typically used to attach an irb session to
|
5
|
+
# a running application process:
|
6
|
+
#
|
7
|
+
# irb -r env
|
8
|
+
#
|
9
|
+
# code:
|
10
|
+
# * George Moschovitis <gm@navel.gr>
|
11
|
+
#
|
12
|
+
# (c) 2004 Navel, all rights reserved.
|
13
|
+
# $Id: env.rb 187 2004-12-10 13:34:28Z gmosx $
|
14
|
+
|
15
|
+
$DBG = true
|
16
|
+
|
17
|
+
$LOAD_PATH.unshift '../../lib'
|
18
|
+
|
19
|
+
require 'config'
|
20
|
+
|
21
|
+
$app = N::AppServer.new.exec()
|
22
|
+
|
data/examples/blog/lib/blog.rb
CHANGED
@@ -2,13 +2,14 @@
|
|
2
2
|
# * George Moschovitis <gm@navel.gr>
|
3
3
|
#
|
4
4
|
# (c) 2004 Navel, all rights reserved.
|
5
|
-
# $Id: blog.rb
|
5
|
+
# $Id: blog.rb 185 2004-12-10 13:29:09Z gmosx $
|
6
6
|
|
7
7
|
require 'nitro/service'
|
8
8
|
require 'nitro/builders/rss'
|
9
|
+
require 'nitro/ui/pager'
|
9
10
|
|
10
|
-
$blog_username = '
|
11
|
-
$blog_password = '
|
11
|
+
$blog_username = 'George Moschovitis'
|
12
|
+
$blog_password = 'mypassword'
|
12
13
|
|
13
14
|
module N
|
14
15
|
|
@@ -19,11 +20,12 @@ module N
|
|
19
20
|
class Common
|
20
21
|
prop :create_time, Time
|
21
22
|
prop_accessor :author, String
|
22
|
-
prop_accessor :body, String
|
23
|
+
prop_accessor :body, String, :form => :textarea
|
23
24
|
|
24
25
|
def initialize
|
25
26
|
@create_time = Time.now
|
26
27
|
end
|
28
|
+
|
27
29
|
end
|
28
30
|
|
29
31
|
class Comment < Common; end
|
@@ -32,7 +34,20 @@ class Comment < Common; end
|
|
32
34
|
#
|
33
35
|
class BlogEntry < Common
|
34
36
|
prop_accessor :title, String
|
35
|
-
has_many :comments, N::Comment, :linkback => 'entry_oid'
|
37
|
+
has_many :comments, N::Comment, :linkback => 'entry_oid'
|
38
|
+
|
39
|
+
# Play a bit with the text the user enters.
|
40
|
+
#
|
41
|
+
def body=(str)
|
42
|
+
if str
|
43
|
+
str.gsub!(/</, '<')
|
44
|
+
str.gsub!(/>/, '>')
|
45
|
+
str.gsub!(/"/, '"')
|
46
|
+
str.gsub!(/'/, ''')
|
47
|
+
str.gsub!(/\r\n/, ' <br />')
|
48
|
+
@body = str
|
49
|
+
end
|
50
|
+
end
|
36
51
|
end
|
37
52
|
|
38
53
|
# = Comment
|
@@ -41,13 +56,22 @@ class Comment < Common
|
|
41
56
|
belongs_to :entry, N::BlogEntry
|
42
57
|
end
|
43
58
|
|
44
|
-
# =
|
59
|
+
# = BlogService
|
45
60
|
#
|
46
|
-
|
47
|
-
|
48
|
-
|
61
|
+
class BlogService < N::Service
|
62
|
+
SOURCE_FILE = __FILE__
|
63
|
+
|
64
|
+
before_filter :audit
|
65
|
+
after_filter :cache
|
66
|
+
|
49
67
|
scaffold N::BlogEntry, :name => 'entry', :index => true
|
50
68
|
scaffold N::Comment
|
69
|
+
|
70
|
+
def list_entry
|
71
|
+
@pager = N::UI::Pager.new('entries', @request, 3)
|
72
|
+
@entries = N::BlogEntry.all("ORDER BY oid DESC #{@pager.sql_limit}")
|
73
|
+
@pager.set(N::BlogEntry.count)
|
74
|
+
end
|
51
75
|
|
52
76
|
def new_entry
|
53
77
|
entry = request.fill(N::BlogEntry.new)
|
@@ -84,14 +108,18 @@ module BlogMethods
|
|
84
108
|
|
85
109
|
def logout
|
86
110
|
session['owner'] = session['username'] = nil
|
87
|
-
end
|
111
|
+
end
|
88
112
|
|
89
|
-
|
113
|
+
private
|
90
114
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
115
|
+
def audit
|
116
|
+
puts "audit (before filter example)"
|
117
|
+
end
|
118
|
+
|
119
|
+
def cache
|
120
|
+
puts "cache (after filter example)"
|
121
|
+
end
|
122
|
+
|
95
123
|
end
|
96
124
|
|
97
125
|
end # module
|
Binary file
|
@@ -49,6 +49,11 @@ input, textarea {
|
|
49
49
|
background: url(m/h1_bg.gif) no-repeat bottom left;
|
50
50
|
}
|
51
51
|
|
52
|
+
#header h1 a {
|
53
|
+
color: #fff;
|
54
|
+
text-decoration: none;
|
55
|
+
}
|
56
|
+
|
52
57
|
#footer {
|
53
58
|
height: 40px;
|
54
59
|
color: #fff;
|
@@ -216,3 +221,81 @@ h2.date {
|
|
216
221
|
background: url(m/rss.gif) no-repeat 0 6px;
|
217
222
|
}
|
218
223
|
|
224
|
+
/* --- pager --- */
|
225
|
+
|
226
|
+
.pager {
|
227
|
+
margin-top: 40px; margin-bottom: 50px;
|
228
|
+
border-top: 1px solid #ccc;
|
229
|
+
background-color: #f0f0f0;
|
230
|
+
}
|
231
|
+
|
232
|
+
.pager .first {
|
233
|
+
float: left;
|
234
|
+
padding: 5px;
|
235
|
+
}
|
236
|
+
|
237
|
+
.pager .previous {
|
238
|
+
float: left;
|
239
|
+
padding: 5px;
|
240
|
+
margin-left: 5px;
|
241
|
+
}
|
242
|
+
|
243
|
+
.pager .next {
|
244
|
+
float: right;
|
245
|
+
padding: 5px;
|
246
|
+
margin-right: 5px;
|
247
|
+
}
|
248
|
+
|
249
|
+
.pager .last {
|
250
|
+
float: right;
|
251
|
+
padding: 5px;
|
252
|
+
}
|
253
|
+
|
254
|
+
.pager ul {
|
255
|
+
float: left;
|
256
|
+
margin: 0px;
|
257
|
+
padding: 0px;
|
258
|
+
}
|
259
|
+
|
260
|
+
.pager li {
|
261
|
+
float: left;
|
262
|
+
display: inline;
|
263
|
+
padding: 5px;
|
264
|
+
padding-left: 10px;
|
265
|
+
padding-right: 10px;
|
266
|
+
background: none;
|
267
|
+
}
|
268
|
+
|
269
|
+
.pager li.active {
|
270
|
+
background-color: #ffa;
|
271
|
+
}
|
272
|
+
|
273
|
+
.noitems {
|
274
|
+
padding: 5px;
|
275
|
+
text-align: center;
|
276
|
+
}
|
277
|
+
|
278
|
+
/* --- forms --- */
|
279
|
+
|
280
|
+
dl {
|
281
|
+
margin: 0px;
|
282
|
+
}
|
283
|
+
|
284
|
+
dt {
|
285
|
+
display: block;
|
286
|
+
margin: 0px;
|
287
|
+
margin-right: 10px;
|
288
|
+
padding-bottom: 10px;
|
289
|
+
font-weight: bold;
|
290
|
+
}
|
291
|
+
|
292
|
+
dd {
|
293
|
+
display: block;
|
294
|
+
margin: 0px;
|
295
|
+
padding-bottom: 10px;
|
296
|
+
}
|
297
|
+
|
298
|
+
textarea {
|
299
|
+
width: 90%;
|
300
|
+
height: 150px;
|
301
|
+
}
|