netzke-core 0.6.4 → 0.6.5
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +19 -0
- data/README.markdown +43 -0
- data/TODO +1 -5
- data/app/controllers/netzke_controller.rb +47 -15
- data/config/database.yml +2 -0
- data/features/component_loader.feature +6 -1
- data/features/composition.feature +2 -0
- data/features/js_include.feature +18 -0
- data/features/nested_views.feature +9 -0
- data/features/persistence.feature +6 -4
- data/features/support/paths.rb +3 -0
- data/javascripts/core.js +166 -519
- data/javascripts/ext.js +355 -0
- data/javascripts/touch.js +47 -0
- data/lib/netzke/actions.rb +31 -38
- data/lib/netzke/base.rb +48 -6
- data/lib/netzke/composition.rb +52 -63
- data/lib/netzke/configuration.rb +6 -2
- data/lib/netzke/core/version.rb +2 -2
- data/lib/netzke/core.rb +22 -15
- data/lib/netzke/javascript/scopes.rb +39 -0
- data/lib/netzke/javascript.rb +145 -114
- data/lib/netzke/railz/action_view_ext/ext.rb +59 -0
- data/lib/netzke/railz/action_view_ext/touch.rb +50 -0
- data/lib/netzke/railz/action_view_ext.rb +86 -0
- data/lib/netzke/railz/controller_extensions.rb +33 -0
- data/lib/netzke/{rails → railz}/routes.rb +0 -0
- data/lib/netzke/railz.rb +3 -0
- data/lib/netzke/session.rb +18 -3
- data/lib/netzke/state.rb +42 -15
- data/lib/netzke/stylesheets.rb +23 -8
- data/lib/netzke-core.rb +23 -16
- data/netzke-core.gemspec +52 -10
- data/spec/component/base_spec.rb +11 -0
- data/spec/component/javascript_spec.rb +3 -2
- data/spec/component/state_spec.rb +18 -0
- data/spec/spec_helper.rb +1 -1
- data/test/rails_app/Gemfile +3 -2
- data/test/rails_app/Gemfile.lock +73 -71
- data/test/rails_app/app/components/component_loader.rb +39 -4
- data/test/rails_app/app/components/{custom.css → component_with_custom_css/stylesheets/custom.css} +0 -0
- data/test/rails_app/app/components/component_with_custom_css.rb +2 -2
- data/test/rails_app/app/components/component_with_js_mixin/javascripts/extra_one.js +2 -0
- data/test/rails_app/app/components/component_with_js_mixin/javascripts/extra_two.js +2 -0
- data/test/rails_app/app/components/component_with_js_mixin/javascripts/method_set_one.js +6 -0
- data/test/rails_app/app/components/component_with_js_mixin/javascripts/method_set_two.js +5 -0
- data/test/rails_app/app/components/component_with_js_mixin.rb +8 -0
- data/test/rails_app/app/components/component_with_session_persistence.rb +10 -3
- data/test/rails_app/app/components/extended_component_with_js_mixin/javascripts/some_method_set.js +5 -0
- data/test/rails_app/app/components/extended_component_with_js_mixin.rb +7 -0
- data/test/rails_app/app/components/hello_world_component.rb +31 -0
- data/test/rails_app/app/components/server_caller.rb +1 -1
- data/test/rails_app/app/components/simple_panel.rb +2 -0
- data/test/rails_app/app/components/touch/hello_world_component.rb +25 -0
- data/test/rails_app/app/components/touch/server_caller.rb +28 -0
- data/test/rails_app/app/components/touch/simple_carousel.rb +17 -0
- data/test/rails_app/app/controllers/components_controller.rb +6 -1
- data/test/rails_app/app/controllers/touch_controller.rb +6 -0
- data/test/rails_app/app/helpers/touch_helper.rb +2 -0
- data/test/rails_app/app/views/components/panel_with_autoload.html.erb +2 -0
- data/test/rails_app/app/views/components/some_tab_panel.html.erb +11 -0
- data/test/rails_app/app/views/layouts/nested.html.erb +5 -0
- data/test/rails_app/app/views/layouts/touch.html.erb +13 -0
- data/test/rails_app/config/initializers/netzke.rb +1 -1
- data/test/rails_app/config/locales/en.yml +7 -1
- data/test/rails_app/config/routes.rb +10 -1
- data/test/rails_app/db/migrate/20110110132720_create_netzke_component_states.rb +20 -0
- data/test/rails_app/db/schema.rb +14 -1
- data/test/rails_app/spec/controllers/touch_controller_spec.rb +5 -0
- data/test/rails_app/spec/helpers/touch_helper_spec.rb +15 -0
- data/test/unit/netzke_core_test.rb +2 -6
- metadata +53 -11
- data/README.rdoc +0 -136
- data/lib/netzke/rails/action_view_ext.rb +0 -103
- data/lib/netzke/rails/controller_extensions.rb +0 -31
- data/test/rails_app/db/migrate/20100905214933_create_netzke_preferences.rb +0 -16
data/spec/component/base_spec.rb
CHANGED
@@ -22,4 +22,15 @@ describe Netzke::Base do
|
|
22
22
|
Parent.with_feature.should == "maybe"
|
23
23
|
Child.with_feature.should == "no"
|
24
24
|
end
|
25
|
+
|
26
|
+
it "should return correct i18n_id" do
|
27
|
+
module Netzke
|
28
|
+
module MyComponents
|
29
|
+
class CoolComponent < Netzke::Base
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
Netzke::MyComponents::CoolComponent.new.i18n_id.should == "netzke.my_components.cool_component"
|
35
|
+
end
|
25
36
|
end
|
@@ -8,8 +8,9 @@ module Netzke
|
|
8
8
|
class InheritedComponent < SomeComponent
|
9
9
|
end
|
10
10
|
|
11
|
-
|
12
|
-
|
11
|
+
it "should be indicated by extends_netzke_component? if we're extending a Netzke component" do
|
12
|
+
SomeComponent.send(:"extends_netzke_component?").should == false
|
13
|
+
InheritedComponent.send(:"extends_netzke_component?").should == true
|
13
14
|
end
|
14
15
|
end
|
15
16
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
require 'netzke-core'
|
3
|
+
|
4
|
+
module Netzke
|
5
|
+
describe State do
|
6
|
+
it "should be possible to save component's state" do
|
7
|
+
component = Base.new(:name => 'some_component', :persistence => true)
|
8
|
+
component.state.should == {}
|
9
|
+
|
10
|
+
component.update_state(:value_to_remember, 42)
|
11
|
+
component.state.should == {:value_to_remember => 42}
|
12
|
+
|
13
|
+
component.update_state(:more_to_remember => "a string", :and_yet_more => "another string")
|
14
|
+
component.state.should == {:value_to_remember => 42, :more_to_remember => "a string", :and_yet_more => "another string"}
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -26,7 +26,7 @@ RSpec.configure do |config|
|
|
26
26
|
config.mock_with :rspec
|
27
27
|
|
28
28
|
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
29
|
-
config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
29
|
+
# config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
30
30
|
|
31
31
|
# If you're not using ActiveRecord, or you'd prefer not to run each of your
|
32
32
|
# examples within a transaction, remove the following line or assign false
|
data/test/rails_app/Gemfile
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
source 'http://rubygems.org'
|
2
2
|
|
3
|
-
gem 'rails', '3.0.
|
3
|
+
gem 'rails', '3.0.3'
|
4
4
|
|
5
5
|
# Bundle edge Rails instead:
|
6
6
|
# gem 'rails', :git => 'git://github.com/rails/rails.git'
|
@@ -30,7 +30,8 @@ group :development, :test do
|
|
30
30
|
gem 'database_cleaner'
|
31
31
|
gem 'cucumber-rails'
|
32
32
|
gem 'cucumber'
|
33
|
-
gem 'rspec-rails'
|
33
|
+
gem 'rspec-rails'
|
34
34
|
gem 'spork'
|
35
35
|
gem 'launchy' # So you can do Then show me the page
|
36
|
+
gem 'netzke-persistence'
|
36
37
|
end
|
data/test/rails_app/Gemfile.lock
CHANGED
@@ -2,34 +2,33 @@ GEM
|
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
4
|
abstract (1.0.0)
|
5
|
-
actionmailer (3.0.
|
6
|
-
actionpack (= 3.0.
|
7
|
-
mail (~> 2.2.
|
8
|
-
actionpack (3.0.
|
9
|
-
activemodel (= 3.0.
|
10
|
-
activesupport (= 3.0.
|
5
|
+
actionmailer (3.0.3)
|
6
|
+
actionpack (= 3.0.3)
|
7
|
+
mail (~> 2.2.9)
|
8
|
+
actionpack (3.0.3)
|
9
|
+
activemodel (= 3.0.3)
|
10
|
+
activesupport (= 3.0.3)
|
11
11
|
builder (~> 2.1.2)
|
12
12
|
erubis (~> 2.6.6)
|
13
|
-
i18n (~> 0.4
|
13
|
+
i18n (~> 0.4)
|
14
14
|
rack (~> 1.2.1)
|
15
|
-
rack-mount (~> 0.6.
|
16
|
-
rack-test (~> 0.5.
|
15
|
+
rack-mount (~> 0.6.13)
|
16
|
+
rack-test (~> 0.5.6)
|
17
17
|
tzinfo (~> 0.3.23)
|
18
|
-
activemodel (3.0.
|
19
|
-
activesupport (= 3.0.
|
18
|
+
activemodel (3.0.3)
|
19
|
+
activesupport (= 3.0.3)
|
20
20
|
builder (~> 2.1.2)
|
21
|
-
i18n (~> 0.4
|
22
|
-
activerecord (3.0.
|
23
|
-
activemodel (= 3.0.
|
24
|
-
activesupport (= 3.0.
|
25
|
-
arel (~>
|
21
|
+
i18n (~> 0.4)
|
22
|
+
activerecord (3.0.3)
|
23
|
+
activemodel (= 3.0.3)
|
24
|
+
activesupport (= 3.0.3)
|
25
|
+
arel (~> 2.0.2)
|
26
26
|
tzinfo (~> 0.3.23)
|
27
|
-
activeresource (3.0.
|
28
|
-
activemodel (= 3.0.
|
29
|
-
activesupport (= 3.0.
|
30
|
-
activesupport (3.0.
|
31
|
-
arel (
|
32
|
-
activesupport (~> 3.0.0)
|
27
|
+
activeresource (3.0.3)
|
28
|
+
activemodel (= 3.0.3)
|
29
|
+
activesupport (= 3.0.3)
|
30
|
+
activesupport (3.0.3)
|
31
|
+
arel (2.0.6)
|
33
32
|
builder (2.1.2)
|
34
33
|
capybara (0.4.0)
|
35
34
|
celerity (>= 0.7.9)
|
@@ -40,86 +39,88 @@ GEM
|
|
40
39
|
rack-test (>= 0.5.4)
|
41
40
|
selenium-webdriver (>= 0.0.27)
|
42
41
|
xpath (~> 0.1.2)
|
43
|
-
celerity (0.8.
|
44
|
-
childprocess (0.1.
|
42
|
+
celerity (0.8.7)
|
43
|
+
childprocess (0.1.6)
|
45
44
|
ffi (~> 0.6.3)
|
46
|
-
configuration (1.
|
47
|
-
cucumber (0.
|
48
|
-
builder (
|
45
|
+
configuration (1.2.0)
|
46
|
+
cucumber (0.10.0)
|
47
|
+
builder (>= 2.1.2)
|
49
48
|
diff-lcs (~> 1.1.2)
|
50
|
-
gherkin (~> 2.2
|
49
|
+
gherkin (~> 2.3.2)
|
51
50
|
json (~> 1.4.6)
|
52
51
|
term-ansicolor (~> 1.0.5)
|
53
52
|
cucumber-rails (0.3.2)
|
54
53
|
cucumber (>= 0.8.0)
|
55
|
-
culerity (0.2.
|
56
|
-
database_cleaner (0.
|
54
|
+
culerity (0.2.14)
|
55
|
+
database_cleaner (0.6.0)
|
57
56
|
diff-lcs (1.1.2)
|
58
57
|
erubis (2.6.6)
|
59
58
|
abstract (>= 1.0.0)
|
60
59
|
ffi (0.6.3)
|
61
60
|
rake (>= 0.8.7)
|
62
|
-
gherkin (2.
|
61
|
+
gherkin (2.3.3)
|
63
62
|
json (~> 1.4.6)
|
64
|
-
|
65
|
-
i18n (0.4.1)
|
63
|
+
i18n (0.5.0)
|
66
64
|
json (1.4.6)
|
67
65
|
json_pure (1.4.6)
|
68
66
|
launchy (0.3.7)
|
69
67
|
configuration (>= 0.0.5)
|
70
68
|
rake (>= 0.8.1)
|
71
|
-
mail (2.2.
|
69
|
+
mail (2.2.14)
|
72
70
|
activesupport (>= 2.3.6)
|
73
|
-
|
74
|
-
|
71
|
+
i18n (>= 0.4.0)
|
72
|
+
mime-types (~> 1.16)
|
73
|
+
treetop (~> 1.4.8)
|
75
74
|
mime-types (1.16)
|
76
|
-
|
75
|
+
netzke-persistence (0.1.1)
|
76
|
+
nokogiri (1.4.4)
|
77
77
|
polyglot (0.3.1)
|
78
78
|
rack (1.2.1)
|
79
79
|
rack-mount (0.6.13)
|
80
80
|
rack (>= 1.0.0)
|
81
|
-
rack-test (0.5.
|
81
|
+
rack-test (0.5.7)
|
82
82
|
rack (>= 1.0)
|
83
|
-
rails (3.0.
|
84
|
-
actionmailer (= 3.0.
|
85
|
-
actionpack (= 3.0.
|
86
|
-
activerecord (= 3.0.
|
87
|
-
activeresource (= 3.0.
|
88
|
-
activesupport (= 3.0.
|
89
|
-
bundler (~> 1.0
|
90
|
-
railties (= 3.0.
|
91
|
-
railties (3.0.
|
92
|
-
actionpack (= 3.0.
|
93
|
-
activesupport (= 3.0.
|
94
|
-
rake (>= 0.8.
|
95
|
-
thor (~> 0.14.
|
83
|
+
rails (3.0.3)
|
84
|
+
actionmailer (= 3.0.3)
|
85
|
+
actionpack (= 3.0.3)
|
86
|
+
activerecord (= 3.0.3)
|
87
|
+
activeresource (= 3.0.3)
|
88
|
+
activesupport (= 3.0.3)
|
89
|
+
bundler (~> 1.0)
|
90
|
+
railties (= 3.0.3)
|
91
|
+
railties (3.0.3)
|
92
|
+
actionpack (= 3.0.3)
|
93
|
+
activesupport (= 3.0.3)
|
94
|
+
rake (>= 0.8.7)
|
95
|
+
thor (~> 0.14.4)
|
96
96
|
rake (0.8.7)
|
97
|
-
rspec (2.0
|
98
|
-
rspec-core (~> 2.0
|
99
|
-
rspec-expectations (~> 2.0
|
100
|
-
rspec-mocks (~> 2.0
|
101
|
-
rspec-core (2.0
|
102
|
-
rspec-expectations (2.0
|
103
|
-
diff-lcs (
|
104
|
-
rspec-mocks (2.0
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
97
|
+
rspec (2.4.0)
|
98
|
+
rspec-core (~> 2.4.0)
|
99
|
+
rspec-expectations (~> 2.4.0)
|
100
|
+
rspec-mocks (~> 2.4.0)
|
101
|
+
rspec-core (2.4.0)
|
102
|
+
rspec-expectations (2.4.0)
|
103
|
+
diff-lcs (~> 1.1.2)
|
104
|
+
rspec-mocks (2.4.0)
|
105
|
+
rspec-rails (2.4.1)
|
106
|
+
actionpack (~> 3.0)
|
107
|
+
activesupport (~> 3.0)
|
108
|
+
railties (~> 3.0)
|
109
|
+
rspec (~> 2.4.0)
|
109
110
|
rubyzip (0.9.4)
|
110
|
-
selenium-webdriver (0.
|
111
|
-
childprocess (
|
111
|
+
selenium-webdriver (0.1.2)
|
112
|
+
childprocess (~> 0.1.5)
|
112
113
|
ffi (~> 0.6.3)
|
113
114
|
json_pure
|
114
115
|
rubyzip
|
115
116
|
spork (0.8.4)
|
116
|
-
sqlite3-ruby (1.3.
|
117
|
+
sqlite3-ruby (1.3.2)
|
117
118
|
term-ansicolor (1.0.5)
|
118
|
-
thor (0.14.
|
119
|
-
treetop (1.4.
|
119
|
+
thor (0.14.6)
|
120
|
+
treetop (1.4.9)
|
120
121
|
polyglot (>= 0.3.1)
|
121
122
|
tzinfo (0.3.23)
|
122
|
-
xpath (0.1.
|
123
|
+
xpath (0.1.3)
|
123
124
|
nokogiri (~> 1.3)
|
124
125
|
|
125
126
|
PLATFORMS
|
@@ -131,7 +132,8 @@ DEPENDENCIES
|
|
131
132
|
cucumber-rails
|
132
133
|
database_cleaner
|
133
134
|
launchy
|
134
|
-
|
135
|
-
|
135
|
+
netzke-persistence
|
136
|
+
rails (= 3.0.3)
|
137
|
+
rspec-rails
|
136
138
|
spork
|
137
139
|
sqlite3-ruby
|
@@ -16,6 +16,8 @@ class ComponentLoader < Netzke::Base
|
|
16
16
|
:lazy_loading => true
|
17
17
|
}
|
18
18
|
|
19
|
+
component :some_composite, :lazy_loading => true
|
20
|
+
|
19
21
|
js_method :on_load_with_feedback, <<-JS
|
20
22
|
function(){
|
21
23
|
this.loadComponent({name: 'simple_component', callback: function(){
|
@@ -28,10 +30,14 @@ class ComponentLoader < Netzke::Base
|
|
28
30
|
|
29
31
|
action :load_window_with_simple_component
|
30
32
|
|
33
|
+
action :load_composite
|
34
|
+
|
35
|
+
action :load_with_params
|
36
|
+
|
31
37
|
js_properties(
|
32
38
|
:title => "Component Loader",
|
33
39
|
:layout => "fit",
|
34
|
-
:bbar => [{:text => "Load component", :ref => "../button"}, {:text => "Load in window", :ref => "../loadInWindowButton"}, :load_with_feedback.action, :load_window_with_simple_component.action]
|
40
|
+
:bbar => [{:text => "Load component", :ref => "../button"}, {:text => "Load in window", :ref => "../loadInWindowButton"}, :load_with_feedback.action, :load_window_with_simple_component.action, :load_composite.action, :load_with_params.action]
|
35
41
|
)
|
36
42
|
|
37
43
|
js_method :on_load_window_with_simple_component, <<-JS
|
@@ -40,6 +46,18 @@ class ComponentLoader < Netzke::Base
|
|
40
46
|
}
|
41
47
|
JS
|
42
48
|
|
49
|
+
js_method :on_load_composite, <<-JS
|
50
|
+
function(params){
|
51
|
+
this.loadComponent({name: "some_composite"});
|
52
|
+
}
|
53
|
+
JS
|
54
|
+
|
55
|
+
js_method :on_load_with_params, <<-JS
|
56
|
+
function(params){
|
57
|
+
this.loadComponent({name: "simple_component", params: {html: "Simple Component with changed HTML"}});
|
58
|
+
}
|
59
|
+
JS
|
60
|
+
|
43
61
|
js_method :init_component, <<-JS
|
44
62
|
function(){
|
45
63
|
#{js_full_class_name}.superclass.initComponent.call(this);
|
@@ -49,11 +67,28 @@ class ComponentLoader < Netzke::Base
|
|
49
67
|
}, this);
|
50
68
|
|
51
69
|
this.loadInWindowButton.on('click', function(){
|
52
|
-
var w = new Ext.Window({
|
70
|
+
var w = new Ext.Window({
|
71
|
+
width: 500, height: 400, modal: true, layout:'fit',
|
72
|
+
items: [{xtype: 'panel'}]
|
73
|
+
});
|
53
74
|
w.show(null, function(){
|
54
|
-
this.loadComponent({name: 'component_loaded_in_window', container: w.getId()});
|
75
|
+
this.loadComponent({name: 'component_loaded_in_window', container: w.items.first().getId()});
|
55
76
|
}, this);
|
56
77
|
}, this);
|
57
78
|
}
|
58
79
|
JS
|
59
|
-
|
80
|
+
|
81
|
+
def deliver_component_endpoint(params)
|
82
|
+
if params[:name] == "simple_component" && params[:html]
|
83
|
+
components[:simple_component].merge!(:html => params[:html])
|
84
|
+
end
|
85
|
+
super
|
86
|
+
end
|
87
|
+
|
88
|
+
# For visual testing purposes
|
89
|
+
# def deliver_component_endpoint(params)
|
90
|
+
# sleep 2
|
91
|
+
# super
|
92
|
+
# end
|
93
|
+
|
94
|
+
end
|
data/test/rails_app/app/components/{custom.css → component_with_custom_css/stylesheets/custom.css}
RENAMED
File without changes
|
@@ -2,7 +2,7 @@
|
|
2
2
|
class ComponentWithCustomCss < Netzke::Base
|
3
3
|
js_property :title, "ComponentWithCustomCss"
|
4
4
|
|
5
|
-
js_property :html, "A component with the
|
5
|
+
js_property :html, "A component with the body hidden by means of custom CSS"
|
6
6
|
|
7
|
-
css_include
|
7
|
+
css_include :custom
|
8
8
|
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
class ComponentWithJsMixin < Netzke::Base
|
2
|
+
js_property :title, "ComponentWithJsMixin"
|
3
|
+
js_include :extra_one, :extra_two
|
4
|
+
js_mixin :method_set_one, :method_set_two
|
5
|
+
action :action_one
|
6
|
+
action :action_two
|
7
|
+
js_property :bbar, [:action_one.action, :action_two.action]
|
8
|
+
end
|
@@ -1,8 +1,14 @@
|
|
1
1
|
class ComponentWithSessionPersistence < Netzke::Base
|
2
|
-
js_property :title, "
|
2
|
+
js_property :title, "Default Title"
|
3
3
|
js_property :bbar, [{:text => "Tell server to store new title", :ref => "../button"}]
|
4
4
|
|
5
|
-
|
5
|
+
def default_config
|
6
|
+
super.merge(:session_persistence => true)
|
7
|
+
end
|
8
|
+
|
9
|
+
def configuration
|
10
|
+
super.merge(:html => component_session[:html_content] || "Default HTML")
|
11
|
+
end
|
6
12
|
|
7
13
|
js_method :bug_server, <<-JS
|
8
14
|
function(){
|
@@ -18,7 +24,8 @@ class ComponentWithSessionPersistence < Netzke::Base
|
|
18
24
|
JS
|
19
25
|
|
20
26
|
endpoint :whats_up do |params|
|
21
|
-
update_session_options(:title => "
|
27
|
+
update_session_options(:title => "Title From Session") # setting a value in session_options, which will get auto-merged into +config+
|
28
|
+
component_session[:html_content] = "HTML from session" # setting some custom session key/value, which we use manually in +configuration+
|
22
29
|
{}
|
23
30
|
end
|
24
31
|
|