config_panel.toml.example 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  1. ## Config panel are available from webadmin > Apps > YOUR_APP > Config Panel Button
  2. ## Those panels let user configure some params on their apps using a friendly interface,
  3. ## and remove the need to manually edit files from the command line.
  4. ## From a packager perspective, this .toml is coupled to the scripts/config script,
  5. ## which may be used to define custom getters/setters. However, most use cases
  6. ## should be covered automagically by the core, thus it may not be necessary
  7. ## to define a scripts/config at all!
  8. ## -----------------------------------------------------------------------------
  9. ## IMPORTANT: In accordance with YunoHost's spirit, please keep things simple and
  10. ## do not overwhelm the admin with tons of misunderstandable or advanced settings.
  11. ## -----------------------------------------------------------------------------
  12. ## The top level describe the entire config panels screen.
  13. ## The version is a required property.
  14. ## Here a small reminder to associate config panel version with YunoHost version
  15. ## | Config | YNH | Config panel small change log |
  16. ## | ------ | --- | ------------------------------------------------------- |
  17. ## | 0.1 | 3.x | 0.1 config script not compatible with YNH >= 4.3 |
  18. ## | 1.0 | 4.3.x | The new config panel system with 'bind' property |
  19. version = "1.0"
  20. ## (optional) i18n property let you internationalize questions, however this feature
  21. ## is only available in core configuration panel (like yunohost domain config).
  22. ## So in app config panel this key is ignored for now, but you can internationalize
  23. ## by using a lang dictionary (see property name bellow)
  24. # i18n = "prefix_translation_key"
  25. ################################################################################
  26. #### ABOUT PANELS
  27. ################################################################################
  28. ## The next level describes web admin panels
  29. ## You have to choose an ID for each panel, in this example the ID is "main"
  30. ## Keep in mind this ID will be used in CLI to refer to your question, so choose
  31. ## something short and meaningfull.
  32. ## In the webadmin, each panel corresponds to a distinct tab / form
  33. [main]
  34. ## Define the label for your panel
  35. ## Internationalization works similarly to the 'description' and 'ask' questions in the manifest
  36. # name.en = "Main configuration"
  37. # name.fr = "Configuration principale"
  38. ## (optional) If you need to trigger a service reload-or-restart after the user
  39. ## change a question in this panel, you can add your service in the list.
  40. services = ["__APP__"]
  41. # or services = ["nginx", "__APP__"] to also reload-or-restart nginx
  42. ## (optional) This help properties is a short help displayed on the same line
  43. ## than the panel title but not displayed in the tab.
  44. # help = ""
  45. ############################################################################
  46. #### ABOUT SECTIONS
  47. ############################################################################
  48. ## A panel is composed of one or several sections.
  49. ##
  50. ## Sections are meant to group questions together when they correspond to
  51. ## a same subtopic. This impacts the rendering in terms of CLI prompts
  52. ## and HTML forms
  53. ##
  54. ## You should choose an ID for your section, and prefix it with the panel ID
  55. ## (Be sure to not make a typo in the panel ID, which would implicitly create
  56. ## an other entire panel)
  57. ##
  58. ## We use the context of pepettes_ynh as an example,
  59. ## which is a simple donation form app written in python,
  60. ## and for which the admin will want to edit the configuration
  61. [main.customization]
  62. ## (optional) Defining a proper title for sections is not mandatory
  63. ## and depends on the exact rendering you're aiming for the CLI / webadmin
  64. name = ""
  65. ## (optional) This help properties is a short help displayed on the same line
  66. ## than the section title, meant to provide additional details
  67. # help = ""
  68. ## (optional) As for panel, you can specify to trigger a service
  69. ## reload-or-restart after the user change a question in this section.
  70. ## This property is added to the panel property, it doesn't deactivate it.
  71. ## So no need to replicate, the service list from panel services property.
  72. # services = []
  73. ## (optional) By default all questions are optionals, but you can specify a
  74. ## default behaviour for question in the section
  75. optional = false
  76. ## (optional) It's also possible with the 'visible' property to only
  77. ## display the section depending on the user's answers to previous questions.
  78. ##
  79. ## Be careful that the 'visible' property should only refer to **previous** questions
  80. ## Hence, it should not make sense to have a "visible" property on the very first section.
  81. ##
  82. ## Also, keep in mind that this feature only works in the webadmin and not in CLI
  83. ## (therefore a user could be prompted in CLI for a question that may not be relevant)
  84. # visible = true
  85. ########################################################################
  86. #### ABOUT QUESTIONS
  87. ########################################################################
  88. ## A section is compound of one or several questions.
  89. ## ---------------------------------------------------------------------
  90. ## IMPORTANT: as for panel and section you have to choose an ID, but this
  91. ## one should be unique in all this document, even if the question is in
  92. ## an other panel.
  93. ## ---------------------------------------------------------------------
  94. ## You can use same questions types and properties than in manifest.yml
  95. ## install part. However, in YNH 4.3, a lot of change has been made to
  96. ## extend availables questions types list.
  97. ## See: TODO DOC LINK
  98. [main.customization.project_name]
  99. ## (required) The ask property is equivalent to the ask property in
  100. ## the manifest. However, in config panels, questions are displayed on the
  101. ## left side and therefore have less space to be rendered. Therefore,
  102. ## it is better to use a short question, and use the "help" property to
  103. ## provide additional details if necessary.
  104. ask.en = "Name of the project"
  105. ## (required) The type property indicates how the question should be
  106. ## displayed, validated and managed. Some types have specific properties.
  107. ##
  108. ## Types available: string, boolean, number, range, text, password, path
  109. ## email, url, date, time, color, select, domain, user, tags, file.
  110. ##
  111. ## For a complete list with specific properties, see: TODO DOC LINK
  112. type = "string"
  113. ########################################################################
  114. #### ABOUT THE BIND PROPERTY
  115. ########################################################################
  116. ## (recommended) 'bind' property is a powerful feature that let you
  117. ## configure how and where the data will be read, validated and written.
  118. ## By default, 'bind property is in "settings" mode, it means it will
  119. ## **only** read and write the value in application settings file.
  120. ## bind = "settings"
  121. ## However, settings usually correspond to key/values in actual app configurations
  122. ## Hence, a more useful mode is to have bind = ":FILENAME". In that case, YunoHost
  123. ## will automagically find a line with "KEY=VALUE" in FILENAME
  124. ## (with the adequate separator between KEY and VALUE)
  125. ##
  126. ## YunoHost will then use this value for the read/get operation.
  127. ## During write/set operations, YunoHost will overwrite the value
  128. ## in **both** FILENAME and in the app's settings.yml
  129. ## Configuration file format supported: yaml, toml, json, ini, env, php,
  130. ## python. The feature probably works with others formats, but should be tested carefully.
  131. ## Note that this feature only works with relatively simple cases
  132. ## such as `KEY: VALUE`, but won't properly work with
  133. ## complex data structures like multilin array/lists or dictionnaries.
  134. ## It also doesn't work with XML format, custom config function call, php define(), ...
  135. ## More info on TODO
  136. # bind = ":/var/www/__APP__/settings.py"
  137. ## By default, bind = ":FILENAME" will use the question ID as KEY
  138. ## ... but the question ID may sometime not be the exact KEY name in the configuration file.
  139. ##
  140. ## In particular, in pepettes, the python variable is 'name' and not 'project_name'
  141. ## (c.f. https://github.com/YunoHost-Apps/pepettes_ynh/blob/5cc2d3ffd6529cc7356ff93af92dbb6785c3ab9a/conf/settings.py##L11 )
  142. ##
  143. ## In that case, the key name can be specified before the column ':'
  144. bind = "name:/var/www/__APP__/settings.py"
  145. ## ---------------------------------------------------------------------
  146. ## IMPORTANT: other 'bind' mode exists:
  147. ##
  148. ## bind = "FILENAME" (with no column character before FILENAME)
  149. ## may be used to bind to the **entire file content** (instead of a single KEY/VALUE)
  150. ## This could be used to expose an entire configuration file, or binary files such as images
  151. ## For example:
  152. ## bind = "/var/www/__APP__/img/logo.png"
  153. ##
  154. ## bind = "null" can be used to disable reading / writing in settings.
  155. ## This creates sort of a "virtual" or "ephemeral" question which is not related to any actual setting
  156. ## In this mode, you are expected to define custom getter/setters/validators in scripts/config:
  157. ##
  158. ## getter: get__QUESTIONID()
  159. ## setter: set__QUESTIONID()
  160. ## validator: validate__QUESTIONID()
  161. ##
  162. ## You can also specify a common getter / setter / validator, with the
  163. ## function 'bind' mode, for example here it will try to run
  164. ## get__array_settings() first.
  165. # bind = "array_settings()"
  166. ## ---------------------------------------------------------------------
  167. ## ---------------------------------------------------------------------
  168. ## IMPORTANT: with the exception of bind=null questions,
  169. ## question IDs should almost **always** correspond to an app setting
  170. ## initialized / reused during install/upgrade.
  171. ## Not doing so may result in inconsistencies between the config panel mechanism
  172. ## and the use of ynh_add_config
  173. ## ---------------------------------------------------------------------
  174. ########################################################################
  175. #### OTHER GENERIC PROPERTY FOR QUESTIONS
  176. ########################################################################
  177. ## (optional) An help text for the question
  178. help = "Fill the name of the project which will received donation"
  179. ## (optional) An example display as placeholder in web form
  180. # example = "YunoHost"
  181. ## (optional) set to true in order to redact the value in operation logs
  182. # redact = false
  183. ## (optional) A validation pattern
  184. ## ---------------------------------------------------------------------
  185. ## IMPORTANT: your pattern should be between simple quote, not double.
  186. ## ---------------------------------------------------------------------
  187. pattern.regexp = '^\w{3,30}$'
  188. pattern.error = "The name should be at least 3 chars and less than 30 chars. Alphanumeric chars are accepted"
  189. ## Note: visible and optional properties are also available for questions
  190. [main.customization.contact_url]
  191. ask = "Contact url"
  192. type = "url"
  193. example = "mailto: contact@example.org"
  194. help = "mailto: accepted"
  195. pattern.regexp = '^mailto:[^@]+@[^@]+|https://$'
  196. pattern.error = "Should be https or mailto:"
  197. bind = ":/var/www/__APP__/settings.py"
  198. [main.customization.logo]
  199. ask = "Logo"
  200. type = "file"
  201. accept = ".png"
  202. help = "Fill with an already resized logo"
  203. bind = "__FINALPATH__/img/logo.png"
  204. [main.customization.favicon]
  205. ask = "Favicon"
  206. type = "file"
  207. accept = ".png"
  208. help = "Fill with an already sized favicon"
  209. bind = "__FINALPATH__/img/favicon.png"
  210. [main.stripe]
  211. name = "Stripe general info"
  212. optional = false
  213. # The next alert is overwrited with a getter from the config script
  214. [main.stripe.amount]
  215. ask = "Donation in the month : XX €
  216. type = "alert"
  217. style = "success"
  218. [main.stripe.publishable_key]
  219. ask = "Publishable key"
  220. type = "string"
  221. redact = true
  222. help = "Indicate here the stripe publishable key"
  223. bind = ":/var/www/__APP__/settings.py"
  224. [main.stripe.secret_key]
  225. ask = "Secret key"
  226. type = "string"
  227. redact = true
  228. help = "Indicate here the stripe secret key"
  229. bind = ":/var/www/__APP__/settings.py"
  230. [main.stripe.prices]
  231. ask = "Prices ID"
  232. type = "tags"
  233. help = """\
  234. Indicates here the prices ID of donation products you created in stripe interfaces. \
  235. Go on [Stripe products](https://dashboard.stripe.com/products) to create those donation products. \
  236. Fill it tag with 'FREQUENCY/CURRENCY/PRICE_ID' \
  237. FREQUENCY: 'one_time' or 'recuring' \
  238. CURRENCY: 'EUR' or 'USD' \
  239. PRICE_ID: ID from stripe interfaces starting with 'price_' \
  240. """
  241. pattern.regexp = '^(one_time|recuring)/(EUR|USD)/price_.*$'
  242. pattern.error = "Please respect the format describe in help text for each price ID"