netzke-core 0.12.3 → 1.0.0.0.pre

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 (41) hide show
  1. data/CHANGELOG.md +65 -607
  2. data/Gemfile +1 -1
  3. data/LICENSE +2 -6
  4. data/README.md +77 -145
  5. data/javascripts/base.js +582 -96
  6. data/javascripts/core.js +62 -0
  7. data/javascripts/notifications.js +43 -0
  8. data/javascripts/remoting_provider.js +29 -0
  9. data/javascripts/routing.js +63 -0
  10. data/lib/netzke/base.rb +16 -83
  11. data/lib/netzke/core/action_config.rb +1 -5
  12. data/lib/netzke/core/actions.rb +59 -21
  13. data/lib/netzke/core/{client_class.rb → client_class_config.rb} +81 -73
  14. data/lib/netzke/core/client_code.rb +157 -0
  15. data/lib/netzke/core/component_config.rb +2 -2
  16. data/lib/netzke/core/composition.rb +85 -65
  17. data/lib/netzke/core/configuration.rb +26 -14
  18. data/lib/netzke/core/core_i18n.rb +17 -0
  19. data/lib/netzke/core/css_config.rb +6 -6
  20. data/lib/netzke/core/dynamic_assets.rb +17 -24
  21. data/lib/netzke/core/embedding.rb +2 -2
  22. data/lib/netzke/core/endpoint_response.rb +8 -2
  23. data/lib/netzke/core/inheritance.rb +33 -0
  24. data/lib/netzke/core/plugins.rb +1 -4
  25. data/lib/netzke/core/railz/action_view_ext.rb +1 -1
  26. data/lib/netzke/core/railz/controller_extensions.rb +21 -15
  27. data/lib/netzke/core/services.rb +61 -48
  28. data/lib/netzke/core/session.rb +0 -2
  29. data/lib/netzke/core/state.rb +11 -9
  30. data/lib/netzke/core/stylesheets.rb +3 -3
  31. data/lib/netzke/core/version.rb +1 -1
  32. data/lib/netzke/core.rb +3 -3
  33. data/lib/netzke/plugin.rb +2 -6
  34. data/stylesheets/core.css +2 -2
  35. metadata +11 -10
  36. data/TODO.md +0 -9
  37. data/javascripts/ext.js +0 -518
  38. data/lib/netzke/core/config_to_dsl_delegator.rb +0 -62
  39. data/lib/netzke/core/dsl_support.rb +0 -70
  40. data/lib/netzke/core/html.rb +0 -29
  41. data/lib/netzke/core/javascript.rb +0 -123
@@ -1,123 +0,0 @@
1
- module Netzke::Core
2
- # Client class definition and instantiation.
3
- #
4
- # == JavaScript instance methods
5
- #
6
- # The following public JavaScript methods are defined on (mixed-in into) all Netzke components (for detailed documentation on them see the inline documentation in javascript/base.js and javascript/ext.js files):
7
- # * netzkeLoadComponent - dynamically loads a child Netzke component
8
- # * netzkeInstantiateComponent - instantiates and returns a Netzke component by its item_id
9
- # * netzkeFeedback - shows a feedback message
10
- # * componentNotInSession - gets called when the session that the component is defined in gets expired. Override it to do whatever is appropriate.
11
- module Javascript
12
- extend ActiveSupport::Concern
13
-
14
- module ClassMethods
15
- # Configures JS class
16
- # Example:
17
- #
18
- # js_configure do |c|
19
- # # c is an instance of ClientClass
20
- # c.title = "My title"
21
- # c.mixin
22
- # c.require :extra_js
23
- # # ...etc
24
- # end
25
- #
26
- # For more details see {Netzke::Core::ClientClass}
27
- def js_configure &block
28
- @js_configure_blocks ||= []
29
- @js_configure_blocks << block
30
- end
31
-
32
- # Class-level client class config
33
- def js_config
34
- return @js_config if @js_config.present?
35
- @js_config = Netzke::Core::ClientClass.new(self)
36
- @js_config.tap do |c|
37
- (@js_configure_blocks || []).each{|block| block.call(c)}
38
- end
39
- end
40
- end
41
-
42
- # Builds {#js_config} used for instantiating a client class. Override it when you need to extend/modify the config for the JS component intance. It's *not* being called when the *server* class is being instantiated (e.g. to process an endpoint call). With other words, it's only being called before a component is first being loaded in the browser. so, it's ok to do heavy stuf fhere, like building a tree panel nodes from the database.
43
- def js_configure(c)
44
- c.merge!(normalized_config)
45
-
46
- %w[id item_id path netzke_components endpoints xtype alias i18n netzke_plugins flash].each do |thing|
47
- js_thing = send(:"js_#{thing}")
48
- c[thing] = js_thing if js_thing.present?
49
- end
50
-
51
- # reset component session
52
- # TODO: also remove empty hashes from the global session
53
- component_session.clear
54
- end
55
-
56
- def js_path
57
- @path
58
- end
59
-
60
- def js_xtype
61
- self.class.js_config.xtype
62
- end
63
-
64
- def js_item_id
65
- @item_id
66
- end
67
-
68
- # Ext.createByAlias may be used to instantiate the component.
69
- def js_alias
70
- self.class.js_config.class_alias
71
- end
72
-
73
- # Endpoints (besides the default "deliver_component" - JavaScript side already knows about it)
74
- def js_endpoints
75
- self.class.endpoints.keys - [:deliver_component]
76
- end
77
-
78
- def js_netzke_plugins
79
- plugins.map{ |p| p.to_s.camelcase(:lower) }
80
- end
81
-
82
- # TODO: get rid of this in 0.9
83
- def js_flash
84
- session && session[:flash]
85
- end
86
-
87
- # Instance-level client class config. The result of this method (a hash) is converted to a JSON object and passed as options to the constructor of our JavaScript class.
88
- # Not to be overridden, override {#js_configure} instead.
89
- def js_config
90
- @js_config ||= ActiveSupport::OrderedOptions.new.tap{|c| js_configure(c)}
91
- end
92
-
93
- # Hash containing configuration for all child components to be instantiated at the JS side
94
- def js_components
95
- @js_components ||= eagerly_loaded_components.inject({}) do |out, (name, config)|
96
- instance = component_instance(name.to_sym)
97
- out.merge(name => instance.js_config)
98
- end
99
- end
100
-
101
- alias js_netzke_components js_components
102
-
103
- # All the JS-code required by this instance of the component to be instantiated in the browser.
104
- # It includes JS-classes for the parents, eagerly loaded child components, and itself.
105
- def js_missing_code(cached = [])
106
- code = dependency_classes.inject("") do |r,k|
107
- cached.include?(k.js_config.xtype) ? r : r + k.js_config.code_with_dependencies
108
- end
109
- code.blank? ? nil : Netzke::Core::DynamicAssets.minify_js(code)
110
- end
111
-
112
- private
113
-
114
- # Merges all the translations in the class hierarchy
115
- # Note: this method can't be moved out to ClientClass, because I18n is loaded only once, when other Ruby classes are evaluated; so, this must remain at instance level.
116
- def js_i18n
117
- @js_i18n ||= self.class.netzke_ancestors.inject({}) do |r,klass|
118
- hsh = klass.js_config.translated_properties.inject({}) { |h,t| h.merge(t => I18n.t("#{klass.i18n_id}.#{t}")) }
119
- r.merge(hsh)
120
- end
121
- end
122
- end
123
- end