Line: 1 to 1 | ||||||||
---|---|---|---|---|---|---|---|---|
TWiki Plugins | ||||||||
Line: 190 to 190 | ||||||||
| ||||||||
Changed: | ||||||||
< < |
| |||||||
> > |
| |||||||
| ||||||||
Line: 289 to 289 | ||||||||
Config.spec files are read during TWiki configuration. Once a Config.spec has defined a configuration item, it is available for edit through the standard configure interface. Config.spec files are stored in the 'plugin directory' e.g. lib/TWiki/Plugins/BathPlugin/Config.spec .
Structure of a | ||||||||
Changed: | ||||||||
< < | The Config.spec file for a plugin starts with the plugin announcing what it is: | |||||||
> > | The Config.spec file for an extension starts with the extension announcing what it is: | |||||||
# ---+ BathPlugin # This plugin senses the level of water in your bath, and ensures the plug | ||||||||
Line: 303 to 303 | ||||||||
# *NUMBER* # Enter the chain length in cm | ||||||||
Changed: | ||||||||
< < | $TWiki::cfg{BathPlugin}{ChainLength} = '30'; | |||||||
> > | $TWiki::cfg{BathPlugin}{ChainLength} = 30; | |||||||
# *BOOLEAN EXPERT* | ||||||||
Changed: | ||||||||
< < | # Turn this option off to disable the water temperature alarm $TWiki::cfg{BathPlugin}{TempSensorEnabled} = '1'; | |||||||
> > | # Set this option to 0 to disable the water temperature alarm $TWiki::cfg{BathPlugin}{TempSensorEnabled} = 1; | |||||||
Changed: | ||||||||
< < | The type (e.g. **SELECT** ) tells configure to how to prompt for the value. It also tells configure how to do some basic checking on the value you actually enter. All the comments between the type and the configuration item are taken as part of the description. The configuration item itself defines the default value for the configuration item. The above spec defines the configuration items $TWiki::cfg{BathPlugin}{PlugType} , $TWiki::cfg{BathPlugin}{ChainLength} , and $TWiki::cfg{BathPlugin}{TempSensorEnabled} for use in your plugin. For example, | |||||||
> > | The type (e.g. **SELECT** ) tells configure to how to prompt for the value. It also tells configure how to do some basic checking on the value you actually enter. All the comments between the type and the configuration item are taken as part of the description. The configuration item itself defines the default value for the configuration item. The above spec defines the configuration items $TWiki::cfg{BathPlugin}{PlugType} , $TWiki::cfg{BathPlugin}{ChainLength} , and $TWiki::cfg{BathPlugin}{TempSensorEnabled} for use in your plugin. For example, | |||||||
if( $TWiki::cfg{BathPlugin}{TempSensorEnabled} && $curTemperature > 50 ) { die "The bathwater is too hot for comfort"; } | ||||||||
Changed: | ||||||||
< < | The config.spec file is read by configure, and configure then writes LocalSite.cfg with the values chosen by the local site admin. | |||||||
> > | The config.spec file is read by configure , which then writes LocalSite.cfg with the values chosen by the local site admin. | |||||||
A range of types are available for use in Config.spec files: | ||||||||
Line: 342 to 342 | ||||||||
See lib/TWiki.spec for many more examples. | ||||||||
Changed: | ||||||||
< < | Config.spec files are also used for other (non-plugin) extensions. in this case they are stored under the Contrib directory instead of the Plugins directory. | |||||||
> > | Config.spec files for non-plugin extensions are stored under the Contrib directory instead of the Plugins directory.
Note that from TWiki 5.0 onwards, CGI scripts (in the TWiki bin directory) provided by extensions must also have an entry in the Config.spec file. This entry looks like this (example taken from PublishContrib)
# **PERL H** # Bin script registration - do not modify $TWiki::cfg{SwitchBoard}{publish} = [ "TWiki::Contrib::Publish", "publish", { publishing => 1 } ]; PERL specifies a perl data structure, and H a hidden setting (it won't appear in configure ). The first field of the data value specifies the class where the function that implements the script can be found. The second field specifies the name of the function, which must be the same as the name of the script. The third parameter is a hash of initial context settings for the script. | |||||||
TWiki:TWiki/SpecifyingConfigurationItemsForExtensions has supplemental documentation on configure settings. |