From 69beb13e9601d578c64968d88413c5d83129cd73 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Wed, 11 Oct 2023 23:40:25 +0200 Subject: [PATCH 1/6] 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 #================================================= From 35386e0855e37270cde1609df14ec2fdcdc06c49 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Thu, 12 Oct 2023 00:59:42 +0200 Subject: [PATCH 2/6] Better handle defautl blog --- scripts/config | 85 +++++++++++++++++++++++++++++++------------------ scripts/install | 2 +- scripts/upgrade | 2 +- 3 files changed, 56 insertions(+), 33 deletions(-) diff --git a/scripts/config b/scripts/config index 7426c3d..1aeb40f 100644 --- a/scripts/config +++ b/scripts/config @@ -16,6 +16,8 @@ ynh_abort_if_errors install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) admin=$(ynh_app_setting_get --app=$app --key=admin) +domain=$(ynh_app_setting_get --app=$app --key=domain) +path=$(ynh_app_setting_get --app=$app --key=path) #================================================= # SPECIFIC SETTERS FOR TOML SHORT KEYS @@ -25,13 +27,15 @@ set__blogs_list() { declare -A domain_array declare -A path_array + default_present=false for blog in $(echo $blogs_list | sed "s/,/ /"); do id=$(echo $blog | cut -d@ -f1) - domain=$(echo $blog | cut -d@ -f2 | cut -d/ -f1) - path="/$(echo $blog | cut -d@ -f2 | cut -d/ -f2)" + d=$(echo $blog | cut -d@ -f2 | cut -d/ -f1) + p="/$(echo $blog | cut -d@ -f2 | cut -d/ -f2)" + [ $id = "default" ] && default_present=true - domain_array+=([$id]=$domain) - path_array+=([$id]=$path) + domain_array+=([$id]=$d) + path_array+=([$id]=$p) done declare -A old_domain_array @@ -39,43 +43,62 @@ set__blogs_list() { for blog in $(echo ${old[blogs_list]} | sed "s/,/ /"); do id=$(echo $blog | cut -d@ -f1) - domain=$(echo $blog | cut -d@ -f2 | cut -d/ -f1) - path="/$(echo $blog | cut -d@ -f2 | cut -d/ -f2)" + d=$(echo $blog | cut -d@ -f2 | cut -d/ -f1) + p="/$(echo $blog | cut -d@ -f2 | cut -d/ -f2)" - old_domain_array+=([$id]=$domain) - old_path_array+=([$id]=$path) + old_domain_array+=([$id]=$d) + old_path_array+=([$id]=$p) done + # Make sure the default blog is always listed + domain_array+=(["default"]=$domain) + path_array+=(["default"]=$path) + old_domain_array+=(["default"]=$domain) + old_path_array+=(["default"]=$path) + if [ $default_present = false ]; then + if [ -z ${blogs_list:-} ]; then + blogs_list="default@$domain$path" + else + blogs_list+=",default@$domain$path" + fi + fi + # 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 `) + added_ids_array=() + added_ids_array+=(`echo ${!domain_array[@]} ${!old_domain_array[@]} | tr ' ' '\n' | sort | uniq -u `) + removed_ids_array=() + removed_ids_array+=(`echo ${!domain_array[@]} ${!old_domain_array[@]} | tr ' ' '\n' | sort | uniq -D | uniq `) - for id in $removed_ids_array; do - if [ ynh_permission_exists --permission="$id" ]; then - ynh_permission_delete --permission="$id" + ynh_print_info --message="Added blogs: ${added_ids_array[@]}" + ynh_print_info --message="Removed blogs: ${removed_ids_array[@]}" + + for id in ${removed_ids_array[@]}; do + if [ $id != "default" ]; then + if ynh_permission_exists --permission="$id"; then + ynh_permission_delete --permission="$id" + fi + ynh_secure_remove --file="/etc/nginx/conf.d/${old_domain_array[$id]}.d/$app-$id.conf" fi - ynh_secure_remove --file="/etc/nginx/conf.d/${old_domain_array[$id]}.d/$app.conf" done - for id in $domain_array; do - - if [ $domain_array[$id] != $old_domain_array[$id] ]; then - mv /etc/nginx/conf.d/${old_domain_array[$id]}.d/$app.conf /etc/nginx/conf.d/${domain_array[$id]}.d/$app.conf - fi - - if [ $path_array[$id] != $old_path_array[$id] ]; then - domain=$domain_array[$id] - path=$path_array[$id] - ynh_add_config --template="nginx.conf" --destination="/etc/nginx/conf.d/${domain_array[$id]}.d/$app.conf" - fi + for id in ${!domain_array[@]}; do + if [ $id != "default" ]; then + if [ ${domain_array[$id]:-} != ${old_domain_array[$id]:-} ] || + [ ${path_array[$id]:-} != ${old_path_array[$id]:-} ]; then + domain=${domain_array[$id]} + path=${path_array[$id]} + [ ! -z ${old_domain_array[$id]:-} ] && ynh_secure_remove --file="/etc/nginx/conf.d/${old_domain_array[$id]}.d/$app-$id.conf" + ynh_add_config --template="nginx.conf" --destination="/etc/nginx/conf.d/${domain_array[$id]}.d/$app-$id.conf" + fi - 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" - 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" + 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" + else + ynh_permission_create --permission="$id" --url="${domain_array[$id]}${path_array[$id]}" --show_tile=true + ynh_permission_create --permission="${id}-admin" --url="${domain_array[$id]}${path_array[$id]}/admin" --show_tile=true + fi fi done diff --git a/scripts/install b/scripts/install index c3e91f8..d990398 100755 --- a/scripts/install +++ b/scripts/install @@ -132,7 +132,7 @@ 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="" +ynh_app_setting_set --app=$app --key=blogs_list --value="default@$domain$path" #================================================= # GENERIC FINALIZATION diff --git a/scripts/upgrade b/scripts/upgrade index 68c7b51..0626b94 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -57,7 +57,7 @@ fi if [ -z "$blogs_list" ]; then # Initializing blogs_list (excluding default) - ynh_app_setting_set --app=$app --key=blogs_list --value="" + ynh_app_setting_set --app=$app --key=blogs_list --value="default@$domain$path" fi #================================================= From 67cc2ce252c633b00c6a8d08533cc160877e5024 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Thu, 12 Oct 2023 22:14:17 +0200 Subject: [PATCH 3/6] Remove too long features list from description --- doc/DESCRIPTION.md | 33 +-------------------------------- 1 file changed, 1 insertion(+), 32 deletions(-) diff --git a/doc/DESCRIPTION.md b/doc/DESCRIPTION.md index f4c2455..50c1db9 100644 --- a/doc/DESCRIPTION.md +++ b/doc/DESCRIPTION.md @@ -1,35 +1,4 @@ Dotclear is an open-source web publishing software. Take control over your blog! -Dotclear project's purpose is to provide a user-friendly -tool allowing anyone to publish on the web, regardless of their technical skills. - -### Features - -- Easy publication -- Fully customizable theme -- User-friendly administration -- Flexible template system -- Media management -- Choose from several editing syntax (wiki, markdown or directly in wysiwyg) -- Flexible comment system -- Built-in antispam -- Localization -- Presentation widgets -- Themes and plugins -- Pages -- Tags and categories -- Automated installation -- Support for several database types -- Multiblog -- Multi-user with permissions -- Standards compliant -- Accessible -- Importing / exporting -- Naturally optimized for search engines -- Syndication feeds -- Complete trackback/pingback/webmention support -- Full Unicode support -- Extensible -- Performance and scalability -- Twice free +Dotclear project's purpose is to provide a user-friendly tool allowing anyone to publish on the web, regardless of their technical skills. From f49f2cfd2dda2971290a34d19143154343035a20 Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Thu, 12 Oct 2023 20:16:00 +0000 Subject: [PATCH 4/6] Auto-update README --- README.md | 33 +-------------------------------- README_fr.md | 33 +-------------------------------- 2 files changed, 2 insertions(+), 64 deletions(-) diff --git a/README.md b/README.md index f299d5c..55cb658 100644 --- a/README.md +++ b/README.md @@ -19,38 +19,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in Dotclear is an open-source web publishing software. Take control over your blog! -Dotclear project's purpose is to provide a user-friendly -tool allowing anyone to publish on the web, regardless of their technical skills. - -### Features - -- Easy publication -- Fully customizable theme -- User-friendly administration -- Flexible template system -- Media management -- Choose from several editing syntax (wiki, markdown or directly in wysiwyg) -- Flexible comment system -- Built-in antispam -- Localization -- Presentation widgets -- Themes and plugins -- Pages -- Tags and categories -- Automated installation -- Support for several database types -- Multiblog -- Multi-user with permissions -- Standards compliant -- Accessible -- Importing / exporting -- Naturally optimized for search engines -- Syndication feeds -- Complete trackback/pingback/webmention support -- Full Unicode support -- Extensible -- Performance and scalability -- Twice free +Dotclear project's purpose is to provide a user-friendly tool allowing anyone to publish on the web, regardless of their technical skills. **Shipped version:** 2.27.3~ynh1 diff --git a/README_fr.md b/README_fr.md index 8d0e991..e79095f 100644 --- a/README_fr.md +++ b/README_fr.md @@ -19,38 +19,7 @@ Si vous n’avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) po Dotclear is an open-source web publishing software. Take control over your blog! -Dotclear project's purpose is to provide a user-friendly -tool allowing anyone to publish on the web, regardless of their technical skills. - -### Features - -- Easy publication -- Fully customizable theme -- User-friendly administration -- Flexible template system -- Media management -- Choose from several editing syntax (wiki, markdown or directly in wysiwyg) -- Flexible comment system -- Built-in antispam -- Localization -- Presentation widgets -- Themes and plugins -- Pages -- Tags and categories -- Automated installation -- Support for several database types -- Multiblog -- Multi-user with permissions -- Standards compliant -- Accessible -- Importing / exporting -- Naturally optimized for search engines -- Syndication feeds -- Complete trackback/pingback/webmention support -- Full Unicode support -- Extensible -- Performance and scalability -- Twice free +Dotclear project's purpose is to provide a user-friendly tool allowing anyone to publish on the web, regardless of their technical skills. **Version incluse :** 2.27.3~ynh1 From 543d7ea35de57354868604740889656c5bc035b9 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Thu, 12 Oct 2023 23:25:50 +0200 Subject: [PATCH 5/6] Fix multiple blogs conf script --- scripts/config | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/scripts/config b/scripts/config index 1aeb40f..a2f7f49 100644 --- a/scripts/config +++ b/scripts/config @@ -65,14 +65,13 @@ set__blogs_list() { # https://stackoverflow.com/questions/2312762/compare-difference-of-two-arrays-in-bash # Get added and removed blogs - added_ids_array=() - added_ids_array+=(`echo ${!domain_array[@]} ${!old_domain_array[@]} | tr ' ' '\n' | sort | uniq -u `) - removed_ids_array=() - removed_ids_array+=(`echo ${!domain_array[@]} ${!old_domain_array[@]} | tr ' ' '\n' | sort | uniq -D | uniq `) + difference_ids_array=(`echo ${!domain_array[@]} ${!old_domain_array[@]} | tr ' ' '\n' | sort | uniq -u `) + added_ids_array=(`echo ${!domain_array[@]} ${difference_ids_array[@]} | tr ' ' '\n' | sort | uniq -D | uniq `) + removed_ids_array=(`echo ${!old_domain_array[@]} ${difference_ids_array[@]} | tr ' ' '\n' | sort | uniq -D | uniq `) ynh_print_info --message="Added blogs: ${added_ids_array[@]}" ynh_print_info --message="Removed blogs: ${removed_ids_array[@]}" - + for id in ${removed_ids_array[@]}; do if [ $id != "default" ]; then if ynh_permission_exists --permission="$id"; then @@ -84,8 +83,8 @@ set__blogs_list() { for id in ${!domain_array[@]}; do if [ $id != "default" ]; then - if [ ${domain_array[$id]:-} != ${old_domain_array[$id]:-} ] || - [ ${path_array[$id]:-} != ${old_path_array[$id]:-} ]; then + if [ "${domain_array[$id]:-}" != "${old_domain_array[$id]:-}" ] || + [ "${path_array[$id]:-}" != "${old_path_array[$id]:-}" ]; then domain=${domain_array[$id]} path=${path_array[$id]} [ ! -z ${old_domain_array[$id]:-} ] && ynh_secure_remove --file="/etc/nginx/conf.d/${old_domain_array[$id]}.d/$app-$id.conf" From 855860b187b07cb5c98413f902544f50b3794446 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Sat, 14 Oct 2023 10:21:44 +0200 Subject: [PATCH 6/6] Improve config panel and script for multiple blogs management --- conf/nginx.conf | 1 + config_panel.toml | 20 +++++++++++++++----- scripts/config | 9 +++++++-- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index c5d0284..7046cac 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -16,6 +16,7 @@ location __PATH__/ { fastcgi_index index.php; include fastcgi_params; + fastcgi_param DC_BLOG_ID __BLOG_ID__; fastcgi_param REMOTE_USER $remote_user; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param SCRIPT_FILENAME $request_filename; diff --git a/config_panel.toml b/config_panel.toml index 6004fb1..c2c069d 100644 --- a/config_panel.toml +++ b/config_panel.toml @@ -106,13 +106,23 @@ help = "These permissions apply to the first connection of the user, the super u [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] + name = "" - [blogs.blogs_list.blogs_list] - ask = "List blogs with the format `id@domain.example/path`" + [blogs.blogs.info] + type = "alert" + style = "info" + ask = "Here you can instruct YunoHost to handle multiple blogs. It will create the appropriate permissions and NGINX configuration files.\n 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.blogs_list] + ask = "List of blogs" type = "tags" pattern.regexp = "[\\w]+@[\\w.]+\\/[\\w]*" pattern.error = "Incorrect format. Use `id@domain.example/path`" + help = """\ + - The `default` blog cannot be deleted and will be put back in the list. Use the usual Change URL method to move it to a new URL.\n\ + - Additional blogs must be declared with the format `id@domain.example/path`. + Each blog will have two permissions for main and admin access. By default the former has "visitors and all_users" access and the latter has "admins" group access. + Keeping the same `id` but changing the domain or path will keep the permission but reset the NGINX configuration file to the new location. + """ diff --git a/scripts/config b/scripts/config index a2f7f49..d6bc1ad 100644 --- a/scripts/config +++ b/scripts/config @@ -18,6 +18,7 @@ install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) admin=$(ynh_app_setting_get --app=$app --key=admin) domain=$(ynh_app_setting_get --app=$app --key=domain) path=$(ynh_app_setting_get --app=$app --key=path) +phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= # SPECIFIC SETTERS FOR TOML SHORT KEYS @@ -77,6 +78,9 @@ set__blogs_list() { if ynh_permission_exists --permission="$id"; then ynh_permission_delete --permission="$id" fi + if ynh_permission_exists --permission="${id}-admin"; then + ynh_permission_delete --permission="${id}-admin" + fi ynh_secure_remove --file="/etc/nginx/conf.d/${old_domain_array[$id]}.d/$app-$id.conf" fi done @@ -87,6 +91,7 @@ set__blogs_list() { [ "${path_array[$id]:-}" != "${old_path_array[$id]:-}" ]; then domain=${domain_array[$id]} path=${path_array[$id]} + blog_id=$id [ ! -z ${old_domain_array[$id]:-} ] && ynh_secure_remove --file="/etc/nginx/conf.d/${old_domain_array[$id]}.d/$app-$id.conf" ynh_add_config --template="nginx.conf" --destination="/etc/nginx/conf.d/${domain_array[$id]}.d/$app-$id.conf" fi @@ -95,8 +100,8 @@ set__blogs_list() { 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" else - ynh_permission_create --permission="$id" --url="${domain_array[$id]}${path_array[$id]}" --show_tile=true - ynh_permission_create --permission="${id}-admin" --url="${domain_array[$id]}${path_array[$id]}/admin" --show_tile=true + ynh_permission_create --permission="$id" --url="${domain_array[$id]}${path_array[$id]}" --show_tile=true --allowed=visitors all_users + ynh_permission_create --permission="${id}-admin" --url="${domain_array[$id]}${path_array[$id]}/admin" --show_tile=false --allowed=admins fi fi