nitro 0.17.0 → 0.18.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (161) hide show
  1. data/CHANGELOG +124 -0
  2. data/README +2 -2
  3. data/Rakefile +4 -12
  4. data/bin/nitro +1 -1
  5. data/bin/nitrogen +47 -31
  6. data/doc/AUTHORS +3 -3
  7. data/doc/RELEASES +50 -1
  8. data/examples/README +7 -0
  9. data/lib/nitro.rb +5 -4
  10. data/lib/nitro/{adapters → adapter}/cgi.rb +2 -4
  11. data/lib/nitro/{adapters → adapter}/fastcgi.rb +1 -1
  12. data/lib/nitro/{adapters → adapter}/webrick.rb +5 -10
  13. data/lib/nitro/buffering.rb +6 -0
  14. data/lib/nitro/{builders → builder}/atom.rb +1 -5
  15. data/lib/nitro/{builders → builder}/form.rb +1 -5
  16. data/lib/nitro/{builders → builder}/rss.rb +3 -1
  17. data/lib/nitro/{builders → builder}/table.rb +2 -4
  18. data/lib/nitro/{builders → builder}/xhtml.rb +3 -5
  19. data/lib/nitro/{builders → builder}/xml.rb +2 -4
  20. data/lib/nitro/caching.rb +6 -4
  21. data/lib/nitro/caching/output.rb +18 -11
  22. data/lib/nitro/context.rb +3 -1
  23. data/lib/nitro/controller.rb +29 -18
  24. data/lib/nitro/dispatcher.rb +2 -4
  25. data/lib/nitro/element.rb +2 -0
  26. data/lib/nitro/environment.rb +2 -4
  27. data/lib/nitro/errors.rb +69 -0
  28. data/lib/nitro/mail.rb +2 -4
  29. data/lib/nitro/markup.rb +20 -3
  30. data/lib/nitro/output.rb +5 -9
  31. data/lib/nitro/part.rb +2 -3
  32. data/lib/nitro/render.rb +49 -30
  33. data/lib/nitro/request.rb +2 -1
  34. data/lib/nitro/runner.rb +23 -12
  35. data/lib/nitro/scaffold.rb +5 -3
  36. data/lib/nitro/service.rb +22 -0
  37. data/lib/nitro/service/xmlrpc.rb +42 -0
  38. data/lib/nitro/session.rb +2 -4
  39. data/lib/nitro/template.rb +8 -10
  40. data/lib/nitro/testing.rb +0 -4
  41. data/proto/public/error.xhtml +27 -2
  42. data/test/nitro/{adapters → adapter}/raw_post1.bin +0 -0
  43. data/test/nitro/{adapters → adapter}/tc_cgi.rb +1 -1
  44. data/test/nitro/{adapters → adapter}/tc_webrick.rb +1 -1
  45. data/test/nitro/{builders → builder}/tc_atom.rb +1 -1
  46. data/test/nitro/{builders → builder}/tc_rss.rb +1 -1
  47. data/test/nitro/{builders → builder}/tc_table.rb +1 -1
  48. data/test/nitro/{builders → builder}/tc_xhtml.rb +1 -1
  49. data/test/nitro/{builders → builder}/tc_xml.rb +1 -1
  50. data/test/nitro/tc_caching.rb +18 -0
  51. data/test/nitro/tc_controller.rb +1 -1
  52. data/test/nitro/tc_mail.rb +3 -1
  53. metadata +33 -168
  54. data/examples/README.windows +0 -9
  55. data/examples/ajax/controller.rb +0 -21
  56. data/examples/ajax/public/index.xhtml +0 -72
  57. data/examples/ajax/public/js/ajax.js +0 -64
  58. data/examples/ajax/run.rb +0 -14
  59. data/examples/blog/README +0 -70
  60. data/examples/blog/conf/apache.conf +0 -30
  61. data/examples/blog/conf/apache.conf.new +0 -53
  62. data/examples/blog/conf/lhttpd.conf +0 -79
  63. data/examples/blog/conf/locales/de.yml +0 -4
  64. data/examples/blog/conf/locales/en.yml +0 -4
  65. data/examples/blog/log/README +0 -3
  66. data/examples/blog/log/apache.error_log +0 -6647
  67. data/examples/blog/log/rewrite_log +0 -161
  68. data/examples/blog/public/base.xsl +0 -153
  69. data/examples/blog/public/fcgi.rb +0 -5
  70. data/examples/blog/public/m/bubbles.gif +0 -0
  71. data/examples/blog/public/m/comments_curve.gif +0 -0
  72. data/examples/blog/public/m/down.gif +0 -0
  73. data/examples/blog/public/m/footer_bg.gif +0 -0
  74. data/examples/blog/public/m/garrow.gif +0 -0
  75. data/examples/blog/public/m/gbull.gif +0 -0
  76. data/examples/blog/public/m/grbull.gif +0 -0
  77. data/examples/blog/public/m/h1_bg.gif +0 -0
  78. data/examples/blog/public/m/header_bg.gif +0 -0
  79. data/examples/blog/public/m/nitro.gif +0 -0
  80. data/examples/blog/public/m/obull.gif +0 -0
  81. data/examples/blog/public/m/page_bg.gif +0 -0
  82. data/examples/blog/public/m/rss.gif +0 -0
  83. data/examples/blog/public/m/side_title_bg.gif +0 -0
  84. data/examples/blog/public/m/sidebar_bg.gif +0 -0
  85. data/examples/blog/public/style.css +0 -305
  86. data/examples/blog/run.rb +0 -43
  87. data/examples/blog/src/blog.rb +0 -21
  88. data/examples/blog/src/controller.rb +0 -151
  89. data/examples/blog/src/mailer.rb +0 -23
  90. data/examples/blog/src/models/blog.rb +0 -33
  91. data/examples/blog/src/models/content.rb +0 -18
  92. data/examples/blog/src/views/blog_entry_email.xhtml +0 -16
  93. data/examples/blog/src/views/comments.xhtml +0 -36
  94. data/examples/blog/src/views/entry_form.xhtml +0 -22
  95. data/examples/blog/src/views/error.xhtml +0 -56
  96. data/examples/blog/src/views/index.xhtml +0 -49
  97. data/examples/blog/src/views/login.xhtml +0 -26
  98. data/examples/blog/src/views/recent_posts.xhtml +0 -14
  99. data/examples/blog/src/views/view_entry.xhtml +0 -37
  100. data/examples/blog/src/views/view_entry.xml +0 -12
  101. data/examples/blog/src/xsl/base.xsl +0 -160
  102. data/examples/blog/src/xsl/style.xsl +0 -143
  103. data/examples/blog/test/tc_blog.rb +0 -43
  104. data/examples/flash/log/README +0 -3
  105. data/examples/flash/root/index.xhtml +0 -16
  106. data/examples/flash/root/show_inline_text.xhtml +0 -17
  107. data/examples/flash/run.rb +0 -7
  108. data/examples/no_xsl_blog/README +0 -24
  109. data/examples/no_xsl_blog/conf/apache.conf +0 -30
  110. data/examples/no_xsl_blog/conf/lhttpd.conf +0 -79
  111. data/examples/no_xsl_blog/conf/locales/de.yml +0 -4
  112. data/examples/no_xsl_blog/conf/locales/en.yml +0 -4
  113. data/examples/no_xsl_blog/lib/blog.rb +0 -16
  114. data/examples/no_xsl_blog/lib/blog/controller.rb +0 -116
  115. data/examples/no_xsl_blog/lib/blog/model.rb +0 -35
  116. data/examples/no_xsl_blog/lib/blog/template.rb +0 -138
  117. data/examples/no_xsl_blog/lib/content.rb +0 -47
  118. data/examples/no_xsl_blog/log/README +0 -3
  119. data/examples/no_xsl_blog/log/apache.error_log +0 -473
  120. data/examples/no_xsl_blog/public/comments.xhtml +0 -36
  121. data/examples/no_xsl_blog/public/entry_form.xhtml +0 -22
  122. data/examples/no_xsl_blog/public/fcgi.rb +0 -5
  123. data/examples/no_xsl_blog/public/index.xhtml +0 -39
  124. data/examples/no_xsl_blog/public/login.xhtml +0 -21
  125. data/examples/no_xsl_blog/public/m/bubbles.gif +0 -0
  126. data/examples/no_xsl_blog/public/m/comments_curve.gif +0 -0
  127. data/examples/no_xsl_blog/public/m/down.gif +0 -0
  128. data/examples/no_xsl_blog/public/m/footer_bg.gif +0 -0
  129. data/examples/no_xsl_blog/public/m/garrow.gif +0 -0
  130. data/examples/no_xsl_blog/public/m/gbull.gif +0 -0
  131. data/examples/no_xsl_blog/public/m/grbull.gif +0 -0
  132. data/examples/no_xsl_blog/public/m/h1_bg.gif +0 -0
  133. data/examples/no_xsl_blog/public/m/header_bg.gif +0 -0
  134. data/examples/no_xsl_blog/public/m/nitro.gif +0 -0
  135. data/examples/no_xsl_blog/public/m/obull.gif +0 -0
  136. data/examples/no_xsl_blog/public/m/page_bg.gif +0 -0
  137. data/examples/no_xsl_blog/public/m/rss.gif +0 -0
  138. data/examples/no_xsl_blog/public/m/side_title_bg.gif +0 -0
  139. data/examples/no_xsl_blog/public/m/sidebar_bg.gif +0 -0
  140. data/examples/no_xsl_blog/public/recent_posts.xhtml +0 -14
  141. data/examples/no_xsl_blog/public/style.css +0 -299
  142. data/examples/no_xsl_blog/public/view_entry.xhtml +0 -25
  143. data/examples/no_xsl_blog/public/view_entry.xml +0 -12
  144. data/examples/no_xsl_blog/run.rb +0 -35
  145. data/examples/tiny/README +0 -14
  146. data/examples/tiny/conf/apache.conf +0 -30
  147. data/examples/tiny/conf/lhttpd.conf +0 -79
  148. data/examples/tiny/log/README +0 -3
  149. data/examples/tiny/log/apache.error_log +0 -154
  150. data/examples/tiny/public/deep/dir/hello.xhtml +0 -3
  151. data/examples/tiny/public/fcgi.rb +0 -5
  152. data/examples/tiny/public/include.xhtml +0 -3
  153. data/examples/tiny/public/index.xhtml +0 -55
  154. data/examples/tiny/public/nitro.png +0 -0
  155. data/examples/tiny/public/upload.xhtml +0 -21
  156. data/examples/tiny/run.rb +0 -7
  157. data/examples/wee_style/README +0 -10
  158. data/examples/wee_style/run.rb +0 -50
  159. data/examples/why_wiki/README +0 -5
  160. data/examples/why_wiki/run.rb +0 -59
  161. data/proto/public/js/ajax.js +0 -63
data/examples/tiny/run.rb DELETED
@@ -1,7 +0,0 @@
1
- # * George Moschovitis <gm@navel.gr>
2
- # (c) 2004-2005 Navel, all rights reserved.
3
- # $Id: run.rb 1 2005-04-11 11:04:30Z gmosx $
4
-
5
- require 'nitro'
6
-
7
- Nitro.run(:host => '127.0.0.1', :port => 9999)
@@ -1,10 +0,0 @@
1
- = Wee-style Example
2
-
3
- This is a simple example that demonstrates that writing
4
- Wee-style 'self-contained' web applications is easy.
5
-
6
- To run the example just issue
7
-
8
- $ ruby wee.rb
9
-
10
- in the command line to start the application.
@@ -1,50 +0,0 @@
1
- # * George Moschovitis <gm@navel.gr>
2
- # (c) 2004-2005 Navel, all rights reserved.
3
- # $Id: run.rb 18 2005-04-15 09:17:08Z gmosx $
4
-
5
- require 'nitro'
6
- require 'nitro/adapters/webrick'
7
-
8
- include Nitro
9
-
10
- class Wee < Controller
11
-
12
- def index
13
- counter = session[:counter] || 0
14
-
15
- o.html {
16
- o.comment 'This is a comment!'
17
- o.h1 'Hello world'
18
- o.text 'This is '
19
- o.b 'BOLD'
20
- o.br.br
21
- o.p 'Here comes some text'
22
- o.br.br
23
- o.p "Here is the counter: #{counter}"
24
- o.p {
25
- o.a('Increase', :href => :inc_counter).text(' the counter.')
26
- }
27
- o.p '<a href="reset_counter">Reset</a> the counter.'
28
- o.hr
29
- o.text 'Powered by Nitro.'
30
- }
31
- end
32
-
33
- def inc_counter
34
- session[:counter] ||= 0
35
- session[:counter] += 1
36
- end
37
-
38
- def reset_counter
39
- session[:counter] = 0
40
- end
41
-
42
- end
43
-
44
- conf = {
45
- :host => '127.0.0.1',
46
- :port => 9999,
47
- :dispatcher => Dispatcher.new(Wee)
48
- }
49
-
50
- Webrick.start(conf)
@@ -1,5 +0,0 @@
1
- = Why's wiki
2
-
3
- Original example from Why's excellent Blog,
4
- http://redhanded.hobix.com
5
-
@@ -1,59 +0,0 @@
1
- # * George Moschovitis <gm@navel.gr>
2
- # $Id: run.rb 18 2005-04-15 09:17:08Z gmosx $
3
-
4
- require 'cgi'
5
- require 'redcloth'
6
- require 'yaml/store'
7
-
8
- require 'nitro'
9
- require 'nitro/adapters/webrick'
10
-
11
- include Nitro
12
-
13
- # A simple wiki. A straight conversion of the redhanded.hobix.com
14
- # example. Original code by why the lucky stiff.
15
- # This is just a cool example, not the preffered way to write
16
- # Nitro applications.
17
-
18
- WIKI = YAML::Store.new('wiki.yml')
19
-
20
- class Wiki < Controller
21
-
22
- def index
23
- @p = 'Home'
24
- show
25
- end
26
-
27
- def show
28
- o.h1(@p)
29
- o.a('Home', :href => '/') unless @p == 'Home'
30
- WIKI.transaction do
31
- if WIKI[@p]
32
- o << RedCloth.new(WIKI[@p]).to_html.gsub(/([A-Z]\w+){2}/) { "<a href='/show/#$&'>#$&</a>" }
33
- o.a 'Edit', :href => "/edit/#@p"
34
- else
35
- o.p("No page #{p}. ").a('Create?', :href => "/edit/#@p")
36
- end
37
- end
38
- end
39
- action :show, :route => /show\/(.*)/, 'p' => String
40
-
41
- def edit
42
- if c = request['c']
43
- WIKI.transaction { WIKI[@p] = c }
44
- redirect "/show/#@p"
45
- end
46
- WIKI.transaction do
47
- o.h1 "Editing #@p"
48
- o.a('Show', :href => "/show/#@p").br.br
49
- o.form(:method => 'post') {
50
- o.input :type => 'hidden', :name => 'p', :value => @p
51
- o.textarea WIKI[@p].to_s, :name => 'c', :style => 'width: 90%; height: 200px'
52
- o.br.br.submit
53
- }
54
- end
55
- end
56
- action :edit, :route => /edit\/(.*)/, 'p' => String
57
- end
58
-
59
- Webrick.start(:dispatcher => Dispatcher.new(Wiki))
@@ -1,63 +0,0 @@
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
- }