version = "0.1" # version number, not used yet but important
name = "name that will be displayed on the admin"
[section_id]
name = "name of the section that will be displayed"
[section_id.sub_section_id]
name = "sub section"
# those arguments are in yunohost argument format like manifest.json
[section_id.sub_section_id.option_id]
ask = "the text displayed for the option"
type = "argument_option"
default = true
help = "A public Leed will be accessible for third party apps.<br>By turning on 'anonymous readers' in Leed configuration, you can made your feeds public."
help = "A public Leed will be accessible for third party apps.<br>By turning on 'anonymous readers' in Leed configuration, you can made your feeds public."
[main.overwrite_files]
name = "Overwriting config files"
[main.overwrite_files.overwrite_nginx]
ask = "Overwrite the nginx config file ?"
type = "boolean"
default = true
help = "If the file is overwritten, a backup will be created."
[main.overwrite_files.overwrite_phpfpm]
ask = "Overwrite the php-fpm config file ?"
type = "boolean"
default = true
help = "If the file is overwritten, a backup will be created."
...
```
### the scripts/config script
To make your configuration panel functional you need write a "config" script
that will be location in the "script" folder like the "install" script. This
script will be called at 2 different occasions:
* when the configuration panel is displayed and yunohost needs to fill the values
* when the configuration is modified by the user
Every option of the configuration panel will be send to the script
following this naming convention:
```bash
YNH_{section_id}_{sub_section_id}_{option_id} (everything in upper case)
```
For example, this option value:
```toml
[main]
name = "Leed configuration"
[main.is_public]
name = "Public access"
# those arguments are in yunohost argument format
[main.is_public.is_public]
...
```
Will be available under this name in the config script:
```
YNH_CONFIG_MAIN_IS_PUBLIC_IS_PUBLIC
```
Also, the same "scripts/config" script is called in both situation. To differentiate
those situation the first argument passed to the config script is either "show"
or "apply".
A common pattern to handle that is to write your script following this pattern:
```bash
show_config() {
# do stuff
}
apply_config() {
# do stuff
}
case $1 in
show) show_config;;
apply) apply_config;;
esac
```
#### The "show" part
The show part is when the user ask to see the current state of the
configuration panel (like opening to configuration panel page on the admin
interface). The role of the scripts/config script here is to gather all the
relevant information, by for example parsing a configuration file or querying a
database, and communicate it to YunoHost. To do so, you need to use the helper