rsence 2.0.0.10.pre → 2.0.0.11
Sign up to get free protection for your applications and to get access to all the features.
- data/.yardopts +10 -0
- data/INSTALL.rdoc +52 -86
- data/{LICENSE → LICENSE.txt} +0 -0
- data/README.rdoc +52 -49
- data/VERSION +1 -1
- data/bin/rsence +4 -6
- data/conf/default_conf.yaml +314 -305
- data/conf/default_strings.yaml +70 -71
- data/docs/ExampleGuiPlugin.rdoc +193 -0
- data/{js/comm/comm/autosync/js.inc → docs/JavascriptBundles.rdoc} +0 -0
- data/docs/PluginBundleInfo.rdoc +173 -0
- data/docs/PluginBundles.rdoc +96 -0
- data/docs/Values.rdoc +163 -0
- data/js/comm/{comm/autosync → autosync}/autosync.js +1 -2
- data/js/comm/{comm → autosync}/js.inc +0 -0
- data/js/comm/{comm/comm.js → comm.js} +1 -0
- data/js/comm/{comm/queue/js.inc → js.inc} +0 -0
- data/js/comm/jsloader/jsloader.js +2 -4
- data/js/comm/{comm/session → queue}/js.inc +0 -0
- data/js/comm/{comm/queue → queue}/queue.js +1 -0
- data/js/comm/{comm/sessionwatcher → session}/js.inc +0 -0
- data/js/comm/{comm/session → session}/session.js +4 -3
- data/js/comm/{comm/transporter → sessionwatcher}/js.inc +0 -0
- data/js/comm/{comm/sessionwatcher → sessionwatcher}/sessionwatcher.js +1 -0
- data/js/comm/{comm/urlresponder → transporter}/js.inc +0 -0
- data/js/comm/{comm/transporter → transporter}/transporter.js +1 -0
- data/js/comm/{comm/values → urlresponder}/js.inc +0 -0
- data/js/comm/{comm/urlresponder → urlresponder}/urlresponder.js +1 -0
- data/js/comm/{reloadapp → values}/js.inc +0 -0
- data/js/comm/{comm/values → values}/values.js +1 -0
- data/js/controls/button/button.js +10 -1
- data/js/controls/checkbox/checkbox.js +2 -0
- data/js/controls/dialogs/alert_sheet/alert_sheet.js +1 -0
- data/js/controls/dialogs/confirm_sheet/confirm_sheet.js +1 -0
- data/js/controls/dialogs/sheet/sheet.js +1 -0
- data/js/controls/imageview/imageview.js +1 -0
- data/js/controls/passwordcontrol/passwordcontrol.js +1 -0
- data/js/controls/progress/progressbar/progressbar.js +1 -0
- data/js/controls/progress/progressindicator/progressindicator.js +1 -0
- data/js/controls/radiobutton/radiobutton.js +3 -1
- data/js/controls/sliders/slider/slider.js +1 -0
- data/js/controls/sliders/vslider/vslider.js +1 -0
- data/js/controls/stepper/stepper.js +1 -0
- data/js/controls/stringview/stringview.js +2 -2
- data/js/controls/tab/tab.js +7 -5
- data/js/controls/textarea/textarea.js +1 -0
- data/js/controls/textcontrol/textcontrol.js +3 -1
- data/js/controls/uploader/uploader.js +1 -0
- data/js/controls/validatorview/validatorview.js +62 -59
- data/js/controls/window/window.js +1 -0
- data/js/core/class/class.js +2 -1
- data/js/core/elem/elem.js +27 -27
- data/js/core/event/event.js +3 -874
- data/js/{comm/sha → core/rsence_ns}/js.inc +0 -0
- data/js/core/rsence_ns/rsence_ns.js +15 -0
- data/js/{controls/datetime → datetime}/calendar/calendar.js +1 -0
- data/js/{comm/values/value → datetime/calendar}/js.inc +0 -0
- data/js/{controls/datetime → datetime}/calendar/themes/default/calendar.css +0 -0
- data/js/{controls/datetime → datetime}/calendar/themes/default/calendar.html +0 -0
- data/js/{controls/datetime → datetime}/calendar/themes/default/calendar_arrows-ie6.gif +0 -0
- data/js/{controls/datetime → datetime}/calendar/themes/default/calendar_arrows.png +0 -0
- data/js/{controls/datetime → datetime}/datetimevalue/datetimevalue.js +1 -0
- data/js/{comm/values/valuematrix → datetime/datetimevalue}/js.inc +0 -0
- data/js/{controls/datetime/calendar → datetime/timesheet}/js.inc +0 -0
- data/js/{controls/datetime → datetime}/timesheet/themes/default/timesheet.css +0 -0
- data/js/{controls/datetime → datetime}/timesheet/themes/default/timesheet.html +0 -0
- data/js/{controls/datetime → datetime}/timesheet/timesheet.js +1 -0
- data/js/{controls/datetime/datetimevalue → datetime/timesheet_item}/js.inc +0 -0
- data/js/{controls/datetime → datetime}/timesheet_item/themes/default/timesheet_item.css +0 -0
- data/js/{controls/datetime → datetime}/timesheet_item/themes/default/timesheet_item.html +0 -0
- data/js/{controls/datetime → datetime}/timesheet_item/timesheet_item.js +1 -0
- data/js/{controls/datetime/timesheet → datetime/timesheet_item_edit}/js.inc +0 -0
- data/js/{controls/datetime → datetime}/timesheet_item_edit/timesheet_item_edit.js +1 -1
- data/js/foundation/application/application.js +1 -2
- data/js/foundation/control/control.js +1 -4
- data/js/foundation/control/controldefaults/controldefaults.js +1 -4
- data/js/foundation/control/dummyvalue/dummyvalue.js +1 -0
- data/js/foundation/control/dyncontrol/dyncontrol.js +1 -2
- data/js/foundation/control/eventresponder/eventresponder.js +11 -3
- data/js/{controls/datetime/timesheet_item → foundation/control/valuematrix}/js.inc +0 -0
- data/js/{comm/values → foundation/control}/valuematrix/valuematrix.js +2 -5
- data/js/foundation/control/valueresponder/valueresponder.js +3 -1
- data/js/foundation/eventmanager/eventmanager.js +884 -0
- data/js/{controls/datetime/timesheet_item_edit → foundation/eventmanager}/js.inc +0 -0
- data/js/foundation/geom/point/point.js +2 -2
- data/js/foundation/geom/rect/rect.js +1 -0
- data/js/foundation/json_renderer/json_renderer.js +2 -0
- data/js/foundation/system/system.js +2 -1
- data/js/foundation/thememanager/thememanager.js +29 -23
- data/js/{controls/lists/checkboxlist → foundation/value}/js.inc +0 -0
- data/js/{comm/values → foundation}/value/value.js +1 -0
- data/js/foundation/view/markupview/markupview.js +2 -1
- data/js/foundation/view/morphanimation/morphanimation.js +1 -0
- data/js/foundation/view/view.js +6 -12
- data/js/foundation/view/viewdefaults/viewdefaults.js +1 -0
- data/js/{controls/lists → lists}/checkboxlist/checkboxlist.js +1 -0
- data/js/{controls/lists/listitems → lists/checkboxlist}/js.inc +0 -0
- data/js/{controls/lists/radiobuttonlist → lists/listitems}/js.inc +0 -0
- data/js/{controls/lists → lists}/listitems/listitems.js +22 -3
- data/js/lists/radiobuttonlist/js.inc +0 -0
- data/js/{controls/lists → lists}/radiobuttonlist/radiobuttonlist.js +2 -12
- data/js/util/reloadapp/js.inc +0 -0
- data/js/{comm → util}/reloadapp/reloadapp.js +10 -8
- data/js/{comm → util}/reloadapp/themes/default/reloadapp_warning-ie6.gif +0 -0
- data/js/{comm → util}/reloadapp/themes/default/reloadapp_warning.png +0 -0
- data/js/util/sha/js.inc +0 -0
- data/js/{comm → util}/sha/sha.js +27 -33
- data/js/views/centerview/centerview.js +33 -3
- data/js/views/inlineview/inlineview.js +1 -0
- data/js/views/scrollview/scrollview.js +1 -0
- data/lib/conf/argv.rb +34 -22
- data/lib/conf/default.rb +165 -173
- data/lib/daemon/daemon.rb +9 -9
- data/lib/daemon/sigcomm.rb +4 -4
- data/lib/http/broker.rb +30 -27
- data/lib/http/rackup.rb +2 -3
- data/lib/http/request.rb +1 -2
- data/lib/http/response.rb +10 -10
- data/lib/plugins/dependencies.rb +2 -1
- data/lib/plugins/gui_plugin.rb +77 -50
- data/lib/plugins/guiparser.rb +26 -22
- data/lib/plugins/plugin.rb +207 -427
- data/lib/plugins/plugin_base.rb +162 -0
- data/lib/plugins/plugin_plugins.rb +21 -15
- data/lib/plugins/plugin_sqlite_db.rb +45 -20
- data/lib/plugins/pluginmanager.rb +10 -5
- data/lib/plugins/plugins.rb +65 -31
- data/lib/plugins/servlet.rb +74 -26
- data/lib/rsence.rb +32 -0
- data/lib/session/msg.rb +131 -96
- data/lib/session/sessionmanager.rb +5 -4
- data/lib/session/sessionstorage.rb +4 -3
- data/lib/transporter/transporter.rb +30 -21
- data/lib/util/gzstring.rb +4 -2
- data/lib/util/ruby19_fixes.rb +18 -0
- data/lib/values/hvalue.rb +139 -88
- data/lib/values/valuemanager.rb +60 -46
- data/plugins/client_pkg/client_pkg.rb +6 -5
- data/plugins/client_pkg/lib/client_pkg_build.rb +5 -5
- data/plugins/client_pkg/lib/client_pkg_serve.rb +8 -0
- data/plugins/index_html/index_html.rb +3 -1
- data/plugins/index_html/tmpl/index.html +2 -3
- data/plugins/main/js/main.js +84 -0
- data/plugins/main/main.rb +54 -27
- data/plugins/ticket/lib/common.rb +4 -2
- data/plugins/ticket/lib/favicon.rb +3 -2
- data/plugins/ticket/lib/file.rb +2 -2
- data/plugins/ticket/lib/img.rb +2 -2
- data/plugins/ticket/lib/objblob.rb +2 -2
- data/plugins/ticket/lib/rsrc.rb +2 -2
- data/plugins/ticket/lib/upload.rb +9 -8
- data/plugins/ticket/ticket.rb +141 -8
- data/setup/welcome/welcome.rb +1 -0
- metadata +76 -72
- data/lib/plugins/plugin_util.rb +0 -107
- data/plugins/index_html/tmpl/startup_index.html +0 -29
- data/plugins/main/js/riassence_ns.js +0 -87
- data/setup/legacy/info.yaml +0 -18
- data/setup/legacy/legacy.rb +0 -17
- data/setup/welcome/gui/welcome.yaml +0 -68
- data/setup/welcome/text/welcome.html +0 -8
data/conf/default_strings.yaml
CHANGED
@@ -1,77 +1,76 @@
|
|
1
1
|
|
2
|
+
# Default string configuration file
|
2
3
|
|
3
|
-
#
|
4
|
+
# System message strings
|
5
|
+
:messages:
|
4
6
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
:
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
:
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
:
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
:
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
:
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
:
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
:
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
:
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
:
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
:
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
:title: 'PluginIdleError'
|
73
|
-
:descr: 'The idle event failed for a plugin with error:'
|
74
|
-
:uri: '/'
|
7
|
+
:transporter:
|
8
|
+
#
|
9
|
+
# If the client fails on javascript, display this:
|
10
|
+
:client_error:
|
11
|
+
:title: 'ClientError'
|
12
|
+
:descr: 'Javascript execution error:'
|
13
|
+
:uri: '/'
|
14
|
+
#
|
15
|
+
# If the filecache fails, display this:
|
16
|
+
:filecache_error:
|
17
|
+
:title: 'FileCacheError'
|
18
|
+
:descr: 'FileCache failed with error:'
|
19
|
+
:uri: '/'
|
20
|
+
#
|
21
|
+
# If the plugins rescan fails, display this:
|
22
|
+
:plugins_rescan_error:
|
23
|
+
:title: 'PluginsRescanError'
|
24
|
+
:descr: 'The initialization of a plugin failed with error:'
|
25
|
+
:uri: '/'
|
26
|
+
#
|
27
|
+
# If the plugins rescan fails, display this:
|
28
|
+
:valuemanager_xhr_error:
|
29
|
+
:title: 'ValueSyncError'
|
30
|
+
:descr: 'Data value synchronization failed with error:'
|
31
|
+
:uri: '/'
|
32
|
+
#
|
33
|
+
# If the plugins rescan fails, display this:
|
34
|
+
:valuemanager_validate_error:
|
35
|
+
:title: 'ValueValidationError'
|
36
|
+
:descr: 'The value validation failed with error:'
|
37
|
+
:uri: '/'
|
38
|
+
#
|
39
|
+
# If the plugins rescan fails, display this:
|
40
|
+
:valuemanager_sync_client_error:
|
41
|
+
:title: 'SyncClientError'
|
42
|
+
:descr: 'The value synchronization to the client failed with error:'
|
43
|
+
:uri: '/'
|
44
|
+
#
|
45
|
+
# If the plugins rescan fails, display this:
|
46
|
+
:plugin_delegate_restore_ses_error:
|
47
|
+
:title: 'RestoreSesError'
|
48
|
+
:descr: 'The plugin delegation process for restore_ses failed with error:'
|
49
|
+
:uri: '/'
|
50
|
+
#
|
51
|
+
# If the plugins rescan fails, display this:
|
52
|
+
:plugin_delegate_init_ses_error:
|
53
|
+
:title: 'InitSesError'
|
54
|
+
:descr: 'The plugin delegation process for init_ses failed with error:'
|
55
|
+
:uri: '/'
|
56
|
+
#
|
57
|
+
# If the plugins delegation of the cloned_target event fails, display this:
|
58
|
+
:plugin_delegate_cloned_target_error:
|
59
|
+
:title: 'ClonedTargetError'
|
60
|
+
:descr: 'The plugin delegation process for cloned_target failed with error:'
|
61
|
+
:uri: '/'
|
62
|
+
#
|
63
|
+
# If the plugins delegation of the cloned_source event fails, display this:
|
64
|
+
:plugin_delegate_cloned_source_error:
|
65
|
+
:title: 'ClonedSourceError'
|
66
|
+
:descr: 'The plugin delegation process for cloned_source failed with error:'
|
67
|
+
:uri: '/'
|
68
|
+
#
|
69
|
+
# If the plugins rescan fails, display this:
|
70
|
+
:plugin_idle_error:
|
71
|
+
:title: 'PluginIdleError'
|
72
|
+
:descr: 'The idle event failed for a plugin with error:'
|
73
|
+
:uri: '/'
|
75
74
|
|
76
75
|
|
77
76
|
|
@@ -0,0 +1,193 @@
|
|
1
|
+
= Example: The "welcome" GUIPlugin bundle
|
2
|
+
|
3
|
+
This bundle is installed by default for each new RSence project environment, when created by the +rsence initenv+ command. It displays a simple user interface that contains a congratulatory message of a successful setup. Feel free to experiment with the plugin in your project environment.
|
4
|
+
|
5
|
+
=== File / directory structure
|
6
|
+
This is just an example, the meaning of gui/
|
7
|
+
!!!plain
|
8
|
+
|-- info.yaml
|
9
|
+
|-- values.yaml
|
10
|
+
|-- text
|
11
|
+
| `-- welcome.html
|
12
|
+
|-- gui
|
13
|
+
| `-- welcome.yaml
|
14
|
+
`-- welcome.rb
|
15
|
+
|
16
|
+
=== The +info.yaml+ file of the "welcome" bundle
|
17
|
+
This file defines the meta-information used by RSence to decide the loading order, dependencies and such. This bundle doesn't have any dependencies, so it's just using the default +depends_on: :system+, which means its loaded and called in order after the built-in plugins of RSence.
|
18
|
+
|
19
|
+
The human-readable product name of the bundle
|
20
|
+
!!!yaml
|
21
|
+
title: Welcome message
|
22
|
+
|
23
|
+
The human-readable version of the bundle
|
24
|
+
!!!yaml
|
25
|
+
version: 1.0.0
|
26
|
+
|
27
|
+
A brief description of the package
|
28
|
+
!!!yaml
|
29
|
+
description: |
|
30
|
+
This is a simple welcome message plugin. It's installed in new project
|
31
|
+
environments, when the rsence initenv in executed.
|
32
|
+
You may safely remove this plugin bundle.
|
33
|
+
|
34
|
+
System version requirements. In this case "RSence 2.0.0 or newer"
|
35
|
+
!!!yaml
|
36
|
+
sys_version: '>= 2.0.0'
|
37
|
+
|
38
|
+
=== The +values.yaml+ file of the "welcome" bundle
|
39
|
+
Only two values are used by the "welcome" plugin bundle. One to signal the server the "Close" button is clicked and the other to signal that the "Don't show again" check box is checked.
|
40
|
+
|
41
|
+
The checkbox uses Boolean values and it doesn't need a responder so none is bound. Its default value is false.
|
42
|
+
!!!yaml
|
43
|
+
:dont_show_again:
|
44
|
+
:value: false
|
45
|
+
|
46
|
+
The button (and sheet) in the gui are bound to this value, which defaults to 0 and has the +close_button+ method defined as the responder, which called when the value is changed in the client by clicking the "Close" button.
|
47
|
+
!!!yaml
|
48
|
+
:close:
|
49
|
+
:value: 0
|
50
|
+
:responders:
|
51
|
+
- { :method: close_button }
|
52
|
+
|
53
|
+
=== The +welcome.rb+ source code file of the "welcome" bundle.
|
54
|
+
The code in this file not only define the type and features of the plugin bundle, but also defines a few methods that are triggered.
|
55
|
+
|
56
|
+
The class definition itself, just subclass {RSence::Plugins::GUIPlugin__ GUIPlugin}.
|
57
|
+
class WelcomePlugin < GUIPlugin
|
58
|
+
|
59
|
+
The +gui_params+ method is called by the {RSence::Plugins::GUIParser GUIParser} just before processing the GUITree data. In this case, it's extended to provide not only the values (delivered by the superclass), but also a custom entry, the +:text+ hash with the +:welcome+ member, which is the contents of the +welcome.html+ file inside the +text+ directory of the bundle. The params is accessed using dot notation in Symbol form in the GUITree yaml file.
|
60
|
+
def gui_params( msg )
|
61
|
+
params = super
|
62
|
+
params[:text] = {
|
63
|
+
:welcome => file_read('text/welcome.html')
|
64
|
+
}
|
65
|
+
return params
|
66
|
+
end
|
67
|
+
|
68
|
+
The +close_button+ method is defined as a responder for the +:close+ value defined in the +values.yaml+. It's called when the "Close" button is clicked in the client. If the other value; +:dont_show_again+, has the data value +true+ ("Don't show again" -checkbox is checked), also calls the +disable_self+ method. Finally returns +true+, because the data doesn't need further validation and is good as-is.
|
69
|
+
def close_button( msg, value )
|
70
|
+
dont_show_again = get_ses(msg)[:dont_show_again]
|
71
|
+
if (value.data == 1) and (dont_show_again.data == true)
|
72
|
+
disable_self
|
73
|
+
end
|
74
|
+
return true
|
75
|
+
end
|
76
|
+
|
77
|
+
The +disable_self+ method just disables the "welcome" plugin and tells RSence to unload itself. The "disabled" file means the bundle won't be loaded as long as the file is in place.
|
78
|
+
def disable_self
|
79
|
+
file_write( 'disabled', '' )
|
80
|
+
@plugins.unload_bundle( @name )
|
81
|
+
end
|
82
|
+
|
83
|
+
Ends the class block:
|
84
|
+
end
|
85
|
+
|
86
|
+
|
87
|
+
|
88
|
+
=== The +gui/welcome.yaml+ file of the "welcome" bundle
|
89
|
+
This file has the user interface description encoded in YAML[http://yaml.org/]. It's converted by a {RSence::Plugins::GUIParser GUIParser} instance automatically set up by the {RSence::Plugins::GUIPlugin__ GUIPlugin} class instance, when the RSence web page is loaded (and reloaded) by the user.
|
90
|
+
|
91
|
+
By convention, place the type and version of the GUITree specification first. This is used by the system to interpret the contents accordingly.
|
92
|
+
!!!yaml
|
93
|
+
type: GUITree
|
94
|
+
version: 0.6
|
95
|
+
|
96
|
+
By convention, place the dependencies next. These are the javascript packages to load by the client before rendering the GUITree.
|
97
|
+
!!!yaml
|
98
|
+
dependencies:
|
99
|
+
- default_theme
|
100
|
+
- controls
|
101
|
+
|
102
|
+
Next, the root class of the user interface tree is defined. This is usually an instance of +HApplication+, in this case the +RSence.GUIApp+ is used, because it's a customized extension of +HApplication+ designed for GUITree usage and supports options like +title+ and +priority+ by default.
|
103
|
+
!!!yaml
|
104
|
+
class: RSence.GUIApp
|
105
|
+
options:
|
106
|
+
title: Welcome App
|
107
|
+
priority: 20
|
108
|
+
|
109
|
+
To have the +RSence.GUIApp+ instance titled "Welcome App" contain any views, we define the +subviews+ for it:
|
110
|
+
!!!yaml
|
111
|
+
subviews:
|
112
|
+
|
113
|
+
The first subview is an instance of the +HSheet+ component, which is a component that self-centers, dims the background and its visibility controlled by its value.
|
114
|
+
!!!yaml
|
115
|
+
- class: HSheet
|
116
|
+
|
117
|
+
All components use a +rect+ item to define their geometry, this is usually in form of an Array with at exactly +4+ or +6+ coordinates. In this case, with the offset of +0+ units from the left edge of its parent and +0+ units from the top edge of its parent. It has a size of +600+ units wide and +500+ units tall. Each unit at the default (100%) zoom level is exactly 1 pixel.
|
118
|
+
!!!yaml
|
119
|
+
rect: [ 0, 0, 600, 500 ]
|
120
|
+
|
121
|
+
There is also a {RSence::HValue +HValue+} named +close+ defined in the +values.yaml+. This binds the +HSheet+ instance to the value and vice versa.
|
122
|
+
!!!yaml
|
123
|
+
bind: :values.close
|
124
|
+
|
125
|
+
We also extend the component to kill its application (the +RSence.GUIApp+ defined above), which in effect destructs all the views defined by this GUITree when the data of the value becomes 1.
|
126
|
+
!!!yaml
|
127
|
+
extend:
|
128
|
+
refreshValue: |
|
129
|
+
|
130
|
+
Custom Javascript extensions can be written inline like this. Functions are identified as text blocks that begin with 'function('. Other types are mapped as-is and converted to JSON structures.
|
131
|
+
!!!js
|
132
|
+
function(){
|
133
|
+
this.base();
|
134
|
+
if ( this.value==1 ) {
|
135
|
+
this.app.die();
|
136
|
+
}
|
137
|
+
}
|
138
|
+
|
139
|
+
Then, we define the first subview of the +HSheet+ instance as a +HScrollView+, which is a view that has scroll bars. Its +rect+ is defined with stretching content filling entirely the area of its parent (the +HSheet+) except for the +42+ units at the bottom of its parent (the +HSheet+). Its minimum size is defined as +550+ units wide and +300+ units tall. Its options define that it displays horizontal scroll bars if the content doesn't fit and a white background with a black border at the bottom.
|
140
|
+
!!!yaml
|
141
|
+
- class: HScrollView
|
142
|
+
rect: [ 0, 0, 550, 300, 0, 42 ]
|
143
|
+
options:
|
144
|
+
scrollX: false
|
145
|
+
scrollY: auto
|
146
|
+
style:
|
147
|
+
- [ 'background-color', 'white' ]
|
148
|
+
- [ 'border-bottom', '1px solid black' ]
|
149
|
+
|
150
|
+
Then, a few few items are defined as its subviews. An HImageView displaying the RSence logo, a +HView+ displaying a link to rsence.org and a +HInlineView+ displaying the contents of the +text/welcome.html+ file.
|
151
|
+
!!!yaml
|
152
|
+
- class: HImageView
|
153
|
+
rect: [ 18, 10, 559, 110 ]
|
154
|
+
options:
|
155
|
+
value: http://rsence.org/rsence_org_logo.gif
|
156
|
+
- class: HView
|
157
|
+
rect: [ null, 95, 310, 25, 35, null ]
|
158
|
+
options:
|
159
|
+
html: |
|
160
|
+
<i style="font-family:Helvetica,Arial,sans-serif;font-size:16px;">
|
161
|
+
<a style="color:#28c;font-weight:bold" href="http://rsence.org/">http://www.rsence.org/</a>
|
162
|
+
</i>
|
163
|
+
style:
|
164
|
+
- - text-align
|
165
|
+
- right
|
166
|
+
- class: HInlineView
|
167
|
+
rect: [ 0, 0, null, null, 0, 0 ]
|
168
|
+
options:
|
169
|
+
html: :text.welcome
|
170
|
+
style:
|
171
|
+
- - font-family
|
172
|
+
- 'Helvetica, Arial, sans-serif'
|
173
|
+
- - font-size
|
174
|
+
- 16px
|
175
|
+
- - line-height
|
176
|
+
- 20px
|
177
|
+
|
178
|
+
Finally, we define a +HClickValueButton+ (a button with the click event triggering a change of its value to +1+), which is bound to the same value as the +HSheet+, causing the +HSheet+ and the application including all child views to be destructed. The value change is also synchronized to the server-side responder method +close_button+ in the +welcome.rb+ file.
|
179
|
+
!!!yaml
|
180
|
+
- class: HClickValueButton
|
181
|
+
rect: [ null, null, 60, 24, 8, 8 ]
|
182
|
+
bind: :values.close
|
183
|
+
options:
|
184
|
+
label: Close
|
185
|
+
|
186
|
+
We also define a +HCheckbox+ with another value bound, the +:dont_show_again+. This causes the plugin to be disabled when the close button is clicked.
|
187
|
+
!!!yaml
|
188
|
+
- class: HCheckbox
|
189
|
+
rect: [ null, null, 130, 24, 74, 8 ]
|
190
|
+
bind: :values.dont_show_again
|
191
|
+
options:
|
192
|
+
label: Don't show again
|
193
|
+
|
File without changes
|
@@ -0,0 +1,173 @@
|
|
1
|
+
= Overview
|
2
|
+
|
3
|
+
Each {file:PluginBundles plugin bundle} should contain an +info.yaml+ file.
|
4
|
+
|
5
|
+
The main purpose of the +info.yaml+ file is to provide meta-information to the {RSence::PluginManager PluginManager} about the bundle.
|
6
|
+
|
7
|
+
Using ruby notation, the defaults look like this:
|
8
|
+
@info = {
|
9
|
+
# The human-readable product name of the package
|
10
|
+
:title => bundle_name.to_s.capitalize,
|
11
|
+
|
12
|
+
# The human-readable version of the package
|
13
|
+
:version => '0.0.0',
|
14
|
+
|
15
|
+
# A brief description of the package (rdoc formatting supported)
|
16
|
+
:description => 'No Description',
|
17
|
+
|
18
|
+
# A flag (when false) prevents the plugin from automatically reload when changed.
|
19
|
+
:reloadable => true,
|
20
|
+
|
21
|
+
# Dependency, by default the system category (built-in plugins).
|
22
|
+
# A nil ( "~" in yaml ) value means no dependencies.
|
23
|
+
:depends_on => :system,
|
24
|
+
|
25
|
+
# Optional, name of category. The built-in plugins are :system
|
26
|
+
:category => nil
|
27
|
+
}
|
28
|
+
|
29
|
+
|
30
|
+
Using YAML notation, the same data would looks like this, if the name of the bundle in this example is "example_plugin":
|
31
|
+
!!!yaml
|
32
|
+
:title: Example_plugin
|
33
|
+
:version: 0.0.0
|
34
|
+
:description: 'No Description'
|
35
|
+
:reloadable: true
|
36
|
+
:depends_on: :system
|
37
|
+
:category: nil
|
38
|
+
|
39
|
+
When defining your own, not all of the key-value pairs need to be entered, just the ones that are different from the defaults. In this example the +:version+, +:description+ and +:title+ are defined:
|
40
|
+
!!!yaml
|
41
|
+
:title: Example Plugin
|
42
|
+
:version: 1.0.0
|
43
|
+
:description: |
|
44
|
+
This plugin is an example showing how to define the info.yaml file.
|
45
|
+
Besides that, no functionality is defined.
|
46
|
+
|
47
|
+
|
48
|
+
== Example 1: A set of plugins with dependency relationship
|
49
|
+
|
50
|
+
In this example, we have an user interface bundle named 'myapp' that uses a an user database wrapper 'myapp_users' for a database connection provided by another plugin called 'myapp_db', which defines the category +:myapp_support+, which is a practical way of defining groups of dependencies. One could then add other supporting plugins to do specific tasks, when the requirements of the application grows.
|
51
|
+
|
52
|
+
=== Files and directories of the example
|
53
|
+
|
54
|
+
The "plugins" directory of a RSence environment containing only the three plugins of this example would look like:
|
55
|
+
|
56
|
+
!!!text
|
57
|
+
plugins/
|
58
|
+
|-- myapp
|
59
|
+
| |-- gui
|
60
|
+
| | `-- main.yaml
|
61
|
+
| |-- info.yaml
|
62
|
+
| `-- main.rb
|
63
|
+
|-- myapp_db
|
64
|
+
| |-- info.yaml
|
65
|
+
| `-- main.rb
|
66
|
+
`-- myapp_users
|
67
|
+
|-- info.yaml
|
68
|
+
`-- main.rb
|
69
|
+
|
70
|
+
=== A plugin bundle named 'myapp_db'
|
71
|
+
|
72
|
+
The +info.yaml+ can also used to store settings. In this example, database connection parameters:
|
73
|
+
!!!yaml
|
74
|
+
:title: MyApp DB
|
75
|
+
:version: 0.1.3
|
76
|
+
:description: This plugin provides connectivity to the FooBase database server.
|
77
|
+
:category: :myapp_support
|
78
|
+
:settings:
|
79
|
+
:host: '10.0.0.172'
|
80
|
+
:port: 12345
|
81
|
+
:database: example_database
|
82
|
+
:username: foobert
|
83
|
+
:password: n0ts0s3cr3t
|
84
|
+
:db_keys:
|
85
|
+
- abc123
|
86
|
+
- foobar
|
87
|
+
- 123456
|
88
|
+
|
89
|
+
This information could then be read inside a plugin code like this:
|
90
|
+
|
91
|
+
require 'foo_orm'
|
92
|
+
|
93
|
+
# Provides connectivity to the FooBase user database using the FooBasePlugin
|
94
|
+
class FooBasePlugin < Plugin
|
95
|
+
|
96
|
+
# Opens database connection after plugin is loaded
|
97
|
+
def open
|
98
|
+
@db = FooORM.new( database_connection_string )
|
99
|
+
super
|
100
|
+
end
|
101
|
+
|
102
|
+
# Closes database connection before plugin is unloaded
|
103
|
+
def close
|
104
|
+
@db.disconnect
|
105
|
+
super
|
106
|
+
end
|
107
|
+
|
108
|
+
# Returns database connection with very basic data access restriction
|
109
|
+
def db( db_key )
|
110
|
+
return nil unless @info[:settings][:db_keys].include?( db_key )
|
111
|
+
return @db
|
112
|
+
end
|
113
|
+
|
114
|
+
private
|
115
|
+
|
116
|
+
# Returns database connection string according to the settings.
|
117
|
+
# @return [String] FooBase connection string.
|
118
|
+
def database_connection_string
|
119
|
+
s = @info[:settings]
|
120
|
+
# Returns "foobase://foobert:n0ts0s3cr3t@10.0.0.172:12345/example_database" when using the default settings
|
121
|
+
"foobase://#{s[:username]}:#{s[:password]}@#{s[:host]}:#{s[:port]}/#{s[:database]}"
|
122
|
+
end
|
123
|
+
|
124
|
+
end
|
125
|
+
|
126
|
+
=== A plugin bundle named 'myapp_users'
|
127
|
+
|
128
|
+
Here, the +info.yaml+ document depends on the +:myapp_db+ plugin defined above.
|
129
|
+
!!!yaml
|
130
|
+
:title: MyApp Users
|
131
|
+
:version: 0.0.1
|
132
|
+
:description: This plugin provides an interface to access user information using FooBasePlugin
|
133
|
+
:depends_on: :myapp_db
|
134
|
+
:category: :myapp_support
|
135
|
+
:settings:
|
136
|
+
:db_key: foobar
|
137
|
+
|
138
|
+
Code example:
|
139
|
+
|
140
|
+
# Provides the user_name method to MyApp
|
141
|
+
class MyAppUsersPlugin < Plugin
|
142
|
+
|
143
|
+
# Returns the user name that has the id provided by selecting it from the users table.
|
144
|
+
def user_name( user_id )
|
145
|
+
db_key = @info[:settings][:db_key]
|
146
|
+
db = @plugins.myapp_db.db( db_key )
|
147
|
+
unless db
|
148
|
+
warn "Invalid database key: #{db_key.inspect}"
|
149
|
+
return "[Database Error]"
|
150
|
+
end
|
151
|
+
user_info = db[:users].filter(:id => user_id).first
|
152
|
+
return "[Unknown User]" unless user_info
|
153
|
+
return user_info[:user_name]
|
154
|
+
end
|
155
|
+
|
156
|
+
end
|
157
|
+
|
158
|
+
=== A plugin bundle named 'myapp'
|
159
|
+
Another plugin depending on the two plugins above may set it as a dependency if its +info.yaml+ is defined like this:
|
160
|
+
!!!yaml
|
161
|
+
:title: MyApp
|
162
|
+
:version: 0.2.0
|
163
|
+
:description: This application does fancy stuff using FooBasePlugin.
|
164
|
+
:depends_on: :myapp_support
|
165
|
+
|
166
|
+
Defining the dependency like above ensures the 'foobase' plugin will be available when this code is run:
|
167
|
+
class MyAppPlugin < GUIPlugin
|
168
|
+
def gui_params( msg )
|
169
|
+
params = super
|
170
|
+
params[:greeting] = 'Welcome, ' + @plugins.myapp_users.user_name( msg.user_id )
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|