diff --git a/config_panel.toml b/config_panel.toml new file mode 100644 index 0000000..413e937 --- /dev/null +++ b/config_panel.toml @@ -0,0 +1,26 @@ +version = "1.0" + +[main] + +services = [ "__APP__" ] + +name.en = "Config panel" +name.fr = "Panneau de configuration" + +help = "Here you can easily configure some things about your Fluffychat instance." + +#################### +#### FLUFFYCHAT CONFIG +#################### + + [main.fluffychat] + name = "Fluffychat config" + + [main.fluffychat.default_matrix_server] + ask.en = "Default Matrix server?" + ask.fr = "Serveur Matrix par défaut ?" + help.en = "This option changes the default Matrix server on the Fluffychat login page." + help.fr = "Cette option modifie le serveur Matrix renseigné par défaut sur la page de connexion de Fluffychat." + type = "string" + pattern.regexp = '^([-?a-zA-Z0-9]\.?){1,256}[a-zA-Z0-9]{1,6}$' + pattern.error = "Must be a domain name or a sub-domain. Must not start with 'http://' or 'https://'." diff --git a/manifest.toml b/manifest.toml index b3e5ecf..46d585a 100644 --- a/manifest.toml +++ b/manifest.toml @@ -45,6 +45,12 @@ ram.runtime = "50M" type = "group" default = "visitors" + [install.default_matrix_server] + ask.en = "Default Matrix server" + help.en = "Serveur Matrix par défaut" + type = "url" + default = "matrix.org" + [resources] [resources.sources] [resources.sources.main] diff --git a/scripts/install b/scripts/install index c969593..1be7400 100755 --- a/scripts/install +++ b/scripts/install @@ -9,6 +9,16 @@ source _common.sh source /usr/share/yunohost/helpers +#================================================= +# INITIALIZE AND STORE SETTINGS +#================================================= + +# remove the 'https://' part +default_matrix_server=${default_matrix_server#*://} +# remove any trailing slash +default_matrix_server=${default_matrix_server%/} +ynh_app_setting_set --app="$app" --key=default_matrix_server --value="$default_matrix_server" + #================================================= # APP "BUILD" (DEPLOYING SOURCES, VENV, COMPILING ETC) #================================================= @@ -23,6 +33,9 @@ ynh_setup_source --dest_dir="$install_dir" path_without_trailing_slash=${path%/} ynh_replace_string --match_string="" --replace_string="" --target_file="$install_dir/index.html" +# patching main.dart.js to replace the default matrix server +ynh_replace_string --match_string="$.cmx=\"matrix.org\"" --replace_string="$.cmx=\"$default_matrix_server\"" --target_file="$install_dir/main.dart.js" + chown -R "www-data:www-data" "$install_dir" #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index d0606b0..af4fa76 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -27,6 +27,9 @@ then # remove potential trailing slash to avoid double slashes path_without_trailing_slash=${path%/} ynh_replace_string --match_string="" --replace_string="" --target_file="$install_dir/index.html" + + # patching main.dart.js to replace the default matrix server + ynh_replace_string --match_string="$.cmx=\".*\"" --replace_string="$.cmx=\"$default_matrix_server\"" --target_file="$install_dir/main.dart.js" fi chown -R "www-data:www-data" "$install_dir"