NAME
CallBackery::GuiPlugin::Abstract - GuiPlugin base class
SYNOPSIS
use Mojo::Base 'CallBackery::GuiPlugin::Abstract';
DESCRIPTION
The abstract base class for callbackery gui classes.
ATTRIBUTES
config
The Plugin instance specific config section from the master config file.
name
The PLUGIN instance 'name' as specified in the *** PLUGIN:... ***
section.
user
The current user object
tabName
What should the tab holding this plugin be called
instantiationMode
Should the plugin in the webui be instantiated immediately or only when the tab gets selected
grammar
Returns the Config::Grammar parser for the configuration of this plugin.
schema
A very simple minded grammar to json-schema convertor with no magic. Better supply a proper schema.
controller
the current controller
app
the app object
log
the log object
args
some meta information provided when instantiating the plugin. for example when buidling the response to getUserConfig, args will contain the output of getUrlConfig from the frontend in the key urlConfig, which will allow to pass information from the url to calls like checkAccess.
screenCfg
Returns the information for building a plugin configuration screen.
checkAccess()
Check if the current user may access the Plugin. Override in the Child class to limit accessibility. By default plugins are not accessible unless you have numeric UID or the word __CONFIG
.
The CallBackery::Command::shell sets the userId to __SHELL
. If a plugin should be configurable interactively it must allow access to the __SHELL
user.
checkAccess can also return a promise or be an async method
mayAnonymous
may this gui plugin run for unauthenticated users ?
stateFiles
A list of files that contain the state of the settings configured by this plugin this is used both for backup purposes and to replicate the settings to a second installation.
unconfigureFiles
a list of files to be removed when 'unConfiguring' a device
eventActions
A map of callbacks that will be called according to events in the system. The following events are available:
configChanged
METHODS
All the methods of Mojo::Base plus:
makeRxValidator(rx,error)
Create a regular expression base validator function. The supplied regular expression gets anchored front and back automatically.
filterHashKey(data,key)
Walks a hash/array structure and removes all occurrences of the given key.
CODE references get turned into 'true' values and JSON true/false get passed on.
processData(arguments)
Take the data from the plug-in screen and process them.
getData(arguments)
Receive current data for plug-in screen content.
reConfigure
Re-generate all configuration that does not require direct user input. This function may be called from within action handlers to apply newly acquired data to to the running system.
validateData(arguments)
Validate user supplied data prior to acting on it.
mergeGrammar
A very simpleminded grammar merger with no recursion. For identical keys, the later instance wins.
varCompiler
Returns a compiler sub reference for use in configuration variables or _text sections with perl syntax. The resulting sub will provide access to a hash called $variableName.
massageConfig($cfg)
Allow the plugin to 'massage' the config hash ... doing this requires deep knowledge of the cfg structure ...
renderTemplate(template,destination)
Render the given template and write the result into the given file. These templates support the Mojo::Template language enhanced by the command L('Plugin::key')
which looks up values from the config database. The convention is that each plugin writes data in it's own namespace.
If the destination already exists, the method compares the current content with the new one. It will only update the file if the content differs.
The method returns 0 when there was no change and 1 when a new version of the file was written.
These additional commands are available to the templates.
slurp(file)
getConfigValue(key)
Read a config value from the database.
setConfigValue(key)
Save a config value to the database.
systemNoFd(args)
A version of the system function that makes sure to NOT to inherit any extra filehandles to the kids and sends the output of the call system log file. I would suggest to use this in preference to the normal system function. Especially when launching daemons since Mojo seems to fiddle with $^F and will thus inherit open sockets to child processes.
If the binary name starts with -, the output will be ignored ... this can be necessary for programs starting daemons that do not close their output. Otherwhise you will read the output of the daemon and NOT terminate. We are also using kill 0 to check if the process is still active.
LICENSE
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
COPYRIGHT
Copyright (c) 2013 by OETIKER+PARTNER AG. All rights reserved.
AUTHOR
Tobias Oetiker <tobi@oetiker.ch>
HISTORY
2013-12-16 to 1.0 first version