rsence 2.0.0.5.pre → 2.0.0.6.pre
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +2 -2
- data/VERSION +1 -1
- data/bin/rsence +4 -1
- data/conf/default_conf.yaml +1 -1
- data/conf/rsence_command_strings.yaml +444 -0
- data/js/comm/comm/autosync/autosync.js +1 -1
- data/js/comm/comm/comm.js +1 -1
- data/js/comm/comm/queue/queue.js +1 -1
- data/js/comm/comm/session/session.js +1 -1
- data/js/comm/comm/sessionwatcher/sessionwatcher.js +1 -1
- data/js/comm/comm/transporter/transporter.js +1 -1
- data/js/comm/comm/urlresponder/urlresponder.js +1 -1
- data/js/comm/comm/values/values.js +1 -1
- data/js/comm/jsloader/jsloader.js +1 -1
- data/js/comm/reloadapp/reloadapp.js +1 -1
- data/js/comm/sha/sha.js +1 -1
- data/js/comm/values/value/value.js +1 -1
- data/js/comm/values/valuematrix/valuematrix.js +1 -1
- data/js/controls/button/button.js +1 -1
- data/js/controls/checkbox/checkbox.js +1 -1
- data/js/controls/datetime/calendar/calendar.js +1 -1
- data/js/controls/datetime/datetimevalue/datetimevalue.js +1 -1
- data/js/controls/datetime/timesheet/timesheet.js +1 -1
- data/js/controls/datetime/timesheet_item/timesheet_item.js +1 -1
- data/js/controls/datetime/timesheet_item_edit/timesheet_item_edit.js +1 -1
- data/js/controls/dialogs/alert_sheet/alert_sheet.js +1 -1
- data/js/controls/dialogs/confirm_sheet/confirm_sheet.js +1 -1
- data/js/controls/dialogs/sheet/sheet.js +1 -1
- data/js/controls/imageview/imageview.js +1 -1
- data/js/controls/lists/checkboxlist/checkboxlist.js +1 -1
- data/js/controls/lists/listitems/listitems.js +1 -1
- data/js/controls/lists/radiobuttonlist/radiobuttonlist.js +1 -1
- data/js/controls/passwordcontrol/passwordcontrol.js +1 -1
- data/js/controls/progress/progressbar/progressbar.js +1 -1
- data/js/controls/progress/progressindicator/progressindicator.js +1 -1
- data/js/controls/radiobutton/radiobutton.js +1 -1
- data/js/controls/sliders/slider/slider.js +1 -1
- data/js/controls/sliders/vslider/vslider.js +1 -1
- data/js/controls/stepper/stepper.js +1 -1
- data/js/controls/stringview/stringview.js +1 -1
- data/js/controls/tab/tab.js +1 -1
- data/js/controls/textarea/textarea.js +1 -1
- data/js/controls/textcontrol/textcontrol.js +1 -1
- data/js/controls/uploader/uploader.js +1 -1
- data/js/controls/validatorview/validatorview.js +6 -2
- data/js/controls/window/window.js +1 -1
- data/js/core/class/class.js +1 -1
- data/js/core/elem/elem.js +1 -1
- data/js/core/event/event.js +1 -1
- data/js/core/iefix/iefix.js +1 -1
- data/js/foundation/application/application.js +1 -1
- data/js/foundation/control/control.js +1 -1
- data/js/foundation/control/controldefaults/controldefaults.js +1 -1
- data/js/foundation/control/dummyvalue/dummyvalue.js +1 -1
- data/js/foundation/control/dyncontrol/dyncontrol.js +1 -1
- data/js/foundation/control/eventresponder/eventresponder.js +1 -1
- data/js/foundation/control/valueresponder/valueresponder.js +1 -1
- data/js/foundation/geom/point/point.js +1 -1
- data/js/foundation/geom/rect/rect.js +1 -1
- data/js/foundation/json_renderer/json_renderer.js +1 -1
- data/js/foundation/system/system.js +1 -1
- data/js/foundation/thememanager/thememanager.js +1 -1
- data/js/foundation/view/markupview/markupview.js +1 -1
- data/js/foundation/view/morphanimation/morphanimation.js +1 -1
- data/js/foundation/view/view.js +1 -1
- data/js/foundation/view/viewdefaults/viewdefaults.js +1 -1
- data/js/views/centerview/centerview.js +1 -1
- data/js/views/inlineview/inlineview.js +1 -1
- data/js/views/scrollview/scrollview.js +1 -1
- data/lib/conf/argv.rb +719 -1006
- data/lib/conf/default.rb +14 -3
- data/lib/daemon/daemon.rb +1 -1
- data/lib/daemon/sigcomm.rb +1 -1
- data/lib/http/broker.rb +5 -1
- data/lib/http/rackup.rb +1 -1
- data/lib/http/request.rb +1 -1
- data/lib/http/response.rb +2 -2
- data/lib/plugins/dependencies.rb +36 -0
- data/lib/plugins/gui_plugin.rb +83 -80
- data/lib/plugins/guiparser.rb +7 -3
- data/lib/plugins/plugin.rb +308 -307
- data/lib/plugins/plugin_plugins.rb +5 -1
- data/lib/plugins/plugin_sqlite_db.rb +5 -1
- data/lib/plugins/plugin_util.rb +22 -0
- data/lib/plugins/pluginmanager.rb +95 -95
- data/lib/plugins/plugins.rb +117 -0
- data/lib/plugins/servlet.rb +47 -57
- data/lib/session/msg.rb +1 -1
- data/lib/session/sessionmanager.rb +1 -1
- data/lib/session/sessionstorage.rb +2 -2
- data/lib/transporter/transporter.rb +1 -2
- data/lib/values/hvalue.rb +7 -3
- data/lib/values/valuemanager.rb +7 -1
- data/plugins/client_pkg/client_pkg.rb +15 -48
- data/plugins/client_pkg/info.yaml +1 -1
- data/plugins/client_pkg/lib/client_pkg_build.rb +1 -1
- data/plugins/client_pkg/lib/client_pkg_cache.rb +1 -1
- data/plugins/index_html/index_html.rb +5 -6
- data/plugins/index_html/info.yaml +21 -0
- data/plugins/index_html/tmpl/index.html +1 -1
- data/plugins/index_html/tmpl/startup_index.html +1 -1
- data/plugins/main/info.yaml +21 -0
- data/plugins/main/main.rb +1 -5
- data/plugins/{ticketservices → ticket}/lib/common.rb +92 -2
- data/plugins/{ticketservices → ticket}/lib/favicon.rb +1 -1
- data/plugins/{ticketservices → ticket}/lib/file.rb +1 -1
- data/plugins/{ticketservices → ticket}/lib/img.rb +1 -1
- data/plugins/{ticketservices → ticket}/lib/objblob.rb +1 -1
- data/plugins/{ticketservices → ticket}/lib/rsrc.rb +1 -1
- data/plugins/{ticketservices → ticket}/lib/upload.rb +60 -31
- data/plugins/{ticketservices/ticketservices.rb → ticket/ticket.rb} +50 -118
- data/{plugins → setup}/legacy/info.yaml +0 -0
- data/{plugins → setup}/legacy/legacy.rb +2 -0
- data/setup/welcome/welcome.rb +1 -1
- metadata +27 -21
- data/conf/config.yaml +0 -4
- data/conf/local_conf.yaml.devel +0 -14
- data/lib/conf/wizard.rb +0 -303
- data/plugins/client_pkg/log/build_log +0 -0
- data/plugins/legacy/disabled +0 -0
- data/plugins/legacy/disabled- +0 -0
data/lib/conf/default.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
##
|
2
|
+
## RSence
|
3
3
|
# Copyright 2008 Riassence Inc.
|
4
4
|
# http://riassence.com/
|
5
5
|
#
|
@@ -13,7 +13,13 @@ require 'rack'
|
|
13
13
|
require 'yaml'
|
14
14
|
|
15
15
|
if RUBY_VERSION.to_f >= 1.9
|
16
|
-
Encoding.default_external = Encoding::
|
16
|
+
# Encoding.default_external = Encoding::BINARY
|
17
|
+
# Encoding.default_internal = Encoding::BINARY
|
18
|
+
class String
|
19
|
+
def each
|
20
|
+
self.split($/).each { |e| yield e }
|
21
|
+
end
|
22
|
+
end
|
17
23
|
end
|
18
24
|
|
19
25
|
# Legacy:
|
@@ -193,12 +199,17 @@ class Configuration
|
|
193
199
|
config[:broker_urls][broker_key] = default_uri
|
194
200
|
end
|
195
201
|
end
|
196
|
-
|
202
|
+
# if RUBY_VERSION.to_f >= 1.9
|
203
|
+
# config[:no_gzip] = true
|
204
|
+
# end
|
197
205
|
# The default address of the index_html plugin
|
198
206
|
unless config[:index_html].has_key?(:respond_address)
|
199
207
|
config[:index_html][:respond_address] = File.join(config[:base_url])
|
200
208
|
end
|
201
209
|
|
210
|
+
config[:client_pkg][:no_obfuscation] = true if args[:client_pkg_no_obfuscation]
|
211
|
+
config[:client_pkg][:no_whitespace_removal] = true if args[:client_pkg_no_whitespace_removal]
|
212
|
+
|
202
213
|
## Uses the lib paths as search paths
|
203
214
|
lib_paths.each do |lib_path|
|
204
215
|
$LOAD_PATH << lib_path
|
data/lib/daemon/daemon.rb
CHANGED
data/lib/daemon/sigcomm.rb
CHANGED
data/lib/http/broker.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
##
|
2
|
+
## RSence
|
3
3
|
# Copyright 2008 Riassence Inc.
|
4
4
|
# http://riassence.com/
|
5
5
|
#
|
@@ -47,7 +47,9 @@ class Broker
|
|
47
47
|
dispatcher = dispatcher_class.new( request, response )
|
48
48
|
dispatcher.send(request_method)
|
49
49
|
content_type = dispatcher.content_type
|
50
|
+
# puts "encoding: #{response.body.encoding.inspect}"
|
50
51
|
response.header['Content-Length'] = response.body.length.to_s unless response.header.has_key?('Content-Length')
|
52
|
+
# puts [response.status, response.header, response.body].inspect
|
51
53
|
return [response.status, response.header, response.body]
|
52
54
|
end
|
53
55
|
|
@@ -71,7 +73,9 @@ class Broker
|
|
71
73
|
end
|
72
74
|
Thread.new do
|
73
75
|
Thread.pass
|
76
|
+
puts "testing port.. #{host.inspect}"
|
74
77
|
until RSence.argv.test_port( port, host )
|
78
|
+
puts "port tested"
|
75
79
|
sleep 0.1
|
76
80
|
end
|
77
81
|
@@transporter.online = true
|
data/lib/http/rackup.rb
CHANGED
data/lib/http/request.rb
CHANGED
data/lib/http/response.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
##
|
2
|
+
## RSence
|
3
3
|
# Copyright 2008 Riassence Inc.
|
4
4
|
# http://riassence.com/
|
5
5
|
#
|
@@ -26,7 +26,7 @@ class Response
|
|
26
26
|
@status = 200
|
27
27
|
@header = {
|
28
28
|
'Content-Type' => 'text/plain',
|
29
|
-
'Server' => '
|
29
|
+
'Server' => 'RSence'
|
30
30
|
}
|
31
31
|
end
|
32
32
|
def body=(body_data)
|
@@ -0,0 +1,36 @@
|
|
1
|
+
## RSence
|
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
|
+
module RSence
|
10
|
+
class Dependencies
|
11
|
+
def initialize( deps = [] )
|
12
|
+
@deps = deps
|
13
|
+
@depends_on = {
|
14
|
+
# :name => [ :dep1, :dep2, :dep3, ... ]
|
15
|
+
}
|
16
|
+
# ...additional initialization?
|
17
|
+
end
|
18
|
+
def set_deps( name, deps )
|
19
|
+
if not @depends_on.has_key?(name)
|
20
|
+
@depends_on[name] = deps
|
21
|
+
else
|
22
|
+
@depends_on[name].join( deps )
|
23
|
+
end
|
24
|
+
# ...additional checks?
|
25
|
+
end
|
26
|
+
alias set_dependencies set_deps
|
27
|
+
def deps
|
28
|
+
# calculate @depends_on and push items with
|
29
|
+
# resolved dependencies into @deps
|
30
|
+
# ...
|
31
|
+
return @deps
|
32
|
+
end
|
33
|
+
alias deps load_order
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
data/lib/plugins/gui_plugin.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
##
|
1
|
+
## RSence
|
2
2
|
# Copyright 2009 Riassence Inc.
|
3
3
|
# http://riassence.com/
|
4
4
|
#
|
@@ -26,104 +26,107 @@
|
|
26
26
|
##
|
27
27
|
##
|
28
28
|
##
|
29
|
-
|
29
|
+
module ::RSence
|
30
|
+
module Plugins
|
31
|
+
class GUIPluginTemplate < PluginTemplate
|
32
|
+
def self.bundle_type; :GUIPlugin; end
|
30
33
|
|
31
|
-
|
34
|
+
@@default_yaml_src = <<-END
|
32
35
|
type: GUITree
|
33
|
-
version: 0.
|
36
|
+
version: 0.6
|
34
37
|
|
35
38
|
class: HApplication
|
36
39
|
options:
|
37
40
|
label: "Dummy Application"
|
38
|
-
|
41
|
+
|
42
|
+
END
|
39
43
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
44
|
+
# Automatically initializes an GUIParser instance as @gui
|
45
|
+
def init
|
46
|
+
super
|
47
|
+
yaml_src = file_read( "gui/#{@name}.yaml" )
|
48
|
+
yaml_src = file_read( "gui/main.yaml" ) unless yaml_src
|
49
|
+
yaml_src = @@default_yaml_src unless yaml_src
|
50
|
+
@gui = GUIParser.new( self, yaml_src )
|
51
|
+
@client_pkgs = false
|
52
|
+
end
|
49
53
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
54
|
+
# Extend this method to return custom params to GUIParser#init.
|
55
|
+
# Called from init_ui.
|
56
|
+
# By default assigns the session values as :values to use for
|
57
|
+
# valueObjId: ":values.my_value_name" in the YAML GUI file.
|
58
|
+
def gui_params( msg )
|
59
|
+
return {
|
60
|
+
:values => @gui.values( get_ses( msg ) )
|
61
|
+
}
|
62
|
+
end
|
59
63
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
64
|
+
def install_client_pkgs
|
65
|
+
if @client_pkgs
|
66
|
+
warn "install_client_pkgs: called with @client_pkgs defined; returning"
|
67
|
+
return
|
68
|
+
end
|
69
|
+
@client_pkgs = yaml_read( 'client_pkgs.yaml' )
|
70
|
+
if @client_pkgs
|
71
|
+
if @client_pkgs.has_key?(:src_dirs)
|
72
|
+
@client_pkgs[:src_dirs].each do |src_dir|
|
73
|
+
src_dir = bundle_path( src_dir[2..-1] ) if src_dir.start_with?('./')
|
74
|
+
@plugins.client_pkg.add_src_dir( src_dir )
|
75
|
+
end
|
76
|
+
end
|
77
|
+
@plugins.client_pkg.add_packages( @client_pkgs[:packages ] ) if @client_pkgs.has_key?(:packages )
|
78
|
+
@plugins.client_pkg.add_themes( @client_pkgs[:theme_names ] ) if @client_pkgs.has_key?(:theme_names )
|
79
|
+
@plugins.client_pkg.add_gfx_formats( @client_pkgs[:gfx_formats ] ) if @client_pkgs.has_key?(:gfx_formats )
|
80
|
+
@plugins.client_pkg.add_reserved_names( @client_pkgs[:reserved_names] ) if @client_pkgs.has_key?(:reserved_names)
|
81
|
+
@plugins.client_pkg.rebuild_client
|
71
82
|
end
|
72
83
|
end
|
73
|
-
@plugins.client_pkg.add_packages( @client_pkgs[:packages ] ) if @client_pkgs.has_key?(:packages )
|
74
|
-
@plugins.client_pkg.add_themes( @client_pkgs[:theme_names ] ) if @client_pkgs.has_key?(:theme_names )
|
75
|
-
@plugins.client_pkg.add_gfx_formats( @client_pkgs[:gfx_formats ] ) if @client_pkgs.has_key?(:gfx_formats )
|
76
|
-
@plugins.client_pkg.add_reserved_names( @client_pkgs[:reserved_names] ) if @client_pkgs.has_key?(:reserved_names)
|
77
|
-
@plugins.client_pkg.rebuild_client
|
78
|
-
end
|
79
|
-
end
|
80
84
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
85
|
+
def uninstall_client_pkgs
|
86
|
+
if not @client_pkgs
|
87
|
+
warn "uninstall_client_pkgs: called without @client_pkgs defined"
|
88
|
+
else
|
89
|
+
if @client_pkgs.has_key?(:src_dirs)
|
90
|
+
@client_pkgs[:src_dirs].each do |src_dir|
|
91
|
+
src_dir = bundle_path( src_dir[2..-1] ) if src_dir.start_with?('./')
|
92
|
+
@plugins.client_pkg.del_src_dir( src_dir )
|
93
|
+
end
|
94
|
+
end
|
95
|
+
@plugins.client_pkg.del_reserved_names( @client_pkgs[:reserved_names] ) if @client_pkgs.has_key?(:reserved_names)
|
96
|
+
@plugins.client_pkg.del_gfx_formats( @client_pkgs[:gfx_formats ] ) if @client_pkgs.has_key?(:gfx_formats )
|
97
|
+
@plugins.client_pkg.del_themes( @client_pkgs[:theme_names ] ) if @client_pkgs.has_key?(:theme_names )
|
98
|
+
@plugins.client_pkg.del_packages( @client_pkgs[:packages].keys ) if @client_pkgs.has_key?(:packages )
|
99
|
+
@plugins.client_pkg.rebuild_client
|
89
100
|
end
|
101
|
+
@client_pkgs = false
|
90
102
|
end
|
91
|
-
@plugins.client_pkg.del_reserved_names( @client_pkgs[:reserved_names] ) if @client_pkgs.has_key?(:reserved_names)
|
92
|
-
@plugins.client_pkg.del_gfx_formats( @client_pkgs[:gfx_formats ] ) if @client_pkgs.has_key?(:gfx_formats )
|
93
|
-
@plugins.client_pkg.del_themes( @client_pkgs[:theme_names ] ) if @client_pkgs.has_key?(:theme_names )
|
94
|
-
@plugins.client_pkg.del_packages( @client_pkgs[:packages].keys ) if @client_pkgs.has_key?(:packages )
|
95
|
-
@plugins.client_pkg.rebuild_client
|
96
|
-
end
|
97
|
-
@client_pkgs = false
|
98
|
-
end
|
99
103
|
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
def close
|
106
|
-
super
|
107
|
-
uninstall_client_pkgs if @client_pkgs
|
108
|
-
end
|
104
|
+
def open
|
105
|
+
super
|
106
|
+
install_client_pkgs if File.exist? bundle_path( 'client_pkgs.yaml' )
|
107
|
+
end
|
109
108
|
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
109
|
+
def close
|
110
|
+
super
|
111
|
+
uninstall_client_pkgs if @client_pkgs
|
112
|
+
end
|
114
113
|
|
115
|
-
|
116
|
-
|
117
|
-
|
114
|
+
# Sends gui specification to the main plugin
|
115
|
+
def spec_ui( msg )
|
116
|
+
# TODO
|
117
|
+
end
|
118
118
|
|
119
|
-
|
120
|
-
|
119
|
+
# Automatically inits the UI using GUIParser#init.
|
120
|
+
# Passes on the return value of gui_params.
|
121
|
+
def init_ui( msg ); @gui.init( msg, gui_params( msg ) ); end
|
121
122
|
|
122
|
-
|
123
|
-
|
123
|
+
# Automatically kills the UI using GUIParser#kill
|
124
|
+
def kill_ui( msg ); @gui.kill( msg ); end
|
124
125
|
|
125
|
-
|
126
|
+
# Makes include_js public to enable calls to it from GUIParser
|
127
|
+
public :include_js, :read_js_once
|
126
128
|
|
129
|
+
attr_reader :plugins
|
130
|
+
end
|
131
|
+
end
|
127
132
|
end
|
128
|
-
|
129
|
-
|
data/lib/plugins/guiparser.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
##
|
1
|
+
## RSence
|
2
2
|
# Copyright 2009 Riassence Inc.
|
3
3
|
# http://riassence.com/
|
4
4
|
#
|
@@ -6,6 +6,8 @@
|
|
6
6
|
# with this software package. If not, contact licensing@riassence.com
|
7
7
|
##
|
8
8
|
|
9
|
+
module ::RSence
|
10
|
+
module Plugins
|
9
11
|
# This class automatically loads a YAML file from "gui" subdirectory of a plugin.
|
10
12
|
# Extend your plugin from the GUIPlugin class instead of the Plugin class to make
|
11
13
|
# this work automatically.
|
@@ -38,7 +40,8 @@ class GUIParser
|
|
38
40
|
end
|
39
41
|
end
|
40
42
|
gui_name = @parent.name
|
41
|
-
|
43
|
+
json_data = JSON.dump( gui_data )
|
44
|
+
msg.reply( "JSONRenderer.nu(#{json_data});", true )
|
42
45
|
end
|
43
46
|
|
44
47
|
# Use this method to extract all the value id's of the +ses+ hash.
|
@@ -111,4 +114,5 @@ private
|
|
111
114
|
end
|
112
115
|
|
113
116
|
end
|
114
|
-
|
117
|
+
end
|
118
|
+
end
|
data/lib/plugins/plugin.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
##
|
1
|
+
## RSence
|
2
2
|
# Copyright 2006 Riassence Inc.
|
3
3
|
# http://riassence.com/
|
4
4
|
#
|
@@ -298,355 +298,356 @@
|
|
298
298
|
## end
|
299
299
|
## SessionLogger.new.register( 'ses_logger' )
|
300
300
|
##
|
301
|
-
|
301
|
+
module ::RSence
|
302
|
+
module Plugins
|
303
|
+
class PluginTemplate
|
304
|
+
include PluginUtil
|
305
|
+
def self.bundle_type; :Plugin; end
|
302
306
|
|
303
|
-
|
307
|
+
# The +names+ is a list of (usually just one) names the plugin is registered under.
|
308
|
+
attr_reader :name, :path, :info, :inited
|
304
309
|
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
@plugins = @@plugin_manager
|
316
|
-
register unless @info[:inits_self]
|
317
|
-
end
|
318
|
-
|
319
|
-
# Extend this method to do any initial tasks before other methods are called.
|
320
|
-
# By default init_values is called to load the +values.yaml+ configuration file.
|
321
|
-
def init
|
322
|
-
@values = init_values
|
323
|
-
end
|
324
|
-
|
325
|
-
# Extend this method to do any tasks every time the client makes a request.
|
326
|
-
def idle( msg )
|
327
|
-
end
|
310
|
+
# The constructor should not take any parameters. In most cases, it's better
|
311
|
+
# to extend the +#init+ method, because it's called after the plugin is set up.
|
312
|
+
def initialize( bundle_name, bundle_info, bundle_path, plugin_manager )
|
313
|
+
@inited = false
|
314
|
+
@info = bundle_info
|
315
|
+
@name = bundle_name
|
316
|
+
@path = bundle_path
|
317
|
+
@plugins = plugin_manager
|
318
|
+
register unless @info[:inits_self]
|
319
|
+
end
|
328
320
|
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
end
|
321
|
+
# Extend this method to do any initial tasks before other methods are called.
|
322
|
+
# By default init_values is called to load the +values.yaml+ configuration file.
|
323
|
+
def init
|
324
|
+
@values = init_values
|
325
|
+
end
|
335
326
|
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
def restore_ses( msg )
|
340
|
-
restore_ses_values( msg )
|
341
|
-
end
|
327
|
+
# Extend this method to do any tasks every time the client makes a request.
|
328
|
+
def idle( msg )
|
329
|
+
end
|
342
330
|
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
#
|
350
|
-
# The +source_ses+ is the actual previous session object, which
|
351
|
-
# was used as the source of the clone.
|
352
|
-
def cloned_target( msg, source_session )
|
353
|
-
end
|
331
|
+
# Extend this method to invoke actions, when a new session is created.
|
332
|
+
# By default +#init_ses_values+ is called to initialize values defined in the
|
333
|
+
# +values.yaml+ configuration file.
|
334
|
+
def init_ses( msg )
|
335
|
+
init_ses_values( msg )
|
336
|
+
end
|
354
337
|
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
# window or tab, while the previous session is still active.
|
362
|
-
#
|
363
|
-
# The +target_ses+ is the actual cloned session object, which
|
364
|
-
# is a copy of the current session.
|
365
|
-
def cloned_source( msg, target_sessions )
|
366
|
-
end
|
338
|
+
# Extend this method to invoke actions, when a previous session is restored.
|
339
|
+
# By default +#restore_ses_values+ is called to perform actions on values as
|
340
|
+
# defined in the +values.yaml+ configuration file.
|
341
|
+
def restore_ses( msg )
|
342
|
+
restore_ses_values( msg )
|
343
|
+
end
|
367
344
|
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
else
|
379
|
-
name = @name
|
345
|
+
# Extend this method to invoke actions, when the session
|
346
|
+
# is a clone of another session. It's called once, just
|
347
|
+
# before +#restore_ses+ is called.
|
348
|
+
#
|
349
|
+
# A session is cloned, when a user opens a another browser
|
350
|
+
# window or tab, while the previous session is still active.
|
351
|
+
#
|
352
|
+
# The +source_ses+ is the actual previous session object, which
|
353
|
+
# was used as the source of the clone.
|
354
|
+
def cloned_target( msg, source_session )
|
380
355
|
end
|
381
|
-
@plugins.register_bundle( self, name )
|
382
|
-
@inited = true
|
383
|
-
end
|
384
|
-
end
|
385
356
|
|
386
|
-
|
357
|
+
# Extend this method to invoke actions, when the session
|
358
|
+
# has been cloned to another session. It's called once, just
|
359
|
+
# before +#restore_ses+ is called on the first request after
|
360
|
+
# the cloning happened.
|
361
|
+
#
|
362
|
+
# A session is cloned, when a user opens a another browser
|
363
|
+
# window or tab, while the previous session is still active.
|
364
|
+
#
|
365
|
+
# The +target_ses+ is the actual cloned session object, which
|
366
|
+
# is a copy of the current session.
|
367
|
+
def cloned_source( msg, target_sessions )
|
368
|
+
end
|
387
369
|
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
370
|
+
# This method must be called to register the plugin instance
|
371
|
+
# into the system. Otherwise, it's subject to destruction
|
372
|
+
# and garbage collection. Use the +name+ parameter to
|
373
|
+
# give the (unique) name of your plugin.
|
374
|
+
def register( name=false )
|
375
|
+
if @inited
|
376
|
+
@plugins.register_alias( @name, name )
|
377
|
+
else
|
378
|
+
if name
|
379
|
+
name = name.to_s
|
380
|
+
else
|
381
|
+
name = @name
|
382
|
+
end
|
383
|
+
@plugins.register_bundle( self, name )
|
384
|
+
@inited = true
|
385
|
+
end
|
386
|
+
end
|
398
387
|
|
399
|
-
|
400
|
-
# def name
|
401
|
-
# return @names.first
|
402
|
-
# end
|
388
|
+
private
|
403
389
|
|
390
|
+
# This method looks looks for a file called "values.yaml"
|
391
|
+
# in the plugin's bundle directory
|
392
|
+
#.
|
393
|
+
# If this file is found, it loads it for initial value definitions.
|
394
|
+
#
|
395
|
+
# These definitions are accessible as the +@values+ attribute.
|
396
|
+
def init_values
|
397
|
+
values_path = compose_plugin_path( 'values.yaml' )
|
398
|
+
return yaml_read( values_path )
|
399
|
+
end
|
404
400
|
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
name_sym = name.to_sym
|
410
|
-
unless msg.session.has_key?( name_sym )
|
411
|
-
msg.session[ name_sym ] = {}
|
412
|
-
end
|
413
|
-
return msg.session[ name_sym ]
|
414
|
-
end
|
401
|
+
# Returns all the names your plugin respond to.
|
402
|
+
# def name
|
403
|
+
# return @names.first
|
404
|
+
# end
|
415
405
|
|
416
|
-
# Returns the source code of the javascript file +name+ in the 'js'
|
417
|
-
# subdirectory of the plugin bundle.
|
418
|
-
def read_js( js_name )
|
419
|
-
file_read( compose_plugin_path( js_name, 'js', '.js' ) )
|
420
|
-
end
|
421
406
|
|
422
|
-
|
423
|
-
|
407
|
+
# Returns or creates a new session hash for the plugin.
|
408
|
+
#
|
409
|
+
# Uses the first name registered for the plugin and converts it to a symbol.
|
410
|
+
def get_ses( msg )
|
411
|
+
name_sym = name.to_sym
|
412
|
+
unless msg.session.has_key?( name_sym )
|
413
|
+
msg.session[ name_sym ] = {}
|
414
|
+
end
|
415
|
+
return msg.session[ name_sym ]
|
416
|
+
end
|
424
417
|
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
# Returns false otherwise.
|
431
|
-
def read_js_once( msg, js_name )
|
432
|
-
ses = msg.session
|
433
|
-
if not ses.has_key?(:deps)
|
434
|
-
ses[:deps] = []
|
435
|
-
end
|
436
|
-
path = compose_plugin_path( js_name, 'js', '.js' )
|
437
|
-
unless ses[:deps].include?( path )
|
438
|
-
ses[:deps].push( path )
|
439
|
-
return file_read( path )
|
440
|
-
else
|
441
|
-
return ''
|
442
|
-
end
|
443
|
-
end
|
418
|
+
# Returns the source code of the javascript file +name+ in the 'js'
|
419
|
+
# subdirectory of the plugin bundle.
|
420
|
+
def read_js( js_name )
|
421
|
+
file_read( compose_plugin_path( js_name, 'js', '.js' ) )
|
422
|
+
end
|
444
423
|
|
445
|
-
|
446
|
-
|
424
|
+
# Deprecated name of +#read_js+
|
425
|
+
alias require_js read_js
|
447
426
|
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
#
|
459
|
-
# {
|
460
|
-
# # Default value; defaults to 0
|
461
|
-
# :value => 'foo',
|
462
|
-
#
|
463
|
-
# # A plugin method to call to define the default value instead of the one defined in :value
|
464
|
-
# :value_call => {
|
465
|
-
# :plugin => 'plugin_name', # defaults to the plugin where defined
|
466
|
-
# :method => 'method_name', # mandatory; name of the method to call
|
467
|
-
# :args => [ 1, 'foo', 3 ], # optional, list of parameter values for the :method
|
468
|
-
# :uses_msg => true # defaults to true; when false, doesn't pass the msg as the first parameter
|
469
|
-
# },
|
470
|
-
#
|
471
|
-
# # Restore the default, when the session is restored; defaults to false
|
472
|
-
# :restore_default => false,
|
473
|
-
#
|
474
|
-
# # List of value responder methods to bind.
|
475
|
-
# :responders => [
|
476
|
-
# {
|
477
|
-
# :plugin => 'plugin_name', # defaults to the plugin where defined
|
478
|
-
# :method => 'method_name' # mandatory, name of the method to call
|
479
|
-
# },
|
480
|
-
# # You can supply as many responders as you like:
|
481
|
-
# { :plugin => 'another_plugin', :method => 'another_method' }
|
482
|
-
# ]
|
483
|
-
# }
|
484
|
-
#
|
485
|
-
def init_ses_value( msg, value_name, value_properties )
|
486
|
-
ses = get_ses( msg )
|
487
|
-
if value_properties.has_key?(:value_call)
|
488
|
-
default_value = init_value_call( msg, value_properties[:value_call] )
|
489
|
-
elsif value_properties.has_key?(:value)
|
490
|
-
default_value = value_properties[:value]
|
491
|
-
else
|
492
|
-
default_value = 0
|
493
|
-
end
|
494
|
-
ses[value_name] = HValue.new( msg, default_value )
|
495
|
-
if value_properties.has_key?(:responders)
|
496
|
-
value_properties[:responders].each do |responder|
|
497
|
-
if responder.has_key?(:plugin)
|
498
|
-
responder_plugin = responder[:plugin]
|
499
|
-
else
|
500
|
-
responder_plugin = @name
|
427
|
+
# Like +#read_js+, but reads the file only once per session.
|
428
|
+
#
|
429
|
+
# Returns the contents of the file on the first call,
|
430
|
+
# an empty string on the subsequent calls.
|
431
|
+
#
|
432
|
+
# Returns false otherwise.
|
433
|
+
def read_js_once( msg, js_name )
|
434
|
+
ses = msg.session
|
435
|
+
if not ses.has_key?(:deps)
|
436
|
+
ses[:deps] = []
|
501
437
|
end
|
502
|
-
|
503
|
-
|
438
|
+
path = compose_plugin_path( js_name, 'js', '.js' )
|
439
|
+
unless ses[:deps].include?( path )
|
440
|
+
ses[:deps].push( path )
|
441
|
+
return file_read( path )
|
442
|
+
else
|
443
|
+
return ''
|
504
444
|
end
|
505
445
|
end
|
506
|
-
end
|
507
|
-
end
|
508
446
|
|
509
|
-
|
510
|
-
|
511
|
-
def init_ses_values( msg )
|
512
|
-
return unless @values
|
513
|
-
@values.each do | value_name, value_properties |
|
514
|
-
init_ses_value( msg, value_name, value_properties )
|
515
|
-
end
|
516
|
-
end
|
447
|
+
# Deprecated name of +#read_js_once+
|
448
|
+
alias require_js_once read_js_once
|
517
449
|
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
450
|
+
# Creates a new instance of HValue, assigns it as +value_name+ into the
|
451
|
+
# session and uses the +value_properties+ Hash to define the default
|
452
|
+
# value and value responders.
|
453
|
+
#
|
454
|
+
# This method is invoked automatically, when handling the properties
|
455
|
+
# of the +values.yaml+ configuration file of a new session.
|
456
|
+
#
|
457
|
+
# It's invoked by +#init_ses+ via +#init_ses_values+.
|
458
|
+
#
|
459
|
+
# Structure of +value_properties+, all top-level items are optional:
|
460
|
+
#
|
461
|
+
# {
|
462
|
+
# # Default value; defaults to 0
|
463
|
+
# :value => 'foo',
|
464
|
+
#
|
465
|
+
# # A plugin method to call to define the default value instead of the one defined in :value
|
466
|
+
# :value_call => {
|
467
|
+
# :plugin => 'plugin_name', # defaults to the plugin where defined
|
468
|
+
# :method => 'method_name', # mandatory; name of the method to call
|
469
|
+
# :args => [ 1, 'foo', 3 ], # optional, list of parameter values for the :method
|
470
|
+
# :uses_msg => true # defaults to true; when false, doesn't pass the msg as the first parameter
|
471
|
+
# },
|
472
|
+
#
|
473
|
+
# # Restore the default, when the session is restored; defaults to false
|
474
|
+
# :restore_default => false,
|
475
|
+
#
|
476
|
+
# # List of value responder methods to bind.
|
477
|
+
# :responders => [
|
478
|
+
# {
|
479
|
+
# :plugin => 'plugin_name', # defaults to the plugin where defined
|
480
|
+
# :method => 'method_name' # mandatory, name of the method to call
|
481
|
+
# },
|
482
|
+
# # You can supply as many responders as you like:
|
483
|
+
# { :plugin => 'another_plugin', :method => 'another_method' }
|
484
|
+
# ]
|
485
|
+
# }
|
486
|
+
#
|
487
|
+
def init_ses_value( msg, value_name, value_properties )
|
488
|
+
ses = get_ses( msg )
|
489
|
+
if value_properties.has_key?(:value_call)
|
490
|
+
default_value = init_value_call( msg, value_properties[:value_call] )
|
491
|
+
elsif value_properties.has_key?(:value)
|
492
|
+
default_value = value_properties[:value]
|
543
493
|
else
|
544
|
-
|
494
|
+
default_value = 0
|
545
495
|
end
|
546
|
-
|
547
|
-
if
|
548
|
-
|
549
|
-
|
550
|
-
|
496
|
+
ses[value_name] = HValue.new( msg, default_value, { :name => "#{@name}.#{value_name}" } )
|
497
|
+
if value_properties.has_key?(:responders)
|
498
|
+
value_properties[:responders].each do |responder|
|
499
|
+
if responder.has_key?(:plugin)
|
500
|
+
responder_plugin = responder[:plugin]
|
501
|
+
else
|
502
|
+
responder_plugin = @name
|
503
|
+
end
|
504
|
+
if responder.has_key?(:method)
|
505
|
+
ses[value_name].bind( responder_plugin, responder[:method] )
|
506
|
+
end
|
507
|
+
end
|
508
|
+
end
|
509
|
+
end
|
510
|
+
|
511
|
+
# Initializes session values, if the contents of the +values.yaml+
|
512
|
+
# file is defined in the bundle directory and loaded in +#init_values+.
|
513
|
+
def init_ses_values( msg )
|
514
|
+
return unless @values
|
515
|
+
@values.each do | value_name, value_properties |
|
516
|
+
init_ses_value( msg, value_name, value_properties )
|
551
517
|
end
|
552
518
|
end
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
519
|
+
|
520
|
+
# Returns a value based on the :method and :plugin members of the
|
521
|
+
# +value_call+ hash.
|
522
|
+
#
|
523
|
+
# The call is made via msg.run if the method is not defined in
|
524
|
+
# the local plugin bundle.
|
525
|
+
#
|
526
|
+
# This method is called from +#init_ses_value+.
|
527
|
+
#
|
528
|
+
# Structure of the +value_call+ Hash:
|
529
|
+
# { :plugin => 'plugin_name', # defaults to the plugin where defined
|
530
|
+
# :method => 'method_name', # mandatory; name of the method to call
|
531
|
+
# :args => [ 1, 'foo', 3 ], # optional, list of parameter values for the :method
|
532
|
+
# :uses_msg => true # defaults to true; when false, doesn't pass the msg as the first parameter
|
533
|
+
# }
|
534
|
+
def init_value_call( msg, value_call )
|
535
|
+
value_call_method = value_call[:method]
|
536
|
+
if value_call.has_key?(:plugin)
|
537
|
+
value_call_plugin = value_call[:plugin]
|
557
538
|
else
|
558
|
-
|
539
|
+
value_call_plugin = false
|
559
540
|
end
|
560
|
-
|
561
|
-
|
562
|
-
|
541
|
+
if value_call.has_key?(:args)
|
542
|
+
if value_call.has_key?(:uses_msg) and value_call[:uses_msg] != false
|
543
|
+
if value_call_plugin
|
544
|
+
return msg.run( value_call_plugin, value_call_method, msg, *value_call[:args] )
|
545
|
+
else
|
546
|
+
return self.method( value_call_method ).call( msg, *value_call[:args] )
|
547
|
+
end
|
548
|
+
else
|
549
|
+
if value_call_plugin
|
550
|
+
return msg.run( value_call_plugin, value_call_method, *value_call[:args] )
|
551
|
+
else
|
552
|
+
return self.method( value_call_method ).call( *value_call[:args] )
|
553
|
+
end
|
554
|
+
end
|
563
555
|
else
|
564
|
-
|
556
|
+
if value_call.has_key?(:uses_msg) and value_call[:uses_msg] != false
|
557
|
+
if value_call_plugin
|
558
|
+
return msg.run( value_call_plugin, value_call_method, msg )
|
559
|
+
else
|
560
|
+
return self.method( value_call_method ).call( msg )
|
561
|
+
end
|
562
|
+
else
|
563
|
+
if value_call_plugin
|
564
|
+
return msg.run( value_call_plugin, value_call_method )
|
565
|
+
else
|
566
|
+
return self.method( value_call_method ).call( )
|
567
|
+
end
|
568
|
+
end
|
565
569
|
end
|
566
570
|
end
|
567
|
-
end
|
568
|
-
end
|
569
571
|
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
572
|
+
# Restores session values to default, unless specified otherwise.
|
573
|
+
#
|
574
|
+
# Called from +#restore_ses+
|
575
|
+
def restore_ses_values( msg )
|
576
|
+
return unless @values
|
577
|
+
ses = get_ses( msg )
|
578
|
+
@values.each do | value_name, value_properties |
|
579
|
+
if ses.has_key?( value_name ) and ses[ value_name ].class == HValue
|
580
|
+
unless value_properties[:restore_default] == false
|
581
|
+
if value_properties.has_key?(:value_call)
|
582
|
+
default_value = init_value_call( msg, value_properties[:value_call] )
|
583
|
+
elsif value_properties.has_key?(:value)
|
584
|
+
default_value = value_properties[:value]
|
585
|
+
else
|
586
|
+
default_value = 0
|
587
|
+
end
|
588
|
+
ses[value_name].set( msg, default_value )
|
589
|
+
end
|
583
590
|
else
|
584
|
-
|
591
|
+
init_ses_value( msg, value_name, value_properties )
|
585
592
|
end
|
586
|
-
ses[value_name].set( msg, default_value )
|
587
593
|
end
|
588
|
-
else
|
589
|
-
init_ses_value( msg, value_name, value_properties )
|
590
594
|
end
|
591
|
-
end
|
592
|
-
end
|
593
595
|
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
596
|
+
# Extracts +HValue+ references as javascript from the session Hash.
|
597
|
+
# The +ses+ parameter is used for supplying a hash with the +HValue+
|
598
|
+
# instances. It's optional and defaults to the current plugin node in
|
599
|
+
# the active session.
|
600
|
+
#
|
601
|
+
# The return value is a string representing a js object similar to
|
602
|
+
# the ruby Hash +ses+.
|
603
|
+
#
|
604
|
+
# Sample usage:
|
605
|
+
#
|
606
|
+
# values_js( msg, msg.session[:main] )
|
607
|
+
#
|
608
|
+
def values_js( msg, ses=false )
|
609
|
+
# backwards-compatible with pre-1.3 behaviour
|
610
|
+
ses = msg if msg.class == Hash
|
611
|
+
# gets the session automatically, if false
|
612
|
+
ses = get_ses( msg ) unless ses
|
613
|
+
js_references = []
|
614
|
+
ses.each_key do |key_name|
|
615
|
+
if ses[key_name].class == HValue
|
616
|
+
js_references.push( "#{key_name.to_s}:HVM.values['#{ses[key_name].val_id}']" )
|
617
|
+
end
|
618
|
+
end
|
619
|
+
return "{#{js_references.join(',')}}"
|
615
620
|
end
|
616
|
-
end
|
617
|
-
return "{#{js_references.join(',')}}"
|
618
|
-
end
|
619
621
|
|
620
|
-
|
621
|
-
|
622
|
+
# Deprecated name of +#values_js+
|
623
|
+
alias extract_hvalues_from_hash values_js
|
622
624
|
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
625
|
+
# Tells the js client framework to load a list of dependency packages.
|
626
|
+
# It keeps track of what's loaded, so nothing library loaded twice.
|
627
|
+
#
|
628
|
+
# The +dependencies+ parameter is an Array of dependencies.
|
629
|
+
#
|
630
|
+
# Sample usage:
|
631
|
+
#
|
632
|
+
# include_js( msg, [ 'default_theme', 'controls', 'lists', 'datetime' ] )
|
633
|
+
#
|
634
|
+
def include_js( msg, dependencies=[] )
|
635
|
+
ses = msg.session
|
636
|
+
# check, if the session has a dependency array
|
637
|
+
if not ses.has_key?( :deps )
|
638
|
+
# make an array of dependencies for this session, if not already done
|
639
|
+
ses[:deps] = []
|
640
|
+
end
|
641
|
+
dependencies = [dependencies] if dependencies.class == String
|
642
|
+
# Check the required dependencies until everything is loaded.
|
643
|
+
dependencies.each do |dependency|
|
644
|
+
unless ses[:deps].include?( dependency )
|
645
|
+
ses[:deps].push( dependency )
|
646
|
+
msg.reply(%{jsLoader.load("#{dependency}");})
|
647
|
+
end
|
648
|
+
end
|
645
649
|
end
|
646
650
|
end
|
647
651
|
end
|
648
|
-
|
649
|
-
|
650
652
|
end
|
651
653
|
|
652
|
-
|