lolita 3.1.18 → 3.2.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (144) hide show
  1. data/Gemfile +5 -2
  2. data/History.rdoc +24 -0
  3. data/README.md +113 -0
  4. data/VERSION +1 -1
  5. data/{public → app/assets}/images/lolita/plus.png +0 -0
  6. data/{public → app/assets}/javascripts/lolita/application.js +0 -0
  7. data/{public → app/assets}/javascripts/lolita/base64.js +0 -0
  8. data/{public → app/assets}/javascripts/lolita/main.js +1 -0
  9. data/{public → app/assets}/javascripts/lolita/tab.js +0 -0
  10. data/{public → app/assets}/stylesheets/lolita/PIE-custom.htc +0 -0
  11. data/{public → app/assets}/stylesheets/lolita/PIE.htc +0 -0
  12. data/{public → app/assets}/stylesheets/lolita/default.css +0 -0
  13. data/{public → app/assets}/stylesheets/lolita/style.css +0 -21
  14. data/app/controllers/lolita/info_controller.rb +1 -12
  15. data/app/controllers/lolita/rest_controller.rb +2 -7
  16. data/app/helpers/lolita_helper.rb +1 -12
  17. data/app/views/components/lolita/configuration/column/_header.html.erb +1 -1
  18. data/app/views/components/lolita/configuration/column/_sort.html.erb +4 -7
  19. data/app/views/components/lolita/configuration/field/array/habtm/_display.html.haml +1 -1
  20. data/app/views/components/lolita/configuration/field/array/select/_display.html.erb +1 -1
  21. data/app/views/components/lolita/configuration/field/string/disabled/_display.html.erb +1 -1
  22. data/app/views/components/lolita/configuration/field/string/text/_display.html.erb +1 -1
  23. data/app/views/components/lolita/configuration/list/_paginator.html.erb +1 -1
  24. data/app/views/components/lolita/configuration/list/_title.html.erb +1 -6
  25. data/app/views/components/lolita/configuration/nested_form/_display.html.erb +6 -8
  26. data/app/views/components/lolita/navigation/_tree.html.erb +25 -18
  27. data/app/views/components/lolita/shared/_header.html.erb +1 -1
  28. data/app/views/components/lolita/shared/_right_sidebar.html.erb +6 -1
  29. data/app/views/layouts/lolita/application.html.erb +3 -3
  30. data/config/locales/en.yml +24 -1
  31. data/config/locales/lv.yml +0 -1
  32. data/config/routes.rb +1 -3
  33. data/lib/generators/lolita/install_generator.rb +1 -5
  34. data/lib/lolita.rb +23 -38
  35. data/lib/lolita/adapter/abstract_adapter.rb +0 -1
  36. data/lib/lolita/adapter/active_record.rb +4 -42
  37. data/lib/lolita/adapter/mongoid.rb +4 -76
  38. data/lib/lolita/configuration/base.rb +2 -15
  39. data/lib/lolita/configuration/column.rb +2 -25
  40. data/lib/lolita/configuration/factory/field.rb +2 -10
  41. data/lib/lolita/configuration/field.rb +1 -6
  42. data/lib/lolita/configuration/field/array.rb +31 -124
  43. data/lib/lolita/configuration/field/integer.rb +1 -0
  44. data/lib/lolita/configuration/list.rb +2 -23
  45. data/lib/lolita/configuration/tabs.rb +0 -6
  46. data/lib/lolita/controllers/component_helpers.rb +1 -1
  47. data/lib/lolita/controllers/internal_helpers.rb +4 -18
  48. data/lib/lolita/controllers/user_helpers.rb +11 -23
  49. data/lib/lolita/hooks.rb +120 -163
  50. data/lib/lolita/lazy_loader.rb +0 -3
  51. data/lib/lolita/mapping.rb +0 -23
  52. data/lib/lolita/modules/rest.rb +1 -1
  53. data/lib/lolita/navigation/branch.rb +1 -52
  54. data/lib/lolita/navigation/tree.rb +0 -10
  55. data/lib/lolita/rails.rb +2 -1
  56. data/lib/lolita/rails/routes.rb +5 -4
  57. data/lib/lolita/system_configuration/application.rb +1 -7
  58. data/lolita.gemspec +83 -100
  59. data/spec/configuration/field_spec.rb +1 -1
  60. data/spec/configuration/list_spec.rb +14 -19
  61. data/spec/rails_app/app/mongoid/post.rb +0 -4
  62. data/spec/rails_app/config/application.rb +1 -12
  63. data/spec/rails_app/config/environments/development.rb +2 -6
  64. data/spec/rails_app/config/environments/production.rb +1 -5
  65. data/spec/rails_app/config/environments/test.rb +1 -5
  66. data/vendor/assets/javascripts/jquery-1.6.2.min.js +18 -0
  67. data/{public → vendor/assets}/javascripts/jquery-ui-1.8.13.min.js +0 -0
  68. data/{public → vendor/assets}/javascripts/modernizr-1.7.min.js +0 -0
  69. data/{public → vendor/assets}/javascripts/tinymce/jquery.tinymce.js +0 -0
  70. data/{public → vendor/assets}/javascripts/tinymce/langs/en.js +0 -0
  71. data/{public → vendor/assets}/javascripts/tinymce/license.txt +0 -0
  72. data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/about.htm +0 -0
  73. data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/anchor.htm +0 -0
  74. data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/charmap.htm +0 -0
  75. data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/color_picker.htm +0 -0
  76. data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/editor_template.js +0 -0
  77. data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/editor_template_src.js +0 -0
  78. data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/image.htm +0 -0
  79. data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/img/colorpicker.jpg +0 -0
  80. data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/img/flash.gif +0 -0
  81. data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/img/icons.gif +0 -0
  82. data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/img/iframe.gif +0 -0
  83. data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/img/pagebreak.gif +0 -0
  84. data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/img/quicktime.gif +0 -0
  85. data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/img/realmedia.gif +0 -0
  86. data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/img/shockwave.gif +0 -0
  87. data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/img/trans.gif +0 -0
  88. data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/img/video.gif +0 -0
  89. data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/img/windowsmedia.gif +0 -0
  90. data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/js/about.js +0 -0
  91. data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/js/anchor.js +0 -0
  92. data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/js/charmap.js +0 -0
  93. data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/js/color_picker.js +0 -0
  94. data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/js/image.js +0 -0
  95. data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/js/link.js +0 -0
  96. data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/js/source_editor.js +0 -0
  97. data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/langs/en.js +0 -0
  98. data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/langs/en_dlg.js +0 -0
  99. data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/link.htm +0 -0
  100. data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/shortcuts.htm +0 -0
  101. data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/skins/cirkuit/content.css +0 -0
  102. data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/skins/cirkuit/dialog.css +0 -0
  103. data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/skins/cirkuit/img/butt2.png +0 -0
  104. data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/skins/cirkuit/img/button-bg.png +0 -0
  105. data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/skins/cirkuit/img/buttons.png +0 -0
  106. data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/skins/cirkuit/img/down_arrow.gif +0 -0
  107. data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/skins/cirkuit/img/fade-butt.png +0 -0
  108. data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/skins/cirkuit/img/icons.png +0 -0
  109. data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/skins/cirkuit/img/items.gif +0 -0
  110. data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/skins/cirkuit/img/menu-arrow.png +0 -0
  111. data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/skins/cirkuit/img/menu-check.png +0 -0
  112. data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/skins/cirkuit/img/progress.gif +0 -0
  113. data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/skins/cirkuit/img/tabs.gif +0 -0
  114. data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/skins/cirkuit/img/toolbarbg.png +0 -0
  115. data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/skins/cirkuit/ui.css +0 -0
  116. data/{public → vendor/assets}/javascripts/tinymce/themes/advanced/source_editor.htm +0 -0
  117. data/{public → vendor/assets}/javascripts/tinymce/tiny_mce.js +0 -0
  118. data/{public → vendor/assets}/javascripts/tinymce/tiny_mce_popup.js +0 -0
  119. data/{public → vendor/assets}/javascripts/tinymce/utils/editable_selects.js +0 -0
  120. data/{public → vendor/assets}/javascripts/tinymce/utils/form_utils.js +0 -0
  121. data/{public → vendor/assets}/javascripts/tinymce/utils/mctabs.js +0 -0
  122. data/{public → vendor/assets}/javascripts/tinymce/utils/validate.js +0 -0
  123. data/{public → vendor/assets}/javascripts/tinymce_config.js +1 -1
  124. metadata +121 -127
  125. data/README.rdoc +0 -100
  126. data/app/controllers/lolita/field_data_controller.rb +0 -36
  127. data/app/views/components/lolita/configuration/field/array/autocomplete/_display.html.haml +0 -11
  128. data/app/views/components/lolita/configuration/field/array/checkbox/_display.html.haml +0 -8
  129. data/app/views/components/lolita/configuration/field/array/polymorphic/_display.html.haml +0 -6
  130. data/app/views/components/lolita/configuration/field/array/polymorphic/_options_for_select.html.haml +0 -1
  131. data/app/views/components/lolita/configuration/search/_display.html.haml +0 -2
  132. data/app/views/components/lolita/shared/_save_button.html.erb +0 -6
  133. data/lib/generators/lolita/assets_generator.rb +0 -19
  134. data/lib/lolita/configuration/factory.rb +0 -56
  135. data/lib/lolita/configuration/helper.rb +0 -24
  136. data/lib/lolita/configuration/page.rb +0 -126
  137. data/lib/lolita/configuration/search.rb +0 -91
  138. data/lib/lolita/controller_additions.rb +0 -15
  139. data/lib/lolita/controllers/authorization_helpers.rb +0 -56
  140. data/lib/lolita/search/simple.rb +0 -76
  141. data/public/javascripts/jquery-1.6.min.js +0 -16
  142. data/public/javascripts/rails.js +0 -137
  143. data/spec/configuration/search_spec.rb +0 -44
  144. data/spec/search/simple_spec.rb +0 -48
data/lib/lolita/hooks.rb CHANGED
@@ -59,154 +59,6 @@ module Lolita
59
59
  # ==Named hooks
60
60
  # See Lolita::Hooks::NamedHook for details.
61
61
  module Hooks
62
- class Runner
63
-
64
- class << self
65
- def singleton_hook(hook_object,hook_name)
66
- class << hook_object
67
- def hooks_runned(name=nil)
68
- @hooks_runned ||=[]
69
- @hooks_runned << name if name
70
- @hooks_runned
71
- end
72
- end
73
-
74
- hook_object.hooks_runned(hook_name)
75
- end
76
-
77
- def runned?(hook_object,hook_name)
78
- if hook_object.respond_to?(:hooks_runned)
79
- hook_object.hooks_runned.include?(hook_name)
80
- end
81
- end
82
-
83
- def singleton_hooks
84
- @singleton_hooks || {}
85
- end
86
- end
87
-
88
- attr_accessor :hooks_run_scope, :given_callback_content
89
- attr_writer :hooks_scope
90
-
91
- def initialize(hook_class,hook_name, options)
92
- @hook_class = hook_class
93
- @hook_name = hook_name
94
- @options = options
95
- @options[:once] = @options[:once] == true ? @hook_class : @options[:once]
96
- end
97
-
98
- # Hooks scope is used to execute callbacks. By default it is class itself.
99
- def hooks_scope
100
- @hooks_scope || @hook_class
101
- end
102
-
103
- def run(&block)
104
- if !@options[:once] || (@options[:once] && !self.class.runned?(@options[:once],@hook_name))
105
- self.class.singleton_hook(@options[:once],@hook_name)
106
- result = nil
107
- in_hooks_scope(@options[:scope],@options[:run_scope]) do
108
- callback = get_callback(@hook_name)
109
- result = run_callback(callback,&block)
110
- end
111
- result
112
- end
113
- end
114
-
115
- # Call callback block inside of run block.
116
- # ====Example
117
- # MyClass.run(:before_save) do
118
- # do_stuff
119
- # let_content # execute callback block(-s) in same scope as run is executed.
120
- # end
121
- def let_content
122
- if self.given_callback_content.respond_to?(:call)
123
- run_block(self.given_callback_content)
124
- elsif self.given_callback_content
125
- self.given_callback_content
126
- end
127
- end
128
-
129
- protected
130
-
131
- # Switch between self and given <em>scope</em>. Block will be executed with <em>scope</em>.
132
- # And after that it will switch back to self.
133
- def in_hooks_scope(scope,run_scope=nil)
134
- begin
135
- this = self
136
- self.hooks_scope=scope || @hook_class
137
- self.hooks_scope.define_singleton_method(:let_content) do
138
- this.let_content
139
- end
140
- if run_scope
141
- run_scope.define_singleton_method(:let_content) do
142
- this.let_content
143
- end
144
- end
145
- self.hooks_run_scope = run_scope || self.hooks_scope
146
- yield
147
- ensure
148
- self.hooks_scope = @hook_class
149
- self.hooks_run_scope = self.hooks_scope
150
- end
151
- end
152
-
153
- # Return all callbacks
154
- # If scope is not class then it merge class callbacks with scope callbacks. That means that
155
- # class callbacks always will be called before scope callbacks.
156
- def get_callback(name)
157
- scope_callbacks = hooks_scope.callbacks[name.to_sym] || {}
158
-
159
- @hook_class.superclasses.each do |const_name|
160
- scope_callbacks = @hook_class.collect_callbacks_from(name,const_name,scope_callbacks)
161
- end
162
- scope_callbacks
163
- end
164
-
165
- # Run callback. Each callback is Hash with <i>:methods</i> Array and </i>:blocks</i> Array
166
- def run_callback(callback,&block)
167
- method_results=run_methods(callback[:methods],&block)
168
- block_results=run_blocks(callback[:blocks],&block)
169
- method_results+block_results
170
- end
171
-
172
- # Run methods from <em>methods</em> Array
173
- def run_methods methods, &block
174
- result = ""
175
- (methods||[]).each do |method_name|
176
- result << (hooks_run_scope.__send__(method_name,&block)).to_s
177
- end
178
- result
179
- end
180
-
181
- # Run blocks from <em>blocks</em> Array. Also it set #given_callback_content if block is given, this
182
- # will allow to call #let_content. Each block is runned with #run_block.
183
- # After first run result of first block become #given_callback_content, and when next block
184
- # call #let_content, this string will be returned for that block
185
- def run_blocks blocks,&given_block
186
- result=""
187
-
188
- self.given_callback_content=block_given? ? given_block : nil
189
-
190
- if blocks && !blocks.empty?
191
- blocks.each do |block|
192
- result << (run_block(block,&given_block)).to_s
193
- self.given_callback_content=result
194
- end
195
- elsif block_given?
196
- self.given_callback_content=nil
197
- result << run_block(given_block).to_s
198
- end
199
- result
200
- end
201
-
202
- # Run block in scope.
203
- def run_block block, &given_block
204
- hooks_run_scope.instance_eval(&block)
205
- end
206
-
207
-
208
- end # end of Runner
209
-
210
62
  def self.included(base)
211
63
  base.extend(ClassMethods)
212
64
  base.extend(CommonMethods)
@@ -240,14 +92,28 @@ module Lolita
240
92
  end
241
93
 
242
94
  module ClassMethods
95
+ attr_accessor :hooks_run_scope
243
96
 
244
- def hooks_scope=(value)
245
- @hooks_scope = value
97
+ # Setter for #hook_scope.
98
+ def hooks_scope=(object)
99
+ @hooks_scope=object
246
100
  end
247
101
 
248
- def hooks_scope
249
- @hooks_scope || self
102
+ # Hooks scope is used to execute callbacks. By default it is class itself.
103
+ def hooks_scope
104
+ @hooks_scope||self
105
+ end
106
+
107
+ # Setter for #callback_content
108
+ def given_callback_content=(content)
109
+ @given_callback_content=content
250
110
  end
111
+
112
+ # Callback content is used to let callback content executed insede of run block.
113
+ def given_callback_content
114
+ @given_callback_content
115
+ end
116
+
251
117
  # All hooks for class. This is Array of hook names.
252
118
  def hooks
253
119
  @hooks||=[]
@@ -297,15 +163,6 @@ module Lolita
297
163
  }
298
164
  end
299
165
 
300
- def in_hooks_scope(scope)
301
- begin
302
- self.hooks_scope = scope
303
- yield
304
- ensure
305
- self.hooks_scope = self
306
- end
307
- end
308
-
309
166
  # run is used to execute callback. Method accept one or more <i>hook_names</i> and optional block.
310
167
  # It will raise error if hook don't exist for this class. Also it accept <em>:scope</em> options, that
311
168
  # is used to #get_callbacks and #run_callbacks.
@@ -314,10 +171,16 @@ module Lolita
314
171
  # # this will call callbacks in MyClass instance scope, that means that self will be MyClass instance.
315
172
  def run(hook_name,*args,&block)
316
173
 
174
+ result=nil
317
175
  options=args ? args.extract_options! : {}
176
+
318
177
  raise Lolita::HookNotFound, "Hook #{hook_name} is not defined for #{self}." unless self.has_hook?(hook_name)
319
- runner = Lolita::Hooks::Runner.new(self,hook_name,options)
320
- runner.run(&block)
178
+ in_hooks_scope(options[:scope],options[:run_scope]) do
179
+ callback=get_callback(hook_name)
180
+ result=run_callback(callback,&block)
181
+ end
182
+
183
+ result
321
184
  end
322
185
 
323
186
  # Is hook with <em>name</em> is defined for class.
@@ -333,6 +196,20 @@ module Lolita
333
196
  end
334
197
  end
335
198
 
199
+ # Call callback block inside of run block.
200
+ # ====Example
201
+ # MyClass.run(:before_save) do
202
+ # do_stuff
203
+ # let_content # execute callback block(-s) in same scope as run is executed.
204
+ # end
205
+ def let_content
206
+ if self.given_callback_content.respond_to?(:call)
207
+ run_block(self.given_callback_content)
208
+ elsif self.given_callback_content
209
+ self.given_callback_content
210
+ end
211
+ end
212
+
336
213
  # Set #method_missing
337
214
  def recognize_hook_methods method_name, *args, &block
338
215
  if method_name.to_s.match(/^run_(\w+)/)
@@ -341,6 +218,81 @@ module Lolita
341
218
  end
342
219
  end
343
220
 
221
+ protected
222
+
223
+ # Switch between self and given <em>scope</em>. Block will be executed with <em>scope</em>.
224
+ # And after that it will switch back to self.
225
+ def in_hooks_scope(scope,run_scope=nil)
226
+ begin
227
+ self.hooks_scope=scope||self
228
+ if run_scope
229
+ run_scope.define_singleton_method(:let_content) do
230
+ scope.let_content
231
+ end
232
+ end
233
+ self.hooks_run_scope=run_scope || self.hooks_scope
234
+ yield
235
+ ensure
236
+ self.hooks_scope=self
237
+ self.hooks_run_scope=self.hooks_scope
238
+ end
239
+ end
240
+
241
+ # Run callback. Each callback is Hash with <i>:methods</i> Array and </i>:blocks</i> Array
242
+ def run_callback(callback,&block)
243
+ method_results=run_methods(callback[:methods],&block)
244
+ block_results=run_blocks(callback[:blocks],&block)
245
+ method_results+block_results
246
+ end
247
+
248
+ # Run methods from <em>methods</em> Array
249
+ def run_methods methods, &block
250
+ result=""
251
+ (methods||[]).each do |method_name|
252
+ result << (hooks_run_scope.__send__(method_name,&block)).to_s
253
+ end
254
+ result
255
+ end
256
+
257
+ # Run blocks from <em>blocks</em> Array. Also it set #given_callback_content if block is given, this
258
+ # will allow to call #let_content. Each block is runned with #run_block.
259
+ # After first run result of first block become #given_callback_content, and when next block
260
+ # call #let_content, this string will be returned for that block
261
+ def run_blocks blocks,&given_block
262
+ result=""
263
+
264
+ self.given_callback_content=block_given? ? given_block : nil
265
+
266
+ if blocks && !blocks.empty?
267
+ blocks.each do |block|
268
+ result << (run_block(block,&given_block)).to_s
269
+ self.given_callback_content=result
270
+ end
271
+ elsif block_given?
272
+ self.given_callback_content=nil
273
+ result << run_block(given_block).to_s
274
+ end
275
+ result
276
+ end
277
+
278
+ # Run block in scope.
279
+ def run_block block, &given_block
280
+ hooks_run_scope.instance_eval(&block)
281
+ end
282
+
283
+ # Return all callbacks
284
+ # If scope is not class then it merge class callbacks with scope callbacks. That means that
285
+ # class callbacks always will be called before scope callbacks.
286
+ def get_callback(name)
287
+ scope_callbacks=hooks_scope.callbacks[name.to_sym] || {}
288
+
289
+ superclasses.each do |const_name|
290
+ scope_callbacks=collect_callbacks_from(name,const_name,scope_callbacks)
291
+ end
292
+ scope_callbacks
293
+ end
294
+
295
+
344
296
  def collect_callbacks_from(name,const_name,scope_callbacks)
345
297
  class_callbacks=const_name.callbacks[name.to_sym] || {}
346
298
  [:methods,:blocks].each do |attr|
@@ -387,6 +339,11 @@ module Lolita
387
339
  self.class.run(*hook_names,options,&block)
388
340
  end
389
341
 
342
+ # See Lolita::Hooks::ClassMethods#let_content
343
+ def let_content
344
+ self.class.let_content
345
+ end
346
+
390
347
  # See Lolita::Hooks::ClassMethods#method_missing
391
348
  def method_missing(*args,&block)
392
349
  unless self.class.recognize_hook_methods(*args,:scope=>self,&block)
@@ -36,9 +36,6 @@ module Lolita
36
36
  @class_instance=@lazy_class.new(&@eval_block)
37
37
  end
38
38
  end
39
- if @class_instance.respond_to?(:after_initialize,true)
40
- @class_instance.send(:after_initialize)
41
- end
42
39
  @class_instance.__send__(method_name,*args,&block)
43
40
  end
44
41
 
@@ -18,16 +18,12 @@ module Lolita
18
18
  # Also eahc request containers information with mapping related to it.
19
19
  class Mapping
20
20
  attr_reader :class_name,:path,:singular,:plural,:path_prefix,:module,:controllers,:as
21
- attr_reader :visible, :only, :append_to
22
21
  alias :name :singular
23
22
 
24
23
 
25
24
  def initialize(name,options={})
26
25
  # TODO how it is when lolita plugin extend default path and there is module is this not break the logic?
27
26
  @as=options[:as]
28
- @visible = options.keys.include?(:visible) ? options[:visible] : true
29
- @append_to = options[:append_to]
30
- @only = options[:only] || nil
31
27
  @plural=(options[:as] ? options[:as] : name).to_sym
32
28
  @singular=(options[:singular] || @plural.to_s.singularize).to_sym
33
29
  @class_name=(options[:class_name] || name.to_s.classify).to_s
@@ -54,25 +50,6 @@ module Lolita
54
50
  def url_name #TODO test what with namespace
55
51
  "#{@path}_#{@plural}"
56
52
  end
57
-
58
- def add_to_navigation_tree
59
- tree = Lolita::Navigation::Tree[:"left_side_navigation"]
60
- if self.visible
61
- if self.append_to
62
- parent_branch = tree.branches.detect{|b| b.options[:system_name] == self.append_to}
63
- unless parent_branch
64
- parent_branch = tree.append(nil,:title => lambda{|branch|
65
- return ::I18n.t("lolita.navigation." + branch.options[:system_name])
66
- }, :system_name => self.append_to
67
- )
68
- end
69
- tree = parent_branch.children
70
- end
71
- unless tree.branches.detect{|b| b.object.is_a?(Lolita::Mapping) && b.object.to==self.to}
72
- tree.append(self)
73
- end
74
- end
75
- end
76
53
 
77
54
  end
78
55
  end
@@ -2,7 +2,7 @@ module ActionDispatch::Routing
2
2
  class Mapper
3
3
  protected
4
4
  def lolita_rest_route mapping, controllers
5
- resources mapping.plural,:only=>mapping.only.is_a?(Array) ? mapping.only : [:index,:new,:create,:edit,:update,:destroy],
5
+ resources mapping.plural,:only=>[:index,:new,:create,:edit,:update,:destroy],
6
6
  :controller=>controllers[:rest],:module=>mapping.module
7
7
  end
8
8
  end
@@ -2,9 +2,8 @@ module Lolita
2
2
  module Navigation
3
3
  class Branch
4
4
 
5
- attr_accessor :name,:object
5
+ attr_accessor :title,:name,:object
6
6
  attr_reader :level,:options,:tree,:parent
7
- attr_writer :title
8
7
 
9
8
  def initialize(*args)
10
9
 
@@ -14,22 +13,6 @@ module Lolita
14
13
  assign_attributes_from_options
15
14
  end
16
15
 
17
- def method_missing method_name, *args
18
- if @options.keys.include?(method_name) || @options.keys.include?(method_name.to_s)
19
- @options[method_name] || @options[method_name.to_s]
20
- else
21
- super
22
- end
23
- end
24
-
25
- def title
26
- if @title && @title.respond_to?(:call)
27
- @title.call(self)
28
- else
29
- @title || self.object.to.model_name.human(:count=>2)
30
- end
31
- end
32
-
33
16
  def tree=(new_tree)
34
17
  raise ArgumentError, "Tree already assigned" if self.tree || !new_tree.is_a?(Lolita::Navigation::Tree)
35
18
  @tree=new_tree
@@ -59,10 +42,6 @@ module Lolita
59
42
  self.tree.get_branch_index(self)
60
43
  end
61
44
 
62
- def subtree?
63
- self.children.branches.any?
64
- end
65
-
66
45
  def siblings
67
46
  index=self.index
68
47
  {
@@ -87,34 +66,6 @@ module Lolita
87
66
  move_to(:prepend,*args)
88
67
  end
89
68
 
90
- def active?(view)
91
- resource = view.respond_to?(:resource_class) ? view.send(:resource_class) : nil rescue nil
92
- request = view.send(:request)
93
- self_active = if self.object.is_a?(Lolita::Mapping) && self.object && self.object.to == resource
94
- true
95
- elsif self.options[:active].respond_to?(:call)
96
- self.options[:active].call(view,self)
97
- elsif self.options[:url]
98
- self.options[:url] == request.path
99
- end
100
- self_active || (self.children.any? && self.children.branches.detect{|c_branch| c_branch.active?(view)})
101
- end
102
-
103
- def visible?(view)
104
- self_visible = if self.object && self.object.respond_to?(:to)
105
- view.send(:can?,:read,self.object.to)
106
- elsif self.options[:visible]
107
- if self.options[:visible].respond_to?(:call)
108
- self.options[:visible].call(view,self,branch)
109
- else
110
- self.options[:visible]
111
- end
112
- else
113
- true
114
- end
115
- self_visible && (self.children.any? && self.children.visible?(view) || self.children.empty?)
116
- end
117
-
118
69
  def self.get_or_create(*args)
119
70
  options=args ? args.extract_options! : {}
120
71
  args||=[]
@@ -174,8 +125,6 @@ module Lolita
174
125
  @options.each{|key,value|
175
126
  if self.respond_to?(:"#{key}=")
176
127
  self.send(:"#{key}=",@options.delete(key))
177
- else
178
- self.options[key] = value
179
128
  end
180
129
  }
181
130
  end