rsence 2.0.0.10.pre → 2.0.0.11
Sign up to get free protection for your applications and to get access to all the features.
- data/.yardopts +10 -0
- data/INSTALL.rdoc +52 -86
- data/{LICENSE → LICENSE.txt} +0 -0
- data/README.rdoc +52 -49
- data/VERSION +1 -1
- data/bin/rsence +4 -6
- data/conf/default_conf.yaml +314 -305
- data/conf/default_strings.yaml +70 -71
- data/docs/ExampleGuiPlugin.rdoc +193 -0
- data/{js/comm/comm/autosync/js.inc → docs/JavascriptBundles.rdoc} +0 -0
- data/docs/PluginBundleInfo.rdoc +173 -0
- data/docs/PluginBundles.rdoc +96 -0
- data/docs/Values.rdoc +163 -0
- data/js/comm/{comm/autosync → autosync}/autosync.js +1 -2
- data/js/comm/{comm → autosync}/js.inc +0 -0
- data/js/comm/{comm/comm.js → comm.js} +1 -0
- data/js/comm/{comm/queue/js.inc → js.inc} +0 -0
- data/js/comm/jsloader/jsloader.js +2 -4
- data/js/comm/{comm/session → queue}/js.inc +0 -0
- data/js/comm/{comm/queue → queue}/queue.js +1 -0
- data/js/comm/{comm/sessionwatcher → session}/js.inc +0 -0
- data/js/comm/{comm/session → session}/session.js +4 -3
- data/js/comm/{comm/transporter → sessionwatcher}/js.inc +0 -0
- data/js/comm/{comm/sessionwatcher → sessionwatcher}/sessionwatcher.js +1 -0
- data/js/comm/{comm/urlresponder → transporter}/js.inc +0 -0
- data/js/comm/{comm/transporter → transporter}/transporter.js +1 -0
- data/js/comm/{comm/values → urlresponder}/js.inc +0 -0
- data/js/comm/{comm/urlresponder → urlresponder}/urlresponder.js +1 -0
- data/js/comm/{reloadapp → values}/js.inc +0 -0
- data/js/comm/{comm/values → values}/values.js +1 -0
- data/js/controls/button/button.js +10 -1
- data/js/controls/checkbox/checkbox.js +2 -0
- data/js/controls/dialogs/alert_sheet/alert_sheet.js +1 -0
- data/js/controls/dialogs/confirm_sheet/confirm_sheet.js +1 -0
- data/js/controls/dialogs/sheet/sheet.js +1 -0
- data/js/controls/imageview/imageview.js +1 -0
- data/js/controls/passwordcontrol/passwordcontrol.js +1 -0
- data/js/controls/progress/progressbar/progressbar.js +1 -0
- data/js/controls/progress/progressindicator/progressindicator.js +1 -0
- data/js/controls/radiobutton/radiobutton.js +3 -1
- data/js/controls/sliders/slider/slider.js +1 -0
- data/js/controls/sliders/vslider/vslider.js +1 -0
- data/js/controls/stepper/stepper.js +1 -0
- data/js/controls/stringview/stringview.js +2 -2
- data/js/controls/tab/tab.js +7 -5
- data/js/controls/textarea/textarea.js +1 -0
- data/js/controls/textcontrol/textcontrol.js +3 -1
- data/js/controls/uploader/uploader.js +1 -0
- data/js/controls/validatorview/validatorview.js +62 -59
- data/js/controls/window/window.js +1 -0
- data/js/core/class/class.js +2 -1
- data/js/core/elem/elem.js +27 -27
- data/js/core/event/event.js +3 -874
- data/js/{comm/sha → core/rsence_ns}/js.inc +0 -0
- data/js/core/rsence_ns/rsence_ns.js +15 -0
- data/js/{controls/datetime → datetime}/calendar/calendar.js +1 -0
- data/js/{comm/values/value → datetime/calendar}/js.inc +0 -0
- data/js/{controls/datetime → datetime}/calendar/themes/default/calendar.css +0 -0
- data/js/{controls/datetime → datetime}/calendar/themes/default/calendar.html +0 -0
- data/js/{controls/datetime → datetime}/calendar/themes/default/calendar_arrows-ie6.gif +0 -0
- data/js/{controls/datetime → datetime}/calendar/themes/default/calendar_arrows.png +0 -0
- data/js/{controls/datetime → datetime}/datetimevalue/datetimevalue.js +1 -0
- data/js/{comm/values/valuematrix → datetime/datetimevalue}/js.inc +0 -0
- data/js/{controls/datetime/calendar → datetime/timesheet}/js.inc +0 -0
- data/js/{controls/datetime → datetime}/timesheet/themes/default/timesheet.css +0 -0
- data/js/{controls/datetime → datetime}/timesheet/themes/default/timesheet.html +0 -0
- data/js/{controls/datetime → datetime}/timesheet/timesheet.js +1 -0
- data/js/{controls/datetime/datetimevalue → datetime/timesheet_item}/js.inc +0 -0
- data/js/{controls/datetime → datetime}/timesheet_item/themes/default/timesheet_item.css +0 -0
- data/js/{controls/datetime → datetime}/timesheet_item/themes/default/timesheet_item.html +0 -0
- data/js/{controls/datetime → datetime}/timesheet_item/timesheet_item.js +1 -0
- data/js/{controls/datetime/timesheet → datetime/timesheet_item_edit}/js.inc +0 -0
- data/js/{controls/datetime → datetime}/timesheet_item_edit/timesheet_item_edit.js +1 -1
- data/js/foundation/application/application.js +1 -2
- data/js/foundation/control/control.js +1 -4
- data/js/foundation/control/controldefaults/controldefaults.js +1 -4
- data/js/foundation/control/dummyvalue/dummyvalue.js +1 -0
- data/js/foundation/control/dyncontrol/dyncontrol.js +1 -2
- data/js/foundation/control/eventresponder/eventresponder.js +11 -3
- data/js/{controls/datetime/timesheet_item → foundation/control/valuematrix}/js.inc +0 -0
- data/js/{comm/values → foundation/control}/valuematrix/valuematrix.js +2 -5
- data/js/foundation/control/valueresponder/valueresponder.js +3 -1
- data/js/foundation/eventmanager/eventmanager.js +884 -0
- data/js/{controls/datetime/timesheet_item_edit → foundation/eventmanager}/js.inc +0 -0
- data/js/foundation/geom/point/point.js +2 -2
- data/js/foundation/geom/rect/rect.js +1 -0
- data/js/foundation/json_renderer/json_renderer.js +2 -0
- data/js/foundation/system/system.js +2 -1
- data/js/foundation/thememanager/thememanager.js +29 -23
- data/js/{controls/lists/checkboxlist → foundation/value}/js.inc +0 -0
- data/js/{comm/values → foundation}/value/value.js +1 -0
- data/js/foundation/view/markupview/markupview.js +2 -1
- data/js/foundation/view/morphanimation/morphanimation.js +1 -0
- data/js/foundation/view/view.js +6 -12
- data/js/foundation/view/viewdefaults/viewdefaults.js +1 -0
- data/js/{controls/lists → lists}/checkboxlist/checkboxlist.js +1 -0
- data/js/{controls/lists/listitems → lists/checkboxlist}/js.inc +0 -0
- data/js/{controls/lists/radiobuttonlist → lists/listitems}/js.inc +0 -0
- data/js/{controls/lists → lists}/listitems/listitems.js +22 -3
- data/js/lists/radiobuttonlist/js.inc +0 -0
- data/js/{controls/lists → lists}/radiobuttonlist/radiobuttonlist.js +2 -12
- data/js/util/reloadapp/js.inc +0 -0
- data/js/{comm → util}/reloadapp/reloadapp.js +10 -8
- data/js/{comm → util}/reloadapp/themes/default/reloadapp_warning-ie6.gif +0 -0
- data/js/{comm → util}/reloadapp/themes/default/reloadapp_warning.png +0 -0
- data/js/util/sha/js.inc +0 -0
- data/js/{comm → util}/sha/sha.js +27 -33
- data/js/views/centerview/centerview.js +33 -3
- data/js/views/inlineview/inlineview.js +1 -0
- data/js/views/scrollview/scrollview.js +1 -0
- data/lib/conf/argv.rb +34 -22
- data/lib/conf/default.rb +165 -173
- data/lib/daemon/daemon.rb +9 -9
- data/lib/daemon/sigcomm.rb +4 -4
- data/lib/http/broker.rb +30 -27
- data/lib/http/rackup.rb +2 -3
- data/lib/http/request.rb +1 -2
- data/lib/http/response.rb +10 -10
- data/lib/plugins/dependencies.rb +2 -1
- data/lib/plugins/gui_plugin.rb +77 -50
- data/lib/plugins/guiparser.rb +26 -22
- data/lib/plugins/plugin.rb +207 -427
- data/lib/plugins/plugin_base.rb +162 -0
- data/lib/plugins/plugin_plugins.rb +21 -15
- data/lib/plugins/plugin_sqlite_db.rb +45 -20
- data/lib/plugins/pluginmanager.rb +10 -5
- data/lib/plugins/plugins.rb +65 -31
- data/lib/plugins/servlet.rb +74 -26
- data/lib/rsence.rb +32 -0
- data/lib/session/msg.rb +131 -96
- data/lib/session/sessionmanager.rb +5 -4
- data/lib/session/sessionstorage.rb +4 -3
- data/lib/transporter/transporter.rb +30 -21
- data/lib/util/gzstring.rb +4 -2
- data/lib/util/ruby19_fixes.rb +18 -0
- data/lib/values/hvalue.rb +139 -88
- data/lib/values/valuemanager.rb +60 -46
- data/plugins/client_pkg/client_pkg.rb +6 -5
- data/plugins/client_pkg/lib/client_pkg_build.rb +5 -5
- data/plugins/client_pkg/lib/client_pkg_serve.rb +8 -0
- data/plugins/index_html/index_html.rb +3 -1
- data/plugins/index_html/tmpl/index.html +2 -3
- data/plugins/main/js/main.js +84 -0
- data/plugins/main/main.rb +54 -27
- data/plugins/ticket/lib/common.rb +4 -2
- data/plugins/ticket/lib/favicon.rb +3 -2
- data/plugins/ticket/lib/file.rb +2 -2
- data/plugins/ticket/lib/img.rb +2 -2
- data/plugins/ticket/lib/objblob.rb +2 -2
- data/plugins/ticket/lib/rsrc.rb +2 -2
- data/plugins/ticket/lib/upload.rb +9 -8
- data/plugins/ticket/ticket.rb +141 -8
- data/setup/welcome/welcome.rb +1 -0
- metadata +76 -72
- data/lib/plugins/plugin_util.rb +0 -107
- data/plugins/index_html/tmpl/startup_index.html +0 -29
- data/plugins/main/js/riassence_ns.js +0 -87
- data/setup/legacy/info.yaml +0 -18
- data/setup/legacy/legacy.rb +0 -17
- data/setup/welcome/gui/welcome.yaml +0 -68
- data/setup/welcome/text/welcome.html +0 -8
data/lib/values/valuemanager.rb
CHANGED
@@ -7,6 +7,7 @@
|
|
7
7
|
##
|
8
8
|
|
9
9
|
|
10
|
+
|
10
11
|
# Require needed value types (hvalue supports bool/float/int/string)
|
11
12
|
require 'values/hvalue'
|
12
13
|
|
@@ -15,82 +16,90 @@ require 'randgen'
|
|
15
16
|
|
16
17
|
module RSence
|
17
18
|
|
18
|
-
|
19
|
+
# @private ValueManager provides automatic, transparent synchronization of values
|
20
|
+
# between client and server by keeping track of session value ids that
|
21
|
+
# need to be synchronized to the client and to pass on the incoming data
|
22
|
+
# for validation.
|
19
23
|
class ValueManager
|
20
|
-
|
21
|
-
attr_accessor :randgen
|
22
|
-
|
23
|
-
# Initializes the member value handler objects.
|
24
|
-
def initialize
|
25
24
|
|
26
|
-
|
25
|
+
# @private Accessor for the {RandGen} instance used.
|
26
|
+
# @return [RandGen]
|
27
|
+
attr_accessor :randgen
|
27
28
|
|
29
|
+
def initialize
|
30
|
+
# Initializes the member value handler objects.
|
31
|
+
@config = RSence.config[:session_conf]
|
32
|
+
|
28
33
|
## 'Unique' Random String generator for HValue keys (passed on to the client)
|
29
34
|
@randgen = RandGen.new( @config[:key_length] )
|
30
|
-
|
35
|
+
|
31
36
|
end
|
32
|
-
|
33
|
-
# Re-constructs all stored values and sends them to the client
|
34
|
-
def resend_session_values( msg )
|
35
37
|
|
38
|
+
# @private Re-constructs all stored values and sends them to the client.
|
39
|
+
# Used for restoring and cloning session values.
|
40
|
+
def resend_session_values( msg )
|
41
|
+
|
36
42
|
# with disposable keys enabled,
|
37
43
|
# sessions restored from cookie_key replace
|
38
44
|
# all val_id:s with new ones
|
39
45
|
if @config[:disposable_keys]
|
40
|
-
|
46
|
+
|
41
47
|
# get the session values
|
42
48
|
ses_values = msg.session[:values]
|
43
|
-
|
49
|
+
|
44
50
|
# loop through the value id:s
|
45
51
|
old_ids = ses_values[:by_id].keys
|
46
52
|
old_ids.each do |old_id|
|
47
|
-
|
48
|
-
# make a new id
|
49
|
-
new_id = @randgen.gen
|
50
|
-
new_id = @randgen.gen while id_exists?( msg, new_id )
|
51
|
-
|
53
|
+
|
52
54
|
# get the hvalue
|
53
55
|
val_obj = ses_values[:by_id][old_id]
|
54
|
-
|
55
|
-
#
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
ses_values[:
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
56
|
+
|
57
|
+
# make a new id
|
58
|
+
unless RSence.args[:debug] and val_obj.meta[:name]
|
59
|
+
new_id = @randgen.gen
|
60
|
+
new_id = @randgen.gen while id_exists?( msg, new_id )
|
61
|
+
|
62
|
+
# replace the old id in the hvalue itself
|
63
|
+
val_obj.val_id = new_id
|
64
|
+
|
65
|
+
# re-associate the value with the new id
|
66
|
+
ses_values[:by_id][new_id] = val_obj
|
67
|
+
ses_values[:by_id].delete(old_id)
|
68
|
+
|
69
|
+
# replace the id in the unvalidated values (:check) array
|
70
|
+
if ses_values[:check].include?(old_id)
|
71
|
+
old_idx = ses_values[:check].index(old_id)
|
72
|
+
ses_values[:check][old_idx] = new_id
|
73
|
+
end
|
74
|
+
|
75
|
+
# replace the id in the unsynchronized values (:sync) array
|
76
|
+
if ses_values[:sync].include?(old_id)
|
77
|
+
old_idx = ses_values[:sync].index(old_id)
|
78
|
+
ses_values[:sync][old_idx] = new_id
|
79
|
+
end
|
80
|
+
|
72
81
|
end
|
73
|
-
|
82
|
+
|
74
83
|
# tell the hvalue to send its client-side initialization
|
75
84
|
val_obj.restore( msg )
|
76
85
|
|
77
86
|
end
|
78
|
-
|
87
|
+
|
79
88
|
## keeping the id:s between page reloads is faster, but less tamper-proof
|
80
89
|
else
|
81
90
|
msg.session[:values][:by_id].each_key do |val_id|
|
82
91
|
msg.session[:values][:by_id][val_id].restore( msg )
|
83
92
|
end
|
84
93
|
end
|
85
|
-
|
94
|
+
|
86
95
|
end
|
87
|
-
|
88
|
-
# Verifies
|
96
|
+
|
97
|
+
# @private Verifies new_id is unique.
|
89
98
|
def id_exists?( msg, new_id )
|
90
99
|
return msg.session[:values][:by_id].has_key?(new_id)
|
91
100
|
end
|
92
101
|
|
93
|
-
# Parses the json from the client and passes it on to associated values
|
102
|
+
# @private Parses the json from the client and passes it on to associated values
|
94
103
|
def xhr( msg, syncdata_str )
|
95
104
|
|
96
105
|
# parses the json data sent by the client
|
@@ -107,7 +116,7 @@ module RSence
|
|
107
116
|
end
|
108
117
|
end
|
109
118
|
|
110
|
-
# Sets a value by id
|
119
|
+
# @private Sets a value by id
|
111
120
|
def set( msg, val_id, val_data )
|
112
121
|
|
113
122
|
# get the session data of this session
|
@@ -118,7 +127,7 @@ module RSence
|
|
118
127
|
val_obj.set( msg, val_data )
|
119
128
|
end
|
120
129
|
|
121
|
-
# Validates the new data of all client-side-modified session-bound values
|
130
|
+
# @private Validates the new data of all client-side-modified session-bound values
|
122
131
|
def validate( msg )
|
123
132
|
|
124
133
|
# get the session data of this session
|
@@ -132,7 +141,7 @@ module RSence
|
|
132
141
|
|
133
142
|
end
|
134
143
|
|
135
|
-
# Sends the new data of all server-side-modified session-bound values to the client
|
144
|
+
# @private Sends the new data of all server-side-modified session-bound values to the client
|
136
145
|
def sync_client( msg )
|
137
146
|
|
138
147
|
# get the session data of this session
|
@@ -143,7 +152,12 @@ module RSence
|
|
143
152
|
|
144
153
|
# the sync-array will return the value id
|
145
154
|
val_id = session_values[:sync].shift
|
146
|
-
|
155
|
+
|
156
|
+
unless session_values[:by_id].has_key? val_id
|
157
|
+
warn "ValueManager#sync_client -- Invalid value id: #{val_id.inspect}"
|
158
|
+
next
|
159
|
+
end
|
160
|
+
|
147
161
|
# tell the value of that id to report its state to the client
|
148
162
|
session_values[:by_id][val_id].to_client( msg )
|
149
163
|
|
@@ -6,6 +6,7 @@
|
|
6
6
|
# with this software package. If not, contact licensing@riassence.com
|
7
7
|
##
|
8
8
|
|
9
|
+
|
9
10
|
# the library path of this plugin
|
10
11
|
lib_path = File.join( bundle_path, 'lib' )
|
11
12
|
|
@@ -19,8 +20,8 @@ require File.join( lib_path, 'client_pkg_serve' )
|
|
19
20
|
require File.join( lib_path, 'client_pkg_build' )
|
20
21
|
|
21
22
|
|
22
|
-
|
23
|
-
class
|
23
|
+
# @private The ClientPkgPlugin builds and serves the client packages. It's not intended to be a part of the public API at this time.
|
24
|
+
class ClientPkgPlugin < Servlet
|
24
25
|
|
25
26
|
include ClientPkgServe
|
26
27
|
|
@@ -31,7 +32,7 @@ class ClientPkg < Servlet
|
|
31
32
|
@log_file = nil
|
32
33
|
end
|
33
34
|
def log( str )
|
34
|
-
if
|
35
|
+
if RSence.args[:verbose]
|
35
36
|
puts str
|
36
37
|
return
|
37
38
|
else
|
@@ -140,10 +141,10 @@ class ClientPkg < Servlet
|
|
140
141
|
|
141
142
|
@thr = false
|
142
143
|
|
143
|
-
@build_logger = BuildLogger.new( File.join(
|
144
|
+
@build_logger = BuildLogger.new( File.join(RSence.args[:env_path],'log','build_log') )
|
144
145
|
@build_logger.open
|
145
146
|
|
146
|
-
@client_build = ClientPkgBuild.new(
|
147
|
+
@client_build = ClientPkgBuild.new( RSence.config[:client_pkg], @build_logger )
|
147
148
|
@client_cache = ClientPkgCache.new
|
148
149
|
|
149
150
|
@build_busy = false
|
@@ -7,13 +7,13 @@
|
|
7
7
|
##
|
8
8
|
|
9
9
|
|
10
|
+
require 'jsmin_c'
|
11
|
+
require 'jscompress'
|
12
|
+
require 'html_min'
|
13
|
+
|
14
|
+
|
10
15
|
class ClientPkgBuild
|
11
16
|
|
12
|
-
require 'jsmin_c'
|
13
|
-
require 'jscompress'
|
14
|
-
require 'html_min'
|
15
|
-
require 'util/gzstring'
|
16
|
-
|
17
17
|
def read_file( path )
|
18
18
|
filehandle = open( path, 'rb' )
|
19
19
|
filedata = filehandle.read
|
@@ -1,3 +1,11 @@
|
|
1
|
+
## RSence
|
2
|
+
# Copyright 2007 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
|
+
|
1
9
|
|
2
10
|
module ClientPkgServe
|
3
11
|
def broker_urls
|
@@ -6,7 +6,9 @@
|
|
6
6
|
# with this software package. If not, contact licensing@riassence.com
|
7
7
|
##
|
8
8
|
|
9
|
-
|
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.
|
10
12
|
class IndexHtmlPlugin < Servlet
|
11
13
|
|
12
14
|
def match( uri, method )
|
@@ -12,9 +12,8 @@ __SCRIPT_DEPS__
|
|
12
12
|
<script>
|
13
13
|
|
14
14
|
/** Runtime configuration: **/
|
15
|
-
|
16
|
-
|
17
|
-
HCLIENT_HELLO='__CLIENT_HELLO__';
|
15
|
+
COMM.ClientPrefix='__CLIENT_BASE__';
|
16
|
+
COMM.Transporter.HelloUrl='__CLIENT_HELLO__';
|
18
17
|
HThemeManager.themePath='__CLIENT_BASE__/themes';
|
19
18
|
|
20
19
|
</script>
|
@@ -0,0 +1,84 @@
|
|
1
|
+
// List of apps initialized utilizing GUITrees, by GUIPlugin name
|
2
|
+
RSence.apps = { };
|
3
|
+
|
4
|
+
// Subview that utilizes GUITrees
|
5
|
+
RSence.GUIView = HControl.extend({
|
6
|
+
|
7
|
+
});
|
8
|
+
|
9
|
+
// Application that handles GUITrees, populates its values dynamically
|
10
|
+
RSence.GUIApp = HApplication.extend({
|
11
|
+
constructor: function(_options){
|
12
|
+
|
13
|
+
var
|
14
|
+
_this = this,
|
15
|
+
|
16
|
+
// Application priority
|
17
|
+
_priority = _options.priority?_options.priority:100,
|
18
|
+
|
19
|
+
// Application label / title
|
20
|
+
_label = _options.label?_options.label:'Untitled Application',
|
21
|
+
|
22
|
+
// Application description (multiline)
|
23
|
+
_descr = _options.descr?_options.descr:'No Description',
|
24
|
+
|
25
|
+
// Allow multiple instances?
|
26
|
+
_allowMulti = _options.allowMulti?_options.allowMulti:false,
|
27
|
+
|
28
|
+
// The GUI Tree
|
29
|
+
_valueObj = _options.valueObj?_options.valueObj:false,
|
30
|
+
|
31
|
+
// Signal input (from server to client)
|
32
|
+
_sigInput = _options.sigInput?COMM.Values.values[_options.sigInput]:false,
|
33
|
+
|
34
|
+
// Signal output (from client to server)
|
35
|
+
_sigOutput = _options.sigOutput?COMM.Values.values[_options.sigOutput]:false,
|
36
|
+
|
37
|
+
// Icon image url.
|
38
|
+
// Minimum size is 16x16 and multiple sizes are stacked on top of each other,
|
39
|
+
// largest topmost, smaller versions aligned left below in size order.
|
40
|
+
// Image formats supported are: SVG (except for IE), PNG (all), GIF (all), JPG (all).
|
41
|
+
// Recommended formats are: SVG and PNG24 with transparency / translucency.
|
42
|
+
// Size has to be a factor of two; 16,32,64,128,256,512 are valid dimensions:
|
43
|
+
// 32x32 -> 32x32 single icon
|
44
|
+
// 32x48 -> 32x32 and 16x16
|
45
|
+
// 512x512 -> 512x512 single icon
|
46
|
+
// 512x768 -> 512x512, 256x256
|
47
|
+
// 512x640 -> 512x512, 128x128
|
48
|
+
// 512x896 -> 512x512, 256x256 and 128x128
|
49
|
+
// etc..
|
50
|
+
_iconUrl = _options.iconUrl?COMM.Values.values[_options.iconUrl]:false;
|
51
|
+
|
52
|
+
// Construct the application base:
|
53
|
+
_this.base( _priority, _label );
|
54
|
+
|
55
|
+
// Options combined from vars above
|
56
|
+
_this.options = HClass.extend(_options).extend({
|
57
|
+
label: _label,
|
58
|
+
descr: _descr,
|
59
|
+
allowMulti: _allowMulti,
|
60
|
+
sigInput: _sigInput,
|
61
|
+
sigOutput: _sigOutput,
|
62
|
+
icon: { url: _iconUrl, width: null, height: null },
|
63
|
+
pid: this.appId,
|
64
|
+
views: []
|
65
|
+
}).nu();
|
66
|
+
|
67
|
+
_this.valueObj = _valueObj;
|
68
|
+
_this.value = _valueObj.value;
|
69
|
+
|
70
|
+
// _this.app = _this;
|
71
|
+
|
72
|
+
//
|
73
|
+
// _this.renderer = COMM.JSONRenderer.extend({
|
74
|
+
//
|
75
|
+
// }).nu( _this.value, _this );
|
76
|
+
},
|
77
|
+
|
78
|
+
die: function(){
|
79
|
+
this.base();
|
80
|
+
|
81
|
+
}
|
82
|
+
|
83
|
+
});
|
84
|
+
|
data/plugins/main/main.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
#--
|
2
1
|
## RSence
|
3
2
|
# Copyright 2008 Riassence Inc.
|
4
3
|
# http://riassence.com/
|
@@ -6,16 +5,27 @@
|
|
6
5
|
# You should have received a copy of the GNU General Public License along
|
7
6
|
# with this software package. If not, contact licensing@riassence.com
|
8
7
|
##
|
9
|
-
#++
|
10
8
|
|
11
|
-
|
9
|
+
|
10
|
+
# The MainPlugin is accessible as +@plugins.main+ from other plugins.
|
11
|
+
#
|
12
|
+
# = MainPlugin provides mainly client setup and the following services:
|
13
|
+
# * The url of the client as a HValue, including the anchor.
|
14
|
+
# * Accessible via +msg.session[:main][:location_href]+
|
15
|
+
# * The local time of the client's web browser as a HValue, as seconds since epoch.
|
16
|
+
# * Accessible via +msg.session[:main][:client_time]+
|
17
|
+
# * Sequential loading. See {#delayed_call #delayed_call}
|
18
|
+
# * Provides the +#init_ui+ event for plugins that respond to it.
|
19
|
+
class MainPlugin < Plugin
|
12
20
|
|
21
|
+
# @private Internal structures, binds configuration data as instance variables
|
13
22
|
def init
|
14
23
|
super
|
15
24
|
@conf = ::RSence.config[:index_html]
|
16
25
|
@bconf = ::RSence.config[:broker_urls]
|
17
26
|
end
|
18
27
|
|
28
|
+
# @private Internal structures, matches the "hello/goodbye" session termination request
|
19
29
|
def match( uri, request_type )
|
20
30
|
if request_type == :post and
|
21
31
|
uri == File.join(@bconf[:hello],'goodbye')
|
@@ -24,23 +34,24 @@ class Main < Plugin
|
|
24
34
|
return false
|
25
35
|
end
|
26
36
|
|
37
|
+
# @private Internal structures, score for the "hello/goodbye" session termination request
|
27
38
|
def score; 100; end
|
28
39
|
|
40
|
+
# @private Internal structures, handler for the "hello/goodbye" session termination request
|
29
41
|
def post( req, res, ses )
|
30
42
|
msg = @plugins.sessions.init_msg( req, res, { :cookies => true } )
|
31
43
|
msg.expire_session()
|
32
44
|
msg.response_done
|
33
45
|
end
|
34
46
|
|
35
|
-
# url_responder gets called whenever the
|
36
|
-
#
|
37
|
-
#
|
38
|
-
#
|
47
|
+
# @private url_responder gets called whenever the
|
48
|
+
# page location.href changes, enabled virtual uris
|
49
|
+
# to enable back/forward/bookmarking in browsers,
|
50
|
+
# when software is coded to support it.
|
39
51
|
#
|
40
52
|
# Client-side support is included in js/url_responder.js
|
41
53
|
#
|
42
|
-
# Also allows virtual-host -like behavior, if software
|
43
|
-
# is coded to support it.
|
54
|
+
# Also allows virtual-host -like behavior, if software is coded to support it.
|
44
55
|
def url_responder(msg,location_href)
|
45
56
|
|
46
57
|
ses = get_ses( msg )
|
@@ -75,15 +86,13 @@ class Main < Plugin
|
|
75
86
|
end
|
76
87
|
|
77
88
|
|
78
|
-
# new session initialization,
|
79
|
-
# called just once per session.
|
89
|
+
# @private new session initialization, called just once per session.
|
80
90
|
def init_ses(msg)
|
81
91
|
super
|
82
92
|
restore_ses( msg )
|
83
93
|
end
|
84
94
|
|
85
|
-
# called once when a session is
|
86
|
-
# restored using the cookie's ses_key
|
95
|
+
# @private called once when a session is restored using the cookie's ses_key
|
87
96
|
def restore_ses(msg)
|
88
97
|
super
|
89
98
|
## Resets session data to defaults
|
@@ -95,14 +104,33 @@ class Main < Plugin
|
|
95
104
|
end
|
96
105
|
|
97
106
|
# Interface for adding delayed calls
|
98
|
-
|
99
|
-
|
107
|
+
#
|
108
|
+
# 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.
|
109
|
+
#
|
110
|
+
# It can also be used for loading sequences to the client, when using a String as the +params+.
|
111
|
+
#
|
112
|
+
# == Format of +params+ for plugin callback:
|
113
|
+
# Array:: [ plugin_name, method_name, *args ]
|
114
|
+
#
|
115
|
+
# == Format of +params+ for javascript sequences:
|
116
|
+
# String:: Javascript to send
|
117
|
+
#
|
118
|
+
# Calls will be flushed per request with the following conditions:
|
119
|
+
# * At most four (4) delayed calls will be processed at a time
|
120
|
+
# * If the calls use more than 200ms combined, even less will be processed at a time
|
121
|
+
#
|
122
|
+
# @param [Message] msg The message instance.
|
123
|
+
# @param [Array, String] params The params of the delayed call.
|
124
|
+
#
|
125
|
+
# @return [nil]
|
126
|
+
def delayed_call( msg, params )
|
127
|
+
get_ses( msg )[:delayed_calls].push( params )
|
100
128
|
end
|
101
129
|
|
102
|
-
# Initializes the client-side COMM.urlResponder and sesWatcher
|
130
|
+
# @private Initializes the client-side COMM.urlResponder and sesWatcher
|
103
131
|
def boot0( msg, ses )
|
104
132
|
|
105
|
-
msg.reply read_js( '
|
133
|
+
msg.reply read_js( 'main' )
|
106
134
|
|
107
135
|
msg.reply("ELEM.setStyle(0,'background-color','#{::RSence.config[:main_plugin][:bg_color]}');")
|
108
136
|
|
@@ -120,20 +148,20 @@ class Main < Plugin
|
|
120
148
|
poll_interval = ::RSence.config[:main_plugin][:server_poll_interval]
|
121
149
|
msg.reply "sesWatcher = COMM.SessionWatcher.nu(#{poll_interval},#{client_time_id});"
|
122
150
|
|
123
|
-
|
124
151
|
end
|
125
152
|
|
126
|
-
# Calls the init_ui method of each loaded plugin and removes the loading -message
|
153
|
+
# @private Calls the init_ui method of each loaded plugin and removes the loading -message
|
127
154
|
def boot1( msg, ses )
|
128
155
|
# Delegates the init_ui method to each plugin to signal bootstrap completion.
|
129
156
|
msg.plugins.delegate( 'init_ui', msg ) unless ses[:dont_init_ui]
|
130
157
|
end
|
131
158
|
|
159
|
+
# @private
|
132
160
|
def dont_init_ui( msg )
|
133
161
|
get_ses( msg )[:dont_init_ui] = true
|
134
162
|
end
|
135
163
|
|
136
|
-
# Flushes commands in the :delayed_calls array
|
164
|
+
# @private Flushes commands in the :delayed_calls array
|
137
165
|
def flush_delayed( msg, ses )
|
138
166
|
## Limits the amount of delayed calls to process to 4.
|
139
167
|
## Prevents the client from choking even when the server
|
@@ -187,10 +215,10 @@ class Main < Plugin
|
|
187
215
|
end
|
188
216
|
end
|
189
217
|
|
190
|
-
# When nothing is delayed and the second poll has been made (init_ui called),
|
191
|
-
#
|
192
|
-
#
|
193
|
-
#
|
218
|
+
# @private When nothing is delayed and the second poll has been made (init_ui called),
|
219
|
+
# sets the client to non-polling-mode, having only HValue
|
220
|
+
# changes trigger new requests. SesWatcher makes this happen
|
221
|
+
# regularly.
|
194
222
|
def end_polling( msg, ses )
|
195
223
|
if ses[:poll_mode] == true
|
196
224
|
msg.reply "COMM.Transporter.poll(0);"
|
@@ -198,7 +226,7 @@ class Main < Plugin
|
|
198
226
|
end
|
199
227
|
end
|
200
228
|
|
201
|
-
# Starts polling.
|
229
|
+
# @private Starts polling.
|
202
230
|
def start_polling( msg, ses )
|
203
231
|
if ses[:poll_mode] == false
|
204
232
|
msg.reply( "COMM.Transporter.poll(#{::RSence.config[:transporter_conf][:client_poll_priority]});" )
|
@@ -206,8 +234,7 @@ class Main < Plugin
|
|
206
234
|
end
|
207
235
|
end
|
208
236
|
|
209
|
-
# called on every request of an
|
210
|
-
# active, valid session
|
237
|
+
# @private called on every request of an active, valid session
|
211
238
|
def idle(msg)
|
212
239
|
|
213
240
|
ses = get_ses( msg )
|