rsence 2.1.11 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (216) hide show
  1. data/INSTALL.rdoc +5 -3
  2. data/README.rdoc +23 -22
  3. data/VERSION +1 -1
  4. data/conf/default_conf.yaml +65 -29
  5. data/conf/rsence_command_strings.yaml +101 -71
  6. data/js/comm/autosync/autosync.js +3 -3
  7. data/js/comm/jsloader/jsloader.js +16 -3
  8. data/js/comm/queue/queue.js +1 -1
  9. data/js/comm/transporter/transporter.js +106 -83
  10. data/js/comm/values/values.js +8 -2
  11. data/js/controls/button/button.js +9 -4
  12. data/js/controls/button/themes/default/button.css +1 -1
  13. data/js/controls/checkbox/themes/default/checkbox.css +1 -1
  14. data/js/controls/dialogs/sheet/sheet.js +27 -18
  15. data/js/controls/radiobutton/themes/default/radiobutton.css +1 -1
  16. data/js/controls/searchfield/searchfield.coffee +2 -0
  17. data/js/controls/searchfield/themes/default/searchfield.css +96 -0
  18. data/js/controls/searchfield/themes/default/searchfield.html +12 -0
  19. data/js/controls/searchfield/themes/default/searchfield_parts1-ie6.gif +0 -0
  20. data/js/controls/searchfield/themes/default/searchfield_parts1.png +0 -0
  21. data/js/controls/sliders/slider/slider.js +7 -1
  22. data/js/controls/stepper/stepper.js +6 -1
  23. data/js/controls/stringview/stringview.js +50 -39
  24. data/js/controls/tab/tab.js +103 -7
  25. data/js/controls/tab/themes/default/tab.css +2 -0
  26. data/js/controls/textarea/themes/default/textarea.css +4 -0
  27. data/js/controls/textcontrol/textcontrol.js +32 -2
  28. data/js/controls/textcontrol/themes/default/textcontrol.css +17 -2
  29. data/js/controls/uploader/themes/default/uploader.css +3 -3
  30. data/js/controls/uploader/themes/default/uploader.html +1 -1
  31. data/js/controls/uploader/uploader.coffee +110 -0
  32. data/js/controls/window/themes/default/window.css +28 -5
  33. data/js/controls/window/themes/default/window.html +2 -0
  34. data/js/controls/window/window.js +5 -1
  35. data/js/core/class/class.js +22 -4
  36. data/js/core/elem/elem.coffee +816 -0
  37. data/js/core/event/event.js +2 -2
  38. data/js/core/rsence_ns/rsence_ns.coffee +31 -0
  39. data/js/core/rsence_ns/rsence_ns.js +6 -6
  40. data/js/datetime/calendar/calendar.coffee +307 -0
  41. data/js/datetime/calendar/themes/default/calendar.css +90 -9
  42. data/js/datetime/calendar/themes/default/calendar.html +11 -0
  43. data/js/datetime/calendar/themes/default/calendar_bg-ie6.gif +0 -0
  44. data/js/datetime/calendar/themes/default/calendar_bg.png +0 -0
  45. data/js/datetime/calendar/themes/default/calendar_parts1-ie6.gif +0 -0
  46. data/js/datetime/calendar/themes/default/calendar_parts1.png +0 -0
  47. data/js/datetime/calendar/themes/default/calendar_parts2-ie6.gif +0 -0
  48. data/js/datetime/calendar/themes/default/calendar_parts2.png +0 -0
  49. data/js/datetime/datetimepicker/datetimepicker.js +217 -0
  50. data/js/datetime/datetimevalue/datetimevalue.js +22 -5
  51. data/js/datetime/timesheet/themes/default/timesheet.css +51 -22
  52. data/js/datetime/timesheet/themes/default/timesheet.html +4 -2
  53. data/js/datetime/timesheet/timesheet.js +782 -192
  54. data/js/datetime/timesheet_item/themes/default/timesheet_item.css +42 -11
  55. data/js/datetime/timesheet_item/themes/default/timesheet_item.html +4 -2
  56. data/js/datetime/timesheet_item/themes/default/timesheet_item_icons.png +0 -0
  57. data/js/datetime/timesheet_item/timesheet_item.js +158 -254
  58. data/js/datetime/timesheet_item_edit/timesheet_item_edit.js +0 -274
  59. data/js/foundation/application/application.js +52 -9
  60. data/js/foundation/control/eventresponder/eventresponder.js +7 -4
  61. data/js/foundation/control/valueaction/valueaction.js +71 -0
  62. data/js/foundation/eventmanager/eventmanager.js +71 -33
  63. data/js/foundation/geom/rect/rect.js +39 -7
  64. data/js/foundation/json_renderer/json_renderer.js +278 -62
  65. data/js/foundation/locale_settings/locale_settings.js +131 -0
  66. data/js/foundation/system/system.js +40 -13
  67. data/js/foundation/thememanager/thememanager.js +21 -0
  68. data/js/foundation/view/markupview/markupview.js +12 -12
  69. data/js/foundation/view/view.js +221 -27
  70. data/js/graphics/svgcontrol/svgcontrol.js +400 -0
  71. data/js/lists/checkboxlist/checkboxlist.js +18 -7
  72. data/js/lists/listitems/listitems.js +52 -38
  73. data/js/lists/radiobuttonlist/radiobuttonlist.js +23 -7
  74. data/js/menus/menuitem/menuitem.js +5 -0
  75. data/js/menus/menuitem/themes/default/menuitem.css +45 -0
  76. data/js/menus/menuitem/themes/default/menuitem.html +4 -0
  77. data/js/menus/minimenu/minimenu.js +47 -16
  78. data/js/menus/minimenuitem/minimenuitem.js +62 -0
  79. data/js/menus/{minimenu/minimenuitem → minimenuitem}/themes/default/minimenuitem.css +2 -2
  80. data/js/menus/{minimenu/minimenuitem → minimenuitem}/themes/default/minimenuitem.html +0 -0
  81. data/js/menus/{minimenu/minimenuitem → minimenuitem}/themes/default/minimenuitem_checkmark.png +0 -0
  82. data/js/menus/popupmenu/popupmenu.js +14 -0
  83. data/js/menus/popupmenu/themes/default/popupmenu.css +65 -0
  84. data/js/menus/popupmenu/themes/default/popupmenu.html +7 -0
  85. data/js/menus/popupmenu/themes/default/popupmenu.png +0 -0
  86. data/js/no_pkg/no_pkg.js +2 -0
  87. data/js/util/reloadapp/reloadapp.js +1 -1
  88. data/js/views/scrollview/scrollview.js +6 -0
  89. data/lib/rsence.rb +136 -3
  90. data/lib/rsence/argv.rb +218 -0
  91. data/lib/rsence/argv/argv_util.rb +58 -0
  92. data/lib/rsence/argv/env_check.rb +58 -0
  93. data/lib/rsence/argv/help_argv.rb +15 -0
  94. data/lib/rsence/argv/initenv_argv.rb +218 -0
  95. data/lib/rsence/argv/save_argv.rb +92 -0
  96. data/lib/rsence/argv/startup_argv.rb +118 -0
  97. data/lib/rsence/argv/status_argv.rb +132 -0
  98. data/lib/rsence/argv/test_port.rb +32 -0
  99. data/lib/{daemon → rsence}/daemon.rb +67 -23
  100. data/lib/{conf/default.rb → rsence/default_config.rb} +18 -10
  101. data/lib/{plugins → rsence}/dependencies.rb +0 -0
  102. data/lib/{util → rsence}/gzstring.rb +0 -0
  103. data/lib/rsence/http.rb +3 -0
  104. data/lib/{http → rsence/http}/broker.rb +106 -19
  105. data/lib/{http → rsence/http}/rackup.rb +0 -0
  106. data/lib/{http → rsence/http}/request.rb +0 -4
  107. data/lib/{http → rsence/http}/response.rb +0 -1
  108. data/lib/{session → rsence}/msg.rb +17 -1
  109. data/lib/{plugins → rsence}/pluginmanager.rb +29 -12
  110. data/lib/{plugins → rsence}/plugins.rb +7 -7
  111. data/lib/{plugins → rsence/plugins}/gui_plugin.rb +8 -3
  112. data/lib/{plugins → rsence/plugins}/guiparser.rb +9 -6
  113. data/lib/{plugins → rsence/plugins}/plugin.rb +23 -4
  114. data/lib/{plugins → rsence/plugins}/plugin_base.rb +11 -1
  115. data/lib/{plugins → rsence/plugins}/plugin_plugins.rb +2 -2
  116. data/lib/{plugins → rsence/plugins}/plugin_sqlite_db.rb +0 -0
  117. data/lib/{plugins → rsence/plugins}/servlet.rb +0 -0
  118. data/lib/{session → rsence}/sessionmanager.rb +101 -39
  119. data/lib/{session → rsence}/sessionstorage.rb +30 -16
  120. data/lib/{daemon → rsence}/sigcomm.rb +0 -0
  121. data/lib/{transporter → rsence}/transporter.rb +13 -11
  122. data/lib/{values/hvalue.rb → rsence/value.rb} +6 -1
  123. data/lib/{values → rsence}/valuemanager.rb +1 -1
  124. data/plugins/client_pkg/client_pkg.rb +14 -4
  125. data/plugins/client_pkg/info.yaml +2 -2
  126. data/plugins/client_pkg/lib/client_pkg_build.rb +145 -45
  127. data/plugins/client_pkg/lib/client_pkg_cache.rb +1 -1
  128. data/plugins/client_pkg/lib/client_pkg_serve.rb +1 -1
  129. data/plugins/main/main.rb +43 -3
  130. data/plugins/main/tmpl/index.html +2 -10
  131. data/plugins/main/values.yaml +3 -1
  132. data/plugins/ticket/lib/common.rb +6 -3
  133. data/plugins/ticket/ticket.rb +11 -3
  134. metadata +144 -174
  135. data/js/comm/autosync/js.inc +0 -0
  136. data/js/comm/js.inc +0 -0
  137. data/js/comm/jsloader/js.inc +0 -0
  138. data/js/comm/queue/js.inc +0 -0
  139. data/js/comm/session/js.inc +0 -0
  140. data/js/comm/sessionwatcher/js.inc +0 -0
  141. data/js/comm/transporter/js.inc +0 -0
  142. data/js/comm/urlresponder/js.inc +0 -0
  143. data/js/comm/values/js.inc +0 -0
  144. data/js/controls/button/js.inc +0 -0
  145. data/js/controls/checkbox/js.inc +0 -0
  146. data/js/controls/dialogs/alert_sheet/js.inc +0 -0
  147. data/js/controls/dialogs/confirm_sheet/js.inc +0 -0
  148. data/js/controls/dialogs/sheet/js.inc +0 -0
  149. data/js/controls/imageview/js.inc +0 -0
  150. data/js/controls/passwordcontrol/js.inc +0 -0
  151. data/js/controls/progress/progressbar/js.inc +0 -0
  152. data/js/controls/progress/progressindicator/js.inc +0 -0
  153. data/js/controls/radiobutton/js.inc +0 -0
  154. data/js/controls/sliders/slider/js.inc +0 -0
  155. data/js/controls/sliders/vslider/js.inc +0 -0
  156. data/js/controls/stepper/js.inc +0 -0
  157. data/js/controls/stringview/js.inc +0 -0
  158. data/js/controls/tab/js.inc +0 -0
  159. data/js/controls/textarea/js.inc +0 -0
  160. data/js/controls/textcontrol/js.inc +0 -0
  161. data/js/controls/uploader/js.inc +0 -0
  162. data/js/controls/uploader/uploader.js +0 -154
  163. data/js/controls/validatorview/js.inc +0 -0
  164. data/js/controls/window/js.inc +0 -0
  165. data/js/core/class/js.inc +0 -0
  166. data/js/core/elem/elem.js +0 -1325
  167. data/js/core/elem/js.inc +0 -0
  168. data/js/core/event/js.inc +0 -0
  169. data/js/core/iefix/js.inc +0 -0
  170. data/js/core/rsence_ns/js.inc +0 -0
  171. data/js/datetime/calendar/calendar.js +0 -198
  172. data/js/datetime/calendar/js.inc +0 -0
  173. data/js/datetime/datetimevalue/js.inc +0 -0
  174. data/js/datetime/timesheet/js.inc +0 -0
  175. data/js/datetime/timesheet/old_timesheet.js +0 -292
  176. data/js/datetime/timesheet/themes/default/old_timesheet.css +0 -30
  177. data/js/datetime/timesheet/themes/default/old_timesheet.html +0 -2
  178. data/js/datetime/timesheet_item/js.inc +0 -0
  179. data/js/datetime/timesheet_item/old_timesheet_item.js +0 -308
  180. data/js/datetime/timesheet_item/themes/default/old_timesheet_item.css +0 -42
  181. data/js/datetime/timesheet_item/themes/default/old_timesheet_item.html +0 -8
  182. data/js/datetime/timesheet_item_edit/js.inc +0 -0
  183. data/js/datetime/timesheet_item_edit/old_timesheet_item_edit.js +0 -274
  184. data/js/foundation/application/js.inc +0 -0
  185. data/js/foundation/control/controldefaults/js.inc +0 -0
  186. data/js/foundation/control/dummyvalue/js.inc +0 -0
  187. data/js/foundation/control/dyncontrol/js.inc +0 -0
  188. data/js/foundation/control/eventresponder/js.inc +0 -0
  189. data/js/foundation/control/js.inc +0 -0
  190. data/js/foundation/control/valuematrix/js.inc +0 -0
  191. data/js/foundation/control/valueresponder/js.inc +0 -0
  192. data/js/foundation/eventmanager/js.inc +0 -0
  193. data/js/foundation/geom/point/js.inc +0 -0
  194. data/js/foundation/geom/rect/js.inc +0 -0
  195. data/js/foundation/json_renderer/js.inc +0 -0
  196. data/js/foundation/system/js.inc +0 -0
  197. data/js/foundation/thememanager/js.inc +0 -0
  198. data/js/foundation/value/js.inc +0 -0
  199. data/js/foundation/view/js.inc +0 -0
  200. data/js/foundation/view/markupview/js.inc +0 -0
  201. data/js/foundation/view/morphanimation/js.inc +0 -0
  202. data/js/foundation/view/viewdefaults/js.inc +0 -0
  203. data/js/lists/checkboxlist/js.inc +0 -0
  204. data/js/lists/listitems/js.inc +0 -0
  205. data/js/lists/propertylist/js.inc +0 -0
  206. data/js/lists/propertylist/propertylisteditor/js.inc +0 -0
  207. data/js/lists/radiobuttonlist/js.inc +0 -0
  208. data/js/menus/minimenu/js.inc +0 -0
  209. data/js/menus/minimenu/minimenuitem/js.inc +0 -0
  210. data/js/menus/minimenu/minimenuitem/minimenuitem.js +0 -33
  211. data/js/util/reloadapp/js.inc +0 -0
  212. data/js/util/sha/js.inc +0 -0
  213. data/js/views/centerview/js.inc +0 -0
  214. data/js/views/inlineview/js.inc +0 -0
  215. data/js/views/scrollview/js.inc +0 -0
  216. data/lib/conf/argv.rb +0 -880
@@ -0,0 +1,58 @@
1
+ module RSence
2
+ module ArgvUtil
3
+
4
+ # Tests for a valid environment
5
+ def valid_env?( arg, quiet=false )
6
+
7
+ # Checks, if the top-level path exists and is a directory
8
+ path = File.expand_path( arg )
9
+ if not File.exists?( path )
10
+ puts ERB.new( @strs[:messages][:no_such_directory] ).result( binding ) unless quiet
11
+ return false
12
+ elsif not File.directory?( path )
13
+ puts ERB.new( @strs[:messages][:not_a_directory] ).result( binding ) unless quiet
14
+ return false
15
+ end
16
+
17
+ # Checks, if the conf path exists and is a directory
18
+ conf_path = File.join( path, 'conf' )
19
+ if not File.exists?( conf_path )
20
+ puts ERB.new( @strs[:messages][:missing_conf_directory] ).result( binding ) unless quiet
21
+ return false
22
+ elsif not File.directory?( conf_path )
23
+ puts ERB.new( @strs[:messages][:invalid_conf_directory] ).result( binding ) unless quiet
24
+ return false
25
+ end
26
+
27
+ # Checks, if the conf/config.yaml file exists and is a directory
28
+ conf_file = File.join( path, 'conf', 'config.yaml' )
29
+ if not File.exists?(conf_file)
30
+ puts ERB.new( @strs[:messages][:missing_conf_file] ).result( binding ) unless quiet
31
+ return false
32
+ elsif not File.file?( conf_file )
33
+ puts ERB.new( @strs[:messages][:invalid_conf_file_not_file] ).result( binding ) unless quiet
34
+ return false
35
+ end
36
+
37
+ # Checks, if the plugins path exists and is a directory
38
+ plugin_path = File.join( path, 'plugins' )
39
+ if not File.exists?( plugin_path )
40
+ warn ERB.new( @strs[:messages][:warn_no_plugin_directory_in_project] ).result( binding ) if @args[:verbose]
41
+ elsif not File.directory?( plugin_path )
42
+ puts ERB.new( @strs[:messages][:plugin_directory_not_a_directory] ).result( binding ) unless quiet
43
+ return false
44
+ end
45
+
46
+ # Checks (and automatically creates if missing) the run, db and log directories
47
+ ['run','log','db'].each do |dir_name|
48
+ dir_path = File.join( path, dir_name )
49
+ unless File.exists?( dir_path )
50
+ warn ERB.new( @strs[:messages][:warn_no_directory_creating] ).result( binding ) if @args[:verbose]
51
+ Dir.mkdir( dir_path )
52
+ end
53
+ end
54
+ return true
55
+ end
56
+
57
+ end
58
+ end
@@ -0,0 +1,58 @@
1
+ module RSence
2
+ module ArgvUtil
3
+
4
+ # Tests for a valid environment
5
+ def valid_env?( arg, quiet=false )
6
+
7
+ # Checks, if the top-level path exists and is a directory
8
+ path = File.expand_path( arg )
9
+ if not File.exists?( path )
10
+ puts ERB.new( @strs[:messages][:no_such_directory] ).result( binding ) unless quiet
11
+ return false
12
+ elsif not File.directory?( path )
13
+ puts ERB.new( @strs[:messages][:not_a_directory] ).result( binding ) unless quiet
14
+ return false
15
+ end
16
+
17
+ # Checks, if the conf path exists and is a directory
18
+ conf_path = File.join( path, 'conf' )
19
+ if not File.exists?( conf_path )
20
+ puts ERB.new( @strs[:messages][:missing_conf_directory] ).result( binding ) unless quiet
21
+ return false
22
+ elsif not File.directory?( conf_path )
23
+ puts ERB.new( @strs[:messages][:invalid_conf_directory] ).result( binding ) unless quiet
24
+ return false
25
+ end
26
+
27
+ # Checks, if the conf/config.yaml file exists and is a directory
28
+ conf_file = File.join( path, 'conf', 'config.yaml' )
29
+ if not File.exists?(conf_file)
30
+ puts ERB.new( @strs[:messages][:missing_conf_file] ).result( binding ) unless quiet
31
+ return false
32
+ elsif not File.file?( conf_file )
33
+ puts ERB.new( @strs[:messages][:invalid_conf_file_not_file] ).result( binding ) unless quiet
34
+ return false
35
+ end
36
+
37
+ # Checks, if the plugins path exists and is a directory
38
+ plugin_path = File.join( path, 'plugins' )
39
+ if not File.exists?( plugin_path )
40
+ warn ERB.new( @strs[:messages][:warn_no_plugin_directory_in_project] ).result( binding ) if @args[:verbose]
41
+ elsif not File.directory?( plugin_path )
42
+ puts ERB.new( @strs[:messages][:plugin_directory_not_a_directory] ).result( binding ) unless quiet
43
+ return false
44
+ end
45
+
46
+ # Checks (and automatically creates if missing) the run, db and log directories
47
+ ['run','log','db'].each do |dir_name|
48
+ dir_path = File.join( path, dir_name )
49
+ unless File.exists?( dir_path )
50
+ warn ERB.new( @strs[:messages][:warn_no_directory_creating] ).result( binding ) if @args[:verbose]
51
+ Dir.mkdir( dir_path )
52
+ end
53
+ end
54
+ return true
55
+ end
56
+
57
+ end
58
+ end
@@ -0,0 +1,15 @@
1
+ module RSence
2
+ module ArgvUtil
3
+ # Main parser for the help command
4
+ def help( cmd )
5
+ cmd.to_sym! if cmd.class != Symbol
6
+ puts @strs[:help][:head]
7
+ if @strs[:help].has_key?(cmd)
8
+ puts @strs[:help][cmd]
9
+ else
10
+ puts @strs[:help][:help_main]
11
+ end
12
+ puts @strs[:help][:tail]
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,218 @@
1
+ module RSence
2
+ module ArgvUtil
3
+
4
+ # asks y/n and returns booleans,
5
+ # the default tells if which one is for just enter
6
+ def yesno(default=false)
7
+ if default
8
+ question = "Y/n? "
9
+ else
10
+ question = "y/N? "
11
+ end
12
+ print question
13
+ answer = $stdin.gets.strip.downcase[0]
14
+ answer = answer.chr if answer
15
+ if answer == 'n'
16
+ return false
17
+ elsif answer == 'y'
18
+ return true
19
+ elsif answer == nil
20
+ return default
21
+ else
22
+ return nil
23
+ end
24
+ end
25
+
26
+ # The initenv command and its parser. Asks questions about the environment before doing anything else.
27
+ def parse_initenv_argv
28
+ init_args
29
+ expect_option = false
30
+ option_name = false
31
+ valid_env = false
32
+ interactive = true
33
+ create_blank = false
34
+ if @argv.length >= 2
35
+ @argv[1..-1].each_with_index do |arg,i|
36
+ if expect_option
37
+ if [:port].include?(option_name) and arg.to_i.to_s != arg
38
+ puts ERB.new( @strs[:messages][:invalid_option_expected_number] ).result( binding )
39
+ exit
40
+ else
41
+ @args[option_name] = arg
42
+ end
43
+ expect_option = false
44
+ else
45
+ if arg.start_with?('--')
46
+ if arg == '--port'
47
+ expect_option = true
48
+ option_name = :port
49
+ elsif arg == '--addr'
50
+ expect_option = true
51
+ option_name = :addr
52
+ elsif arg == '--server'
53
+ expect_option = true
54
+ option_name = :server
55
+ elsif arg == '--title'
56
+ expect_option = true
57
+ option_name = :title
58
+ elsif arg == '--database'
59
+ expect_option = true
60
+ option_name = :db
61
+ elsif arg == '--uri-prefix'
62
+ expect_option = true
63
+ option_name = :base_url
64
+ elsif arg == '--blank'
65
+ create_blank = true
66
+ elsif arg == '--non-interactive'
67
+ interactive = false
68
+ else
69
+ invalid_option(arg)
70
+ end
71
+ elsif arg.start_with?('-')
72
+ arg.split('')[1..-1].each do |chr|
73
+ if chr == 'q'
74
+ interactive = false
75
+ end
76
+ end
77
+ else
78
+ @args[:env_path] = File.expand_path(arg)
79
+ end
80
+ end
81
+ end
82
+ if expect_option
83
+ puts ERB.new( @strs[:messages][:no_value_for_option] ).result( binding )
84
+ exit
85
+ end
86
+ end
87
+ if valid_env?(@args[:env_path],true)
88
+ puts @strs[:initenv][:env_already_initialized]
89
+ exit
90
+ end
91
+ conf_file = File.expand_path( File.join( @args[:env_path], 'conf', 'config.yaml' ) )
92
+ if File.exists?(@args[:env_path])
93
+ env_empty = true # true while entries start with a dot
94
+ env_clear = true # true while entries don't contain RSence project files
95
+ env_entries = ['conf', 'db', 'log', 'plugins', 'run', 'README', 'VERSION']
96
+ Dir.entries(@args[:env_path]).each do |entry|
97
+ next if entry.start_with?('.')
98
+ env_empty = false
99
+ if env_entries.include? entry
100
+ env_clear = false
101
+ break
102
+ end
103
+ end
104
+ unless env_clear
105
+ puts ERB.new( @strs[:initenv][:env_not_clear] ).result( binding )
106
+ print @strs[:initenv][:continue_question]
107
+ exit unless yesno
108
+ end
109
+ unless env_empty
110
+ puts ERB.new( @strs[:initenv][:env_not_empty] ).result( binding )
111
+ print @strs[:initenv][:continue_question]
112
+ exit unless yesno
113
+ end
114
+ end
115
+
116
+ require 'rsence/default_config'
117
+ default_config = Configuration.new(@args,true).config
118
+
119
+ config = {
120
+ :base_url => (@args[:base_url] or default_config[:base_url]),
121
+ :http_server => {
122
+ :port => (@args[:port] or default_config[:http_server][:port]),
123
+ :bind_address => (@args[:addr] or default_config[:http_server][:bind_address]),
124
+ :rack_require => (@args[:server] or default_config[:http_server][:rack_require])
125
+ },
126
+ :index_html => {
127
+ :title => (@args[:title] or default_config[:index_html][:title])
128
+ },
129
+ :database => {
130
+ :ses_db => (@args[:db] or default_config[:database][:ses_db])
131
+ }
132
+ }
133
+ Signal.trap 'INT' do
134
+ puts
135
+ puts "Configuration aborted."
136
+ exit
137
+ end
138
+ if interactive
139
+ answers_ok = false
140
+ until answers_ok
141
+ puts ERB.new( @strs[:initenv][:creating_env] ).result( binding )
142
+
143
+ require 'highline/import'
144
+
145
+ say @strs[:initenv][:enter_title]
146
+ str_project_title = @strs[:initenv][:project_title]
147
+ config[:index_html][:title] = ask( str_project_title ) do |q|
148
+ q.default = config[:index_html][:title]
149
+ end
150
+
151
+ say @strs[:initenv][:enter_db_url]
152
+ str_db_url = @strs[:initenv][:db_url]
153
+ config[:database][:ses_db] = ask(str_db_url) do |q|
154
+ q.default = config[:database][:ses_db]
155
+ end
156
+
157
+ say @strs[:initenv][:enter_http_port]
158
+ str_http_port = @strs[:initenv][:http_port]
159
+ config[:http_server][:port] = ask(str_http_port) do |q|
160
+ q.default = config[:http_server][:port]
161
+ end
162
+
163
+ say @strs[:initenv][:enter_tcp_ip]
164
+ str_tcp_ip = @strs[:initenv][:tcp_ip]
165
+ config[:http_server][:bind_address] = ask(str_tcp_ip) do |q|
166
+ q.default = config[:http_server][:bind_address]
167
+ end
168
+
169
+ say @strs[:initenv][:enter_root_dir]
170
+ str_root_dir = @strs[:initenv][:root_dir]
171
+ config[:base_url] = ask(str_root_dir) do |q|
172
+ q.default = config[:base_url]
173
+ end
174
+
175
+ test_url = "http://#{config[:http_server][:bind_address]}:#{config[:http_server][:port]}#{config[:base_url]}"
176
+ say ERB.new( @strs[:initenv][:config_summary] ).result( binding )
177
+ print @strs[:initenv][:confirm_config]
178
+ answers_ok = yesno(true)
179
+ end
180
+ else
181
+ test_url = "http://#{config[:http_server][:bind_address]}:#{config[:http_server][:port]}#{config[:base_url]}"
182
+ end
183
+
184
+ puts @strs[:initenv][:creating_dirs]
185
+ env_dir = @args[:env_path]
186
+ require 'fileutils'
187
+ FileUtils.mkdir_p( env_dir ) unless File.exists?( env_dir )
188
+ conf_dir = File.expand_path( 'conf', env_dir )
189
+ Dir.mkdir( conf_dir )
190
+ db_dir = File.expand_path( 'db', env_dir )
191
+ Dir.mkdir( db_dir )
192
+ log_dir = File.expand_path( 'log', env_dir )
193
+ Dir.mkdir( log_dir )
194
+ plugins_dir = File.expand_path( 'plugins', env_dir )
195
+ Dir.mkdir( plugins_dir )
196
+ run_dir = File.expand_path( 'run', env_dir )
197
+ Dir.mkdir( run_dir )
198
+ unless create_blank
199
+ print @strs[:initenv][:install_welcome]
200
+ if yesno
201
+ welcome_plugin_dir = File.join( SERVER_PATH, 'setup', 'welcome' )
202
+ welcome_plugin_dst = File.join( plugins_dir, 'welcome' )
203
+ puts ERB.new( @strs[:initenv][:installing_welcome_plugin] ).result( binding )
204
+ FileUtils.cp_r( welcome_plugin_dir, welcome_plugin_dst )
205
+ end
206
+ end
207
+ puts @strs[:initenv][:creating_files]
208
+ conf_file = File.join( conf_dir, 'config.yaml' )
209
+ File.open( conf_file, 'w' ) {|f| f.write( YAML.dump( config ) ) }
210
+ readme_file = File.join( env_dir, 'README' )
211
+ File.open( readme_file, 'w' ) {|f| f.write( ERB.new( @strs[:initenv][:readme] ).result( binding ) ) }
212
+ version_file = File.join( env_dir, 'VERSION' )
213
+ File.open( version_file, 'w' ) {|f| f.write( "RSence Environment Version #{version.to_f}" ) }
214
+ puts ERB.new( @strs[:initenv][:congratulations] ).result( binding )
215
+ exit
216
+ end
217
+ end
218
+ end
@@ -0,0 +1,92 @@
1
+ module RSence
2
+ module ArgvUtil
3
+ # Main argument parser for the save command. Sends the USR1 POSIX signal to the process, if running.
4
+ def parse_save_argv
5
+ init_args
6
+ expect_option = false
7
+ option_name = false
8
+ if @argv.length >= 2
9
+ @argv[1..-1].each_with_index do |arg,i|
10
+ if expect_option
11
+ if option_name == :conf_files
12
+ if not File.exists?( arg ) or not File.file?( arg )
13
+ puts ERB.new( @strs[:messages][:no_such_configuration_file] ).result( binding )
14
+ exit
15
+ else
16
+ @args[:conf_files].push( arg )
17
+ end
18
+ else
19
+ @args[option_name] = arg
20
+ end
21
+ expect_option = false
22
+ else
23
+ if arg.start_with?('--')
24
+ if arg == '--debug'
25
+ set_debug
26
+ elsif arg == '--verbose'
27
+ set_verbose
28
+ elsif arg == '--conf' or arg == '--config'
29
+ expect_option = true
30
+ option_name = :conf_files
31
+ else
32
+ invalid_option(arg)
33
+ end
34
+ elsif arg.start_with?('-')
35
+ arg.split('')[1..-1].each do |chr|
36
+ if chr == 'd'
37
+ set_debug
38
+ elsif chr == 'v'
39
+ set_verbose
40
+ else
41
+ invalid_option(arg,chr)
42
+ end
43
+ end
44
+ elsif valid_env?(arg)
45
+ @args[:env_path] = File.expand_path(arg)
46
+ @args[:conf_files].unshift( File.expand_path( File.join( arg, 'conf', 'config.yaml' ) ) )
47
+ else
48
+ invalid_env( arg )
49
+ end
50
+ end
51
+ end
52
+ if expect_option
53
+ puts ERB.new( @strs[:messages][:no_value_for_option] ).result( binding )
54
+ exit
55
+ end
56
+ end
57
+ if valid_env?(@args[:env_path])
58
+ conf_file = File.expand_path( File.join( @args[:env_path], 'conf', 'config.yaml' ) )
59
+ @args[:conf_files].unshift( conf_file ) unless @args[:conf_files].include?( conf_file )
60
+ else
61
+ invalid_env
62
+ end
63
+ require 'rsence/default_config'
64
+ config = Configuration.new(@args).config
65
+ if RSence.pid_support?
66
+ pid_fn = config[:daemon][:pid_fn]
67
+ if File.exists?( pid_fn )
68
+ pid = File.read( pid_fn ).to_i
69
+ saving_message = @strs[:messages][:saving_message]
70
+ pid_status = RSence::SIGComm.wait_signal_response(
71
+ pid, pid_fn, 'USR2', 30, saving_message, '.', 0.1, true
72
+ )
73
+ else
74
+ warn @strs[:messages][:no_pid_file] if @args[:verbose]
75
+ pid_status = nil
76
+ end
77
+ else
78
+ warn @strs[:messages][:no_pid_support] if @args[:verbose]
79
+ pid_status = nil
80
+ end
81
+ if RSence.pid_support?
82
+ if pid_status == nil
83
+ puts @strs[:messages][:no_pid_unable_to_save]
84
+ elsif pid_status == false
85
+ puts @strs[:messages][:no_process_running]
86
+ else
87
+ puts @strs[:messages][:session_data_saved]
88
+ end
89
+ end
90
+ end
91
+ end
92
+ end
@@ -0,0 +1,118 @@
1
+ module RSence
2
+ module ArgvUtil
3
+
4
+ # Main argument parser for all 'start' -type commands.
5
+ def parse_startup_argv
6
+ init_args
7
+ expect_option = false
8
+ option_name = false
9
+ if @argv.length >= 2
10
+ @argv[1..-1].each_with_index do |arg,i|
11
+ if expect_option
12
+ if [ :port, :latency, :http_delayed_start ].include?(option_name) and arg.to_i.to_s != arg
13
+ puts ERB.new( @strs[:messages][:invalid_option_expected_number] ).result( binding )
14
+ exit
15
+ elsif option_name == :conf_files
16
+ if not File.exists?( arg ) or not File.file?( arg )
17
+ puts ERB.new( @strs[:messages][:no_such_configuration_file] ).result( binding )
18
+ exit
19
+ else
20
+ @args[:conf_files].push( arg )
21
+ end
22
+ elsif option_name == :http_delayed_start
23
+ @args[:http_delayed_start] = arg.to_i
24
+ else
25
+ arg = arg.to_i if option_name == :latency
26
+ @args[option_name] = arg
27
+ end
28
+ expect_option = false
29
+ else
30
+ if arg.start_with?('--')
31
+ if arg == '--profile'
32
+ true
33
+ elsif arg == '--debug'
34
+ set_debug
35
+ elsif arg == '--verbose'
36
+ set_verbose
37
+ elsif arg == '--log-fg'
38
+ set_log_fg
39
+ elsif arg == '--trace-js'
40
+ @args[:trace_js] = true
41
+ elsif arg == '--trace-delegate'
42
+ @args[:trace_delegate] = true
43
+ elsif arg == '--port'
44
+ expect_option = true
45
+ option_name = :port
46
+ elsif arg == '--addr' or arg == '--bind'
47
+ expect_option = true
48
+ option_name = :addr
49
+ elsif arg == '--http-delayed-start' or arg == '--delayed-start'
50
+ expect_option = true
51
+ option_name = :http_delayed_start
52
+ elsif arg == '--server'
53
+ expect_option = true
54
+ option_name = :server
55
+ elsif arg == '--conf' or arg == '--config'
56
+ expect_option = true
57
+ option_name = :conf_files
58
+ elsif arg == '--reset-sessions'
59
+ set_reset_ses
60
+ elsif arg == '--auto-update'
61
+ set_autoupdate
62
+ elsif arg == '--latency'
63
+ expect_option = true
64
+ option_name = :latency
65
+ elsif arg == '--say'
66
+ set_say
67
+ elsif arg == '--disable-gzip'
68
+ @args[:client_pkg_no_gzip] = true
69
+ elsif arg == '--disable-obfuscation'
70
+ @args[:client_pkg_no_obfuscation] = true
71
+ elsif arg == '--disable-jsmin'
72
+ @args[:client_pkg_no_whitespace_removel] = true
73
+ elsif arg == '--build-report'
74
+ @args[:suppress_build_messages] = false
75
+ else
76
+ invalid_option(arg)
77
+ end
78
+ elsif arg.start_with?('-')
79
+ arg.split('')[1..-1].each do |chr|
80
+ if chr == 'd'
81
+ set_debug
82
+ elsif chr == 'v'
83
+ set_verbose
84
+ elsif chr == 'f'
85
+ set_log_fg
86
+ elsif chr == 'r'
87
+ set_reset_ses
88
+ elsif chr == 'a'
89
+ set_autoupdate
90
+ elsif chr == 'S'
91
+ set_say
92
+ else
93
+ invalid_option(arg,chr)
94
+ end
95
+ end
96
+ elsif valid_env?(arg)
97
+ @args[:env_path] = File.expand_path(arg)
98
+ @args[:conf_files].push( File.expand_path( File.join( arg, 'conf', 'config.yaml' ) ) )
99
+ else
100
+ invalid_env( arg )
101
+ end
102
+ end
103
+ end
104
+ if expect_option
105
+ puts ERB.new( @strs[:messages][:no_value_for_option] ).result( binding )
106
+ exit
107
+ end
108
+ end
109
+ if valid_env?(@args[:env_path])
110
+ conf_file = File.expand_path( File.join( @args[:env_path], 'conf', 'config.yaml' ) )
111
+ @args[:conf_files].unshift( conf_file ) unless @args[:conf_files].include?( conf_file )
112
+ else
113
+ invalid_env
114
+ end
115
+ @startable = true
116
+ end
117
+ end
118
+ end