mirror of
https://github.com/YunoHost/test_apps.git
synced 2024-09-03 20:06:29 +02:00
[enh] Add test for config panel
This commit is contained in:
parent
d94c7054b2
commit
cd40f1e76a
12 changed files with 341 additions and 0 deletions
5
config_app_ynh/conf/index.html
Normal file
5
config_app_ynh/conf/index.html
Normal file
|
@ -0,0 +1,5 @@
|
|||
<html>
|
||||
<body>
|
||||
This is a dummy app to test the change url feature.
|
||||
</body>
|
||||
</html>
|
3
config_app_ynh/conf/nginx.conf
Normal file
3
config_app_ynh/conf/nginx.conf
Normal file
|
@ -0,0 +1,3 @@
|
|||
location PATHTOCHANGE {
|
||||
alias /var/www/FOLDER;
|
||||
}
|
0
config_app_ynh/conf/test.ini
Normal file
0
config_app_ynh/conf/test.ini
Normal file
0
config_app_ynh/conf/test.json
Normal file
0
config_app_ynh/conf/test.json
Normal file
0
config_app_ynh/conf/test.php
Normal file
0
config_app_ynh/conf/test.php
Normal file
0
config_app_ynh/conf/test.py
Normal file
0
config_app_ynh/conf/test.py
Normal file
0
config_app_ynh/conf/test.yml
Normal file
0
config_app_ynh/conf/test.yml
Normal file
212
config_app_ynh/config_panel.toml
Normal file
212
config_app_ynh/config_panel.toml
Normal file
|
@ -0,0 +1,212 @@
|
|||
version = "0.1"
|
||||
name = "Configuration panel"
|
||||
|
||||
[main]
|
||||
name = "Main section"
|
||||
|
||||
[main.components]
|
||||
name = "Components"
|
||||
|
||||
[main.components.boolean]
|
||||
ask = "Put a boolean"
|
||||
type = "boolean"
|
||||
choices = ["on", "off"]
|
||||
default = "off"
|
||||
|
||||
[main.components.number]
|
||||
ask = "Put a number"
|
||||
type = "number"
|
||||
min = 1
|
||||
max = 100
|
||||
|
||||
[main.components.range]
|
||||
ask = "Put a range"
|
||||
type = "range"
|
||||
min = 1
|
||||
max = 100
|
||||
|
||||
[main.components.str]
|
||||
ask = "Put a string with yunohost word"
|
||||
type = "string"
|
||||
pattern = "yunohost"
|
||||
|
||||
[main.components.text]
|
||||
ask = "Put a text"
|
||||
type = "text"
|
||||
|
||||
[main.components.password]
|
||||
ask = "Put a password"
|
||||
type = "password"
|
||||
|
||||
[main.components.custom_path]
|
||||
ask = "Put a path"
|
||||
type = "path"
|
||||
|
||||
[main.components.email]
|
||||
ask = "Put a email"
|
||||
type = "email"
|
||||
|
||||
[main.components.url]
|
||||
ask = "Put a url"
|
||||
type = "url"
|
||||
|
||||
[main.components.date]
|
||||
ask = "Put a date"
|
||||
type = "date"
|
||||
|
||||
[main.components.time]
|
||||
ask = "Put a time"
|
||||
type = "time"
|
||||
|
||||
[main.components.color]
|
||||
ask = "Put a color"
|
||||
type = "color"
|
||||
|
||||
[main.components.select]
|
||||
ask = "Choose an option"
|
||||
type = "select"
|
||||
choices = ["option1", "option2", "option3"]
|
||||
|
||||
[main.components.custom_domain]
|
||||
ask = "Put a domain"
|
||||
type = "domain"
|
||||
|
||||
[main.components.user]
|
||||
ask = "Put a user"
|
||||
type = "user"
|
||||
|
||||
[main.components.tags]
|
||||
ask = "Put some tags"
|
||||
type = "tags"
|
||||
|
||||
[main.components.file]
|
||||
ask = "Put a file"
|
||||
type = "file"
|
||||
accept = ".cube"
|
||||
|
||||
[main.messages]
|
||||
name = "Read only components"
|
||||
|
||||
[main.messages.success]
|
||||
ask = "This is a success message"
|
||||
type = "success"
|
||||
|
||||
[main.messages.info]
|
||||
ask = "This is an info message"
|
||||
type = "info"
|
||||
|
||||
[main.messages.warning]
|
||||
ask = "This is an warning message"
|
||||
type = "warning"
|
||||
|
||||
[main.messages.error]
|
||||
ask = "This is an error message"
|
||||
type = "error"
|
||||
|
||||
[main.messages.display_text]
|
||||
ask = "This is a simple text"
|
||||
type = "display_text"
|
||||
|
||||
[main.messages.markdown]
|
||||
ask = "This is a **markdown** text"
|
||||
type = "markdown"
|
||||
|
||||
[main.generic]
|
||||
name = "Generic options"
|
||||
|
||||
[main.generic.default]
|
||||
ask = "This is a question with a default value"
|
||||
type = "string"
|
||||
default = "Camille"
|
||||
|
||||
[main.generic.example]
|
||||
ask = "This is a question with an example value"
|
||||
type = "string"
|
||||
example = "Camille"
|
||||
|
||||
[main.generic.optional]
|
||||
ask = "This is an optional value"
|
||||
type = "string"
|
||||
optional = true
|
||||
|
||||
[main.generic.help]
|
||||
ask = "Here we add some help"
|
||||
type = "string"
|
||||
help = "You can feel this question with your keyboard (yes i know it's very useful)"
|
||||
|
||||
[main.generic.helpLink]
|
||||
ask = "Here we add an help link"
|
||||
type = "string"
|
||||
help.href = "https://yunohost.org/doc"
|
||||
help.text = "Yunohost Doc"
|
||||
|
||||
[main.generic.visibleIf]
|
||||
ask = "Display if helpLink question is filled"
|
||||
type = "string"
|
||||
visibleIf = "helpLink"
|
||||
|
||||
[source]
|
||||
name = "Source section"
|
||||
|
||||
[source.settings]
|
||||
name = "App settings"
|
||||
|
||||
[source.settings.arg1]
|
||||
ask = "Save app settings arg1"
|
||||
type = "string"
|
||||
|
||||
[source.yml]
|
||||
name = "YAML"
|
||||
|
||||
[source.yml.arg2]
|
||||
ask = "Save arg2 in YAML"
|
||||
type = "string"
|
||||
source = "__FINALPATH__/test.yml"
|
||||
|
||||
[source.json]
|
||||
name = "JSON"
|
||||
|
||||
[source.json.arg3]
|
||||
ask = "Save arg3 in JSON"
|
||||
type = "string"
|
||||
source = "__FINALPATH__/test.json"
|
||||
|
||||
[source.ini]
|
||||
name = "INI"
|
||||
|
||||
[conf.ini.arg4]
|
||||
ask = "Save arg4 in INI"
|
||||
type = "string"
|
||||
source = "__FINALPATH__/test.ini"
|
||||
|
||||
[source.php]
|
||||
name = "PHP"
|
||||
|
||||
[source.php.arg5]
|
||||
ask = "Save arg5 in PHP file"
|
||||
type = "string"
|
||||
source = "__FINALPATH__/test.php"
|
||||
|
||||
[source.python]
|
||||
name = "Python"
|
||||
|
||||
[source.python.arg6]
|
||||
ask = "Save arg6 in python file"
|
||||
type = "string"
|
||||
source = "__FINALPATH__/test.py"
|
||||
|
||||
[source.file]
|
||||
name = "File"
|
||||
|
||||
[source.file.arg7]
|
||||
ask = "Save a cube file"
|
||||
type = "file"
|
||||
accept = ".cube"
|
||||
source = "__FINALPATH__/test.cube"
|
||||
|
||||
[source.function]
|
||||
name = "function"
|
||||
|
||||
[source.function.arg8]
|
||||
ask = "Custom validate and save arg8 password"
|
||||
type = "password"
|
36
config_app_ynh/manifest.json
Normal file
36
config_app_ynh/manifest.json
Normal file
|
@ -0,0 +1,36 @@
|
|||
{
|
||||
"name": "Config panel",
|
||||
"id": "config_app",
|
||||
"description": {
|
||||
"en": "Dummy app to test config panel"
|
||||
},
|
||||
"license": "GPL-3+",
|
||||
"maintainer": {
|
||||
"name": "ljf",
|
||||
"email": "ljf+config_app@reflexlibre.net",
|
||||
"url": "http://reflexlibre.net"
|
||||
},
|
||||
"requirements": {
|
||||
"yunohost": ">> 4.2.7"
|
||||
},
|
||||
"multi_instance": false,
|
||||
"arguments": {
|
||||
"install" : [
|
||||
{
|
||||
"name": "domain",
|
||||
"ask": {
|
||||
"en": "Choose a domain"
|
||||
},
|
||||
"example": "domain.org"
|
||||
},
|
||||
{
|
||||
"name": "path",
|
||||
"ask": {
|
||||
"en": "Choose a path"
|
||||
},
|
||||
"example": "/",
|
||||
"default": "/"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
68
config_app_ynh/scripts/config
Normal file
68
config_app_ynh/scripts/config
Normal file
|
@ -0,0 +1,68 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC STARTING
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# RETRIEVE ARGUMENTS
|
||||
#=================================================
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
final_path=$(ynh_app_setting_get $app final_path)
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC GETTERS FOR TOML SHORT KEY
|
||||
#=================================================
|
||||
|
||||
get__arg8() {
|
||||
echo ""
|
||||
}
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC VALIDATORS FOR TOML SHORT KEYS
|
||||
#=================================================
|
||||
validate__arg8() {
|
||||
[[ "$#arg8" -lt 8 ]] &&
|
||||
echo 'Too short password'
|
||||
}
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC SETTERS FOR TOML SHORT KEYS
|
||||
#=================================================
|
||||
set__arg8() {
|
||||
if [ -z "$arg8" ]
|
||||
then
|
||||
python -c "import crypt; print(crypt.crypt(\"${arg8}\", \"\$6\$saltsalt\$\"))" > $final_path/password
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
|
||||
#=================================================
|
||||
# OVERWRITING APPLY STEP
|
||||
#=================================================
|
||||
ynh_panel_apply() {
|
||||
_ynh_panel_apply
|
||||
systemctl restart nginx
|
||||
}
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# Please don't change that code.
|
||||
# You can overwrite these functions if you need it
|
||||
#=================================================
|
||||
|
||||
ynh_panel_init
|
||||
case $1 in
|
||||
show) ynh_panel_show;;
|
||||
apply) ynh_panel_validate && ynh_panel_apply;;
|
||||
esac
|
||||
|
10
config_app_ynh/scripts/install
Normal file
10
config_app_ynh/scripts/install
Normal file
|
@ -0,0 +1,10 @@
|
|||
set -eux
|
||||
|
||||
# Source app helpers
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
mkdir -p /var/www/$app
|
||||
|
||||
cp ../conf/* /var/www/$app/
|
7
config_app_ynh/scripts/remove
Normal file
7
config_app_ynh/scripts/remove
Normal file
|
@ -0,0 +1,7 @@
|
|||
set -eux
|
||||
|
||||
# See comments in install script
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
rm -rf /var/www/$app
|
||||
|
Loading…
Reference in a new issue