rsence 2.0.0.3.pre → 2.0.0.4.pre
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/js/comm/comm/comm.js +9 -2
- data/js/comm/comm/sessionwatcher/sessionwatcher.js +1 -1
- data/js/controls/button/button.js +7 -1
- data/js/foundation/json_renderer/json_renderer.js +18 -5
- data/lib/conf/argv.rb +352 -76
- data/lib/conf/default.rb +6 -8
- data/lib/daemon/daemon.rb +19 -4
- data/lib/http/broker.rb +18 -4
- data/lib/plugins/plugin_util.rb +1 -3
- data/lib/plugins/pluginmanager.rb +11 -16
- data/lib/session/sessionstorage.rb +62 -30
- data/lib/transporter/transporter.rb +24 -2
- data/plugins/client_pkg/lib/client_pkg_build.rb +1 -5
- data/plugins/ticketservices/ticketservices.rb +1 -1
- data/setup/welcome/gui/welcome.yaml +68 -0
- data/setup/welcome/info.yaml +23 -0
- data/setup/welcome/text/welcome.html +8 -0
- data/setup/welcome/values.yaml +6 -0
- data/setup/welcome/welcome.rb +31 -0
- metadata +10 -7
- data/js/debugg/debugg.js +0 -43
- data/js/debugg/js.inc +0 -0
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.0.0.
|
1
|
+
2.0.0.4.pre
|
data/js/comm/comm/comm.js
CHANGED
@@ -133,6 +133,13 @@ COMM = {
|
|
133
133
|
if(!_options.onSuccess){
|
134
134
|
_this.onSuccess = function(resp){console.log('No success handler specified, response: ',resp);};
|
135
135
|
}
|
136
|
+
if(!_options.on302){
|
137
|
+
/** Redirection handler **/
|
138
|
+
_this.on503 = function(_this){
|
139
|
+
var _retryAfter = parseInt(_this.X.getResponseHeader('Retry-After'),10)*1000,
|
140
|
+
_timeout = setTimeout(function(){COMM.request(_this.url,_this.options);},_retryAfter);
|
141
|
+
};
|
142
|
+
}
|
136
143
|
_this.url = _url;
|
137
144
|
_this.options = _options;
|
138
145
|
_this.X = _comm._XMLHttpRequest();
|
@@ -181,9 +188,9 @@ if(window['XMLHttpRequest']!==undefined){
|
|
181
188
|
return new XMLHttpRequest();
|
182
189
|
};
|
183
190
|
}
|
184
|
-
else if(
|
191
|
+
else if(window.ActiveXObject){
|
185
192
|
COMM._XMLHttpRequest = function(){
|
186
|
-
return new ActiveXObject("
|
193
|
+
return new ActiveXObject("Microsoft.XMLHTTP");
|
187
194
|
};
|
188
195
|
}
|
189
196
|
else {
|
@@ -30,7 +30,7 @@ COMM.SessionWatcher = HApplication.extend({
|
|
30
30
|
|
31
31
|
// gets the HValue represented by
|
32
32
|
// sesTimeoutValueId (:client_time in server)
|
33
|
-
this.sesTimeoutValue =
|
33
|
+
this.sesTimeoutValue = COMM.Values.values[_sesTimeoutValueId];
|
34
34
|
this.timeoutSecs = _timeoutSecs;
|
35
35
|
},
|
36
36
|
|
@@ -36,7 +36,12 @@ HButton = HControl.extend({
|
|
36
36
|
** +1+:: Disabled, clicked
|
37
37
|
** +Other+:: Disabled, not clickable, not clicked
|
38
38
|
***/
|
39
|
-
|
39
|
+
HClickButton = HButton.extend({
|
40
|
+
|
41
|
+
defaultEvents: {
|
42
|
+
click: true
|
43
|
+
},
|
44
|
+
|
40
45
|
/** = Description
|
41
46
|
* Sets the button enabled if this.value is 0.
|
42
47
|
*
|
@@ -55,3 +60,4 @@ HClickValueButton = HButton.extend({
|
|
55
60
|
}
|
56
61
|
});
|
57
62
|
|
63
|
+
HClickValueButton = HClickButton;
|
@@ -23,7 +23,7 @@
|
|
23
23
|
***/
|
24
24
|
COMM.JSONRenderer = HClass.extend({
|
25
25
|
|
26
|
-
version: 0.
|
26
|
+
version: 0.6,
|
27
27
|
|
28
28
|
/** = Description
|
29
29
|
* Renders JSON structured data, see some of the demos for usage examples.
|
@@ -145,6 +145,10 @@ COMM.JSONRenderer = HClass.extend({
|
|
145
145
|
_hasExtension = _dataNode['extend'] !== undefined,
|
146
146
|
_extension = _hasExtension?_dataNode['extend']:null,
|
147
147
|
|
148
|
+
// JS Extension block
|
149
|
+
_hasBind = _dataNode['bind'] !== undefined,
|
150
|
+
_bind = _hasBind?_dataNode['bind']:null,
|
151
|
+
|
148
152
|
// JS Definition block
|
149
153
|
_hasDefinition = _dataNode['define'] !== undefined,
|
150
154
|
_definitions = _hasDefinition?_dataNode['define']:null,
|
@@ -155,7 +159,6 @@ COMM.JSONRenderer = HClass.extend({
|
|
155
159
|
i,
|
156
160
|
|
157
161
|
_subView;
|
158
|
-
// console.log('className:',_className,' class:',_class);
|
159
162
|
this.scopeDepth ++;
|
160
163
|
this.scopes.push({});
|
161
164
|
try{
|
@@ -189,9 +192,14 @@ COMM.JSONRenderer = HClass.extend({
|
|
189
192
|
_class = _class.extend( _extBlock );
|
190
193
|
}
|
191
194
|
if(_hasOptions){
|
192
|
-
if(
|
193
|
-
|
194
|
-
|
195
|
+
if(_hasBind){
|
196
|
+
_options.valueObj = COMM.Values.values[_bind];
|
197
|
+
}
|
198
|
+
else{
|
199
|
+
if(_options['valueObjId'] !== undefined){
|
200
|
+
var _valueObjId = _options['valueObjId'];
|
201
|
+
_options['valueObj'] = COMM.Values.values[_options['valueObjId']];
|
202
|
+
}
|
195
203
|
}
|
196
204
|
}
|
197
205
|
// For HApplication -derived classes
|
@@ -202,6 +210,11 @@ COMM.JSONRenderer = HClass.extend({
|
|
202
210
|
else if(_hasRect){
|
203
211
|
_instance = _class.nu(_rect,_parent,_options);
|
204
212
|
}
|
213
|
+
if(!_hasOptions){
|
214
|
+
if(_hasBind){
|
215
|
+
COMM.Values.values[_bind].bind(_instance);
|
216
|
+
}
|
217
|
+
}
|
205
218
|
}
|
206
219
|
else if(!(!_class && _hasSubviews)) {
|
207
220
|
console.log('renderNode warning; No such class: '+_className+', node: ',_dataNode);
|
data/lib/conf/argv.rb
CHANGED
@@ -18,10 +18,10 @@ class ARGVParser
|
|
18
18
|
@@version = File.read( File.join( SERVER_PATH, 'VERSION' ) ).strip
|
19
19
|
|
20
20
|
if RSence.pid_support?
|
21
|
-
@@cmds = [ :run, :status, :start, :stop, :restart, :save,
|
21
|
+
@@cmds = [ :run, :status, :start, :stop, :restart, :save,
|
22
22
|
:initenv, :version, :help ]
|
23
23
|
else
|
24
|
-
@@cmds = [ :run, :
|
24
|
+
@@cmds = [ :run, :initenv, :version, :help ]
|
25
25
|
end
|
26
26
|
|
27
27
|
@@cmd_help = {}
|
@@ -49,30 +49,6 @@ EOF
|
|
49
49
|
The [PATH] is the RSence environment to use.
|
50
50
|
The [PATH] defaults to the current working directory.
|
51
51
|
|
52
|
-
The expected structure of a project environment (where 'project_directory'
|
53
|
-
is the directory of your project) is:
|
54
|
-
|
55
|
-
[dir] project_directory :: The directory of your project.
|
56
|
-
[dir] conf :: The directory of config files.
|
57
|
-
[file] config.yaml :: The config file to load by defult.
|
58
|
-
[dir] db :: Directory containing database files.
|
59
|
-
[dir] log :: Directory containing log files.
|
60
|
-
[dir] plugins :: Directory containing installed plugins.
|
61
|
-
[dir] run :: Directory containing runtime pid files.
|
62
|
-
|
63
|
-
The 'config.yaml' file contains patches specific to your project.
|
64
|
-
|
65
|
-
The configuration files are loaded and applied in this order:
|
66
|
-
1: [rsence_install_path]/conf/default_conf.yaml
|
67
|
-
2: [rsence_install_path]/conf/local_conf.yaml
|
68
|
-
3: /etc/rsence/config.yaml
|
69
|
-
4: ~/.rsence/config.yaml
|
70
|
-
5: [project_directory]/conf/config.yaml
|
71
|
-
6: Any files given using --conf parameters, in order of occurrence.
|
72
|
-
|
73
|
-
The plugins directory contains the plugins installed in the project.
|
74
|
-
|
75
|
-
See also the 'setup' and 'initenv' commands.
|
76
52
|
EOF
|
77
53
|
|
78
54
|
@@cmd_help[:options] = <<-EOF
|
@@ -100,7 +76,7 @@ Available options:
|
|
100
76
|
'0.0.0.0' matches all interfaces.
|
101
77
|
'127.0.0.1' matches the local loopback interface.
|
102
78
|
|
103
|
-
--server <handler> The Rack handler to use.
|
79
|
+
--server <handler> The Rack handler to use. Defaults to mongrel
|
104
80
|
|
105
81
|
--reset-sessions (-r) Resets all active sessions.
|
106
82
|
|
@@ -124,12 +100,69 @@ Available options:
|
|
124
100
|
|
125
101
|
EOF
|
126
102
|
|
103
|
+
@@cmd_help[:initenv] = <<-EOF
|
104
|
+
usage: 'rsence initenv [options] [PATH]'
|
105
|
+
|
106
|
+
The 'initenv' command creates a new RSence environment.
|
107
|
+
|
108
|
+
The expected structure of a project environment (where 'project_directory'
|
109
|
+
is the directory of your project) is:
|
110
|
+
|
111
|
+
[d] project_name : The name of your project.
|
112
|
+
[d] conf : The directory of config files.
|
113
|
+
[f] config.yaml : The config file to load by defult.
|
114
|
+
[d] db : Directory containing database files.
|
115
|
+
[d] log : Directory containing log files.
|
116
|
+
[d] plugins : Directory containing installed plugins.
|
117
|
+
[d] run : Directory containing runtime pid files.
|
118
|
+
[f] README : Description of the environment directory.
|
119
|
+
[f] VERSION : RSence version the environment was created with
|
120
|
+
|
121
|
+
The 'config.yaml' file contains patches specific to your project.
|
122
|
+
|
123
|
+
The configuration files are loaded and applied in this order:
|
124
|
+
1: [rsence_install_path]/conf/default_conf.yaml
|
125
|
+
2: [rsence_install_path]/conf/local_conf.yaml
|
126
|
+
3: /etc/rsence/config.yaml
|
127
|
+
4: ~/.rsence/config.yaml
|
128
|
+
5: [project_directory]/conf/config.yaml
|
129
|
+
6: Any files given using --conf parameters, in order of occurrence.
|
130
|
+
|
131
|
+
The plugins directory contains the plugins that are run in the project.
|
132
|
+
|
133
|
+
|
134
|
+
Available options:
|
135
|
+
|
136
|
+
--port <number> The port number the http server listens to.
|
137
|
+
|
138
|
+
--addr <ip address> The IP address or netmask the http server listens to.
|
139
|
+
'0.0.0.0' matches all interfaces.
|
140
|
+
'127.0.0.1' matches the local loopback interface.
|
141
|
+
Defaults to 0.0.0.0
|
142
|
+
|
143
|
+
--server <handler> The Rack handler to use. Defaults to mongrel
|
144
|
+
|
145
|
+
--title <title> The title of the index page.
|
146
|
+
|
147
|
+
--database <conn_str> Use the Sequel connection string to configure the
|
148
|
+
default session database.
|
149
|
+
|
150
|
+
--uri-prefix <path> Configure RSence to use this http "directory" as
|
151
|
+
the prefix. It defaults to the root directory: /
|
152
|
+
|
153
|
+
--blank Doesn't install the Welcome -plugin.
|
154
|
+
|
155
|
+
--non-interactive (-q) Doesn't ask anything, just creates the environment
|
156
|
+
with the options supplied.
|
157
|
+
|
158
|
+
For further configuration, edit the config.yaml file.
|
159
|
+
|
160
|
+
EOF
|
161
|
+
|
127
162
|
@@cmd_help[:run] = <<-EOF
|
128
163
|
usage: 'rsence run [options] [PATH]'
|
129
164
|
|
130
165
|
The 'run' command starts RSence in foreground (no daemon). Exit with CTRL-C.
|
131
|
-
This is the suggested mode for development and the only mode supported by
|
132
|
-
Windows, because Windows is missing the concept of a process ID.
|
133
166
|
|
134
167
|
#{@@cmd_help[:path]}
|
135
168
|
#{@@cmd_help[:options]}
|
@@ -144,7 +177,7 @@ Use the 'stop' command to stop RSence.
|
|
144
177
|
|
145
178
|
Use the 'restart' command to restart RSence in the background.
|
146
179
|
|
147
|
-
Use the 'status' command to
|
180
|
+
Use the 'status' command to see if RSence is running.
|
148
181
|
|
149
182
|
#{@@cmd_help[:path]}
|
150
183
|
#{@@cmd_help[:options]}
|
@@ -155,7 +188,7 @@ usage: 'rsence stop [options] [PATH]'
|
|
155
188
|
|
156
189
|
The 'stop' command stops RSence running in the background (as a daemon).
|
157
190
|
|
158
|
-
Use the 'status' command to
|
191
|
+
Use the 'status' command to see if RSence is running.
|
159
192
|
|
160
193
|
#{@@cmd_help[:path]}
|
161
194
|
#{@@cmd_help[:options]}
|
@@ -169,7 +202,8 @@ If RSence wasn't running before the 'restart' command was issued, the
|
|
169
202
|
effect is the same as 'start'.
|
170
203
|
|
171
204
|
Use the 'stop' command to stop RSence.
|
172
|
-
|
205
|
+
|
206
|
+
Use the 'status' command to see if RSence is running.
|
173
207
|
|
174
208
|
#{@@cmd_help[:path]}
|
175
209
|
#{@@cmd_help[:options]}
|
@@ -228,6 +262,35 @@ usage: 'rsence version'
|
|
228
262
|
|
229
263
|
The 'version' command simply outputs the version number of RSence.
|
230
264
|
|
265
|
+
RSence follows the standard four-numbered sequence-based version identification
|
266
|
+
scheme. The scheme is defined like: major.minor[.maintenance[.package]][.pre]
|
267
|
+
|
268
|
+
The major number designates major changes in functionality, sometimes limiting
|
269
|
+
backwards compatibility with software written for previous versions.
|
270
|
+
|
271
|
+
The minor number designates minor changes in functionality, like minor or
|
272
|
+
moderate changes in functinality that usually don't impact backwards
|
273
|
+
compatibilty of software written for a previous release with the same major
|
274
|
+
version.
|
275
|
+
|
276
|
+
The maintenance number designates bug fixes and other minimal changes to
|
277
|
+
the release. In a maintenance number change, no new features are introduced.
|
278
|
+
|
279
|
+
The package number is a sequence used for the package release. Rubygems
|
280
|
+
requires an unique version for each gem released, so pre-releases usually
|
281
|
+
occupy the first package numbers of any release.
|
282
|
+
|
283
|
+
The '.pre' suffix signifies a pre-release, like "Alpha" or "Beta". To
|
284
|
+
install a prerelease version, gem requires the '--pre' command line argument.
|
285
|
+
Release versions never have the '.pre' suffix. There are usually several
|
286
|
+
package number increments of a new release.
|
287
|
+
|
288
|
+
Version number conventions in written text should include both major and
|
289
|
+
minor version numbers prefixed with 'RSence'. The maintennance number
|
290
|
+
is usally not mentioned unless an issue is fix or such is discussed.
|
291
|
+
|
292
|
+
For instance: "RSence 2.0 has undergone some major refactoring since 1.2.1"
|
293
|
+
|
231
294
|
EOF
|
232
295
|
|
233
296
|
@@cmd_help[:tail] = <<-EOF
|
@@ -396,36 +459,36 @@ EOF
|
|
396
459
|
@args[:say] = true
|
397
460
|
end
|
398
461
|
|
399
|
-
def valid_env?( arg )
|
462
|
+
def valid_env?( arg, quiet=false )
|
400
463
|
path = File.expand_path( arg )
|
401
464
|
if not File.exists?( path )
|
402
|
-
puts "no such directory: #{path.inspect}"
|
465
|
+
puts "no such directory: #{path.inspect}" unless quiet
|
403
466
|
return false
|
404
467
|
elsif not File.directory?( path )
|
405
|
-
puts "not a directory: #{path.inspect}"
|
468
|
+
puts "not a directory: #{path.inspect}" unless quiet
|
406
469
|
return false
|
407
470
|
end
|
408
471
|
conf_path = File.join( path, 'conf' )
|
409
472
|
if not File.exists?( conf_path )
|
410
|
-
puts "no conf directory, expected: #{conf_path.inspect}"
|
473
|
+
puts "no conf directory, expected: #{conf_path.inspect}" unless quiet
|
411
474
|
return false
|
412
475
|
elsif not File.directory?( conf_path )
|
413
|
-
puts "not a conf directory, expected: #{conf_path.inspect}"
|
476
|
+
puts "not a conf directory, expected: #{conf_path.inspect}" unless quiet
|
414
477
|
return false
|
415
478
|
end
|
416
479
|
conf_file = File.join( path, 'conf', 'config.yaml' )
|
417
480
|
if not File.exists?(conf_file)
|
418
|
-
puts "missing conf file, expected: #{conf_file.inspect}"
|
481
|
+
puts "missing conf file, expected: #{conf_file.inspect}" unless quiet
|
419
482
|
return false
|
420
483
|
elsif not File.file?( conf_file )
|
421
|
-
puts "conf file not a file, expected: #{conf_file.inspect}"
|
484
|
+
puts "conf file not a file, expected: #{conf_file.inspect}" unless quiet
|
422
485
|
return false
|
423
486
|
end
|
424
487
|
plugin_path = File.join( path, 'plugins' )
|
425
488
|
if not File.exists?( plugin_path )
|
426
489
|
warn "Warning; no plugin directory in project, expected: #{plugin_path.inspect}" if @args[:verbose]
|
427
490
|
elsif not File.directory?( plugin_path )
|
428
|
-
puts "plugin directory not a directory, expected: #{plugin_path.inspect}"
|
491
|
+
puts "plugin directory not a directory, expected: #{plugin_path.inspect}" unless quiet
|
429
492
|
return false
|
430
493
|
end
|
431
494
|
run_path = File.join( path, 'run' )
|
@@ -466,11 +529,15 @@ EOF
|
|
466
529
|
def test_port( port, addr='127.0.0.1' )
|
467
530
|
require 'socket'
|
468
531
|
begin
|
532
|
+
addr = '127.0.0.1' if addr == '0.0.0.0'
|
469
533
|
sock = TCPsocket.open( addr, port )
|
470
534
|
sock.close
|
471
535
|
return true
|
472
536
|
rescue Errno::ECONNREFUSED
|
473
537
|
return false
|
538
|
+
rescue => e
|
539
|
+
warn e.inspect
|
540
|
+
return false
|
474
541
|
end
|
475
542
|
end
|
476
543
|
|
@@ -667,15 +734,35 @@ EOF
|
|
667
734
|
end
|
668
735
|
end
|
669
736
|
|
670
|
-
|
671
|
-
|
737
|
+
# asks y/n and returns boleans,
|
738
|
+
# the default tells if which one is for just enter
|
739
|
+
def yesno(default=false)
|
740
|
+
if default
|
741
|
+
question = "Y/n? "
|
742
|
+
else
|
743
|
+
question = "y/N? "
|
744
|
+
end
|
745
|
+
print question
|
746
|
+
answer = $stdin.gets.strip.downcase[0]
|
747
|
+
answer = answer.chr if answer
|
748
|
+
if answer == 'n'
|
749
|
+
return false
|
750
|
+
elsif answer == 'y'
|
751
|
+
return true
|
752
|
+
elsif answer == nil
|
753
|
+
return default
|
754
|
+
else
|
755
|
+
return nil
|
756
|
+
end
|
672
757
|
end
|
673
758
|
|
674
759
|
def parse_initenv_argv
|
675
760
|
init_args
|
676
761
|
expect_option = false
|
677
|
-
option_name
|
678
|
-
valid_env
|
762
|
+
option_name = false
|
763
|
+
valid_env = false
|
764
|
+
interactive = true
|
765
|
+
create_blank = false
|
679
766
|
if @argv.length >= 2
|
680
767
|
@argv[1..-1].each_with_index do |arg,i|
|
681
768
|
if expect_option
|
@@ -701,10 +788,26 @@ EOF
|
|
701
788
|
elsif arg == '--title'
|
702
789
|
expect_option = true
|
703
790
|
option_name = :title
|
791
|
+
elsif arg == '--database'
|
792
|
+
expect_option = true
|
793
|
+
option_name = :db
|
794
|
+
elsif arg == '--uri-prefix'
|
795
|
+
expect_option = true
|
796
|
+
option_name = :base_url
|
797
|
+
elsif arg == '--blank'
|
798
|
+
create_blank = true
|
799
|
+
elsif arg == '--non-interactive'
|
800
|
+
interactive = false
|
704
801
|
else
|
705
802
|
invalid_option(arg)
|
706
803
|
end
|
707
|
-
elsif
|
804
|
+
elsif arg.start_with?('-')
|
805
|
+
arg.split('')[1..-1].each do |chr|
|
806
|
+
if chr == 'q'
|
807
|
+
interactive = false
|
808
|
+
end
|
809
|
+
end
|
810
|
+
else
|
708
811
|
@args[:env_path] = File.expand_path(arg)
|
709
812
|
end
|
710
813
|
end
|
@@ -715,42 +818,217 @@ EOF
|
|
715
818
|
exit
|
716
819
|
end
|
717
820
|
end
|
718
|
-
if valid_env?(@args[:env_path])
|
719
|
-
|
720
|
-
@args[:conf_files].push( conf_file ) unless @args[:conf_files].include?( conf_file )
|
721
|
-
else
|
722
|
-
puts "invalid environment."
|
821
|
+
if valid_env?(@args[:env_path],true)
|
822
|
+
puts "Environment already initialized."
|
723
823
|
exit
|
724
824
|
end
|
825
|
+
conf_file = File.expand_path( File.join( @args[:env_path], 'conf', 'config.yaml' ) )
|
826
|
+
if File.exists?(@args[:env_path])
|
827
|
+
if Dir.entries(@args[:env_path]).length > 2 # [ '.', '..' ]
|
828
|
+
puts "Environment directory #{@args[:env_path]} is not empty."
|
829
|
+
exit
|
830
|
+
end
|
831
|
+
end
|
832
|
+
|
725
833
|
require 'conf/default'
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
)
|
737
|
-
|
738
|
-
|
739
|
-
|
834
|
+
default_config = Configuration.new(@args,true).config
|
835
|
+
|
836
|
+
config = {
|
837
|
+
:base_url => (@args[:base_url] or default_config[:base_url]),
|
838
|
+
:http_server => {
|
839
|
+
:port => (@args[:port] or default_config[:http_server][:port]),
|
840
|
+
:bind_address => (@args[:addr] or default_config[:http_server][:bind_address]),
|
841
|
+
:rack_require => (@args[:server] or default_config[:http_server][:rack_require])
|
842
|
+
},
|
843
|
+
:index_html => {
|
844
|
+
:title => (@args[:title] or default_config[:index_html][:title])
|
845
|
+
},
|
846
|
+
:database => {
|
847
|
+
:ses_db => (@args[:db] or default_config[:database][:ses_db])
|
848
|
+
}
|
849
|
+
}
|
850
|
+
Signal.trap 'INT' do
|
851
|
+
puts
|
852
|
+
puts "Configuration aborted."
|
853
|
+
exit
|
854
|
+
end
|
855
|
+
if interactive
|
856
|
+
answers_ok = false
|
857
|
+
until answers_ok
|
858
|
+
puts <<-END
|
859
|
+
|
860
|
+
Creating a new RSence environment at #{@args[:env_path]}
|
861
|
+
|
862
|
+
RSence will first ask a few questions about your environment
|
863
|
+
in order to initialize and prepare the project configuration.
|
864
|
+
|
865
|
+
You may abort this command at any time by pressing CTRL-C
|
866
|
+
Nothing will be written until you have answered all the questions.
|
867
|
+
|
868
|
+
Pressing the ENTER (or RETURN) key at each prompt will choose the
|
869
|
+
default option shown.
|
870
|
+
If you are not sure about how to answer a question, press
|
871
|
+
the ENTER (or RETURN) key to continue.
|
872
|
+
|
873
|
+
END
|
874
|
+
|
875
|
+
require 'highline/import'
|
876
|
+
|
877
|
+
say <<-END
|
878
|
+
|
879
|
+
Please enter the title of your project.
|
880
|
+
This title will be used in the default page title.
|
881
|
+
|
882
|
+
END
|
883
|
+
config[:index_html][:title] = ask("Project Title") do |q|
|
884
|
+
q.default = config[:index_html][:title]
|
885
|
+
end
|
886
|
+
|
887
|
+
say <<-END
|
888
|
+
|
889
|
+
|
890
|
+
|
891
|
+
Please specify the connection string for the session database to use.
|
892
|
+
By default, a local SQLite database is created in the 'db' subdirectory
|
893
|
+
of the environment directory. Any database supported by Sequel is supported
|
894
|
+
by RSence.
|
895
|
+
|
896
|
+
For further information about database connection strings, read the Sequel
|
897
|
+
documentation at:
|
898
|
+
http://sequel.rubyforge.org/rdoc/files/doc/opening_databases_rdoc.html
|
899
|
+
|
900
|
+
You will also need the appropriate ruby driver for the database selected. If
|
901
|
+
none is installed, RSence will not be able to store persistent session data
|
902
|
+
between server restarts.
|
903
|
+
|
904
|
+
END
|
905
|
+
config[:database][:ses_db] = ask("Session database connection string") do |q|
|
906
|
+
q.default = config[:database][:ses_db]
|
907
|
+
end
|
908
|
+
say <<-END
|
909
|
+
|
910
|
+
|
911
|
+
|
912
|
+
Please enter a HTTP port for the server to listen to. This port must not be a
|
913
|
+
TCP port already in use.
|
914
|
+
|
915
|
+
END
|
916
|
+
config[:http_server][:port] = ask("HTTP Port:") do |q|
|
917
|
+
q.default = config[:http_server][:port]
|
918
|
+
end
|
919
|
+
say <<-END
|
920
|
+
|
921
|
+
|
922
|
+
Please enter a TCP/IP address for the HTTP server to listen to. This address
|
923
|
+
must be an address configured by a network interface of this computer.
|
924
|
+
|
925
|
+
The address 0.0.0.0 matches any interfaces.
|
926
|
+
The address 127.0.0.1 matches only the localhost address, this address is
|
927
|
+
not accessible from any other computer.
|
928
|
+
|
929
|
+
END
|
930
|
+
config[:http_server][:bind_address] = ask("Interface TCP/IP address:") do |q|
|
931
|
+
q.default = config[:http_server][:bind_address]
|
932
|
+
end
|
933
|
+
|
934
|
+
say <<-END
|
935
|
+
|
936
|
+
|
937
|
+
Please enter a root directory for RSence to respond in.
|
938
|
+
By default this is the root directory of the server: /
|
939
|
+
|
940
|
+
END
|
941
|
+
config[:base_url] = ask("URI Prefix:") do |q|
|
942
|
+
q.default = config[:base_url]
|
943
|
+
end
|
944
|
+
test_url = "http://#{config[:http_server][:bind_address]}:#{config[:http_server][:port]}#{config[:base_url]}"
|
945
|
+
say <<-END
|
946
|
+
|
947
|
+
Configuration Summary
|
948
|
+
|
949
|
+
Please verify that the configuration is correct.
|
950
|
+
This configuration will be written into the configuration file:
|
951
|
+
#{conf_file}
|
952
|
+
|
953
|
+
Title: #{config[:index_html][:title]}
|
954
|
+
|
955
|
+
Database: #{config[:database][:ses_db]}
|
956
|
+
|
957
|
+
HTTP Server:
|
958
|
+
Address: #{config[:http_server][:bind_address]}
|
959
|
+
Port: #{config[:http_server][:port]}
|
960
|
+
URI Prefix: #{config[:base_url]}
|
961
|
+
|
962
|
+
This means the URL will be #{test_url}
|
963
|
+
|
964
|
+
END
|
965
|
+
print "Is the configuration correct, "
|
966
|
+
answers_ok = yesno(true)
|
740
967
|
end
|
741
968
|
else
|
742
|
-
|
743
|
-
pid_status = nil
|
969
|
+
test_url = "http://#{config[:http_server][:bind_address]}:#{config[:http_server][:port]}#{config[:base_url]}"
|
744
970
|
end
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
971
|
+
|
972
|
+
puts "Creating directories..."
|
973
|
+
env_dir = @args[:env_path]
|
974
|
+
require 'fileutils'
|
975
|
+
FileUtils.mkdir_p( env_dir ) unless File.exists?( env_dir )
|
976
|
+
conf_dir = File.expand_path( 'conf', env_dir )
|
977
|
+
Dir.mkdir( conf_dir )
|
978
|
+
db_dir = File.expand_path( 'db', env_dir )
|
979
|
+
Dir.mkdir( db_dir )
|
980
|
+
log_dir = File.expand_path( 'log', env_dir )
|
981
|
+
Dir.mkdir( log_dir )
|
982
|
+
plugins_dir = File.expand_path( 'plugins', env_dir )
|
983
|
+
Dir.mkdir( plugins_dir )
|
984
|
+
run_dir = File.expand_path( 'run', env_dir )
|
985
|
+
Dir.mkdir( run_dir )
|
986
|
+
unless create_blank
|
987
|
+
welcome_plugin_dir = File.join( SERVER_PATH, 'setup', 'welcome' )
|
988
|
+
welcome_plugin_dst = File.join( plugins_dir, 'welcome' )
|
989
|
+
puts "Installing the welcome plugin. To remove it, just delete this folder:"
|
990
|
+
puts " #{welcome_plugin_dst}"
|
991
|
+
FileUtils.cp_r( welcome_plugin_dir, welcome_plugin_dst )
|
753
992
|
end
|
993
|
+
puts "Creating files..."
|
994
|
+
conf_file = File.join( conf_dir, 'config.yaml' )
|
995
|
+
File.open( conf_file, 'w' ) {|f| f.write( YAML.dump( config ) ) }
|
996
|
+
readme_file = File.join( env_dir, 'README' )
|
997
|
+
File.open( readme_file, 'w' ) {|f| f.write( <<-END
|
998
|
+
This directory contains a RSence environment titled '#{config[:index_html][:title]}'.
|
999
|
+
Visit http://rsence.org/ for further information.
|
1000
|
+
END
|
1001
|
+
) }
|
1002
|
+
version_file = File.join( env_dir, 'VERSION' )
|
1003
|
+
File.open( readme_file, 'w' ) {|f| f.write( "RSence Environment Version #{version.to_f}" ) }
|
1004
|
+
puts <<-END
|
1005
|
+
|
1006
|
+
#{'-='*39}-
|
1007
|
+
|
1008
|
+
RSence project environment for '#{config[:index_html][:title]}' created.
|
1009
|
+
|
1010
|
+
You may configure the environment by editing the file:
|
1011
|
+
|
1012
|
+
#{conf_file}
|
1013
|
+
|
1014
|
+
If you would like to test this environment now, start the RSence server:
|
1015
|
+
|
1016
|
+
rsence run #{env_dir}
|
1017
|
+
|
1018
|
+
Then point your browser to:
|
1019
|
+
|
1020
|
+
#{test_url}
|
1021
|
+
|
1022
|
+
The latest documentation and further information is available at the
|
1023
|
+
RSence website:
|
1024
|
+
|
1025
|
+
http://rsence.org/
|
1026
|
+
|
1027
|
+
|
1028
|
+
Congratulations!
|
1029
|
+
|
1030
|
+
END
|
1031
|
+
exit
|
754
1032
|
end
|
755
1033
|
|
756
1034
|
def help( cmd )
|
@@ -797,8 +1075,6 @@ EOF
|
|
797
1075
|
parse_status_argv
|
798
1076
|
elsif cmd == :save
|
799
1077
|
parse_save_argv
|
800
|
-
elsif cmd == :setup
|
801
|
-
parse_setup_argv
|
802
1078
|
elsif cmd == :initenv
|
803
1079
|
parse_initenv_argv
|
804
1080
|
end
|