nitro 0.25.0 → 0.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. data/CHANGELOG +531 -1
  2. data/ProjectInfo +29 -5
  3. data/README +1 -1
  4. data/doc/AUTHORS +12 -6
  5. data/doc/RELEASES +114 -0
  6. data/lib/glue/sweeper.rb +71 -0
  7. data/lib/nitro.rb +19 -12
  8. data/lib/nitro/adapter/cgi.rb +4 -0
  9. data/lib/nitro/adapter/webrick.rb +4 -2
  10. data/lib/nitro/caching.rb +1 -0
  11. data/lib/nitro/caching/fragments.rb +7 -1
  12. data/lib/nitro/caching/output.rb +6 -1
  13. data/lib/nitro/caching/stores.rb +13 -1
  14. data/lib/nitro/cgi.rb +9 -1
  15. data/lib/nitro/cgi/request.rb +11 -3
  16. data/lib/nitro/cgi/utils.rb +24 -2
  17. data/lib/nitro/compiler.rb +89 -63
  18. data/lib/nitro/compiler/cleanup.rb +16 -0
  19. data/lib/nitro/compiler/elements.rb +117 -0
  20. data/lib/nitro/compiler/markup.rb +3 -1
  21. data/lib/nitro/compiler/morphing.rb +203 -73
  22. data/lib/nitro/compiler/script_generator.rb +14 -0
  23. data/lib/nitro/compiler/shaders.rb +1 -1
  24. data/lib/nitro/context.rb +5 -6
  25. data/lib/nitro/controller.rb +43 -21
  26. data/lib/nitro/dispatcher.rb +86 -37
  27. data/lib/nitro/element.rb +3 -105
  28. data/lib/nitro/helper/benchmark.rb +3 -0
  29. data/lib/nitro/helper/dojo.rb +0 -0
  30. data/lib/nitro/helper/form.rb +85 -255
  31. data/lib/nitro/helper/form/controls.rb +274 -0
  32. data/lib/nitro/helper/javascript.rb +86 -6
  33. data/lib/nitro/helper/pager.rb +5 -0
  34. data/lib/nitro/helper/prototype.rb +49 -0
  35. data/lib/nitro/helper/scriptaculous.rb +0 -0
  36. data/lib/nitro/helper/xhtml.rb +11 -8
  37. data/lib/nitro/helper/xml.rb +1 -1
  38. data/lib/nitro/routing.rb +8 -1
  39. data/lib/nitro/scaffolding.rb +344 -0
  40. data/lib/nitro/server.rb +5 -1
  41. data/lib/nitro/server/runner.rb +19 -15
  42. data/lib/nitro/session.rb +32 -56
  43. data/lib/nitro/session/drbserver.rb +1 -1
  44. data/lib/nitro/session/file.rb +34 -15
  45. data/lib/nitro/session/memory.rb +13 -4
  46. data/lib/nitro/session/og.rb +56 -0
  47. data/proto/public/js/controls.js +30 -1
  48. data/proto/public/js/dragdrop.js +211 -146
  49. data/proto/public/js/effects.js +261 -399
  50. data/proto/public/js/prototype.js +131 -72
  51. data/proto/public/scaffold/edit.xhtml +10 -3
  52. data/proto/public/scaffold/form.xhtml +1 -7
  53. data/proto/public/scaffold/index.xhtml +20 -0
  54. data/proto/public/scaffold/list.xhtml +15 -8
  55. data/proto/public/scaffold/new.xhtml +10 -3
  56. data/proto/public/scaffold/search.xhtml +28 -0
  57. data/proto/public/scaffold/view.xhtml +8 -0
  58. data/proto/run.rb +93 -1
  59. data/src/part/admin.rb +4 -2
  60. data/src/part/admin/controller.rb +62 -28
  61. data/src/part/admin/skin.rb +8 -8
  62. data/src/part/admin/system.css +135 -0
  63. data/src/part/admin/template/index.xhtml +8 -12
  64. data/test/nitro/caching/tc_stores.rb +17 -0
  65. data/test/nitro/tc_caching.rb +1 -4
  66. data/test/nitro/tc_dispatcher.rb +22 -10
  67. data/test/nitro/tc_element.rb +1 -1
  68. data/test/nitro/tc_session.rb +23 -11
  69. data/test/public/blog/another/very_litle/index.xhtml +1 -0
  70. metadata +29 -15
  71. data/lib/nitro/dispatcher/general.rb +0 -62
  72. data/lib/nitro/dispatcher/nice.rb +0 -57
  73. data/lib/nitro/scaffold.rb +0 -171
  74. data/proto/public/index.xhtml +0 -83
  75. data/proto/public/js/scaffold.js +0 -74
  76. data/proto/public/settings.xhtml +0 -66
@@ -1,57 +0,0 @@
1
- require 'nitro/dispatcher'
2
-
3
- module Nitro
4
-
5
- # Specialize the Dispatcher to handle implicit 'nice' urls.
6
-
7
- class Dispatcher
8
-
9
- # The default dispatching algorithm that handles
10
- # implicit nice urls. Subdirectories are supported.
11
- # Action containing '/' separators look for templates
12
- # in subdirectories. The '/' char is converted to '__'
13
- # to find the actual action.
14
- #
15
- # Returns the dispatcher class, the action name and the
16
- # base url. For the root path, the base url is nil.
17
-
18
- def dispatch(path, context)
19
- path = route(path, context)
20
-
21
- parts = path.split('/')
22
- parts.shift # get rid of the leading '/'.
23
-
24
- if klass = controller_class_for("/#{parts.first}")
25
- base = "/#{parts.shift}"
26
- else
27
- base = nil
28
- klass = controller_class_for(ROOT)
29
- end
30
- =begin
31
- if klass.action_methods.include?(parts.first)
32
- action = parts.shift
33
- else
34
- action = 'index'
35
- end
36
- p '---', action
37
- getc
38
- =end
39
- unless action = parts.shift
40
- action = 'index'
41
- end
42
-
43
- unless parts.empty?
44
- context.headers['QUERY_STRING'] = "#{parts.join(';')};#{context.headers['QUERY_STRING']}"
45
- end
46
-
47
- base = nil if base == ROOT
48
-
49
- return klass, "#{action}_action", base
50
- end
51
- end
52
-
53
- Dispatcher.mode = :nice
54
-
55
- end
56
-
57
- # * George Moschovitis <gm@navel.gr>
@@ -1,171 +0,0 @@
1
- require 'mega/orm_support'
2
-
3
- require 'nitro/compiler'
4
- require 'nitro/helper/form'
5
-
6
- module Nitro
7
-
8
- # The scaffolder adds default actions to a Controller.
9
- #--
10
- # FIXME: handle controller base in generated routes.
11
- # FIXME: better handle templates (check if action exists).
12
- #++
13
-
14
- module Scaffolding
15
-
16
- def self.append_features(base) # :nodoc:
17
- super
18
- base.helper :form
19
- base.extend ClassMethods
20
- end
21
-
22
- def self.class_to_name(klass)
23
- klass.to_s.demodulize.underscore.downcase
24
- end
25
-
26
- def self.class_to_list(klass)
27
- klass.to_s.demodulize.underscore.downcase.plural
28
- end
29
-
30
- def self.compile_scaffold_action(compiler, controller, action, suffix)
31
- unless compiler.template_for_action("#{action}#{suffix}", controller.template_root)
32
- source = File.read(File.join(Nitro.proto_path, 'public', 'scaffold', "#{action}.xhtml"))
33
- template = compiler.transform_template(source)
34
-
35
- yield template
36
-
37
- return %{
38
- def #{action}#{suffix}
39
- #{template}
40
- end
41
- }
42
- end
43
-
44
- return nil
45
- end
46
-
47
- module ClassMethods
48
-
49
- # Enchant the caller with a number of default methods.
50
- # Override the automatically generated methods as needed.
51
-
52
- def scaffold(klass, options = {})
53
- compiler = Compiler.new
54
-
55
- oid = options[:oid] || 'oid'
56
- name = options[:name] || Scaffolding.class_to_name(klass)
57
- list_name = options[:plural_name] || name.plural
58
- suffix = options[:nosuffix] ? nil : "_#{name}"
59
-
60
- # Add methods to the scaffolded class.
61
-
62
- unless klass.instance_methods.include? 'to_href'
63
- klass.send(:define_method, :to_href) do
64
- "#{name}/#{@oid}"
65
- end
66
- end
67
-
68
- unless klass.instance_methods.include? 'to_edit_link'
69
- klass.send(:define_method, :to_edit_link) do |base|
70
- %{<a href="#{base}/#{name}/#{@oid}">#{self}</a>&nbsp;(<a href="#{base}/edit#{suffix}/#{@oid}">edit</a>, <a href="#{base}/delete#{suffix}/#{@oid}">del</a>)}
71
- end
72
- end
73
-
74
- # Add methods to the service.
75
-
76
- code = ''
77
-
78
- code << %{
79
- def new#{suffix}
80
- @#{name} = #{klass}.new
81
- render 'form#{suffix}'
82
- end
83
-
84
- def edit#{suffix}(oid)
85
- @#{name} = #{klass}[oid]
86
- render 'form#{suffix}'
87
- end
88
-
89
- def form#{suffix}
90
- end
91
- }
92
-
93
- code << Scaffolding.compile_scaffold_action(compiler, self, 'form', suffix) do |template|
94
- template.gsub!(/%name%/, "#{name}")
95
- template.gsub!(/%name_plural%/, "#{name.plural}")
96
- end
97
-
98
- code << %{
99
- # TODO: add pager support here!
100
-
101
- def #{name.plural}
102
- @#{list_name} = #{klass}.all
103
- }
104
- =begin
105
- code << Scaffolding.compile_scaffold_action(compiler, self, 'list', suffix) do |template|
106
- template.gsub!(/%name%/, "#{name}")
107
- template.gsub!(/%list_name%/, "#{list_name}")
108
- end
109
- =end
110
- unless compiler.template_for_action(list_name, self.template_root) or
111
- #--
112
- # FIXME: this is a hack fix. to better fix, implemente deferred scaffolding.
113
- #++
114
- compiler.template_for_action(list_name, 'public') or
115
- compiler.template_for_action(list_name, 'src/template') or
116
- compiler.template_for_action(list_name, 'src/view')
117
- source = File.read(File.join(Nitro.proto_path, 'public', 'scaffold', 'list.xhtml'))
118
- template = Compiler.new.transform_template(source)
119
-
120
- template.gsub!(/%name%/, "#{name}")
121
- template.gsub!(/%list_name%/, "#{list_name}")
122
-
123
- code << %{
124
- #{template}
125
- }
126
- end
127
-
128
- code << %{
129
- end
130
-
131
- def #{name}(oid)
132
- @#{name} = #{klass}[oid]
133
- end
134
-
135
- def save#{suffix}
136
- if oid = request['#{oid}']
137
- oid = oid.to_s # in case oid is a StringIO (multipart).
138
- obj = request.fill(#{klass}[oid], :assign_relations => true, :force_boolean => true)
139
- else
140
- obj = request.fill(#{klass}.create, :assign_relations => true)
141
- end
142
- unless obj.valid?
143
- session[:ERRORS] = obj.errors
144
- redirect_to_referer
145
- end
146
- obj.save
147
- redirect '#{name.plural}'
148
- end
149
-
150
- def delete#{suffix}(oid)
151
- #{klass}.delete(oid)
152
- redirect_to_referer
153
- end
154
- }
155
-
156
- if options[:index]
157
- code << %{
158
- alias_action :index, :#{name.plural}
159
- }
160
- end
161
-
162
- class_eval(code)
163
- end
164
-
165
- end
166
-
167
- end
168
-
169
- end
170
-
171
- # * George Moschovitis <gm@navel.gr>
@@ -1,83 +0,0 @@
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>
@@ -1,74 +0,0 @@
1
-
2
- Behaviour.register({
3
- '.naction_remove_hash': function(el) {
4
- el.onclick = function(){
5
- //remove a hash list item
6
- parentEl = el
7
- while(parentEl.tagName != 'LI'){
8
- parentEl = parentEl.parentNode
9
- }
10
- Element.remove(parentEl);
11
- return false;
12
- }
13
- },
14
- '.naction_add_hash': function(el) {
15
- el.onclick = function() {
16
- //add a hash list item
17
- ulEl = $(el.id+'_list');
18
- newkey = $(el.id+'_key').value;
19
- if(newkey.length > 0){
20
- new Ajax.Request('../hash_tag_item/'+el.id+'/'+newkey+'/'+$(el.id+'_value').value, {
21
- asynchronous:true,
22
- onComplete: function(t){
23
- ulEl.innerHTML += t.responseText;
24
- Behaviour.apply();
25
- }
26
- });
27
- }
28
- return false;
29
- }
30
- },
31
- '.naction_remove_rel': function(el) {
32
- el.onclick = function() {
33
- //remove rel from list and add option to pulldown
34
- parentEl = el
35
- while(parentEl.tagName != 'LI'){
36
- parentEl = parentEl.parentNode
37
- }
38
- rel_oid = parentEl.getElementsByTagName('input')[0].value;
39
- rel_name = parentEl.getElementsByTagName('input')[0].name.substr(0, parentEl.getElementsByTagName('input')[0].name.length-2);
40
- rel_display = parentEl.getElementsByTagName('span')[0].innerHTML;
41
- newOpt = document.createElement('option');
42
- newOpt.value = rel_oid;
43
- newOpt.appendChild(document.createTextNode(rel_display));
44
- $(rel_name+'_selector').appendChild(newOpt);
45
- Element.remove(parentEl);
46
- return false;
47
- }
48
- },
49
- '.naction_add_rel': function(el) {
50
- el.onclick = function() {
51
- //add a relation list item and remove item from options
52
- ulEl = $(el.id+'_list');
53
- selectorEl = $(el.id+'_selector');
54
- // TODO: moz allows a select box with 0 options in it? ... disabled must be set with js
55
- selectedElement = selectorEl.options[selectorEl.selectedIndex]
56
- sURL = '../relation_item/'+el.id+'/'+selectedElement.innerHTML+'/'+selectedElement.value
57
- new Ajax.Request(sURL, {
58
- asynchronous:true,
59
- onComplete: function(t){
60
- ulEl.innerHTML += t.responseText;
61
- Behaviour.apply();
62
- },
63
- onFailure: function(t){
64
- // TODO: put the rel back in the option list
65
- // chrisfarms: UNTESTED... selectedEl might not be availible?
66
- // prob wont work in ffox. since moz doesnt like innerHTML used like this with options
67
- selectorEl.innerHTML += '<option value="'+selectedElement.value+'">'+selectedElement.innerHTML+'</option>'
68
- }
69
- });
70
- Element.remove(selectedElement);
71
- return false;
72
- }
73
- }
74
- });
@@ -1,66 +0,0 @@
1
- <html>
2
- <head>
3
- <title>Settings</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
- .source {
21
- border: 1px solid #ccc;
22
- padding: 10px;
23
- margin-top: 10px; margin-bottom: 10px;
24
- }
25
- h2 {
26
- padding-left: 5px;
27
- background: #eee;
28
- }
29
- table {
30
- border-collapse: collapse;
31
- width: 100%;
32
- }
33
- th {
34
- border: 1px solid #ccc; padding: 5px; background: #ff0
35
- }
36
- td {
37
- border: 1px solid #ccc; padding: 5px
38
- }
39
- </style>
40
- </head>
41
- <body>
42
- <?r if Run.mode == :debug ?>
43
- <h1>Settings</h1>
44
-
45
- <table width="100%">
46
- <tr>
47
- <th>Name</th>
48
- <th>Value</th>
49
- <th>Type</th>
50
- <th>Description</th>
51
- </tr>
52
- <?r for s in Configuration.settings ?>
53
- <tr>
54
- <td>#{s.owner}.<strong>#{s.name}</strong></td>
55
- <td>#{s.value.inspect}</td>
56
- <td>#{s.type}</td>
57
- <td>#{s.options[:doc]}</td>
58
- </tr>
59
- <?r end ?>
60
- </table>
61
-
62
- <br /><br />
63
- Powered by <a href="http://www.nitrohq.com">Nitro</a> version #{Nitro::Version}
64
- <?r end ?>
65
- </body>
66
- </html>