From 69beb13e9601d578c64968d88413c5d83129cd73 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Wed, 11 Oct 2023 23:40:25 +0200 Subject: [PATCH] Add multiple blogs management --- config_panel.toml | 13 +++++++++++++ scripts/config | 6 +++--- scripts/install | 3 +++ scripts/upgrade | 5 +++++ 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/config_panel.toml b/config_panel.toml index 88867ad..6004fb1 100644 --- a/config_panel.toml +++ b/config_panel.toml @@ -103,3 +103,16 @@ help = "These permissions apply to the first connection of the user, the super u yes = "true" no = "false" bind = "'blogroll':__INSTALL_DIR__/inc/class.auth.ldap.php" + +[blogs] +name = "Multiple blogs management" +help = "Here you can instruct YunoHost to handle multiple blogs. It will create the appropriate permissions and NGINX configuration files. You still need to add them in Dotclear's administration panel. Removing them here will not delete them from Dotclear, and vice-versa." + + [blogs.blogs_list] + name = "List of blogs to handle" + + [blogs.blogs_list.blogs_list] + ask = "List blogs with the format `id@domain.example/path`" + type = "tags" + pattern.regexp = "[\\w]+@[\\w.]+\\/[\\w]*" + pattern.error = "Incorrect format. Use `id@domain.example/path`" diff --git a/scripts/config b/scripts/config index f6a09fa..7426c3d 100644 --- a/scripts/config +++ b/scripts/config @@ -49,7 +49,7 @@ set__blogs_list() { # https://stackoverflow.com/questions/2312762/compare-difference-of-two-arrays-in-bash # Get added and removed blogs added_ids_array=(`echo ${!domain_array[@]} ${!old_domain_array[@]} | tr ' ' '\n' | sort | uniq -u `) - removed_ids_array=(`echo ${!old_domain_array[@]} $!domain_array[@]} | tr ' ' '\n' | sort | uniq -D | uniq `) + removed_ids_array=(`echo ${!old_domain_array[@]} ${!domain_array[@]} | tr ' ' '\n' | sort | uniq -D | uniq `) for id in $removed_ids_array; do if [ ynh_permission_exists --permission="$id" ]; then @@ -72,10 +72,10 @@ set__blogs_list() { if [ ynh_permission_exists --permission="$id" ]; then ynh_permission_url --permission="$id" --url="$domain_array[$id]$path_array[$id]" - ynh_permission_url --permission="$id.admin" --url="$domain_array[$id]$path_array[$id]/admin" + ynh_permission_url --permission="${id}-admin" --url="$domain_array[$id]$path_array[$id]/admin" else ynh_permission_create --permission="$id" --url="$domain_array[$id]$path_array[$id]" - ynh_permission_create --permission="$id.admin" --url="$domain_array[$id]$path_array[$id]/admin" + ynh_permission_create --permission="${id}-admin" --url="$domain_array[$id]$path_array[$id]/admin" fi done diff --git a/scripts/install b/scripts/install index 619e9c0..c3e91f8 100755 --- a/scripts/install +++ b/scripts/install @@ -131,6 +131,9 @@ installUrl="/admin/install/index.php" ynh_local_curl $installUrl "u_email=$email" "u_firstname=$firstname" "u_name=$lastname" "u_login=$admin" "u_pwd=$password" "u_pwd2=$password" +# Initializing blogs_list (excluding default) +ynh_app_setting_set --app=$app --key=blogs_list --value="" + #================================================= # GENERIC FINALIZATION #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index b5b457b..68c7b51 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -55,6 +55,11 @@ if [ -z "$blog_admin" ] || ynh_app_setting_set --app=$app --key=blog_blogroll --value=$blog_blogroll fi +if [ -z "$blogs_list" ]; then + # Initializing blogs_list (excluding default) + ynh_app_setting_set --app=$app --key=blogs_list --value="" +fi + #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #=================================================