netzke-core 0.5.4 → 0.5.5
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -1
- data/CHANGELOG.rdoc +4 -0
- data/README.rdoc +8 -0
- data/Rakefile +2 -1
- data/install.rb +1 -1
- data/javascripts/core.js +26 -3
- data/lib/netzke/action_view_ext.rb +15 -2
- data/lib/netzke/base.rb +3 -2
- data/lib/netzke/base_js.rb +1 -3
- data/lib/netzke/core_ext.rb +2 -7
- metadata +22 -23
data/.gitignore
CHANGED
data/CHANGELOG.rdoc
CHANGED
data/README.rdoc
CHANGED
@@ -37,6 +37,14 @@ Here's how to embed a Netzke widget into your Rails view.
|
|
37
37
|
|
38
38
|
(here we use the GridPanel widget from the netzke-basepack project)
|
39
39
|
|
40
|
+
== Running in production
|
41
|
+
|
42
|
+
1. There is some basic JS minification when running in production. This uses JSMin to strip comments, whitespace etc.
|
43
|
+
|
44
|
+
It can also manually configured by setting :minify_js
|
45
|
+
|
46
|
+
Netzke::Base.configure :minify_js=>true
|
47
|
+
|
40
48
|
== More info
|
41
49
|
Introduction to Netzke framework and wiki: http://github.com/skozlov/netzke
|
42
50
|
|
data/Rakefile
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
begin
|
2
2
|
require 'jeweler'
|
3
3
|
Jeweler::Tasks.new do |gemspec|
|
4
|
-
gemspec.version = "0.5.
|
4
|
+
gemspec.version = "0.5.5"
|
5
5
|
gemspec.name = "netzke-core"
|
6
6
|
gemspec.summary = "Build ExtJS/Rails widgets with minimum effort"
|
7
7
|
gemspec.description = "Allows building ExtJS/Rails reusable code in a DRY way"
|
@@ -9,6 +9,7 @@ begin
|
|
9
9
|
gemspec.homepage = "http://github.com/skozlov/netzke-core"
|
10
10
|
gemspec.rubyforge_project = "netzke-core"
|
11
11
|
gemspec.authors = ["Sergei Kozlov"]
|
12
|
+
gemspec.add_dependency("jsmin", ">=1.0.1")
|
12
13
|
gemspec.post_install_message = <<-MESSAGE
|
13
14
|
|
14
15
|
========================================================================
|
data/install.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
# Install hook code here
|
1
|
+
# Install hook code here
|
data/javascripts/core.js
CHANGED
@@ -390,6 +390,27 @@ Ext.widgetMixIn = {
|
|
390
390
|
return res;
|
391
391
|
},
|
392
392
|
|
393
|
+
locateMenus : function(o) {
|
394
|
+
var keyWords = ["bbar", "tbar", "fbar"];
|
395
|
+
if (Ext.isObject(o)) {
|
396
|
+
Ext.each(keyWords, function(key){
|
397
|
+
if (o[key]) {
|
398
|
+
o[key] = this.normalizeMenuItems(o[key], this);
|
399
|
+
};
|
400
|
+
}, this);
|
401
|
+
|
402
|
+
for (var key in o) {
|
403
|
+
if (keyWords.indexOf(key) == -1) {
|
404
|
+
this.locateMenus(o[key]);
|
405
|
+
}
|
406
|
+
}
|
407
|
+
} else if (Ext.isArray(o)) {
|
408
|
+
Ext.each(o, function(el){
|
409
|
+
this.locateMenus(el);
|
410
|
+
}, this);
|
411
|
+
}
|
412
|
+
|
413
|
+
},
|
393
414
|
|
394
415
|
// Code run before calling Ext's constructor - normalizing config to provide Netzke additional functionality
|
395
416
|
commonBeforeConstructor : function(config){
|
@@ -421,9 +442,11 @@ Ext.widgetMixIn = {
|
|
421
442
|
config.actions = this.actions;
|
422
443
|
}
|
423
444
|
|
424
|
-
|
425
|
-
|
426
|
-
config.
|
445
|
+
this.locateMenus(config);
|
446
|
+
|
447
|
+
// config.bbar = config.bbar && this.normalizeMenuItems(config.bbar, this);
|
448
|
+
// config.tbar = config.tbar && this.normalizeMenuItems(config.tbar, this);
|
449
|
+
// config.fbar = config.fbar && this.normalizeMenuItems(config.fbar, this);
|
427
450
|
config.contextMenu = config.contextMenu && this.normalizeMenuItems(config.contextMenu, this);
|
428
451
|
|
429
452
|
config.menu = config.menu && this.normalizeMenuItems(config.menu, this);
|
@@ -26,13 +26,26 @@ module Netzke
|
|
26
26
|
|
27
27
|
# JavaScript for all Netzke classes in this view, and Ext.onReady which renders all Netzke widgets in this view
|
28
28
|
def netzke_js
|
29
|
-
|
30
|
-
|
29
|
+
js="Ext.Ajax.extraParams = {authenticity_token: '#{form_authenticity_token}'}; // Rails' forgery protection\n"
|
30
|
+
|
31
|
+
|
32
|
+
js << <<-END_OF_JAVASCRIPT if(!ActionController::Base.relative_url_root.blank?)
|
33
|
+
// apply relative URL root, if set
|
34
|
+
Ext.widgetMixIn.buildApiUrl= function(apip){
|
35
|
+
return "#{ActionController::Base.relative_url_root}/netzke/" + this.id + "__" + apip;
|
36
|
+
};
|
37
|
+
Ext.BLANK_IMAGE_URL = "#{ActionController::Base.relative_url_root}/extjs/resources/images/default/s.gif";
|
38
|
+
END_OF_JAVASCRIPT
|
39
|
+
|
40
|
+
js << <<-END_OF_JAVASCRIPT
|
31
41
|
#{@content_for_netzke_js_classes}
|
32
42
|
Ext.onReady(function(){
|
33
43
|
#{@content_for_netzke_on_ready}
|
34
44
|
});
|
35
45
|
END_OF_JAVASCRIPT
|
46
|
+
|
47
|
+
javascript_tag js
|
48
|
+
|
36
49
|
end
|
37
50
|
|
38
51
|
# Wrapper for all the above. Use it in your layout.
|
data/lib/netzke/base.rb
CHANGED
@@ -47,6 +47,8 @@ module Netzke
|
|
47
47
|
# Class-level Netzke::Base configuration. The defaults also get specified here.
|
48
48
|
def self.config
|
49
49
|
set_default_config({
|
50
|
+
# Set to true, if you want generated JS to be minified
|
51
|
+
:minify_js => Rails.env.production?,
|
50
52
|
# Which javascripts and stylesheets must get included at the initial load (see netzke-core.rb)
|
51
53
|
:javascripts => [],
|
52
54
|
:stylesheets => [],
|
@@ -60,7 +62,7 @@ module Netzke
|
|
60
62
|
:ext_location => defined?(RAILS_ROOT) && "#{RAILS_ROOT}/public/extjs",
|
61
63
|
|
62
64
|
# Default location of icons, relative to the root of the domain
|
63
|
-
:icons_uri => "/images/icons/",
|
65
|
+
:icons_uri => ActionController::Base.relative_url_root.to_s+"/images/icons/" ,
|
64
66
|
|
65
67
|
# Default instance config
|
66
68
|
:default_config => {
|
@@ -86,7 +88,6 @@ module Netzke
|
|
86
88
|
# first arg is hash
|
87
89
|
config.deep_merge!(args.first)
|
88
90
|
end
|
89
|
-
|
90
91
|
# widget may implement some kind of control for configuration consistency
|
91
92
|
enforce_config_consistency if respond_to?(:enforce_config_consistency)
|
92
93
|
end
|
data/lib/netzke/base_js.rb
CHANGED
@@ -204,7 +204,7 @@ module Netzke
|
|
204
204
|
# to be reused at the moment of widget instantiation)
|
205
205
|
def js_class(cached = [])
|
206
206
|
# Defining the scope if it isn't known yet
|
207
|
-
res = %Q{
|
207
|
+
res = js_full_scope == "Netzke.classes" ? "" : %Q{
|
208
208
|
if (!#{js_full_scope}) {
|
209
209
|
Ext.ns("#{js_full_scope}");
|
210
210
|
}
|
@@ -227,7 +227,6 @@ module Netzke
|
|
227
227
|
})
|
228
228
|
|
229
229
|
res << <<-END_OF_JAVASCRIPT
|
230
|
-
// Register our xtype
|
231
230
|
Ext.reg("#{js_xtype}", #{js_full_class_name});
|
232
231
|
END_OF_JAVASCRIPT
|
233
232
|
|
@@ -248,7 +247,6 @@ module Netzke
|
|
248
247
|
this.commonAfterConstructor(config);
|
249
248
|
};
|
250
249
|
Ext.extend(#{js_full_class_name}, #{js_base_class}, Ext.applyIf(#{js_extend_properties.to_nifty_json}, Ext.widgetMixIn));
|
251
|
-
// Register xtype
|
252
250
|
Ext.reg("#{js_xtype}", #{js_full_class_name});
|
253
251
|
END_OF_JAVASCRIPT
|
254
252
|
end
|
data/lib/netzke/core_ext.rb
CHANGED
@@ -111,14 +111,9 @@ class String
|
|
111
111
|
LiteralString.new(self)
|
112
112
|
end
|
113
113
|
|
114
|
-
# removes JS-comments
|
114
|
+
# removes JS-comments from the string and minfy it
|
115
115
|
def strip_js_comments
|
116
|
-
|
117
|
-
self.gsub!(regexp, '')
|
118
|
-
|
119
|
-
# also remove empty lines
|
120
|
-
regexp = /^\s*\n/
|
121
|
-
self.gsub!(regexp, '')
|
116
|
+
Netzke::Base.config[:minify_js] ? JSMin.minify(self) : self
|
122
117
|
end
|
123
118
|
|
124
119
|
# "false" => false, "whatever_else" => true
|
metadata
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: netzke-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: 3
|
5
4
|
prerelease: false
|
6
5
|
segments:
|
7
6
|
- 0
|
8
7
|
- 5
|
9
|
-
-
|
10
|
-
version: 0.5.
|
8
|
+
- 5
|
9
|
+
version: 0.5.5
|
11
10
|
platform: ruby
|
12
11
|
authors:
|
13
12
|
- Sergei Kozlov
|
@@ -15,10 +14,24 @@ autorequire:
|
|
15
14
|
bindir: bin
|
16
15
|
cert_chain: []
|
17
16
|
|
18
|
-
date: 2010-08
|
17
|
+
date: 2010-09-08 00:00:00 +02:00
|
19
18
|
default_executable:
|
20
|
-
dependencies:
|
21
|
-
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: jsmin
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
segments:
|
29
|
+
- 1
|
30
|
+
- 0
|
31
|
+
- 1
|
32
|
+
version: 1.0.1
|
33
|
+
type: :runtime
|
34
|
+
version_requirements: *id001
|
22
35
|
description: Allows building ExtJS/Rails reusable code in a DRY way
|
23
36
|
email: sergei@playcode.nl
|
24
37
|
executables: []
|
@@ -84,21 +97,9 @@ has_rdoc: true
|
|
84
97
|
homepage: http://github.com/skozlov/netzke-core
|
85
98
|
licenses: []
|
86
99
|
|
87
|
-
post_install_message:
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
Thanks for installing Netzke Core!
|
92
|
-
|
93
|
-
Don't forget to run "./script/generate netzke_core" for each Rails
|
94
|
-
app that will be using this gem.
|
95
|
-
|
96
|
-
Netzke home page: http://netzke.org
|
97
|
-
Netzke Google Groups: http://groups.google.com/group/netzke
|
98
|
-
Netzke tutorials: http://blog.writelesscode.com
|
99
|
-
|
100
|
-
========================================================================
|
101
|
-
|
100
|
+
post_install_message: "\n\
|
101
|
+
========================================================================\n\n Thanks for installing Netzke Core!\n \n Don't forget to run \"./script/generate netzke_core\" for each Rails \n app that will be using this gem.\n\n Netzke home page: http://netzke.org\n Netzke Google Groups: http://groups.google.com/group/netzke\n Netzke tutorials: http://blog.writelesscode.com\n\n\
|
102
|
+
========================================================================\n\n"
|
102
103
|
rdoc_options:
|
103
104
|
- --charset=UTF-8
|
104
105
|
require_paths:
|
@@ -108,7 +109,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
108
109
|
requirements:
|
109
110
|
- - ">="
|
110
111
|
- !ruby/object:Gem::Version
|
111
|
-
hash: 3
|
112
112
|
segments:
|
113
113
|
- 0
|
114
114
|
version: "0"
|
@@ -117,7 +117,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
117
117
|
requirements:
|
118
118
|
- - ">="
|
119
119
|
- !ruby/object:Gem::Version
|
120
|
-
hash: 3
|
121
120
|
segments:
|
122
121
|
- 0
|
123
122
|
version: "0"
|