rsence-pre 2.2.0.23 → 2.2.0.24

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.2.0.23.pre
1
+ 2.2.0.24.pre
@@ -143,13 +143,20 @@ HTab = HControl.extend({
143
143
  * +_doSelect+::
144
144
  *
145
145
  **/
146
- addTab: function(_tabLabel,_doSelect,_viewClass){
147
- var _tabIdx=this.tabs.length,
148
- _tabLabelHTML = '',
149
- _labelTextWidth = this.stringWidth( _tabLabel, null, 0, this.fontStyle ),
150
- _labelWidth = _labelTextWidth+this.tabLabelLeftEdge+this.tabLabelRightEdge,
151
- _tab = HTabView.nu( [0,this.tabLabelHeight,null,null,0,0] ,this),
152
- _tabLabelElemId = ELEM.make(this.markupElemIds[this.tabLabelParentElem],this.tabLabelElementTagName);
146
+ addTab: function(_tabLabel,_doSelect,_viewClass,_viewClassOptions){
147
+ var
148
+ _tabIdx=this.tabs.length,
149
+ _tabLabelHTML = '',
150
+ _labelTextWidth = this.stringWidth( _tabLabel, null, 0, this.fontStyle ),
151
+ _labelWidth = _labelTextWidth+this.tabLabelLeftEdge+this.tabLabelRightEdge,
152
+ _tabLabelElemId = ELEM.make(this.markupElemIds[this.tabLabelParentElem],this.tabLabelElementTagName),
153
+ _tab;
154
+ if( _viewClass === undefined ){
155
+ _tab = HTabView.nu( [0,this.tabLabelHeight,null,null,0,0], this);
156
+ }
157
+ else {
158
+ _tab = _viewClass.nu( [0,this.tabLabelHeight,null,null,0,0], this, _viewClassOptions );
159
+ }
153
160
  _tabIdx = this.tabs.length;
154
161
  if(this.tabLabelNoHTMLPrefix){
155
162
  _tabLabelHTML = _tabLabel;
@@ -277,4 +284,79 @@ HTabItem = {
277
284
  }
278
285
  };
279
286
 
287
+ var//RSence.Controls
288
+ GUITreeTabView = HControl.extend({
289
+ controlDefaults: HControlDefaults.extend({
290
+ visible: false,
291
+ autoCreate: false,
292
+ autoDestroy: true
293
+ }),
294
+ jsonRenderer: false,
295
+ createJSONRenderer: function(){
296
+ var
297
+ _this = this,
298
+ _value = _this.value,
299
+ _progressView = HView.nu( [4,0, 150, 34, 0, null], _this ),
300
+ // _indicatorPhases = ['/','-','\\','|','/','-','\\','|'], // ascii
301
+ // _indicatorPhases = ['◴','◷','◶','◵'], // unicode sector ball
302
+ // _indicatorPhases = ['◑','◒','◐','◓'], // unicode half ball
303
+ // _indicator = HStringView.nu( [ 2, 2, 32, 32 ], _progressView, { value: _indicatorPhases[0], style: { 'font-size': '24px' } } ),
304
+ // _indicatorTimeout = setInterval( function(){
305
+ // _indicatorPhase = _indicatorPhases.shift();
306
+ // _indicatorPhases.push( _indicatorPhase );
307
+ // _indicator.setValue( _indicatorPhase );
308
+ // }, 100 ),
309
+ _indicatorStr = HStringView.nu( [ 34, 12, 100, 20, 4, null ], _progressView, { value: 'Rendering' } );
310
+ _this.destroyJSONRenderer();
311
+ if( _value.type === undefined || _value.version === undefined ){
312
+ _value = {
313
+ 'type': 'GUITree',
314
+ 'version': 0.9,
315
+ 'class': 'HView',
316
+ 'rect': [0,0, null,null, 0,0],
317
+ 'options': { 'style': { 'overflow': 'auto' } },
318
+ 'subviews': _value
319
+ };
320
+ }
321
+ setTimeout( function(){
322
+ _this.jsonRenderer = JSONRenderer.nu( _value, _this );
323
+ // clearTimeout( _indicatorTimeout );
324
+ _progressView.die();
325
+ }, 10 );
326
+ },
327
+ destroyJSONRenderer: function(){
328
+ if( this.jsonRenderer ){
329
+ this.jsonRenderer.die();
330
+ this.jsonRenderer = false;
331
+ }
332
+ },
333
+ drawSubviews: function(){
334
+ if( this.options.autoCreate ){
335
+ this.createJSONRenderer();
336
+ }
337
+ },
338
+ show: function(){
339
+ this.base();
340
+ if(!this.jsonRenderer){
341
+ this.createJSONRenderer();
342
+ }
343
+ },
344
+ hide: function(){
345
+ this.base();
346
+ if( this.options.autoDestroy ){
347
+ this.destroyJSONRenderer();
348
+ }
349
+ },
350
+ die: function(){
351
+ this.destroyJSONRenderer();
352
+ this.base();
353
+ }
354
+ });
355
+
356
+ var//RSence.Controls
357
+ GUITreeTabItem = {
358
+ nu: function( _rect, _parent, _options ){
359
+ return _parent.addTab( _options.label, _options.select, GUITreeTabView, _options );
360
+ }
361
+ };
280
362
 
@@ -204,15 +204,33 @@ HSystem = {
204
204
  *
205
205
  **/
206
206
  killApp: function(_appId, _forced){
207
- if( !_forced ){
208
- var _startedWaiting = new Date().getTime();
209
- while( this.busyApps[ _appId ] === true ) {
210
- /* Waiting for the app to finish its idle loop... */
211
- if (new Date().getTime() > _startedWaiting + this.maxAppRunTime) {
212
- break;
213
- }
214
- }
207
+ this.reniceApp( _appId, -1 ); // prevent new idle calls to the app
208
+ if( _forced || ( this.busyApps[ _appId ] === false ) ){
209
+ this._forceKillApp( _appId );
210
+ }
211
+ else {
212
+ /* Waiting for the app to finish its idle loop before killing it */
213
+ var
214
+ _startedWaiting = new Date().getTime(),
215
+ _this = this,
216
+ _timeout = setInterval(
217
+ function(){
218
+ if( _this.busyApps[ _appId ] === true ) {
219
+ if (new Date().getTime() > _startedWaiting + _this.maxAppRunTime) {
220
+ clearTimeout(_timeout);
221
+ _this._forceKillApp( _appId );
222
+ }
223
+ else {
224
+ clearTimeout(_timeout);
225
+ _this._forceKillApp( _appId );
226
+ }
227
+ }
228
+ }, 10
229
+ );
215
230
  }
231
+ },
232
+
233
+ _forceKillApp: function( _appId ){
216
234
  this.busyApps[_appId] = true;
217
235
 
218
236
  this.apps[ _appId ].destroyAllViews();
@@ -27,10 +27,10 @@ HCheckboxList = HControl.extend({
27
27
  listItemViews: [],
28
28
  ListCheckbox: HCheckbox.extend({
29
29
 
30
- /** = Description
31
- * Adds listValues to the parent if they are true otherwise deletes them.
32
- *
33
- **/
30
+ /** = Description
31
+ * Adds listValues to the parent if they are true otherwise deletes them.
32
+ *
33
+ **/
34
34
  refreshValue: function(){
35
35
  this.base();
36
36
  if(this.value === true){
@@ -40,7 +40,15 @@ HCheckboxList = HControl.extend({
40
40
  this.parent.delItem( this.options.listValue );
41
41
  }
42
42
  }
43
- }),
43
+ }), // End ListCheckbox
44
+
45
+ setEnabled: function(_state){
46
+ this.base(_state);
47
+ if(!this['listItemViews']){ return; }
48
+ for(var i=0;i<this.listItems.length;i++){
49
+ this.listItemViews[i].setEnabled(_state)
50
+ }
51
+ },
44
52
 
45
53
  /** = Description
46
54
  * Checks if +_listValue+ can be found from the values. Adds the value
@@ -121,7 +129,8 @@ HCheckboxList = HControl.extend({
121
129
  this, {
122
130
  label: _label,
123
131
  value: _checked,
124
- listValue: _value
132
+ listValue: _value,
133
+ enabled: this.enabled
125
134
  }
126
135
  );
127
136
  this.listItemViews[i] = _checkbox;
@@ -61,7 +61,8 @@ HRadioButtonList = HControl.extend({
61
61
  return HRadiobutton.nu(
62
62
  [ 4, (i*23)+4, null, 23, 4, null ],
63
63
  this, {
64
- label: _label
64
+ label: _label,
65
+ enabled: this.enabled
65
66
  }
66
67
  );
67
68
  },
@@ -94,6 +95,13 @@ HRadioButtonList = HControl.extend({
94
95
  },
95
96
  radioButtonIndexValue: false,
96
97
  radioButtonResponder: false,
98
+ setEnabled: function(_state){
99
+ this.base(_state);
100
+ if(!this['listItemViews']){ return; }
101
+ for(var i=0;i<this.listItems.length;i++){
102
+ this.listItemViews[i].setEnabled(_state)
103
+ }
104
+ },
97
105
 
98
106
  /** = Description
99
107
  *
@@ -104,12 +112,15 @@ HRadioButtonList = HControl.extend({
104
112
  this.parent = _parent;
105
113
  },
106
114
  refresh: function(){
107
- var _listItems = this.parent.listItems;
115
+ var
116
+ _listItems = this.parent.listItems,
117
+ _value;
108
118
  if(_listItems === undefined || _listItems === null){
109
119
  return;
110
120
  }
111
121
  if(_listItems[ this.value ] !== undefined){
112
- this.parent.setValue( _listItems[ this.value ][0] );
122
+ _value = _listItems[ this.value ];
123
+ this.parent.setValue( _value[0] );
113
124
  }
114
125
  }
115
126
  }),
@@ -119,6 +130,7 @@ HRadioButtonList = HControl.extend({
119
130
  refreshValue: function(){
120
131
  var _value = this.value;
121
132
  if ( this.listItems && this.listItems.length !== 0 && this['valueMatrix'] !== undefined ) {
133
+ // debugger;
122
134
  if ( this.radioButtonResponder === false ){
123
135
  this.radioButtonIndexValue = HValue.nu( false, 0 );
124
136
  this.radioButtonIndexValue.bind( this.valueMatrix );
data/lib/http/broker.rb CHANGED
@@ -15,7 +15,6 @@ require 'http/response'
15
15
  ## Minimally WEBrick -compatible request object
16
16
  require 'http/request'
17
17
 
18
-
19
18
  module RSence
20
19
 
21
20
 
@@ -41,8 +40,15 @@ class Broker
41
40
  response = Response.new
42
41
  request_method = request.request_method.downcase
43
42
  dispatcher = dispatcher_class.new( request, response )
44
- dispatcher.send( request_method )
45
- content_type = dispatcher.content_type
43
+ if dispatcher.respond_to?( request_method )
44
+ begin
45
+ dispatcher.send( request_method )
46
+ rescue => e
47
+ dispatcher.server_error( e )
48
+ end
49
+ else
50
+ dispatcher.not_implemented( request.request_method )
51
+ end
46
52
  response_body = response.body
47
53
  response.header['Content-Length'] = response.body_bytes unless response.header.has_key?('Content-Length')
48
54
  return [response.status, response.header, response_body]
@@ -55,7 +61,6 @@ class Broker
55
61
  # @return [Broker] An instance of Broker with a {Request} instance as +@request+ and a {Response} instance as +@response+
56
62
  def dispatcher_class
57
63
  @dispatcher ||= Class.new(self.class) do
58
- attr_accessor :content_type
59
64
  def initialize(request,response)
60
65
  @request = request
61
66
  @response = response
@@ -99,7 +104,7 @@ class Broker
99
104
  # Loads the selected web-server (default is 'mongrel')
100
105
  rack_require = conf[:rack_require]
101
106
  puts conf.inspect if RSence.args[:debug]
102
-
107
+
103
108
  require rack_require
104
109
 
105
110
  # Selects the handler for Rack
@@ -112,41 +117,113 @@ class Broker
112
117
  'unicorn' => lambda { Rack::Handler::Unicorn },
113
118
  'rainbows' => lambda { Rack::Handler::Rainbows }
114
119
  }[rack_require].call
115
-
116
120
  handler.run( Rack::Lint.new(self.new), :Host => host, :Port => port )
117
-
118
121
  end
119
122
 
120
123
  # Generic 404 error handler. Just sets up response status, headers, body as a small "Page Not Found" html page
121
124
  def not_found
122
125
  puts "/404: #{@request.fullpath.inspect}" if RSence.args[:verbose]
123
126
  @response.status = 404
124
- err404 = '<html><head><title>404 - Page Not Found</title></head><body>404 - Page Not Found</body></html>'
127
+ err404 = "<html><head><title>404 - Page Not Found</title></head><body>404 - Page &quot;#{@request.fullpath}&quot; Not Found</body></html>"
125
128
  @response['Content-Type'] = 'text/html; charset=UTF-8'
126
- @response['Content-Length'] = err404.bytesize.to_s
127
129
  @response.body = err404
128
130
  end
129
131
 
130
132
  # Routes POST requests to {Transporter#servlet}
131
133
  def post
132
-
133
134
  puts "post: #{@request.fullpath}" if RSence.args[:verbose]
134
-
135
135
  not_found unless @@transporter.servlet( :post, @request, @response )
136
-
137
136
  end
138
137
 
139
138
  # Routes GET requests to {Transporter#servlet}
140
139
  def get
141
-
142
140
  puts "get: #{@request.fullpath}" if RSence.args[:verbose]
143
-
144
141
  not_found unless @@transporter.servlet( :get, @request, @response )
145
-
146
142
  end
147
143
 
148
- ### -- Add more http methods here when we have some apps to test with CalDAV implementation maybe? ++
144
+ # Routes HEAD requests to {Transporter#servlet}
145
+ # Uses GET and removes the response body, if nothing matches HEAD directly.
146
+ def head
147
+ puts "head: #{@request.fullpath}" if RSence.args[:verbose]
148
+ return if @@transporter.servlet( :head, @request, @response )
149
+ if @@transporter.servlet( :get, @request, @response )
150
+ @response.body = ''
151
+ else
152
+ not_found
153
+ end
154
+ end
155
+
156
+ # Generic 405 (method not allowed) handler.
157
+ def not_allowed( method_name )
158
+ @response.status = 405
159
+ body_txt = "Error 405: The method #{method_name} is not allowed on #{@request.fullpath}.\r\n"
160
+ @response['Content-Type'] = 'text/plain; charset=UTF-8'
161
+ @response.body = body_txt
162
+ end
163
+
164
+ # Generic 501 (method not implemented) handler.
165
+ def not_implemented( method_name )
166
+ @response.status = 501
167
+ body_txt = "Error 501: The method #{method_name} is not implemented on #{@request.fullpath}.\r\n"
168
+ @response['Content-Type'] = 'text/plain; charset=UTF-8'
169
+ @response.body = body_txt
170
+ end
149
171
 
172
+ # Generic 500 (server error) handler.
173
+ def server_error( e, custom_name='Broker Exception' )
174
+ @response.status = 500
175
+ exception_detail = [
176
+ custom_name,
177
+ "Time: #{Time.now.to_s}",
178
+ "#{'-='*39}-",
179
+ "#{e.class}: #{e.to_s}",
180
+ "\t#{e.backtrace.join("\r\n\t")}",
181
+ "#{'-='*39}-",
182
+ "Request method: #{@request.request_method}",
183
+ "Request path: #{@request.fullpath}",
184
+ "Request headers: #{@request.header.inspect}",
185
+ "#{'-='*39}-\r\n\r\n"
186
+ ].join("\r\n")
187
+ $stderr.puts exception_detail
188
+ if RSence.args[:debug]
189
+ body_txt = "Error 500: "+ exception_detail
190
+ else
191
+ body_txt = "Error 500: General server error.\r\n"
192
+ end
193
+ @response['Content-Type'] = 'text/plain; charset=UTF-8'
194
+ @response.body = body_txt
195
+ end
196
+
197
+ # Routes OPTIONS requests to {Transporter#servlet}
198
+ def options
199
+ puts "options: #{@request.fullpath}" if RSence.args[:verbose]
200
+ not_allowed('OPTIONS') unless @@transporter.servlet( :options, @request, @response )
201
+ end
202
+
203
+ # Routes PUT requests to {Transporter#servlet}
204
+ def put
205
+ puts "put: #{@request.fullpath}" if RSence.args[:verbose]
206
+ not_allowed('PUT') unless @@transporter.servlet( :put, @request, @response )
207
+ end
208
+
209
+ # Routes DELETE requests to {Transporter#servlet}
210
+ def delete
211
+ puts "delete: #{@request.fullpath}" if RSence.args[:verbose]
212
+ not_allowed('DELETE') unless @@transporter.servlet( :delete, @request, @response )
213
+ end
214
+
215
+ # Routes TRACE requests to {Transporter#servlet}
216
+ def trace
217
+ puts "trace: #{@request.fullpath}" if RSence.args[:verbose]
218
+ not_allowed('TRACE') unless @@transporter.servlet( :trace, @request, @response )
219
+ end
220
+
221
+ # Routes CONNECT requests to {Transporter#servlet}
222
+ def connect
223
+ puts "connect: #{@request.fullpath}" if RSence.args[:verbose]
224
+ not_allowed('CONNECT') unless @@transporter.servlet( :connect, @request, @response )
225
+ end
226
+
150
227
  end
151
228
 
152
229
  end
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: 81
4
+ hash: 79
5
5
  prerelease:
6
6
  segments:
7
7
  - 2
8
8
  - 2
9
9
  - 0
10
- - 23
11
- version: 2.2.0.23
10
+ - 24
11
+ version: 2.2.0.24
12
12
  platform: ruby
13
13
  authors:
14
14
  - Riassence Inc.
@@ -17,7 +17,7 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2011-09-23 00:00:00 Z
20
+ date: 2011-11-03 00:00:00 Z
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
23
23
  name: rsence-deps
@@ -371,3 +371,4 @@ specification_version: 3
371
371
  summary: Pre-Release 2.2 version of RSence.
372
372
  test_files: []
373
373
 
374
+ has_rdoc: