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
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -1,33 +0,0 @@
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
-
10
- /*** = Description
11
- ** Menu item for the HMiniMenu component.
12
- ***/
13
- var//RSence.Menus
14
- HMiniMenuItem = HRadioButton.extend({
15
-
16
- componentName: 'minimenuitem',
17
-
18
- defaultEvents: {
19
- click: true,
20
- mouseUp: true
21
- },
22
-
23
- click: function(){
24
- this.base();
25
- EVENT.changeActiveControl(this.parent.parent);
26
- },
27
-
28
- mouseUp: function(){
29
- this.base();
30
- this.click();
31
- }
32
-
33
- });
File without changes
data/js/util/sha/js.inc DELETED
File without changes
File without changes
File without changes
File without changes
data/lib/conf/argv.rb DELETED
@@ -1,880 +0,0 @@
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
- # Includes the Signal Communication utility.
10
- # Used to respond via special PID files in the run directory of the environment
11
- require 'daemon/sigcomm'
12
-
13
-
14
- module RSence
15
-
16
- # @private Returns true, if platform fully supports POSIX standard signals.
17
- def self.pid_support?
18
- # true for non-windows
19
- return (not ['i386-mingw32','x86-mingw32'].include?(RUBY_PLATFORM))
20
- end
21
-
22
- # @private Returns true, if platform is linux
23
- def self.linux?
24
- return RUBY_PLATFORM.end_with?('-linux')
25
- end
26
-
27
- # @private Returns true, if platform is Mac OS X
28
- def self.darwin?
29
- return RUBY_PLATFORM.include?('-darwin')
30
- end
31
-
32
- # @private Returns signal name that resembles INFO or PWR (extra signal to poll for server status)
33
- def self.info_signal_name
34
- if self.linux?
35
- return 'PWR'
36
- else
37
- return 'INFO'
38
- end
39
- end
40
-
41
- # @private ARGVParser is the "user interface" as a command-line argument parser.
42
- # It parses the command-line arguments and sets up things accordingly.
43
- class ARGVParser
44
-
45
- # The RSence version string, read from the VERSION file in
46
- # the root directory of RSence.
47
- @@version = File.read( File.join( SERVER_PATH, 'VERSION' ) ).strip
48
-
49
- # Makes various commands available depending on the platform.
50
- # The status/start/stop/restart/save -commands depend on an operating
51
- # system that fully implements POSIX standard signals.
52
- # These are necessary to send signals to the background process.
53
- if not RSence.pid_support?
54
- @@cmds = [ :run, :init, :initenv, :version, :help ]
55
- else
56
- @@cmds = [ :run, :status, :start, :stop, :restart, :save,
57
- :init, :initenv, :version, :help ]
58
- end
59
-
60
- help_avail_cmds = @@cmds.map{|cmd|cmd.to_s}.join("\n ")
61
-
62
- # Load the strings from the strings file.
63
- strs_path = File.join( SERVER_PATH, 'conf',
64
- 'rsence_command_strings.yaml' )
65
- strs_data = File.read( strs_path )
66
- require 'erb'
67
-
68
- strs_data = ERB.new( strs_data ).result( binding )
69
-
70
- require 'yaml'
71
- @@strs = YAML.load( strs_data )
72
-
73
- @@strs[:help][:run] += @@strs[:help][:path]+@@strs[:help][:options]
74
- @@strs[:help][:start] += @@strs[:help][:path]+@@strs[:help][:options]
75
- @@strs[:help][:stop] += @@strs[:help][:path]+@@strs[:help][:options]
76
- @@strs[:help][:restart] += @@strs[:help][:path]+@@strs[:help][:options]
77
- @@strs[:help][:status] += @@strs[:help][:path]
78
- @@strs[:help][:save] += @@strs[:help][:path]
79
-
80
-
81
- # Returns true if one of the 'start' -type commands were supplied
82
- # and the environment seems valid.
83
- def startable?; @startable; end
84
-
85
- # Parses an argument of the 'help' command
86
- def parse_help_argv
87
- if @argv.length >= 2
88
- help_cmd = @argv[1].to_sym
89
- else
90
- help_cmd = :help_main
91
- end
92
- help( help_cmd )
93
- exit
94
- end
95
-
96
- # Creates the default and initial @args hash.
97
- def init_args
98
- @args = {
99
- :env_path => Dir.pwd,
100
- :conf_files => [ ], # --conf
101
- :debug => false, # -d --debug
102
- :verbose => false, # -v --verbose
103
- :log_fg => false, # -f --log-fg
104
- :trace_js => false, # --trace-js
105
- :trace_delegate => false, # --trace-delegate
106
- :port => nil, # --port
107
- :addr => nil, # --addr --bind
108
- :server => nil, # --server
109
- :reset_ses => false, # -r --reset-sessions
110
- :autoupdate => false, # -a --auto-update
111
- :latency => 0, # --latency
112
- :say => false, # -S --say
113
-
114
- # client_pkg (not supported yet)
115
- :client_pkg_no_gzip => false, # --build-no-gzip
116
- :client_pkg_no_obfuscation => false, # --build-no-obfuscation
117
- :client_pkg_no_whitespace_removal => false, # --build-keep-whitespace
118
- :client_pkg_quiet => true, # --build-verbose
119
-
120
- }
121
- end
122
-
123
- # Main argument parser for all 'start' -type commands.
124
- def parse_startup_argv
125
- init_args
126
- expect_option = false
127
- option_name = false
128
- if @argv.length >= 2
129
- @argv[1..-1].each_with_index do |arg,i|
130
- if expect_option
131
- if [:port,:latency].include?(option_name) and arg.to_i.to_s != arg
132
- puts ERB.new( @@strs[:messages][:invalid_option_expected_number] ).result( binding )
133
- exit
134
- elsif option_name == :conf_files
135
- if not File.exists?( arg ) or not File.file?( arg )
136
- puts ERB.new( @@strs[:messages][:no_such_configuration_file] ).result( binding )
137
- exit
138
- else
139
- @args[:conf_files].push( arg )
140
- end
141
- else
142
- arg = arg.to_i if option_name == :latency
143
- @args[option_name] = arg
144
- end
145
- expect_option = false
146
- else
147
- if arg.start_with?('--')
148
- if arg == '--profile'
149
- true
150
- elsif arg == '--debug'
151
- set_debug
152
- elsif arg == '--verbose'
153
- set_verbose
154
- elsif arg == '--log-fg'
155
- set_log_fg
156
- elsif arg == '--trace-js'
157
- @args[:trace_js] = true
158
- elsif arg == '--trace-delegate'
159
- @args[:trace_delegate] = true
160
- elsif arg == '--port'
161
- expect_option = true
162
- option_name = :port
163
- elsif arg == '--addr'
164
- expect_option = true
165
- option_name = :addr
166
- elsif arg == '--server'
167
- expect_option = true
168
- option_name = :server
169
- elsif arg == '--conf' or arg == '--config'
170
- expect_option = true
171
- option_name = :conf_files
172
- elsif arg == '--reset-sessions'
173
- set_reset_ses
174
- elsif arg == '--auto-update'
175
- set_autoupdate
176
- elsif arg == '--latency'
177
- expect_option = true
178
- option_name = :latency
179
- elsif arg == '--say'
180
- set_say
181
- else
182
- invalid_option(arg)
183
- end
184
- elsif arg.start_with?('-')
185
- arg.split('')[1..-1].each do |chr|
186
- if chr == 'd'
187
- set_debug
188
- elsif chr == 'v'
189
- set_verbose
190
- elsif chr == 'f'
191
- set_log_fg
192
- elsif chr == 'r'
193
- set_reset_ses
194
- elsif chr == 'a'
195
- set_autoupdate
196
- elsif chr == 'S'
197
- set_say
198
- else
199
- invalid_option(arg,chr)
200
- end
201
- end
202
- elsif valid_env?(arg)
203
- @args[:env_path] = File.expand_path(arg)
204
- @args[:conf_files].push( File.expand_path( File.join( arg, 'conf', 'config.yaml' ) ) )
205
- else
206
- invalid_env( arg )
207
- end
208
- end
209
- end
210
- if expect_option
211
- puts ERB.new( @@strs[:messages][:no_value_for_option] ).result( binding )
212
- exit
213
- end
214
- end
215
- if valid_env?(@args[:env_path])
216
- conf_file = File.expand_path( File.join( @args[:env_path], 'conf', 'config.yaml' ) )
217
- @args[:conf_files].push( conf_file ) unless @args[:conf_files].include?( conf_file )
218
- else
219
- invalid_env
220
- end
221
- @startable = true
222
- end
223
-
224
- # Sets various debug-related options on.
225
- def set_debug
226
- @args[:debug] = true
227
- @args[:verbose] = true
228
- @args[:autoupdate] = true
229
- @args[:client_pkg_no_obfuscation] = true
230
- @args[:client_pkg_no_whitespace_removal] = true
231
- @args[:client_pkg_quiet] = false
232
- end
233
-
234
- # Set the verbose argument on
235
- def set_verbose
236
- @args[:verbose] = true
237
- end
238
-
239
- # Set the foreground logging argument on
240
- def set_log_fg
241
- @args[:log_fg] = true
242
- end
243
-
244
- # Sets the session reset argument on
245
- def set_reset_ses
246
- @args[:reset_ses] = true
247
- end
248
-
249
- # Sets the auto-update argument on
250
- def set_autoupdate
251
- @args[:autoupdate] = true
252
- end
253
-
254
- # Sets the speech synthesis argument on
255
- def set_say
256
- @args[:say] = true
257
- end
258
-
259
- # Tests for a valid environment
260
- def valid_env?( arg, quiet=false )
261
-
262
- # Checks, if the top-level path exists and is a directory
263
- path = File.expand_path( arg )
264
- if not File.exists?( path )
265
- puts ERB.new( @@strs[:messages][:no_such_directory] ).result( binding ) unless quiet
266
- return false
267
- elsif not File.directory?( path )
268
- puts ERB.new( @@strs[:messages][:not_a_directory] ).result( binding ) unless quiet
269
- return false
270
- end
271
-
272
- # Checks, if the conf path exists and is a directory
273
- conf_path = File.join( path, 'conf' )
274
- if not File.exists?( conf_path )
275
- puts ERB.new( @@strs[:messages][:missing_conf_directory] ).result( binding ) unless quiet
276
- return false
277
- elsif not File.directory?( conf_path )
278
- puts ERB.new( @@strs[:messages][:invalid_conf_directory] ).result( binding ) unless quiet
279
- return false
280
- end
281
-
282
- # Checks, if the conf/config.yaml file exists and is a directory
283
- conf_file = File.join( path, 'conf', 'config.yaml' )
284
- if not File.exists?(conf_file)
285
- puts ERB.new( @@strs[:messages][:missing_conf_file] ).result( binding ) unless quiet
286
- return false
287
- elsif not File.file?( conf_file )
288
- puts ERB.new( @@strs[:messages][:invalid_conf_file_not_file] ).result( binding ) unless quiet
289
- return false
290
- end
291
-
292
- # Checks, if the plugins path exists and is a directory
293
- plugin_path = File.join( path, 'plugins' )
294
- if not File.exists?( plugin_path )
295
- warn ERB.new( @@strs[:messages][:warn_no_plugin_directory_in_project] ).result( binding ) if @args[:verbose]
296
- elsif not File.directory?( plugin_path )
297
- puts ERB.new( @@strs[:messages][:plugin_directory_not_a_directory] ).result( binding ) unless quiet
298
- return false
299
- end
300
-
301
- # Checks (and automatically creates if missing) the run, db and log directories
302
- ['run','log','db'].each do |dir_name|
303
- dir_path = File.join( path, dir_name )
304
- unless File.exists?( dir_path )
305
- warn ERB.new( @@strs[:messages][:warn_no_directory_creating] ).result( binding ) if @args[:verbose]
306
- Dir.mkdir( dir_path )
307
- end
308
- end
309
- return true
310
- end
311
-
312
- # Error message when an invalid environment is encountered, exits.
313
- def invalid_env( env_path=false )
314
- env_path = @args[:env_path] unless env_path
315
- puts ERB.new( @@strs[:messages][:invalid_environment] ).result( binding )
316
- exit
317
- end
318
-
319
- # Error message when an invalid option is encountered, exits.
320
- def invalid_option(arg,chr=false)
321
- if chr
322
- puts ERB.new( @@strs[:messages][:invalid_option_chr] ).result( binding )
323
- else
324
- puts ERB.new( @@strs[:messages][:invalid_option] ).result( binding )
325
- end
326
- exit
327
- end
328
-
329
- # Tests, if the port on addr responds or refuses the connection.
330
- # Automatically replaces '0.0.0.0' with '127.0.0.1'
331
- def test_port( port, addr='127.0.0.1' )
332
- require 'socket'
333
- begin
334
- addr = '127.0.0.1' if addr == '0.0.0.0'
335
- if RUBY_VERSION.to_f >= 1.9
336
- sock = TCPSocket.open( addr, port )
337
- else
338
- begin
339
- sock = TCPsocket.open( addr, port )
340
- rescue NameError => e
341
- warn "TCPsocket not available, trying TCPSocket.."
342
- sock = TCPSocket.open( addr, port )
343
- end
344
- end
345
- sock.close
346
- return true
347
- rescue Errno::ECONNREFUSED
348
- return false
349
- rescue => e
350
- warn e.inspect
351
- return false
352
- end
353
- end
354
-
355
- # Main argument parser for the status command, sends the INFO (or PWR on linux) POSIX signal to
356
- # the process, if running.
357
- # Checks if the process responds on the port and address it's configured for.
358
- def parse_status_argv
359
- init_args
360
- expect_option = false
361
- option_name = false
362
- if @argv.length >= 2
363
- @argv[1..-1].each_with_index do |arg,i|
364
- if expect_option
365
- if [:port].include?(option_name) and arg.to_i.to_s != arg
366
- puts ERB.new( @@strs[:messages][:invalid_option_expected_number] ).result( binding )
367
- exit
368
- elsif option_name == :conf_files
369
- if not File.exists?( arg ) or not File.file?( arg )
370
- puts ERB.new( @@strs[:messages][:no_such_configuration_file] ).result( binding )
371
- exit
372
- else
373
- @args[:conf_files].push( arg )
374
- end
375
- else
376
- @args[option_name] = arg
377
- end
378
- expect_option = false
379
- else
380
- if arg.start_with?('--')
381
- if arg == '--debug'
382
- set_debug
383
- elsif arg == '--verbose'
384
- set_verbose
385
- elsif arg == '--port'
386
- expect_option = true
387
- option_name = :port
388
- elsif arg == '--addr'
389
- expect_option = true
390
- option_name = :addr
391
- elsif arg == '--conf' or arg == '--config'
392
- expect_option = true
393
- option_name = :conf_files
394
- else
395
- invalid_option(arg)
396
- end
397
- elsif arg.start_with?('-')
398
- arg.split('')[1..-1].each do |chr|
399
- if chr == 'd'
400
- set_debug
401
- elsif chr == 'v'
402
- set_verbose
403
- else
404
- invalid_option(arg,chr)
405
- end
406
- end
407
- elsif valid_env?(arg)
408
- @args[:env_path] = File.expand_path(arg)
409
- @args[:conf_files].push( File.expand_path( File.join( arg, 'conf', 'config.yaml' ) ) )
410
- else
411
- invalid_env( arg )
412
- end
413
- end
414
- end
415
- if expect_option
416
- puts ERB.new( @@strs[:messages][:no_value_for_option] ).result( binding )
417
- exit
418
- end
419
- end
420
- if valid_env?(@args[:env_path])
421
- conf_file = File.expand_path( File.join( @args[:env_path], 'conf', 'config.yaml' ) )
422
- @args[:conf_files].push( conf_file ) unless @args[:conf_files].include?( conf_file )
423
- else
424
- invalid_env
425
- end
426
- require 'conf/default'
427
- config = Configuration.new(@args).config
428
- port = config[:http_server][:port]
429
- addr = config[:http_server][:bind_address]
430
- port_status = test_port( port, addr )
431
- if RSence.pid_support?
432
- pid_fn = config[:daemon][:pid_fn]
433
- if File.exists?( pid_fn )
434
- pid = File.read( pid_fn ).to_i
435
- sig_name = RSence.info_signal_name
436
- pid_status = RSence::SIGComm.wait_signal_response(
437
- pid, pid_fn, sig_name, 3
438
- )
439
- else
440
- warn @@strs[:messages][:no_pid_file] if @args[:verbose]
441
- pid_status = nil
442
- end
443
- else
444
- warn @@strs[:messages][:no_pid_support] if @args[:verbose]
445
- pid_status = nil
446
- end
447
- if RSence.pid_support?
448
- if pid_status == nil
449
- puts @@strs[:messages][:no_pid]
450
- elsif pid_status == false
451
- if port_status
452
- puts ERB.new( @@strs[:messages][:no_process_running_but_something_responds] ).result( binding )
453
- else
454
- puts ERB.new( @@strs[:messages][:no_process_running_and_nothing_responds] ).result( binding )
455
- end
456
- else
457
- if port_status
458
- puts ERB.new( @@strs[:messages][:process_running_and_responds] ).result( binding )
459
- else
460
- puts ERB.new( @@strs[:messages][:process_running_but_nothing_responds] ).result( binding )
461
- end
462
- end
463
- end
464
- end
465
-
466
- # Main argument parser for the save command. Sends the USR1 POSIX signal to the process, if running.
467
- def parse_save_argv
468
- init_args
469
- expect_option = false
470
- option_name = false
471
- if @argv.length >= 2
472
- @argv[1..-1].each_with_index do |arg,i|
473
- if expect_option
474
- if option_name == :conf_files
475
- if not File.exists?( arg ) or not File.file?( arg )
476
- puts ERB.new( @@strs[:messages][:no_such_configuration_file] ).result( binding )
477
- exit
478
- else
479
- @args[:conf_files].push( arg )
480
- end
481
- else
482
- @args[option_name] = arg
483
- end
484
- expect_option = false
485
- else
486
- if arg.start_with?('--')
487
- if arg == '--debug'
488
- set_debug
489
- elsif arg == '--verbose'
490
- set_verbose
491
- elsif arg == '--conf' or arg == '--config'
492
- expect_option = true
493
- option_name = :conf_files
494
- else
495
- invalid_option(arg)
496
- end
497
- elsif arg.start_with?('-')
498
- arg.split('')[1..-1].each do |chr|
499
- if chr == 'd'
500
- set_debug
501
- elsif chr == 'v'
502
- set_verbose
503
- else
504
- invalid_option(arg,chr)
505
- end
506
- end
507
- elsif valid_env?(arg)
508
- @args[:env_path] = File.expand_path(arg)
509
- @args[:conf_files].push( File.expand_path( File.join( arg, 'conf', 'config.yaml' ) ) )
510
- else
511
- invalid_env( arg )
512
- end
513
- end
514
- end
515
- if expect_option
516
- puts ERB.new( @@strs[:messages][:no_value_for_option] ).result( binding )
517
- exit
518
- end
519
- end
520
- if valid_env?(@args[:env_path])
521
- conf_file = File.expand_path( File.join( @args[:env_path], 'conf', 'config.yaml' ) )
522
- @args[:conf_files].push( conf_file ) unless @args[:conf_files].include?( conf_file )
523
- else
524
- invalid_env
525
- end
526
- require 'conf/default'
527
- config = Configuration.new(@args).config
528
- if RSence.pid_support?
529
- pid_fn = config[:daemon][:pid_fn]
530
- if File.exists?( pid_fn )
531
- pid = File.read( pid_fn ).to_i
532
- saving_message = @@strs[:messages][:saving_message]
533
- pid_status = RSence::SIGComm.wait_signal_response(
534
- pid, pid_fn, 'USR2', 30, saving_message, '.', 0.1, true
535
- )
536
- else
537
- warn @@strs[:messages][:no_pid_file] if @args[:verbose]
538
- pid_status = nil
539
- end
540
- else
541
- warn @@strs[:messages][:no_pid_support] if @args[:verbose]
542
- pid_status = nil
543
- end
544
- if RSence.pid_support?
545
- if pid_status == nil
546
- puts @@strs[:messages][:no_pid_unable_to_save]
547
- elsif pid_status == false
548
- puts @@strs[:messages][:no_process_running]
549
- else
550
- puts @@strs[:messages][:session_data_saved]
551
- end
552
- end
553
- end
554
-
555
- # asks y/n and returns booleans,
556
- # the default tells if which one is for just enter
557
- def yesno(default=false)
558
- if default
559
- question = "Y/n? "
560
- else
561
- question = "y/N? "
562
- end
563
- print question
564
- answer = $stdin.gets.strip.downcase[0]
565
- answer = answer.chr if answer
566
- if answer == 'n'
567
- return false
568
- elsif answer == 'y'
569
- return true
570
- elsif answer == nil
571
- return default
572
- else
573
- return nil
574
- end
575
- end
576
-
577
- # The initenv command and its parser. Asks questions about the environment before doing anything else.
578
- def parse_initenv_argv
579
- init_args
580
- expect_option = false
581
- option_name = false
582
- valid_env = false
583
- interactive = true
584
- create_blank = false
585
- if @argv.length >= 2
586
- @argv[1..-1].each_with_index do |arg,i|
587
- if expect_option
588
- if [:port].include?(option_name) and arg.to_i.to_s != arg
589
- puts ERB.new( @@strs[:messages][:invalid_option_expected_number] ).result( binding )
590
- exit
591
- else
592
- @args[option_name] = arg
593
- end
594
- expect_option = false
595
- else
596
- if arg.start_with?('--')
597
- if arg == '--port'
598
- expect_option = true
599
- option_name = :port
600
- elsif arg == '--addr'
601
- expect_option = true
602
- option_name = :addr
603
- elsif arg == '--server'
604
- expect_option = true
605
- option_name = :server
606
- elsif arg == '--title'
607
- expect_option = true
608
- option_name = :title
609
- elsif arg == '--database'
610
- expect_option = true
611
- option_name = :db
612
- elsif arg == '--uri-prefix'
613
- expect_option = true
614
- option_name = :base_url
615
- elsif arg == '--blank'
616
- create_blank = true
617
- elsif arg == '--non-interactive'
618
- interactive = false
619
- else
620
- invalid_option(arg)
621
- end
622
- elsif arg.start_with?('-')
623
- arg.split('')[1..-1].each do |chr|
624
- if chr == 'q'
625
- interactive = false
626
- end
627
- end
628
- else
629
- @args[:env_path] = File.expand_path(arg)
630
- end
631
- end
632
- end
633
- if expect_option
634
- puts ERB.new( @@strs[:messages][:no_value_for_option] ).result( binding )
635
- exit
636
- end
637
- end
638
- if valid_env?(@args[:env_path],true)
639
- puts @@strs[:initenv][:env_already_initialized]
640
- exit
641
- end
642
- conf_file = File.expand_path( File.join( @args[:env_path], 'conf', 'config.yaml' ) )
643
- if File.exists?(@args[:env_path])
644
- if Dir.entries(@args[:env_path]).length > 2 # [ '.', '..' ]
645
- puts ERB.new( @@strs[:initenv][:env_not_empty] ).result( binding )
646
- exit
647
- end
648
- end
649
-
650
- require 'conf/default'
651
- default_config = Configuration.new(@args,true).config
652
-
653
- config = {
654
- :base_url => (@args[:base_url] or default_config[:base_url]),
655
- :http_server => {
656
- :port => (@args[:port] or default_config[:http_server][:port]),
657
- :bind_address => (@args[:addr] or default_config[:http_server][:bind_address]),
658
- :rack_require => (@args[:server] or default_config[:http_server][:rack_require])
659
- },
660
- :index_html => {
661
- :title => (@args[:title] or default_config[:index_html][:title])
662
- },
663
- :database => {
664
- :ses_db => (@args[:db] or default_config[:database][:ses_db])
665
- }
666
- }
667
- Signal.trap 'INT' do
668
- puts
669
- puts "Configuration aborted."
670
- exit
671
- end
672
- if interactive
673
- answers_ok = false
674
- until answers_ok
675
- puts ERB.new( @@strs[:initenv][:creating_env] ).result( binding )
676
-
677
- require 'highline/import'
678
-
679
- say @@strs[:initenv][:enter_title]
680
- str_project_title = @@strs[:initenv][:project_title]
681
- config[:index_html][:title] = ask( str_project_title ) do |q|
682
- q.default = config[:index_html][:title]
683
- end
684
-
685
- say @@strs[:initenv][:enter_db_url]
686
- str_db_url = @@strs[:initenv][:db_url]
687
- config[:database][:ses_db] = ask(str_db_url) do |q|
688
- q.default = config[:database][:ses_db]
689
- end
690
-
691
- say @@strs[:initenv][:enter_http_port]
692
- str_http_port = @@strs[:initenv][:http_port]
693
- config[:http_server][:port] = ask(str_http_port) do |q|
694
- q.default = config[:http_server][:port]
695
- end
696
-
697
- say @@strs[:initenv][:enter_tcp_ip]
698
- str_tcp_ip = @@strs[:initenv][:tcp_ip]
699
- config[:http_server][:bind_address] = ask(str_tcp_ip) do |q|
700
- q.default = config[:http_server][:bind_address]
701
- end
702
-
703
- say @@strs[:initenv][:enter_root_dir]
704
- str_root_dir = @@strs[:initenv][:root_dir]
705
- config[:base_url] = ask(str_root_dir) do |q|
706
- q.default = config[:base_url]
707
- end
708
-
709
- test_url = "http://#{config[:http_server][:bind_address]}:#{config[:http_server][:port]}#{config[:base_url]}"
710
- say ERB.new( @@strs[:initenv][:config_summary] ).result( binding )
711
- print @@strs[:initenv][:confirm_config]
712
- answers_ok = yesno(true)
713
- end
714
- else
715
- test_url = "http://#{config[:http_server][:bind_address]}:#{config[:http_server][:port]}#{config[:base_url]}"
716
- end
717
-
718
- puts @@strs[:initenv][:creating_dirs]
719
- env_dir = @args[:env_path]
720
- require 'fileutils'
721
- FileUtils.mkdir_p( env_dir ) unless File.exists?( env_dir )
722
- conf_dir = File.expand_path( 'conf', env_dir )
723
- Dir.mkdir( conf_dir )
724
- db_dir = File.expand_path( 'db', env_dir )
725
- Dir.mkdir( db_dir )
726
- log_dir = File.expand_path( 'log', env_dir )
727
- Dir.mkdir( log_dir )
728
- plugins_dir = File.expand_path( 'plugins', env_dir )
729
- Dir.mkdir( plugins_dir )
730
- run_dir = File.expand_path( 'run', env_dir )
731
- Dir.mkdir( run_dir )
732
- unless create_blank
733
- print @@strs[:initenv][:install_welcome]
734
- if yesno(true)
735
- welcome_plugin_dir = File.join( SERVER_PATH, 'setup', 'welcome' )
736
- welcome_plugin_dst = File.join( plugins_dir, 'welcome' )
737
- puts ERB.new( @@strs[:initenv][:installing_welcome_plugin] ).result( binding )
738
- FileUtils.cp_r( welcome_plugin_dir, welcome_plugin_dst )
739
- end
740
- end
741
- puts @@strs[:initenv][:creating_files]
742
- conf_file = File.join( conf_dir, 'config.yaml' )
743
- File.open( conf_file, 'w' ) {|f| f.write( YAML.dump( config ) ) }
744
- readme_file = File.join( env_dir, 'README' )
745
- File.open( readme_file, 'w' ) {|f| f.write( ERB.new( @@strs[:initenv][:readme] ).result( binding ) ) }
746
- version_file = File.join( env_dir, 'VERSION' )
747
- File.open( version_file, 'w' ) {|f| f.write( "RSence Environment Version #{version.to_f}" ) }
748
- puts ERB.new( @@strs[:initenv][:congratulations] ).result( binding )
749
- exit
750
- end
751
-
752
- # Main parser for the help command
753
- def help( cmd )
754
- cmd.to_sym! if cmd.class != Symbol
755
- puts @@strs[:help][:head]
756
- if @@strs[:help].has_key?(cmd)
757
- puts @@strs[:help][cmd]
758
- else
759
- puts @@strs[:help][:help_main]
760
- end
761
- puts @@strs[:help][:tail]
762
- end
763
-
764
- # Returns the version of RSence
765
- def version
766
- @@version
767
- end
768
-
769
- # Returns the command the process was started with.
770
- def cmd
771
- @cmd
772
- end
773
-
774
- # Returns the parsed optional arguments
775
- def args
776
- @args
777
- end
778
-
779
- # Top-level argument parser, checks for command and calls sub-parser, if valid command.
780
- def parse_argv
781
- if @argv.empty?
782
- puts @@strs[:help][:help_help]
783
- exit
784
- else
785
- cmd = @argv[0].to_sym
786
- cmd = :help if [:h, :'-h', :'--help', :'-help'].include? cmd
787
- end
788
- if @@cmds.include?(cmd)
789
- @cmd = cmd
790
- if cmd == :help
791
- parse_help_argv
792
- elsif cmd == :version
793
- puts version
794
- exit
795
- elsif [:run,:start,:stop,:restart].include? cmd
796
- parse_startup_argv
797
- elsif cmd == :status
798
- parse_status_argv
799
- elsif cmd == :save
800
- parse_save_argv
801
- elsif cmd == :initenv or cmd == :init
802
- parse_initenv_argv
803
- end
804
- else
805
- puts @@strs[:help][:unknown] + cmd.to_s.inspect
806
- puts @@strs[:help][:help_help]
807
- exit
808
- end
809
- end
810
-
811
- # Entry point for ARGV parsing
812
- def parse( argv )
813
- @argv = argv
814
- @startable = false
815
- parse_argv
816
- end
817
-
818
- # The constructor sets the @startable flag as false. Use the #parse method with ARGV as the argument to start parsing the ARGV.
819
- def initialize
820
- @startable = false
821
- end
822
-
823
- end
824
-
825
- # @private This accessor enables RSence.argv method, which returns the ARGVParser instance
826
- def self.argv; @@argv_parser; end
827
-
828
- # @private This accessor enables RSence.cmd method, which returns the command the process was started with.
829
- def self.cmd; @@argv_parser.cmd; end
830
-
831
- # Command line options parsed
832
- # @return [Hash] Parsed command-line options:
833
- # *Key* (Symbol):: *Value*
834
- # +:env_path+:: (String) The directory of the environment.
835
- # +:conf_files+:: (Array of Strings) Additional configuration files given with the +--conf+ command-line option. Default is +[]+.
836
- # +:debug+:: (true or false) True, if the +-d+ or +--debug+ command-line option was given. Default is false.
837
- # +:verbose+:: (true or false) True, if the +-v+ or +--verbose+ command-line option was given. Default is false.
838
- # +:log_fg+:: (true or false) True, if the +-f+ or +--log-fg+ command-line option was given. Default is false.
839
- # +:trace_js+:: (true or false) True, if the +--trace-js+ command-line option was given. Default is false.
840
- # +:trace_delegate+:: (true or false) True, if the +--trace-delegate+ command-line option was given. Default is false.
841
- # +:port+:: (String or nil) The TCP port number given with the +--port+ command-line option. Default is nil.
842
- # +:addr+:: (String or nil) The TCP bind address given with the +--addr+ command-line option. Default is nil.
843
- # +:server+:: (String or nil) The Rack http server handler given with the +--server+ command-line option. Default is nil.
844
- # +:reset_ses+:: (true or false) True, if the +-r+ or +--reset-sessions+ command-line option was given. Default is false.
845
- # +:autoupdate+:: (true or false) True, if the +-a+ or +--auto-update+ command-line option was given. Default is false.
846
- # +:latency+:: (Number) Amount of milliseconds to sleep in each request given with the +--latency+ command-line option. Default is 0.
847
- # +:say+:: (true or false) True, if the +-S+ or +--say+ command-line option was given. Default is false.
848
- def self.args; @@argv_parser.args; end
849
-
850
- # @private This accessor enables RSence.startable? method, which returns true if a start-type command was given.
851
- def self.startable?; @@argv_parser.startable?; end
852
-
853
- # @return [String] The version of RSence
854
- def self.version; @@argv_parser.version; end
855
-
856
- # @private This accessor enables RSence.startup method, which starts RSence.
857
- def self.startup
858
- puts "Loading configuration..." if self.args[:verbose]
859
- # Use the default configuration:
860
- require 'conf/default'
861
- @@config = Configuration.new(self.args).config
862
-
863
- # RSence runtime configuration data
864
- # @return [Hash] the active configuration structure as defined by the {file:default_conf default configuration} and overridden by local configuration files.
865
- def self.config
866
- @@config
867
- end
868
- ## Riassence Daemon controls
869
- require 'daemon/daemon'
870
- puts "Starting RSence..." if self.args[:verbose]
871
- daemon = HTTPDaemon.new
872
- daemon.daemonize!
873
- end
874
-
875
- # @private The ARGVParser instance and its startup
876
- @@argv_parser = ARGVParser.new
877
- @@argv_parser.parse( ARGV )
878
-
879
- end
880
-