rsence 2.0.0.pre → 2.0.0.1.pre

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.
Files changed (80) hide show
  1. data/INSTALL.rdoc +295 -0
  2. data/LICENSE +622 -0
  3. data/README.rdoc +87 -0
  4. data/VERSION +1 -0
  5. data/bin/rsence +5 -101
  6. data/conf/config.yaml +4 -0
  7. data/conf/default_conf.yaml +6 -4
  8. data/conf/{local_conf.yaml → local_conf.yaml.devel} +2 -1
  9. data/js/comm/comm/autosync/autosync.js +0 -1
  10. data/js/comm/comm/queue/queue.js +1 -1
  11. data/js/comm/comm/urlresponder/urlresponder.js +58 -35
  12. data/js/comm/comm/values/values.js +13 -3
  13. data/js/comm/jsloader/jsloader.js +29 -12
  14. data/js/controls/button/themes/default/button_parts1-ie6.gif +0 -0
  15. data/js/controls/checkbox/themes/default/checkbox_parts1-ie6.gif +0 -0
  16. data/js/controls/datetime/timesheet/timesheet.js +2 -2
  17. data/js/controls/dialogs/sheet/themes/default/sheet_bg-ie6.gif +0 -0
  18. data/js/controls/dialogs/sheet/themes/default/sheet_parts1-ie6.gif +0 -0
  19. data/js/controls/dialogs/sheet/themes/default/sheet_parts2-ie6.gif +0 -0
  20. data/js/controls/dialogs/sheet/themes/default/sheet_warning-ie6.gif +0 -0
  21. data/js/controls/passwordcontrol/themes/default/passwordcontrol.html +1 -1
  22. data/js/controls/radiobutton/themes/default/radiobutton_parts1-ie6.gif +0 -0
  23. data/js/controls/sliders/slider/themes/default/hslider_tracks-ie6.gif +0 -0
  24. data/js/controls/sliders/slider/themes/default/slider.css +2 -0
  25. data/js/controls/sliders/slider/themes/default/slider_thumbs-ie6.gif +0 -0
  26. data/js/controls/sliders/vslider/themes/default/vslider.css +2 -0
  27. data/js/controls/sliders/vslider/themes/default/vslider_tracks-ie6.gif +0 -0
  28. data/js/controls/stepper/themes/default/stepper-ie6.gif +0 -0
  29. data/js/controls/tab/tab.js +2 -6
  30. data/js/controls/tab/themes/default/tab.css +1 -0
  31. data/js/controls/tab/themes/default/tab.html +1 -1
  32. data/js/controls/tab/themes/default/tab_border_pattern-ie6.gif +0 -0
  33. data/js/controls/tab/themes/default/tab_parts1-ie6.gif +0 -0
  34. data/js/controls/textarea/themes/default/textarea.css +21 -0
  35. data/js/controls/textarea/themes/default/textarea.html +2 -2
  36. data/js/controls/textcontrol/textcontrol.js +56 -69
  37. data/js/controls/textcontrol/themes/default/textcontrol.css +23 -20
  38. data/js/controls/textcontrol/themes/default/textcontrol.html +1 -1
  39. data/js/controls/window/themes/default/window.css +1 -0
  40. data/js/controls/window/themes/default/window_bg_active-ie6.gif +0 -0
  41. data/js/controls/window/themes/default/window_bg_inactive-ie6.gif +0 -0
  42. data/js/controls/window/themes/default/window_buttons-ie6.gif +0 -0
  43. data/js/controls/window/themes/default/window_parts1-ie6.gif +0 -0
  44. data/js/controls/window/themes/default/window_parts2-ie6.gif +0 -0
  45. data/js/controls/window/window.js +28 -7
  46. data/js/core/class/class.js +31 -30
  47. data/js/core/elem/elem.js +94 -71
  48. data/js/core/event/event.js +34 -26
  49. data/js/core/iefix/iefix.js +46 -31
  50. data/js/debugg/debugg.js +43 -0
  51. data/js/debugg/js.inc +0 -0
  52. data/js/foundation/application/application.js +3 -1
  53. data/js/foundation/control/dyncontrol/dyncontrol.js +1 -0
  54. data/js/foundation/control/eventresponder/eventresponder.js +1 -1
  55. data/js/foundation/json_renderer/json_renderer.js +1 -3
  56. data/js/foundation/system/system.js +4 -4
  57. data/js/foundation/thememanager/thememanager.js +3 -3
  58. data/js/foundation/view/view.js +71 -1
  59. data/lib/conf/argv.rb +664 -0
  60. data/lib/conf/default.rb +51 -52
  61. data/lib/daemon/daemon.rb +281 -195
  62. data/lib/plugins/plugin_plugins.rb +47 -0
  63. data/lib/plugins/pluginmanager.rb +17 -12
  64. data/lib/transporter/transporter.rb +6 -9
  65. data/plugins/client_pkg/client_pkg.rb +12 -9
  66. data/plugins/client_pkg/lib/client_pkg_build.rb +1 -1
  67. data/plugins/index_html/tmpl/index.html +3 -3
  68. data/plugins/main/main.rb +1 -0
  69. metadata +16 -14
  70. data/bin/build_client.rb +0 -254
  71. data/bin/help +0 -6
  72. data/bin/launch.rb +0 -120
  73. data/bin/rdoc.sh +0 -2
  74. data/bin/restart +0 -6
  75. data/bin/run +0 -6
  76. data/bin/run.rb +0 -6
  77. data/bin/save +0 -6
  78. data/bin/start +0 -6
  79. data/bin/status +0 -6
  80. data/bin/stop +0 -6
@@ -0,0 +1,47 @@
1
+ ## Riassence Framework
2
+ # Copyright 2010 Riassence Inc.
3
+ # http://riassence.com/
4
+ #
5
+ # You should have received a copy of the GNU General Public License along
6
+ # with this software package. If not, contact licensing@riassence.com
7
+ ##
8
+
9
+ ## Interface to enable plugins in a plugin. Just include this in your subclass of Plugin.
10
+ module PluginPlugins
11
+ def init
12
+ super
13
+ @plugin_plugins = RSence::PluginManager.new( [ bundle_path('plugins') ] )
14
+ end
15
+ def open
16
+ super
17
+ @plugin_plugins.delegate(:open)
18
+ end
19
+ def close
20
+ super
21
+ @plugin_plugins.delegate(:close)
22
+ end
23
+ def flush
24
+ super
25
+ @plugin_plugins.delegate(:flush)
26
+ end
27
+ def idle( msg )
28
+ super
29
+ @plugin_plugins.delegate(:idle,msg)
30
+ end
31
+ def init_ses( msg )
32
+ super
33
+ @plugin_plugins.delegate(:init_ses,msg)
34
+ end
35
+ def restore_ses( msg )
36
+ super
37
+ @plugin_plugins.delegate(:restore_ses,msg)
38
+ end
39
+ def cloned_target( msg, source_session )
40
+ super
41
+ @plugin_plugins.delegate(:cloned_target,msg,source_session)
42
+ end
43
+ def cloned_source( msg, target_session )
44
+ super
45
+ @plugin_plugins.delegate(:cloned_source,msg,target_session)
46
+ end
47
+ end
@@ -58,6 +58,9 @@ require 'plugins/plugin_sqlite_db'
58
58
  # servlet includes the Servlet class, for handling any requests / responses
59
59
  require 'plugins/servlet'
60
60
 
61
+ # Interface for plugins in a plugin bundle
62
+ require 'plugins/plugin_plugins'
63
+
61
64
  ## = Abstract
62
65
  ## PluginManager is the service that loads and provides method delegation
63
66
  ## amongst all installed plugins.
@@ -72,15 +75,16 @@ class PluginManager
72
75
 
73
76
  # Initialize with a list of directories as plugin_paths.
74
77
  # It's an array containing all plugin directories to scan.
75
- def initialize( transporter, plugin_paths )
76
- @transporter = transporter
77
- @sessions = transporter.sessions
78
+ def initialize( plugin_paths, transporter=nil, autoreload=false )
79
+ if transporter
80
+ @transporter = transporter
81
+ @sessions = transporter.sessions
82
+ end
78
83
  @plugin_paths = plugin_paths
79
- puts "Loading plugins..."
84
+ puts "Loading plugins..." if RSence.args[:verbose]
80
85
  scan_plugins
81
- puts "Plugins loaded."
82
- puts "Riassence Framework is online."
83
- if $DEBUG_MODE
86
+ puts "Plugins loaded." if RSence.args[:verbose]
87
+ if autoreload
84
88
  @thr = Thread.new do
85
89
  Thread.pass
86
90
  while true
@@ -118,7 +122,7 @@ class PluginManager
118
122
  if @registry.has_key?( bundle_name.to_sym )
119
123
  puts "Disabling bundle #{bundle_name}..."
120
124
  unload_bundle( bundle_name.to_sym )
121
- if ARGV.include?('-say')
125
+ if RSence.args[:say]
122
126
  Thread.new do
123
127
  Thread.pass
124
128
  system(%{say "Unloaded #{bundle_name.to_s}."})
@@ -130,7 +134,7 @@ class PluginManager
130
134
  puts "Loading bundle #{bundle_name}..."
131
135
  load_bundle( bundle_path, bundle_name.to_sym, bundle_name+'.rb' )
132
136
  call( bundle_name.to_sym, :open )
133
- if ARGV.include?('-say')
137
+ if RSence.args[:say]
134
138
  Thread.new do
135
139
  Thread.pass
136
140
  system(%{say "Loaded #{bundle_name.to_s}."})
@@ -144,7 +148,7 @@ class PluginManager
144
148
  unload_bundle( bundle_name.to_sym )
145
149
  load_bundle( bundle_path, bundle_name.to_sym, bundle_name+'.rb' )
146
150
  call( bundle_name.to_sym, :open )
147
- if ARGV.include?('-say')
151
+ if RSence.args[:say]
148
152
  Thread.new do
149
153
  Thread.pass
150
154
  system(%{say "Reloaded #{bundle_name.to_s}."})
@@ -234,11 +238,12 @@ class PluginManager
234
238
  # Finds the most recent file in the path
235
239
  def most_recent( bundle_path, newest_date=0 )
236
240
  path_date = File.stat( bundle_path ).mtime.to_i
237
- if path_date > newest_date
241
+ is_dir = File.directory?( bundle_path )
242
+ if path_date > newest_date and not is_dir
238
243
  # puts "File is newer: #{bundle_path}"
239
244
  newest_date = path_date
240
245
  end
241
- if File.directory?( bundle_path )
246
+ if is_dir
242
247
  Dir.entries( bundle_path ).each do |entry_name|
243
248
  next if entry_name[0].chr == '.'
244
249
  full_path = File.join( bundle_path, entry_name )
@@ -33,13 +33,10 @@ class Transporter
33
33
 
34
34
  @valuemanager = ValueManager.new
35
35
  @sessions = SessionManager.new( self )
36
- @plugins = PluginManager.new( self, ::RSence.config[:plugin_paths] )
37
-
38
-
39
- # Used by:
40
- # plugins/main/main.rb
41
- $SESSION = @sessions
42
-
36
+ @plugins = PluginManager.new( ::RSence.config[:plugin_paths], self, $DEBUG_MODE )
37
+ if RSence.launch_pid != Process.pid
38
+ Process.kill( 'TERM', RSence.launch_pid )
39
+ end
43
40
  end
44
41
 
45
42
  def servlet( request_type, request, response )
@@ -48,7 +45,7 @@ class Transporter
48
45
  # if $DEBUG_MODE and uri == $config[:index_html][:respond_address] and request_type == :get
49
46
  # unless ARGV.include?('-no-rescan') or ARGV.include?('--no-rescan')
50
47
  # puts "Reloading plugins."
51
- # if ARGV.include?('-say')
48
+ # if RSence.args[:say]
52
49
  # Thread.new do
53
50
  # Thread.pass
54
51
  # system('say "Reloading plugins."')
@@ -56,7 +53,7 @@ class Transporter
56
53
  # end
57
54
  # @plugins.rescan
58
55
  # puts "Plugins reloaded."
59
- # if ARGV.include?('-say')
56
+ # if RSence.args[:say]
60
57
  # Thread.new do
61
58
  # Thread.pass
62
59
  # system('say "Plugins reloaded."')
@@ -63,14 +63,17 @@ class ClientPkg < Servlet
63
63
  @log_file = nil
64
64
  end
65
65
  def log( str )
66
- puts str
67
- return
68
- if @last_time < Time.now - 30
69
- @last_time = Time.now
70
- @log_file.write( %{--- #{@last_time.strftime("%Y-%m-%d %H:%M:%S")} ---\n} )
66
+ if ::RSence.args[:verbose]
67
+ puts str
68
+ return
69
+ else
70
+ if @last_time < Time.now - 30
71
+ @last_time = Time.now
72
+ @log_file.write( %{--- #{@last_time.strftime("%Y-%m-%d %H:%M:%S")} ---\n} )
73
+ end
74
+ @log_file.write( "#{str}\n" )
75
+ @log_file.flush
71
76
  end
72
- @log_file.write( "#{str}\n" )
73
- @log_file.flush
74
77
  end
75
78
  def open
76
79
  return if @log_file
@@ -104,7 +107,7 @@ class ClientPkg < Servlet
104
107
  if @client_build.bundle_changes( @last_change )
105
108
  rebuild_client
106
109
  puts "Autobuilt."
107
- if ARGV.include?('-say')
110
+ if RSence.args[:say]
108
111
  Thread.new do
109
112
  Thread.pass
110
113
  system('say "Autobuilt."')
@@ -169,7 +172,7 @@ class ClientPkg < Servlet
169
172
 
170
173
  @thr = false
171
174
 
172
- @build_logger = BuildLogger.new( File.join(@path,'log','build_log') )
175
+ @build_logger = BuildLogger.new( File.join(::RSence.args[:env_path],'log','build_log') )
173
176
  @build_logger.open
174
177
 
175
178
  @client_build = ClientPkgBuild.new( ::RSence.config[:client_pkg], @build_logger )
@@ -538,7 +538,7 @@ class ClientPkgBuild
538
538
  ## end
539
539
  ## flush
540
540
  ## run
541
- ## `say "Autobuild complete!"` if ARGV.include?('-say')
541
+ ## `say "Autobuild complete!"` if RSence.args[:say]
542
542
  ## end
543
543
  ##end
544
544
 
@@ -6,10 +6,10 @@
6
6
  <title>__DEFAULT_TITLE__</title>
7
7
  <style type="text/css">body{margin:0;padding:0;background-color:#ddd;font-family:Arial,sans-serif;}</style>
8
8
  __SCRIPT_DEPS__
9
- <script type="text/javascript" src="__CLIENT_BASE__/js/core.js"></script>
10
- <!--[if lt IE 7]><script type="text/javascript" src="__CLIENT_BASE__/js/iefix.js"></script><![endif]-->
9
+ <script src="__CLIENT_BASE__/js/core.js"></script>
10
+ <!--[if lt IE 7]><script src="__CLIENT_BASE__/js/iefix.js"></script><![endif]-->
11
11
 
12
- <script type="text/javascript">
12
+ <script>
13
13
 
14
14
  /** Runtime configuration: **/
15
15
  HCLIENT_REV='__CLIENT_REV__';
data/plugins/main/main.rb CHANGED
@@ -110,6 +110,7 @@ class Main < Plugin
110
110
  ## to tell the server its status by updating its value
111
111
  location_href_id = ses[:location_href].val_id.to_json
112
112
  msg.reply "COMM.Values.values[#{location_href_id}].bind(COMM.urlResponder);"
113
+
113
114
  ## This enables SesWatcher that changes :client_time every 60 seconds.
114
115
  ## It makes the client to poll the server on regular intervals, when polling mode
115
116
  ## is disabled.
metadata CHANGED
@@ -6,8 +6,9 @@ version: !ruby/object:Gem::Version
6
6
  - 2
7
7
  - 0
8
8
  - 0
9
+ - 1
9
10
  - pre
10
- version: 2.0.0.pre
11
+ version: 2.0.0.1.pre
11
12
  platform: ruby
12
13
  authors:
13
14
  - Riassence Inc.
@@ -15,7 +16,7 @@ autorequire:
15
16
  bindir: bin
16
17
  cert_chain: []
17
18
 
18
- date: 2010-04-16 00:00:00 +03:00
19
+ date: 2010-05-08 00:00:00 +03:00
19
20
  default_executable: rsence
20
21
  dependencies:
21
22
  - !ruby/object:Gem::Dependency
@@ -41,18 +42,8 @@ extensions: []
41
42
  extra_rdoc_files: []
42
43
 
43
44
  files:
44
- - bin/build_client.rb
45
- - bin/help
46
- - bin/launch.rb
47
- - bin/rdoc.sh
48
- - bin/restart
49
45
  - bin/rsence
50
- - bin/run
51
- - bin/run.rb
52
- - bin/save
53
- - bin/start
54
- - bin/status
55
- - bin/stop
46
+ - lib/conf/argv.rb
56
47
  - lib/conf/default.rb
57
48
  - lib/conf/wizard.rb
58
49
  - lib/daemon/daemon.rb
@@ -63,6 +54,7 @@ files:
63
54
  - lib/plugins/gui_plugin.rb
64
55
  - lib/plugins/guiparser.rb
65
56
  - lib/plugins/plugin.rb
57
+ - lib/plugins/plugin_plugins.rb
66
58
  - lib/plugins/plugin_sqlite_db.rb
67
59
  - lib/plugins/plugin_util.rb
68
60
  - lib/plugins/pluginmanager.rb
@@ -75,9 +67,10 @@ files:
75
67
  - lib/values/hvalue.rb
76
68
  - lib/values/valuemanager.rb
77
69
  - conf/config.ru
70
+ - conf/config.yaml
78
71
  - conf/default_conf.yaml
79
72
  - conf/default_strings.yaml
80
- - conf/local_conf.yaml
73
+ - conf/local_conf.yaml.devel
81
74
  - conf/unicorn.conf
82
75
  - plugins/client_pkg/client_pkg.rb
83
76
  - plugins/client_pkg/info.yaml
@@ -175,6 +168,7 @@ files:
175
168
  - js/controls/dialogs/sheet/sheet.js
176
169
  - js/controls/dialogs/sheet/themes/default/sheet.css
177
170
  - js/controls/dialogs/sheet/themes/default/sheet.html
171
+ - js/controls/dialogs/sheet/themes/default/sheet_bg-ie6.gif
178
172
  - js/controls/dialogs/sheet/themes/default/sheet_bg.png
179
173
  - js/controls/dialogs/sheet/themes/default/sheet_dim-ie6.gif
180
174
  - js/controls/dialogs/sheet/themes/default/sheet_dim.png
@@ -279,7 +273,9 @@ files:
279
273
  - js/controls/window/js.inc
280
274
  - js/controls/window/themes/default/window.css
281
275
  - js/controls/window/themes/default/window.html
276
+ - js/controls/window/themes/default/window_bg_active-ie6.gif
282
277
  - js/controls/window/themes/default/window_bg_active.png
278
+ - js/controls/window/themes/default/window_bg_inactive-ie6.gif
283
279
  - js/controls/window/themes/default/window_bg_inactive.png
284
280
  - js/controls/window/themes/default/window_buttons-ie6.gif
285
281
  - js/controls/window/themes/default/window_buttons.png
@@ -298,6 +294,8 @@ files:
298
294
  - js/core/iefix/ie_css_style.htc
299
295
  - js/core/iefix/iefix.js
300
296
  - js/core/iefix/js.inc
297
+ - js/debugg/debugg.js
298
+ - js/debugg/js.inc
301
299
  - js/foundation/application/application.js
302
300
  - js/foundation/application/js.inc
303
301
  - js/foundation/control/control.js
@@ -338,6 +336,10 @@ files:
338
336
  - js/views/inlineview/js.inc
339
337
  - js/views/scrollview/js.inc
340
338
  - js/views/scrollview/scrollview.js
339
+ - README.rdoc
340
+ - INSTALL.rdoc
341
+ - LICENSE
342
+ - VERSION
341
343
  has_rdoc: true
342
344
  homepage: http://www.rsence.org/
343
345
  licenses: []
data/bin/build_client.rb DELETED
@@ -1,254 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #--
3
- ## Riassence Framework
4
- # Copyright 2010 Riassence Inc.
5
- # http://riassence.com/
6
- #
7
- # You should have received a copy of the GNU General Public License along
8
- # with this software package. If not, contact licensing@riassence.com
9
- ##
10
- #++
11
-
12
- if ARGV.include?('--help') or ARGV.include?('-h')
13
- puts %{
14
-
15
- Riassence Framework Client Builder
16
- This script builds the client into the DESTINATION_PATH that defaults to ./client
17
-
18
- Usage:
19
- #{__FILE__} [DESTINATION_PATH] [params]
20
-
21
- Params:
22
- -d Debug/Development mode
23
- --config <PATH> Optional config override file
24
- --auto Checks if the source has changed every 3 seconds
25
- --help This message
26
- -h This message
27
-
28
- Examples:
29
- #{__FILE__} /web/sites/my_site/rsence/client -d
30
-
31
- Further information:
32
- http://riassence.org/
33
-
34
- }
35
- exit
36
- end
37
-
38
- require 'profile' if ARGV.include?('--profile')
39
-
40
- ## Auto-construct paths using this file as the waypoint
41
- SERVER_PATH = ARGV.include?('--root-path')?(ARGV[ARGV.index('--root-path')+1]):File.split(File.expand_path(File.dirname(__FILE__)))[0]
42
-
43
- ## Include server & lib in the search path
44
- $LOAD_PATH << SERVER_PATH
45
- $LOAD_PATH << File.join( SERVER_PATH, 'lib' )
46
-
47
- require 'rubygems'
48
- require 'yaml'
49
- require 'json'
50
-
51
- config = YAML.load( File.read( File.join( SERVER_PATH, 'conf', 'default_conf.yaml' ) ) )
52
-
53
- ## Create default local configuratation override file, if it does not exist:
54
- local_config_file_paths = [
55
- File.join(SERVER_PATH,'conf','local_conf.yaml'),
56
- File.join( File.split( SERVER_PATH )[0], 'conf', 'local_conf.yaml' ),
57
- File.join( Dir.pwd, 'conf', 'local_conf.yaml' ),
58
- File.join(SERVER_PATH,'conf','client-build-config.rb'),
59
- File.join( File.split( SERVER_PATH )[0], 'conf', 'client-build-config.rb' ),
60
- File.join( Dir.pwd, 'conf', 'client-build-config.rb' ),
61
- ]
62
- if ARGV.include?('--config')
63
- argv_conf_file = ARGV[ARGV.index('--config')+1]
64
- if not argv_conf_file.begin_with? '/'
65
- argv_conf_file = File.join( Dir.pwd, conf_file )
66
- end
67
- local_config_file_paths.push( argv_conf_file )
68
- end
69
-
70
- def array_merge( target, source )
71
- source.each do |item|
72
- unless target.include?(item)
73
- if item.class == Array
74
- sub_arr = []
75
- array_merge( sub_arr, item )
76
- target.push( sub_arr )
77
- elsif item.class == Hash
78
- sub_hash = {}
79
- hash_merge( sub_hash, item )
80
- target.push( sub_hash )
81
- else
82
- target.push( item )
83
- end
84
- end
85
- end
86
- end
87
- def hash_merge( target, source )
88
- source.each do |key,item|
89
- if not target.has_key?key or target[key] != item
90
- if item.class == Array
91
- target[key] = [] unless target.has_key?(key)
92
- array_merge( target[key], item )
93
- # if key == :plugin_paths
94
- # puts target[key].inspect
95
- # end
96
- elsif item.class == Hash
97
- target[key] = {} unless target.has_key?key
98
- hash_merge( target[key], item )
99
- else
100
- target[key] = item
101
- end
102
- end
103
- end
104
- end
105
-
106
- local_config_file_path_found = false
107
- local_config_file_paths.each do |local_config_file_path|
108
- if File.exists? local_config_file_path and File.file? local_config_file_path
109
- if local_config_file_path.end_with? '.yaml'
110
- local_conf = YAML.load( File.read( local_config_file_path ) )
111
- hash_merge( config, local_conf )
112
- local_config_file_path_found = true
113
- else
114
- warn "Only Yaml configuration files are allowed at this time."
115
- end
116
- end
117
- end
118
-
119
-
120
- require 'plugins/client_pkg/lib/client_pkg_build'
121
-
122
- class JSBuilder < ClientPkgBuild
123
- def initialize( conf, logger )
124
- super
125
- @conf = conf
126
- @debug = ARGV.include?('-d')
127
- @quiet = false
128
- end
129
- def flush
130
- @jscompress.free_indexes
131
- end
132
- def ensure_client_dir
133
- dst_dir = @conf[:dst_dir]
134
- Dir.mkdir( dst_dir ) unless File.exist?( dst_dir )
135
- js_dir = File.join( dst_dir, 'js' )
136
- Dir.mkdir( js_dir ) unless File.exist?( js_dir )
137
- themes_dir = File.join( dst_dir, 'themes' )
138
- Dir.mkdir( themes_dir ) unless File.exist?( themes_dir )
139
- @themes.each_key do |theme_name|
140
- theme_dir = File.join( themes_dir, theme_name )
141
- Dir.mkdir( theme_dir ) unless File.exist?( theme_dir )
142
- ['gfx','css','html'].each do |theme_part|
143
- theme_part_dir = File.join( theme_dir, theme_part )
144
- Dir.mkdir( theme_part_dir ) unless File.exist?( theme_part_dir )
145
- end
146
- end
147
- end
148
- def store_client_files
149
- dst_dir = @conf[:dst_dir]
150
- js_dir = File.join( dst_dir, 'js' )
151
- @js.each_key do |js_name|
152
- js_path = File.join( js_dir, "#{js_name}.js" )
153
- js_file = File.open( js_path, 'wb' )
154
- js_file.write( @js[js_name] )
155
- js_file.close
156
- end
157
- @gz.each_key do |gz_name|
158
- gz_path = File.join( js_dir, "#{gz_name}.gz" )
159
- gz_file = File.open( gz_path, 'wb' )
160
- gz_file.write( @gz[gz_name] )
161
- gz_file.close
162
- end
163
- themes_dir = File.join( dst_dir, 'themes' )
164
- @themes.each_key do |theme_name|
165
- theme_dir = File.join( themes_dir, theme_name )
166
- gfx_dir = File.join( theme_dir, 'gfx' )
167
- @themes[theme_name][:gfx].each do | img_name, file_data |
168
- img_path = File.join( gfx_dir, img_name )
169
- img_file = File.open( img_path, 'wb' )
170
- img_file.write( file_data )
171
- img_file.close
172
- end
173
- css_dir = File.join( theme_dir, 'css' )
174
- @themes[theme_name][:css].each do | css_name, file_data |
175
- css_path = File.join( css_dir, "#{css_name}.css" )
176
- css_file = File.open( css_path, 'wb' )
177
- css_file.write( file_data )
178
- css_file.close
179
- css_path += '.gz'
180
- css_file = File.open( css_path, 'wb' )
181
- css_file.write( gzip_string( file_data ) )
182
- css_file.close
183
- end
184
- html_dir = File.join( theme_dir, 'html' )
185
- @themes[theme_name][:html].each do | html_name, file_data |
186
- html_path = File.join( html_dir, "#{html_name}.html" )
187
- html_file = File.open( html_path, 'wb' )
188
- html_file.write( file_data )
189
- html_file.close
190
- html_path += '.gz'
191
- html_file = File.open( html_path, 'wb' )
192
- html_file.write( gzip_string( file_data ) )
193
- html_file.close
194
- end
195
- end
196
- built_path = File.join( js_dir, 'built' )
197
- built_file = File.open( built_path, 'w' )
198
- built_file.write( Time.now.to_i.to_s )
199
- built_file.close
200
- end
201
- def run
202
- ensure_client_dir
203
- super
204
- store_client_files
205
- end
206
- end
207
- class Logger
208
- def log( str )
209
- puts str
210
- end
211
- end
212
-
213
- conf = config[:client_pkg]
214
- dst_dir = File.join( SERVER_PATH, 'client' )
215
- if ARGV.length > 0
216
- unless ['-d','-auto','--auto','-say','--config','--root-path'].include?( ARGV[0] )
217
- dst_dir = ARGV[0]
218
- unless dst_dir.start_with?('/')
219
- dst_dir = File.join( SERVER_PATH, dst_dir )
220
- end
221
- end
222
- end
223
- puts "Client build destination directory: #{dst_dir}"
224
- conf[:dst_dir] = dst_dir
225
-
226
- conf[:compound_packages].each do | pkg_name, js_order |
227
- pkg_files = []
228
- js_order.each do |js_pkg|
229
- unless conf[:packages].has_key?(js_pkg)
230
- pkg_files.push( js_pkg )
231
- next
232
- end
233
- conf[:packages][js_pkg].each do |js_file|
234
- pkg_files.push( js_file )
235
- end
236
- end
237
- conf[:packages][ pkg_name ] = pkg_files
238
- end
239
-
240
- js_builder = JSBuilder.new( conf, Logger.new )
241
- js_builder.run
242
- if ARGV.include? '-auto' or ARGV.include? '--auto'
243
- last_change = Time.now.to_i
244
- while true
245
- if js_builder.bundle_changes( last_change )
246
- last_change = Time.now.to_i
247
- js_builder.run
248
- # client_cache.set_cache( @client_build.js, @client_build.gz, @client_build.themes )
249
- `say "Autobuild complete!"` if ARGV.include?('-say')
250
- end
251
- sleep 3
252
- end
253
- end
254
- js_builder.flush