nitro 0.29.0 → 0.30.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. data/CHANGELOG +410 -0
  2. data/ProjectInfo +36 -44
  3. data/README +5 -5
  4. data/doc/AUTHORS +6 -0
  5. data/doc/RELEASES +159 -2
  6. data/lib/glue/sweeper.rb +2 -2
  7. data/lib/glue/webfile.rb +14 -1
  8. data/lib/nitro.rb +6 -9
  9. data/lib/nitro/adapter/mongrel.rb +36 -43
  10. data/lib/nitro/adapter/scgi.rb +1 -1
  11. data/lib/nitro/adapter/webrick.rb +96 -24
  12. data/lib/nitro/caching/actions.rb +2 -1
  13. data/lib/nitro/caching/fragments.rb +1 -8
  14. data/lib/nitro/caching/output.rb +14 -4
  15. data/lib/nitro/cgi.rb +19 -21
  16. data/lib/nitro/cgi/cookie.rb +5 -1
  17. data/lib/nitro/cgi/request.rb +20 -4
  18. data/lib/nitro/compiler.rb +74 -28
  19. data/lib/nitro/compiler/cleanup.rb +1 -1
  20. data/lib/nitro/compiler/elements.rb +1 -2
  21. data/lib/nitro/compiler/localization.rb +1 -1
  22. data/lib/nitro/compiler/markup.rb +1 -1
  23. data/lib/nitro/compiler/script.rb +52 -44
  24. data/lib/nitro/compiler/squeeze.rb +4 -3
  25. data/lib/nitro/compiler/xslt.rb +7 -6
  26. data/lib/nitro/context.rb +39 -20
  27. data/lib/nitro/controller.rb +24 -5
  28. data/lib/nitro/dispatcher.rb +13 -5
  29. data/lib/nitro/global.rb +63 -0
  30. data/lib/nitro/helper/feed.rb +432 -0
  31. data/lib/nitro/helper/form.rb +11 -3
  32. data/lib/nitro/helper/form/builder.rb +140 -0
  33. data/lib/nitro/helper/form/controls.rb +2 -1
  34. data/lib/nitro/helper/javascript.rb +6 -0
  35. data/lib/nitro/helper/javascript/morphing.rb +13 -6
  36. data/lib/nitro/helper/xhtml.rb +42 -6
  37. data/lib/nitro/helper/xml.rb +3 -0
  38. data/lib/nitro/part.rb +2 -2
  39. data/lib/nitro/render.rb +7 -2
  40. data/lib/nitro/router.rb +57 -16
  41. data/lib/nitro/scaffolding.rb +29 -20
  42. data/lib/nitro/server.rb +4 -10
  43. data/lib/nitro/server/drb.rb +1 -1
  44. data/lib/nitro/server/runner.rb +10 -0
  45. data/lib/nitro/session.rb +31 -12
  46. data/lib/nitro/session/drb.rb +13 -1
  47. data/lib/nitro/session/file.rb +1 -1
  48. data/lib/nitro/session/memcached.rb +1 -1
  49. data/lib/nitro/session/memory.rb +1 -1
  50. data/lib/nitro/session/og.rb +1 -1
  51. data/lib/nitro/test/testcase.rb +3 -0
  52. data/proto/public/error.xhtml +5 -5
  53. data/proto/public/js/controls.js +2 -2
  54. data/proto/public/js/dragdrop.js +320 -79
  55. data/proto/public/js/effects.js +200 -152
  56. data/proto/public/js/prototype.js +284 -63
  57. data/proto/public/js/scriptaculous.js +7 -5
  58. data/proto/public/js/unittest.js +11 -0
  59. data/proto/public/scaffold/advanced_search.xhtml +30 -0
  60. data/proto/public/scaffold/list.xhtml +8 -1
  61. data/proto/public/scaffold/search.xhtml +2 -1
  62. data/proto/script/scgi_service +1 -1
  63. data/src/part/admin/controller.rb +1 -1
  64. data/src/part/admin/skin.rb +1 -1
  65. data/test/nitro/CONFIG.rb +3 -0
  66. data/test/nitro/adapter/tc_webrick.rb +1 -1
  67. data/test/nitro/cgi/tc_cookie.rb +1 -1
  68. data/test/nitro/cgi/tc_request.rb +5 -5
  69. data/test/nitro/compiler/tc_client_morpher.rb +47 -0
  70. data/test/nitro/compiler/tc_compiler.rb +2 -0
  71. data/test/nitro/helper/tc_feed.rb +138 -0
  72. data/test/nitro/helper/tc_pager.rb +1 -1
  73. data/test/nitro/helper/tc_rss.rb +1 -1
  74. data/test/nitro/helper/tc_table.rb +1 -1
  75. data/test/nitro/helper/tc_xhtml.rb +1 -1
  76. data/test/nitro/tc_caching.rb +1 -1
  77. data/test/nitro/tc_cgi.rb +1 -1
  78. data/test/nitro/tc_context.rb +1 -1
  79. data/test/nitro/tc_controller.rb +31 -3
  80. data/test/nitro/tc_controller_aspect.rb +1 -1
  81. data/test/nitro/tc_dispatcher.rb +1 -1
  82. data/test/nitro/tc_element.rb +1 -1
  83. data/test/nitro/tc_flash.rb +1 -1
  84. data/test/nitro/tc_helper.rb +1 -1
  85. data/test/nitro/tc_render.rb +6 -6
  86. data/test/nitro/tc_router.rb +8 -4
  87. data/test/nitro/tc_server.rb +1 -3
  88. data/test/nitro/tc_session.rb +1 -3
  89. metadata +107 -104
  90. data/Rakefile +0 -232
  91. data/lib/nitro/adapter/acgi.rb +0 -237
  92. data/proto/public/Makefile.acgi +0 -40
  93. data/proto/public/acgi.c +0 -138
@@ -0,0 +1,140 @@
1
+ require 'glue/builder/xml'
2
+
3
+ module Nitro
4
+ module FormHelper
5
+
6
+ # A specialized Builder for dynamically building of forms.
7
+ # Provides extra support for forms backed by managed objects
8
+ # (entities).
9
+ #--
10
+ # TODO: allow multiple objects per form.
11
+ # TODO: use more generalized controls.
12
+ #++
13
+
14
+ class FormXmlBuilder < ::Glue::XmlBuilder
15
+
16
+ def initialize buffer = '', options = {}
17
+ super
18
+ @obj = options[:object]
19
+ end
20
+
21
+ # Render a control+label for the given property of the form
22
+ # object.
23
+
24
+ def property sym, options = {}
25
+ if prop = @obj.class.properties[sym]
26
+ control = Form::Control.fetch(@obj, prop, options).render
27
+ print element(prop, control)
28
+ else
29
+ raise "Undefined property '#{sym}' for class '#{@obj.class}'."
30
+ end
31
+ end
32
+
33
+ # Render controls+labels for all relations of the form object.
34
+
35
+ def all_properties options = {}
36
+ for prop in @obj.class.properties.values
37
+ property prop.symbol, options
38
+ end
39
+ end
40
+ alias_method :properties, :all_properties
41
+
42
+ #--
43
+ # IMPLEMENT ME
44
+ #++
45
+
46
+ def relation sym, options = {}
47
+ end
48
+
49
+ #--
50
+ # IMPLEMENT ME
51
+ #++
52
+
53
+ def all_relations options = {}
54
+ end
55
+
56
+ # Renders a control to select a file for upload.
57
+
58
+ def select_file name, options = {}
59
+ print %|<input type="file" name="#{name}" />|
60
+ end
61
+
62
+ private
63
+
64
+ # Emit a label. Override this method to customize the
65
+ # rendering for your application needs.
66
+
67
+ def label prop
68
+ %{<label for="#{prop.name}">#{prop[:title] || prop.name.to_s.humanize}</label>}
69
+ end
70
+
71
+ # Emit a form element. Override this method to customize the
72
+ # rendering for your application needs.
73
+
74
+ def element prop, html
75
+ %{
76
+ <p class="form_#{prop.symbol}">
77
+ <div>#{label(prop)}</div>
78
+ #{html}
79
+ </p>
80
+ }
81
+ end
82
+
83
+ end
84
+
85
+ # A sophisticated form generation helper method.
86
+ #
87
+ # === Options
88
+ #
89
+ # * :object, :entity, :class = The object that acts as model
90
+ # for this form. If you pass a class an empty object is
91
+ # instantiated.
92
+ #
93
+ # === Example
94
+ #
95
+ # #{form(:object => @owner, :action => :save_profile) do |f|
96
+ # f.property :name, :editable => false
97
+ # f.property :password
98
+ # f.br
99
+ # f.submit 'Update'
100
+ # end}
101
+
102
+ def form options = {}, &block
103
+ obj = (options[:object] ||= options[:entity] || options[:class])
104
+
105
+ # If the passed obj is a Class instantiate an empty object
106
+ # of this class.
107
+
108
+ if obj.is_a? Class
109
+ obj = options[:object] = obj.allocate
110
+ end
111
+
112
+ # Convert virtual :multipart method to method="post",
113
+ # enctype="multipart/form-data"
114
+
115
+ if options[:method] == :multipart
116
+ options[:method] = :post
117
+ options[:enctype] = 'multipart/form-data'
118
+ end
119
+
120
+ b = FormXmlBuilder.new('', options)
121
+
122
+ b << '<form'
123
+ b << %| action="#{options[:action]}"| if options[:action]
124
+ b << %| method="#{options[:method]}"| if options[:method]
125
+ b << %| enctype="#{options[:enctype]}"| if options[:enctype]
126
+ b << '>'
127
+
128
+ b.hidden(:name => 'oid', :value => obj.oid) if obj and obj.saved?
129
+
130
+ yield b
131
+
132
+ b << '</form>'
133
+
134
+ return b
135
+ end
136
+
137
+ end
138
+ end
139
+
140
+ # * George Moschovitis <gm@navel.gr>
@@ -1,3 +1,5 @@
1
+ require 'glue/configuration'
2
+
1
3
  require 'nitro/helper/xhtml'
2
4
 
3
5
  module Nitro
@@ -365,7 +367,6 @@ class Control
365
367
  # or :symbol defaults to Control if not found
366
368
 
367
369
  def self.fetch(obj, key, options={})
368
-
369
370
  if key.kind_of? Og::Relation
370
371
  control_sym = key[:control] || key.class.to_s.demodulize.underscore.to_sym
371
372
  elsif key.kind_of? Property
@@ -2,6 +2,12 @@ require 'facet/inflect'
2
2
 
3
3
  module Nitro
4
4
 
5
+ module Javascript
6
+ # The javascript files to auto include.
7
+
8
+ setting :required_files, :default => [], :doc => 'The javascript files to auto include'
9
+ end
10
+
5
11
  # Javascript utilities.
6
12
 
7
13
  module JavascriptUtils
@@ -89,20 +89,27 @@ end
89
89
  #
90
90
  # <a client="action">..</a>
91
91
  # becomes
92
- # <a href="#" onclick="__nc_action(); return false">...</a>
92
+ # <a href="#" onclick="__nc_action(); return false">..</a>
93
+ #
94
+ # <a client="action" params="this.id">..</a>
95
+ # becomes
96
+ # <a href="#" onclick="__nc_action(this.id); return false">..</a>
93
97
 
94
98
  class ClientMorpher < SharedMorpher
95
99
  def before_start(buffer)
96
100
  require_script_file :prototype, :effects
97
101
 
102
+ params = @attributes['params']
103
+
98
104
  case @name
99
- when 'form'
100
- @attributes['onsubmit'] = "__nc_#@value(); return false"
101
- else
102
- @attributes['href'] = '#'
103
- @attributes['onclick'] = "__nc_#@value(); return false"
105
+ when 'form'
106
+ @attributes['onsubmit'] = "__nc_#@value(#{params}); return false"
107
+ else
108
+ @attributes['href'] = '#'
109
+ @attributes['onclick'] = "__nc_#@value(#{params}); return false"
104
110
  end
105
111
  @attributes.delete(@key)
112
+ @attributes.delete('params')
106
113
  end
107
114
  end
108
115
 
@@ -5,7 +5,31 @@ module Nitro
5
5
 
6
6
  module XhtmlHelper
7
7
 
8
- private
8
+ # Creates the href of an Object.
9
+
10
+ def href_of(obj, base = nil)
11
+ if obj.is_a?(Symbol) or obj.is_a?(String)
12
+ href = obj.to_s
13
+ elsif obj.respond_to? :to_href
14
+ href = obj.to_href
15
+ else
16
+ href = "#{obj.class.name.pluralize.undescore}/#{obj.oid}"
17
+ end
18
+
19
+ if base
20
+ base += '/'
21
+ else
22
+ base = "#{self.class.mount_path}/".squeeze
23
+ end
24
+
25
+ return "#{base}#{href}"
26
+ end
27
+
28
+ # Creates a link to an Object.
29
+
30
+ def link_to(obj, base = nil)
31
+ %|<a href="#{href_of(obj, base)}">#{obj}</a>|
32
+ end
9
33
 
10
34
  # Render select options. The parameter is a hash of options.
11
35
  #
@@ -64,17 +88,29 @@ private
64
88
  end
65
89
  end
66
90
 
91
+ # Render a hidden form input.
92
+
93
+ def hidden(options)
94
+ opts = options.collect { |k, v| %[#{k}="#{v}"] }.join(' ')
95
+ %[<input type="hidden" #{opts} />]
96
+ end
97
+
67
98
  # Render a submit input.
68
99
 
69
- def submit(options = nil)
100
+ def submit(label, options = nil)
70
101
  str = ''
71
102
 
72
- if options
103
+ label = options.delete(:value) unless label
104
+
105
+ str << '<input type="submit"'
106
+ str << %[ value="#{label}"] if label
107
+
108
+ unless options.empty?
73
109
  opts = options.collect { |k, v| %[#{k}="#{v}"] }.join(' ')
74
- str << %[<input type="submit" #{opts} />]
75
- else
76
- str << %|<input type="submit" />|
110
+ str << %[ #{opts} ]
77
111
  end
112
+
113
+ str << ' />'
78
114
 
79
115
  return str
80
116
  end
@@ -2,6 +2,9 @@ module Nitro
2
2
 
3
3
  # A helper mixin for programmatically building XML
4
4
  # blocks.
5
+ #--
6
+ # gmosx, INVESTIGATE: is this used or deprecated?
7
+ #++
5
8
 
6
9
  module XmlHelper
7
10
 
@@ -9,8 +9,8 @@ class Part
9
9
  # Require (include) a part in the current application.
10
10
 
11
11
  def self.require(name)
12
- Logger.debug "Requiring part '#{name}'."
13
- Kernel.require "part/#{name}/run.rb"
12
+ Logger.debug "Requiring part '#{name}'." if $DBG
13
+ Kernel.require 'part/' + name + '/run.rb'
14
14
  end
15
15
 
16
16
  end
@@ -94,6 +94,7 @@ module Render
94
94
  # A parent render/controller acts as the context.
95
95
 
96
96
  def initialize(context, base = nil)
97
+ @rendering_context = 0
97
98
  @request = @response = @context = context
98
99
  @controller_name = @base = base
99
100
  @out = context.out
@@ -119,13 +120,17 @@ module Render
119
120
  @context.content_type = klass.instance_variable_get('@content_type') || 'text/html'
120
121
 
121
122
  raise 'No controller for action' unless klass
122
-
123
+
124
+ @context.level += 1
125
+
123
126
  if self.class == klass
124
127
  self.send(action)
125
128
  else
126
129
  klass.new(@context, base).send(action)
127
130
  end
128
131
 
132
+ @context.level -= 1
133
+
129
134
  rescue NoActionError => e1
130
135
  log_error(e1, path, false)
131
136
  print '(error)'
@@ -308,7 +313,7 @@ private
308
313
  def emit(meth, *options)
309
314
  Emitter.instance.send(meth, *options)
310
315
  end
311
-
316
+
312
317
  end
313
318
 
314
319
  end
@@ -10,9 +10,30 @@ module Nitro
10
10
  #
11
11
  # === Example
12
12
  #
13
- # r.add_route(%r{rewritten/url/(.*)}, :controller => IdController, :action => :register, :param => :name)
14
- # r.add_route(%r{another/zelo/(.*)/(.*)}, :controller => AdminController, :action => :kick, :params => [:name, :age])
15
- # r.add_route(%r{cool/(.*)_(.*).html}, :controller => AdminController, :action => :long, :params => [:name, :age])
13
+ # can also be initialized by a YAML file through Configuration.
14
+ #
15
+ # Router.rules = [
16
+ # {:match => /rewritten\/url\/(.*)/, :controller => IdController, :action => :register, :param => :name},
17
+ # {:match => %r{another/zelo/(.*)/(.*)}, :controller => AdminController, :action => :kick, :params => [:name, :age]}
18
+ # ]
19
+ #
20
+ # or
21
+ #
22
+ # Router.add_rule :match => /rewritten\/url\/(.*)/, :controller => IdController, :action => :register, :param => :name
23
+ # Router.add_rule :match => %r{another/zelo/(.*)/(.*)}, :controller => AdminController, :action => :kick, :params => [:name, :age]
24
+ #
25
+ # this is the global table that initializes each Router
26
+ # instance.
27
+ #
28
+ # or (specialized per Router instance)
29
+ #
30
+ # r.add_rule(:match => %r{rewritten/url/(.*)}, :controller => IdController, :action => :register, :param => :name)
31
+ # r.add_rule(:match => %r{another/zelo/(.*)/(.*)}, :controller => AdminController, :action => :kick, :params => [:name, :age])
32
+ # r.add_rule(:match => %r{cool/(.*)_(.*).html}, :controller => AdminController, :action => :long, :params => [:name, :age])
33
+ #
34
+ #--
35
+ # gmosx, TODO: use a hash only instead of [rule, options]
36
+ #++
16
37
 
17
38
  module Router
18
39
 
@@ -20,26 +41,39 @@ module Router
20
41
 
21
42
  setting :strip_path, :default => nil, :doc => 'Strip the beginning of the path, used by cgi adapter'
22
43
 
23
- # The route table maps 'nice URLs' to real URLs that
44
+ # The routing rules. The rules in this table are used to initialize
45
+ # the routing table of each instantiated router.
46
+
47
+ setting :rules, :default => [], :doc => 'The routing rules'
48
+
49
+ # The rules map 'nice URLs' to real URLs that
24
50
  # can be handled by the Dispatcher.
25
51
 
26
- attr_accessor :routes
52
+ attr_accessor :rules
53
+
54
+ # Initialize the routing table by importing from the global
55
+ # Router rules.
56
+
57
+ def init_routes
58
+ @rules = Router.rules.dup
59
+ end
27
60
 
28
61
  # Decodes a url to a [controller, action, params] tupple.
29
62
  # Returns false if no decoding is possible.
30
63
 
31
64
  def decode_route(url)
32
- for rule, options in @routes
33
- if md = url.match(rule)
65
+ for rule in @rules
66
+ if md = url.match(rule[:match])
34
67
  params = nil
35
- if param_names = options[:params] || options[:param]
68
+ if param_names = rule[:params] || rule[:param]
36
69
  param_names = [ param_names ] unless param_names.is_a?(Array)
37
70
  params = {}
38
71
  md.captures.each_with_index do |val, idx|
39
72
  params[param_names[idx].to_s] = val
40
73
  end
41
74
  end
42
- return options[:controller], options[:action], params
75
+ Logger.debug "Rewriting '#{url}' to '#{rule[:controller]}##{rule[:action]}(#{params.values.join(', ')})." if $DBG
76
+ return rule[:controller], rule[:action], params
43
77
  end
44
78
  end
45
79
  return false
@@ -50,9 +84,8 @@ module Router
50
84
  # Returns false if no encoding is possible.
51
85
 
52
86
  def encode_route(controller, action, *params)
53
- if route = @routes.find { |r| (r.last[:controller] == controller) and (r.last[:action] == action) }
54
- rule, options = *route
55
- url = rule.source
87
+ if rule = @rules.find { |r| (r[:controller] == controller) and (r[:action] == action) }
88
+ url = rule[:match].source
56
89
 
57
90
  (params.size / 2).times do |i|
58
91
  val = params[i + i + 1]
@@ -66,12 +99,20 @@ module Router
66
99
 
67
100
  # Add a route to the routing table.
68
101
 
69
- def add_route(rule, options)
70
- (@routes ||= []) << [rule, options]
102
+ def add_rule(rule)
103
+ @rules << rule
71
104
  end
72
- alias_method :<<, :add_route
105
+ alias_method :<<, :add_rule
73
106
 
74
- def add_routes
107
+ def add_rules(new_rules)
108
+ @rules.concat(new_rules)
109
+ end
110
+
111
+ class << self
112
+ def add_rule(rule)
113
+ self.rules << rule
114
+ end
115
+ alias_method :<<, :add_rule
75
116
  end
76
117
 
77
118
  end
@@ -1,7 +1,6 @@
1
1
  require 'nitro/helper/form'
2
2
  require 'nitro/helper/pager'
3
3
 
4
-
5
4
  module Nitro
6
5
 
7
6
  # Scaffolding is a feature of Nitro that automatically generates
@@ -118,11 +117,12 @@ module Scaffolding
118
117
  if File.exist?(path) and source = File.read(path)
119
118
  # Interpolate the source.
120
119
  source.gsub!(/%base%/, @base.to_s)
120
+ source.gsub!(/%klass%/, @klass.to_s)
121
121
  source.gsub!(/%name%/, @name)
122
122
  source.gsub!(/%plural%/, @plural)
123
123
 
124
124
  # Transform the source.
125
- source = @compiler.transform_template(source)
125
+ source = @compiler.transform_template(action, source)
126
126
 
127
127
  @controller.module_eval %{
128
128
  def #{action}_template
@@ -144,15 +144,15 @@ module Scaffolding
144
144
 
145
145
  def scaffold_class
146
146
  define_class_method :scaffold_base, %{
147
- "#{@controller.ann.self.mount_point}/#@base"
147
+ "#{@controller.mount_path}/#@base"
148
148
  }
149
149
 
150
150
  define_class_method :to_href, %{
151
- "#{@controller.ann.self.mount_point}/#@base/view/\#@#{@oid}"
151
+ "#{@controller.mount_path}/#@base/view/\#@#{@oid}"
152
152
  }
153
153
 
154
154
  define_class_method :to_edit_href, %{
155
- "#{@controller.ann.self.mount_point}/#@base/edit/\#@#{@oid}"
155
+ "#{@controller.mount_path}/#@base/edit/\#@#{@oid}"
156
156
  }
157
157
  end
158
158
 
@@ -160,28 +160,28 @@ module Scaffolding
160
160
 
161
161
  def scaffold_controller
162
162
  define_controller_action 'index', %{
163
- #{Glue::Aspects.gen_advice_code(:scaffold_index, @controller.advices, :pre)}
163
+ #{::Aspects.gen_advice_code(:scaffold_index, @controller.advices, :pre)}
164
164
  @list, @pager = paginate(@klass, :per_page => Scaffolding.per_page)
165
165
  }
166
166
 
167
167
  define_controller_action 'list', %{
168
- #{Glue::Aspects.gen_advice_code(:scaffold_list, @controller.advices, :pre)}
168
+ #{::Aspects.gen_advice_code(:scaffold_list, @controller.advices, :pre)}
169
169
  @list, @pager = paginate(@klass, :per_page => Scaffolding.per_page)
170
170
  }
171
171
 
172
172
  define_controller_action 'view(oid)', %{
173
- #{Glue::Aspects.gen_advice_code(:scaffold_view, @controller.advices, :pre)}
173
+ #{::Aspects.gen_advice_code(:scaffold_view, @controller.advices, :pre)}
174
174
  @obj = @klass[oid]
175
175
  }
176
176
 
177
177
  define_controller_action 'new(all = false)', %{
178
- #{Glue::Aspects.gen_advice_code(:scaffold_new, @controller.advices, :pre)}
178
+ #{::Aspects.gen_advice_code(:scaffold_new, @controller.advices, :pre)}
179
179
  @obj = @klass.new
180
180
  @all = all
181
181
  }
182
182
 
183
183
  define_controller_action 'edit(oid = nil, all = false)', %{
184
- #{Glue::Aspects.gen_advice_code(:scaffold_edit, @controller.advices, :pre)}
184
+ #{::Aspects.gen_advice_code(:scaffold_edit, @controller.advices, :pre)}
185
185
  @obj = @klass[oid]
186
186
  @all = all
187
187
  }
@@ -195,29 +195,38 @@ module Scaffolding
195
195
  else
196
196
  obj = request.fill(@klass.create, :assign_relations => true, :preprocess => true)
197
197
  end
198
- #{Glue::Aspects.gen_advice_code(:scaffold_save, @controller.advices, :pre)}
198
+ #{::Aspects.gen_advice_code(:scaffold_save, @controller.advices, :pre)}
199
199
  unless obj.valid?
200
200
  flash[:ERRORS] = obj.errors
201
201
  redirect_to_referer
202
202
  end
203
203
  obj.save
204
204
  oid = obj.pk
205
- #{Glue::Aspects.gen_advice_code(:scaffold_save, @controller.advices, :post)}
205
+ #{::Aspects.gen_advice_code(:scaffold_save, @controller.advices, :post)}
206
206
  redirect '#{action_path(:list)}'
207
207
  }
208
208
 
209
209
  define_controller_action 'search(query)', %{
210
- #{Glue::Aspects.gen_advice_code(:scaffold_search, @controller.advices, :pre)}
210
+ #{::Aspects.gen_advice_code(:scaffold_search, @controller.advices, :pre)}
211
211
  @query = query
212
212
  if @klass.respond_to? :search
213
213
  @list = #@klass.search(query)
214
214
  end
215
+ #{::Aspects.gen_advice_code(:scaffold_search, @controller.advices, :post)}
216
+ }
217
+
218
+ define_controller_action 'advanced_search', %{
219
+ #{::Aspects.gen_advice_code(:scaffold_search, @controller.advices, :pre)}
220
+ if request.post?
221
+ @list = #@klass.query_by_example(request.params)
222
+ end
223
+ #{::Aspects.gen_advice_code(:scaffold_advanced_search, @controller.advices, :post)}
215
224
  }
216
225
 
217
226
  define_controller_action 'delete(oid)', %{
218
- #{Glue::Aspects.gen_advice_code(:scaffold_delete, @controller.advices, :pre)}
227
+ #{::Aspects.gen_advice_code(:scaffold_delete, @controller.advices, :pre)}
219
228
  @klass.delete(oid)
220
- #{Glue::Aspects.gen_advice_code(:scaffold_delete, @controller.advices, :post)}
229
+ #{::Aspects.gen_advice_code(:scaffold_delete, @controller.advices, :post)}
221
230
  redirect_to_referer
222
231
  }
223
232
 
@@ -226,18 +235,18 @@ module Scaffolding
226
235
  for rel in @klass.relations
227
236
  define_controller_action "remove_#{rel.target_singular_name}(oid, rid)", %{
228
237
  obj = @klass[oid]
229
- #{Glue::Aspects.gen_advice_code(:scaffold_remove_relation, @controller.advices, :pre)}
238
+ #{::Aspects.gen_advice_code(:scaffold_remove_relation, @controller.advices, :pre)}
230
239
  rob = #{rel.target_class}[rid]
231
240
  obj.#{rel.name}.remove(rob)
232
- #{Glue::Aspects.gen_advice_code(:scaffold_remove_relation, @controller.advices, :post)}
241
+ #{::Aspects.gen_advice_code(:scaffold_remove_relation, @controller.advices, :post)}
233
242
  redirect_to_referer
234
243
  }
235
244
  define_controller_action "delete_#{rel.target_singular_name}(oid, rid)", %{
236
- #{Glue::Aspects.gen_advice_code(:scaffold_delete_relation, @controller.advices, :pre)}
245
+ #{::Aspects.gen_advice_code(:scaffold_delete_relation, @controller.advices, :pre)}
237
246
  obj = @klass[oid]
238
247
  rob = #{rel.target_class}[rid]
239
248
  obj.#{rel.name}.delete(rob)
240
- #{Glue::Aspects.gen_advice_code(:scaffold_delete_relation, @controller.advices, :post)}
249
+ #{::Aspects.gen_advice_code(:scaffold_delete_relation, @controller.advices, :post)}
241
250
  redirect_to_referer
242
251
  }
243
252
  end
@@ -323,7 +332,7 @@ module Scaffolding
323
332
  if scaffold_all?
324
333
  options = scaffold_all_options
325
334
  Og.manager.manageable_classes.each do |klass|
326
- unless klass.ancestors.include?(Og::Unmanageable) or options[:except] && options[:except].include?(klass)
335
+ unless options[:except] && options[:except].include?(klass)
327
336
  scaffold(klass, options)
328
337
  end
329
338
  end