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