Both sides previous revisionPrevious revisionNext revision | Previous revision |
config:modopts.ini [2012/06/15 03:22] – [modopts.ini] More details. digitalman | config:modopts.ini [2023/10/19 12:27] (current) – Don't copy/paste defaults into your modopts.ini file digital man |
---|
====== modopts.ini ====== | ====== Module Options ====== |
This configuration file (located in the Synchronet ''[[dir:ctrl]]'' directory) is used for the configuration of various Synchronet [[custom:JavaScript]] [[:module:|modules]]. | The ''modopts.ini'' configuration file (located in the Synchronet ''[[dir:ctrl]]'' directory) is used for the configuration of various Synchronet [[custom:JavaScript]] [[:module:|modules]]. |
| |
This file (and its corresponding load library: ''modopts.js'') allows multiple modules to be configured in a single file rather than requiring a separate configuration file for each module that has configurable behavior. That said, it is only appropriate for simple enable/disable or option=value type configuration; modules requiring more complex configuration may still necessitate their own separate configuration files. | This file (and its corresponding load library: ''modopts.js'') allows multiple modules to be configured in a single file rather than requiring a separate configuration file for each module that has configurable behavior. That said, it is only appropriate for simple enable/disable or ''//option//=//value//'' type configuration; modules requiring more complex configuration may still necessitate their own separate configuration files. |
| |
===== Format ===== | ===== Format ===== |
Each [[ini_files#named section]] identifies the module which is being configured and the ''key=//value//'' pairs in that section are used to set configuration options for that module. | Each [[ini_files#named section]] identifies the module which is being configured and the ''key=//value//'' pairs in that section are used to set configuration options for that module. |
| |
| If you find that an expected section or key is not present in the file and you want to modify that section or key, just add it. |
===== Use ===== | ===== Use ===== |
JavaScript module authors use the ''modopts.ini'' file by adding a single line to their ''.js'' file: | JavaScript module authors use the ''modopts.ini'' file by adding a single line to their ''.js'' file: |
options=load("modopts.js", "mymodule"); | <code javascript> |
where "mymodule" is replaced with the JavaScript's module name (typically the module script filename, without the ''.js'' extension). | options=load(new Object, "modopts.js", "mymodule"); |
| </code> |
| where "mymodule" is replaced with the JavaScript's module name (typically the module's main script filename, without the ''.js'' extension). |
| |
As a result of this line being executed, the ''options'' object is created with each key in the module's [[ini_files#named section]] becoming a property of the ''options'' object with a String value containing the //value// portion of the ''key=//value//'' line. | As a result of this line being executed, the ''options'' object is created with each key in the module's [[ini_files#named section]] becoming a property of the ''options'' object with a value (Number, Bool, or String) containing the //value// portion of the ''key=//value//'' line. |
| |
| Example ''modopts.ini'' section: |
| <code ini> |
| [mymodule] |
| enable_cool_feature=true |
| </code> |
| |
| Options that need literal values should use a ':' like this: |
| <code ini> |
| [xtrn_sec] |
| which: \r\n\1-\1gWhich or \1h~Q\1n\1guit: \1h |
| </code> |
| |
| Example module use of modopts in a fictional example module named "mymodule" (e.g. ''mymodule.js''): |
| <code javascript> |
| options=load(new Object, "modopts.js", "mymodule"); |
| |
| if(options && options.enable_cool_feature==true) |
| do_cool_feature(); |
| </code> |
| |
| ===== Defaults ===== |
| Synchronet Modules should have optimal default values for any options that they make available via the ''modopts.ini'' file. Unless you have a good reason to do so, it is **not** recommended that you copy default key/value pairs into your ''modopts.ini'' file. Module defaults may change later (in the module script) and automatically using any //new// default option value is most likely what you and the module-script author want/expect to happen. |
| |
===== See Also ===== | ===== See Also ===== |
* [[:config:|config index]] | * [[:config:|Configuration]] |
| * [[module:avatars|Avatars]] |
| * [[module:sbbslist|BBS List]] |
| * [[module:chat_sec|Chat Section]] |
| * [[module:emailval|Email Validation]] |
| * [[module:xtrn_sec|External Programs Section]] |
| * [[module:fido-nodelist-browser|Fido Nodelist Browser]] |
| * [[service:finger|Finger Service]] |
| * [[module:login|Login]] |
| * [[module:logon|Logon]] |
| * [[module:logonlist|Logon List]] |
| * [[module:newuser|New User]] |
| * [[module:nodelist|Node List]] |
| |
| |
| {{tag>configuration javascript module general_config ini}} |
| |
{{tag>}} | |
| |