1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/dotclear2_ynh.git synced 2024-09-03 18:26:29 +02:00

Improve config panel and script for multiple blogs management

This commit is contained in:
tituspijean 2023-10-14 10:21:44 +02:00
parent 543d7ea35d
commit 855860b187
No known key found for this signature in database
GPG key ID: EF3B0D7CC0A94720
3 changed files with 23 additions and 7 deletions

View file

@ -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;

View file

@ -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.
"""

View file

@ -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