nitro 0.17.0 → 0.18.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +124 -0
- data/README +2 -2
- data/Rakefile +4 -12
- data/bin/nitro +1 -1
- data/bin/nitrogen +47 -31
- data/doc/AUTHORS +3 -3
- data/doc/RELEASES +50 -1
- data/examples/README +7 -0
- data/lib/nitro.rb +5 -4
- data/lib/nitro/{adapters → adapter}/cgi.rb +2 -4
- data/lib/nitro/{adapters → adapter}/fastcgi.rb +1 -1
- data/lib/nitro/{adapters → adapter}/webrick.rb +5 -10
- data/lib/nitro/buffering.rb +6 -0
- data/lib/nitro/{builders → builder}/atom.rb +1 -5
- data/lib/nitro/{builders → builder}/form.rb +1 -5
- data/lib/nitro/{builders → builder}/rss.rb +3 -1
- data/lib/nitro/{builders → builder}/table.rb +2 -4
- data/lib/nitro/{builders → builder}/xhtml.rb +3 -5
- data/lib/nitro/{builders → builder}/xml.rb +2 -4
- data/lib/nitro/caching.rb +6 -4
- data/lib/nitro/caching/output.rb +18 -11
- data/lib/nitro/context.rb +3 -1
- data/lib/nitro/controller.rb +29 -18
- data/lib/nitro/dispatcher.rb +2 -4
- data/lib/nitro/element.rb +2 -0
- data/lib/nitro/environment.rb +2 -4
- data/lib/nitro/errors.rb +69 -0
- data/lib/nitro/mail.rb +2 -4
- data/lib/nitro/markup.rb +20 -3
- data/lib/nitro/output.rb +5 -9
- data/lib/nitro/part.rb +2 -3
- data/lib/nitro/render.rb +49 -30
- data/lib/nitro/request.rb +2 -1
- data/lib/nitro/runner.rb +23 -12
- data/lib/nitro/scaffold.rb +5 -3
- data/lib/nitro/service.rb +22 -0
- data/lib/nitro/service/xmlrpc.rb +42 -0
- data/lib/nitro/session.rb +2 -4
- data/lib/nitro/template.rb +8 -10
- data/lib/nitro/testing.rb +0 -4
- data/proto/public/error.xhtml +27 -2
- data/test/nitro/{adapters → adapter}/raw_post1.bin +0 -0
- data/test/nitro/{adapters → adapter}/tc_cgi.rb +1 -1
- data/test/nitro/{adapters → adapter}/tc_webrick.rb +1 -1
- data/test/nitro/{builders → builder}/tc_atom.rb +1 -1
- data/test/nitro/{builders → builder}/tc_rss.rb +1 -1
- data/test/nitro/{builders → builder}/tc_table.rb +1 -1
- data/test/nitro/{builders → builder}/tc_xhtml.rb +1 -1
- data/test/nitro/{builders → builder}/tc_xml.rb +1 -1
- data/test/nitro/tc_caching.rb +18 -0
- data/test/nitro/tc_controller.rb +1 -1
- data/test/nitro/tc_mail.rb +3 -1
- metadata +33 -168
- data/examples/README.windows +0 -9
- data/examples/ajax/controller.rb +0 -21
- data/examples/ajax/public/index.xhtml +0 -72
- data/examples/ajax/public/js/ajax.js +0 -64
- data/examples/ajax/run.rb +0 -14
- data/examples/blog/README +0 -70
- data/examples/blog/conf/apache.conf +0 -30
- data/examples/blog/conf/apache.conf.new +0 -53
- data/examples/blog/conf/lhttpd.conf +0 -79
- data/examples/blog/conf/locales/de.yml +0 -4
- data/examples/blog/conf/locales/en.yml +0 -4
- data/examples/blog/log/README +0 -3
- data/examples/blog/log/apache.error_log +0 -6647
- data/examples/blog/log/rewrite_log +0 -161
- data/examples/blog/public/base.xsl +0 -153
- data/examples/blog/public/fcgi.rb +0 -5
- data/examples/blog/public/m/bubbles.gif +0 -0
- data/examples/blog/public/m/comments_curve.gif +0 -0
- data/examples/blog/public/m/down.gif +0 -0
- data/examples/blog/public/m/footer_bg.gif +0 -0
- data/examples/blog/public/m/garrow.gif +0 -0
- data/examples/blog/public/m/gbull.gif +0 -0
- data/examples/blog/public/m/grbull.gif +0 -0
- data/examples/blog/public/m/h1_bg.gif +0 -0
- data/examples/blog/public/m/header_bg.gif +0 -0
- data/examples/blog/public/m/nitro.gif +0 -0
- data/examples/blog/public/m/obull.gif +0 -0
- data/examples/blog/public/m/page_bg.gif +0 -0
- data/examples/blog/public/m/rss.gif +0 -0
- data/examples/blog/public/m/side_title_bg.gif +0 -0
- data/examples/blog/public/m/sidebar_bg.gif +0 -0
- data/examples/blog/public/style.css +0 -305
- data/examples/blog/run.rb +0 -43
- data/examples/blog/src/blog.rb +0 -21
- data/examples/blog/src/controller.rb +0 -151
- data/examples/blog/src/mailer.rb +0 -23
- data/examples/blog/src/models/blog.rb +0 -33
- data/examples/blog/src/models/content.rb +0 -18
- data/examples/blog/src/views/blog_entry_email.xhtml +0 -16
- data/examples/blog/src/views/comments.xhtml +0 -36
- data/examples/blog/src/views/entry_form.xhtml +0 -22
- data/examples/blog/src/views/error.xhtml +0 -56
- data/examples/blog/src/views/index.xhtml +0 -49
- data/examples/blog/src/views/login.xhtml +0 -26
- data/examples/blog/src/views/recent_posts.xhtml +0 -14
- data/examples/blog/src/views/view_entry.xhtml +0 -37
- data/examples/blog/src/views/view_entry.xml +0 -12
- data/examples/blog/src/xsl/base.xsl +0 -160
- data/examples/blog/src/xsl/style.xsl +0 -143
- data/examples/blog/test/tc_blog.rb +0 -43
- data/examples/flash/log/README +0 -3
- data/examples/flash/root/index.xhtml +0 -16
- data/examples/flash/root/show_inline_text.xhtml +0 -17
- data/examples/flash/run.rb +0 -7
- data/examples/no_xsl_blog/README +0 -24
- data/examples/no_xsl_blog/conf/apache.conf +0 -30
- data/examples/no_xsl_blog/conf/lhttpd.conf +0 -79
- data/examples/no_xsl_blog/conf/locales/de.yml +0 -4
- data/examples/no_xsl_blog/conf/locales/en.yml +0 -4
- data/examples/no_xsl_blog/lib/blog.rb +0 -16
- data/examples/no_xsl_blog/lib/blog/controller.rb +0 -116
- data/examples/no_xsl_blog/lib/blog/model.rb +0 -35
- data/examples/no_xsl_blog/lib/blog/template.rb +0 -138
- data/examples/no_xsl_blog/lib/content.rb +0 -47
- data/examples/no_xsl_blog/log/README +0 -3
- data/examples/no_xsl_blog/log/apache.error_log +0 -473
- data/examples/no_xsl_blog/public/comments.xhtml +0 -36
- data/examples/no_xsl_blog/public/entry_form.xhtml +0 -22
- data/examples/no_xsl_blog/public/fcgi.rb +0 -5
- data/examples/no_xsl_blog/public/index.xhtml +0 -39
- data/examples/no_xsl_blog/public/login.xhtml +0 -21
- data/examples/no_xsl_blog/public/m/bubbles.gif +0 -0
- data/examples/no_xsl_blog/public/m/comments_curve.gif +0 -0
- data/examples/no_xsl_blog/public/m/down.gif +0 -0
- data/examples/no_xsl_blog/public/m/footer_bg.gif +0 -0
- data/examples/no_xsl_blog/public/m/garrow.gif +0 -0
- data/examples/no_xsl_blog/public/m/gbull.gif +0 -0
- data/examples/no_xsl_blog/public/m/grbull.gif +0 -0
- data/examples/no_xsl_blog/public/m/h1_bg.gif +0 -0
- data/examples/no_xsl_blog/public/m/header_bg.gif +0 -0
- data/examples/no_xsl_blog/public/m/nitro.gif +0 -0
- data/examples/no_xsl_blog/public/m/obull.gif +0 -0
- data/examples/no_xsl_blog/public/m/page_bg.gif +0 -0
- data/examples/no_xsl_blog/public/m/rss.gif +0 -0
- data/examples/no_xsl_blog/public/m/side_title_bg.gif +0 -0
- data/examples/no_xsl_blog/public/m/sidebar_bg.gif +0 -0
- data/examples/no_xsl_blog/public/recent_posts.xhtml +0 -14
- data/examples/no_xsl_blog/public/style.css +0 -299
- data/examples/no_xsl_blog/public/view_entry.xhtml +0 -25
- data/examples/no_xsl_blog/public/view_entry.xml +0 -12
- data/examples/no_xsl_blog/run.rb +0 -35
- data/examples/tiny/README +0 -14
- data/examples/tiny/conf/apache.conf +0 -30
- data/examples/tiny/conf/lhttpd.conf +0 -79
- data/examples/tiny/log/README +0 -3
- data/examples/tiny/log/apache.error_log +0 -154
- data/examples/tiny/public/deep/dir/hello.xhtml +0 -3
- data/examples/tiny/public/fcgi.rb +0 -5
- data/examples/tiny/public/include.xhtml +0 -3
- data/examples/tiny/public/index.xhtml +0 -55
- data/examples/tiny/public/nitro.png +0 -0
- data/examples/tiny/public/upload.xhtml +0 -21
- data/examples/tiny/run.rb +0 -7
- data/examples/wee_style/README +0 -10
- data/examples/wee_style/run.rb +0 -50
- data/examples/why_wiki/README +0 -5
- data/examples/why_wiki/run.rb +0 -59
- data/proto/public/js/ajax.js +0 -63
@@ -1,16 +0,0 @@
|
|
1
|
-
<?xml version="1.0"?>
|
2
|
-
|
3
|
-
<html>
|
4
|
-
|
5
|
-
<h1>Dynamic flash generation.</h1>
|
6
|
-
|
7
|
-
<p>
|
8
|
-
<h3>Implemented inline in the template action</h3>
|
9
|
-
<form name="t1" action="show_inline_text">
|
10
|
-
Enter some text here:<br />
|
11
|
-
<input type="text" name="text" /><br />
|
12
|
-
<input type="submit" />
|
13
|
-
</form>
|
14
|
-
</p>
|
15
|
-
|
16
|
-
</html>
|
@@ -1,17 +0,0 @@
|
|
1
|
-
<?xml version="1.0"?>
|
2
|
-
|
3
|
-
<root>
|
4
|
-
<?r
|
5
|
-
require 'ming/ming'
|
6
|
-
m = SWFMovie.new
|
7
|
-
f = SWFBrowserFont.new('_serif')
|
8
|
-
t = SWFTextField.new
|
9
|
-
t.set_font(f)
|
10
|
-
t.add_string(@contexts['text'])
|
11
|
-
m.add(t)
|
12
|
-
@context.response_headers['Content-Type'] = 'application/x-shockwave-flash'
|
13
|
-
m.save('tmp.swf')
|
14
|
-
@out = File.read('tmp.swf')
|
15
|
-
?>
|
16
|
-
</root>
|
17
|
-
|
data/examples/flash/run.rb
DELETED
data/examples/no_xsl_blog/README
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
= No XSL Blog
|
2
|
-
|
3
|
-
A this is a simple version of the blog example. This
|
4
|
-
version does not use XSLT so it is easier to get this
|
5
|
-
up and running (especially on Windows).
|
6
|
-
|
7
|
-
For configuration and startup instructions, please
|
8
|
-
have a look at examples/blog/README. At the very
|
9
|
-
least you shold configure the database username/password.
|
10
|
-
|
11
|
-
When running on windows, the database binaries should
|
12
|
-
be in the PATH.
|
13
|
-
|
14
|
-
To see the example browse http://127.0.0.1:9999
|
15
|
-
|
16
|
-
= WARNING
|
17
|
-
|
18
|
-
This example seems to have some problems when running
|
19
|
-
with Internet Explorer 6. For the moment, please
|
20
|
-
try running it with Firefox and/or Mozilla.
|
21
|
-
|
22
|
-
Not all features of the blog example are converted.
|
23
|
-
Moreover, this example uses an alternative directory
|
24
|
-
structure to show the flexibility of Nitro.
|
@@ -1,30 +0,0 @@
|
|
1
|
-
# Apache configuration file.
|
2
|
-
# Change as appropriate for your apache configuration.
|
3
|
-
# $Id$
|
4
|
-
|
5
|
-
Listen 9999
|
6
|
-
|
7
|
-
PidFile /var/tmp/httpd.pid
|
8
|
-
TypesConfig /etc/mime.types
|
9
|
-
DocumentRoot /home/gmosx/navel/nitro/examples/no_xsl_blog/public
|
10
|
-
|
11
|
-
# The error log.
|
12
|
-
ErrorLog log/apache.error_log
|
13
|
-
CustomLog log/access_log combined
|
14
|
-
|
15
|
-
# Load dynamic modules.
|
16
|
-
LoadModule fastcgi_module /usr/local/apache2/modules/mod_fastcgi.so
|
17
|
-
# LoadModule rewrite_module /usr/local/apache2/modules/mod_rewrite.so
|
18
|
-
|
19
|
-
FastCgiIpcDir /var/tmp/fcgi
|
20
|
-
# gmosx: if you have installed the distribution the -I is not needed.
|
21
|
-
FastCgiConfig -initial-env 'RUBYOPT=-rubygems -I/home/gmosx/navel/nitro/lib -I/home/gmosx/navel/og/lib -I/home/gmosx/navel/glue/lib'
|
22
|
-
AddHandler fastcgi-script fcgi rb
|
23
|
-
Options +FollowSymLinks +ExecCGI
|
24
|
-
|
25
|
-
RewriteEngine On
|
26
|
-
RewriteRule ^/([\/\-_a-zA-Z0-9]+)?$ /fcgi.rb [QSA,L]
|
27
|
-
RewriteRule ^/([\/\-_a-zA-Z0-9]+)?\?([\-_a-zA-Z0-9=;&%]*)$ /fcgi.rb?$2 [QSA,L]
|
28
|
-
|
29
|
-
# You can also point these error messages to a controller/action
|
30
|
-
# ErrorDocument 500 /500.html
|
@@ -1,79 +0,0 @@
|
|
1
|
-
# Lighttpd configuration file
|
2
|
-
# $Id$
|
3
|
-
|
4
|
-
server.port = 9999
|
5
|
-
server.bind = "127.0.0.1"
|
6
|
-
# server.event-handler = "freebsd-kqueue" # needed on OS X
|
7
|
-
|
8
|
-
server.modules = ( "mod_rewrite", "mod_fastcgi", "mod_access", "mod_accesslog" )
|
9
|
-
|
10
|
-
server.document-root = "/home/gmosx/navel/nitro/examples/no_xsl_blog/public/"
|
11
|
-
server.errorlog = "/home/gmosx/navel/nitro/examples/no_xsl_blog/log/lighttpd.error.log"
|
12
|
-
accesslog.filename = "/home/gmosx/navel/nitro/examples/no_xsl_blog/log/access.log"
|
13
|
-
|
14
|
-
server.indexfiles = ( "index.html" )
|
15
|
-
url.access-deny = ( "~", ".inc" )
|
16
|
-
|
17
|
-
url.rewrite = ( "^/$" => "index.html", "^([^.]+)$" => "$1.html" )
|
18
|
-
server.error-handler-404 = "/fcgi.rb"
|
19
|
-
|
20
|
-
fastcgi.server = ( ".rb" =>
|
21
|
-
( "localhost" =>
|
22
|
-
(
|
23
|
-
"min-procs" => 1,
|
24
|
-
"max-procs" => 1,
|
25
|
-
"socket" => "/tmp/no_xsl_blog.fcgi.socket",
|
26
|
-
"bin-path" => "/home/gmosx/navel/nitro/examples/no_xsl_blog/public/fcgi.rb",
|
27
|
-
"bin-environment" => ( "NITRO_ENV" => "development" )
|
28
|
-
)
|
29
|
-
)
|
30
|
-
)
|
31
|
-
|
32
|
-
mimetype.assign = (
|
33
|
-
".pdf" => "application/pdf",
|
34
|
-
".sig" => "application/pgp-signature",
|
35
|
-
".spl" => "application/futuresplash",
|
36
|
-
".class" => "application/octet-stream",
|
37
|
-
".ps" => "application/postscript",
|
38
|
-
".torrent" => "application/x-bittorrent",
|
39
|
-
".dvi" => "application/x-dvi",
|
40
|
-
".gz" => "application/x-gzip",
|
41
|
-
".pac" => "application/x-ns-proxy-autoconfig",
|
42
|
-
".swf" => "application/x-shockwave-flash",
|
43
|
-
".tar.gz" => "application/x-tgz",
|
44
|
-
".tgz" => "application/x-tgz",
|
45
|
-
".tar" => "application/x-tar",
|
46
|
-
".zip" => "application/zip",
|
47
|
-
".mp3" => "audio/mpeg",
|
48
|
-
".m3u" => "audio/x-mpegurl",
|
49
|
-
".wma" => "audio/x-ms-wma",
|
50
|
-
".wax" => "audio/x-ms-wax",
|
51
|
-
".ogg" => "audio/x-wav",
|
52
|
-
".wav" => "audio/x-wav",
|
53
|
-
".gif" => "image/gif",
|
54
|
-
".jpg" => "image/jpeg",
|
55
|
-
".jpeg" => "image/jpeg",
|
56
|
-
".png" => "image/png",
|
57
|
-
".xbm" => "image/x-xbitmap",
|
58
|
-
".xpm" => "image/x-xpixmap",
|
59
|
-
".xwd" => "image/x-xwindowdump",
|
60
|
-
".css" => "text/css",
|
61
|
-
".html" => "text/html",
|
62
|
-
".htm" => "text/html",
|
63
|
-
".js" => "text/javascript",
|
64
|
-
".asc" => "text/plain",
|
65
|
-
".c" => "text/plain",
|
66
|
-
".conf" => "text/plain",
|
67
|
-
".text" => "text/plain",
|
68
|
-
".txt" => "text/plain",
|
69
|
-
".dtd" => "text/xml",
|
70
|
-
".xml" => "text/xml",
|
71
|
-
".mpeg" => "video/mpeg",
|
72
|
-
".mpg" => "video/mpeg",
|
73
|
-
".mov" => "video/quicktime",
|
74
|
-
".qt" => "video/quicktime",
|
75
|
-
".avi" => "video/x-msvideo",
|
76
|
-
".asf" => "video/x-ms-asf",
|
77
|
-
".asx" => "video/x-ms-asf",
|
78
|
-
".wmv" => "video/x-ms-wmv"
|
79
|
-
)
|
@@ -1,16 +0,0 @@
|
|
1
|
-
# A simple blog to demonstrate the power of Nitro.
|
2
|
-
|
3
|
-
class Blog
|
4
|
-
|
5
|
-
# The administrator username.
|
6
|
-
|
7
|
-
cattr_accessor :username, 'George Moschovitis'
|
8
|
-
|
9
|
-
# The administrator password.
|
10
|
-
|
11
|
-
cattr_accessor :password, 'mypassword'
|
12
|
-
|
13
|
-
end
|
14
|
-
|
15
|
-
require 'lib/blog/model'
|
16
|
-
require 'lib/blog/controller'
|
@@ -1,116 +0,0 @@
|
|
1
|
-
require 'nitro/controller'
|
2
|
-
require 'nitro/builders/rss'
|
3
|
-
require 'nitro/ui/pager'
|
4
|
-
require 'nitro/localization'
|
5
|
-
|
6
|
-
require 'lib/blog/model'
|
7
|
-
require 'lib/blog/template'
|
8
|
-
|
9
|
-
# The controller of the Blog part.
|
10
|
-
|
11
|
-
class BlogController < Nitro::Controller
|
12
|
-
include BlogTemplate
|
13
|
-
|
14
|
-
pre :get_errors
|
15
|
-
wrap Nitro::LocalizationAspect, :pre => :localize
|
16
|
-
|
17
|
-
scaffold BlogEntry, :name => 'entry', :index => true
|
18
|
-
scaffold Comment
|
19
|
-
|
20
|
-
def list_entry
|
21
|
-
@pager = UI::Pager.new('entries', request, 3)
|
22
|
-
@entries = BlogEntry.all(:order => 'oid DESC', :extra => @pager.sql_limit)
|
23
|
-
@pager.set(BlogEntry.count)
|
24
|
-
end
|
25
|
-
|
26
|
-
def new_entry
|
27
|
-
entry = request.fill(BlogEntry.new)
|
28
|
-
entry.author = session[:username]
|
29
|
-
|
30
|
-
unless entry.valid?
|
31
|
-
session[:errors] = entry.errors
|
32
|
-
redirect_referer '#new_entry'
|
33
|
-
end
|
34
|
-
|
35
|
-
entry.save!
|
36
|
-
end
|
37
|
-
|
38
|
-
def new_comment
|
39
|
-
comment = request.fill(Comment.new)
|
40
|
-
|
41
|
-
unless comment.valid?
|
42
|
-
session[:errors] = comment.errors
|
43
|
-
redirect_referer '#new_comment'
|
44
|
-
end
|
45
|
-
|
46
|
-
comment.save!
|
47
|
-
end
|
48
|
-
|
49
|
-
def login
|
50
|
-
if password = request['password']
|
51
|
-
if password == Blog.password
|
52
|
-
session[:owner] = true
|
53
|
-
session[:username] = Blog.username
|
54
|
-
redirect '/'
|
55
|
-
else
|
56
|
-
@error = 'Invalid password'
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
def logout
|
62
|
-
session.delete(:owner)
|
63
|
-
session.delete(:username)
|
64
|
-
end
|
65
|
-
|
66
|
-
def toggle_locale
|
67
|
-
if session[:LOCALE] == :de
|
68
|
-
session[:LOCALE] = :en
|
69
|
-
else
|
70
|
-
session[:LOCALE] = :de
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
private
|
75
|
-
|
76
|
-
# A helper prefilter, autocleans session errors.
|
77
|
-
# Used as an example.
|
78
|
-
|
79
|
-
def get_errors
|
80
|
-
# gmosx: should better implement top-level filters!
|
81
|
-
if errors = session.delete(:errors)
|
82
|
-
@errors = errors
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
# Just an example.
|
87
|
-
|
88
|
-
def cache
|
89
|
-
# Call the automatically configured logger.
|
90
|
-
|
91
|
-
Logger.info "cache (after filter example)"
|
92
|
-
end
|
93
|
-
|
94
|
-
end
|
95
|
-
|
96
|
-
# A special controller for that presents
|
97
|
-
# the blog content using XML (RSS). This controller
|
98
|
-
# reuses the BlogController actions but adds
|
99
|
-
# XML templates.
|
100
|
-
|
101
|
-
class XmlController < BlogController
|
102
|
-
@base = 'xml'
|
103
|
-
@content_type = 'text/xml'
|
104
|
-
@template_root = 'src/views/xml'
|
105
|
-
|
106
|
-
def list_entry
|
107
|
-
super
|
108
|
-
o.build_rss(@entries, :description => 'Blog entries', :link => context.host_url)
|
109
|
-
end
|
110
|
-
|
111
|
-
def list_comment
|
112
|
-
super
|
113
|
-
o.build_rss(@comments, :description => 'Blog comments', :link => context.host_url)
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
@@ -1,35 +0,0 @@
|
|
1
|
-
require 'lib/content'
|
2
|
-
|
3
|
-
# The models used in the Blog part.
|
4
|
-
|
5
|
-
# Forward reference to the Comment definition.
|
6
|
-
|
7
|
-
class Comment; end
|
8
|
-
|
9
|
-
# Common properties/methods for the other classes.
|
10
|
-
# Since markup is required, automatically handles
|
11
|
-
# the markup expanding/compacting for the body.
|
12
|
-
|
13
|
-
module Common
|
14
|
-
include BaseContent
|
15
|
-
include CreateTime
|
16
|
-
|
17
|
-
property :author, String
|
18
|
-
validate_value :body
|
19
|
-
end
|
20
|
-
|
21
|
-
# An entry in the Blog.
|
22
|
-
|
23
|
-
class BlogEntry
|
24
|
-
include Common
|
25
|
-
has_many :comments, Comment, :foreign_name => 'entry'
|
26
|
-
validate_value :title, :msg => 'Please provide a title'
|
27
|
-
end
|
28
|
-
|
29
|
-
# A comment to the blog entry.
|
30
|
-
|
31
|
-
class Comment
|
32
|
-
include Common
|
33
|
-
belongs_to :entry, BlogEntry
|
34
|
-
validate_value :author, :msg => 'Please enter your name'
|
35
|
-
end
|
@@ -1,138 +0,0 @@
|
|
1
|
-
# * George Moschovitis <gm@navel.gr>
|
2
|
-
# (c) 2004-2005 Navel, all rights reserved.
|
3
|
-
# $Id: template.rb 1 2005-04-11 11:04:30Z gmosx $
|
4
|
-
|
5
|
-
# A simple templating system. This demonstrates how
|
6
|
-
# easily you can replace the XSLT templating system
|
7
|
-
# with a custom implementation. Please note, that
|
8
|
-
# this templating system is considerably less
|
9
|
-
# efficient than XSLT. Moreover, not all features of
|
10
|
-
# the XSLT template are ported.
|
11
|
-
|
12
|
-
module BlogTemplate
|
13
|
-
|
14
|
-
def s_head
|
15
|
-
%{
|
16
|
-
<head>
|
17
|
-
<title>#{@context.conf.name}</title>
|
18
|
-
<meta name="title" content="Blog" />
|
19
|
-
<meta name="description" content="Example" />
|
20
|
-
<meta name="keywords" content="nitro, example, blog" />
|
21
|
-
<meta name="category" content="example" />
|
22
|
-
<meta name="robots" content="index, follow" />
|
23
|
-
<meta http-equiv="content-type" content="text/html; charset=utf8" />
|
24
|
-
<base href="#{@context.host_url}/" />
|
25
|
-
<link href="/style.css" rel="stylesheet" type="text/css" media="screen" />
|
26
|
-
<link rel="alternate" type="application/rss+xml" title="Latest Entries" href="#{@context.host_url}/xml/list_entry" />
|
27
|
-
<link rel="alternate" type="application/rss+xml" title="Latest Comments" href="#{@context.host_url}/xml/list_comment" />
|
28
|
-
}
|
29
|
-
end
|
30
|
-
|
31
|
-
def e_head
|
32
|
-
%{
|
33
|
-
</head>
|
34
|
-
}
|
35
|
-
end
|
36
|
-
|
37
|
-
def t_head
|
38
|
-
s_head + e_head
|
39
|
-
end
|
40
|
-
|
41
|
-
def t_header
|
42
|
-
%{
|
43
|
-
<div id="header">
|
44
|
-
<h1><a href="/">#{@context.conf.name}</a></h1>
|
45
|
-
</div>
|
46
|
-
}
|
47
|
-
end
|
48
|
-
|
49
|
-
def t_footer
|
50
|
-
%{
|
51
|
-
<div id="footer">
|
52
|
-
</div>
|
53
|
-
}
|
54
|
-
end
|
55
|
-
|
56
|
-
def t_rendering_errors
|
57
|
-
if @rendering_errors and (!@rendering_errors.empty?)
|
58
|
-
%{
|
59
|
-
<div id="rendering-errors">
|
60
|
-
<h3>RENDERING ERRORS:</h3>
|
61
|
-
#{@rendering_errors.join('<br />')}
|
62
|
-
</div>
|
63
|
-
}
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
def s_page
|
68
|
-
%{
|
69
|
-
<html>
|
70
|
-
#{t_head}
|
71
|
-
<body>
|
72
|
-
|
73
|
-
<div id="page">
|
74
|
-
|
75
|
-
#{t_header}
|
76
|
-
|
77
|
-
<div class="block main">
|
78
|
-
}
|
79
|
-
end
|
80
|
-
|
81
|
-
def e_page
|
82
|
-
%{
|
83
|
-
</div>
|
84
|
-
|
85
|
-
<div class="block side">
|
86
|
-
<h2>About</h2>
|
87
|
-
This is a simple blog powered by <a href="http://www.navel.gr/nitro">
|
88
|
-
Nitro</a> Web Engine. Have a look at the source code and enjoy
|
89
|
-
the power of Ruby.
|
90
|
-
} + unless session['owner'] then %{
|
91
|
-
<p><a href="login">Login</a> as owner.</p>
|
92
|
-
} else %{
|
93
|
-
<p><a href="logout">Logout</a>.</p>
|
94
|
-
} end + %{
|
95
|
-
|
96
|
-
<p>
|
97
|
-
<b>Language</b>: #{session[:LOCALE] || :en} (<a href="toggle_locale">change</a>)
|
98
|
-
</p>
|
99
|
-
|
100
|
-
<h2>Linkage</h2>
|
101
|
-
<ul>
|
102
|
-
<li><a target="_new" href="http://www.navel.gr">Navel Ltd</a></li>
|
103
|
-
<li><a target="_new" href="http://www.navel.gr/nitro">Nitro Web Engine</a></li>
|
104
|
-
<li><a target="_new" href="http://www.ruby-lang.org">Ruby</a></li>
|
105
|
-
<li><a target="_new" href="http://www.blogger.com">Blogger</a></li>
|
106
|
-
<li><a target="_new" href="http://www.w3c.org">W3 Consortium</a></li>
|
107
|
-
</ul>
|
108
|
-
|
109
|
-
<br />
|
110
|
-
<ul class="rss">
|
111
|
-
<li><a href="xml/list_entry">Latest entries</a></li>
|
112
|
-
<li><a href="xml/list_comment">Latest comments</a></li>
|
113
|
-
</ul>
|
114
|
-
|
115
|
-
<br />
|
116
|
-
<p>
|
117
|
-
powered by:<br />
|
118
|
-
<div style="padding: 5px; background: #fff; text-align: center; border: 1px solid #ccc">
|
119
|
-
<a href="http://www.navel.gr/nitro"><img src="m/nitro.gif" style="border: none" /></a>
|
120
|
-
</div>
|
121
|
-
<br />
|
122
|
-
skin from <a href="http://www.blogger.com">Blogger.com</a>
|
123
|
-
</p>
|
124
|
-
</div>
|
125
|
-
|
126
|
-
<div class="clear">.</div>
|
127
|
-
|
128
|
-
#{t_footer}
|
129
|
-
</div>
|
130
|
-
|
131
|
-
#{t_rendering_errors}
|
132
|
-
|
133
|
-
</body>
|
134
|
-
</html>
|
135
|
-
}
|
136
|
-
end
|
137
|
-
|
138
|
-
end
|