mirror of
https://github.com/YunoHost-Apps/fider_ynh.git
synced 2024-09-03 18:36:11 +02:00
[enh] Apply suggestions from code review
Co-authored-by: Alexandre Aubin <alex.aubin@mailoo.org>
This commit is contained in:
parent
12eb08b590
commit
2c2ebd5ec1
1 changed files with 87 additions and 63 deletions
|
@ -1,12 +1,16 @@
|
||||||
|
|
||||||
## Config panel are available from webadmin > Apps > YOUR_APP > Config Panel Button
|
## Config panel are available from webadmin > Apps > YOUR_APP > Config Panel Button
|
||||||
## Those panels let user configure some params on there apps to avoid them to change
|
## Those panels let user configure some params on their apps using a friendly interface,
|
||||||
## its by hand in configuration file and be abliged to reapply their changes at each
|
## and remove the need to manually edit files from the command line.
|
||||||
## app upgrade.
|
|
||||||
|
## From a packager perspective, this .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!
|
||||||
|
|
||||||
## -----------------------------------------------------------------------------
|
## -----------------------------------------------------------------------------
|
||||||
## IMPORTANT: YunoHost spirits is simplicity, please don't expose here tons of
|
## IMPORTANT: In accordance with YunoHost's spirit, please keep things simple and
|
||||||
## misunderstanble app settings or not really useful feature.
|
## do not overwhelm the admin with tons of misunderstandable or advanced settings.
|
||||||
## -----------------------------------------------------------------------------
|
## -----------------------------------------------------------------------------
|
||||||
|
|
||||||
## The top level describe the entire config panels screen.
|
## The top level describe the entire config panels screen.
|
||||||
|
@ -33,21 +37,18 @@ version = "1.0"
|
||||||
## You have to choose an ID for each panel, in this example the ID is "main"
|
## You have to choose an ID for each panel, in this example the ID is "main"
|
||||||
## Keep in mind this id will be used in cli to refer to your question, so choose
|
## Keep in mind this id will be used in cli to refer to your question, so choose
|
||||||
## something short and meaningfull.
|
## something short and meaningfull.
|
||||||
## Note: each panel is a distinct HTML form.
|
## In the webadmin, each panel corresponds to a distinct tab / form
|
||||||
[main]
|
[main]
|
||||||
|
|
||||||
## (recommended) You should define the label of your panel (and associated tab)
|
## Define the label for your panel
|
||||||
## If you don't define it, the ID will be used as title
|
## Internationalization works similarly to the 'description' and 'ask' questions in the manifest
|
||||||
name = "Main configuration"
|
|
||||||
|
|
||||||
## To internationalize the name, and other textual properties you can suggest
|
|
||||||
## translation like this:
|
|
||||||
# name.en = "Main configuration"
|
# name.en = "Main configuration"
|
||||||
# name.fr = "Configuration principale"
|
# name.fr = "Configuration principale"
|
||||||
|
|
||||||
## (optional) If you need to trigger a service reload-or-restart after the user
|
## (optional) If you need to trigger a service reload-or-restart after the user
|
||||||
## change a question in this panel, you can add your service in the list.
|
## change a question in this panel, you can add your service in the list.
|
||||||
services = ["nginx", "__APP__"]
|
services = ["__APP__"]
|
||||||
|
# or services = ["nginx", "__APP__"] to also reload-or-restart nginx
|
||||||
|
|
||||||
## (optional) This help properties is a short help displayed on the same line
|
## (optional) This help properties is a short help displayed on the same line
|
||||||
## than the panel title but not displayed in the tab.
|
## than the panel title but not displayed in the tab.
|
||||||
|
@ -57,21 +58,27 @@ services = ["nginx", "__APP__"]
|
||||||
#### ABOUT SECTIONS
|
#### ABOUT SECTIONS
|
||||||
############################################################################
|
############################################################################
|
||||||
|
|
||||||
## A panel is compound of one or several sections.
|
## A panel is composed of one or several sections.
|
||||||
## You have to choose an ID for your section and prefix it with the panel ID
|
##
|
||||||
## Be sure to not make a typo in panel prefix, or you will get an unwanted
|
## Sections are meant to group questions together when they correspond to
|
||||||
## panel in more.
|
## a same subtopic. This impacts the rendering in terms of CLI prompts
|
||||||
## For this example we imagine, we package the pepettes_ynh app.
|
## and HTML forms
|
||||||
## It's a really simple donation form without administration panel, so we
|
##
|
||||||
## want to expose some settings
|
## You should choose an ID for your section, and prefix it with the panel ID
|
||||||
|
## (Be sure to not make a typo in the panel ID, which would implicitly create
|
||||||
|
## an other entire panel)
|
||||||
|
##
|
||||||
|
## We use the context of pepettes_ynh as an example,
|
||||||
|
## which is a simple donation form app written in python,
|
||||||
|
## and for which the admin will want to edit the configuration
|
||||||
[main.customization]
|
[main.customization]
|
||||||
|
|
||||||
## (optional) A section could have a title, or not. It depends of what you
|
## (optional) Defining a proper title for sections is not mandatory
|
||||||
## are doing exactly. In web admin it will display an <h3> title.
|
## and depends on the exact rendering you're aiming for the CLI / webadmin
|
||||||
name = ""
|
name = ""
|
||||||
|
|
||||||
## (optional) This help properties is a short help displayed on the same line
|
## (optional) This help properties is a short help displayed on the same line
|
||||||
## than the section title.
|
## than the section title, meant to provide additional details
|
||||||
# help = ""
|
# help = ""
|
||||||
|
|
||||||
## (optional) As for panel, you can specify to trigger a service
|
## (optional) As for panel, you can specify to trigger a service
|
||||||
|
@ -84,13 +91,14 @@ services = ["nginx", "__APP__"]
|
||||||
## default behaviour for question in the section
|
## default behaviour for question in the section
|
||||||
optional = false
|
optional = false
|
||||||
|
|
||||||
## (optional) It's also possible with the 'visible' property to display the
|
## (optional) It's also possible with the 'visible' property to only
|
||||||
## question only if the user answer the form in a specific way.
|
## display the section depending on the user's answers to previous questions.
|
||||||
## However, you should not refer to questions after the point where you put
|
##
|
||||||
## the visible property. SO the first section should never have a visible
|
## Be careful that the 'visible' property should only refer to **previous** questions
|
||||||
## property
|
## Hence, it should not make sense to have a "visible" property on the very first section.
|
||||||
## In more this feature is available in webadmin but not in cli, so keep in
|
##
|
||||||
## mind cli user could be prompted for the question...
|
## Also, keep in mind that this feature only works in the webadmin and not in CLI
|
||||||
|
## (therefore a user could be prompted in CLI for a question that may not be relevant)
|
||||||
# visible = true
|
# visible = true
|
||||||
|
|
||||||
########################################################################
|
########################################################################
|
||||||
|
@ -113,9 +121,11 @@ services = ["nginx", "__APP__"]
|
||||||
[main.customization.project_name]
|
[main.customization.project_name]
|
||||||
|
|
||||||
## (required) The ask property is equivalent to the ask property in
|
## (required) The ask property is equivalent to the ask property in
|
||||||
## manifest.yml. However, in config panel questions are displayed on the
|
## the manifest. However, in config panels, questions are displayed on the
|
||||||
## left. So, it's more a label than a complete question, make short.
|
## left side and therefore have less space to be rendered. Therefore,
|
||||||
ask = "Name of the project"
|
## it is better to use a short question, and use the "help" property to
|
||||||
|
## provide additional details if necessary.
|
||||||
|
ask.en = "Name of the project"
|
||||||
|
|
||||||
## (required) The type property indicates how the question should be
|
## (required) The type property indicates how the question should be
|
||||||
## displayed, validated and managed. Some types have specific properties.
|
## displayed, validated and managed. Some types have specific properties.
|
||||||
|
@ -131,47 +141,60 @@ services = ["nginx", "__APP__"]
|
||||||
########################################################################
|
########################################################################
|
||||||
|
|
||||||
## (recommended) 'bind' property is a powerful feature that let you
|
## (recommended) 'bind' property is a powerful feature that let you
|
||||||
## configure how the data will be read, validated and write.
|
## configure how and where the data will be read, validated and written.
|
||||||
|
|
||||||
## By default, 'bind property is in "settings" mode, it means it will
|
## By default, 'bind property is in "settings" mode, it means it will
|
||||||
## read / write the value in application settings file.
|
## **only** read and write the value in application settings file.
|
||||||
## bind = "settings"
|
## bind = "settings"
|
||||||
|
|
||||||
## But in general, you prefer use the ":FILE" mode to read/write a
|
## However, settings usually correspond to key/values in actual app configurations
|
||||||
## specific variable in a file.
|
## Hence, a more useful mode is to have bind = ":FILENAME". In that case, YunoHost
|
||||||
|
## will automagically find a line with "KEY=VALUE" in FILENAME
|
||||||
|
## (with the adequate separator between KEY and VALUE)
|
||||||
|
##
|
||||||
|
## YunoHost will then use this value for the read/get operation.
|
||||||
|
## During write/set operations, YunoHost will overwrite the value
|
||||||
|
## in **both** FILENAME and in the app's settings.yml
|
||||||
|
|
||||||
## Configuration file format supported: yaml, toml, json, ini, env, php,
|
## Configuration file format supported: yaml, toml, json, ini, env, php,
|
||||||
## python. The feature probably works with others formats, but you need
|
## python. The feature probably works with others formats, but should be tested carefully.
|
||||||
## to test it carefully.
|
|
||||||
|
|
||||||
## Unsupported: XML format, custom config function call, php define(),
|
## Note that this feature only works with relatively simple cases
|
||||||
## array/list on several lines.
|
## such as `KEY: VALUE`, but won't properly work with
|
||||||
|
## complex data structures like multilin array/lists or dictionnaries.
|
||||||
|
## It also doesn't work with XML format, custom config function call, php define(), ...
|
||||||
|
|
||||||
## More info on TODO
|
## More info on TODO
|
||||||
# bind = ":/var/www/__APP__/settings.py"
|
# bind = ":/var/www/__APP__/settings.py"
|
||||||
|
|
||||||
## NOTE: in pepettes, the python variable is called 'name' and not
|
|
||||||
## 'project_name', wo here we need to specify the variable name by hand
|
## By default, bind = ":FILENAME" will use the question ID as KEY
|
||||||
## before columns
|
## ... but the question ID may sometime not be the exact KEY name in the configuration file.
|
||||||
## Here pepettes config file to understand: https://github.com/YunoHost-Apps/pepettes_ynh/blob/5cc2d3ffd6529cc7356ff93af92dbb6785c3ab9a/conf/settings.py##L11
|
##
|
||||||
|
## In particular, in pepettes, the python variable is 'name' and not 'project_name'
|
||||||
|
## (c.f. https://github.com/YunoHost-Apps/pepettes_ynh/blob/5cc2d3ffd6529cc7356ff93af92dbb6785c3ab9a/conf/settings.py##L11 )
|
||||||
|
##
|
||||||
|
## In that case, the key name can be specified before the column ':'
|
||||||
|
|
||||||
bind = "name:/var/www/__APP__/settings.py"
|
bind = "name:/var/www/__APP__/settings.py"
|
||||||
|
|
||||||
## ---------------------------------------------------------------------
|
## ---------------------------------------------------------------------
|
||||||
## IMPORTANT: other 'bind' mode exists:
|
## IMPORTANT: other 'bind' mode exists:
|
||||||
##
|
##
|
||||||
## The null mode, to explicitly disable default read / write in settings.
|
## bind = "FILENAME" (with no column character before FILENAME)
|
||||||
# bind = "null"
|
## may be used to bind to the **entire file content** (instead of a single KEY/VALUE)
|
||||||
|
## This could be used to expose an entire configuration file, or binary files such as images
|
||||||
|
## For example:
|
||||||
|
## bind = "/var/www/__APP__/img/logo.png"
|
||||||
##
|
##
|
||||||
## Without columns before the path it means all the file will be replaced
|
## bind = "null" can be used to disable reading / writing in settings.
|
||||||
## by the value (reserved for file and multiline text question):
|
## This creates sort of a "virtual" or "ephemeral" question which is not related to any actual setting
|
||||||
# bind = "/var/www/__APP__/img/logo.png"
|
## In this mode, you are expected to define custom getter/setters/validators in scripts/config:
|
||||||
|
##
|
||||||
|
## getter: get__QUESTIONID()
|
||||||
|
## setter: set__QUESTIONID()
|
||||||
|
## validator: validate__QUESTIONID()
|
||||||
##
|
##
|
||||||
## Finally, if you define a custom getter, setter or validator in config
|
|
||||||
## script it will use it instead of apply default bind behaviour.
|
|
||||||
## getter: get__PROPERTY()
|
|
||||||
## setter: set__PROPERTY()
|
|
||||||
## validator: validate__PROPERTY()
|
|
||||||
## You can also specify a common getter / setter / validator, with the
|
## You can also specify a common getter / setter / validator, with the
|
||||||
## function 'bind' mode, for example here it will try to run
|
## function 'bind' mode, for example here it will try to run
|
||||||
## get__array_settings() first.
|
## get__array_settings() first.
|
||||||
|
@ -179,10 +202,11 @@ services = ["nginx", "__APP__"]
|
||||||
## ---------------------------------------------------------------------
|
## ---------------------------------------------------------------------
|
||||||
|
|
||||||
## ---------------------------------------------------------------------
|
## ---------------------------------------------------------------------
|
||||||
## IMPORTANT: during install/upgrade you should save a first value in
|
## IMPORTANT: with the exception of bind=null questions,
|
||||||
## the source of the bind key and in app settings.
|
## question IDs should almost **always** correspond to an app setting
|
||||||
## During upgrade you should reset values in template files based on
|
## initialized / reused during install/upgrade.
|
||||||
## value saved in app settings.
|
## Not doing so may result in inconsistencies between the config panel mechanism
|
||||||
|
## and the use of ynh_add_config
|
||||||
## ---------------------------------------------------------------------
|
## ---------------------------------------------------------------------
|
||||||
|
|
||||||
########################################################################
|
########################################################################
|
||||||
|
@ -213,7 +237,7 @@ services = ["nginx", "__APP__"]
|
||||||
type = "url"
|
type = "url"
|
||||||
example = "mailto: contact@example.org"
|
example = "mailto: contact@example.org"
|
||||||
help = "mailto: accepted"
|
help = "mailto: accepted"
|
||||||
pattern.regexp = "^mailto:[^@]+@[^@]+|https://$"
|
pattern.regexp = '^mailto:[^@]+@[^@]+|https://$'
|
||||||
pattern.error = "Should be https or mailto:"
|
pattern.error = "Should be https or mailto:"
|
||||||
bind = ":/var/www/__APP__/settings.py"
|
bind = ":/var/www/__APP__/settings.py"
|
||||||
|
|
||||||
|
@ -222,14 +246,14 @@ services = ["nginx", "__APP__"]
|
||||||
type = "file"
|
type = "file"
|
||||||
accept = ".png"
|
accept = ".png"
|
||||||
help = "Fill with an already resized logo"
|
help = "Fill with an already resized logo"
|
||||||
source="__FINALPATH__/img/logo.png"
|
bind = "__FINALPATH__/img/logo.png"
|
||||||
|
|
||||||
[main.customization.favicon]
|
[main.customization.favicon]
|
||||||
ask = "Favicon"
|
ask = "Favicon"
|
||||||
type = "file"
|
type = "file"
|
||||||
accept = ".png"
|
accept = ".png"
|
||||||
help = "Fill with an already sized favicon"
|
help = "Fill with an already sized favicon"
|
||||||
source="__FINALPATH__/img/favicon.png"
|
bind = "__FINALPATH__/img/favicon.png"
|
||||||
|
|
||||||
|
|
||||||
[main.stripe]
|
[main.stripe]
|
||||||
|
|
Loading…
Reference in a new issue