rsence-pre 2.3.0.19 → 2.3.0.20

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.
@@ -504,7 +504,8 @@ HView = UtilMethods.extend({
504
504
  } else {
505
505
  _themeName = HThemeManager.currentTheme;
506
506
  }
507
- return HThemeManager._componentGfxPath( _themeName, this.componentName, this.themePath );
507
+ // return HThemeManager._componentGfxPath( _themeName, this.componentName, this.themePath );
508
+ return HThemeManager.themePaths[_themeName];
508
509
  },
509
510
 
510
511
  /** = Description
@@ -520,7 +521,8 @@ HView = UtilMethods.extend({
520
521
  } else {
521
522
  _themeName = HThemeManager.currentTheme;
522
523
  }
523
- return HThemeManager._componentGfxFile( _themeName, this.componentName, this.themePath, _fileName );
524
+ // return HThemeManager._componentGfxFile( _themeName, this.componentName, this.themePath, _fileName );
525
+ return HThemeManager._buildThemePath( _fileName, _themeName );
524
526
  },
525
527
 
526
528
  /** --
@@ -716,7 +718,7 @@ HView = UtilMethods.extend({
716
718
  this.drawRect();
717
719
  if(!_isDrawn){
718
720
  this.firstDraw();
719
- if(this['componentName']!==undefined){
721
+ if(this.componentName!==undefined){
720
722
  this.drawMarkup();
721
723
  }
722
724
  else if(BROWSER_TYPE.ie && this._ieNoThrough === null){
@@ -779,21 +781,24 @@ HView = UtilMethods.extend({
779
781
  * active theme is used.
780
782
  * ++
781
783
  **/
782
- _loadMarkup: function() {
783
- var _themeName, _markup;
784
- if (this.preserveTheme) {
785
- _themeName = this.theme;
786
- }
787
- else {
788
- _themeName = HThemeManager.currentTheme;
789
- }
790
- _markup = HThemeManager.getMarkup( _themeName, this.componentName, this.themePath );
791
- if(_markup === false && !this.isProduction){
792
- console.log('Warning: Markup template for "'+this.componentName+'" using theme "'+_themeName+'" not loaded.');
793
- }
794
- this.markup = _markup;
795
- return (_markup !== false);
796
- },
784
+ // _loadMarkup: function() {
785
+ // var _themeName, _themeData, _markup, _markupFns;
786
+ // if (this.preserveTheme) {
787
+ // _themeName = this.theme;
788
+ // }
789
+ // else {
790
+ // _themeName = HThemeManager.currentTheme;
791
+ // }
792
+ // _themeData = HThemeManager.getMarkup( _themeName, this.componentName, this.themePath );
793
+ // if(_themeData === false && !this.isProduction){
794
+ // console.log('Warning: Markup template for "'+this.componentName+'" using theme "'+_themeName+'" not loaded.');
795
+ // }
796
+ // _markup = _themeData[0];
797
+ // _markupFns = _themeData[1];
798
+ // this.markup = _markup;
799
+ // this.markupFns = _markupFns;
800
+ // return (_markup !== false);
801
+ // },
797
802
 
798
803
  /** = Description
799
804
  * Replaces the contents of the view's DOM element with html from the theme specific html file.
@@ -806,18 +811,27 @@ HView = UtilMethods.extend({
806
811
  // ELEM.setStyle(this.elemId, 'display', 'none', true);
807
812
 
808
813
  // continue processing from here on:
809
- var _markupStatus = this._loadMarkup();
810
-
811
- this.bindMarkupVariables();
812
- ELEM.setHTML(this.elemId, this.markup);
814
+ // var _markupStatus = this._loadMarkup();
813
815
 
816
+ // this.bindMarkupVariables();
817
+ var _themeName, _markup;
818
+ if (this.preserveTheme) {
819
+ _themeName = this.theme;
820
+ }
821
+ else {
822
+ _themeName = HThemeManager.currentTheme;
823
+ }
824
+ _markup = HThemeManager.resourcesFor( this, _themeName );
814
825
  this.markupElemIds = {};
815
- for(var i=0; i < this.markupElemNames.length; i++ ) {
816
- var _partName = this.markupElemNames[ i ],
817
- _elemName = _partName + this.elemId,
818
- _htmlIdMatch = ' id="' + _elemName + '"';
819
- if( ~this.markup.indexOf( _htmlIdMatch ) ) {
820
- this.markupElemIds[ _partName ] = this.bindDomElement( _elemName );
826
+ if( _markup !== '' ){
827
+ ELEM.setHTML(this.elemId, _markup);
828
+ for(var i=0; i < this.markupElemNames.length; i++ ) {
829
+ var _partName = this.markupElemNames[ i ],
830
+ _elemName = _partName + this.elemId,
831
+ _htmlIdMatch = ' id="' + _elemName + '"';
832
+ if( ~_markup.indexOf( _htmlIdMatch ) ) {
833
+ this.markupElemIds[ _partName ] = this.bindDomElement( _elemName );
834
+ }
821
835
  }
822
836
  }
823
837
 
@@ -1,15 +1,15 @@
1
1
 
2
2
  # the library path of this plugin
3
- lib_path = File.join( bundle_path, 'lib' )
3
+ lib_path = File.expand_path( 'lib', bundle_path )
4
4
 
5
5
  # The ClientPkgCache class:
6
- require File.join( lib_path, 'client_pkg_cache' )
6
+ require File.expand_path( 'client_pkg_cache', lib_path )
7
7
 
8
8
  # The ClientPkgServe module:
9
- require File.join( lib_path, 'client_pkg_serve' )
9
+ require File.expand_path( 'client_pkg_serve', lib_path )
10
10
 
11
11
  # The ClientPkgBuild class:
12
- require File.join( lib_path, 'client_pkg_build' )
12
+ require File.expand_path( 'client_pkg_build', lib_path )
13
13
 
14
14
 
15
15
  # @private The ClientPkgPlugin builds and serves the client packages. It's not intended to be a part of the public API at this time.
@@ -28,7 +28,7 @@ class ClientPkgBuild
28
28
  return gz_string
29
29
  end
30
30
 
31
- def read_css( src_path )
31
+ def read_css( src_path, theme_name, component_name )
32
32
  css_data = read_file( src_path )
33
33
  unless @debug
34
34
  unless @no_whitespace_removal
@@ -38,27 +38,56 @@ class ClientPkgBuild
38
38
  end
39
39
  end
40
40
  end
41
- if @no_gzip
42
- gz_css = false
43
- else
44
- gz_css = gzip_string( css_data )
45
- end
46
- return [css_data, gz_css]
41
+ tmpl_to_js( css_data, theme_name, component_name )
47
42
  end
48
43
 
49
- def read_html( src_path )
44
+ ID_RE = /(#\{_ID\})/
45
+ WIDTH_RE = /(#\{_WIDTH\})/
46
+ HEIGHT_RE = /(#\{_HEIGHT\})/
47
+ TMPL_RE = /([#\$])\{([^\}]*?)\}/m
48
+ def tmpl_to_js( tmpl, theme_name, component_name )
49
+ js_cmds = []
50
+ seq_num = 10
51
+ cached_idx = {}
52
+ tmpl.gsub!( ID_RE, ']I[')
53
+ tmpl.gsub!( WIDTH_RE, ']W[')
54
+ tmpl.gsub!( HEIGHT_RE, ']H[')
55
+ tmpl.gsub!( TMPL_RE ) do
56
+ ( js_type, js_code ) = [ $1, $2 ]
57
+ if cached_idx.has_key?( js_code )
58
+ seq_id = cached_idx[ js_code ]
59
+ else
60
+ seq_id = seq_num.to_s(36)
61
+ cached_idx[ js_code ] = seq_id
62
+ seq_num += 1
63
+ if js_code.include?('_HEIGHT')
64
+ fn_args = '_ID,_WIDTH,_HEIGHT'
65
+ elsif js_code.include?('_WIDTH')
66
+ fn_args = '_ID,_WIDTH'
67
+ elsif js_code.include?('_ID')
68
+ fn_args = '_ID'
69
+ else
70
+ fn_args = ''
71
+ end
72
+ if js_type == '$'
73
+ js_cmds << "function(#{fn_args}){#{js_code}}"
74
+ else
75
+ js_cmds << "function(#{fn_args}){return #{js_code}}"
76
+ end
77
+ end
78
+ "#{js_type}{#{seq_id}}"
79
+ end
80
+ %{[[#{js_cmds.join(',')}],#{tmpl.to_json}]}
81
+ end
82
+
83
+ def read_html( src_path, theme_name, component_name )
50
84
  html_data = read_file( src_path )
51
85
  unless @debug
52
86
  unless @no_whitespace_removal
53
87
  html_data = @html_min.minimize( html_data )
54
88
  end
55
89
  end
56
- if @no_gzip
57
- gz_html = false
58
- else
59
- gz_html = gzip_string( html_data )
60
- end
61
- return [html_data, gz_html]
90
+ tmpl_to_js( html_data, theme_name, component_name )
62
91
  end
63
92
 
64
93
  def read_gfx( src_path_theme, theme_newest )
@@ -92,36 +121,34 @@ class ClientPkgBuild
92
121
  theme_newest = 0
93
122
  end
94
123
  if theme_newest == 0 or find_newer( src_path_theme, theme_newest )
95
- theme_css = { :data => '' }
96
- theme_html = { :data => '' }
97
124
  theme_size = {
98
125
  :css => [0,0],
99
126
  :html => [0,0],
100
127
  :gfx => 0
101
128
  }
129
+ theme_css = ''
102
130
  [ File.join( src_path_theme, bundle_name+'.css' ),
103
131
  File.join( src_path_theme, 'css', bundle_name+'.css' )
104
132
  ].each do |src_file_css|
105
133
  if File.exist?( src_file_css )
106
134
  fstat = File.stat( src_file_css )
107
135
  theme_newest = fstat.mtime.to_f if fstat.mtime.to_f > theme_newest
108
- ( css_data, gz_css ) = read_css( src_file_css )
109
- theme_css = { :data => css_data, :gzip => gz_css }
136
+ theme_css = read_css( src_file_css, theme_name, bundle_name )
110
137
  theme_size[:css][0] += fstat.size
111
- theme_size[:css][1] += css_data.bytesize
138
+ theme_size[:css][1] += theme_css.bytesize
112
139
  break
113
140
  end
114
141
  end
142
+ theme_html = ''
115
143
  [ File.join( src_path_theme, bundle_name+'.html' ),
116
144
  File.join( src_path_theme, 'html', bundle_name+'.html' )
117
145
  ].each do |src_file_html|
118
146
  if File.exist?( src_file_html )
119
147
  fstat = File.stat( src_file_html )
120
148
  theme_newest = fstat.mtime.to_f if fstat.mtime.to_f > theme_newest
121
- ( html_data, gz_html ) = read_html( src_file_html )
122
- theme_html = { :data => html_data, :gzip => gz_html }
149
+ theme_html = read_html( src_file_html, theme_name, bundle_name )
123
150
  theme_size[:html][0] += fstat.size
124
- theme_size[:html][1] += html_data.bytesize
151
+ theme_size[:html][1] += theme_html.bytesize
125
152
  break
126
153
  end
127
154
  end
@@ -142,8 +169,8 @@ class ClientPkgBuild
142
169
  theme_html = tc[:html]
143
170
  theme_gfx = tc[:gfx]
144
171
  end
145
- @html_by_theme[theme_name][bundle_name] = theme_html[:data]
146
- @css_by_theme[theme_name][bundle_name] = theme_css[:data]
172
+ @html_by_theme[theme_name][bundle_name] = theme_html
173
+ @css_by_theme[theme_name][bundle_name] = theme_css
147
174
  th = @themes[theme_name]
148
175
  th[:css][bundle_name] = theme_css
149
176
  th[:html][bundle_name] = theme_html
@@ -161,9 +188,7 @@ class ClientPkgBuild
161
188
  ts[:html][0] += theme_size[:html][0]
162
189
  ts[:html][1] += theme_size[:html][1]
163
190
  ts[:gfx] += theme_size[:gfx]
164
-
165
191
  end
166
-
167
192
  @theme_time += (Time.now.to_f - time_start)
168
193
  end
169
194
 
@@ -379,43 +404,37 @@ class ClientPkgBuild
379
404
  @theme_names.each do |theme_name|
380
405
  html_templates = @html_by_theme[ theme_name ]
381
406
  css_templates = @css_by_theme[ theme_name ]
382
- theme_css_template_data = css_templates.values.join("\n")
383
- theme_html_js_arr = []
384
- theme_html_js_arr.push "(function(){"
385
- theme_html_js_arr.push "HThemeManager._tmplCache[#{theme_name.to_json}]=#{html_templates.to_json}; "
386
- theme_html_js_arr.push "HNoComponentCSS.push(#{theme_name.to_json});"
387
- theme_html_js_arr.push "HNoCommonCSS.push(#{theme_name.to_json});"
388
- theme_html_js_arr.push %{
389
- HThemeManager._pushStart( function(){
390
- var _this = HThemeManager;
391
- _this._cssUrl( #{theme_name.to_json}, #{(theme_name+'_theme').to_json}, _this.themePath, null );
392
- _this.useCSS(#{theme_css_template_data.to_json});
393
- } );
394
- }
395
- theme_html_js_arr.push "})();"
396
- theme_html_js = theme_html_js_arr.join("\n")
397
- @package_origsizes[theme_name+'_theme'] = theme_html_js.bytesize
398
- theme_html_js = process_js( theme_html_js )
399
- @js[theme_name+'_theme'] = theme_html_js
400
- unless @no_gzip
401
- theme_html_gz = gzip_string( @js[theme_name+'_theme'] )
402
- @gz[theme_name+'_theme'] = theme_html_gz
407
+ css_template = ''
408
+ css_templates.each do |bundle_name,theme_data|
409
+ css_template += "#{bundle_name.to_json}:#{theme_data}," unless theme_data.empty?
403
410
  end
404
- unless @quiet
405
- print_stat( "#{theme_name}/html", @theme_sizes[theme_name][:html][0], @theme_sizes[theme_name][:html][1], theme_html_gz.bytesize )
406
- end
407
- @themes[theme_name][:css][theme_name+'_theme'] = {
408
- :data => theme_css_template_data,
409
- :gzip => false
410
- }
411
- unless @no_gzip
412
- theme_css_template_data_gz = gzip_string( theme_css_template_data )
413
- @themes[theme_name][:css][theme_name+'_theme'][:gzip] = theme_css_template_data_gz
411
+ css_template.chop! if css_template.end_with?(',')
412
+ # theme_css_template_data = css_templates.values.join(",")
413
+ html_template = ''
414
+ html_templates.each do |bundle_name,theme_data|
415
+ html_template += "#{bundle_name.to_json}:#{theme_data}," unless theme_data.empty?
414
416
  end
417
+ html_template.chop! if html_template.end_with?(',')
418
+ theme_html_js = "(function(){HThemeManager.installThemeData(#{theme_name.to_json},{#{css_template}},{#{html_template}})})();"
419
+ pkg_name = theme_name+'_theme'
420
+ orig_size = theme_html_js.bytesize
421
+ theme_html_js = @jsmin.minimize( theme_html_js ) unless @no_whitespace_removal
422
+ @destination_files[pkg_name] = theme_html_js
423
+ @destination_origsize[pkg_name] = orig_size
424
+ # @package_origsizes[theme_name+'_theme'] = theme_html_js.bytesize
425
+ # theme_html_js = process_js( theme_html_js )
426
+ # @js[theme_name+'_theme'] = theme_html_js
427
+ # unless @no_gzip
428
+ # theme_html_gz = gzip_string( @js[theme_name+'_theme'] )
429
+ # @gz[theme_name+'_theme'] = theme_html_gz
430
+ # end
431
+ # unless @quiet
432
+ # print_stat( "#{theme_name}/html", @theme_sizes[theme_name][:html][0], @theme_sizes[theme_name][:html][1], theme_html_gz.bytesize )
433
+ # end
415
434
  unless @quiet
416
- print_stat( "#{theme_name}/css", @theme_sizes[theme_name][:css][0], @theme_sizes[theme_name][:css][1], theme_css_template_data_gz.bytesize )
435
+ # print_stat( "#{theme_name}/css", @theme_sizes[theme_name][:css][0], @theme_sizes[theme_name][:css][1], theme_css_template_data_gz.bytesize )
417
436
  print_stat( "#{theme_name}/gfx", @theme_sizes[theme_name][:gfx], @theme_sizes[theme_name][:gfx], @theme_sizes[theme_name][:gfx] )
418
- @logger.log( '' )
437
+ # @logger.log( '' )
419
438
  end
420
439
  end
421
440
  @theme_time += (Time.now.to_f - time_start)
@@ -520,10 +539,11 @@ class ClientPkgBuild
520
539
 
521
540
  compose_destinations
522
541
 
523
- build_indexes
542
+ build_themes
524
543
 
544
+ build_indexes
525
545
  minimize_data
526
- build_themes
546
+
527
547
  build_compound_packages
528
548
 
529
549
  ms_taken = ((Time.now.to_f*10000)-time_start).round/10.0
@@ -143,17 +143,15 @@ module ClientPkgServe
143
143
  has_theme = @client_cache.theme_cache.has_key?( theme_name )
144
144
 
145
145
  # checks for theme part (css/html/gfx)
146
- has_theme_part = ( has_theme and @client_cache.theme_cache[theme_name].has_key?( theme_part ) )
146
+ if theme_part == :css or theme_part == :html
147
+ has_theme_part = false
148
+ else
149
+ has_theme_part = ( has_theme and @client_cache.theme_cache[theme_name].has_key?(theme_part) )
150
+ end
147
151
 
148
152
  # checks for theme file
149
153
  has_theme_file = ( has_theme_part and @client_cache.theme_cache[theme_name][theme_part].has_key?( req_file ) )
150
154
 
151
- if not has_theme_file and req_file == 'common.css'
152
- response.status = 200
153
- response['Content-Type'] = 'text/css'
154
- response.body = ''
155
- end
156
-
157
155
  if not has_theme
158
156
  response.status = 404
159
157
  response.body = '404 - Theme Not Found'
@@ -166,50 +164,28 @@ module ClientPkgServe
166
164
  response.body = '404 - Theme Resource Not Found'
167
165
  puts "File not found, avail: #{@client_cache.theme_cache[theme_name][theme_part].keys.join(', ')}" if RSence.args[:verbose]
168
166
  else
169
-
170
167
  response.status = 200
171
-
172
168
  file_ext = req_file.split('.')[-1]
173
169
  response['Content-Type'] = {
174
- 'html' => 'text/html; charset=utf-8',
175
- 'css' => 'text/css; charset=utf-8',
176
170
  'png' => 'image/png',
177
171
  'jpg' => 'image/jpeg',
178
172
  'gif' => 'image/gif',
179
173
  'swf' => 'application/x-shockwave-flash'
180
174
  }[file_ext]
181
-
182
- if theme_part == :gfx
183
- support_gzip = false
184
- else
185
- support_gzip = support_gzip?( ua )
175
+ # Special IE6 condition to serve gifs instead of png's, because it works much better
176
+ # than using the ActiveX alpha filter hack
177
+ if ua[:msie6] and req_file[-4..-1] == '.png'
178
+ ie6_req_png2gif = req_file.gsub('.png','-ie6.gif')
179
+ req_file = ie6_req_png2gif if @client_cache.theme_cache[theme_name][theme_part].include?(ie6_req_png2gif)
186
180
  end
187
-
188
- if support_gzip
189
- response['Last-Modified'] = @client_cache.last_modified
190
- body = @client_cache.theme_cache[theme_name][theme_part][ req_file+'.gz' ]
191
- response['Content-Length'] = body.bytesize.to_s
192
- response['Content-Encoding'] = 'gzip'
193
- response.body = body
194
- else
195
-
196
- # Special IE6 condition to serve gifs instead of png's, because it works much better
197
- # than using the ActiveX alpha filter hack
198
- if ua[:msie6] and req_file[-4..-1] == '.png'
199
- ie6_req_png2gif = req_file.gsub('.png','-ie6.gif')
200
- req_file = ie6_req_png2gif if @client_cache.theme_cache[theme_name][theme_part].include?(ie6_req_png2gif)
201
- end
202
-
203
- response['Last-Modified'] = @client_cache.last_modified
204
- body = @client_cache.theme_cache[theme_name][theme_part][ req_file ]
205
- if body.nil?
206
- warn "ClientPkgServe#get: empty body for #{request.path}"
207
- body = ''
208
- end
209
- response['Content-Length'] = body.bytesize.to_s
210
- response.body = body
211
-
181
+ response['Last-Modified'] = @client_cache.last_modified
182
+ body = @client_cache.theme_cache[theme_name][theme_part][req_file]
183
+ if body.nil?
184
+ warn "ClientPkgServe#get: empty body for #{request.path}"
185
+ body = ''
212
186
  end
187
+ response['Content-Length'] = body.bytesize.to_s
188
+ response.body = body
213
189
  end
214
190
  end
215
191
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rsence-pre
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.0.19
4
+ version: 2.3.0.20
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-02-27 00:00:00.000000000 Z
13
+ date: 2013-03-01 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rsence-deps
@@ -289,7 +289,6 @@ files:
289
289
  - js/core/iefix/ie_css_style.htc
290
290
  - js/core/iefix/iefix.js
291
291
  - js/core/rsence_ns/rsence_ns.coffee
292
- - js/core/rsence_ns/rsence_ns.js
293
292
  - js/core/util/util_methods/util_methods.coffee
294
293
  - js/datetime/calendar/calendar.coffee
295
294
  - js/datetime/calendar/themes/default/calendar.css
@@ -338,7 +337,7 @@ files:
338
337
  - js/foundation/json_renderer/json_renderer.js
339
338
  - js/foundation/locale_settings/locale_settings.js
340
339
  - js/foundation/system/system.js
341
- - js/foundation/thememanager/thememanager.js
340
+ - js/foundation/thememanager/thememanager.coffee
342
341
  - js/foundation/value/value.js
343
342
  - js/foundation/view/markupview/markupview.js
344
343
  - js/foundation/view/morphanimation/morphanimation.js