rsence-pre 2.1.0.1.pre
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.yardopts +10 -0
- data/INSTALL.rdoc +330 -0
- data/LICENSE.txt +622 -0
- data/README.rdoc +98 -0
- data/VERSION +1 -0
- data/bin/rsence +25 -0
- data/bin/rsence-pre +25 -0
- data/conf/default_conf.yaml +346 -0
- data/conf/default_strings.yaml +76 -0
- data/conf/rsence_command_strings.yaml +444 -0
- data/docs/ExampleGuiPlugin.rdoc +193 -0
- data/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/autosync/autosync.js +17 -0
- data/js/comm/autosync/js.inc +0 -0
- data/js/comm/comm.js +203 -0
- data/js/comm/js.inc +0 -0
- data/js/comm/jsloader/js.inc +0 -0
- data/js/comm/jsloader/jsloader.js +112 -0
- data/js/comm/queue/js.inc +0 -0
- data/js/comm/queue/queue.js +184 -0
- data/js/comm/session/js.inc +0 -0
- data/js/comm/session/session.js +52 -0
- data/js/comm/sessionwatcher/js.inc +0 -0
- data/js/comm/sessionwatcher/sessionwatcher.js +44 -0
- data/js/comm/transporter/js.inc +0 -0
- data/js/comm/transporter/transporter.js +261 -0
- data/js/comm/urlresponder/js.inc +0 -0
- data/js/comm/urlresponder/urlresponder.js +149 -0
- data/js/comm/values/js.inc +0 -0
- data/js/comm/values/values.js +433 -0
- data/js/controls/button/button.js +72 -0
- data/js/controls/button/js.inc +0 -0
- data/js/controls/button/themes/bright/button.css +89 -0
- data/js/controls/button/themes/bright/button.html +7 -0
- data/js/controls/button/themes/bright/button_parts1-ie6.gif +0 -0
- data/js/controls/button/themes/bright/button_parts1.png +0 -0
- data/js/controls/button/themes/default/button.css +89 -0
- data/js/controls/button/themes/default/button.html +7 -0
- data/js/controls/button/themes/default/button_parts1-ie6.gif +0 -0
- data/js/controls/button/themes/default/button_parts1.png +0 -0
- data/js/controls/checkbox/checkbox.js +49 -0
- data/js/controls/checkbox/js.inc +0 -0
- data/js/controls/checkbox/themes/default/checkbox.css +69 -0
- data/js/controls/checkbox/themes/default/checkbox.html +5 -0
- data/js/controls/checkbox/themes/default/checkbox_parts1-ie6.gif +0 -0
- data/js/controls/checkbox/themes/default/checkbox_parts1.png +0 -0
- data/js/controls/dialogs/alert_sheet/alert_sheet.js +63 -0
- data/js/controls/dialogs/alert_sheet/js.inc +0 -0
- data/js/controls/dialogs/confirm_sheet/confirm_sheet.js +37 -0
- data/js/controls/dialogs/confirm_sheet/js.inc +0 -0
- data/js/controls/dialogs/sheet/js.inc +0 -0
- data/js/controls/dialogs/sheet/sheet.js +84 -0
- data/js/controls/dialogs/sheet/themes/default/sheet.css +64 -0
- data/js/controls/dialogs/sheet/themes/default/sheet.html +14 -0
- data/js/controls/dialogs/sheet/themes/default/sheet_bg-ie6.gif +0 -0
- data/js/controls/dialogs/sheet/themes/default/sheet_bg.png +0 -0
- data/js/controls/dialogs/sheet/themes/default/sheet_dim-ie6.gif +0 -0
- data/js/controls/dialogs/sheet/themes/default/sheet_dim.png +0 -0
- data/js/controls/dialogs/sheet/themes/default/sheet_parts1-ie6.gif +0 -0
- data/js/controls/dialogs/sheet/themes/default/sheet_parts1.png +0 -0
- data/js/controls/dialogs/sheet/themes/default/sheet_parts2-ie6.gif +0 -0
- data/js/controls/dialogs/sheet/themes/default/sheet_parts2.png +0 -0
- data/js/controls/dialogs/sheet/themes/default/sheet_warning-ie6.gif +0 -0
- data/js/controls/dialogs/sheet/themes/default/sheet_warning.png +0 -0
- data/js/controls/imageview/imageview.js +109 -0
- data/js/controls/imageview/js.inc +0 -0
- data/js/controls/imageview/themes/default/blank.gif +0 -0
- data/js/controls/passwordcontrol/js.inc +0 -0
- data/js/controls/passwordcontrol/passwordcontrol.js +23 -0
- data/js/controls/passwordcontrol/themes/default/passwordcontrol.css +0 -0
- data/js/controls/passwordcontrol/themes/default/passwordcontrol.html +18 -0
- data/js/controls/progress/progressbar/js.inc +0 -0
- data/js/controls/progress/progressbar/progressbar.js +40 -0
- data/js/controls/progress/progressbar/themes/default/progressbar.css +16 -0
- data/js/controls/progress/progressbar/themes/default/progressbar.html +2 -0
- data/js/controls/progress/progressindicator/js.inc +0 -0
- data/js/controls/progress/progressindicator/progressindicator.js +44 -0
- data/js/controls/radiobutton/js.inc +0 -0
- data/js/controls/radiobutton/radiobutton.js +43 -0
- data/js/controls/radiobutton/themes/default/radiobutton.css +69 -0
- data/js/controls/radiobutton/themes/default/radiobutton.html +5 -0
- data/js/controls/radiobutton/themes/default/radiobutton_parts1-ie6.gif +0 -0
- data/js/controls/radiobutton/themes/default/radiobutton_parts1.png +0 -0
- data/js/controls/sliders/slider/js.inc +0 -0
- data/js/controls/sliders/slider/slider.js +357 -0
- data/js/controls/sliders/slider/themes/default/hslider_tracks-ie6.gif +0 -0
- data/js/controls/sliders/slider/themes/default/hslider_tracks.png +0 -0
- data/js/controls/sliders/slider/themes/default/slider.css +108 -0
- data/js/controls/sliders/slider/themes/default/slider.html +5 -0
- data/js/controls/sliders/slider/themes/default/slider_thumbs-ie6.gif +0 -0
- data/js/controls/sliders/slider/themes/default/slider_thumbs.png +0 -0
- data/js/controls/sliders/vslider/js.inc +0 -0
- data/js/controls/sliders/vslider/themes/default/vslider.css +52 -0
- data/js/controls/sliders/vslider/themes/default/vslider.html +5 -0
- data/js/controls/sliders/vslider/themes/default/vslider_tracks-ie6.gif +0 -0
- data/js/controls/sliders/vslider/themes/default/vslider_tracks.png +0 -0
- data/js/controls/sliders/vslider/vslider.js +41 -0
- data/js/controls/stepper/js.inc +0 -0
- data/js/controls/stepper/stepper.js +213 -0
- data/js/controls/stepper/themes/default/stepper-ie6.gif +0 -0
- data/js/controls/stepper/themes/default/stepper.css +14 -0
- data/js/controls/stepper/themes/default/stepper.html +2 -0
- data/js/controls/stepper/themes/default/stepper.png +0 -0
- data/js/controls/stringview/js.inc +0 -0
- data/js/controls/stringview/stringview.js +49 -0
- data/js/controls/stringview/themes/default/stringview.css +8 -0
- data/js/controls/stringview/themes/default/stringview.html +1 -0
- data/js/controls/tab/js.inc +0 -0
- data/js/controls/tab/tab.js +280 -0
- data/js/controls/tab/themes/bright/tab.css +76 -0
- data/js/controls/tab/themes/bright/tab.html +6 -0
- data/js/controls/tab/themes/bright/tab_bg_color-ie6.gif +0 -0
- data/js/controls/tab/themes/bright/tab_bg_color.png +0 -0
- data/js/controls/tab/themes/bright/tab_border_pattern-ie6.gif +0 -0
- data/js/controls/tab/themes/bright/tab_border_pattern.png +0 -0
- data/js/controls/tab/themes/bright/tab_parts1-ie6.gif +0 -0
- data/js/controls/tab/themes/bright/tab_parts1.png +0 -0
- data/js/controls/tab/themes/default/tab.css +77 -0
- data/js/controls/tab/themes/default/tab.html +6 -0
- data/js/controls/tab/themes/default/tab_bg_color-ie6.gif +0 -0
- data/js/controls/tab/themes/default/tab_bg_color.png +0 -0
- data/js/controls/tab/themes/default/tab_border_pattern-ie6.gif +0 -0
- data/js/controls/tab/themes/default/tab_border_pattern.png +0 -0
- data/js/controls/tab/themes/default/tab_parts1-ie6.gif +0 -0
- data/js/controls/tab/themes/default/tab_parts1.png +0 -0
- data/js/controls/textarea/js.inc +0 -0
- data/js/controls/textarea/textarea.js +24 -0
- data/js/controls/textarea/themes/default/textarea.css +21 -0
- data/js/controls/textarea/themes/default/textarea.html +18 -0
- data/js/controls/textcontrol/js.inc +0 -0
- data/js/controls/textcontrol/textcontrol.js +374 -0
- data/js/controls/textcontrol/themes/default/textcontrol.css +107 -0
- data/js/controls/textcontrol/themes/default/textcontrol.html +18 -0
- data/js/controls/textcontrol/themes/default/textcontrol_parts1-ie6.gif +0 -0
- data/js/controls/textcontrol/themes/default/textcontrol_parts1.png +0 -0
- data/js/controls/textcontrol/themes/default/textcontrol_parts2-ie6.gif +0 -0
- data/js/controls/textcontrol/themes/default/textcontrol_parts2.png +0 -0
- data/js/controls/textcontrol/themes/default/textcontrol_parts3-ie6.gif +0 -0
- data/js/controls/textcontrol/themes/default/textcontrol_parts3.png +0 -0
- data/js/controls/uploader/js.inc +0 -0
- data/js/controls/uploader/themes/default/upload_progress.gif +0 -0
- data/js/controls/uploader/themes/default/uploader.css +108 -0
- data/js/controls/uploader/themes/default/uploader.html +27 -0
- data/js/controls/uploader/uploader.js +154 -0
- data/js/controls/validatorview/js.inc +0 -0
- data/js/controls/validatorview/themes/default/validator-ie6.gif +0 -0
- data/js/controls/validatorview/themes/default/validator.png +0 -0
- data/js/controls/validatorview/themes/default/validatorview.css +0 -0
- data/js/controls/validatorview/themes/default/validatorview.html +0 -0
- data/js/controls/validatorview/validatorview.js +62 -0
- data/js/controls/window/js.inc +0 -0
- data/js/controls/window/themes/default/window.css +219 -0
- data/js/controls/window/themes/default/window.html +17 -0
- data/js/controls/window/themes/default/window_bg_active-ie6.gif +0 -0
- data/js/controls/window/themes/default/window_bg_active.png +0 -0
- data/js/controls/window/themes/default/window_bg_inactive-ie6.gif +0 -0
- data/js/controls/window/themes/default/window_bg_inactive.png +0 -0
- data/js/controls/window/themes/default/window_buttons-ie6.gif +0 -0
- data/js/controls/window/themes/default/window_buttons.png +0 -0
- data/js/controls/window/themes/default/window_parts1-ie6.gif +0 -0
- data/js/controls/window/themes/default/window_parts1.png +0 -0
- data/js/controls/window/themes/default/window_parts2-ie6.gif +0 -0
- data/js/controls/window/themes/default/window_parts2.png +0 -0
- data/js/controls/window/window.js +286 -0
- data/js/core/class/class.js +318 -0
- data/js/core/class/js.inc +0 -0
- data/js/core/elem/elem.js +1383 -0
- data/js/core/elem/js.inc +0 -0
- data/js/core/event/event.js +153 -0
- data/js/core/event/js.inc +0 -0
- data/js/core/iefix/ie_css_element.htc +5 -0
- data/js/core/iefix/ie_css_style.htc +5 -0
- data/js/core/iefix/iefix.js +359 -0
- data/js/core/iefix/js.inc +0 -0
- data/js/core/rsence_ns/js.inc +0 -0
- data/js/core/rsence_ns/rsence_ns.js +21 -0
- data/js/datetime/calendar/calendar.js +198 -0
- data/js/datetime/calendar/js.inc +0 -0
- data/js/datetime/calendar/themes/default/calendar.css +108 -0
- data/js/datetime/calendar/themes/default/calendar.html +9 -0
- data/js/datetime/calendar/themes/default/calendar_arrows-ie6.gif +0 -0
- data/js/datetime/calendar/themes/default/calendar_arrows.png +0 -0
- data/js/datetime/datetimevalue/datetimevalue.js +247 -0
- data/js/datetime/datetimevalue/js.inc +0 -0
- data/js/datetime/timesheet/js.inc +0 -0
- data/js/datetime/timesheet/themes/default/timesheet.css +30 -0
- data/js/datetime/timesheet/themes/default/timesheet.html +2 -0
- data/js/datetime/timesheet/timesheet.js +183 -0
- data/js/datetime/timesheet_item/js.inc +0 -0
- data/js/datetime/timesheet_item/themes/default/timesheet_item.css +42 -0
- data/js/datetime/timesheet_item/themes/default/timesheet_item.html +8 -0
- data/js/datetime/timesheet_item/timesheet_item.js +248 -0
- data/js/datetime/timesheet_item_edit/js.inc +0 -0
- data/js/datetime/timesheet_item_edit/timesheet_item_edit.js +274 -0
- data/js/foundation/application/application.js +208 -0
- data/js/foundation/application/js.inc +0 -0
- data/js/foundation/control/control.js +339 -0
- data/js/foundation/control/controldefaults/controldefaults.js +56 -0
- data/js/foundation/control/controldefaults/js.inc +0 -0
- data/js/foundation/control/dummyvalue/dummyvalue.js +51 -0
- data/js/foundation/control/dummyvalue/js.inc +0 -0
- data/js/foundation/control/dyncontrol/dyncontrol.js +500 -0
- data/js/foundation/control/dyncontrol/js.inc +0 -0
- data/js/foundation/control/dyncontrol/themes/default/dyncontrol.css +0 -0
- data/js/foundation/control/dyncontrol/themes/default/dyncontrol.html +0 -0
- data/js/foundation/control/eventresponder/eventresponder.js +750 -0
- data/js/foundation/control/eventresponder/js.inc +0 -0
- data/js/foundation/control/js.inc +0 -0
- data/js/foundation/control/valuematrix/js.inc +0 -0
- data/js/foundation/control/valuematrix/valuematrix.js +135 -0
- data/js/foundation/control/valueresponder/js.inc +0 -0
- data/js/foundation/control/valueresponder/valueresponder.js +79 -0
- data/js/foundation/eventmanager/eventmanager.js +991 -0
- data/js/foundation/eventmanager/js.inc +0 -0
- data/js/foundation/geom/point/js.inc +0 -0
- data/js/foundation/geom/point/point.js +202 -0
- data/js/foundation/geom/rect/js.inc +0 -0
- data/js/foundation/geom/rect/rect.js +651 -0
- data/js/foundation/json_renderer/js.inc +0 -0
- data/js/foundation/json_renderer/json_renderer.js +246 -0
- data/js/foundation/system/js.inc +0 -0
- data/js/foundation/system/system.js +381 -0
- data/js/foundation/thememanager/js.inc +0 -0
- data/js/foundation/thememanager/thememanager.js +393 -0
- data/js/foundation/value/js.inc +0 -0
- data/js/foundation/value/value.js +183 -0
- data/js/foundation/view/js.inc +0 -0
- data/js/foundation/view/markupview/js.inc +0 -0
- data/js/foundation/view/markupview/markupview.js +114 -0
- data/js/foundation/view/morphanimation/js.inc +0 -0
- data/js/foundation/view/morphanimation/morphanimation.js +237 -0
- data/js/foundation/view/view.js +1812 -0
- data/js/foundation/view/viewdefaults/js.inc +0 -0
- data/js/foundation/view/viewdefaults/viewdefaults.js +26 -0
- data/js/lists/checkboxlist/checkboxlist.js +171 -0
- data/js/lists/checkboxlist/js.inc +0 -0
- data/js/lists/listitems/js.inc +0 -0
- data/js/lists/listitems/listitems.js +88 -0
- data/js/lists/propertylist/js.inc +0 -0
- data/js/lists/propertylist/propertylist.js +326 -0
- data/js/lists/radiobuttonlist/js.inc +0 -0
- data/js/lists/radiobuttonlist/radiobuttonlist.js +116 -0
- data/js/util/reloadapp/js.inc +0 -0
- data/js/util/reloadapp/reloadapp.js +152 -0
- data/js/util/reloadapp/themes/default/reloadapp_warning-ie6.gif +0 -0
- data/js/util/reloadapp/themes/default/reloadapp_warning.png +0 -0
- data/js/util/sha/js.inc +0 -0
- data/js/util/sha/sha.js +426 -0
- data/js/views/centerview/centerview.js +75 -0
- data/js/views/centerview/js.inc +0 -0
- data/js/views/inlineview/inlineview.js +15 -0
- data/js/views/inlineview/js.inc +0 -0
- data/js/views/scrollview/js.inc +0 -0
- data/js/views/scrollview/scrollview.js +40 -0
- data/lib/conf/argv.rb +850 -0
- data/lib/conf/default.rb +219 -0
- data/lib/daemon/daemon.rb +387 -0
- data/lib/daemon/sigcomm.rb +64 -0
- data/lib/http/broker.rb +150 -0
- data/lib/http/rackup.rb +91 -0
- data/lib/http/request.rb +66 -0
- data/lib/http/response.rb +65 -0
- data/lib/plugins/dependencies.rb +285 -0
- data/lib/plugins/gui_plugin.rb +160 -0
- data/lib/plugins/guiparser.rb +123 -0
- data/lib/plugins/plugin.rb +438 -0
- data/lib/plugins/plugin_base.rb +162 -0
- data/lib/plugins/plugin_plugins.rb +81 -0
- data/lib/plugins/plugin_sqlite_db.rb +98 -0
- data/lib/plugins/pluginmanager.rb +635 -0
- data/lib/plugins/plugins.rb +169 -0
- data/lib/plugins/servlet.rb +108 -0
- data/lib/rsence.rb +32 -0
- data/lib/session/msg.rb +327 -0
- data/lib/session/sessionmanager.rb +522 -0
- data/lib/session/sessionstorage.rb +340 -0
- data/lib/transporter/transporter.rb +263 -0
- data/lib/util/gzstring.rb +9 -0
- data/lib/util/ruby19_fixes.rb +18 -0
- data/lib/values/hvalue.rb +378 -0
- data/lib/values/valuemanager.rb +172 -0
- data/plugins/client_pkg/client_pkg.rb +157 -0
- data/plugins/client_pkg/info.yaml +25 -0
- data/plugins/client_pkg/lib/client_pkg_build.rb +561 -0
- data/plugins/client_pkg/lib/client_pkg_cache.rb +50 -0
- data/plugins/client_pkg/lib/client_pkg_serve.rb +218 -0
- data/plugins/index_html/img/loading.gif +0 -0
- data/plugins/index_html/img/riassence.gif +0 -0
- data/plugins/index_html/index_html.rb +120 -0
- data/plugins/index_html/info.yaml +18 -0
- data/plugins/index_html/tmpl/index.html +15 -0
- data/plugins/main/info.yaml +18 -0
- data/plugins/main/js/main.js +84 -0
- data/plugins/main/main.rb +255 -0
- data/plugins/main/values.yaml +8 -0
- data/plugins/ticket/info.yaml +21 -0
- data/plugins/ticket/lib/common.rb +392 -0
- data/plugins/ticket/lib/favicon.rb +39 -0
- data/plugins/ticket/lib/file.rb +58 -0
- data/plugins/ticket/lib/img.rb +50 -0
- data/plugins/ticket/lib/objblob.rb +66 -0
- data/plugins/ticket/lib/rsrc.rb +34 -0
- data/plugins/ticket/lib/upload.rb +236 -0
- data/plugins/ticket/ticket.rb +333 -0
- data/setup/welcome/gui/welcome.yaml +92 -0
- data/setup/welcome/info.yaml +13 -0
- data/setup/welcome/text/welcome.html +9 -0
- data/setup/welcome/values.yaml +9 -0
- data/setup/welcome/welcome.rb +54 -0
- metadata +407 -0
@@ -0,0 +1,438 @@
|
|
1
|
+
## RSence
|
2
|
+
# Copyright 2006 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
|
+
module RSence
|
11
|
+
module Plugins
|
12
|
+
|
13
|
+
# The Plugin__ is actually available as +Plugin+ from plugin bundles using the {RSence::Plugins::Plugin} class mimic method.
|
14
|
+
#
|
15
|
+
# The Plugin class is the base class for extending server logic. A single Plugin instance serves the requests of all sessions, which makes them very cpu and memory efficient compared to systems, where the server classes are constructed and destructed for each request.
|
16
|
+
#
|
17
|
+
# Plugins are designed to be contained in a plugin directory bundle and to be loaded by the main {PluginManager}, which is also responsible for delegating the events and other calls throughout the system.
|
18
|
+
#
|
19
|
+
#
|
20
|
+
# == Anatomy of a plugin bundle
|
21
|
+
#
|
22
|
+
# First read about the {file:PluginBundles Plugin Bundles}.
|
23
|
+
#
|
24
|
+
# The plugin bundle contains all data needed to run the plugin. Design your plugin without any hard-coded paths, remember that it's intended to be installed by moving or copying the whole plugin into one of the "plugins" directories. Use {#bundle_path} to construct paths.
|
25
|
+
#
|
26
|
+
# The {PluginManager} looks for these bundles and evaluates them into an anonymous +Module+ namespace. The contents of the ruby source file is then responsible for including its libraries, constructing an instance of itself and registering itself as a part of the system.
|
27
|
+
#
|
28
|
+
# Use the {GUIPlugin__ GUIPlugin} class for plugins that handle user interfaces. Use the {Plugin__ Plugin} class for plugin bundles that provide supplemental functionality, value responders and other utilities that supplement the user interface.
|
29
|
+
#
|
30
|
+
# = Extension hooks for server events
|
31
|
+
# These methods are provided as the basic server event hooks:
|
32
|
+
# * {#init +#init+} -- Use instead of +initialize+
|
33
|
+
# * {#open +#open+} -- Extend to open objects
|
34
|
+
# * {#flush +#flush+} -- Extend to write the state and to flush buffers
|
35
|
+
# * {#close +#close+} -- Extend to close objects
|
36
|
+
#
|
37
|
+
# = Extension hooks for session events
|
38
|
+
# * {#idle +#idle+} -- Extend to implement logic for each client data synchronization and "idle poll" request.
|
39
|
+
# * {#init_ses +#init_ses+} -- Extend to implement logic when a new session is created. A new session is created, when a user enters accesses the server the first time, or the first time after the previous session expired.
|
40
|
+
# * {#restore_ses +#restore_ses+} -- Extend to implement logic when an old session is restored. A session is restored, when the user returns to the page or reloads the page before the session is expired.
|
41
|
+
#
|
42
|
+
# == Extension hooks for session events, If the server is configured to restore and clone previous sessions (default):
|
43
|
+
# When sessions are cloned, the previous session is not invalidated and exists until timing out as a result of the web browser window being closed or client computer losing network connectivity for a certain (configurable) time frame.
|
44
|
+
# * {#cloned_target +#cloned_target+} -- Extend to implement logic in the request when session is a clone of the original session.
|
45
|
+
# * {#cloned_source +#cloned_source+} -- Extend to implement logic in the next request of the original session after it has been cloned.
|
46
|
+
#
|
47
|
+
# == If the server is configured to not clone sessions:
|
48
|
+
# When the user accesses the same page using the same browser (in different tabs or windows), only the most recently restored one is valid, while the previous ones are immediately invalidated. This is a more secure mode of operation, but has several drawback to usability, so it's not enabled by default.
|
49
|
+
#
|
50
|
+
# = Utility methods
|
51
|
+
# These are general utility methods not intended to be extended.
|
52
|
+
# * {#get_ses +#get_ses+} Returns the bundle-specific session Hash.
|
53
|
+
# * {#file_read +#file_read+} Use to read files
|
54
|
+
# * {#yaml_read +#yaml_read+} Use to read yaml data
|
55
|
+
# * {#file_write +#file_write+} Use to write files
|
56
|
+
# * {#bundle_path +#bundle_path+} Use for plugin bundle -specific paths
|
57
|
+
# * {#httime +#httime+} Use for HTTP date/time
|
58
|
+
#
|
59
|
+
# = Client-support
|
60
|
+
# These methods are intended for server-client interaction. Namely, commanding the client.
|
61
|
+
# * {#read_js +#read_js+} Returns a javascript source file.
|
62
|
+
# * {#read_js_once +#read_js_once+} Returns a javascript source file once per session.
|
63
|
+
# * {#values_js +#values_js+} Returns a javascript source snippet containing references to values.
|
64
|
+
# * {#include_js +#include_js+} Tells the client to load a library package.
|
65
|
+
#
|
66
|
+
# = See also
|
67
|
+
# * {file:PluginBundles Plugin Bundles} -- General information about the plugin bundle system
|
68
|
+
# * {file:Values Values} -- General information about the value exchange system
|
69
|
+
# * {file:PluginBundleInfo Plugin Bundle +info.yaml+ files} -- General information about the meta-information files.
|
70
|
+
# * {PluginBase PluginBase} -- The PluginBase module
|
71
|
+
# * {Servlet__ Servlet} -- The Servlet base class
|
72
|
+
# * {GUIPlugin__ GUIPlugin} -- The GUIPlugin base class
|
73
|
+
class Plugin__
|
74
|
+
|
75
|
+
|
76
|
+
include PluginBase
|
77
|
+
|
78
|
+
# @private Class type identifier for the PluginManager.
|
79
|
+
# @return [:Plugin]
|
80
|
+
def self.bundle_type; :Plugin; end
|
81
|
+
|
82
|
+
# @return [Symbol] The name of the plugin bundle
|
83
|
+
attr_reader :name
|
84
|
+
|
85
|
+
# @return [String] The absolute path of the plugin bundle.
|
86
|
+
attr_reader :path
|
87
|
+
|
88
|
+
# @return [Hash] The {file:PluginBundleInfo meta-information} of the plugin bundle.
|
89
|
+
attr_reader :info
|
90
|
+
|
91
|
+
# @private State of the plugin.
|
92
|
+
attr_reader :inited
|
93
|
+
|
94
|
+
# @private The constructor should not be accessed from anywhere else than the PluginManager, which does it automatically.
|
95
|
+
def initialize( bundle_name, bundle_info, bundle_path, plugin_manager )
|
96
|
+
@inited = false
|
97
|
+
@info = bundle_info
|
98
|
+
@name = bundle_name
|
99
|
+
@path = bundle_path
|
100
|
+
@plugins = plugin_manager
|
101
|
+
register unless @info[:inits_self]
|
102
|
+
end
|
103
|
+
|
104
|
+
# Extend this method to do any initial tasks before other methods are called.
|
105
|
+
#
|
106
|
+
# By default {#init_values} is called to load the {file:Values +values.yaml+} configuration file.
|
107
|
+
#
|
108
|
+
# @return [nil]
|
109
|
+
#
|
110
|
+
# @see PluginBase#init
|
111
|
+
def init
|
112
|
+
@values = init_values
|
113
|
+
end
|
114
|
+
|
115
|
+
# Extend this method to do any tasks every time the client makes a request.
|
116
|
+
#
|
117
|
+
# @param [Message] msg The message is supplied by the system.
|
118
|
+
#
|
119
|
+
# @return [nil]
|
120
|
+
def idle( msg )
|
121
|
+
end
|
122
|
+
|
123
|
+
# Extend this method to invoke actions, when a new session is created.
|
124
|
+
#
|
125
|
+
# By default {#init_ses_values} is called to initialize values defined in the {file:Values +values.yaml+} configuration file.
|
126
|
+
#
|
127
|
+
# @param [Message] msg The message is supplied by the system.
|
128
|
+
#
|
129
|
+
# @return [nil]
|
130
|
+
def init_ses( msg )
|
131
|
+
init_ses_values( msg )
|
132
|
+
end
|
133
|
+
|
134
|
+
# Extend this method to invoke actions, when a previous session is restored.
|
135
|
+
#
|
136
|
+
# By default +#restore_ses_values+ is called to perform actions on values as defined in the {file:Values +values.yaml+} configuration file.
|
137
|
+
#
|
138
|
+
# @param [Message] msg The message is supplied by the system.
|
139
|
+
#
|
140
|
+
# @return [nil]
|
141
|
+
def restore_ses( msg )
|
142
|
+
restore_ses_values( msg )
|
143
|
+
end
|
144
|
+
|
145
|
+
# Extend this method to invoke actions, when the session is a clone of another session. It's called once, just before {#restore_ses} is called.
|
146
|
+
#
|
147
|
+
# A session is cloned, when a user opens a another browser window or tab, while the previous session is still active.
|
148
|
+
#
|
149
|
+
# @param [Message] msg The message is supplied by the system.
|
150
|
+
# @param [Hash] source_session The actual previous session object, which was used as the source of the clone.
|
151
|
+
#
|
152
|
+
# @return [nil]
|
153
|
+
def cloned_target( msg, source_session )
|
154
|
+
end
|
155
|
+
|
156
|
+
# Extend this method to invoke actions, when the session has been cloned to another session. It's called once, just before {#restore_ses} is called on the first request after the cloning happened.
|
157
|
+
#
|
158
|
+
# A session is cloned, when a user opens a another browser window or tab, while the previous session is still active.
|
159
|
+
#
|
160
|
+
# @param [Message] msg The message is supplied by the system.
|
161
|
+
# @param [Hash] target_session The actual cloned session object, which is a copy of the current session.
|
162
|
+
#
|
163
|
+
# @return [nil]
|
164
|
+
def cloned_source( msg, target_sessions )
|
165
|
+
end
|
166
|
+
|
167
|
+
# @private This method must be called to register the plugin instance into the system. Otherwise, it's subject to destruction and garbage collection. Use the +name+ parameter to give the (unique) name of your plugin.
|
168
|
+
def register( name=false )
|
169
|
+
if @inited
|
170
|
+
@plugins.register_alias( @name, name )
|
171
|
+
else
|
172
|
+
if name
|
173
|
+
name = name.to_s
|
174
|
+
else
|
175
|
+
name = @name
|
176
|
+
end
|
177
|
+
@plugins.register_bundle( self, name )
|
178
|
+
@inited = true
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
# This method returns (or creates and returns) the entry in the session based on the name your plugin is registered as. It's advised to use this call instead of manually managing {Message#session msg#session} in most cases.
|
183
|
+
#
|
184
|
+
# Uses the first name registered for the plugin and converts it to a symbol.
|
185
|
+
#
|
186
|
+
# @param [Message] msg The message is supplied by the system.
|
187
|
+
#
|
188
|
+
# @return [Hash] Plugin-specific session hash
|
189
|
+
def get_ses( msg )
|
190
|
+
name_sym = name.to_sym
|
191
|
+
unless msg.session.has_key?( name_sym )
|
192
|
+
msg.session[ name_sym ] = {}
|
193
|
+
end
|
194
|
+
return msg.session[ name_sym ]
|
195
|
+
end
|
196
|
+
|
197
|
+
# Returns the source code of the javascript file +js_name+ in the 'js' subdirectory of the plugin bundle. Use it to send raw javascript command code to the client. Use {#read_js_once} for libraries.
|
198
|
+
#
|
199
|
+
# @param [String] js_name Javascript source file name without the '.js' suffix.
|
200
|
+
#
|
201
|
+
# @return [String] The source of the file.
|
202
|
+
# @return [false] Returns false, when file was not found.
|
203
|
+
def read_js( js_name )
|
204
|
+
file_read( bundle_path( js_name, 'js', '.js' ) )
|
205
|
+
end
|
206
|
+
|
207
|
+
# Like {#read_js}, but reads the file only once per session. Use for inclusion of custom library code.
|
208
|
+
#
|
209
|
+
# @param [Message] msg The message is supplied by the system.
|
210
|
+
# @param [String] js_name Javascript source file name without the '.js' suffix.
|
211
|
+
#
|
212
|
+
# @return [String] The source of the file on the first call in a session, or an empty string on the subsequent calls.
|
213
|
+
# @return [false] Returns false, when file was not found.
|
214
|
+
def read_js_once( msg, js_name )
|
215
|
+
ses = msg.session
|
216
|
+
if not ses.has_key?(:deps)
|
217
|
+
ses[:deps] = []
|
218
|
+
end
|
219
|
+
path = bundle_path( js_name, 'js', '.js' )
|
220
|
+
unless ses[:deps].include?( path )
|
221
|
+
ses[:deps].push( path )
|
222
|
+
return file_read( path )
|
223
|
+
else
|
224
|
+
return ''
|
225
|
+
end
|
226
|
+
end
|
227
|
+
|
228
|
+
# Extracts +HValue+ references as javascript from the session Hash.
|
229
|
+
#
|
230
|
+
# @param [Message] msg The message is supplied by the system.
|
231
|
+
# @param [Hash] ses Used for supplying a Hash with the {HValue} instances. It's optional and defaults to the current plugin node in the active session.
|
232
|
+
#
|
233
|
+
# @return [String] A string representing a javascript object similar to the ruby Hash +ses+.
|
234
|
+
#
|
235
|
+
# @example
|
236
|
+
# values_js( msg, get_ses(msg) )
|
237
|
+
def values_js( msg, ses=false )
|
238
|
+
# backwards-compatible with pre-1.3 behavior
|
239
|
+
ses = msg if msg.class == Hash
|
240
|
+
# gets the session automatically, if false
|
241
|
+
ses = get_ses( msg ) unless ses
|
242
|
+
js_references = []
|
243
|
+
ses.each_key do |key_name|
|
244
|
+
if ses[key_name].class == HValue
|
245
|
+
js_references.push( "#{key_name.to_s}:HVM.values['#{ses[key_name].val_id}']" )
|
246
|
+
end
|
247
|
+
end
|
248
|
+
return "{#{js_references.join(',')}}"
|
249
|
+
end
|
250
|
+
|
251
|
+
|
252
|
+
# Tells the js client framework to load a list of pre-packaged client libraries.
|
253
|
+
#
|
254
|
+
# It keeps track of what's loaded, so nothing library loaded twice.
|
255
|
+
#
|
256
|
+
# @param [Message] msg The message is supplied by the system.
|
257
|
+
# @param [Array] dependencies A list of package names.
|
258
|
+
#
|
259
|
+
# @return [nil]
|
260
|
+
#
|
261
|
+
# @example
|
262
|
+
# include_js( msg, [ 'default_theme', 'controls' ] )
|
263
|
+
#
|
264
|
+
def include_js( msg, dependencies=[] )
|
265
|
+
ses = msg.session
|
266
|
+
# check, if the session has a dependency array
|
267
|
+
if not ses.has_key?( :deps )
|
268
|
+
# make an array of dependencies for this session, if not already done
|
269
|
+
ses[:deps] = []
|
270
|
+
end
|
271
|
+
dependencies = [dependencies] if dependencies.class == String
|
272
|
+
# Check the required dependencies until everything is loaded.
|
273
|
+
dependencies.each do |dependency|
|
274
|
+
unless ses[:deps].include?( dependency )
|
275
|
+
ses[:deps].push( dependency )
|
276
|
+
msg.reply(%{jsLoader.load("#{dependency}");})
|
277
|
+
end
|
278
|
+
end
|
279
|
+
end
|
280
|
+
|
281
|
+
|
282
|
+
# @private This method looks looks for a file called "values.yaml" in the plugin's bundle directory.
|
283
|
+
# If this file is found, it loads it for initial value definitions.
|
284
|
+
# These definitions are accessible as the +@values+ attribute.
|
285
|
+
def init_values
|
286
|
+
values_path = bundle_path( 'values.yaml' )
|
287
|
+
return yaml_read( values_path )
|
288
|
+
end
|
289
|
+
|
290
|
+
# @private Creates a new instance of HValue, assigns it as +value_name+ into the
|
291
|
+
# session and uses the +value_properties+ Hash to define the default
|
292
|
+
# value and value responders.
|
293
|
+
#
|
294
|
+
# This method is invoked automatically, when handling the properties
|
295
|
+
# of the +values.yaml+ configuration file of a new session.
|
296
|
+
#
|
297
|
+
# It's invoked by +#init_ses+ via +#init_ses_values+.
|
298
|
+
#
|
299
|
+
# Structure of +value_properties+, all top-level items are optional:
|
300
|
+
#
|
301
|
+
# {
|
302
|
+
# # Default value; defaults to 0
|
303
|
+
# :value => 'foo',
|
304
|
+
#
|
305
|
+
# # A plugin method to call to define the default value instead of the one defined in :value
|
306
|
+
# :value_call => {
|
307
|
+
# :plugin => 'plugin_name', # defaults to the plugin where defined
|
308
|
+
# :method => 'method_name', # mandatory; name of the method to call
|
309
|
+
# :args => [ 1, 'foo', 3 ], # optional, list of parameter values for the :method
|
310
|
+
# :uses_msg => true # defaults to true; when false, doesn't pass the msg as the first parameter
|
311
|
+
# },
|
312
|
+
#
|
313
|
+
# # Restore the default, when the session is restored; defaults to true
|
314
|
+
# :restore_default => false,
|
315
|
+
#
|
316
|
+
# # List of value responder methods to bind.
|
317
|
+
# :responders => [
|
318
|
+
# {
|
319
|
+
# :plugin => 'plugin_name', # defaults to the plugin where defined
|
320
|
+
# :method => 'method_name' # mandatory, name of the method to call
|
321
|
+
# },
|
322
|
+
# # You can supply as many responders as you like:
|
323
|
+
# { :plugin => 'another_plugin', :method => 'another_method' }
|
324
|
+
# ]
|
325
|
+
# }
|
326
|
+
#
|
327
|
+
def init_ses_value( msg, value_name, value_properties )
|
328
|
+
ses = get_ses( msg )
|
329
|
+
if value_properties.has_key?(:value_call)
|
330
|
+
default_value = init_value_call( msg, value_properties[:value_call] )
|
331
|
+
elsif value_properties.has_key?(:value)
|
332
|
+
default_value = value_properties[:value]
|
333
|
+
else
|
334
|
+
default_value = 0
|
335
|
+
end
|
336
|
+
ses[value_name] = HValue.new( msg, default_value, { :name => "#{@name}.#{value_name}" } )
|
337
|
+
if value_properties.has_key?(:responders)
|
338
|
+
value_properties[:responders].each do |responder|
|
339
|
+
if responder.has_key?(:plugin)
|
340
|
+
responder_plugin = responder[:plugin]
|
341
|
+
else
|
342
|
+
responder_plugin = @name
|
343
|
+
end
|
344
|
+
if responder.has_key?(:method)
|
345
|
+
ses[value_name].bind( responder_plugin, responder[:method] )
|
346
|
+
end
|
347
|
+
end
|
348
|
+
end
|
349
|
+
end
|
350
|
+
|
351
|
+
# @private Initializes session values, if the contents of the +values.yaml+
|
352
|
+
# file is defined in the bundle directory and loaded in +#init_values+.
|
353
|
+
def init_ses_values( msg )
|
354
|
+
return unless @values
|
355
|
+
@values.each do | value_name, value_properties |
|
356
|
+
init_ses_value( msg, value_name, value_properties )
|
357
|
+
end
|
358
|
+
end
|
359
|
+
|
360
|
+
# @private Returns a value based on the :method and :plugin members of the
|
361
|
+
# +value_call+ hash.
|
362
|
+
#
|
363
|
+
# The call is made via msg.run if the method is not defined in
|
364
|
+
# the local plugin bundle.
|
365
|
+
#
|
366
|
+
# This method is called from +#init_ses_value+.
|
367
|
+
#
|
368
|
+
# Structure of the +value_call+ Hash:
|
369
|
+
# { :plugin => 'plugin_name', # defaults to the plugin where defined
|
370
|
+
# :method => 'method_name', # mandatory; name of the method to call
|
371
|
+
# :args => [ 1, 'foo', 3 ], # optional, list of parameter values for the :method
|
372
|
+
# :uses_msg => true # defaults to true; when false, doesn't pass the msg as the first parameter
|
373
|
+
# }
|
374
|
+
def init_value_call( msg, value_call )
|
375
|
+
value_call_method = value_call[:method]
|
376
|
+
if value_call.has_key?(:plugin)
|
377
|
+
value_call_plugin = value_call[:plugin]
|
378
|
+
else
|
379
|
+
value_call_plugin = false
|
380
|
+
end
|
381
|
+
if value_call.has_key?(:args)
|
382
|
+
if value_call.has_key?(:uses_msg) and value_call[:uses_msg] != false
|
383
|
+
if value_call_plugin
|
384
|
+
return msg.run( value_call_plugin, value_call_method, msg, *value_call[:args] )
|
385
|
+
else
|
386
|
+
return self.method( value_call_method ).call( msg, *value_call[:args] )
|
387
|
+
end
|
388
|
+
else
|
389
|
+
if value_call_plugin
|
390
|
+
return msg.run( value_call_plugin, value_call_method, *value_call[:args] )
|
391
|
+
else
|
392
|
+
return self.method( value_call_method ).call( *value_call[:args] )
|
393
|
+
end
|
394
|
+
end
|
395
|
+
else
|
396
|
+
if value_call.has_key?(:uses_msg) and value_call[:uses_msg] != false
|
397
|
+
if value_call_plugin
|
398
|
+
return msg.run( value_call_plugin, value_call_method, msg )
|
399
|
+
else
|
400
|
+
return self.method( value_call_method ).call( msg )
|
401
|
+
end
|
402
|
+
else
|
403
|
+
if value_call_plugin
|
404
|
+
return msg.run( value_call_plugin, value_call_method )
|
405
|
+
else
|
406
|
+
return self.method( value_call_method ).call( )
|
407
|
+
end
|
408
|
+
end
|
409
|
+
end
|
410
|
+
end
|
411
|
+
|
412
|
+
# @private Restores session values to default, unless specified otherwise.
|
413
|
+
#
|
414
|
+
# Called from +#restore_ses+
|
415
|
+
def restore_ses_values( msg )
|
416
|
+
return unless @values
|
417
|
+
ses = get_ses( msg )
|
418
|
+
@values.each do | value_name, value_properties |
|
419
|
+
if ses.has_key?( value_name ) and ses[ value_name ].class == HValue
|
420
|
+
unless value_properties[:restore_default] == false
|
421
|
+
if value_properties.has_key?(:value_call)
|
422
|
+
default_value = init_value_call( msg, value_properties[:value_call] )
|
423
|
+
elsif value_properties.has_key?(:value)
|
424
|
+
default_value = value_properties[:value]
|
425
|
+
else
|
426
|
+
default_value = 0
|
427
|
+
end
|
428
|
+
ses[value_name].set( msg, default_value )
|
429
|
+
end
|
430
|
+
else
|
431
|
+
init_ses_value( msg, value_name, value_properties )
|
432
|
+
end
|
433
|
+
end
|
434
|
+
end
|
435
|
+
end
|
436
|
+
end
|
437
|
+
end
|
438
|
+
|
@@ -0,0 +1,162 @@
|
|
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
|
+
module RSence
|
11
|
+
|
12
|
+
|
13
|
+
module Plugins
|
14
|
+
|
15
|
+
# This module contains common functionality included in the {Plugin__ Plugin}, {GUIPlugin__ GUIPlugin} and the {Servlet__ Servlet} base classes.
|
16
|
+
#
|
17
|
+
# = Extension hooks for server events
|
18
|
+
# These methods are provided as the basic server event hooks:
|
19
|
+
# * {#init +#init+} -- Use instead of +initialize+
|
20
|
+
# * {#open +#open+} -- Extend to open objects
|
21
|
+
# * {#flush +#flush+} -- Extend to write the state and to flush buffers
|
22
|
+
# * {#close +#close+} -- Extend to close objects
|
23
|
+
#
|
24
|
+
# = Utility methods
|
25
|
+
# These are general utility methods not intended to be extended.
|
26
|
+
# * {#file_read +#file_read+} Use to read files
|
27
|
+
# * {#yaml_read +#yaml_read+} Use to read yaml data
|
28
|
+
# * {#file_write +#file_write+} Use to write files
|
29
|
+
# * {#bundle_path +#bundle_path+} Use for plugin bundle -specific paths
|
30
|
+
# * {#httime +#httime+} Use for HTTP date/time
|
31
|
+
#
|
32
|
+
# = See also
|
33
|
+
# * {file:PluginBundles Plugin Bundles} -- General information about the plugin bundle system
|
34
|
+
# * {Plugin__ Plugin} -- The Plugin base class
|
35
|
+
# * {Servlet__ Servlet} -- The Servlet base class
|
36
|
+
# * {GUIPlugin__ GUIPlugin} -- The GUIPlugin base class
|
37
|
+
module PluginBase
|
38
|
+
|
39
|
+
# @private External accessor for @plugins
|
40
|
+
# @return [PluginManager] The PluginManager the instance belongs to.
|
41
|
+
attr_reader :plugins
|
42
|
+
|
43
|
+
# Extend this method do any initial configuration instead of extending the +initialize+ constructor, which should *never* be done in plugins.
|
44
|
+
#
|
45
|
+
# It is called by the {PluginManager#register_bundle PluginManager} when the plugin has been constructed and registered.
|
46
|
+
#
|
47
|
+
# @return [nil]
|
48
|
+
def init
|
49
|
+
end
|
50
|
+
|
51
|
+
# Extend to open objects like streams and database connections.
|
52
|
+
#
|
53
|
+
# It is called by the {PluginManager#update_bundles! PluginManager} after the {#init} method, when everything is constructed after all plugins are loaded.
|
54
|
+
#
|
55
|
+
# @return [nil]
|
56
|
+
def open
|
57
|
+
end
|
58
|
+
|
59
|
+
# Extend to save your plugin state, write or flush any data that needs to be stored.
|
60
|
+
#
|
61
|
+
# It is called by the {PluginManager#unload_bundle PluginManager} before {#close}, but doesn't always mean a +close+ event is imminent.
|
62
|
+
#
|
63
|
+
# @return [nil]
|
64
|
+
def flush
|
65
|
+
end
|
66
|
+
|
67
|
+
# Extend to close objects like streams and database connections.
|
68
|
+
#
|
69
|
+
# It is called by the {PluginManager#unload_bundle PluginManager} when the plugin is about to be destructed, so don't expect any events after it has been called.
|
70
|
+
#
|
71
|
+
# @return [nil]
|
72
|
+
def close
|
73
|
+
end
|
74
|
+
|
75
|
+
# File reader utility
|
76
|
+
#
|
77
|
+
# Reads the contents of the file given in the +path+.
|
78
|
+
#
|
79
|
+
# @param [String] path The +path+ is relative to the bundle path by default, unless it starts with '/' or '..'; it's simply processed by {#bundle_path} before reading the file.
|
80
|
+
#
|
81
|
+
# @return [false] If there is no file, returns +false+
|
82
|
+
# @return [String] The contents of the file.
|
83
|
+
def file_read( path )
|
84
|
+
path = bundle_path( path )
|
85
|
+
return false unless File.exist?( path )
|
86
|
+
return File.read( path )
|
87
|
+
end
|
88
|
+
|
89
|
+
# YAML reader utility
|
90
|
+
#
|
91
|
+
# Reads the contents of the YAML file given in the +path+ and returns as a parsed structure of the contents of the file.
|
92
|
+
#
|
93
|
+
# @param [String] path The +path+ is relative to the bundle path by default, unless it starts with '/' or '..'; it's simply processed by {#bundle_path} before reading the file.
|
94
|
+
#
|
95
|
+
# @return [false] If the is no file, returns +false+
|
96
|
+
# @return [Object] Any valid structure defined by the YAML file, parsed to a Ruby object.
|
97
|
+
def yaml_read( path )
|
98
|
+
file_data = file_read( path )
|
99
|
+
if not file_data
|
100
|
+
return false
|
101
|
+
else
|
102
|
+
return YAML.load( file_data )
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
# Flie writer utility.
|
107
|
+
#
|
108
|
+
# Writes the contents of the +data+ into the file given in the +path+.
|
109
|
+
# @param [String] path The +path+ is relative to the bundle path by default, unless it starts with '/' or '..'; it's simply processed by {#bundle_path} before writing the file.
|
110
|
+
# @param [#to_s] data The data to write.
|
111
|
+
#
|
112
|
+
# @return [true,false] A success code of the operation (+false+ for failure and +true+ for success).
|
113
|
+
def file_write( path, data )
|
114
|
+
path = bundle_path( path )
|
115
|
+
begin
|
116
|
+
datafile = File.open( path, 'wb' )
|
117
|
+
datafile.write( data.to_s )
|
118
|
+
datafile.close
|
119
|
+
return true
|
120
|
+
rescue => e
|
121
|
+
warn "file_write error for path #{path} #{e}"
|
122
|
+
return false
|
123
|
+
end
|
124
|
+
end
|
125
|
+
alias file_save file_write
|
126
|
+
|
127
|
+
# Path utility
|
128
|
+
#
|
129
|
+
# Makes a full, absolute path using the plugin bundle as the default path when a relative path is given. Returns just the bundle's local path, if no parameters given.
|
130
|
+
#
|
131
|
+
# @param [String, false] path The path is relative to the bundle path by default, unless it starts with '/' or '..'.
|
132
|
+
# @param [String, false] prefix Alternative root path if +path+ is specified as a relative path.
|
133
|
+
# @param [String, false] suffix The file suffix, like the the extension.
|
134
|
+
#
|
135
|
+
# @return [String] Full absolute path.
|
136
|
+
def bundle_path( path=false, prefix=false, suffix=false )
|
137
|
+
return @path if not path
|
138
|
+
if suffix
|
139
|
+
path = "#{path}#{suffix}" unless path.end_with?(suffix)
|
140
|
+
end
|
141
|
+
if prefix
|
142
|
+
path = File.join( prefix, path )
|
143
|
+
end
|
144
|
+
path = File.expand_path( path, @path )
|
145
|
+
return path
|
146
|
+
end
|
147
|
+
|
148
|
+
# Utility for returning the time in the HTTP RFC specification format, like:
|
149
|
+
# !!!text
|
150
|
+
# Sun, 04 Jul 2010 06:20:53 EEST
|
151
|
+
#
|
152
|
+
# @param [Time, false] time An Time object to format. Uses the current date/time by default.
|
153
|
+
#
|
154
|
+
# @return [String] The date/time formatted according to the HTTP RFC specification.
|
155
|
+
def httime(time=false)
|
156
|
+
time = Time.new unless time
|
157
|
+
return time.gmtime.strftime('%a, %d %b %Y %H:%M:%S %Z')
|
158
|
+
end
|
159
|
+
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|
@@ -0,0 +1,81 @@
|
|
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
|
+
module RSence
|
11
|
+
|
12
|
+
|
13
|
+
module Plugins
|
14
|
+
|
15
|
+
|
16
|
+
# Include this module in your subclass of {Plugin__ Plugin} to enable sub-plugin bundles in another plugin bundle.
|
17
|
+
#
|
18
|
+
# The plugins loaded using this system are isolated from system-wide plugins.
|
19
|
+
#
|
20
|
+
# To address them from this plugin, use +@plugin_plugins+ instead of +@plugins+ to access them.
|
21
|
+
#
|
22
|
+
# Install your sub-plugins into a directory named +plugins+ inside your plugin bundle.
|
23
|
+
module PluginPlugins
|
24
|
+
|
25
|
+
# Extended {#init}, delegates calls to the sub-plugins.
|
26
|
+
def init
|
27
|
+
super
|
28
|
+
@plugin_plugins = RSence::PluginManager.new( [ bundle_path('plugins') ] )
|
29
|
+
end
|
30
|
+
|
31
|
+
# Extended {#open}, delegates calls to the sub-plugins.
|
32
|
+
def open
|
33
|
+
super
|
34
|
+
@plugin_plugins.delegate(:open)
|
35
|
+
end
|
36
|
+
|
37
|
+
# Extended {#close}, delegates calls to the sub-plugins.
|
38
|
+
def close
|
39
|
+
super
|
40
|
+
@plugin_plugins.delegate(:close)
|
41
|
+
end
|
42
|
+
|
43
|
+
# Extended {#flush}, delegates calls to the sub-plugins.
|
44
|
+
def flush
|
45
|
+
super
|
46
|
+
@plugin_plugins.delegate(:flush)
|
47
|
+
end
|
48
|
+
|
49
|
+
# Extended {#idle}, delegates calls to the sub-plugins.
|
50
|
+
def idle( msg )
|
51
|
+
super
|
52
|
+
@plugin_plugins.delegate(:idle,msg)
|
53
|
+
end
|
54
|
+
|
55
|
+
# Extended {#init_ses}, delegates calls to the sub-plugins.
|
56
|
+
def init_ses( msg )
|
57
|
+
super
|
58
|
+
@plugin_plugins.delegate(:init_ses,msg)
|
59
|
+
end
|
60
|
+
|
61
|
+
# Extended {#restore_ses}, delegates calls to the sub-plugins.
|
62
|
+
def restore_ses( msg )
|
63
|
+
super
|
64
|
+
@plugin_plugins.delegate(:restore_ses,msg)
|
65
|
+
end
|
66
|
+
|
67
|
+
# Extended {#cloned_target}, delegates calls to the sub-plugins.
|
68
|
+
def cloned_target( msg, source_session )
|
69
|
+
super
|
70
|
+
@plugin_plugins.delegate(:cloned_target,msg,source_session)
|
71
|
+
end
|
72
|
+
|
73
|
+
# Extended {#cloned_source}, delegates calls to the sub-plugins.
|
74
|
+
def cloned_source( msg, target_session )
|
75
|
+
super
|
76
|
+
@plugin_plugins.delegate(:cloned_source,msg,target_session)
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|