netzke-core 0.6.7 → 0.7.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.
- data/CHANGELOG.rdoc +36 -1
- data/{README.markdown → README.md} +17 -15
- data/Rakefile +1 -1
- data/TODO +4 -4
- data/app/controllers/netzke_controller.rb +8 -3
- data/javascripts/base.js +71 -68
- data/javascripts/ext.js +182 -111
- data/lib/netzke/actions.rb +2 -1
- data/lib/netzke/base.rb +5 -1
- data/lib/netzke/composition.rb +2 -2
- data/lib/netzke/configuration.rb +1 -1
- data/lib/netzke/core/dynamic_assets.rb +7 -7
- data/lib/netzke/core/session.rb +4 -0
- data/lib/netzke/core/version.rb +2 -2
- data/lib/netzke/core.rb +23 -30
- data/lib/netzke/core_ext/symbol.rb +1 -1
- data/lib/netzke/embedding.rb +1 -1
- data/lib/netzke/ext_component.rb +2 -2
- data/lib/netzke/javascript.rb +70 -39
- data/lib/netzke/plugin.rb +15 -0
- data/lib/netzke/plugins.rb +29 -0
- data/lib/netzke/railz/action_view_ext/ext.rb +13 -16
- data/lib/netzke/railz/action_view_ext/touch.rb +3 -3
- data/lib/netzke/railz/action_view_ext.rb +0 -3
- data/lib/netzke/railz/engine.rb +34 -29
- data/lib/netzke/services.rb +1 -1
- data/lib/netzke/state.rb +2 -2
- data/lib/netzke-core.rb +1 -0
- data/netzke-core.gemspec +108 -9
- data/stylesheets/core.css +25 -5
- data/test/rails_app/Gemfile +1 -1
- data/test/rails_app/Gemfile.lock +37 -36
- data/test/rails_app/app/components/component_loader.rb +36 -24
- data/test/rails_app/app/components/component_with_js_mixin/javascripts/component_with_js_mixin.js +5 -0
- data/test/rails_app/app/components/component_with_js_mixin.rb +3 -1
- data/test/rails_app/app/components/component_with_nested_through.rb +28 -0
- data/test/rails_app/app/components/component_with_session_persistence.rb +7 -5
- data/test/rails_app/app/components/dynamic_tab_panel/javascripts/dynamic_tab_panel.js +9 -0
- data/test/rails_app/app/components/dynamic_tab_panel.rb +19 -0
- data/test/rails_app/app/components/extended_server_caller.rb +6 -5
- data/test/rails_app/app/components/loader_of_component_with_custom_css.rb +7 -8
- data/test/rails_app/app/components/localized_panel.rb +10 -1
- data/test/rails_app/app/components/nested_component.rb +18 -0
- data/test/rails_app/app/components/panel_with_plugin.rb +4 -0
- data/test/rails_app/app/components/panel_with_tools.rb +19 -0
- data/test/rails_app/app/components/plugin_with_components.rb +14 -0
- data/test/rails_app/app/components/server_caller.rb +1 -1
- data/test/rails_app/app/components/server_counter.rb +1 -1
- data/test/rails_app/app/components/simple_component.rb +2 -0
- data/test/rails_app/app/components/simple_tab_panel.rb +21 -21
- data/test/rails_app/app/components/simple_window.rb +1 -1
- data/test/rails_app/app/components/some_composite.rb +3 -2
- data/test/rails_app/app/components/some_plugin.rb +39 -0
- data/test/rails_app/app/controllers/application_controller.rb +1 -1
- data/test/rails_app/app/controllers/components_controller.rb +1 -1
- data/test/rails_app/app/views/layouts/touch.html.erb +1 -1
- data/test/rails_app/config/application.rb +0 -2
- data/test/rails_app/config/initializers/netzke.rb +2 -1
- data/test/rails_app/config/locales/es.yml +1 -0
- data/test/rails_app/features/{actions.feature → actions_and_tools.feature} +8 -0
- data/test/rails_app/features/client-server.feature +0 -1
- data/test/rails_app/features/complex_component.feature +1 -1
- data/test/rails_app/features/component_loader.feature +7 -0
- data/test/rails_app/features/composition.feature +2 -2
- data/test/rails_app/features/custom_css.feature +1 -1
- data/test/rails_app/features/i18n.feature +3 -0
- data/test/rails_app/features/js_include.feature +2 -0
- data/test/rails_app/features/nested_views.feature +5 -4
- data/test/rails_app/features/plugin.feature +16 -0
- data/test/rails_app/features/step_definitions/generic_steps.rb +21 -2
- data/test/rails_app/features/touch.feature +10 -10
- data/test/rails_app/spec/component/component_spec.rb +20 -0
- metadata +106 -10
- data/app/models/netzke_preference.rb +0 -170
data/lib/netzke/core.rb
CHANGED
@@ -23,11 +23,14 @@ module Netzke
|
|
23
23
|
extend Session
|
24
24
|
extend Masquerading
|
25
25
|
|
26
|
+
# Use Ext 3 compatibility layer
|
27
|
+
mattr_accessor :ext3_compat_uri
|
28
|
+
|
26
29
|
# Configuration specified at the initialization times (set in the Engine in case of Rails)
|
27
30
|
mattr_accessor :config
|
28
31
|
@@config = {}
|
29
32
|
|
30
|
-
#
|
33
|
+
# :ext or :touch
|
31
34
|
mattr_accessor :platform
|
32
35
|
@@platform = :ext
|
33
36
|
|
@@ -44,12 +47,6 @@ module Netzke
|
|
44
47
|
mattr_accessor :ext_stylesheets
|
45
48
|
@@ext_stylesheets = []
|
46
49
|
|
47
|
-
mattr_accessor :touch_javascripts
|
48
|
-
@@touch_javascripts = []
|
49
|
-
|
50
|
-
mattr_accessor :touch_stylesheets
|
51
|
-
@@touch_stylesheets = []
|
52
|
-
|
53
50
|
# Stylesheets that cannot be loaded dynamically along with the rest of the component, e.g. due to that relative paths are used in them
|
54
51
|
mattr_accessor :external_ext_css
|
55
52
|
@@external_ext_css = []
|
@@ -57,22 +54,35 @@ module Netzke
|
|
57
54
|
mattr_accessor :icons_uri
|
58
55
|
@@icons_uri = "/images/icons"
|
59
56
|
|
57
|
+
mattr_accessor :ext_uri
|
58
|
+
@@ext_uri = "/extjs"
|
59
|
+
|
60
|
+
mattr_accessor :ext_path
|
61
|
+
|
62
|
+
mattr_accessor :current_user_method
|
63
|
+
@@current_user_method = :current_user
|
64
|
+
|
60
65
|
mattr_accessor :persistence_manager
|
61
66
|
@@persistence_manager = "NetzkeComponentState"
|
62
67
|
|
63
68
|
# The amount of retries that the direct remoting provider will attempt in case of failure
|
64
69
|
mattr_accessor :js_direct_max_retries
|
65
|
-
@@js_direct_max_retries =
|
66
|
-
|
67
|
-
# Set in the Engine after_initialize callback
|
68
|
-
mattr_accessor :ext_location # TODO: rename to ext_path
|
69
|
-
|
70
|
-
mattr_accessor :touch_location # TODO: rename to touch_path
|
70
|
+
@@js_direct_max_retries = 2
|
71
71
|
|
72
72
|
mattr_accessor :with_icons
|
73
73
|
|
74
74
|
mattr_accessor :persistence_manager_class
|
75
75
|
|
76
|
+
# Sencha Touch specific
|
77
|
+
mattr_accessor :touch_javascripts
|
78
|
+
@@touch_javascripts = []
|
79
|
+
|
80
|
+
mattr_accessor :touch_stylesheets
|
81
|
+
@@touch_stylesheets = []
|
82
|
+
|
83
|
+
mattr_accessor :touch_uri
|
84
|
+
@@touch_uri = "/sencha-touch"
|
85
|
+
|
76
86
|
def self.setup
|
77
87
|
yield self
|
78
88
|
end
|
@@ -80,22 +90,5 @@ module Netzke
|
|
80
90
|
def self.reset_components_in_session
|
81
91
|
Netzke::Core.session[:netzke_components].try(:clear)
|
82
92
|
end
|
83
|
-
|
84
|
-
def self.ext_js
|
85
|
-
res = initial_dynamic_javascript << "\n"
|
86
|
-
|
87
|
-
include_base_js(res)
|
88
|
-
|
89
|
-
# Ext-specific JavaScript
|
90
|
-
res << File.new(File.expand_path("../../../javascripts/ext.js", __FILE__)).read
|
91
|
-
|
92
|
-
# Pluggable JavaScript (used by other Netzke-powered gems like netzke-basepack)
|
93
|
-
Netzke::Core.ext_javascripts.each do |path|
|
94
|
-
f = File.new(path)
|
95
|
-
res << f.read
|
96
|
-
end
|
97
|
-
|
98
|
-
render :text => defined?(::Rails) && ::Rails.env.production? ? res.strip_js_comments : res
|
99
|
-
end
|
100
93
|
end
|
101
94
|
end
|
data/lib/netzke/embedding.rb
CHANGED
data/lib/netzke/ext_component.rb
CHANGED
@@ -13,7 +13,7 @@ module Netzke
|
|
13
13
|
|
14
14
|
# Rendering
|
15
15
|
def js_component_render
|
16
|
-
%Q{Ext.
|
16
|
+
%Q{Ext.ComponentManager.create("#{js_full_class_name}", #{config.to_nifty_json}).render("ext-#{name.to_s.split('_').join('-')}");}
|
17
17
|
end
|
18
18
|
|
19
19
|
# Container for rendering
|
@@ -22,4 +22,4 @@ module Netzke
|
|
22
22
|
end
|
23
23
|
|
24
24
|
end
|
25
|
-
end
|
25
|
+
end
|
data/lib/netzke/javascript.rb
CHANGED
@@ -157,7 +157,9 @@ module Netzke
|
|
157
157
|
# }
|
158
158
|
#
|
159
159
|
# Also accepts a string, which will be interpreted as a full path to the file (useful for sharing mixins between classes).
|
160
|
+
# With no parameters, will assume :component_class_name_underscored.
|
160
161
|
def js_mixin(*args)
|
162
|
+
args << name.split("::").last.underscore.to_sym if args.empty? # if no args provided, component_class_underscored_name is assumed
|
161
163
|
current_mixins = read_clean_inheritable_array(:js_mixins) || []
|
162
164
|
callr = caller.first
|
163
165
|
args.each{ |a| current_mixins << (a.is_a?(Symbol) ? File.read(expand_js_include_path(a, callr)) : File.read(a))}
|
@@ -175,6 +177,20 @@ module Netzke
|
|
175
177
|
name.gsub("::", "").downcase
|
176
178
|
end
|
177
179
|
|
180
|
+
# Alias prefix. Overridden for plugins.
|
181
|
+
def js_alias_prefix
|
182
|
+
"widget"
|
183
|
+
end
|
184
|
+
|
185
|
+
# Builds this component's alias
|
186
|
+
# E.g.: netzke.basepack.window, netzke.basepack.gridpanel
|
187
|
+
#
|
188
|
+
# MAV from http://stackoverflow.com/questions/5380770/replacing-ext-reg-xtype-in-extjs4
|
189
|
+
# "When you use an xtype in Ext JS 4 it looks for a class with an alias of 'widget.[xtype]'"
|
190
|
+
def js_alias
|
191
|
+
[js_alias_prefix, js_xtype].join(".")
|
192
|
+
end
|
193
|
+
|
178
194
|
# Component's JavaScript class declaration.
|
179
195
|
# It gets stored in the JS class cache storage (Netzke.classes) at the client side to be reused at the moment of component instantiation.
|
180
196
|
def js_class
|
@@ -184,7 +200,10 @@ module Netzke
|
|
184
200
|
|
185
201
|
res << (extends_netzke_component? ? js_class_declaration_extending_component : js_class_declaration_new_component)
|
186
202
|
|
187
|
-
|
203
|
+
# Store created class xtype in the cache
|
204
|
+
res << %(
|
205
|
+
Netzke.cache.push('#{js_xtype}');
|
206
|
+
)
|
188
207
|
|
189
208
|
res.join("\n")
|
190
209
|
end
|
@@ -232,13 +251,16 @@ module Netzke
|
|
232
251
|
# Generates declaration of the JS class as direct extension of a Ext component
|
233
252
|
def js_class_declaration_new_component
|
234
253
|
mixins = js_mixins.empty? ? "" : %(#{js_mixins.join(", \n")}, )
|
235
|
-
%(#{js_full_class_name} = function(config){
|
236
|
-
Netzke.aliasMethodChain(this, "initComponent", "netzke");
|
237
|
-
#{js_full_class_name}.superclass.constructor.call(this, config);
|
238
|
-
};
|
239
254
|
|
240
|
-
|
241
|
-
|
255
|
+
# Resulting JS:
|
256
|
+
%(Ext.define('#{js_full_class_name}', Netzke.chainApply({
|
257
|
+
extend: '#{js_base_class}',
|
258
|
+
alias: '#{js_alias}',
|
259
|
+
constructor: function(config) {
|
260
|
+
Netzke.aliasMethodChain(this, "initComponent", "netzke");
|
261
|
+
#{js_full_class_name}.superclass.constructor.call(this, config);
|
262
|
+
}
|
263
|
+
}, Netzke.componentMixin,\n#{mixins} #{js_extend_properties.to_nifty_json}));)
|
242
264
|
end
|
243
265
|
|
244
266
|
# Generates declaration of the JS class as extension of another Netzke component
|
@@ -247,7 +269,11 @@ module Netzke
|
|
247
269
|
|
248
270
|
mixins = js_mixins.empty? ? "" : %(#{js_mixins.join(", \n")}, )
|
249
271
|
|
250
|
-
|
272
|
+
# Resulting JS:
|
273
|
+
%(Ext.define('#{js_full_class_name}', Netzke.chainApply(#{mixins}#{js_extend_properties.to_nifty_json}, {
|
274
|
+
extend: '#{base_class}',
|
275
|
+
alias: '#{js_alias}'
|
276
|
+
}));)
|
251
277
|
end
|
252
278
|
|
253
279
|
def expand_js_include_path(sym, callr) # :nodoc:
|
@@ -261,51 +287,56 @@ module Netzke
|
|
261
287
|
end
|
262
288
|
|
263
289
|
module InstanceMethods
|
264
|
-
# The result of this method (a hash) is converted to a JSON object and passed as
|
290
|
+
# The result of this method (a hash) is converted to a JSON object and passed as options
|
265
291
|
# to the constructor of our JavaScript class. Override it when you want to pass any extra configuration
|
266
292
|
# to the JavaScript side.
|
267
293
|
def js_config
|
268
|
-
|
294
|
+
{}.tap do |res|
|
295
|
+
# Unique id of the component
|
296
|
+
res[:id] = global_id
|
297
|
+
|
298
|
+
# Non-lazy-loaded components
|
299
|
+
comp_hash = {}
|
300
|
+
eager_loaded_components.each_pair do |comp_name, comp_config|
|
301
|
+
comp_instance = component_instance(comp_name.to_sym)
|
302
|
+
comp_instance.before_load
|
303
|
+
comp_hash[comp_name] = comp_instance.js_config
|
304
|
+
end
|
269
305
|
|
270
|
-
|
271
|
-
|
306
|
+
# Configuration for all of our non-lazy-loaded children specified here. We can refer to them in +items+ so they get instantiated by Ext.
|
307
|
+
res[:netzke_components] = comp_hash unless comp_hash.empty?
|
272
308
|
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
comp_instance = component_instance(comp_name.to_sym)
|
277
|
-
comp_instance.before_load
|
278
|
-
comp_hash[comp_name] = comp_instance.js_config
|
279
|
-
end
|
309
|
+
# Endpoints (besides the default "deliver_component" - JavaScript side already knows about it)
|
310
|
+
endpoints = self.class.endpoints.keys - [:deliver_component]
|
311
|
+
res[:endpoints] = endpoints unless endpoints.empty?
|
280
312
|
|
281
|
-
|
282
|
-
|
283
|
-
res[:components] = comp_hash unless comp_hash.empty?
|
313
|
+
# Inform the JavaScript side if persistent_config is enabled
|
314
|
+
# res[:persistent_config] = persistence_enabled?
|
284
315
|
|
285
|
-
|
286
|
-
|
287
|
-
res[:endpoints] = endpoints unless endpoints.empty?
|
316
|
+
# Include our xtype
|
317
|
+
res[:xtype] = self.class.js_xtype
|
288
318
|
|
289
|
-
|
290
|
-
|
319
|
+
# Include our alias: Ext.createByAlias may be used to instantiate the component.
|
320
|
+
res[:alias] = self.class.js_alias
|
291
321
|
|
292
|
-
|
293
|
-
|
322
|
+
# Merge with the rest of config options, besides those that are only meant for the server side
|
323
|
+
res.merge!(config.reject{ |k,v| self.class.server_side_config_options.include?(k.to_sym) })
|
294
324
|
|
295
|
-
|
296
|
-
|
325
|
+
if config[:ext_config].present?
|
326
|
+
::ActiveSupport::Deprecation.warn("Using ext_config option is deprecated. All config options must be specified at the same level in the hash.", caller)
|
327
|
+
res.merge!(config[:ext_config])
|
328
|
+
end
|
297
329
|
|
298
|
-
|
299
|
-
|
300
|
-
res.merge!(config[:ext_config])
|
301
|
-
end
|
330
|
+
# Items (nested Ext/Netzke components)
|
331
|
+
res[:items] = items unless items.blank?
|
302
332
|
|
303
|
-
|
304
|
-
|
333
|
+
# So we can use getComponent(<component_name>) to retrieve a child component
|
334
|
+
res[:item_id] ||= name
|
305
335
|
|
306
|
-
|
336
|
+
res[:i18n] = js_translate_properties if js_translate_properties.present?
|
307
337
|
|
308
|
-
|
338
|
+
res[:netzke_plugins] = plugins.map{ |p| p.to_s.camelcase(:lower) } if plugins.present?
|
339
|
+
end
|
309
340
|
end
|
310
341
|
|
311
342
|
# All the JS-code required by this instance of the component to be instantiated in the browser.
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Netzke
|
2
|
+
module Plugins
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
module ClassMethods
|
6
|
+
# Defines a plugin
|
7
|
+
def plugin(name, config = {}, &block)
|
8
|
+
component(name, config, &block)
|
9
|
+
register_plugin(name)
|
10
|
+
end
|
11
|
+
|
12
|
+
# Register a plugin
|
13
|
+
def register_plugin(name)
|
14
|
+
current_plugins = read_inheritable_attribute(:plugins) || []
|
15
|
+
current_plugins << name
|
16
|
+
write_inheritable_attribute(:plugins, current_plugins.uniq)
|
17
|
+
end
|
18
|
+
|
19
|
+
# Returns registered plugins
|
20
|
+
def registered_plugins
|
21
|
+
read_inheritable_attribute(:plugins) || []
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def plugins
|
26
|
+
self.class.registered_plugins
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -8,10 +8,7 @@ module Netzke
|
|
8
8
|
|
9
9
|
def netzke_ext_css_include(params)
|
10
10
|
# ExtJS base
|
11
|
-
res = ["/
|
12
|
-
|
13
|
-
# ExtJS theming
|
14
|
-
res << "/extjs/resources/css/xtheme-#{params[:theme]}" if params[:theme]
|
11
|
+
res = ["#{Netzke::Core.ext_uri}/resources/css/ext-all"]
|
15
12
|
|
16
13
|
# Netzke-related dynamic css
|
17
14
|
res << "/netzke/ext"
|
@@ -22,19 +19,20 @@ module Netzke
|
|
22
19
|
end
|
23
20
|
|
24
21
|
def netzke_ext_js_include(params)
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
"/extjs/ext-all"
|
35
|
-
]
|
22
|
+
res = []
|
23
|
+
|
24
|
+
# ExtJS
|
25
|
+
res << (ENV['RAILS_ENV'] == 'development' ? ["#{Netzke::Core.ext_uri}/ext-all-debug"] : ["#{Netzke::Core.ext_uri}/ext-all"])
|
26
|
+
|
27
|
+
# ExtJS 3 compatibility layer
|
28
|
+
if compat_uri = Netzke::Core.ext3_compat_uri
|
29
|
+
res << "#{compat_uri}/ext3-core-compat"
|
30
|
+
res << "#{compat_uri}/ext3-compat"
|
36
31
|
end
|
37
32
|
|
33
|
+
# Ext I18n
|
34
|
+
res << "#{Netzke::Core.ext_uri}/locale/ext-lang-#{I18n.locale}" if I18n.locale != :en
|
35
|
+
|
38
36
|
# Netzke-related dynamic JavaScript
|
39
37
|
res << "/netzke/ext"
|
40
38
|
|
@@ -44,7 +42,6 @@ module Netzke
|
|
44
42
|
def netzke_ext_js(params)
|
45
43
|
res = []
|
46
44
|
res << content_for(:netzke_js_classes)
|
47
|
-
res << "\n"
|
48
45
|
|
49
46
|
res << "Ext.onReady(function(){"
|
50
47
|
res << content_for(:netzke_on_ready)
|
@@ -9,7 +9,7 @@ module Netzke
|
|
9
9
|
def netzke_touch_css_include(params)
|
10
10
|
# Note: no themes for now
|
11
11
|
|
12
|
-
res = stylesheet_link_tag("/
|
12
|
+
res = stylesheet_link_tag("#{Netzke::Core.touch_uri}/resources/css/sencha-touch")
|
13
13
|
|
14
14
|
# Netzke-related (dynamically generated by NetzkeController)
|
15
15
|
res << "\n" << stylesheet_link_tag("/netzke/touch")
|
@@ -35,9 +35,9 @@ module Netzke
|
|
35
35
|
def netzke_touch_js_include(params)
|
36
36
|
# ExtJS
|
37
37
|
res = if ENV['RAILS_ENV'] == 'development'
|
38
|
-
["/sencha-touch
|
38
|
+
["#{Netzke::Core.touch_uri}/sencha-touch-debug.js"]
|
39
39
|
else
|
40
|
-
["/sencha-touch
|
40
|
+
["#{Netzke::Core.touch_uri}/sencha-touch"]
|
41
41
|
end
|
42
42
|
|
43
43
|
# Netzke
|
@@ -22,9 +22,6 @@ module Netzke
|
|
22
22
|
Netzke::Core.platform = params[:platform] || :ext
|
23
23
|
theme = params[:theme] || params[:ext_theme]
|
24
24
|
|
25
|
-
# Rails' forgery protection
|
26
|
-
content_for :netzke_js_classes, %Q(\n\nExt.Ajax.extraParams = {authenticity_token: '#{form_authenticity_token}'};)
|
27
|
-
|
28
25
|
raw([netzke_css_include(params), netzke_css(params), netzke_js_include(params), netzke_js(params)].join("\n"))
|
29
26
|
end
|
30
27
|
|
data/lib/netzke/railz/engine.rb
CHANGED
@@ -3,41 +3,46 @@ module Netzke
|
|
3
3
|
class Engine < Rails::Engine
|
4
4
|
config.netzke = Netzke::Core::OptionsHash.new
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
6
|
+
initializer "netzke.core" do |app|
|
7
|
+
app.config.eager_load_paths -= ["#{app.config.root}/app/components"]
|
8
|
+
app.config.autoload_paths += ["#{app.config.root}/app/components"]
|
9
|
+
end
|
10
|
+
|
11
|
+
# before loading initializers
|
12
|
+
config.before_initialize do |app|
|
13
|
+
Netzke::Core.config = config.netzke # passing app-level config to Netzke::Core
|
11
14
|
Netzke::Core.persistence_manager_class = Netzke::Core.persistence_manager.constantize rescue nil
|
12
15
|
end
|
13
16
|
|
14
|
-
# after loading initializers
|
17
|
+
# after loading initializers
|
15
18
|
config.after_initialize do
|
19
|
+
Netzke::Core.ext_path = Rails.root.join('public', Netzke::Core.ext_uri[1..-1])
|
16
20
|
Netzke::Core.with_icons = File.exists?("#{::Rails.root}/public#{Netzke::Core.icons_uri}") if Netzke::Core.with_icons.nil?
|
17
21
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
22
|
+
# Dynamic generation of Netzke js and css.
|
23
|
+
# WIP: the problem with this is that on Heroku, for example, you don't have write access to 'public'.
|
24
|
+
# dynamic_assets = %w[ext.js ext.css touch.js touch.css]
|
25
|
+
#
|
26
|
+
# if Rails.configuration.cache_classes
|
27
|
+
# # Memoize Netzke::Base.constantize_class_name for performance
|
28
|
+
# class << Netzke::Base
|
29
|
+
# memoize :constantize_class_name
|
30
|
+
# end
|
31
|
+
#
|
32
|
+
# # Generate dynamic assets and put them into public/netzke
|
33
|
+
# require 'fileutils'
|
34
|
+
# FileUtils.mkdir_p(Rails.root.join('public', 'netzke'))
|
35
|
+
#
|
36
|
+
# dynamic_assets.each do |asset|
|
37
|
+
# File.open(Rails.root.join('public', 'netzke', asset), 'w') {|f| f.write(Netzke::Core::DynamicAssets.send(asset.sub(".", "_"))) }
|
38
|
+
# end
|
39
|
+
# else
|
40
|
+
# dynamic_assets.each do |asset|
|
41
|
+
# file_path = Rails.root.join('public', 'netzke', asset)
|
42
|
+
# File.delete(file_path) if File.exists?(file_path)
|
43
|
+
# end
|
44
|
+
# end
|
40
45
|
end
|
41
46
|
end
|
42
47
|
end
|
43
|
-
end
|
48
|
+
end
|
data/lib/netzke/services.rb
CHANGED
data/lib/netzke/state.rb
CHANGED
@@ -71,7 +71,7 @@ module Netzke
|
|
71
71
|
|
72
72
|
# Initialized state manager class. At this moment this class has current_user, component, and session set.
|
73
73
|
def state_manager
|
74
|
-
|
74
|
+
Netzke::Core.persistence_manager_class && Netzke::Core.persistence_manager_class.init({
|
75
75
|
:component => persistence_key,
|
76
76
|
:current_user => Netzke::Core.controller.respond_to?(:current_user) && Netzke::Core.controller.current_user,
|
77
77
|
:session => Netzke::Core.session
|
@@ -80,7 +80,7 @@ module Netzke
|
|
80
80
|
|
81
81
|
# Initialized state manager class, configured for managing global (not component specific) settings. At this moment this class has current_user and session set.
|
82
82
|
def global_state_manager
|
83
|
-
|
83
|
+
Netzke::Core.persistence_manager_class && Netzke::Core.persistence_manager_class.init({
|
84
84
|
:current_user => Netzke::Core.controller.respond_to?(:current_user) && Netzke::Core.controller.current_user,
|
85
85
|
:session => Netzke::Core.session
|
86
86
|
})
|