rsence-pre 2.1.0.14 → 2.1.0.15

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.1.0.14.pre
1
+ 2.1.0.15.pre
@@ -46,7 +46,7 @@
46
46
  Invalid environment: <%%= env_path.inspect %>
47
47
 
48
48
  Type 'rsence help <%%= @cmd.to_s %>' for usage."
49
- Type 'rsence help initenv' for environment initialization usage."
49
+ Type 'rsence help init' for environment initialization usage."
50
50
  :invalid_option_chr: |
51
51
  Invalid option character for option character block <%%= arg.inspect %>:
52
52
  <%%= chr.inspect %>
@@ -79,7 +79,7 @@
79
79
  No process running.
80
80
  :session_data_saved: |
81
81
  Session data saved.
82
- # Strings for the initenv command
82
+ # Strings for the init command
83
83
  :initenv:
84
84
  :env_already_initialized: |
85
85
  Environment already initialized.
@@ -171,6 +171,7 @@
171
171
 
172
172
  :confirm_config: "Is the configuration correct, "
173
173
  :creating_dirs: "Creating directories..."
174
+ :install_welcome: "Do you want to install the 'welcome' plugin as a starting point, "
174
175
  :installing_welcome_plugin: |+
175
176
  Installing the welcome plugin. To remove it, just delete this folder:
176
177
  <%%= welcome_plugin_dst %>
@@ -278,9 +279,19 @@
278
279
  'say' command installed.
279
280
 
280
281
  :initenv: |+
281
- usage: 'rsence initenv [options] [PATH]'
282
+ Alias name of the 'init' command.
283
+
284
+ See: rsence help init
285
+
286
+ :initialize: |+
287
+ Alias name of the 'init' command.
288
+
289
+ See: rsence help init
290
+
291
+ :init: |+
292
+ usage: 'rsence init [options] [PATH]'
282
293
 
283
- The 'initenv' command creates a new RSence environment.
294
+ The 'init' command creates a new RSence environment.
284
295
 
285
296
  The expected structure of a project environment (where 'project_directory'
286
297
  is the directory of your project) is:
data/lib/conf/argv.rb CHANGED
@@ -51,10 +51,10 @@ module RSence
51
51
  # system that fully implements POSIX standard signals.
52
52
  # These are necessary to send signals to the background process.
53
53
  if not RSence.pid_support?
54
- @@cmds = [ :run, :initenv, :version, :help ]
54
+ @@cmds = [ :run, :init, :initenv, :version, :help ]
55
55
  else
56
56
  @@cmds = [ :run, :status, :start, :stop, :restart, :save,
57
- :initenv, :version, :help ]
57
+ :init, :initenv, :version, :help ]
58
58
  end
59
59
 
60
60
  help_avail_cmds = @@cmds.map{|cmd|cmd.to_s}.join("\n ")
@@ -724,10 +724,13 @@ module RSence
724
724
  run_dir = File.expand_path( 'run', env_dir )
725
725
  Dir.mkdir( run_dir )
726
726
  unless create_blank
727
- welcome_plugin_dir = File.join( SERVER_PATH, 'setup', 'welcome' )
728
- welcome_plugin_dst = File.join( plugins_dir, 'welcome' )
729
- puts ERB.new( @@strs[:initenv][:installing_welcome_plugin] ).result( binding )
730
- FileUtils.cp_r( welcome_plugin_dir, welcome_plugin_dst )
727
+ print @@strs[:initenv][:install_welcome]
728
+ if yesno(true)
729
+ welcome_plugin_dir = File.join( SERVER_PATH, 'setup', 'welcome' )
730
+ welcome_plugin_dst = File.join( plugins_dir, 'welcome' )
731
+ puts ERB.new( @@strs[:initenv][:installing_welcome_plugin] ).result( binding )
732
+ FileUtils.cp_r( welcome_plugin_dir, welcome_plugin_dst )
733
+ end
731
734
  end
732
735
  puts @@strs[:initenv][:creating_files]
733
736
  conf_file = File.join( conf_dir, 'config.yaml' )
@@ -789,7 +792,7 @@ module RSence
789
792
  parse_status_argv
790
793
  elsif cmd == :save
791
794
  parse_save_argv
792
- elsif cmd == :initenv
795
+ elsif cmd == :initenv or cmd == :init
793
796
  parse_initenv_argv
794
797
  end
795
798
  else
@@ -289,13 +289,140 @@ module RSence
289
289
  end
290
290
  end
291
291
 
292
+ # @private Returns a hash with valid symbol keys for +#value_call+.
293
+ def sanitize_value_call_hash( hash_dirty )
294
+ hash_clean = {}
295
+ hash_dirty.each do | key, value |
296
+ if key.to_sym == :method
297
+ hash_clean[:method] = value.to_sym
298
+ elsif key.to_sym == :plugin
299
+ hash_clean[:plugin] = value.to_sym
300
+ elsif key.to_sym == :args
301
+ if value.class == Array
302
+ hash_clean[:args] = value
303
+ else
304
+ warn "Invalid arguments (#{value.inspect}). Expected Array."
305
+ end
306
+ elsif key.to_sym == :uses_msg
307
+ value == false if value == nil
308
+ if value.class == TrueClass or value.class == FalseClass
309
+ hash_clean[:uses_msg] = value
310
+ else
311
+ warn "Invalid argument for :uses_msg (#{value.inspect}), expected boolean."
312
+ end
313
+ else
314
+ warn "Undefined value_call key: #{key.inspect}"
315
+ end
316
+ end
317
+ return hash_clean
318
+ end
319
+
320
+ # @private Returns a sanitized copy of a single responder specification.
321
+ def sanitize_value_responders( responders_dirty )
322
+ if responders_dirty.class != Array
323
+ warn "Unsupported responders type: #{responders_dirty.inspect} (expected Array or Hash). Trying work-around.." unless responders_dirty.class == Hash
324
+ responders_dirty = [ responders_dirty ]
325
+ end
326
+ responders_clean = []
327
+ responders_dirty.each do |responder_dirty|
328
+ if responder_dirty.class != Hash
329
+ if responder_dirty.class == Symbol
330
+ responder_dirty = { :method => responder_dirty }
331
+ elsif responder_dirty.class == String
332
+ if responder_dirty.include?('.')
333
+ last_dot_index = responder_dirty.rindex('.')
334
+ responder_plugin = responder_dirty[0..(last_dot_index-1)].to_sym
335
+ responder_method = responder_dirty[(last_dot_index+1)..-1].to_sym
336
+ responder_dirty = { :method => responder_method, :plugin => responder_plugin }
337
+ else
338
+ responder_dirty = { :method => responders_dirty.to_sym }
339
+ end
340
+ else
341
+ warn "Unsupported responder type: #{responder_dirty.inspect}. Skipping.."
342
+ next
343
+ end
344
+ end
345
+ responder_clean = {}
346
+ responder_dirty.each do |key, value|
347
+ if key.to_sym == :method
348
+ responder_clean[ :method ] = value.to_sym
349
+ elsif key.to_sym == :plugin
350
+ responder_clean[ :plugin ] = value.to_sym
351
+ else
352
+ warn "Unsupported responder key: #{key.inspect} => #{value.inspect}. Ignoring.."
353
+ end
354
+ end
355
+ if responder_clean.has_key?( :method )
356
+ responders_clean.push( responder_clean )
357
+ else
358
+ warn "Responder (#{responder_clean.inspect}) is missing a :method specification. Skipping.."
359
+ end
360
+ end
361
+ return responders_clean
362
+ end
363
+
364
+ # @private Returns a sanitized copy of a single value item.
365
+ def sanitize_value_item( value_item_dirty )
366
+ value_item_clean = {}
367
+ value_item_dirty.each do | key, value |
368
+ if key.to_sym == :value or key.to_sym == :data
369
+ if [Array, Hash, String, TrueClass, FalseClass, Fixnum, Bignum, Float, NilClass].include? value.class
370
+ value_item_clean[:value] = value
371
+ else
372
+ warn "Unsupported value class (#{value.class.inspect}) for value: #{value.inspect}. Using 0 instead."
373
+ value_item_clean[:value] = 0
374
+ end
375
+ elsif key.to_sym == :value_call or key.to_sym == :call
376
+ value_item_clean[:value_call] = sanitize_value_call_hash( value )
377
+ elsif key.to_sym == :restore_default or key.to_sym == :restore
378
+ if [TrueClass, FalseClass].include? value.class
379
+ value_item_clean[:restore_default] = value
380
+ else
381
+ warn "Unsupported type of restore (expected true or false): #{value.inspect}. Using true instead."
382
+ value_item_clean[:restore_default] = true
383
+ end
384
+ elsif key.to_sym == :responders or key.to_sym == :responder
385
+ sanitized_responders = sanitize_value_responders( value )
386
+ value_item_clean[:responders] = sanitized_responders unless sanitized_responders.empty?
387
+ else
388
+ warn "Unsupported value specification key: #{key.inspect}."
389
+ end
390
+ end
391
+ return value_item_clean
392
+ end
393
+
394
+ # @private Returns sanitized hash of the structure specified in values.yaml
395
+ def sanitize_values_yaml( values_path )
396
+ values_dirty = yaml_read( values_path )
397
+ return false if values_dirty == false
398
+ if values_dirty.class == Hash
399
+ values_clean = {}
400
+ values_dirty.each do |key, value|
401
+ values_clean[ key.to_sym ] = sanitize_value_item( value )
402
+ end
403
+ return values_clean unless values_clean.empty?
404
+ elsif values_dirty.class == Array
405
+ values_clean = []
406
+ values_dirty.each do |values_dirty_segment|
407
+ values_clean_segment = {}
408
+ values_dirty_segment.each do |key, value|
409
+ values_clean_segment[ key.to_sym ] = sanitize_value_item( value )
410
+ end
411
+ values_clean.push( values_clean_segment )
412
+ end
413
+ return values_clean unless values_clean.empty?
414
+ else
415
+ warn "Unsupported format of values.yaml, got: #{values_dirty.inspect}, expected Hash or Array."
416
+ end
417
+ return false
418
+ end
292
419
 
293
420
  # @private This method looks looks for a file called "values.yaml" in the plugin's bundle directory.
294
421
  # If this file is found, it loads it for initial value definitions.
295
422
  # These definitions are accessible as the +@values+ attribute.
296
423
  def init_values
297
424
  values_path = bundle_path( 'values.yaml' )
298
- return yaml_read( values_path )
425
+ return sanitize_values_yaml( values_path )
299
426
  end
300
427
 
301
428
  # @private Creates a new instance of HValue, assigns it as +value_name+ into the
data/lib/session/msg.rb CHANGED
@@ -175,6 +175,13 @@ module RSence
175
175
  @session[:user_id]
176
176
  end
177
177
 
178
+ # Getter for the user info hash
179
+ # @return [Hash] The current user info hash. Returns {} by default.
180
+ def user_info
181
+ @session[:user_info] = {} unless @session.has_key?(:user_info)
182
+ @session[:user_info]
183
+ end
184
+
178
185
  # @private used for automatic reload of page, when the plugins have been changed.
179
186
  def refresh_page?( plugin_incr )
180
187
  if plugin_incr != @session[:plugin_incr]
@@ -191,6 +198,13 @@ module RSence
191
198
  def user_id=(user_id)
192
199
  @session[:user_id] = user_id
193
200
  end
201
+
202
+ # Setter for the user info
203
+ # @param [Hash] user_info The user info hash to set. Use in login situations to store the user information.
204
+ # @return [nil]
205
+ def user_info=(user_info)
206
+ @session[:user_info] = user_info
207
+ end
194
208
 
195
209
  # Returns the session id
196
210
  # @return [Number]
@@ -88,6 +88,9 @@ module RSence
88
88
 
89
89
  # user id, map to your own user management code
90
90
  :user_id => 0,
91
+
92
+ # user info, map to your own user management code
93
+ :user_info => {},
91
94
 
92
95
  # valuemanager data
93
96
  :values => {
@@ -3,16 +3,17 @@
3
3
  title: Main Plugin
4
4
 
5
5
  # The human-readable version of the package
6
- version: 2.0.0
6
+ version: 2.1.0
7
7
 
8
8
  # A brief description of the package (rdoc formatting supported)
9
9
  description: |
10
- The main plugin manages the flow of communication between client and server.
10
+ The main plugin manages the flow of communication between client and server
11
+ as well as initializes a startup web page, if no other plugin does so.
11
12
 
12
13
  # System version requirement.
13
- sys_version: '>= 2.0.0'
14
+ sys_version: '>= 2.1.0'
14
15
 
15
16
  category: :system
16
17
 
17
- depends_on: :index_html
18
+ depends_on: :client_pkg
18
19
 
data/plugins/main/main.rb CHANGED
@@ -7,9 +7,10 @@
7
7
  ##
8
8
 
9
9
 
10
- # The MainPlugin is accessible as +@plugins.main+ from other plugins.
10
+ # The MainPlugin is accessible as +@plugins.main+ and just +main+ from other plugins.
11
11
  #
12
12
  # = MainPlugin provides mainly client setup and the following services:
13
+ # * The root html page, which includes the scripts and sets up client startup variables.
13
14
  # * The url of the client as a HValue, including the anchor.
14
15
  # * Accessible via +msg.session[:main][:location_href]+
15
16
  # * The local time of the client's web browser as a HValue, as seconds since epoch.
@@ -18,38 +19,165 @@
18
19
  # * Provides the +#init_ui+ event for plugins that respond to it.
19
20
  class MainPlugin < Plugin
20
21
 
21
- # @private Internal structures, binds configuration data as instance variables
22
+ # # Session-specific index page renderer (unused)
23
+ # def session_index_html( request, response )
24
+ #
25
+ # ses_key = @randgen.gen
26
+ # sha_key = ''
27
+ #
28
+ # buffer = [
29
+ # "var qP=function(cmd){COMM.Queue.push(cmd);};"
30
+ # ]
31
+ #
32
+ # req_num = 0
33
+ #
34
+ # 3.times do |req_num|
35
+ # sha_key = Digest::SHA1.hexdigest( ses_key + sha_key )
36
+ # msg = @plugins.transporter.xhr(
37
+ # request, response, {
38
+ # :servlet => true,
39
+ # :cookie => (req_num==0),
40
+ # :query => {
41
+ # 'ses_key' => "#{req_num}:.o.:#{sha_key}"
42
+ # }
43
+ # }
44
+ # )
45
+ # buffer += msg.value_buffer
46
+ # msg.buffer.each do |buffer_item|
47
+ # buffer.push( "qP(function(){#{buffer_item};});")
48
+ # end
49
+ # ses_key = msg.ses_key
50
+ # end
51
+ #
52
+ # buffer.unshift( "COMM.Session.newKey(#{ses_key.to_json});" )
53
+ # buffer.unshift( "COMM.Session.sha_key=#{sha_key.to_json};" )
54
+ # buffer.unshift( "COMM.Session.req_num=#{req_num};" )
55
+ #
56
+ # index_html = render_index_html
57
+ #
58
+ # return index_html.gsub('__STARTUP_SEQUENCE__', buffer.join("\n") )
59
+ # end
60
+
61
+
62
+ # Index page renderer
63
+ def render_index_html
64
+
65
+ index_html = @index_html_src.clone
66
+
67
+ client_rev = client_pkg.client_cache.client_rev
68
+ deps_src = ''
69
+ @conf[:deps].each do |dep|
70
+ deps_src += %{<script src="#{dep}" type="text/javascript"></script>}
71
+ end
72
+ client_base = File.join(@bconf[:h],client_rev)
73
+
74
+ index_html.gsub!( '__CLIENT_BASE__', client_base )
75
+ index_html.gsub!( '__DEFAULT_TITLE__', @conf[:title] )
76
+ index_html.gsub!( '__CLIENT_REV__', client_rev )
77
+ index_html.gsub!( '__CLIENT_HELLO__', @bconf[:hello] )
78
+ index_html.gsub!( '__NOSCRIPT__', @conf[:noscript] )
79
+ index_html.gsub!( '__SCRIPT_DEPS__', deps_src )
80
+
81
+ return index_html
82
+ end
83
+
84
+
85
+
86
+ ### Top-level plugin events:
87
+
88
+
89
+ # Binds configuration data as instance variables
22
90
  def init
23
91
  super
92
+ @plugins.register_alias( :main, :index_html )
93
+ @randgen = RandGen.new( 40 )
94
+ ::RSence.config[:index_html][:instance] = self
24
95
  @conf = ::RSence.config[:index_html]
25
96
  @bconf = ::RSence.config[:broker_urls]
26
97
  @goodbye_uri = File.join(@bconf[:hello],'goodbye')
27
98
  end
28
99
 
29
- # @private Internal structures, matches the "hello/goodbye" session termination request
30
- def match( uri, request_type )
31
- if request_type == :post and uri == @goodbye_uri
100
+ # Opens and renders the index page template
101
+ def open
102
+ super
103
+ @index_html_src = file_read( ::RSence.config[:index_html][:index_tmpl] )
104
+ render_index_html
105
+ end
106
+
107
+ # Frees the ticket resource id of the "loading" gif image.
108
+ def close
109
+ super
110
+ @plugins[:ticket].del_rsrc( @loading_gif_id )
111
+ end
112
+
113
+
114
+
115
+ ### Servlet features; responds to GET / as well as POST /hello/goodbye
116
+
117
+
118
+ # @private Internal structures, matches the "hello/goodbye" session termination POST request and the "/" index html page GET request
119
+ def match( uri, method )
120
+ if uri == ::RSence.config[:index_html][:respond_address] and method == :get
32
121
  return true
122
+ elsif req_type == :post and uri == @goodbye_uri
123
+ return true
124
+ else
125
+ return false
33
126
  end
34
- return false
35
127
  end
36
128
 
37
- # @private Internal structures, score for the "hello/goodbye" session termination request
38
- def score; 100; end
129
+ # @private Internal structures, score for the "hello/goodbye" session termination request and the default index html page
130
+ def score
131
+ return 1000 # allows overriding with anything with a score below 1000
132
+ end
133
+
134
+ # Inspects the http request header to decide if the browser supports gzip compressed responses.
135
+ def support_gzip( header )
136
+ return false if not ::RSence.config[:no_gzip]
137
+ return false if not header.has_key?('accept-encoding')
138
+ return header['accept-encoding'].include?('gzip')
139
+ end
39
140
 
40
- # @private Internal structures, handler for the "hello/goodbye" session termination request
141
+ # Outputs the startup web page.
142
+ def get( req, response, ses )
143
+ index_html = render_index_html
144
+
145
+ response.status = 200
146
+
147
+ response['Content-Type'] = 'text/html; charset=UTF-8'
148
+ response['Date'] = httime( Time.now )
149
+ response['Server'] = 'RSence'
150
+ response['Cache-Control'] = 'no-cache'
151
+
152
+ if support_gzip( req.header )
153
+ index_gzip = GZString.new('')
154
+ gzwriter = Zlib::GzipWriter.new( index_gzip, 9 )
155
+ gzwriter.write( index_html )
156
+ gzwriter.close
157
+ response['Content-Length'] = index_gzip.length
158
+ response['Content-Encoding'] = 'gzip'
159
+ response.body = index_gzip
160
+ else
161
+ response['Content-Length'] = index_html.length
162
+ response.body = index_html
163
+ end
164
+ end
165
+
166
+ # Returns the "hello/goodbye" session termination request
41
167
  def post( req, res, ses )
42
168
  @plugins.sessions.expire_ses_by_req( req, res )
43
169
  end
44
170
 
45
- # @private url_responder gets called whenever the
46
- # page location.href changes, enabled virtual uris
47
- # to enable back/forward/bookmarking in browsers,
48
- # when software is coded to support it.
171
+
172
+
173
+ ### Features accessible from other plugins:
174
+
175
+ # The +#url_responder+ gets called whenever the anchor (pound) of location.href changes.
176
+ # It enables virtual url events for back/forward buttons and bookmarking in browsers whenever utilized.
49
177
  #
50
178
  # Client-side support is included in js/url_responder.js
51
179
  #
52
- # Also allows virtual-host -like behavior, if software is coded to support it.
180
+ # Also allows virtual-host -like behavior if utilized.
53
181
  def url_responder(msg,location_href)
54
182
 
55
183
  ses = get_ses( msg )
@@ -83,24 +211,31 @@ class MainPlugin < Plugin
83
211
 
84
212
  end
85
213
 
214
+
86
215
  # Returns base url of browser (before the '#' sign)
87
216
  def url( msg )
88
217
  get_ses( msg )[:url][0]
89
218
  end
90
219
 
220
+
91
221
  # Returns pound url of browser (after the '#' sign)
92
222
  def pound( msg )
93
223
  get_ses( msg )[:url][1]
94
224
  end
95
225
 
96
226
 
97
- # @private new session initialization, called just once per session.
227
+
228
+ ### Session events:
229
+
230
+
231
+ # New session initialization, called just once per session.
98
232
  def init_ses(msg)
99
233
  super
100
234
  restore_ses( msg )
101
235
  end
102
236
 
103
- # @private called once when a session is restored using the cookie's ses_key
237
+
238
+ # Called once when a session is restored or cloned using the cookie's ses_key
104
239
  def restore_ses(msg)
105
240
  super
106
241
  ## Resets session data to defaults
@@ -111,6 +246,7 @@ class MainPlugin < Plugin
111
246
  ses[:poll_mode] = true
112
247
  end
113
248
 
249
+
114
250
  # Interface for adding delayed calls
115
251
  #
116
252
  # When adding a delayed call, use an Array to define a plugin/method with optional arguments that will be called on the next request. The client will call back immediately when a delayed call is pending. The first param of the method is a +msg+. Don't include the +msg+ of the current request in params, it will be inserted automatically for the delayed call.
@@ -135,6 +271,7 @@ class MainPlugin < Plugin
135
271
  get_ses( msg )[:delayed_calls].push( params )
136
272
  end
137
273
 
274
+
138
275
  # @private Initializes the client-side COMM.urlResponder and sesWatcher
139
276
  def boot0( msg, ses )
140
277
 
@@ -158,18 +295,27 @@ class MainPlugin < Plugin
158
295
 
159
296
  end
160
297
 
298
+
161
299
  # @private Calls the init_ui method of each loaded plugin and removes the loading -message
162
300
  def boot1( msg, ses )
163
301
  # Delegates the init_ui method to each plugin to signal bootstrap completion.
164
302
  msg.plugins.delegate( 'init_ui', msg ) unless ses[:dont_init_ui]
165
303
  end
166
304
 
167
- # @private
305
+
306
+ # Disables the init_ui event.
168
307
  def dont_init_ui( msg )
169
308
  get_ses( msg )[:dont_init_ui] = true
170
309
  end
171
310
 
172
- # @private Flushes commands in the :delayed_calls array
311
+
312
+ # Enables the init_ui event.
313
+ def do_init_ui( msg )
314
+ get_ses( msg )[:dont_init_ui] = false
315
+ end
316
+
317
+
318
+ # Flushes commands in the :delayed_calls array
173
319
  def flush_delayed( msg, ses )
174
320
  ## Limits the amount of delayed calls to process to 4.
175
321
  ## Prevents the client from choking even when the server
@@ -223,10 +369,10 @@ class MainPlugin < Plugin
223
369
  end
224
370
  end
225
371
 
226
- # @private When nothing is delayed and the second poll has been made (init_ui called),
227
- # sets the client to non-polling-mode, having only HValue
228
- # changes trigger new requests. SesWatcher makes this happen
229
- # regularly.
372
+ # When nothing is delayed and the second poll has been made (init_ui called),
373
+ # sets the client to non-polling-mode, having only value synchronization trigger
374
+ # new requests. On the client, SesWatcher forces the change by sending the
375
+ # client time periodically.
230
376
  def end_polling( msg, ses )
231
377
  if ses[:poll_mode] == true
232
378
  msg.reply "COMM.Transporter.poll(0);"
@@ -234,7 +380,7 @@ class MainPlugin < Plugin
234
380
  end
235
381
  end
236
382
 
237
- # @private Starts polling.
383
+ # Starts polling mode.
238
384
  def start_polling( msg, ses )
239
385
  if ses[:poll_mode] == false
240
386
  msg.reply( "COMM.Transporter.poll(#{::RSence.config[:transporter_conf][:client_poll_priority]});" )
@@ -242,7 +388,7 @@ class MainPlugin < Plugin
242
388
  end
243
389
  end
244
390
 
245
- # @private called on every request of an active, valid session
391
+ # Called on every request of an active, valid session
246
392
  def idle(msg)
247
393
 
248
394
  ses = get_ses( msg )
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rsence-pre
3
3
  version: !ruby/object:Gem::Version
4
- hash: 123
4
+ hash: 121
5
5
  prerelease: false
6
6
  segments:
7
7
  - 2
8
8
  - 1
9
9
  - 0
10
- - 14
11
- version: 2.1.0.14
10
+ - 15
11
+ version: 2.1.0.15
12
12
  platform: ruby
13
13
  authors:
14
14
  - Riassence Inc.
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-11-17 00:00:00 +02:00
19
+ date: 2010-11-22 00:00:00 +02:00
20
20
  default_executable: rsence-pre
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -93,14 +93,12 @@ files:
93
93
  - plugins/client_pkg/lib/client_pkg_build.rb
94
94
  - plugins/client_pkg/lib/client_pkg_cache.rb
95
95
  - plugins/client_pkg/lib/client_pkg_serve.rb
96
- - plugins/index_html/img/loading.gif
97
- - plugins/index_html/img/riassence.gif
98
- - plugins/index_html/index_html.rb
99
- - plugins/index_html/info.yaml
100
- - plugins/index_html/tmpl/index.html
96
+ - plugins/main/img/loading.gif
97
+ - plugins/main/img/riassence.gif
101
98
  - plugins/main/info.yaml
102
99
  - plugins/main/js/main.js
103
100
  - plugins/main/main.rb
101
+ - plugins/main/tmpl/index.html
104
102
  - plugins/main/values.yaml
105
103
  - plugins/ticket/info.yaml
106
104
  - plugins/ticket/lib/common.rb
@@ -1,120 +0,0 @@
1
- ## RSence
2
- # Copyright 2009 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
-
10
-
11
- # @private IndexHtmlPlugin is the servlet plugin that is responsible for initializing the "boot-strap page". It's not intended as a part of the public API at this time.
12
- class IndexHtmlPlugin < Servlet
13
-
14
- def match( uri, method )
15
- if uri == ::RSence.config[:index_html][:respond_address] and method == :get
16
- return true
17
- else
18
- return false
19
- end
20
- end
21
-
22
- def score
23
- return 1000 # allows overriding with anything with a score below 1000
24
- end
25
-
26
- def init
27
- @randgen = RandGen.new( 40 )
28
- ::RSence.config[:index_html][:instance] = self
29
- end
30
-
31
- def open
32
- @index_html_src = file_read( ::RSence.config[:index_html][:index_tmpl] )
33
- render_index_html
34
- end
35
-
36
- def close
37
- @plugins[:ticket].del_rsrc( @loading_gif_id )
38
- end
39
-
40
- def render_index_html
41
-
42
- index_html = @index_html_src.clone
43
-
44
- index_html.gsub!('__DEFAULT_TITLE__',::RSence.config[:index_html][:title])
45
- client_rev = @plugins[:client_pkg].client_cache.client_rev
46
- index_html.gsub!('__CLIENT_REV__',client_rev)
47
- index_html.gsub!('__CLIENT_BASE__',File.join(::RSence.config[:broker_urls][:h],client_rev))
48
- index_html.gsub!('__CLIENT_HELLO__',::RSence.config[:broker_urls][:hello])
49
- index_html.gsub!('__NOSCRIPT__',::RSence.config[:index_html][:noscript])
50
-
51
- deps_src = ''
52
- ::RSence.config[:index_html][:deps].each do |dep|
53
- deps_src += %{<script src="#{dep}" type="text/javascript"></script>}
54
- end
55
- index_html.gsub!('__SCRIPT_DEPS__',deps_src)
56
-
57
- return index_html
58
- end
59
-
60
- def session_index_html( request, response )
61
- ses_key = @randgen.gen
62
- sha_key = ''
63
- buffer = [
64
- "var qP=function(cmd){COMM.Queue.push(cmd);};"
65
- ]
66
- req_num = 0
67
- 3.times do |req_num|
68
- sha_key = Digest::SHA1.hexdigest( ses_key + sha_key )
69
- msg = @plugins.transporter.xhr(
70
- request, response, {
71
- :servlet => true,
72
- :cookie => (req_num==0),
73
- :query => {
74
- 'ses_key' => "#{req_num}:.o.:#{sha_key}"
75
- }
76
- }
77
- )
78
- buffer += msg.value_buffer
79
- msg.buffer.each do |buffer_item|
80
- buffer.push( "qP(function(){#{buffer_item};});")
81
- end
82
- ses_key = msg.ses_key
83
- end
84
- buffer.unshift( "COMM.Session.newKey(#{ses_key.to_json});" )
85
- buffer.unshift( "COMM.Session.sha_key=#{sha_key.to_json};" )
86
- buffer.unshift( "COMM.Session.req_num=#{req_num};" )
87
- index_html = render_index_html
88
- return index_html.gsub('__STARTUP_SEQUENCE__', buffer.join("\n") )
89
- end
90
-
91
- ## Outputs a static web page.
92
- def get( request, response, ses )
93
- index_html = render_index_html
94
- support_gzip = (request.header.has_key?('accept-encoding') and \
95
- request.header['accept-encoding'].include?('gzip')) \
96
- and not ::RSence.config[:no_gzip]
97
-
98
- response.status = 200
99
-
100
- response['Content-Type'] = 'text/html; charset=UTF-8'
101
- response['Date'] = httime( Time.now )
102
- response['Server'] = 'RSence'
103
- response['Cache-Control'] = 'no-cache'
104
-
105
- if support_gzip
106
- index_gzip = GZString.new('')
107
- gzwriter = Zlib::GzipWriter.new( index_gzip, 9 )
108
- gzwriter.write( index_html )
109
- gzwriter.close
110
- response['Content-Length'] = index_gzip.length
111
- response['Content-Encoding'] = 'gzip'
112
- response.body = index_gzip
113
- else
114
- response['Content-Length'] = index_html.length
115
- response.body = index_html
116
- end
117
- end
118
-
119
- end
120
-
@@ -1,18 +0,0 @@
1
-
2
- # The human-readable product name of the package
3
- title: Index HTML Page
4
-
5
- # The human-readable version of the package
6
- version: 2.0.0
7
-
8
- # A brief description of the package (rdoc formatting supported)
9
- description: |
10
- This plugin serves the initial html page.
11
-
12
- # System version requirement.
13
- sys_version: '>= 2.0.0'
14
-
15
- category: :system
16
-
17
- depends_on: :client_pkg
18
-
File without changes
File without changes
File without changes