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
@@ -12,10 +12,15 @@
|
|
12
12
|
// centered inside its parent by adjusting its "left" style property.
|
13
13
|
// Designed to be used as a root-level view, listens to the resize event and
|
14
14
|
// re-calculates the center position accordingly. Likely to evolve a lot still.
|
15
|
+
var//RSence.Views
|
15
16
|
HCenterView = HControl.extend({
|
16
17
|
defaultEvents: {
|
17
18
|
resize: true
|
18
19
|
},
|
20
|
+
controlDefaults: HControlDefaults.extend({
|
21
|
+
centerX: true,
|
22
|
+
centerY: false
|
23
|
+
}),
|
19
24
|
drawRect: function(_selfCalled){
|
20
25
|
this.base();
|
21
26
|
if(!_selfCalled){
|
@@ -23,10 +28,14 @@ HCenterView = HControl.extend({
|
|
23
28
|
}
|
24
29
|
},
|
25
30
|
minLeft: false,
|
31
|
+
minTop: false,
|
26
32
|
resize: function(){
|
27
33
|
if(this.minLeft === false){
|
28
34
|
this.minLeft = this.rect.left;
|
29
35
|
}
|
36
|
+
if(this.minTop === false){
|
37
|
+
this.minTop = this.rect.top;
|
38
|
+
}
|
30
39
|
var
|
31
40
|
_rect = this.rect,
|
32
41
|
_winSize = ELEM.windowSize(),
|
@@ -35,11 +44,32 @@ HCenterView = HControl.extend({
|
|
35
44
|
_rectWidth = _rect.width,
|
36
45
|
_rectWidthHalf = Math.floor(_rectWidth/2),
|
37
46
|
_winWidthHalf = Math.floor(_winWidth/2),
|
38
|
-
_left = _winWidthHalf - _rectWidthHalf
|
39
|
-
|
47
|
+
_left = _winWidthHalf - _rectWidthHalf,
|
48
|
+
_rectHeight = _rect.height,
|
49
|
+
_rectHeightHalf = Math.floor(_rectHeight/2),
|
50
|
+
_winHeightHalf = Math.floor(_winHeight/2),
|
51
|
+
_top = _winHeightHalf - _rectHeightHalf;
|
52
|
+
if (!this.options.centerX){
|
53
|
+
_left = _rect.left;
|
54
|
+
}
|
55
|
+
else if( _left < this.minLeft ){
|
40
56
|
_left = this.minLeft;
|
41
57
|
}
|
42
|
-
|
58
|
+
if (!this.options.centerY){
|
59
|
+
_top = _rect.top;
|
60
|
+
}
|
61
|
+
else if( _top < this.minTop ){
|
62
|
+
_top = this.minTop;
|
63
|
+
}
|
64
|
+
_rect.offsetTo( _left, _top );
|
43
65
|
this.drawRect(true);
|
44
66
|
}
|
45
67
|
});
|
68
|
+
|
69
|
+
var//RSence.Views
|
70
|
+
HMiddleView = HCenterView.extend({
|
71
|
+
controlDefaults: HControlDefaults.extend({
|
72
|
+
centerX: false,
|
73
|
+
centerY: true
|
74
|
+
})
|
75
|
+
});
|
data/lib/conf/argv.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
#--
|
2
1
|
## RSence
|
3
2
|
# Copyright 2010 Riassence Inc.
|
4
3
|
# http://riassence.com/
|
@@ -6,44 +5,37 @@
|
|
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
|
-
# --
|
12
9
|
# Includes the Signal Communication utility.
|
13
10
|
# Used to respond via special PID files in the run directory of the environment
|
14
|
-
# ++
|
15
11
|
require 'daemon/sigcomm'
|
16
12
|
|
17
|
-
|
18
|
-
# Creates the RSence module. RSence classes are defined within.
|
19
|
-
# ++
|
13
|
+
|
20
14
|
module RSence
|
21
15
|
|
22
|
-
# Returns true, if platform fully supports POSIX standard signals.
|
16
|
+
# @private Returns true, if platform fully supports POSIX standard signals.
|
23
17
|
def self.pid_support?
|
24
18
|
# true for non-windows
|
25
19
|
return (not ['i386-mingw32','x86-mingw32'].include?(RUBY_PLATFORM))
|
26
20
|
end
|
27
21
|
|
28
|
-
# ARGVParser is the "user interface" as a command-line argument parser.
|
29
|
-
#
|
22
|
+
# @private ARGVParser is the "user interface" as a command-line argument parser.
|
23
|
+
# It parses the command-line arguments and sets up things accordingly.
|
30
24
|
class ARGVParser
|
31
25
|
|
32
26
|
# The RSence version string, read from the VERSION file in
|
33
27
|
# the root directory of RSence.
|
34
28
|
@@version = File.read( File.join( SERVER_PATH, 'VERSION' ) ).strip
|
35
29
|
|
36
|
-
# --
|
37
30
|
# Makes various commands available depending on the platform.
|
38
31
|
# The status/start/stop/restart/save -commands depend on an operating
|
39
32
|
# system that fully implements POSIX standard signals.
|
40
33
|
# These are necessary to send signals to the background process.
|
41
|
-
|
42
|
-
|
34
|
+
if not RSence.pid_support?
|
35
|
+
@@cmds = [ :run, :initenv, :version, :help ]
|
36
|
+
else
|
43
37
|
@@cmds = [ :run, :status, :start, :stop, :restart, :save,
|
44
38
|
:initenv, :version, :help ]
|
45
|
-
else
|
46
|
-
@@cmds = [ :run, :initenv, :version, :help ]
|
47
39
|
end
|
48
40
|
|
49
41
|
help_avail_cmds = @@cmds.map{|cmd|cmd.to_s}.join("\n ")
|
@@ -531,7 +523,7 @@ module RSence
|
|
531
523
|
end
|
532
524
|
end
|
533
525
|
|
534
|
-
# asks y/n and returns
|
526
|
+
# asks y/n and returns booleans,
|
535
527
|
# the default tells if which one is for just enter
|
536
528
|
def yesno(default=false)
|
537
529
|
if default
|
@@ -798,27 +790,46 @@ module RSence
|
|
798
790
|
|
799
791
|
end
|
800
792
|
|
801
|
-
# This accessor enables RSence.argv method, which returns the ARGVParser instance
|
793
|
+
# @private This accessor enables RSence.argv method, which returns the ARGVParser instance
|
802
794
|
def self.argv; @@argv_parser; end
|
803
795
|
|
804
|
-
# This accessor enables RSence.cmd method, which returns the command the process was started with.
|
796
|
+
# @private This accessor enables RSence.cmd method, which returns the command the process was started with.
|
805
797
|
def self.cmd; @@argv_parser.cmd; end
|
806
798
|
|
807
|
-
#
|
799
|
+
# Command line options parsed
|
800
|
+
# @return [Hash] Parsed command-line options:
|
801
|
+
# *Key* (Symbol):: *Value*
|
802
|
+
# +:env_path+:: (String) The directory of the environment.
|
803
|
+
# +:conf_files+:: (Array of Strings) Additional configuration files given with the +--conf+ command-line option. Default is +[]+.
|
804
|
+
# +:debug+:: (true or false) True, if the +-d+ or +--debug+ command-line option was given. Default is false.
|
805
|
+
# +:verbose+:: (true or false) True, if the +-v+ or +--verbose+ command-line option was given. Default is false.
|
806
|
+
# +:log_fg+:: (true or false) True, if the +-f+ or +--log-fg+ command-line option was given. Default is false.
|
807
|
+
# +:trace_js+:: (true or false) True, if the +--trace-js+ command-line option was given. Default is false.
|
808
|
+
# +:trace_delegate+:: (true or false) True, if the +--trace-delegate+ command-line option was given. Default is false.
|
809
|
+
# +:port+:: (String or nil) The TCP port number given with the +--port+ command-line option. Default is nil.
|
810
|
+
# +:addr+:: (String or nil) The TCP bind address given with the +--addr+ command-line option. Default is nil.
|
811
|
+
# +:server+:: (String or nil) The Rack http server handler given with the +--server+ command-line option. Default is nil.
|
812
|
+
# +:reset_ses+:: (true or false) True, if the +-r+ or +--reset-sessions+ command-line option was given. Default is false.
|
813
|
+
# +:autoupdate+:: (true or false) True, if the +-a+ or +--auto-update+ command-line option was given. Default is false.
|
814
|
+
# +:latency+:: (Number) Amount of milliseconds to sleep in each request given with the +--latency+ command-line option. Default is 0.
|
815
|
+
# +:say+:: (true or false) True, if the +-S+ or +--say+ command-line option was given. Default is false.
|
808
816
|
def self.args; @@argv_parser.args; end
|
809
817
|
|
810
|
-
# This accessor enables RSence.startable? method, which returns true if a start-type command was given.
|
818
|
+
# @private This accessor enables RSence.startable? method, which returns true if a start-type command was given.
|
811
819
|
def self.startable?; @@argv_parser.startable?; end
|
812
820
|
|
813
|
-
#
|
821
|
+
# @return [String] The version of RSence
|
814
822
|
def self.version; @@argv_parser.version; end
|
815
823
|
|
816
|
-
# This accessor enables RSence.startup method, which starts RSence.
|
824
|
+
# @private This accessor enables RSence.startup method, which starts RSence.
|
817
825
|
def self.startup
|
818
826
|
puts "Loading configuration..." if self.args[:verbose]
|
819
827
|
# Use the default configuration:
|
820
828
|
require 'conf/default'
|
821
829
|
@@config = Configuration.new(self.args).config
|
830
|
+
|
831
|
+
# RSence runtime configuration data
|
832
|
+
# @return [Hash] the active configuration structure as defined by the {file:default_conf default configuration} and overridden by local configuration files.
|
822
833
|
def self.config
|
823
834
|
@@config
|
824
835
|
end
|
@@ -829,6 +840,7 @@ module RSence
|
|
829
840
|
daemon.daemonize!
|
830
841
|
end
|
831
842
|
|
843
|
+
# @private The ARGVParser instance and its startup
|
832
844
|
@@argv_parser = ARGVParser.new
|
833
845
|
@@argv_parser.parse( ARGV )
|
834
846
|
|
data/lib/conf/default.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
#--
|
2
1
|
## RSence
|
3
2
|
# Copyright 2008 Riassence Inc.
|
4
3
|
# http://riassence.com/
|
@@ -6,222 +5,215 @@
|
|
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
|
-
|
8
|
+
|
10
9
|
|
11
10
|
require 'rubygems'
|
12
11
|
require 'rack'
|
13
12
|
require 'yaml'
|
14
13
|
|
15
|
-
if RUBY_VERSION.to_f >= 1.9
|
16
|
-
# --
|
17
|
-
# Ruby 1.9 encoding defaults.
|
18
|
-
# This is clearly not enough but a good start for fixing the encoding madness.
|
19
|
-
# ++
|
20
|
-
Encoding.default_external = Encoding::BINARY
|
21
|
-
Encoding.default_internal = Encoding::BINARY
|
22
|
-
# --
|
23
|
-
# Ruby 1.9 doesn't have String#each anymore.
|
24
|
-
# This is a backwards-compatible work-around.
|
25
|
-
# ++
|
26
|
-
class String
|
27
|
-
def each
|
28
|
-
self.split($/).each { |e| yield e }
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
14
|
|
33
|
-
|
34
|
-
|
15
|
+
|
16
|
+
require 'util/ruby19_fixes' if RUBY_VERSION.to_f >= 1.9
|
17
|
+
|
18
|
+
|
19
|
+
module RSence
|
20
|
+
|
35
21
|
|
36
|
-
#
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
22
|
+
# Configuration handles config files and such.
|
23
|
+
class Configuration
|
24
|
+
|
25
|
+
# Combines the Arrays `target` and `source` recursively.
|
26
|
+
# @param [Array] target Gets merged with `source`
|
27
|
+
# @param [Array] source Has its items pushed to `target` unless an identical item already exists in `target`. If an item class is a Hash, then uses {#hash_merge} to combine them.
|
28
|
+
def array_merge( target, source )
|
29
|
+
source.each do |item|
|
30
|
+
unless target.include?(item)
|
31
|
+
if item.class == Array
|
32
|
+
sub_arr = []
|
33
|
+
array_merge( sub_arr, item )
|
34
|
+
target.push( sub_arr )
|
35
|
+
elsif item.class == Hash
|
36
|
+
sub_hash = {}
|
37
|
+
hash_merge( sub_hash, item )
|
38
|
+
target.push( sub_hash )
|
39
|
+
else
|
40
|
+
target.push( item )
|
41
|
+
end
|
50
42
|
end
|
51
43
|
end
|
52
44
|
end
|
53
|
-
end
|
54
45
|
|
55
|
-
|
56
|
-
|
57
|
-
source
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
46
|
+
# Combines the Hashes `target` and `source` recursively.
|
47
|
+
# @param [Hash] target Gets merged with `source`
|
48
|
+
# @param [Hash] source Has its items merged to `target` unless a key with an identical value already exists in `target`. If an item class is Array, then uses {#array_merge} to combine them.
|
49
|
+
def hash_merge( target, source )
|
50
|
+
source.each do |key,item|
|
51
|
+
if not target.has_key?key or target[key] != item
|
52
|
+
if item.class == Array
|
53
|
+
target[key] = [] unless target.has_key?(key)
|
54
|
+
array_merge( target[key], item )
|
55
|
+
elsif item.class == Hash
|
56
|
+
target[key] = {} unless target.has_key?key
|
57
|
+
hash_merge( target[key], item )
|
58
|
+
else
|
59
|
+
target[key] = item
|
60
|
+
end
|
67
61
|
end
|
68
62
|
end
|
69
63
|
end
|
70
|
-
end
|
71
64
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
def initialize( args, dont_expand_path=false )
|
65
|
+
# @param args A parsed structure of the command-line arguments.
|
66
|
+
# @param dont_expand_path Is reserved for special cases, when Configuration is used without running RSence.
|
67
|
+
def initialize( args, dont_expand_path=false )
|
76
68
|
|
77
|
-
|
78
|
-
|
79
|
-
|
69
|
+
## Paths for log and pid files
|
70
|
+
pidpath = File.join( args[:env_path], 'run' )
|
71
|
+
logpath = File.join( args[:env_path], 'log' )
|
80
72
|
|
81
|
-
|
82
|
-
|
73
|
+
# The default configuration path, this one is distributed with the system.
|
74
|
+
yaml_conf_path = File.join( SERVER_PATH, 'conf', 'default_conf.yaml' )
|
83
75
|
|
84
|
-
|
85
|
-
|
86
|
-
|
76
|
+
# Parses the default configuration from yaml first.
|
77
|
+
# This is used as the basis for overriding the defaults in various other config files.
|
78
|
+
config = YAML.load( File.read( yaml_conf_path ) )
|
87
79
|
|
88
|
-
|
89
|
-
|
90
|
-
|
80
|
+
# The default strings for various messages, this one is distributed with the system.
|
81
|
+
yaml_strings_path = File.join( SERVER_PATH, 'conf', 'default_strings.yaml' )
|
82
|
+
strings = YAML.load( File.read( yaml_strings_path ) )
|
91
83
|
|
92
|
-
|
93
|
-
|
84
|
+
# Transporter-specific strings are set.
|
85
|
+
config[:transporter_conf][:messages] = strings[:messages][:transporter]
|
94
86
|
|
95
|
-
|
96
|
-
|
97
|
-
|
87
|
+
# Makes the distribution 'js' directory containing the client core the
|
88
|
+
# first client package source directory.
|
89
|
+
config[:client_pkg][:src_dirs].unshift( File.join( SERVER_PATH, 'js' ) )
|
98
90
|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
91
|
+
# The distributed standard plugins are in this directory.
|
92
|
+
default_plugins_path = File.join( SERVER_PATH, 'plugins' )
|
93
|
+
unless config[:plugin_paths].include? default_plugins_path
|
94
|
+
config[:plugin_paths].push( default_plugins_path )
|
95
|
+
end
|
104
96
|
|
105
|
-
|
106
|
-
|
97
|
+
# Paths to add to $LOAD_PATH after all configuration files are read.
|
98
|
+
lib_paths = []
|
107
99
|
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
100
|
+
# List of configuration files to look for.
|
101
|
+
local_config_file_paths = [
|
102
|
+
File.join(SERVER_PATH,'conf','local_conf.yaml'),
|
103
|
+
'/etc/rsence/config.yaml',
|
104
|
+
File.expand_path('~/.rsence/config.yaml'),
|
105
|
+
File.join( File.split( SERVER_PATH )[0], 'conf', 'local_conf.yaml' )
|
106
|
+
]
|
115
107
|
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
108
|
+
# Add the additional config files optionally specified in ARGVParser
|
109
|
+
args[:conf_files].each do |conf_file|
|
110
|
+
local_config_file_paths.push( conf_file )
|
111
|
+
end
|
120
112
|
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
113
|
+
# Loads the configuration files
|
114
|
+
local_config_file_paths.each do |local_config_file_path|
|
115
|
+
if File.exists? local_config_file_path and File.file? local_config_file_path
|
116
|
+
if local_config_file_path.end_with? '.yaml'
|
117
|
+
puts "loading config file: #{local_config_file_path}" if args[:verbose]
|
118
|
+
local_conf = YAML.load( File.read( local_config_file_path ) )
|
119
|
+
unless local_conf.class == Hash
|
120
|
+
warn "invalid configuration file: #{local_config_file_path.inspect}"
|
121
|
+
next
|
122
|
+
end
|
123
|
+
hash_merge( config, local_conf )
|
124
|
+
else
|
125
|
+
warn "Only Yaml configuration files are supported."
|
130
126
|
end
|
131
|
-
hash_merge( config, local_conf )
|
132
|
-
else
|
133
|
-
warn "Only Yaml configuration files are supported."
|
134
127
|
end
|
135
128
|
end
|
136
|
-
end
|
137
129
|
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
130
|
+
# Adds the plugins directory of the environment
|
131
|
+
# to the configuration automatically
|
132
|
+
env_plugins_path = File.expand_path( 'plugins', args[:env_path] )
|
133
|
+
unless config[:plugin_paths].include? env_plugins_path
|
134
|
+
config[:plugin_paths].push( env_plugins_path )
|
135
|
+
end
|
144
136
|
|
145
|
-
|
137
|
+
# At this point, configuration files are read and ready.
|
146
138
|
|
147
|
-
|
139
|
+
puts "plugin paths: #{config[:plugin_paths].inspect}" if args[:debug]
|
148
140
|
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
141
|
+
# Override configuration options with command-line-options.
|
142
|
+
config[:trace] = true if args[:trace_js]
|
143
|
+
config[:debug_mode] = true if args[:debug]
|
144
|
+
config[:http_server][:latency] = args[:latency]
|
145
|
+
config[:http_server][:port] = args[:port] if args[:port]
|
146
|
+
config[:http_server][:bind_address] = args[:addr] if args[:addr]
|
147
|
+
config[:http_server][:rack_require] = args[:server] if args[:server]
|
148
|
+
config[:session_conf][:reset_sessions] = true if args[:reset_ses]
|
157
149
|
|
158
|
-
|
159
|
-
|
150
|
+
config[:client_pkg][:no_obfuscation] = true if args[:client_pkg_no_obfuscation]
|
151
|
+
config[:client_pkg][:no_whitespace_removal] = true if args[:client_pkg_no_whitespace_removal]
|
160
152
|
|
161
|
-
|
162
|
-
|
163
|
-
|
153
|
+
# Sets the default pid and log paths used by the HTTPDaemon
|
154
|
+
config[:daemon][:pid_fn] = File.join(pidpath, "rsence.pid") unless config[:daemon].has_key?(:pid_fn)
|
155
|
+
config[:daemon][:log_fn] = File.join(logpath, "rsence") unless config[:daemon].has_key?(:log_fn)
|
164
156
|
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
157
|
+
# Check database path for sqlite databases.
|
158
|
+
if config[:database][:ses_db].start_with?('sqlite://') and not dont_expand_path
|
159
|
+
db_url = File.expand_path( config[:database][:ses_db].split('sqlite://')[1], args[:env_path] )
|
160
|
+
config[:database][:ses_db] = "sqlite://#{db_url}"
|
161
|
+
end
|
170
162
|
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
163
|
+
# Sets the various standard url prefixes:
|
164
|
+
[ ## POST-requests
|
165
|
+
# broker_key # default_uri
|
166
|
+
# The default responder for transporter requests.
|
167
|
+
[ :x, File.join(config[:base_url],'x') ],
|
168
|
+
# The default responder for cookie-enabled "handshake" transporter requests
|
169
|
+
[ :hello, File.join(config[:base_url],'hello') ],
|
170
|
+
# The default responder for file uploads
|
171
|
+
[ :u, File.join(config[:base_url],'U') ],
|
180
172
|
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
173
|
+
## GET-requests
|
174
|
+
# broker_key # default_uri
|
175
|
+
# The default address of built javascript and theme packages
|
176
|
+
[ :h, File.join(config[:base_url],'H/') ],
|
177
|
+
# The default address of the ticketserve :img -category
|
178
|
+
[ :i, File.join(config[:base_url],'i/') ],
|
179
|
+
# The default address of the ticketserve :rsrc -category
|
180
|
+
[ :d, File.join(config[:base_url],'d/') ],
|
181
|
+
# The default address of the ticketserve :file -category
|
182
|
+
[ :f, File.join(config[:base_url],'f/') ],
|
183
|
+
# The default address of the ticketserve :blobobj -category
|
184
|
+
[ :b, File.join(config[:base_url],'b/') ],
|
185
|
+
# The default address of the favicon
|
186
|
+
[ :favicon, '/favicon.ico' ],
|
187
|
+
# The default address of the "empty" iframe of uploader
|
188
|
+
[ :uploader_iframe, File.join(config[:base_url],'U/iframe_html') ],
|
189
|
+
].each do |broker_key, default_uri|
|
190
|
+
unless config[:broker_urls].has_key?( broker_key )
|
191
|
+
config[:broker_urls][broker_key] = default_uri
|
192
|
+
end
|
200
193
|
end
|
201
|
-
end
|
202
194
|
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
195
|
+
if RUBY_VERSION.to_f >= 1.9
|
196
|
+
# The encodings mess up compression when using ruby1.9
|
197
|
+
warn "Disabling gzip support for ruby 1.9" if args[:debug]
|
198
|
+
config[:no_gzip] = true
|
199
|
+
end
|
208
200
|
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
201
|
+
# The default address of the index_html plugin
|
202
|
+
unless config[:index_html].has_key?(:respond_address)
|
203
|
+
config[:index_html][:respond_address] = File.join(config[:base_url])
|
204
|
+
end
|
213
205
|
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
206
|
+
## Uses the lib paths as search paths
|
207
|
+
lib_paths.merge( config[:lib_paths] ) if config.has_key?(:lib_paths)
|
208
|
+
lib_paths.each do |lib_path|
|
209
|
+
$LOAD_PATH << lib_path
|
210
|
+
end
|
219
211
|
|
220
|
-
|
221
|
-
|
212
|
+
@config = config
|
213
|
+
end
|
222
214
|
|
223
|
-
|
215
|
+
attr_reader :config
|
224
216
|
|
217
|
+
end
|
225
218
|
end
|
226
219
|
|
227
|
-
|