mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
doc:config: misc cosmetics fix
This commit is contained in:
parent
ee72d2f463
commit
b80868e967
3 changed files with 64 additions and 65 deletions
|
@ -141,7 +141,7 @@ You can read and write values with 2 mechanisms: the `bind` property in the `con
|
|||
`bind` allows us to alter the default behavior of applying option's values, which is: get from and set in the app `settings.yml`.
|
||||
|
||||
We can:
|
||||
- alter the source the value comes from wit binds to file or custom getters.
|
||||
- alter the source the value comes from with binds to file or custom getters.
|
||||
- alter the destination with binds to file or settings.
|
||||
- parse/validate the value before destination with validators
|
||||
|
||||
|
|
|
@ -88,9 +88,10 @@ class SectionModel(ContainerModel, OptionsModel):
|
|||
Group options. Sections are `dict`s defined inside a Panel and require a unique id (in the below example, the id is `customization` prepended by the panel's id `main`). Keep in mind that this combined id will be used in CLI to refer to the section, so choose something short and meaningfull. Also make sure to not make a typo in the panel id, which would implicitly create an other entire panel.
|
||||
|
||||
If at least one `button` is present it then become an action section.
|
||||
Options in action sections are not considered settings and therefor are not saved, they are more like parameters that exists only during the execution of an action. FIXME i'm not sure we have this in code.
|
||||
Options in action sections are not considered settings and therefor are not saved, they are more like parameters that exists only during the execution of an action.
|
||||
FIXME i'm not sure we have this in code.
|
||||
|
||||
##### Examples
|
||||
### Examples
|
||||
```toml
|
||||
[main]
|
||||
|
||||
|
@ -100,18 +101,19 @@ class SectionModel(ContainerModel, OptionsModel):
|
|||
help = "Every form items in this section are not saved."
|
||||
services = ["__APP__", "nginx"]
|
||||
|
||||
[config.advanced.option]
|
||||
[main.customization.option_id]
|
||||
type = "string"
|
||||
# …refer to Options doc
|
||||
```
|
||||
##### Properties
|
||||
|
||||
### Properties
|
||||
- `name` (optional): `Translation` or `str`, displayed as the section's title if any
|
||||
- `help`: `Translation` or `str`, text to display before the first option
|
||||
- `services` (optional): `list` of services names to reload when any option's value contained in the section changes
|
||||
- `services` (optional): `list` of services names to `reload-or-restart` when any option's value contained in the section changes
|
||||
- `"__APP__` will refer to the app instance name
|
||||
- `optional`: `bool` (default: `true`), set the default `optional` prop of all Options in the section
|
||||
- `visible`: `bool` or `JSExpression` (default: `true`), allow to conditionally display a section depending on user's answers to previous questions.
|
||||
- Be careful that the `visible` property should only refer to **previous** questions. Hence, it should not make sense to have a `visible` property on the very first section.
|
||||
- Be careful that the `visible` property should only refer to **previous** options's value. Hence, it should not make sense to have a `visible` property on the very first section.
|
||||
"""
|
||||
|
||||
visible: Union[bool, str] = True
|
||||
|
@ -163,7 +165,7 @@ class PanelModel(ContainerModel):
|
|||
"""
|
||||
Group sections. Panels are `dict`s defined inside a ConfigPanel file and require a unique id (in the below example, the id is `main`). Keep in mind that this id will be used in CLI to refer to the panel, so choose something short and meaningfull.
|
||||
|
||||
##### Examples
|
||||
### Examples
|
||||
```toml
|
||||
[main]
|
||||
name.en = "Main configuration"
|
||||
|
@ -174,10 +176,10 @@ class PanelModel(ContainerModel):
|
|||
[main.customization]
|
||||
# …refer to Sections doc
|
||||
```
|
||||
##### Properties
|
||||
### Properties
|
||||
- `name`: `Translation` or `str`, displayed as the panel title
|
||||
- `help` (optional): `Translation` or `str`, text to display before the first section
|
||||
- `services` (optional): `list` of services names to `reload-or-restart when any option's value contained in the panel changes
|
||||
- `services` (optional): `list` of services names to `reload-or-restart` when any option's value contained in the panel changes
|
||||
- `"__APP__` will refer to the app instance name
|
||||
- `actions`: FIXME not sure what this does
|
||||
"""
|
||||
|
@ -219,7 +221,7 @@ class ConfigPanelModel(BaseModel):
|
|||
|
||||
Those panels could also be used as interface generator to extend quickly capabilities of YunoHost (e.g. VPN Client, Hotspost, Borg, etc.).
|
||||
|
||||
From a packager perspective, this `config_panel.toml` is coupled to the `scripts/config` script, which may be used to define custom getters/setters. However, most use cases should be covered automagically by the core, thus it may not be necessary to define a scripts/config at all!
|
||||
From a packager perspective, this `config_panel.toml` is coupled to the `scripts/config` script, which may be used to define custom getters/setters/validations/actions. However, most use cases should be covered automagically by the core, thus it may not be necessary to define a scripts/config at all!
|
||||
|
||||
! IMPORTANT: Please: Keep in mind the YunoHost spirit, and try to build your panels in such a way as to expose only really useful parameters, and if there are many of them, to relegate those corresponding to rarer use cases to "Advanced" sub-sections.
|
||||
|
||||
|
@ -248,19 +250,19 @@ class ConfigPanelModel(BaseModel):
|
|||
- [Check config panels of other apps](https://grep.app/search?q=version&filter[repo.pattern][0]=YunoHost-Apps&filter[lang][0]=TOML)
|
||||
- [Check `scripts/config` of other apps](https://grep.app/search?q=ynh_app_config_apply&filter[repo.pattern][0]=YunoHost-Apps&filter[lang][0]=Shell)
|
||||
|
||||
##### Examples
|
||||
### Examples
|
||||
```toml
|
||||
version = 1.0
|
||||
|
||||
[config]
|
||||
# …refer to Panels doc
|
||||
```
|
||||
##### Properties
|
||||
### Properties
|
||||
- `version`: `float` (default: `1.0`), version that the config panel supports in terms of features.
|
||||
- `i18n` (optional): `str`, an i18n property that let you internationalize options text.
|
||||
- However this feature is only available in core configuration panel (like `yunohost domain config`), prefer the use `Translation` in `name`, `help`, etc.
|
||||
|
||||
###### Version
|
||||
#### Version
|
||||
Here a small reminder to associate config panel version with YunoHost version.
|
||||
|
||||
| Config | YNH | Config panel small change log |
|
||||
|
|
|
@ -299,17 +299,14 @@ class Pattern(BaseModel):
|
|||
|
||||
class BaseOption(BaseModel):
|
||||
"""
|
||||
Options are fields declaration that renders as form items, button, alerts or text in the web-admin and printed or prompted in CLI.
|
||||
Options are fields declaration that renders as form items, button, alert or text in the web-admin and printed or prompted in CLI.
|
||||
They are used in app manifests to declare the before installation form and in config panels.
|
||||
|
||||
[Have a look at the app config panel doc](/packaging_apps_config_panels) for details about Panels and Sections.
|
||||
|
||||
----------------
|
||||
IMPORTANT: as for Panels and Sections you have to choose an id, but this one should be unique in all this document, even if the question is in an other panel.
|
||||
! IMPORTANT: as for Panels and Sections you have to choose an id, but this one should be unique in all this document, even if the question is in an other panel.
|
||||
|
||||
----------------
|
||||
|
||||
##### Examples
|
||||
#### Examples
|
||||
|
||||
```toml
|
||||
[section.my_option_id]
|
||||
|
@ -326,7 +323,7 @@ class BaseOption(BaseModel):
|
|||
bind = "null"
|
||||
```
|
||||
|
||||
##### Properties
|
||||
#### Properties
|
||||
|
||||
- `type`:
|
||||
- readonly types:
|
||||
|
@ -448,7 +445,7 @@ class DisplayTextOption(BaseReadonlyOption):
|
|||
"""
|
||||
Display simple multi-line content.
|
||||
|
||||
##### Examples
|
||||
#### Examples
|
||||
|
||||
```toml
|
||||
[section.my_option_id]
|
||||
|
@ -465,7 +462,7 @@ class MarkdownOption(BaseReadonlyOption):
|
|||
Display markdown multi-line content.
|
||||
Markdown is currently only rendered in the web-admin
|
||||
|
||||
##### Examples
|
||||
#### Examples
|
||||
```toml
|
||||
[section.my_option_id]
|
||||
type = "display_text"
|
||||
|
@ -488,7 +485,7 @@ class AlertOption(BaseReadonlyOption):
|
|||
Alerts displays a important message with a level of severity.
|
||||
You can use markdown in `ask` but will only be rendered in the web-admin.
|
||||
|
||||
##### Examples
|
||||
#### Examples
|
||||
|
||||
```toml
|
||||
[section.my_option_id]
|
||||
|
@ -497,7 +494,7 @@ class AlertOption(BaseReadonlyOption):
|
|||
style = "warning"
|
||||
icon = "warning"
|
||||
```
|
||||
##### Properties
|
||||
#### Properties
|
||||
|
||||
- [common properties](#common-option-properties)
|
||||
- `style`: any of `"success|info|warning|danger"` (default: `"info"`)
|
||||
|
@ -529,7 +526,7 @@ class ButtonOption(BaseReadonlyOption):
|
|||
Every options defined in an action section (a config panel section with at least one `button`) is guaranted to be shown/asked to the user and available in `scripts/config`'s scope.
|
||||
[check examples in advanced use cases](#actions).
|
||||
|
||||
##### Examples
|
||||
#### Examples
|
||||
|
||||
```toml
|
||||
[section.my_option_id]
|
||||
|
@ -549,7 +546,7 @@ class ButtonOption(BaseReadonlyOption):
|
|||
}
|
||||
```
|
||||
|
||||
##### Properties
|
||||
#### Properties
|
||||
|
||||
- [common properties](#common-option-properties)
|
||||
- `bind`: forced to `"null"`
|
||||
|
@ -583,7 +580,7 @@ class BaseInputOption(BaseOption):
|
|||
"""
|
||||
Rest of the option types available are considered `inputs`.
|
||||
|
||||
##### Examples
|
||||
#### Examples
|
||||
|
||||
```toml
|
||||
[section.my_option_id]
|
||||
|
@ -597,7 +594,7 @@ class BaseInputOption(BaseOption):
|
|||
placeholder = "write something…"
|
||||
```
|
||||
|
||||
##### Properties
|
||||
#### Properties
|
||||
|
||||
- [common properties](#common-option-properties)
|
||||
- `optional`: `bool` (default: `false`, but `true` in config panels)
|
||||
|
@ -760,7 +757,7 @@ class StringOption(BaseStringOption):
|
|||
"""
|
||||
Ask for a simple string.
|
||||
|
||||
##### Examples
|
||||
#### Examples
|
||||
```toml
|
||||
[section.my_option_id]
|
||||
type = "string"
|
||||
|
@ -769,7 +766,7 @@ class StringOption(BaseStringOption):
|
|||
pattern.error = "Provide a room like F12 : one uppercase and 2 numbers"
|
||||
```
|
||||
|
||||
##### Properties
|
||||
#### Properties
|
||||
- [common inputs properties](#common-inputs-properties)
|
||||
- `default`: `""`
|
||||
- `pattern` (optional): `Pattern`, a regex to match the value against
|
||||
|
@ -783,13 +780,13 @@ class TextOption(BaseStringOption):
|
|||
Ask for a multiline string.
|
||||
Renders as a `textarea` in the web-admin and by opening a text editor on the CLI.
|
||||
|
||||
##### Examples
|
||||
#### Examples
|
||||
```toml
|
||||
[section.my_option_id]
|
||||
type = "text"
|
||||
default = "multi\\nline\\ncontent"
|
||||
```
|
||||
##### Properties
|
||||
#### Properties
|
||||
- [common inputs properties](#common-inputs-properties)
|
||||
- `default`: `""`
|
||||
- `pattern` (optional): `Pattern`, a regex to match the value against
|
||||
|
@ -806,12 +803,12 @@ class PasswordOption(BaseInputOption):
|
|||
Ask for a password.
|
||||
The password is tested as a regular user password (at least 8 chars)
|
||||
|
||||
##### Examples
|
||||
#### Examples
|
||||
```toml
|
||||
[section.my_option_id]
|
||||
type = "password"
|
||||
```
|
||||
##### Properties
|
||||
#### Properties
|
||||
- [common inputs properties](#common-inputs-properties)
|
||||
- `default`: forced to `""`
|
||||
- `redact`: forced to `true`
|
||||
|
@ -858,13 +855,13 @@ class ColorOption(BaseInputOption):
|
|||
Ask for a color represented as a hex value (with possibly an alpha channel).
|
||||
Renders as color picker in the web-admin and as a prompt that accept named color like `yellow` in CLI.
|
||||
|
||||
##### Examples
|
||||
#### Examples
|
||||
```toml
|
||||
[section.my_option_id]
|
||||
type = "color"
|
||||
default = "#ff0"
|
||||
```
|
||||
##### Properties
|
||||
#### Properties
|
||||
- [common inputs properties](#common-inputs-properties)
|
||||
- `default`: `""`
|
||||
"""
|
||||
|
@ -904,7 +901,7 @@ class NumberOption(BaseInputOption):
|
|||
"""
|
||||
Ask for a number (an integer).
|
||||
|
||||
##### Examples
|
||||
#### Examples
|
||||
```toml
|
||||
[section.my_option_id]
|
||||
type = "number"
|
||||
|
@ -913,7 +910,7 @@ class NumberOption(BaseInputOption):
|
|||
max = 200
|
||||
step = 5
|
||||
```
|
||||
##### Properties
|
||||
#### Properties
|
||||
- [common inputs properties](#common-inputs-properties)
|
||||
- `type`: `number` or `range` (input or slider in the web-admin)
|
||||
- `min` (optional): minimal int value inclusive
|
||||
|
@ -979,7 +976,7 @@ class BooleanOption(BaseInputOption):
|
|||
Ask for a boolean.
|
||||
Renders as a switch in the web-admin and a yes/no prompt in CLI.
|
||||
|
||||
##### Examples
|
||||
#### Examples
|
||||
```toml
|
||||
[section.my_option_id]
|
||||
type = "boolean"
|
||||
|
@ -987,7 +984,7 @@ class BooleanOption(BaseInputOption):
|
|||
yes = "agree"
|
||||
no = "disagree"
|
||||
```
|
||||
##### Properties
|
||||
#### Properties
|
||||
- [common inputs properties](#common-inputs-properties)
|
||||
- `default`: `0`
|
||||
- `yes` (optional): (default: `1`) define as what the thruthy value should output
|
||||
|
@ -1107,13 +1104,13 @@ class DateOption(BaseInputOption):
|
|||
|
||||
Can also take a timestamp as value that will output as an ISO date string.
|
||||
|
||||
##### Examples
|
||||
#### Examples
|
||||
```toml
|
||||
[section.my_option_id]
|
||||
type = "date"
|
||||
default = "2070-12-31"
|
||||
```
|
||||
##### Properties
|
||||
#### Properties
|
||||
- [common inputs properties](#common-inputs-properties)
|
||||
- `default`: `""`
|
||||
"""
|
||||
|
@ -1137,13 +1134,13 @@ class TimeOption(BaseInputOption):
|
|||
Ask for an hour in the form `"22:35"`.
|
||||
Renders as a date-picker in the web-admin and a regular prompt in CLI.
|
||||
|
||||
##### Examples
|
||||
#### Examples
|
||||
```toml
|
||||
[section.my_option_id]
|
||||
type = "time"
|
||||
default = "12:26"
|
||||
```
|
||||
##### Properties
|
||||
#### Properties
|
||||
- [common inputs properties](#common-inputs-properties)
|
||||
- `default`: `""`
|
||||
"""
|
||||
|
@ -1170,13 +1167,13 @@ class EmailOption(BaseInputOption):
|
|||
"""
|
||||
Ask for an email. Validation made with [python-email-validator](https://github.com/JoshData/python-email-validator)
|
||||
|
||||
##### Examples
|
||||
#### Examples
|
||||
```toml
|
||||
[section.my_option_id]
|
||||
type = "email"
|
||||
default = "Abc.123@test-example.com"
|
||||
```
|
||||
##### Properties
|
||||
#### Properties
|
||||
- [common inputs properties](#common-inputs-properties)
|
||||
- `default`: `""`
|
||||
"""
|
||||
|
@ -1190,13 +1187,13 @@ class WebPathOption(BaseStringOption):
|
|||
"""
|
||||
Ask for an web path (the part of an url after the domain). Used by default in app install to define from where the app will be accessible.
|
||||
|
||||
##### Examples
|
||||
#### Examples
|
||||
```toml
|
||||
[section.my_option_id]
|
||||
type = "path"
|
||||
default = "/"
|
||||
```
|
||||
##### Properties
|
||||
#### Properties
|
||||
- [common inputs properties](#common-inputs-properties)
|
||||
- `default`: `""`
|
||||
- `pattern` (optional): `Pattern`, a regex to match the value against
|
||||
|
@ -1238,13 +1235,13 @@ class URLOption(BaseStringOption):
|
|||
"""
|
||||
Ask for any url.
|
||||
|
||||
##### Examples
|
||||
#### Examples
|
||||
```toml
|
||||
[section.my_option_id]
|
||||
type = "url"
|
||||
default = "https://example.xn--zfr164b/@handle/"
|
||||
```
|
||||
##### Properties
|
||||
#### Properties
|
||||
- [common inputs properties](#common-inputs-properties)
|
||||
- `default`: `""`
|
||||
- `pattern` (optional): `Pattern`, a regex to match the value against
|
||||
|
@ -1262,7 +1259,7 @@ class FileOption(BaseInputOption):
|
|||
Ask for file.
|
||||
Renders a file prompt in the web-admin and ask for a path in CLI.
|
||||
|
||||
##### Examples
|
||||
#### Examples
|
||||
```toml
|
||||
[section.my_option_id]
|
||||
type = "file"
|
||||
|
@ -1270,7 +1267,7 @@ class FileOption(BaseInputOption):
|
|||
# bind the file to a location to save the file there
|
||||
bind = "/tmp/my_file.json"
|
||||
```
|
||||
##### Properties
|
||||
#### Properties
|
||||
- [common inputs properties](#common-inputs-properties)
|
||||
- `default`: `""`
|
||||
- `accept`: a comma separated list of extension to accept like `".conf, .ini`
|
||||
|
@ -1390,7 +1387,7 @@ class SelectOption(BaseChoicesOption):
|
|||
Ask for value from a limited set of values.
|
||||
Renders as a regular `<select/>` in the web-admin and as a regular prompt in CLI with autocompletion of `choices`.
|
||||
|
||||
##### Examples
|
||||
#### Examples
|
||||
```toml
|
||||
[section.my_option_id]
|
||||
type = "select"
|
||||
|
@ -1398,7 +1395,7 @@ class SelectOption(BaseChoicesOption):
|
|||
choices = "one,two,three"
|
||||
default = "two"
|
||||
```
|
||||
##### Properties
|
||||
#### Properties
|
||||
- [common inputs properties](#common-inputs-properties)
|
||||
- `default`: `""`, obviously the default has to be empty or an available `choices` item.
|
||||
- `choices`: a (coma separated) list of values
|
||||
|
@ -1418,7 +1415,7 @@ class TagsOption(BaseChoicesOption):
|
|||
|
||||
This output as a coma separated list of strings `"one,two,three"`
|
||||
|
||||
##### Examples
|
||||
#### Examples
|
||||
```toml
|
||||
[section.my_option_id]
|
||||
type = "tags"
|
||||
|
@ -1430,7 +1427,7 @@ class TagsOption(BaseChoicesOption):
|
|||
# choices = "one,two,three"
|
||||
default = "two,three"
|
||||
```
|
||||
##### Properties
|
||||
#### Properties
|
||||
- [common inputs properties](#common-inputs-properties)
|
||||
- `default`: `""`, obviously the default has to be empty or an available `choices` item.
|
||||
- `pattern` (optional): `Pattern`, a regex to match all the values against
|
||||
|
@ -1523,12 +1520,12 @@ class DomainOption(BaseChoicesOption):
|
|||
Ask for a user domain.
|
||||
Renders as a select in the web-admin and as a regular prompt in CLI with autocompletion of registered domains.
|
||||
|
||||
##### Examples
|
||||
#### Examples
|
||||
```toml
|
||||
[section.my_option_id]
|
||||
type = "domain"
|
||||
```
|
||||
##### Properties
|
||||
#### Properties
|
||||
- [common inputs properties](#common-inputs-properties)
|
||||
- `default`: forced to the instance main domain
|
||||
"""
|
||||
|
@ -1577,13 +1574,13 @@ class AppOption(BaseChoicesOption):
|
|||
Ask for a user app.
|
||||
Renders as a select in the web-admin and as a regular prompt in CLI with autocompletion of installed apps.
|
||||
|
||||
##### Examples
|
||||
#### Examples
|
||||
```toml
|
||||
[section.my_option_id]
|
||||
type = "app"
|
||||
filter = "is_webapp"
|
||||
```
|
||||
##### Properties
|
||||
#### Properties
|
||||
- [common inputs properties](#common-inputs-properties)
|
||||
- `default`: `""`
|
||||
- `filter` (optional): `JSExpression` with what `yunohost app info <app_id> --full` returns as context (only first level keys)
|
||||
|
@ -1630,12 +1627,12 @@ class UserOption(BaseChoicesOption):
|
|||
Ask for a user.
|
||||
Renders as a select in the web-admin and as a regular prompt in CLI with autocompletion of available usernames.
|
||||
|
||||
##### Examples
|
||||
#### Examples
|
||||
```toml
|
||||
[section.my_option_id]
|
||||
type = "user"
|
||||
```
|
||||
##### Properties
|
||||
#### Properties
|
||||
- [common inputs properties](#common-inputs-properties)
|
||||
- `default`: the first admin user found
|
||||
"""
|
||||
|
@ -1690,13 +1687,13 @@ class GroupOption(BaseChoicesOption):
|
|||
Ask for a group.
|
||||
Renders as a select in the web-admin and as a regular prompt in CLI with autocompletion of available groups.
|
||||
|
||||
##### Examples
|
||||
#### Examples
|
||||
```toml
|
||||
[section.my_option_id]
|
||||
type = "group"
|
||||
default = "visitors"
|
||||
```
|
||||
##### Properties
|
||||
#### Properties
|
||||
- [common inputs properties](#common-inputs-properties)
|
||||
- `default`: `"all_users"`, `"visitors"` or `"admins"` (default: `"all_users"`)
|
||||
"""
|
||||
|
|
Loading…
Add table
Reference in a new issue