skozlov-netzke-core 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
data/.autotest ADDED
@@ -0,0 +1 @@
1
+ require 'autotest/redgreen'
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.log
2
+ pkg
3
+ doc
4
+ .DS_Store
data/CHANGELOG CHANGED
@@ -1,3 +1,11 @@
1
+ v0.4.2
2
+ 2009-09-11
3
+ Fix: the API call (at the JavaScript side) was ignoring the callback parameter.
4
+ Impr: if the array of API points is empty, it's not added into js_config anymore.
5
+ New: new testing widgets in netzke_controller.
6
+ Fix: extra CSS includes now take effect.
7
+ New: Support for masquerading as "World". In this mode all the "touched" persistent preferences will be overwritten for all roles and users.
8
+
1
9
  v0.4.1
2
10
  2009-09-06
3
11
  Version bumb to force github rebuild the gem (Manifest is now included)
data/Rakefile CHANGED
@@ -1,14 +1,32 @@
1
- require 'echoe'
1
+ begin
2
+ require 'jeweler'
3
+ Jeweler::Tasks.new do |gemspec|
4
+ gemspec.name = "netzke-core"
5
+ gemspec.summary = "Build ExtJS/Rails widgets with minimum effort"
6
+ gemspec.description = "Build ExtJS/Rails widgets with minimum effort"
7
+ gemspec.email = "sergei@playcode.nl"
8
+ gemspec.homepage = "http://github.com/skozlov/netzke-core"
9
+ gemspec.rubyforge_project = "netzke-core"
10
+ gemspec.authors = ["Sergei Kozlov"]
11
+ end
12
+ Jeweler::RubyforgeTasks.new do |rubyforge|
13
+ rubyforge.doc_task = "rdoc"
14
+ end
15
+
16
+ rescue LoadError
17
+ puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
18
+ end
19
+
20
+ require 'rake/rdoctask'
21
+ Rake::RDocTask.new do |rdoc|
22
+ if File.exist?('VERSION')
23
+ version = File.read('VERSION')
24
+ else
25
+ version = ""
26
+ end
2
27
 
3
- Echoe.new("netzke-core") do |p|
4
- p.author = "Sergei Kozlov"
5
- p.email = "sergei@playcode.nl"
6
- p.summary = "Build ExtJS/Rails widgets with minimum effort"
7
- p.url = "http://playcode.nl"
8
- p.development_dependencies = []
9
- p.test_pattern = 'test/**/*_test.rb'
10
- p.retain_gemspec = true
11
-
12
- # fixing the problem with lib/*-* files being removed while doing manifest
13
- p.clean_pattern = ["pkg", "doc", 'build/*', '**/coverage', '**/*.o', '**/*.so', '**/*.a', '**/*.log', "{ext,lib}/*.{bundle,so,obj,pdb,lib,def,exp}", "ext/Makefile", "{ext,lib}/**/*.{bundle,so,obj,pdb,lib,def,exp}", "ext/**/Makefile", "pkg", "*.gem", ".config"]
28
+ rdoc.rdoc_dir = 'rdoc'
29
+ rdoc.title = "netzke-core #{version}"
30
+ rdoc.rdoc_files.include('README*')
31
+ rdoc.rdoc_files.include('lib/**/*.rb')
14
32
  end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.4.2
data/javascripts/core.js CHANGED
@@ -126,9 +126,10 @@ Ext.widgetMixIn = {
126
126
  // this.getChildWidget(params.id).ownerCt.enable();
127
127
 
128
128
  // provide the callback to that widget that was loading the child, passing the child itself
129
- if (this.callbackHash[params.id]) {
130
- this.callbackHash[params.id].call(params.scope || this, this.getChildWidget(params.id));
131
- delete this.callbackHash[params.id];
129
+ var callbackFn = this.callbackHash[params.id.camelize(true)];
130
+ if (callbackFn) {
131
+ callbackFn.call(params.scope || this, this.getChildWidget(params.id));
132
+ delete this.callbackHash[params.id.camelize(true)];
132
133
  }
133
134
  }
134
135
  },
@@ -54,7 +54,7 @@ class NetzkeController < ActionController::Base
54
54
  :ext_config => {
55
55
  :html => "Panel 1",
56
56
  },
57
- :active => true
57
+ # :active => true
58
58
  },{
59
59
  :widget_class_name => "Panel",
60
60
  :ext_config => {
@@ -67,8 +67,8 @@ class NetzkeController < ActionController::Base
67
67
  :widget_class_name => "Panel",
68
68
  :ext_config => {
69
69
  :html => "Panel 1",
70
- }
71
- # :active => true
70
+ },
71
+ :active => true
72
72
  },{
73
73
  :widget_class_name => "Panel",
74
74
  :ext_config => {
@@ -79,6 +79,8 @@ class NetzkeController < ActionController::Base
79
79
  # BasicApp
80
80
  netzke :basic_app
81
81
 
82
+ netzke :panel, :ext_config => {:html => "Panel", :title => "Test panel", :border => true}
83
+
82
84
  def test_widgets
83
85
  html = "<h3>Quick primitive widgets tests</h3>"
84
86
 
@@ -85,12 +85,21 @@ class NetzkePreference < ActiveRecord::Base
85
85
  # if it doesn't exist, get them for the user's role
86
86
  user = User.find(session[:masq_user])
87
87
  res ||= self.find(:first, :conditions => cond.merge({:role_id => user.role.id}))
88
+ # if it doesn't exist either, get them for the World (role_id = 0)
89
+ res ||= self.find(:first, :conditions => cond.merge({:role_id => 0}))
88
90
  elsif session[:masq_role]
91
+ # first, get the prefs for this role
89
92
  res = self.find(:first, :conditions => cond.merge({:role_id => session[:masq_role]}))
93
+ # if it doesn't exist, get them for the World (role_id = 0)
94
+ res ||= self.find(:first, :conditions => cond.merge({:role_id => 0}))
90
95
  elsif session[:netzke_user_id]
91
96
  user = User.find(session[:netzke_user_id])
97
+ # first, get the prefs for this user
92
98
  res = self.find(:first, :conditions => cond.merge({:user_id => user.id}))
99
+ # if it doesn't exist, get them for the user's role
93
100
  res ||= self.find(:first, :conditions => cond.merge({:role_id => user.role.id}))
101
+ # if it doesn't exist either, get them for the World (role_id = 0)
102
+ res ||= self.find(:first, :conditions => cond.merge({:role_id => 0}))
94
103
  else
95
104
  res = self.find(:first, :conditions => cond)
96
105
  end
@@ -105,7 +114,9 @@ class NetzkePreference < ActiveRecord::Base
105
114
 
106
115
  if session[:masq_user]
107
116
  cond.merge!({:user_id => session[:masq_user]})
117
+ # first, try to find the preference for masq_user
108
118
  res = self.find(:first, :conditions => cond)
119
+ # if it doesn't exist, create it
109
120
  res ||= self.new(cond)
110
121
  elsif session[:masq_role]
111
122
  # first, delete all the corresponding preferences for the users that have this role
@@ -115,6 +126,11 @@ class NetzkePreference < ActiveRecord::Base
115
126
  cond.merge!({:role_id => session[:masq_role]})
116
127
  res = self.find(:first, :conditions => cond)
117
128
  res ||= self.new(cond)
129
+ elsif session[:masq_world]
130
+ # first, delete all the corresponding preferences for all users and roles
131
+ self.delete_all(cond)
132
+ # then, create the new preference for the World (role_id = 0)
133
+ res = self.new(cond.merge(:role_id => 0))
118
134
  elsif session[:netzke_user_id]
119
135
  res = self.find(:first, :conditions => cond.merge({:user_id => session[:netzke_user_id]}))
120
136
  res ||= self.new(cond.merge({:user_id => session[:netzke_user_id]}))
data/lib/netzke/base.rb CHANGED
@@ -495,7 +495,7 @@ module Netzke
495
495
 
496
496
  [{
497
497
  :js => widget.js_missing_code(cache),
498
- :css => css_missing_code(cache)
498
+ :css => widget.css_missing_code(cache)
499
499
  }, {
500
500
  :render_widget_in_container => {
501
501
  :container => params[:container],
@@ -41,7 +41,8 @@ module Netzke
41
41
  end
42
42
 
43
43
  # Api (besides the default "load_aggregatee_with_cache" - JavaScript side already knows about it)
44
- res.merge!(:api => self.class.api_points.reject{ |p| p == :load_aggregatee_with_cache })
44
+ api_points = self.class.api_points.reject{ |p| p == :load_aggregatee_with_cache }
45
+ res.merge!(:api => api_points) unless api_points.empty?
45
46
 
46
47
  # Widget class name. Needed for dynamic instantiation in javascript.
47
48
  res.merge!(:widget_class_name => short_widget_class_name)
@@ -166,31 +167,29 @@ module Netzke
166
167
  end
167
168
  end
168
169
 
169
- def css_include(*args)
170
- included_css = read_inheritable_attribute(:included_css) || []
171
- args.each do |inclusion|
172
- if inclusion.is_a?(Hash)
173
- # we are signalized a non-default file location (e.g. Ext examples)
174
- case inclusion.keys.first
175
- when :ext_examples
176
- location = Netzke::Base.config[:ext_location] + "/examples/"
177
- end
178
- files = inclusion.values.first
179
- else
180
- location = ""
181
- files = inclusion
182
- end
183
-
184
- files = [files] if files.is_a?(String)
185
-
186
- for f in files
187
- included_css << location + f
188
- end
189
- end
190
- write_inheritable_attribute(:included_css, included_css)
170
+ #
171
+ # Extra JavaScript
172
+ #
173
+
174
+ # Override this method. Must return an array of paths to javascript files that we depend on.
175
+ # This javascript code will be loaded along with the widget's class, and before it.
176
+ def include_js
177
+ []
191
178
  end
179
+
180
+ # Returns all extra JavaScript-code (as string) required by this widget's class
181
+ def js_included
182
+ res = ""
192
183
 
193
- # all JS code needed for this class, including one from the ancestor widget
184
+ include_js.each do |path|
185
+ f = File.new(path)
186
+ res << f.read << "\n"
187
+ end
188
+
189
+ res
190
+ end
191
+
192
+ # All JavaScript code needed for this class, including one from the ancestor widget
194
193
  def js_code(cached_dependencies = [])
195
194
  res = ""
196
195
 
@@ -205,40 +204,28 @@ module Netzke
205
204
  res
206
205
  end
207
206
 
207
+ #
208
+ # Extra CSS
209
+ #
208
210
 
209
- # Override this method. Must return an array of paths to javascript files that we depend on.
210
- # This javascript code will be loaded along with the widget's class, and before it.
211
- def include_js
211
+ # Override this method. Must return an array of paths to css files that we depend on.
212
+ def include_css
212
213
  []
213
214
  end
214
-
215
- # returns all extra js-code (as string) required by this widget's class
216
- def js_included
217
- res = ""
218
-
219
- include_js.each do |path|
220
- f = File.new(path)
221
- res << f.read << "\n"
222
- end
223
-
224
- res
225
- end
226
-
227
215
 
228
- # returns all extra js-code (as string) required by this widget's class
216
+ # Returns all extra CSS code (as string) required by this widget's class
229
217
  def css_included
230
218
  res = ""
231
219
 
232
- included_css = read_inheritable_attribute(:included_css) || []
233
- res << included_css.inject("") do |r, path|
220
+ include_css.each do |path|
234
221
  f = File.new(path)
235
- r << f.read
222
+ res << f.read << "\n"
236
223
  end
237
224
 
238
225
  res
239
226
  end
240
227
 
241
- # all JS code needed for this class including the one from the ancestor widget
228
+ # All CSS code needed for this class including the one from the ancestor widget
242
229
  def css_code(cached_dependencies = [])
243
230
  res = ""
244
231
 
@@ -250,7 +237,11 @@ module Netzke
250
237
  res
251
238
  end
252
239
 
240
+
241
+ # Little helper
253
242
  def this; "this".l; end
243
+
244
+ # Little helper
254
245
  def null; "null".l; end
255
246
 
256
247
  end
data/netzke-core.gemspec CHANGED
@@ -1,23 +1,103 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
1
4
  # -*- encoding: utf-8 -*-
2
5
 
3
6
  Gem::Specification.new do |s|
4
7
  s.name = %q{netzke-core}
5
- s.version = "0.4.1"
8
+ s.version = "0.4.2"
6
9
 
7
- s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
11
  s.authors = ["Sergei Kozlov"]
9
- s.date = %q{2009-09-06}
12
+ s.date = %q{2009-09-11}
10
13
  s.description = %q{Build ExtJS/Rails widgets with minimum effort}
11
14
  s.email = %q{sergei@playcode.nl}
12
- s.extra_rdoc_files = ["CHANGELOG", "LICENSE", "README.rdoc", "TODO", "lib/app/controllers/netzke_controller.rb", "lib/app/models/netzke_preference.rb", "lib/netzke-core.rb", "lib/netzke/action_view_ext.rb", "lib/netzke/base.rb", "lib/netzke/base_js.rb", "lib/netzke/controller_extensions.rb", "lib/netzke/core_ext.rb", "lib/netzke/feedback_ghost.rb", "lib/netzke/routing.rb", "tasks/netzke_core_tasks.rake"]
13
- s.files = ["CHANGELOG", "LICENSE", "Manifest", "README.rdoc", "Rakefile", "TODO", "autotest/discover.rb", "generators/netzke_core/USAGE", "generators/netzke_core/netzke_core_generator.rb", "generators/netzke_core/templates/create_netzke_preferences.rb", "init.rb", "install.rb", "javascripts/core.js", "lib/app/controllers/netzke_controller.rb", "lib/app/models/netzke_preference.rb", "lib/netzke-core.rb", "lib/netzke/action_view_ext.rb", "lib/netzke/base.rb", "lib/netzke/base_js.rb", "lib/netzke/controller_extensions.rb", "lib/netzke/core_ext.rb", "lib/netzke/feedback_ghost.rb", "lib/netzke/routing.rb", "netzke-core.gemspec", "stylesheets/core.css", "tasks/netzke_core_tasks.rake", "test/app_root/app/controllers/application_controller.rb", "test/app_root/app/models/role.rb", "test/app_root/app/models/user.rb", "test/app_root/config/boot.rb", "test/app_root/config/database.yml", "test/app_root/config/environment.rb", "test/app_root/config/environments/in_memory.rb", "test/app_root/config/environments/mysql.rb", "test/app_root/config/environments/postgresql.rb", "test/app_root/config/environments/sqlite.rb", "test/app_root/config/environments/sqlite3.rb", "test/app_root/config/routes.rb", "test/app_root/db/migrate/20081222035855_create_netzke_preferences.rb", "test/app_root/db/migrate/20090423214303_create_roles.rb", "test/app_root/db/migrate/20090423222114_create_users.rb", "test/app_root/lib/console_with_fixtures.rb", "test/app_root/script/console", "test/fixtures/roles.yml", "test/fixtures/users.yml", "test/test_helper.rb", "test/unit/core_ext_test.rb", "test/unit/netzke_core_test.rb", "test/unit/netzke_preference_test.rb", "uninstall.rb"]
14
- s.homepage = %q{http://playcode.nl}
15
- s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Netzke-core", "--main", "README.rdoc"]
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".autotest",
21
+ ".gitignore",
22
+ "CHANGELOG",
23
+ "LICENSE",
24
+ "Manifest",
25
+ "README.rdoc",
26
+ "Rakefile",
27
+ "TODO",
28
+ "VERSION",
29
+ "autotest/discover.rb",
30
+ "generators/netzke_core/USAGE",
31
+ "generators/netzke_core/netzke_core_generator.rb",
32
+ "generators/netzke_core/templates/create_netzke_preferences.rb",
33
+ "init.rb",
34
+ "install.rb",
35
+ "javascripts/core.js",
36
+ "lib/app/controllers/netzke_controller.rb",
37
+ "lib/app/models/netzke_preference.rb",
38
+ "lib/netzke-core.rb",
39
+ "lib/netzke/action_view_ext.rb",
40
+ "lib/netzke/base.rb",
41
+ "lib/netzke/base_js.rb",
42
+ "lib/netzke/controller_extensions.rb",
43
+ "lib/netzke/core_ext.rb",
44
+ "lib/netzke/feedback_ghost.rb",
45
+ "lib/netzke/routing.rb",
46
+ "netzke-core.gemspec",
47
+ "stylesheets/core.css",
48
+ "tasks/netzke_core_tasks.rake",
49
+ "test/app_root/app/controllers/application_controller.rb",
50
+ "test/app_root/app/models/role.rb",
51
+ "test/app_root/app/models/user.rb",
52
+ "test/app_root/config/boot.rb",
53
+ "test/app_root/config/database.yml",
54
+ "test/app_root/config/environment.rb",
55
+ "test/app_root/config/environments/in_memory.rb",
56
+ "test/app_root/config/environments/mysql.rb",
57
+ "test/app_root/config/environments/postgresql.rb",
58
+ "test/app_root/config/environments/sqlite.rb",
59
+ "test/app_root/config/environments/sqlite3.rb",
60
+ "test/app_root/config/routes.rb",
61
+ "test/app_root/db/migrate/20081222035855_create_netzke_preferences.rb",
62
+ "test/app_root/db/migrate/20090423214303_create_roles.rb",
63
+ "test/app_root/db/migrate/20090423222114_create_users.rb",
64
+ "test/app_root/lib/console_with_fixtures.rb",
65
+ "test/app_root/script/console",
66
+ "test/fixtures/roles.yml",
67
+ "test/fixtures/users.yml",
68
+ "test/test_helper.rb",
69
+ "test/unit/core_ext_test.rb",
70
+ "test/unit/netzke_core_test.rb",
71
+ "test/unit/netzke_preference_test.rb",
72
+ "uninstall.rb"
73
+ ]
74
+ s.homepage = %q{http://github.com/skozlov/netzke-core}
75
+ s.rdoc_options = ["--charset=UTF-8"]
16
76
  s.require_paths = ["lib"]
17
77
  s.rubyforge_project = %q{netzke-core}
18
78
  s.rubygems_version = %q{1.3.4}
19
79
  s.summary = %q{Build ExtJS/Rails widgets with minimum effort}
20
- s.test_files = ["test/unit/core_ext_test.rb", "test/unit/netzke_core_test.rb", "test/unit/netzke_preference_test.rb"]
80
+ s.test_files = [
81
+ "test/app_root/app/controllers/application_controller.rb",
82
+ "test/app_root/app/models/role.rb",
83
+ "test/app_root/app/models/user.rb",
84
+ "test/app_root/config/boot.rb",
85
+ "test/app_root/config/environment.rb",
86
+ "test/app_root/config/environments/in_memory.rb",
87
+ "test/app_root/config/environments/mysql.rb",
88
+ "test/app_root/config/environments/postgresql.rb",
89
+ "test/app_root/config/environments/sqlite.rb",
90
+ "test/app_root/config/environments/sqlite3.rb",
91
+ "test/app_root/config/routes.rb",
92
+ "test/app_root/db/migrate/20081222035855_create_netzke_preferences.rb",
93
+ "test/app_root/db/migrate/20090423214303_create_roles.rb",
94
+ "test/app_root/db/migrate/20090423222114_create_users.rb",
95
+ "test/app_root/lib/console_with_fixtures.rb",
96
+ "test/test_helper.rb",
97
+ "test/unit/core_ext_test.rb",
98
+ "test/unit/netzke_core_test.rb",
99
+ "test/unit/netzke_preference_test.rb"
100
+ ]
21
101
 
22
102
  if s.respond_to? :specification_version then
23
103
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: skozlov-netzke-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergei Kozlov
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-09-06 00:00:00 -07:00
12
+ date: 2009-09-11 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -20,28 +20,18 @@ executables: []
20
20
  extensions: []
21
21
 
22
22
  extra_rdoc_files:
23
- - CHANGELOG
24
23
  - LICENSE
25
24
  - README.rdoc
26
- - TODO
27
- - lib/app/controllers/netzke_controller.rb
28
- - lib/app/models/netzke_preference.rb
29
- - lib/netzke-core.rb
30
- - lib/netzke/action_view_ext.rb
31
- - lib/netzke/base.rb
32
- - lib/netzke/base_js.rb
33
- - lib/netzke/controller_extensions.rb
34
- - lib/netzke/core_ext.rb
35
- - lib/netzke/feedback_ghost.rb
36
- - lib/netzke/routing.rb
37
- - tasks/netzke_core_tasks.rake
38
25
  files:
26
+ - .autotest
27
+ - .gitignore
39
28
  - CHANGELOG
40
29
  - LICENSE
41
30
  - Manifest
42
31
  - README.rdoc
43
32
  - Rakefile
44
33
  - TODO
34
+ - VERSION
45
35
  - autotest/discover.rb
46
36
  - generators/netzke_core/USAGE
47
37
  - generators/netzke_core/netzke_core_generator.rb
@@ -87,16 +77,11 @@ files:
87
77
  - test/unit/netzke_preference_test.rb
88
78
  - uninstall.rb
89
79
  has_rdoc: false
90
- homepage: http://playcode.nl
80
+ homepage: http://github.com/skozlov/netzke-core
91
81
  licenses:
92
82
  post_install_message:
93
83
  rdoc_options:
94
- - --line-numbers
95
- - --inline-source
96
- - --title
97
- - Netzke-core
98
- - --main
99
- - README.rdoc
84
+ - --charset=UTF-8
100
85
  require_paths:
101
86
  - lib
102
87
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -109,7 +94,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
109
94
  requirements:
110
95
  - - ">="
111
96
  - !ruby/object:Gem::Version
112
- version: "1.2"
97
+ version: "0"
113
98
  version:
114
99
  requirements: []
115
100
 
@@ -119,6 +104,22 @@ signing_key:
119
104
  specification_version: 3
120
105
  summary: Build ExtJS/Rails widgets with minimum effort
121
106
  test_files:
107
+ - test/app_root/app/controllers/application_controller.rb
108
+ - test/app_root/app/models/role.rb
109
+ - test/app_root/app/models/user.rb
110
+ - test/app_root/config/boot.rb
111
+ - test/app_root/config/environment.rb
112
+ - test/app_root/config/environments/in_memory.rb
113
+ - test/app_root/config/environments/mysql.rb
114
+ - test/app_root/config/environments/postgresql.rb
115
+ - test/app_root/config/environments/sqlite.rb
116
+ - test/app_root/config/environments/sqlite3.rb
117
+ - test/app_root/config/routes.rb
118
+ - test/app_root/db/migrate/20081222035855_create_netzke_preferences.rb
119
+ - test/app_root/db/migrate/20090423214303_create_roles.rb
120
+ - test/app_root/db/migrate/20090423222114_create_users.rb
121
+ - test/app_root/lib/console_with_fixtures.rb
122
+ - test/test_helper.rb
122
123
  - test/unit/core_ext_test.rb
123
124
  - test/unit/netzke_core_test.rb
124
125
  - test/unit/netzke_preference_test.rb