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.
Files changed (121) hide show
  1. data/README.rdoc +2 -2
  2. data/VERSION +1 -1
  3. data/bin/rsence +4 -1
  4. data/conf/default_conf.yaml +1 -1
  5. data/conf/rsence_command_strings.yaml +444 -0
  6. data/js/comm/comm/autosync/autosync.js +1 -1
  7. data/js/comm/comm/comm.js +1 -1
  8. data/js/comm/comm/queue/queue.js +1 -1
  9. data/js/comm/comm/session/session.js +1 -1
  10. data/js/comm/comm/sessionwatcher/sessionwatcher.js +1 -1
  11. data/js/comm/comm/transporter/transporter.js +1 -1
  12. data/js/comm/comm/urlresponder/urlresponder.js +1 -1
  13. data/js/comm/comm/values/values.js +1 -1
  14. data/js/comm/jsloader/jsloader.js +1 -1
  15. data/js/comm/reloadapp/reloadapp.js +1 -1
  16. data/js/comm/sha/sha.js +1 -1
  17. data/js/comm/values/value/value.js +1 -1
  18. data/js/comm/values/valuematrix/valuematrix.js +1 -1
  19. data/js/controls/button/button.js +1 -1
  20. data/js/controls/checkbox/checkbox.js +1 -1
  21. data/js/controls/datetime/calendar/calendar.js +1 -1
  22. data/js/controls/datetime/datetimevalue/datetimevalue.js +1 -1
  23. data/js/controls/datetime/timesheet/timesheet.js +1 -1
  24. data/js/controls/datetime/timesheet_item/timesheet_item.js +1 -1
  25. data/js/controls/datetime/timesheet_item_edit/timesheet_item_edit.js +1 -1
  26. data/js/controls/dialogs/alert_sheet/alert_sheet.js +1 -1
  27. data/js/controls/dialogs/confirm_sheet/confirm_sheet.js +1 -1
  28. data/js/controls/dialogs/sheet/sheet.js +1 -1
  29. data/js/controls/imageview/imageview.js +1 -1
  30. data/js/controls/lists/checkboxlist/checkboxlist.js +1 -1
  31. data/js/controls/lists/listitems/listitems.js +1 -1
  32. data/js/controls/lists/radiobuttonlist/radiobuttonlist.js +1 -1
  33. data/js/controls/passwordcontrol/passwordcontrol.js +1 -1
  34. data/js/controls/progress/progressbar/progressbar.js +1 -1
  35. data/js/controls/progress/progressindicator/progressindicator.js +1 -1
  36. data/js/controls/radiobutton/radiobutton.js +1 -1
  37. data/js/controls/sliders/slider/slider.js +1 -1
  38. data/js/controls/sliders/vslider/vslider.js +1 -1
  39. data/js/controls/stepper/stepper.js +1 -1
  40. data/js/controls/stringview/stringview.js +1 -1
  41. data/js/controls/tab/tab.js +1 -1
  42. data/js/controls/textarea/textarea.js +1 -1
  43. data/js/controls/textcontrol/textcontrol.js +1 -1
  44. data/js/controls/uploader/uploader.js +1 -1
  45. data/js/controls/validatorview/validatorview.js +6 -2
  46. data/js/controls/window/window.js +1 -1
  47. data/js/core/class/class.js +1 -1
  48. data/js/core/elem/elem.js +1 -1
  49. data/js/core/event/event.js +1 -1
  50. data/js/core/iefix/iefix.js +1 -1
  51. data/js/foundation/application/application.js +1 -1
  52. data/js/foundation/control/control.js +1 -1
  53. data/js/foundation/control/controldefaults/controldefaults.js +1 -1
  54. data/js/foundation/control/dummyvalue/dummyvalue.js +1 -1
  55. data/js/foundation/control/dyncontrol/dyncontrol.js +1 -1
  56. data/js/foundation/control/eventresponder/eventresponder.js +1 -1
  57. data/js/foundation/control/valueresponder/valueresponder.js +1 -1
  58. data/js/foundation/geom/point/point.js +1 -1
  59. data/js/foundation/geom/rect/rect.js +1 -1
  60. data/js/foundation/json_renderer/json_renderer.js +1 -1
  61. data/js/foundation/system/system.js +1 -1
  62. data/js/foundation/thememanager/thememanager.js +1 -1
  63. data/js/foundation/view/markupview/markupview.js +1 -1
  64. data/js/foundation/view/morphanimation/morphanimation.js +1 -1
  65. data/js/foundation/view/view.js +1 -1
  66. data/js/foundation/view/viewdefaults/viewdefaults.js +1 -1
  67. data/js/views/centerview/centerview.js +1 -1
  68. data/js/views/inlineview/inlineview.js +1 -1
  69. data/js/views/scrollview/scrollview.js +1 -1
  70. data/lib/conf/argv.rb +719 -1006
  71. data/lib/conf/default.rb +14 -3
  72. data/lib/daemon/daemon.rb +1 -1
  73. data/lib/daemon/sigcomm.rb +1 -1
  74. data/lib/http/broker.rb +5 -1
  75. data/lib/http/rackup.rb +1 -1
  76. data/lib/http/request.rb +1 -1
  77. data/lib/http/response.rb +2 -2
  78. data/lib/plugins/dependencies.rb +36 -0
  79. data/lib/plugins/gui_plugin.rb +83 -80
  80. data/lib/plugins/guiparser.rb +7 -3
  81. data/lib/plugins/plugin.rb +308 -307
  82. data/lib/plugins/plugin_plugins.rb +5 -1
  83. data/lib/plugins/plugin_sqlite_db.rb +5 -1
  84. data/lib/plugins/plugin_util.rb +22 -0
  85. data/lib/plugins/pluginmanager.rb +95 -95
  86. data/lib/plugins/plugins.rb +117 -0
  87. data/lib/plugins/servlet.rb +47 -57
  88. data/lib/session/msg.rb +1 -1
  89. data/lib/session/sessionmanager.rb +1 -1
  90. data/lib/session/sessionstorage.rb +2 -2
  91. data/lib/transporter/transporter.rb +1 -2
  92. data/lib/values/hvalue.rb +7 -3
  93. data/lib/values/valuemanager.rb +7 -1
  94. data/plugins/client_pkg/client_pkg.rb +15 -48
  95. data/plugins/client_pkg/info.yaml +1 -1
  96. data/plugins/client_pkg/lib/client_pkg_build.rb +1 -1
  97. data/plugins/client_pkg/lib/client_pkg_cache.rb +1 -1
  98. data/plugins/index_html/index_html.rb +5 -6
  99. data/plugins/index_html/info.yaml +21 -0
  100. data/plugins/index_html/tmpl/index.html +1 -1
  101. data/plugins/index_html/tmpl/startup_index.html +1 -1
  102. data/plugins/main/info.yaml +21 -0
  103. data/plugins/main/main.rb +1 -5
  104. data/plugins/{ticketservices → ticket}/lib/common.rb +92 -2
  105. data/plugins/{ticketservices → ticket}/lib/favicon.rb +1 -1
  106. data/plugins/{ticketservices → ticket}/lib/file.rb +1 -1
  107. data/plugins/{ticketservices → ticket}/lib/img.rb +1 -1
  108. data/plugins/{ticketservices → ticket}/lib/objblob.rb +1 -1
  109. data/plugins/{ticketservices → ticket}/lib/rsrc.rb +1 -1
  110. data/plugins/{ticketservices → ticket}/lib/upload.rb +60 -31
  111. data/plugins/{ticketservices/ticketservices.rb → ticket/ticket.rb} +50 -118
  112. data/{plugins → setup}/legacy/info.yaml +0 -0
  113. data/{plugins → setup}/legacy/legacy.rb +2 -0
  114. data/setup/welcome/welcome.rb +1 -1
  115. metadata +27 -21
  116. data/conf/config.yaml +0 -4
  117. data/conf/local_conf.yaml.devel +0 -14
  118. data/lib/conf/wizard.rb +0 -303
  119. data/plugins/client_pkg/log/build_log +0 -0
  120. data/plugins/legacy/disabled +0 -0
  121. data/plugins/legacy/disabled- +0 -0
data/lib/conf/default.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  #--
2
- ## Riassence Framework
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::ASCII_8BIT
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
@@ -1,5 +1,5 @@
1
1
  #--
2
- ## Riassence Framework
2
+ ## RSence
3
3
  # Copyright 2008 Riassence Inc.
4
4
  # http://riassence.com/
5
5
  #
@@ -1,5 +1,5 @@
1
1
  #--
2
- ## Riassence Framework
2
+ ## RSence
3
3
  # Copyright 2010 Riassence Inc.
4
4
  # http://riassence.com/
5
5
  #
data/lib/http/broker.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  #--
2
- ## Riassence Framework
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
@@ -1,5 +1,5 @@
1
1
  #--
2
- ## Riassence Framework
2
+ ## RSence
3
3
  # Copyright 2008 Riassence Inc.
4
4
  # http://riassence.com/
5
5
  #
data/lib/http/request.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  #--
2
- ## Riassence Framework
2
+ ## RSence
3
3
  # Copyright 2008 Riassence Inc.
4
4
  # http://riassence.com/
5
5
  #
data/lib/http/response.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  #--
2
- ## Riassence Framework
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' => 'Riassence Framework'
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
+
@@ -1,4 +1,4 @@
1
- ## Riassence Framework
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
- class GUIPlugin < Plugin
29
+ module ::RSence
30
+ module Plugins
31
+ class GUIPluginTemplate < PluginTemplate
32
+ def self.bundle_type; :GUIPlugin; end
30
33
 
31
- @@default_yaml_src = %{
34
+ @@default_yaml_src = <<-END
32
35
  type: GUITree
33
- version: 0.5
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
- # Automatically initializes an GUIParser instance as @gui
41
- def init
42
- super
43
- yaml_src = file_read( "gui/#{@name}.yaml" )
44
- yaml_src = file_read( "gui/main.yaml" ) unless yaml_src
45
- yaml_src = @@default_yaml_src unless yaml_src
46
- @gui = GUIParser.new( self, yaml_src )
47
- @client_pkgs = false
48
- end
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
- # Extend this method to return custom params to GUIParser#init.
51
- # Called from init_ui.
52
- # By default assigns the session values as :values to use for
53
- # valueObjId: ":values.my_value_name" in the YAML GUI file.
54
- def gui_params( msg )
55
- return {
56
- :values => @gui.values( get_ses( msg ) )
57
- }
58
- end
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
- def install_client_pkgs
61
- if @client_pkgs
62
- warn "install_client_pkgs: called with @client_pkgs defined; returning"
63
- return
64
- end
65
- @client_pkgs = yaml_read( 'client_pkgs.yaml' )
66
- if @client_pkgs
67
- if @client_pkgs.has_key?(:src_dirs)
68
- @client_pkgs[:src_dirs].each do |src_dir|
69
- src_dir = bundle_path( src_dir[2..-1] ) if src_dir.start_with?('./')
70
- @plugins.client_pkg.add_src_dir( src_dir )
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
- def uninstall_client_pkgs
82
- if not @client_pkgs
83
- warn "uninstall_client_pkgs: called without @client_pkgs defined"
84
- else
85
- if @client_pkgs.has_key?(:src_dirs)
86
- @client_pkgs[:src_dirs].each do |src_dir|
87
- src_dir = bundle_path( src_dir[2..-1] ) if src_dir.start_with?('./')
88
- @plugins.client_pkg.del_src_dir( src_dir )
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
- def open
101
- super
102
- install_client_pkgs if File.exist? bundle_path( 'client_pkgs.yaml' )
103
- end
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
- # Sends gui specification to the main plugin
111
- def spec_ui( msg )
112
- # TODO
113
- end
109
+ def close
110
+ super
111
+ uninstall_client_pkgs if @client_pkgs
112
+ end
114
113
 
115
- # Automatically inits the UI using GUIParser#init.
116
- # Passes on the return value of gui_params.
117
- def init_ui( msg ); @gui.init( msg, gui_params( msg ) ); end
114
+ # Sends gui specification to the main plugin
115
+ def spec_ui( msg )
116
+ # TODO
117
+ end
118
118
 
119
- # Automatically kills the UI using GUIParser#kill
120
- def kill_ui( msg ); @gui.kill( msg ); end
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
- # Makes include_js public to enable calls to it from GUIParser
123
- public :include_js, :read_js_once
123
+ # Automatically kills the UI using GUIParser#kill
124
+ def kill_ui( msg ); @gui.kill( msg ); end
124
125
 
125
- attr_reader :plugins
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
-
@@ -1,4 +1,4 @@
1
- ## Riassence Framework
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
- msg.reply( "JSONRenderer.nu(#{gui_data.to_json});", true )
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
@@ -1,4 +1,4 @@
1
- ## Riassence Framework
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
- class Plugin
301
+ module ::RSence
302
+ module Plugins
303
+ class PluginTemplate
304
+ include PluginUtil
305
+ def self.bundle_type; :Plugin; end
302
306
 
303
- include PluginUtil
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
- # The +names+ is a list of (usually just one) names the plugin is registered under.
306
- attr_reader :name, :path, :info, :inited
307
-
308
- # The constructor should not take any parameters. In most cases, it's better
309
- # to extend the +#init+ method, because it's called after the plugin is set up.
310
- def initialize
311
- @inited = false
312
- @info = @@bundle_info
313
- @name = @@bundle_name
314
- @path = @@bundle_path
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
- # Extend this method to invoke actions, when a new session is created.
330
- # By default +#init_ses_values+ is called to initialize values defined in the
331
- # +values.yaml+ configuration file.
332
- def init_ses( msg )
333
- init_ses_values( msg )
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
- # Extend this method to invoke actions, when a previous session is restored.
337
- # By default +#restore_ses_values+ is called to perform actions on values as
338
- # defined in the +values.yaml+ configuration file.
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
- # Extend this method to invoke actions, when the session
344
- # is a clone of another session. It's called once, just
345
- # before +#restore_ses+ is called.
346
- #
347
- # A session is cloned, when a user opens a another browser
348
- # window or tab, while the previous session is still active.
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
- # Extend this method to invoke actions, when the session
356
- # has been cloned to another session. It's called once, just
357
- # before +#restore_ses+ is called on the first request after
358
- # the cloning happened.
359
- #
360
- # A session is cloned, when a user opens a another browser
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
- # This method must be called to register the plugin instance
369
- # into the system. Otherwise, it's subject to destruction
370
- # and garbage collection. Use the +name+ parameter to
371
- # give the (unique) name of your plugin.
372
- def register( name=false )
373
- if @inited
374
- @plugins.register_alias( @name, name )
375
- else
376
- if name
377
- name = name.to_s
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
- private
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
- # This method looks looks for a file called "values.yaml"
389
- # in the plugin's bundle directory
390
- #.
391
- # If this file is found, it loads it for initial value definitions.
392
- #
393
- # These definitions are accessible as the +@values+ attribute.
394
- def init_values
395
- values_path = compose_plugin_path( 'values.yaml' )
396
- return yaml_read( values_path )
397
- end
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
- # Returns all the names your plugin respond to.
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
- # Returns or creates a new session hash for the plugin.
406
- #
407
- # Uses the first name registered for the plugin and converts it to a symbol.
408
- def get_ses( msg )
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
- # Deprecated name of +#read_js+
423
- alias require_js read_js
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
- # Like +#read_js+, but reads the file only once per session.
426
- #
427
- # Returns the contents of the file on the first call,
428
- # an empty string on the subsequent calls.
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
- # Deprecated name of +#read_js_once+
446
- alias require_js_once read_js_once
424
+ # Deprecated name of +#read_js+
425
+ alias require_js read_js
447
426
 
448
- # Creates a new instance of HValue, assigns it as +value_name+ into the
449
- # session and uses the +value_properties+ Hash to define the default
450
- # value and value responders.
451
- #
452
- # This method is invoked automatically, when handling the properties
453
- # of the +values.yaml+ configuration file of a new session.
454
- #
455
- # It's invoked by +#init_ses+ via +#init_ses_values+.
456
- #
457
- # Structure of +value_properties+, all top-level items are optional:
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
- if responder.has_key?(:method)
503
- ses[value_name].bind( responder_plugin, responder[:method] )
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
- # Initializes session values, if the contents of the +values.yaml+
510
- # file is defined in the bundle directory and loaded in +#init_values+.
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
- # Returns a value based on the :method and :plugin members of the
519
- # +value_call+ hash.
520
- #
521
- # The call is made via msg.run if the method is not defined in
522
- # the local plugin bundle.
523
- #
524
- # This method is called from +#init_ses_value+.
525
- #
526
- # Structure of the +value_call+ Hash:
527
- # { :plugin => 'plugin_name', # defaults to the plugin where defined
528
- # :method => 'method_name', # mandatory; name of the method to call
529
- # :args => [ 1, 'foo', 3 ], # optional, list of parameter values for the :method
530
- # :uses_msg => true # defaults to true; when false, doesn't pass the msg as the first parameter
531
- # }
532
- def init_value_call( msg, value_call )
533
- value_call_method = value_call[:method]
534
- if value_call.has_key?(:plugin)
535
- value_call_plugin = value_call[:plugin]
536
- else
537
- value_call_plugin = false
538
- end
539
- if value_call.has_key?(:args)
540
- if value_call.has_key?(:uses_msg) and value_call[:uses_msg] != false
541
- if value_call_plugin
542
- return msg.run( value_call_plugin, value_call_method, msg, *value_call[:args] )
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
- return self.method( value_call_method ).call( msg, *value_call[:args] )
494
+ default_value = 0
545
495
  end
546
- else
547
- if value_call_plugin
548
- return msg.run( value_call_plugin, value_call_method, *value_call[:args] )
549
- else
550
- return self.method( value_call_method ).call( *value_call[:args] )
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
- else
554
- if value_call.has_key?(:uses_msg) and value_call[:uses_msg] != false
555
- if value_call_plugin
556
- return msg.run( value_call_plugin, value_call_method, msg )
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
- return self.method( value_call_method ).call( msg )
539
+ value_call_plugin = false
559
540
  end
560
- else
561
- if value_call_plugin
562
- return msg.run( value_call_plugin, value_call_method )
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
- return self.method( value_call_method ).call( )
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
- # Restores session values to default, unless specified otherwise.
571
- #
572
- # Called from +#restore_ses+
573
- def restore_ses_values( msg )
574
- return unless @values
575
- ses = get_ses( msg )
576
- @values.each do | value_name, value_properties |
577
- if ses.has_key?( value_name ) and ses[ value_name ].class == HValue
578
- unless value_properties[:restore_default] == false
579
- if value_properties.has_key?(:value_call)
580
- default_value = init_value_call( msg, value_properties[:value_call] )
581
- elsif value_properties.has_key?(:value)
582
- default_value = value_properties[:value]
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
- default_value = 0
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
- # Extracts +HValue+ references as javascript from the session Hash.
595
- # The +ses+ parameter is used for supplying a hash with the +HValue+
596
- # instances. It's optional and defaults to the current plugin node in
597
- # the active session.
598
- #
599
- # The return value is a string representing a js object similar to
600
- # the ruby Hash +ses+.
601
- #
602
- # Sample usage:
603
- #
604
- # values_js( msg, msg.session[:main] )
605
- #
606
- def values_js( msg, ses=false )
607
- # backwards-compatible with pre-1.3 behaviour
608
- ses = msg if msg.class == Hash
609
- # gets the session automatically, if false
610
- ses = get_ses( msg ) unless ses
611
- js_references = []
612
- ses.each_key do |key_name|
613
- if ses[key_name].class == HValue
614
- js_references.push( "#{key_name.to_s}:HVM.values['#{ses[key_name].val_id}']" )
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
- # Deprecated name of +#values_js+
621
- alias extract_hvalues_from_hash values_js
622
+ # Deprecated name of +#values_js+
623
+ alias extract_hvalues_from_hash values_js
622
624
 
623
- # Tells the js client framework to load a list of dependency packages.
624
- # It keeps track of what's loaded, so nothing library loaded twice.
625
- #
626
- # The +dependencies+ parameter is an Array of dependencies.
627
- #
628
- # Sample usage:
629
- #
630
- # include_js( msg, [ 'default_theme', 'controls', 'lists', 'datetime' ] )
631
- #
632
- def include_js( msg, dependencies=[] )
633
- ses = msg.session
634
- # check, if the session has a dependency array
635
- if not ses.has_key?( :deps )
636
- # make an array of dependencies for this session, if not already done
637
- ses[:deps] = []
638
- end
639
- dependencies = [dependencies] if dependencies.class == String
640
- # Check the required dependencies until everything is loaded.
641
- dependencies.each do |dependency|
642
- unless ses[:deps].include?( dependency )
643
- ses[:deps].push( dependency )
644
- msg.reply(%{jsLoader.load("#{dependency}");})
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
-