rsence 2.2.0 → 2.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. data/VERSION +1 -1
  2. data/js/comm/queue/queue.js +17 -8
  3. data/js/comm/transporter/transporter.js +11 -10
  4. data/js/controls/button/themes/bright/button_parts1.png +0 -0
  5. data/js/controls/button/themes/default/button_parts1.png +0 -0
  6. data/js/controls/checkbox/themes/default/checkbox_parts1.png +0 -0
  7. data/js/controls/dialogs/sheet/themes/default/sheet_bg.png +0 -0
  8. data/js/controls/dialogs/sheet/themes/default/sheet_dim.png +0 -0
  9. data/js/controls/dialogs/sheet/themes/default/sheet_parts1.png +0 -0
  10. data/js/controls/dialogs/sheet/themes/default/sheet_parts2.png +0 -0
  11. data/js/controls/dialogs/sheet/themes/default/sheet_warning.png +0 -0
  12. data/js/controls/radiobutton/themes/default/radiobutton_parts1.png +0 -0
  13. data/js/controls/searchfield/themes/default/searchfield_parts1.png +0 -0
  14. data/js/controls/sliders/slider/themes/default/hslider_tracks.png +0 -0
  15. data/js/controls/sliders/slider/themes/default/slider_thumbs.png +0 -0
  16. data/js/controls/sliders/vslider/themes/default/vslider_tracks.png +0 -0
  17. data/js/controls/tab/tab.js +4 -3
  18. data/js/controls/tab/themes/bright/tab_bg_color.png +0 -0
  19. data/js/controls/tab/themes/bright/tab_border_pattern.png +0 -0
  20. data/js/controls/tab/themes/bright/tab_parts1.png +0 -0
  21. data/js/controls/tab/themes/default/tab_bg_color.png +0 -0
  22. data/js/controls/tab/themes/default/tab_border_pattern.png +0 -0
  23. data/js/controls/tab/themes/default/tab_parts1.png +0 -0
  24. data/js/controls/textcontrol/textcontrol.js +3 -1
  25. data/js/controls/textcontrol/themes/default/textcontrol_parts1.png +0 -0
  26. data/js/controls/textcontrol/themes/default/textcontrol_parts2.png +0 -0
  27. data/js/controls/textcontrol/themes/default/textcontrol_parts3.png +0 -0
  28. data/js/controls/validatorview/themes/default/validator.png +0 -0
  29. data/js/controls/window/themes/default/window.css +66 -54
  30. data/js/controls/window/themes/default/window.html +6 -2
  31. data/js/controls/window/themes/default/window_bg_active.png +0 -0
  32. data/js/controls/window/themes/default/window_bg_inactive.png +0 -0
  33. data/js/controls/window/themes/default/window_buttons.png +0 -0
  34. data/js/controls/window/themes/default/window_parts1.png +0 -0
  35. data/js/controls/window/themes/default/window_parts2.png +0 -0
  36. data/js/controls/window/window.js +167 -40
  37. data/js/core/class/class.js +3 -0
  38. data/js/core/elem/elem.coffee +36 -16
  39. data/js/datetime/calendar/calendar.coffee +24 -8
  40. data/js/datetime/calendar/themes/default/calendar.html +2 -2
  41. data/js/datetime/calendar/themes/default/calendar_arrows.png +0 -0
  42. data/js/datetime/calendar/themes/default/calendar_bg.png +0 -0
  43. data/js/datetime/calendar/themes/default/calendar_parts1.png +0 -0
  44. data/js/datetime/calendar/themes/default/calendar_parts2.png +0 -0
  45. data/js/datetime/timesheet_item/themes/default/timesheet_item_icons.png +0 -0
  46. data/js/datetime/timesheet_item/timesheet_item.js +1 -1
  47. data/js/foundation/geom/rect/rect.js +83 -47
  48. data/js/foundation/thememanager/thememanager.js +3 -0
  49. data/js/foundation/view/markupview/markupview.js +1 -1
  50. data/js/foundation/view/view.js +136 -37
  51. data/js/lists/propertylist/propertylist.js +33 -31
  52. data/js/menus/minimenu/minimenu.js +4 -2
  53. data/js/menus/minimenu/themes/default/minimenu.png +0 -0
  54. data/js/menus/minimenuitem/themes/default/minimenuitem_checkmark.png +0 -0
  55. data/js/menus/popupmenu/themes/default/popupmenu.png +0 -0
  56. data/js/util/reloadapp/themes/default/reloadapp_warning.png +0 -0
  57. data/lib/rsence/argv/startup_argv.rb +1 -1
  58. data/lib/rsence/default_config.rb +2 -2
  59. data/lib/rsence/plugins/plugin.rb +0 -1
  60. data/plugins/client_pkg/client_pkg.rb +7 -9
  61. data/plugins/client_pkg/lib/client_pkg_build.rb +214 -99
  62. data/plugins/main/main.rb +5 -1
  63. metadata +4 -4
@@ -69,7 +69,7 @@ HPropertyList = HControl.extend({
69
69
  drawSubviews: function(){
70
70
 
71
71
  var borderAndBg = ELEM.make(this.elemId);
72
- ELEM.setCSS(borderAndBg,'position:absolute;left:0;top:0;right:0;bottom:0;background-color:#e6e6e6;border:1px solid #999;');
72
+ ELEM.setCSS(borderAndBg,'position:absolute;left:0;top:0;right:0;bottom:0;background-color:#e6e6e6;border:1px solid #999999;');
73
73
 
74
74
  this.markupElemIds = {
75
75
  bg: borderAndBg
@@ -131,7 +131,9 @@ HPropertyList = HControl.extend({
131
131
  this.keyColumn = HView.nu(
132
132
  [ 0, 0, this.keyColumnRight(), 24 ],
133
133
  this.contentView, {
134
- style: [ [ 'border-right', '1px solid #999' ] ]
134
+ style: {
135
+ borderRight: '1px solid #999'
136
+ }
135
137
  }
136
138
  );
137
139
 
@@ -140,7 +142,9 @@ HPropertyList = HControl.extend({
140
142
  this.typeColumn = HView.nu(
141
143
  [ this.typeColumnLeft(), 0, 60, 24 ],
142
144
  this.contentView, {
143
- style: [ [ 'border-right', '1px solid #999' ] ]
145
+ style: {
146
+ borderRight: '1px solid #999'
147
+ }
144
148
  }
145
149
  );
146
150
  }
@@ -160,13 +164,13 @@ HPropertyList = HControl.extend({
160
164
  [ 0, 0, this.parent.keyColumnRight(), 24 ],
161
165
  this, {
162
166
  html: '<b>Key</b>',
163
- style: [
164
- [ 'text-align', 'middle' ],
165
- [ 'text-indent', '16px' ],
166
- [ 'line-height', '24px' ],
167
- [ 'font-size', '13px' ],
168
- [ 'border-right', '3px double #999' ]
169
- ]
167
+ style: {
168
+ verticalAlign: 'middle',
169
+ textIndent: '16px',
170
+ lineHeight: '24px',
171
+ fontSize: '13px',
172
+ borderRight: '3px double #999999'
173
+ }
170
174
  }
171
175
  );
172
176
  if(!this.parent.options.hideTypeColumn){
@@ -174,14 +178,14 @@ HPropertyList = HControl.extend({
174
178
  [ this.parent.typeColumnLeft(), 0, 60, 24 ],
175
179
  this, {
176
180
  html: '<b>Type</b>',
177
- style: [
178
- [ 'text-align', 'middle' ],
179
- [ 'text-indent', '8px' ],
180
- [ 'line-height', '24px' ],
181
- [ 'font-size', '13px' ],
182
- [ 'padding-right', '1px' ],
183
- [ 'border-right', '1px solid #999' ]
184
- ]
181
+ style: {
182
+ verticalAlign: 'middle',
183
+ textIndent: '8px',
184
+ lineHeight: '24px',
185
+ fontSize: '13px',
186
+ paddingRight: '1px',
187
+ borderRight: '1px solid #999999'
188
+ }
185
189
  }
186
190
  );
187
191
  }
@@ -189,19 +193,19 @@ HPropertyList = HControl.extend({
189
193
  [ this.parent.valueColumnLeft(), 0, 80, 24, 0, null ],
190
194
  this, {
191
195
  html: '<b>Value</b>',
192
- style: [
193
- [ 'text-align', 'middle' ],
194
- [ 'text-indent', '8px' ],
195
- [ 'line-height', '24px' ],
196
- [ 'font-size', '13px' ]
197
- ]
196
+ style: {
197
+ verticalAlign: 'middle',
198
+ textIndent: '8px',
199
+ lineHeight: '24px',
200
+ fontSize: '13px'
201
+ }
198
202
  }
199
203
  );
200
204
  }
201
205
  }).nu(
202
206
  [ 0, 0, null, 24, 0, null ],
203
207
  this, {
204
- style: [ [ 'border-bottom', '1px solid #999' ] ]
208
+ style: { borderBottom: '1px solid #999' }
205
209
  }
206
210
  );
207
211
 
@@ -231,8 +235,8 @@ HPropertyList = HControl.extend({
231
235
  keyColumn = parent.keyColumn,
232
236
  keyLabel = parent.header.keyLabel,
233
237
  keyRight = parent.keyColumnRight();
234
- keyColumn.rect.setRight( keyRight );
235
- keyLabel.rect.setRight( keyRight );
238
+ keyColumn.rect.setRight( keyRight );
239
+ keyLabel.rect.setRight( keyRight );
236
240
 
237
241
  var
238
242
  valueColumn = parent.valueColumn,
@@ -275,9 +279,7 @@ HPropertyList = HControl.extend({
275
279
  [ this.keyColumnRight(), 0, 5, 25 ],
276
280
  this, {
277
281
  events: { draggable: true },
278
- style: [
279
- [ 'cursor', 'ew-resize' ]
280
- ]
282
+ style: { cursor: 'ew-resize' }
281
283
  }
282
284
  );
283
285
 
@@ -452,7 +454,7 @@ HPropertyList = HControl.extend({
452
454
  },
453
455
 
454
456
  // Row separator style
455
- rowSeparatorStyle: "position:absolute;left:1px;right:1px;font-size:0px;height:1px;overflow:hidden;border-bottom:1px solid #999;",
457
+ rowSeparatorStyle: "position:absolute;left:1px;right:1px;font-size:0px;height:1px;overflow:hidden;border-bottom:1px solid #999999;",
456
458
 
457
459
  // Adds row separator
458
460
  addRowSeparator: function( token, i, even ){
@@ -82,8 +82,10 @@ HMiniMenu = HRadioButtonList.extend({
82
82
  },
83
83
 
84
84
  menuHide: function(){
85
- this.menuItemView.sendToBack();
86
- this.menuItemView.hide();
85
+ if( this.menuItemView ){
86
+ this.menuItemView.sendToBack();
87
+ this.menuItemView.hide();
88
+ }
87
89
  },
88
90
 
89
91
  startDrag: function(x,y){
@@ -69,7 +69,7 @@ module ArgvUtil
69
69
  elsif arg == '--disable-obfuscation'
70
70
  @args[:client_pkg_no_obfuscation] = true
71
71
  elsif arg == '--disable-jsmin'
72
- @args[:client_pkg_no_whitespace_removel] = true
72
+ @args[:client_pkg_no_whitespace_removal] = true
73
73
  elsif arg == '--build-report'
74
74
  @args[:suppress_build_messages] = false
75
75
  else
@@ -144,8 +144,8 @@ module RSence
144
144
  config[:session_conf][:reset_sessions] = true if args[:reset_ses]
145
145
  config[:daemon][:http_delayed_start] = args[:http_delayed_start] if args[:http_delayed_start] != nil
146
146
 
147
- config[:client_pkg][:no_obfuscation] = true if args[:client_pkg_no_obfuscation]
148
- config[:client_pkg][:no_whitespace_removal] = true if args[:client_pkg_no_whitespace_removal]
147
+ config[:client_pkg][:no_obfuscation] = args[:client_pkg_no_obfuscation]
148
+ config[:client_pkg][:no_whitespace_removal] = args[:client_pkg_no_whitespace_removal]
149
149
 
150
150
  # Sets the default pid and log paths used by the HTTPDaemon
151
151
  if config[:daemon].has_key?(:pid_fn)
@@ -670,7 +670,6 @@ module RSence
670
670
  # Called from +#restore_ses+
671
671
  def restore_ses_values( msg )
672
672
  return unless @values
673
- ses = get_ses( msg )
674
673
  if @values.class == Array
675
674
  @values.each do | value_item |
676
675
  value_item.each do | value_name, value_properties |
@@ -55,17 +55,15 @@ class ClientPkgPlugin < Servlet
55
55
  end
56
56
 
57
57
  def rebuild_client
58
- while @build_busy
59
- puts "-- build busy, sleeping.. --"
60
- sleep 0.1
61
- end
62
58
  @build_busy = true
63
- @last_change = Time.now.to_i
59
+ next_change=Time.now.to_f
64
60
  @client_build.setup_dirs
65
- @client_build.run
66
- @client_cache = ClientPkgCache.new
67
- @client_cache.set_cache( @client_build.js, @client_build.gz, @client_build.themes )
61
+ @client_build.run( next_change )
62
+ client_cache = ClientPkgCache.new
63
+ client_cache.set_cache( @client_build.js, @client_build.gz, @client_build.themes )
64
+ @client_cache = client_cache
68
65
  RSence.plugin_manager.incr! if RSence.config[:transporter_conf][:client_autoreload]
66
+ @last_change = next_change
69
67
  @build_busy = false
70
68
  end
71
69
 
@@ -79,7 +77,7 @@ class ClientPkgPlugin < Servlet
79
77
  Thread.pass
80
78
  while true
81
79
  begin
82
- if @client_build.bundle_changes( @last_change )
80
+ if not @build_busy and @client_build.bundle_changes( @last_change )
83
81
  rebuild_client
84
82
  puts "Autobuilt."
85
83
  if RSence.args[:say]
@@ -7,7 +7,7 @@
7
7
  ##
8
8
 
9
9
 
10
- require 'jsminc'
10
+ require 'jsmin_c'
11
11
  require 'jscompress'
12
12
  require 'html_min'
13
13
  begin
@@ -69,65 +69,110 @@ class ClientPkgBuild
69
69
  return [html_data, gz_html]
70
70
  end
71
71
 
72
- def read_gfx( src_path_theme, tgt_hash_gfx )
72
+ def read_gfx( src_path_theme, theme_newest )
73
73
  gfx_size = 0
74
+ gfx_data = {}
74
75
  src_files_gfx_path = File.join( src_path_theme, 'gfx' )
75
76
  [ src_path_theme, src_files_gfx_path ].each do |src_files_gfx|
76
77
  if File.exist?( src_files_gfx )
77
78
  Dir.entries( src_files_gfx ).each do |src_gfx_filename|
78
79
  src_file_gfx = File.join( src_files_gfx, src_gfx_filename )
79
80
  if @gfx_formats.include?( src_file_gfx[-4..-1] )
80
- tgt_hash_gfx[src_gfx_filename] = read_file( src_file_gfx )
81
- gfx_size += File.stat( src_file_gfx ).size
81
+ fstat = File.stat( src_file_gfx )
82
+ theme_newest = fstat.mtime.to_f if fstat.mtime.to_f > theme_newest
83
+ gfx_size += fstat.size
84
+ gfx_data[src_gfx_filename] = read_file( src_file_gfx )
82
85
  end
83
86
  end
84
87
  end
85
88
  end
86
- return gfx_size
89
+ return [ gfx_size, gfx_data, theme_newest ]
87
90
  end
88
91
 
89
92
  # processes theme-related files
90
93
  def read_theme( bundle_dir, bundle_name )
94
+ time_start = Time.now.to_f
91
95
  @theme_names.each do |theme_name|
92
- @theme_sizes[ theme_name ] = {
93
- :css => [0,0],
94
- :html => [0,0],
95
- :gfx => 0
96
- } unless @theme_sizes.has_key?( theme_name )
97
- tgt_hash_theme = @themes[theme_name]
98
96
  src_path_theme = File.join( bundle_dir, 'themes', theme_name )
99
- [ File.join( src_path_theme, bundle_name+'.css' ),
100
- File.join( src_path_theme, 'css', bundle_name+'.css' )
101
- ].each do |src_file_css|
102
- if File.exist?( src_file_css )
103
- ( css_data, gz_css ) = read_css( src_file_css )
104
- tgt_hash_css = tgt_hash_theme[:css][bundle_name] = {
105
- :data => css_data,
106
- :gzip => gz_css
107
- }
108
- @theme_sizes[ theme_name ][:css][0] += File.stat( src_file_css ).size
109
- @theme_sizes[ theme_name ][:css][1] += css_data.bytesize
110
- @css_by_theme[ theme_name ][ bundle_name ] = css_data
111
- end
97
+ if @src_cache[:theme_timestamp].has_key?(src_path_theme)
98
+ theme_newest = @src_cache[:theme_timestamp][src_path_theme]
99
+ else
100
+ theme_newest = 0
112
101
  end
113
- [ File.join( src_path_theme, bundle_name+'.html' ),
114
- File.join( src_path_theme, 'html', bundle_name+'.html' )
115
- ].each do |src_file_html|
116
- if File.exist?( src_file_html )
117
- ( html_data, gz_html ) = read_html( src_file_html )
118
- tgt_hash_html = tgt_hash_theme[:html][bundle_name] = {
119
- :data => html_data,
120
- :gzip => gz_html
121
- }
122
- @theme_sizes[ theme_name ][:html][0] += File.stat( src_file_html ).size
123
- @theme_sizes[ theme_name ][:html][1] += html_data.bytesize
124
- @html_by_theme[ theme_name ][ bundle_name ] = html_data
102
+ if theme_newest == 0 or find_newer( src_path_theme, theme_newest )
103
+ theme_css = { :data => '' }
104
+ theme_html = { :data => '' }
105
+ theme_size = {
106
+ :css => [0,0],
107
+ :html => [0,0],
108
+ :gfx => 0
109
+ }
110
+ [ File.join( src_path_theme, bundle_name+'.css' ),
111
+ File.join( src_path_theme, 'css', bundle_name+'.css' )
112
+ ].each do |src_file_css|
113
+ if File.exist?( src_file_css )
114
+ fstat = File.stat( src_file_css )
115
+ theme_newest = fstat.mtime.to_f if fstat.mtime.to_f > theme_newest
116
+ ( css_data, gz_css ) = read_css( src_file_css )
117
+ theme_css = { :data => css_data, :gzip => gz_css }
118
+ theme_size[:css][0] += fstat.size
119
+ theme_size[:css][1] += css_data.bytesize
120
+ break
121
+ end
122
+ end
123
+ [ File.join( src_path_theme, bundle_name+'.html' ),
124
+ File.join( src_path_theme, 'html', bundle_name+'.html' )
125
+ ].each do |src_file_html|
126
+ if File.exist?( src_file_html )
127
+ fstat = File.stat( src_file_html )
128
+ theme_newest = fstat.mtime.to_f if fstat.mtime.to_f > theme_newest
129
+ ( html_data, gz_html ) = read_html( src_file_html )
130
+ theme_html = { :data => html_data, :gzip => gz_html }
131
+ theme_size[:html][0] += fstat.size
132
+ theme_size[:html][1] += html_data.bytesize
133
+ break
134
+ end
125
135
  end
136
+ ( gfx_size, theme_gfx, theme_newest ) = read_gfx( src_path_theme, theme_newest )
137
+ theme_size[:gfx] += gfx_size
138
+ @src_cache[:theme_timestamp][src_path_theme] = theme_newest
139
+ @src_cache[:theme_data][src_path_theme] = {} unless @src_cache[:theme_data].has_key?(src_path_theme)
140
+ @src_cache[:theme_data][src_path_theme][:size] = theme_size
141
+ @src_cache[:theme_data][src_path_theme][:data] = {
142
+ :css => theme_css,
143
+ :html => theme_html,
144
+ :gfx => theme_gfx
145
+ }
146
+ else
147
+ theme_size = @src_cache[:theme_data][src_path_theme][:size]
148
+ tc = @src_cache[:theme_data][src_path_theme][:data]
149
+ theme_css = tc[:css]
150
+ theme_html = tc[:html]
151
+ theme_gfx = tc[:gfx]
152
+ end
153
+ @html_by_theme[theme_name][bundle_name] = theme_html[:data]
154
+ @css_by_theme[theme_name][bundle_name] = theme_css[:data]
155
+ th = @themes[theme_name]
156
+ th[:css][bundle_name] = theme_css
157
+ th[:html][bundle_name] = theme_html
158
+ th[:gfx].merge!(theme_gfx)
159
+ unless @theme_sizes.has_key?( theme_name )
160
+ @theme_sizes[ theme_name ] = {
161
+ :css => [0,0],
162
+ :html => [0,0],
163
+ :gfx => 0
164
+ }
126
165
  end
127
- tgt_hash_gfx = tgt_hash_theme[:gfx]
128
- gfx_size = read_gfx( src_path_theme, tgt_hash_gfx )
129
- @theme_sizes[ theme_name ][:gfx] += gfx_size
166
+ ts = @theme_sizes[theme_name]
167
+ ts[:css][0] += theme_size[:css][0]
168
+ ts[:css][1] += theme_size[:css][1]
169
+ ts[:html][0] += theme_size[:html][0]
170
+ ts[:html][1] += theme_size[:html][1]
171
+ ts[:gfx] += theme_size[:gfx]
172
+
130
173
  end
174
+
175
+ @theme_time += (Time.now.to_f - time_start)
131
176
  end
132
177
 
133
178
  def add_bundle( bundle_name, bundle_path, entries, has_js=false, has_coffee=false )
@@ -144,45 +189,74 @@ class ClientPkgBuild
144
189
  return true
145
190
  end
146
191
  if has_coffee and @coffee_supported
147
- begin
148
- coffee_start = Time.new.to_f
149
- coffee_path = File.join( bundle_path, bundle_name+'.coffee' )
150
- coffee_timestamp = File.stat( coffee_path ).mtime.to_i
151
- has_cache_compiled = @coffee_cache[:path_compiled].has_key?( coffee_path )
152
- has_cache_timestamp = @coffee_cache[:path_timestamp].has_key?( coffee_path )
153
- has_cache_entry = has_cache_compiled and has_cache_timestamp
154
- has_cached = ( has_cache_entry and ( @coffee_cache[:path_timestamp][coffee_path] == coffee_timestamp ) )
155
- if has_cached
156
- js_data = @coffee_cache[:path_compiled][coffee_path]
192
+ src_path = File.join( bundle_path, bundle_name+'.coffee' )
193
+ is_coffee = true
194
+ elsif not has_js
195
+ src_path = false
196
+ else
197
+ src_path = File.join( bundle_path, bundle_name+'.js' )
198
+ is_coffee = false
199
+ end
200
+ if src_path
201
+ src_timestamp = File.stat( src_path ).mtime.to_i
202
+ src_cache_compiled = @src_cache[:path_compiled].has_key?( src_path )
203
+ src_cache_timestamp = @src_cache[:path_timestamp].has_key?( src_path )
204
+ src_cache_entry = src_cache_compiled and src_cache_timestamp
205
+ src_cached = ( src_cache_entry and ( @src_cache[:path_timestamp][src_path] == src_timestamp ) )
206
+ if src_cached
207
+ js_data = @src_cache[:path_compiled][src_path]
208
+ js_size = @src_cache[:orig_size][src_path]
209
+ min_size = js_data.bytesize
210
+ else
211
+ process_start = Time.new.to_f
212
+ if is_coffee
213
+ begin
214
+ coffee_src = read_file( src_path )
215
+ js_data = CoffeeScript.compile( coffee_src, :bare => true )
216
+ rescue CoffeeScript::CompilationError
217
+ if has_js
218
+ js_data = %{console.log( "WARNING: CoffeeScript complilation failed for source file #{src_path.to_json}, using the js variant instead." );}
219
+ js_data += read_file( File.join( bundle_path, bundle_name+'.js' ) )
220
+ else
221
+ js_data = %{console.log( "WARNING: CoffeeScript complilation failed for source file #{src_path.to_json}" );}
222
+ end
223
+ end
157
224
  else
158
- coffee_src = read_file( coffee_path )
159
- js_data = CoffeeScript.compile( coffee_src, :bare => true )
160
- @coffee_cache[:path_timestamp][coffee_path] = coffee_timestamp
161
- @coffee_cache[:path_compiled][coffee_path] = js_data
225
+ js_data = read_file( src_path )
162
226
  end
163
- @coffee_time += ( Time.new.to_f - coffee_start )
164
- rescue CoffeeScript::CompilationError
165
- if has_js
166
- js_data = %{console.log( "WARNING: CoffeeScript complilation failed for source file #{coffee_path}, using the js variant instead." );}
167
- js_data += read_file( File.join( bundle_path, bundle_name+'.js' ) )
227
+ js_size = js_data.bytesize
228
+ if @debug
229
+ min_size = js_size
168
230
  else
169
- js_data = %{console.log( "WARNING: CoffeeScript complilation failed for source file #{coffee_path}" );}
231
+ js_data = @jsmin.minimize( js_data ) unless @no_whitespace_removal
232
+ min_size = js_data.bytesize
170
233
  end
234
+ if is_coffee
235
+ @coffee_time += ( Time.new.to_f - process_start )
236
+ else
237
+ @js_time += ( Time.new.to_f - process_start )
238
+ end
239
+ @src_cache[:path_timestamp][src_path] = src_timestamp
240
+ @src_cache[:path_compiled][src_path] = js_data
241
+ @src_cache[:orig_size][src_path] = js_size
171
242
  end
172
- elsif not has_js
173
- js_data = %{console.log( "ERROR: CoffeeScript not suuported and no JS source available for #{bundle_path}" );}
174
243
  else
175
- js_data = read_file( File.join( bundle_path, bundle_name+'.js' ) )
244
+ js_data = %{console.log( "ERROR: CoffeeScript not suuported and no JS source available for #{bundle_path}" );}
245
+ js_size = js_data.bytesize
246
+ min_size = js_size
247
+ src_timestamp = 0
176
248
  end
177
249
  @bundles_found[ bundle_name ] = {
178
250
  :path => bundle_path,
179
251
  :js_data => js_data,
180
- :js_size => js_data.bytesize,
181
- :has_themes => has_themes
252
+ :js_size => min_size,
253
+ :orig_size => js_size,
254
+ :has_themes => has_themes,
255
+ :src_timestamp => src_timestamp
182
256
  }
183
- if has_themes
184
- read_theme( bundle_path, bundle_name )
185
- end
257
+
258
+ read_theme( bundle_path, bundle_name ) if has_themes
259
+
186
260
  return true
187
261
  end
188
262
 
@@ -229,9 +303,10 @@ class ClientPkgBuild
229
303
  @logger.log( '' )
230
304
  @logger.log( "Client package build report.......................#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}" )
231
305
  @logger.log( '' )
232
- @logger.log( "JS Package....................: Original | Minimized | Compressed" )
306
+ @logger.log( "JS Package....................: Source | Minimized | GNUZipped" )
233
307
  @logger.log( " : | |" )
234
308
  end
309
+ @package_origsizes = {}
235
310
  @destination_files.each_key do | package_name |
236
311
  jsc_data = process_js( @destination_files[package_name] )
237
312
  @js[package_name] = jsc_data
@@ -240,7 +315,8 @@ class ClientPkgBuild
240
315
  @gz[package_name] = gz_data
241
316
  end
242
317
  unless @quiet
243
- js_size = @destination_files[ package_name ].bytesize
318
+ js_size = @destination_origsize[package_name] #@destination_files[ package_name ].bytesize
319
+ @package_origsizes[package_name] = js_size
244
320
  jsc_size = jsc_data.bytesize
245
321
  if @no_gzip
246
322
  gz_size = -1
@@ -255,17 +331,22 @@ class ClientPkgBuild
255
331
  def squeeze( js, is_coffee=false )
256
332
  unless @no_whitespace_removal
257
333
  begin
258
- # js = @jsmin.minimize( js )#.strip
259
- js = JSMinC.minify( js )
334
+ js = @jsmin.minimize( js ).strip
335
+ # js = JSMinC.minify( js )
260
336
  rescue IndexError => e
261
337
  warn "js can't get smaller using js; just ignoring jsmin"
262
338
  end
263
339
  end
264
340
  unless @no_obfuscation
265
- @jscompress.build_indexes( js )
266
- js = @jscompress.compress( js )
341
+ begin
342
+ ## Not creating new indexes on the fly, to save some speed
343
+ # @jscompress.build_indexes( js )
344
+ js = @jscompress.compress( js )
345
+ rescue
346
+ warn "jscompress failed squeeze; just ignoring jscompress"
347
+ end
267
348
  end
268
- return js.strip
349
+ return js
269
350
  end
270
351
 
271
352
  def coffee( src )
@@ -290,17 +371,16 @@ class ClientPkgBuild
290
371
  return src_in
291
372
  else
292
373
  src_out = src_in
293
- # src_out = @jsmin.minimize( src_out ) unless @no_whitespace_removal
294
- src_out = JSMinC.minify( src_out ) unless @no_whitespace_removal
295
374
  src_out = pre_convert( src_out ) unless @no_obfuscation
296
- return src_out.strip
375
+ return src_out
297
376
  end
298
377
  end
299
378
 
300
379
  def build_themes
380
+ time_start = Time.now.to_f
301
381
  unless @quiet
302
382
  @logger.log( '' )
303
- @logger.log( "Theme name and part...........: Original | Minimized | Compressed" )
383
+ @logger.log( "Theme name and part...........: Source | Minimized | GNUZipped" )
304
384
  @logger.log( " : | |" )
305
385
  end
306
386
  # compile "all-in-one" css and html resources
@@ -309,6 +389,7 @@ class ClientPkgBuild
309
389
  css_templates = @css_by_theme[ theme_name ]
310
390
  theme_css_template_data = css_templates.values.join("\n")
311
391
  theme_html_js_arr = []
392
+ theme_html_js_arr.push "(function(){"
312
393
  theme_html_js_arr.push "HThemeManager._tmplCache[#{theme_name.to_json}]=#{html_templates.to_json}; "
313
394
  theme_html_js_arr.push "HNoComponentCSS.push(#{theme_name.to_json});"
314
395
  theme_html_js_arr.push "HNoCommonCSS.push(#{theme_name.to_json});"
@@ -319,7 +400,10 @@ class ClientPkgBuild
319
400
  _this.useCSS(#{theme_css_template_data.to_json});
320
401
  } );
321
402
  }
322
- theme_html_js = process_js( theme_html_js_arr.join('') )
403
+ theme_html_js_arr.push "})();"
404
+ theme_html_js = theme_html_js_arr.join("\n")
405
+ @package_origsizes[theme_name+'_theme'] = theme_html_js.bytesize
406
+ theme_html_js = process_js( theme_html_js )
323
407
  @js[theme_name+'_theme'] = theme_html_js
324
408
  unless @no_gzip
325
409
  theme_html_gz = gzip_string( @js[theme_name+'_theme'] )
@@ -338,47 +422,48 @@ class ClientPkgBuild
338
422
  end
339
423
  unless @quiet
340
424
  print_stat( "#{theme_name}/css", @theme_sizes[theme_name][:css][0], @theme_sizes[theme_name][:css][1], theme_css_template_data_gz.bytesize )
341
- print_stat( "#{theme_name}/gfx", @theme_sizes[theme_name][:gfx], -1, -1 )
425
+ print_stat( "#{theme_name}/gfx", @theme_sizes[theme_name][:gfx], @theme_sizes[theme_name][:gfx], @theme_sizes[theme_name][:gfx] )
342
426
  @logger.log( '' )
343
427
  end
344
428
  end
429
+ @theme_time += (Time.now.to_f - time_start)
345
430
  end
346
431
 
347
432
  def build_compound_packages
433
+ time_start = Time.now.to_f
348
434
  unless @quiet
349
435
  @logger.log( '' )
350
- @logger.log( "Compound package..............: Original | Minimized | Compressed" )
436
+ @logger.log( "Compound package..............: Source | Minimized | GNUZipped" )
351
437
  @logger.log( " : | |" )
352
438
  end
353
439
  @compound_config.each do |pkg_name, js_order|
440
+ js_size = 0
354
441
  pkg_parts = []
355
442
  js_order.each do |js_pkg|
356
443
  pkg_part = @js[ js_pkg ]
357
444
  pkg_parts.push( pkg_part )
445
+ js_size += ( @package_origsizes[ js_pkg ] or @destination_origsize[ js_pkg ] )
358
446
  end
359
- js_src = pkg_parts.join('')
447
+ js_src = pkg_parts.join("\n")
360
448
  @js[ pkg_name ] = js_src
361
449
  unless @no_gzip
362
450
  gz_data = gzip_string( js_src )
363
451
  @gz[ pkg_name ] = gz_data
364
452
  end
365
453
  unless @quiet
366
- js_size = js_src.bytesize
454
+ jsc_size = js_src.bytesize
367
455
  if @no_gzip
368
456
  gz_size = -1
369
457
  else
370
458
  gz_size = gz_data.bytesize
371
459
  end
372
- print_stat( pkg_name, js_size, -1, gz_size )
460
+ print_stat( pkg_name, js_size, jsc_size, gz_size )
373
461
  end
374
462
  end
463
+ @js_time += (Time.now.to_f - time_start)
375
464
  end
376
465
 
377
- def run
378
-
379
- time_start = Time.now.to_f*10000
380
- @coffee_time = 0
381
-
466
+ def reset_structures
382
467
  # hash of bundles per bundle name per theme; @html_by_theme[theme_name][bundle_name] = bundle_data
383
468
  @html_by_theme = {}
384
469
  @css_by_theme = {}
@@ -397,33 +482,60 @@ class ClientPkgBuild
397
482
  end
398
483
  @bundles_found = {} # populated by add_bundle
399
484
  @conversion_stats = {} # populated by add_hints
485
+ end
486
+
487
+ def traverse_bundles
400
488
  src_dirs = @src_dirs.clone
401
489
  src_dirs.each do | src_dir |
402
490
  find_bundles( src_dir )
403
491
  end
492
+ end
493
+
494
+ def compose_destinations
404
495
  @destination_files = {} # rename to package_products
496
+ @destination_origsize = {}
405
497
  @package_names.each do |package_name|
406
498
  @packages[package_name].each do |bundle_name|
407
499
  if @bundles_found.has_key?( bundle_name )
408
500
  @destination_files[ package_name ] = [] unless @destination_files.has_key?( package_name )
409
501
  @destination_files[ package_name ].push( @bundles_found[bundle_name][:js_data] )
502
+ @destination_origsize[ package_name ] = 0 unless @destination_origsize.has_key?( package_name )
503
+ @destination_origsize[ package_name ] += @bundles_found[bundle_name][:orig_size]
410
504
  end
411
505
  end
412
506
  end
413
507
  @destination_files.each do | package_name, package_array |
414
- package_data = package_array.join('')
508
+ package_data = package_array.join("\n")
415
509
  @destination_files[ package_name ] = package_data
416
510
  end
511
+ end
512
+
513
+ def run( last_change=0 )
514
+
515
+ time_start = Time.now.to_f*10000
516
+ @coffee_time = 0
517
+ @js_time = 0
518
+ @theme_time = 0
519
+ @last_change = last_change
520
+
521
+ reset_structures
417
522
 
523
+ traverse_bundles
524
+
525
+ compose_destinations
526
+
418
527
  build_indexes
419
- build_themes
528
+
420
529
  minimize_data
530
+ build_themes
421
531
  build_compound_packages
422
532
 
423
533
  ms_taken = ((Time.now.to_f*10000)-time_start).round/10.0
534
+ js_taken = (@js_time*10000).round/10.0
424
535
  coffee_taken = (@coffee_time*10000).round/10.0
425
- without_coffee = ((ms_taken - coffee_taken)*10).round/10.0
426
- @logger.log( "Time taken:\n .coffee: #{coffee_taken}ms\n other: #{without_coffee}ms\n total: #{ms_taken}ms\n\n" )
536
+ themes_taken = (@theme_time*10000).round/10.0
537
+ other_taken = ((ms_taken - coffee_taken - js_taken - themes_taken)*10).round/10.0
538
+ @logger.log( "\nTime taken:\n js: #{js_taken}ms\n coffee: #{coffee_taken}ms\n themes: #{themes_taken}ms\n other: #{other_taken}ms\n total: #{ms_taken}ms\n\n" )
427
539
 
428
540
  end
429
541
 
@@ -544,9 +656,12 @@ class ClientPkgBuild
544
656
  def initialize( config, logger )
545
657
 
546
658
  @coffee_supported = config[:coffee_supported]
547
- @coffee_cache = {
659
+ @src_cache = {
548
660
  :path_timestamp => {},
549
- :path_compiled => {}
661
+ :path_compiled => {},
662
+ :orig_size => {},
663
+ :theme_timestamp => {},
664
+ :theme_data => {}
550
665
  }
551
666
 
552
667
  @logger = logger
@@ -580,7 +695,7 @@ class ClientPkgBuild
580
695
  @html_min = HTMLMin.new
581
696
 
582
697
  # JSMin removes js white-space (makes the source shorter)
583
- # @jsmin = JSMin.new
698
+ @jsmin = JSMin.new
584
699
 
585
700
  # makes sure the specified dirs are ok
586
701
  return if not setup_dirs
@@ -607,7 +722,7 @@ class ClientPkgBuild
607
722
  @compound_config = config[:compound_packages]
608
723
  end
609
724
 
610
- def find_newer( src_dir, newer_than )
725
+ def find_newer( src_dir, newer_than, quiet=false )
611
726
  if File.exist?( src_dir ) and File.directory?( src_dir )
612
727
  Dir.entries( src_dir ).each do | dir_entry |
613
728
  next if dir_entry[0].chr == '.'
@@ -616,7 +731,7 @@ class ClientPkgBuild
616
731
  return true if find_newer( sub_dir, newer_than )
617
732
  else
618
733
  if newer_than < File.stat( sub_dir ).mtime.to_i
619
- @logger.log( "File changed: #{sub_dir}" )
734
+ @logger.log( "File changed: #{sub_dir}" ) unless quiet
620
735
  return true
621
736
  end
622
737
  end
@@ -635,7 +750,7 @@ class ClientPkgBuild
635
750
  end
636
751
 
637
752
  def print_stat( package_name, dst_size, jsc_size, gz_size )
638
- percent = 'n/a'
753
+ # percent = 'n/a'
639
754
  if dst_size > 0
640
755
  percent1 = (100*(jsc_size/dst_size.to_f)).to_i.to_s + '%'
641
756
  percent2 = (100*(gz_size/dst_size.to_f)).to_i.to_s + '%'