nitro 0.14.0 → 0.15.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. data/CHANGELOG +117 -0
  2. data/INSTALL +4 -0
  3. data/README +30 -31
  4. data/Rakefile +2 -2
  5. data/bin/nitro +10 -1
  6. data/bin/{new_app.rb → nitrogen} +12 -22
  7. data/doc/AUTHORS +4 -13
  8. data/doc/RELEASES +98 -0
  9. data/examples/ajax/run.rb +1 -3
  10. data/examples/blog/cache/entriesadmin +1 -1
  11. data/examples/blog/conf/locales/de.yml +4 -0
  12. data/examples/blog/conf/locales/en.yml +4 -0
  13. data/examples/blog/public/fcgi.rb +2 -3
  14. data/examples/blog/run.rb +10 -5
  15. data/examples/blog/src/controller.rb +21 -10
  16. data/examples/blog/src/mailer.rb +1 -1
  17. data/examples/blog/src/views/index.xhtml +2 -2
  18. data/examples/blog/src/xsl/style.xsl +6 -1
  19. data/examples/flash/run.rb +1 -3
  20. data/examples/no_xsl_blog/conf/locales/de.yml +4 -0
  21. data/examples/no_xsl_blog/conf/locales/en.yml +4 -0
  22. data/examples/no_xsl_blog/lib/blog/controller.rb +10 -0
  23. data/examples/no_xsl_blog/lib/blog/template.rb +4 -0
  24. data/examples/no_xsl_blog/public/fcgi.rb +2 -1
  25. data/examples/no_xsl_blog/public/index.xhtml +1 -1
  26. data/examples/no_xsl_blog/run.rb +8 -4
  27. data/examples/tiny/public/deep/dir/hello.xhtml +1 -0
  28. data/examples/tiny/public/fcgi.rb +2 -1
  29. data/examples/tiny/public/index.xhtml +5 -2
  30. data/examples/tiny/run.rb +1 -3
  31. data/examples/wee_style/run.rb +1 -3
  32. data/examples/why_wiki/run.rb +1 -3
  33. data/lib/nitro.rb +5 -2
  34. data/lib/nitro/builders/form.rb +8 -3
  35. data/lib/nitro/caching/stores.rb +3 -3
  36. data/lib/nitro/controller.rb +26 -6
  37. data/lib/nitro/dispatcher.rb +21 -13
  38. data/lib/nitro/environment.rb +23 -0
  39. data/lib/nitro/filters.rb +10 -8
  40. data/lib/nitro/localization.rb +127 -13
  41. data/lib/nitro/part.rb +24 -0
  42. data/lib/nitro/render.rb +19 -15
  43. data/lib/nitro/runner.rb +2 -1
  44. data/lib/nitro/scaffold.rb +69 -17
  45. data/lib/nitro/shaders.rb +54 -83
  46. data/lib/nitro/template.rb +7 -1
  47. data/proto/README +11 -0
  48. data/proto/conf/apache.conf +51 -0
  49. data/proto/conf/lhttpd.conf +107 -0
  50. data/proto/public/error.xhtml +56 -0
  51. data/proto/public/fcgi.rb +5 -0
  52. data/proto/public/index.xhtml +83 -0
  53. data/proto/public/js/ajax.js +63 -0
  54. data/proto/public/media/nitro.png +0 -0
  55. data/proto/run.rb +11 -0
  56. data/test/nitro/tc_controller.rb +1 -4
  57. data/test/nitro/tc_dispatcher.rb +8 -0
  58. data/test/nitro/tc_localization.rb +49 -0
  59. metadata +34 -6
  60. data/bin/new_form.rb +0 -54
@@ -0,0 +1,56 @@
1
+ <html>
2
+ <head>
3
+ <title>Error</title>
4
+ <style>
5
+ .path {
6
+ padding: 5px;
7
+ font-size: 140%;
8
+ background: #ddd;
9
+ }
10
+ .error {
11
+ padding: 5px;
12
+ padding-top: 15px;
13
+ font-size: 140%;
14
+ color: #f00;
15
+ }
16
+ .load {
17
+ padding: 5px;
18
+ color: #555;
19
+ }
20
+ h2 {
21
+ padding-left: 5px;
22
+ background: #eee;
23
+ }
24
+ </style>
25
+ </head>
26
+ <body>
27
+ <h1>Error</h1>
28
+
29
+ <?r for error, path in @context.rendering_errors ?>
30
+ <div class="path"><strong>Path:</strong> #{path}</div>
31
+ <div class="error"><strong>#{error.class.name}:</strong> #{N::Markup.expand(error.to_s)}</div>
32
+ <div class="load">Click here to <strong><a href="#{request.uri}">reload</a></strong>.</div>
33
+ <div class="load">Click here to go to the <strong><a href="#{request.referer}">referer</a></strong>.</div>
34
+ <h2><a href="#" onclick="document.getElementById('trace').style.display = 'block'; return false">Stack Trace</a></h2>
35
+ <p id="trace" style="display: none">#{error.backtrace.join('<br />')}</p>
36
+ <?r end ?>
37
+
38
+ <h2><a href="#" onclick="document.getElementById('request').style.display = 'block'; return false">Request</a></h2>
39
+ <div id="request" style="display: none">
40
+ <p><strong>Parameters:</strong> #{request.params.reject{ |k,v| k == :__RELOADED__ }.inspect}</p>
41
+ <p><strong>Cookies:</strong> #{request.cookies.inspect}</p>
42
+ <p><strong>Headers:</strong><br />#{request.headers.collect { |k, v| "#{k} => #{v}" }.join('<br />')}</p>
43
+ </div>
44
+
45
+ <h2><a href="#" onclick="document.getElementById('response').style.display = 'block'; return false">Response</a></h2>
46
+ <div id="response" style="display: none">
47
+ <p><strong>Headers:</strong> #{request.response_headers.inspect}</p>
48
+ <p><strong>Cookies:</strong> #{request.response_cookies.inspect}</p>
49
+ </div>
50
+
51
+ <h2><a href="#" onclick="document.getElementById('session').style.display = 'block'; return false">Session</a></h2>
52
+ <div id="session" style="display: none">
53
+ <p><strong>Values:</strong> #{session.inspect}</p>
54
+ </div>
55
+ </body>
56
+ </html>
@@ -0,0 +1,5 @@
1
+ #!/usr/local/bin/ruby
2
+
3
+ ENV['NITRO_INVOKE'] = 'fcgi_proc'
4
+ $0 = File.join(File.dirname(__FILE__), '..', 'run.rb')
5
+ require $0
@@ -0,0 +1,83 @@
1
+ <?xml version="1.0"?>
2
+
3
+ <html>
4
+ <head>
5
+ <title>Nitro, Feel the magic!</title>
6
+ <style>
7
+ body { margin: 10px; background-color: #fff; color: #333; }
8
+
9
+ body, p, ol, ul, td {
10
+ font-family: verdana, arial, helvetica, sans-serif;
11
+ font-size: 12px;
12
+ line-height: 18px;
13
+ }
14
+
15
+ h1 { margin-top: 15px; margin-bottom: 45px; }
16
+
17
+ li {
18
+ margin-bottom: 7px;
19
+ }
20
+
21
+ pre {
22
+ background-color: #eee;
23
+ padding: 10px;
24
+ font-size: 11px;
25
+ }
26
+
27
+ a { color: #000; }
28
+ a:visited { color: #666; }
29
+ a:hover { color: #fff; background-color:#000; }
30
+
31
+ img { border: none; }
32
+ </style>
33
+ </head>
34
+ <body>
35
+
36
+ <a href="http://nitro.rubyforge.org" target="_blank"><img src="media/nitro.png" /></a>
37
+
38
+ <h1>You have successfully installed Nitro!</h1>
39
+
40
+ <p><b>Before you move on</b>, verify that the following conditions have been met:</p>
41
+
42
+ <ol>
43
+ <li>The log directory and the empty log files must be writable to the web server (<code>chmod -R 666 log/*</code>).
44
+ <li>
45
+ The shebang line in the ctl file must reference your Ruby installation. <br/>
46
+ You might need to change it to <code>#!/usr/bin/env ruby</code> or point directly at the installation.
47
+ </li>
48
+ </ol>
49
+
50
+ <p>Have a look at the <b>examples</b>:</p>
51
+
52
+ <ol>
53
+ <li><b>examples/blog</b>: A simple Blog, featuring a nice XSLT based template.</li>
54
+ <li><b>examples/no_xsl_blog</b>: The same example without using XSLT (easier to setup under Windows).</li>
55
+ <li><b>examples/why_wiki</b>: A conversion of why_'s wiki.</li>
56
+ <li><b>examples/wee_style</b>: A Wee-style (ruby code only) example.</li>
57
+ <li><b>examples/ajax</b>: Implement Google suggest-style functionality using ajax techniques.</li>
58
+ <li><b>examples/tiny</b>: A small example to verify your installation.</li>
59
+ </ol>
60
+
61
+ <p>Here is <b>what do next</b>:</p>
62
+
63
+ <ol>
64
+ <li>Add your xhtml files in the 'public' directory. Those files are
65
+ automagically converted to controller actions by Nitro
66
+ </li>
67
+ <li>Place additional media files, css, or xsl files in the public directory.</li>
68
+ <li>Create your models and controllers.</li>
69
+ <li>Develop your application utilizing Nitro's powerful features.</li>
70
+ </ol>
71
+
72
+ <br />
73
+
74
+ <p>
75
+ <b>Having problems getting up and running?</b><br />
76
+ First try debugging it yourself by looking at the log files.
77
+ If you get stuck, post your problem to the <a href="http://rubyforge.org/mailman/listinfo/nitro-general">Nitro Mailing
78
+ List</a> at <a href="http://www.rubyforge.com">Rubyforge</a>.
79
+ </p>
80
+
81
+ <br /><br />
82
+ </body>
83
+ </html>
@@ -0,0 +1,63 @@
1
+
2
+ function ajax_get(url) {
3
+ req = xml_http_request_object();
4
+ req.open("GET", url, false);
5
+ req.send(null);
6
+ return req.responseText;
7
+ }
8
+
9
+ function ajax_async_get(url, callback) {
10
+ req = xml_http_request_object();
11
+ req.open("GET", url, true);
12
+
13
+ req.onreadystatechange = function() {
14
+ if (req.readyState == 4 && req.status == 200) {
15
+ return callback(req.responseText);
16
+ }
17
+ }
18
+
19
+ req.send(null);
20
+ }
21
+
22
+ function ajax_post(url) {
23
+ req = xml_http_request_object();
24
+ req.open("POST", url, false);
25
+ req.send(null);
26
+ return req.responseText;
27
+ }
28
+
29
+ function ajax_async_post(url, callback) {
30
+ req = xml_http_request_object();
31
+ req.open("POST", url, true);
32
+
33
+ req.onreadystatechange = function() {
34
+ if (req.readyState == 4 && req.status == 200) {
35
+ return callback(req.responseText);
36
+ }
37
+ }
38
+
39
+ req.send(null);
40
+ }
41
+
42
+ function xml_http_request_object() {
43
+ var req = false;
44
+ try {
45
+ req = new ActiveXObject("Msxml2.XMLHTTP");
46
+ } catch (e) {
47
+ try {
48
+ req = new ActiveXObject("Microsoft.XMLHTTP");
49
+ } catch (e) {
50
+ try {
51
+ req = ActiveXObject("Msxml2.XMLHTTP.4.0");
52
+ } catch (e) {
53
+ req = false;
54
+ }
55
+ }
56
+ }
57
+
58
+ if (!req && typeof XMLHttpRequest!='undefined') {
59
+ req = new XMLHttpRequest();
60
+ }
61
+
62
+ return req;
63
+ }
Binary file
data/proto/run.rb ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # * George Moschovitis <gm@navel.gr>
4
+ # (c) 2004-2005 Navel, all rights reserved.
5
+ # $Id: run.rb 331 2005-03-28 11:12:43Z gmosx $
6
+
7
+ Dir.chdir File.dirname(__FILE__)
8
+
9
+ require 'nitro'
10
+
11
+ N::Runner.run(:host => '127.0.0.1', :port => 9999)
@@ -13,10 +13,7 @@ class TC_Controller < Test::Unit::TestCase # :nodoc: all
13
13
  class Blog2Controller < Controller
14
14
  attr_reader :aflag, :tflag
15
15
 
16
- def initialize(context)
17
- super
18
- @template_root = 'test/public/blog'
19
- end
16
+ @template_root = 'test/public/blog'
20
17
 
21
18
  def list
22
19
  @aflag = true
@@ -38,6 +38,14 @@ class TC_Dispatcher < Test::Unit::TestCase # :nodoc: all
38
38
  assert_equal BlogController, klass
39
39
  assert_equal '__xhtml__list', action
40
40
 
41
+ klass, action = @d.dispatch('/blog/another/very_litle/list')
42
+ assert_equal BlogController, klass
43
+ assert_equal '__xhtml__another__very_litle__list', action
44
+
45
+ klass, action = @d.dispatch('/another/litle/list')
46
+ assert_equal MainController, klass
47
+ assert_equal '__xhtml__another__litle__list', action
48
+
41
49
  klass, action, ctype = @d.dispatch('/blog')
42
50
  assert_equal BlogController, klass
43
51
  assert_equal '__xhtml__index', action
@@ -0,0 +1,49 @@
1
+ $:.unshift File.join(File.dirname(__FILE__), '..', '..', 'lib')
2
+
3
+ require 'test/unit'
4
+ require 'ostruct'
5
+
6
+ require 'nitro/localization'
7
+
8
+ class TestCaseLocalization < Test::Unit::TestCase # :nodoc: all
9
+ include N
10
+
11
+ def setup
12
+ locale_en = {
13
+ 'See you' => 'See you',
14
+ :long_paragraph => 'The best new books, up to 30% reduced price',
15
+ :price => 'Price: %d %s',
16
+ :proc_price => proc { |value, cur| "Price: #{value} #{cur}" }
17
+ }
18
+
19
+ locale_de = {
20
+ 'See you' => 'Auf wieder sehen',
21
+ :long_paragraph => 'Die besten neuer buecher, bis zu 30% reduziert',
22
+ :price => 'Preis: %d %s',
23
+ :proc_price => proc { |value, cur| "Preis: #{value} #{cur}" }
24
+ }
25
+
26
+ Localization.add(
27
+ :en => locale_en,
28
+ :de => locale_de
29
+ )
30
+ end
31
+
32
+ def test_all
33
+ lc = Localization.get
34
+ assert_equal 'See you', lc['See you']
35
+ assert_equal 'The best new books, up to 30% reduced price', lc[:long_paragraph]
36
+
37
+ lc = Localization.get(:en)
38
+ assert_equal 'See you', lc['See you']
39
+ assert_equal 'The best new books, up to 30% reduced price', lc[:long_paragraph]
40
+ assert_equal 'Price: 100 euro', lc[:price, 100, 'euro']
41
+ assert_equal 'Price: 100 euro', lc[:proc_price, 100, 'euro']
42
+
43
+ lc = Localization.get(:de)
44
+ assert_equal 'Auf wieder sehen', lc['See you']
45
+ assert_equal 'Die besten neuer buecher, bis zu 30% reduziert', lc[:long_paragraph]
46
+ assert_equal 'Preis: 100 euro', lc.translate(:price, 100, 'euro')
47
+ assert_equal 'Preis: 100 euro', lc[:proc_price, 100, 'euro']
48
+ end
49
+ end
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.10
3
3
  specification_version: 1
4
4
  name: nitro
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.14.0
7
- date: 2005-03-28
6
+ version: 0.15.0
7
+ date: 2005-04-04
8
8
  summary: Nitro Web Engine
9
9
  require_paths:
10
10
  - lib
@@ -34,8 +34,7 @@ files:
34
34
  - README
35
35
  - install.rb
36
36
  - bin/nitro
37
- - bin/new_app.rb
38
- - bin/new_form.rb
37
+ - bin/nitrogen
39
38
  - benchmark/tiny-lhttpd-n-200-c-5.txt
40
39
  - benchmark/simple-webrick-n-200.txt
41
40
  - benchmark/static-webrick-n-200.txt
@@ -65,8 +64,11 @@ files:
65
64
  - examples/no_xsl_blog/README
66
65
  - examples/no_xsl_blog/log/apache.error_log
67
66
  - examples/no_xsl_blog/log/README
67
+ - examples/no_xsl_blog/conf/locales
68
68
  - examples/no_xsl_blog/conf/apache.conf
69
69
  - examples/no_xsl_blog/conf/lhttpd.conf
70
+ - examples/no_xsl_blog/conf/locales/de.yml
71
+ - examples/no_xsl_blog/conf/locales/en.yml
70
72
  - examples/no_xsl_blog/public/login.xhtml
71
73
  - examples/no_xsl_blog/public/index.xhtml
72
74
  - examples/no_xsl_blog/public/style.css
@@ -121,6 +123,9 @@ files:
121
123
  - examples/tiny/public/upload.xhtml
122
124
  - examples/tiny/public/fcgi.rb
123
125
  - examples/tiny/public/include.xhtml
126
+ - examples/tiny/public/deep
127
+ - examples/tiny/public/deep/dir
128
+ - examples/tiny/public/deep/dir/hello.xhtml
124
129
  - examples/wee_style/run.rb
125
130
  - examples/wee_style/README
126
131
  - examples/blog/log
@@ -133,9 +138,12 @@ files:
133
138
  - examples/blog/log/apache.error_log
134
139
  - examples/blog/log/rewrite_log
135
140
  - examples/blog/log/README
141
+ - examples/blog/conf/locales
136
142
  - examples/blog/conf/apache.conf
137
143
  - examples/blog/conf/lhttpd.conf
138
144
  - examples/blog/conf/apache.conf.new
145
+ - examples/blog/conf/locales/de.yml
146
+ - examples/blog/conf/locales/en.yml
139
147
  - examples/blog/cache/entriesadmin
140
148
  - examples/blog/public/style.css
141
149
  - examples/blog/public/m
@@ -186,6 +194,21 @@ files:
186
194
  - doc/architecture.txt
187
195
  - doc/CHANGELOG.2
188
196
  - doc/bugs.txt
197
+ - proto/log
198
+ - proto/conf
199
+ - proto/doc
200
+ - proto/public
201
+ - proto/run.rb
202
+ - proto/README
203
+ - proto/conf/apache.conf
204
+ - proto/conf/lhttpd.conf
205
+ - proto/public/error.xhtml
206
+ - proto/public/index.xhtml
207
+ - proto/public/fcgi.rb
208
+ - proto/public/js
209
+ - proto/public/media
210
+ - proto/public/js/ajax.js
211
+ - proto/public/media/nitro.png
189
212
  - lib/nitro
190
213
  - lib/nitro.rb
191
214
  - lib/nitro/caching.rb
@@ -212,12 +235,15 @@ files:
212
235
  - lib/nitro/response.rb
213
236
  - lib/nitro/cluster.rb
214
237
  - lib/nitro/mail.rb
238
+ - lib/nitro/shaders
215
239
  - lib/nitro/controller.rb
216
240
  - lib/nitro/conf.rb
217
241
  - lib/nitro/dispatcher.rb
218
242
  - lib/nitro/request.rb
219
243
  - lib/nitro/filters
244
+ - lib/nitro/part.rb
220
245
  - lib/nitro/component.rb
246
+ - lib/nitro/environment.rb
221
247
  - lib/nitro/markup.rb
222
248
  - lib/nitro/filters.rb
223
249
  - lib/nitro/caching/invalidation.rb
@@ -253,6 +279,7 @@ files:
253
279
  - test/nitro/tc_context.rb
254
280
  - test/nitro/tc_filters.rb
255
281
  - test/nitro/tc_dispatcher.rb
282
+ - test/nitro/tc_localization.rb
256
283
  - test/nitro/adapters/tc_webrick.rb
257
284
  - test/nitro/adapters/tc_cgi.rb
258
285
  - test/nitro/adapters/raw_post1.bin
@@ -280,6 +307,7 @@ extra_rdoc_files:
280
307
  - README
281
308
  executables:
282
309
  - nitro
310
+ - nitrogen
283
311
  extensions: []
284
312
  requirements: []
285
313
  dependencies:
@@ -291,7 +319,7 @@ dependencies:
291
319
  -
292
320
  - "="
293
321
  - !ruby/object:Gem::Version
294
- version: 0.14.0
322
+ version: 0.15.0
295
323
  version:
296
324
  - !ruby/object:Gem::Dependency
297
325
  name: og
@@ -301,7 +329,7 @@ dependencies:
301
329
  -
302
330
  - "="
303
331
  - !ruby/object:Gem::Version
304
- version: 0.14.0
332
+ version: 0.15.0
305
333
  version:
306
334
  - !ruby/object:Gem::Dependency
307
335
  name: ruby-breakpoint
data/bin/new_form.rb DELETED
@@ -1,54 +0,0 @@
1
- #! /usr/bin/env ruby
2
-
3
- # = New Form Wizzard
4
- #
5
- # Leverages the FormBuilder functionality to generate a scaffold
6
- # form for the given managed object
7
- #
8
- # Example usage:
9
- #
10
- # ./new_form.rb N::Article lib/articles.rb [article_form.xhtml]
11
- #
12
- # code:
13
- # * George Moschovitis <gm@navel.gr>
14
- #
15
- # (c) 2004 Navel, all rights reserved.
16
- # $Id: new_app.rb 188 2004-12-10 14:14:17Z gmosx $
17
-
18
- $LOAD_PATH.unshift 'lib'
19
-
20
- require 'glue/property'
21
- require 'glue/inflector'
22
- require 'nitro/builders/form'
23
- require 'og'
24
-
25
- def die(str)
26
- puts str
27
- exit!
28
- end
29
-
30
- if klass_name = ARGV[0] and lib_filename = ARGV[1]
31
-
32
- require lib_filename
33
- klass = nil
34
- eval "klass = #{klass_name}"
35
- dst_dir = File.dirname(lib_filename)
36
- dst_filename = ARGV[3] || File.join(dst_dir, "#{N::Inflector.name(klass_name)}_form.xhtml")
37
-
38
- # p klass, lib_filename, dst_filename
39
-
40
- form = N::FormBuilder.render(klass.new)
41
-
42
- File.open(dst_filename, 'w') do |file|
43
- file.write(form)
44
- end
45
-
46
- else
47
-
48
- puts %{
49
- USAGE:
50
- new_form class_name library_filename [base_filename]
51
- }
52
-
53
- end
54
-