diff --git a/README.md b/README.md index 058b6d6..22798c1 100644 --- a/README.md +++ b/README.md @@ -15,9 +15,9 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in ## Overview -Service for planning an appointment or making a decision quickly and easily +OpenSondage is an online service for planning an appointment or making a decision quickly and easily. No registration is required. -**Shipped version:** 1.1.16~ynh1 +**Shipped version:** 1.1.17~ynh1 **Demo:** https://framadate.org/ @@ -39,7 +39,6 @@ Service for planning an appointment or making a decision quickly and easily ## Documentation and resources * Official app website: https://framadate.org/ -* Official user documentation: https://yunohost.org/#/app_opensondage * Official admin documentation: https://framagit.org/framasoft/framadate/framadate/wikis/home * Upstream app code repository: https://git.framasoft.org/framasoft/framadate * YunoHost documentation for this app: https://yunohost.org/app_opensondage diff --git a/README_fr.md b/README_fr.md index ea78b08..b7c02d9 100644 --- a/README_fr.md +++ b/README_fr.md @@ -11,9 +11,9 @@ Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour ## Vue d'ensemble -Service pour planifier un rendez-vous ou prendre une décision rapidement et facilement +OpenSondage est un service en ligne permettant de planifier un rendez-vous ou prendre des décisions rapidement et simplement. Aucune inscription préalable n’est nécessaire. -**Version incluse :** 1.1.16~ynh1 +**Version incluse :** 1.1.17~ynh1 **Démo :** https://framadate.org/ @@ -35,7 +35,6 @@ Service pour planifier un rendez-vous ou prendre une décision rapidement et fac ## Documentations et ressources * Site officiel de l'app : https://framadate.org/ -* Documentation officielle utilisateur : https://yunohost.org/#/app_opensondage * Documentation officielle de l'admin : https://framagit.org/framasoft/framadate/framadate/wikis/home * Dépôt de code officiel de l'app : https://git.framasoft.org/framasoft/framadate * Documentation YunoHost pour cette app : https://yunohost.org/app_opensondage diff --git a/check_process b/check_process index 98248f7..cca0046 100644 --- a/check_process +++ b/check_process @@ -13,11 +13,11 @@ setup_private=1 setup_public=1 upgrade=1 - upgrade=1 from_commit=02f2cd7e656ebae74643e969746b23d8912c7798 + upgrade=1 from_commit=61398d8e49d4de8e7425c4ccd8098d5a4c55994b backup_restore=1 multi_instance=1 change_url=1 ;;; Upgrade options - ; commit=02f2cd7e656ebae74643e969746b23d8912c7798 - name=Merge pull request #70 from YunoHost-Apps/testing - manifest_arg=domain=DOMAIN&path=PATH&admin=USER&language=fr_FR&is_public=1& + ; commit=61398d8e49d4de8e7425c4ccd8098d5a4c55994b + name=Merge pull request #77 from YunoHost-Apps/testing + manifest_arg=domain=DOMAIN&path=PATH&admin=USER&language=fr&is_public=1& diff --git a/conf/app.src b/conf/app.src index 6a39146..b307330 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,6 +1,6 @@ -SOURCE_URL=https://framagit.org/framasoft/framadate/framadate/-/archive/1.1.16/framadate-1.1.16.tar.gz -SOURCE_SUM=89da42a915c912a91ae1ba44fd32a61ec8fa5f59c517ee3f5d74335ddee77c7d +SOURCE_URL=https://framagit.org/framasoft/framadate/framadate/-/archive/1.1.17/framadate-1.1.17.tar.gz +SOURCE_SUM=a9b086a7274886d0d13c1c3ed8d6caa848d798315bd6006c6883a37387c390b0 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true -SOURCE_FILENAME=opensondage-1-1-16.tar.gz +SOURCE_FILENAME=opensondage.tar.gz diff --git a/conf/nginx.conf b/conf/nginx.conf index 56d6c10..b102748 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -4,11 +4,6 @@ location __PATH__/ { # Path to source alias __FINALPATH__/; - # Force usage of https - if ($scheme = http) { - rewrite ^ https://$server_name$request_uri? permanent; - } - rewrite "^__PATH__/([a-zA-Z0-9-]+)$" "__PATH__/studs.php?poll=$1"; rewrite "^__PATH__/([a-zA-Z0-9-]+)/action/([a-zA-Z_-]+)/(.+)$" "__PATH__/studs.php?poll=$1&$2=$3"; rewrite "^__PATH__/([a-zA-Z0-9-]+)/vote/([a-zA-Z0-9]{16})$" "__PATH__/studs.php?poll=$1&vote=$2"; diff --git a/doc/DESCRIPTION.md b/doc/DESCRIPTION.md new file mode 100644 index 0000000..797f1f1 --- /dev/null +++ b/doc/DESCRIPTION.md @@ -0,0 +1 @@ +OpenSondage is an online service for planning an appointment or making a decision quickly and easily. No registration is required. \ No newline at end of file diff --git a/doc/DESCRIPTION_fr.md b/doc/DESCRIPTION_fr.md new file mode 100644 index 0000000..862aceb --- /dev/null +++ b/doc/DESCRIPTION_fr.md @@ -0,0 +1 @@ +OpenSondage est un service en ligne permettant de planifier un rendez-vous ou prendre des décisions rapidement et simplement. Aucune inscription préalable n’est nécessaire. \ No newline at end of file diff --git a/hooks/post_app_addaccess b/hooks/post_app_addaccess new file mode 100644 index 0000000..f86ee4e --- /dev/null +++ b/hooks/post_app_addaccess @@ -0,0 +1,33 @@ +#!/bin/bash + +# Source app helpers +source /usr/share/yunohost/helpers + +app=$1 +added_users=$2 +permission=$3 +added_groups=$4 + +if [ "$app" == __APP__ ]; then + if [ "$permission" = "create poll" ]; then # The fake permission "create poll" is modifed. + if [ "$added_groups" = "visitors" ]; then # As is it a fake permission we can only grant/remove the "visitors" group. + domain=$(ynh_app_setting_get --app=$app --key=domain) + path_url=$(ynh_app_setting_get --app=$app --key=path) + + if [ "$path_url" == "/" ]; then + # If the path is /, clear it to prevent any error with the regex. + path_url="" + fi + # Modify the domain to be used in a regex + domain_regex=$(echo "$domain" | sed 's@-@.@g') + ynh_app_setting_set --app=$app --key=unprotected_regex --value="$domain_regex$path_url/create_poll.php?.*$","$domain_regex$path_url/adminstuds.php?.*" + + # Sync the is_public variable according to the permission + ynh_app_setting_set --app=$app --key=is_public --value=1 + + yunohost app ssowatconf + else + ynh_print_warn --message="This app doesn't support this authorisation, you can only add or remove visitors group." + fi + fi +fi \ No newline at end of file diff --git a/hooks/post_app_removeaccess b/hooks/post_app_removeaccess new file mode 100644 index 0000000..1ea9ab3 --- /dev/null +++ b/hooks/post_app_removeaccess @@ -0,0 +1,26 @@ +#!/bin/bash + +# Source app helpers +source /usr/share/yunohost/helpers + +app=$1 +removed_users=$2 +permission=$3 +removed_groups=$4 + +if [ "$app" == __APP__ ]; then + if [ "$permission" = "create poll" ]; then # The fake permission "create poll" is modifed. + if [ "$removed_groups" = "visitors" ]; then # As is it a fake permission we can only grant/remove the "visitors" group. + + # We remove the regex, no more protection is needed. + ynh_app_setting_delete --app=$app --key=unprotected_regex + + # Sync the is_public variable according to the permission + ynh_app_setting_set --app=$app --key=is_public --value=0 + + yunohost app ssowatconf + else + ynh_print_warn --message="This app doesn't support this authorisation, you can only add or remove visitors group." + fi + fi +fi \ No newline at end of file diff --git a/manifest.json b/manifest.json index 42ae370..90fdf69 100644 --- a/manifest.json +++ b/manifest.json @@ -7,14 +7,13 @@ "fr": "Service pour planifier un rendez-vous ou prendre une décision rapidement et facilement", "de": "Service zur schnellen und einfachen Planung eines Termins oder zur Entscheidungsfindung" }, - "version": "1.1.16~ynh1", + "version": "1.1.17~ynh1", "url": "https://git.framasoft.org/framasoft/framadate", "upstream": { "license": "CECILL-B", "website": "https://framadate.org/", "demo": "https://framadate.org/", "admindoc": "https://framagit.org/framasoft/framadate/framadate/wikis/home", - "userdoc": "https://yunohost.org/#/app_opensondage", "code": "https://git.framasoft.org/framasoft/framadate" }, "license": "CECILL-B", @@ -27,7 +26,7 @@ "email": "ljf+opensondage_ynh@grimaud.me" }], "requirements": { - "yunohost": ">= 4.2.0" + "yunohost": ">= 4.3.0" }, "multi_instance": true, "services": [ @@ -39,8 +38,7 @@ "install" : [ { "name": "domain", - "type": "domain", - "example": "domain.org" + "type": "domain" }, { "name": "path", @@ -50,8 +48,7 @@ }, { "name": "admin", - "type": "user", - "example": "johndoe" + "type": "user" }, { "name": "language", diff --git a/scripts/_common.sh b/scripts/_common.sh index 406bdfb..6b3d3fe 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -6,8 +6,8 @@ # dependencies used by the app YNH_PHP_VERSION="7.3" -YNH_COMPOSER_VERSION=2.1.1 -extra_php_dependencies="php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-intl php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-cli" +YNH_COMPOSER_VERSION="2.1.1" +pkg_dependencies="php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-intl php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-cli" #================================================= # PERSONAL HELPERS diff --git a/scripts/change_url b/scripts/change_url index 9eef4d8..1ddffb2 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -98,16 +98,13 @@ ynh_script_progression --message="Upgrading SSOwat configuration..." # Make app public if necessary if [ $is_public -eq 1 ] then - ynh_app_setting_delete --app=$app --key=protected_regex - - # Keep /admin private if [ "$path_url" == "/" ]; then # If the path is /, clear it to prevent any error with the regex. path_url="" fi # Modify the domain to be used in a regex domain_regex=$(echo "$new_domain" | sed 's@-@.@g') - ynh_app_setting_set --app=$app --key=protected_regex --value="$domain_regex$path_url/admin/" + ynh_app_setting_set --app=$app --key=unprotected_regex --value="$domain_regex$path_url/create_poll.php?.*$","$domain_regex$path_url/adminstuds.php?.*" fi #================================================= diff --git a/scripts/install b/scripts/install index f2ba5ba..f14ca07 100644 --- a/scripts/install +++ b/scripts/install @@ -26,6 +26,7 @@ language=$YNH_APP_ARG_LANGUAGE is_public=$YNH_APP_ARG_IS_PUBLIC email=$(ynh_user_get_info --username=$admin --key=mail) timezone="$(cat /etc/timezone)" +phpversion=$YNH_PHP_VERSION app=$YNH_APP_INSTANCE_NAME @@ -50,6 +51,14 @@ ynh_app_setting_set --app=$app --key=path --value=$path_url ynh_app_setting_set --app=$app --key=admin --value=$admin ynh_app_setting_set --app=$app --key=language --value=$language ynh_app_setting_set --app=$app --key=email --value=$email +ynh_app_setting_set --app=$app --key=phpversion --value=$phpversion + +#================================================= +# INSTALL DEPENDENCIES +#================================================= +ynh_script_progression --message="Installing dependencies..." --weight=1 + +ynh_install_app_dependencies $pkg_dependencies #================================================= # CREATE DEDICATED USER @@ -96,8 +105,7 @@ ynh_add_nginx_config ynh_script_progression --message="Configuring PHP-FPM..." --weight=2 # Create a dedicated PHP-FPM config -ynh_add_fpm_config --package="$extra_php_dependencies" -phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) +ynh_add_fpm_config #================================================= # SPECIFIC SETUP @@ -108,6 +116,16 @@ ynh_script_progression --message="Configuring $app..." --weight=2 ynh_add_config --template="../conf/config.php" --destination="$final_path/app/inc/config.php" +chmod 400 "$final_path/app/inc/config.php" +chown $app:$app "$final_path/app/inc/config.php" + +#================================================= +# SETUP HOOKS FILE +#================================================= + +ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="../hooks/post_app_addaccess" +ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="../hooks/post_app_removeaccess" + #================================================= # REPLACE LOGO IMAGE (DEFAULT IS FRAMADATE) #================================================= @@ -147,17 +165,11 @@ ynh_script_progression --message="Configuring permissions..." --weight=1 if [ $is_public -eq 1 ] then ynh_permission_update --permission="main" --add="visitors" - - # Keep /admin private - if [ "$path_url" == "/" ]; then - # If the path is /, clear it to prevent any error with the regex. - path_url="" - fi - # Modify the domain to be used in a regex - domain_regex=$(echo "$domain" | sed 's@-@.@g') - ynh_app_setting_set --app=$app --key=protected_regex --value="$domain_regex$path_url/admin/" fi +# Only the admin can access the admin panel of the app (if the app has an admin panel) +ynh_permission_create --permission="admin" --url="/admin" --allowed=$admin + #================================================= # RELOAD NGINX #================================================= diff --git a/scripts/remove b/scripts/remove index 705c54d..c68f608 100644 --- a/scripts/remove +++ b/scripts/remove @@ -28,6 +28,14 @@ ynh_script_progression --message="Removing the MySQL database..." --weight=5 # Remove a database if it exists, along with the associated user ynh_mysql_remove_db --db_user=$db_name --db_name=$db_name +#================================================= +# REMOVE DEPENDENCIES +#================================================= +ynh_script_progression --message="Removing dependencies..." --weight=1 + +# Remove metapackage and its dependencies +ynh_remove_app_dependencies + #================================================= # REMOVE APP MAIN DIR #================================================= diff --git a/scripts/restore b/scripts/restore index 364a839..262ba90 100644 --- a/scripts/restore +++ b/scripts/restore @@ -35,10 +35,7 @@ timezone="$(cat /etc/timezone)" #================================================ ynh_script_progression --message="Validating restoration parameters..." --weight=1 -ynh_webpath_available --domain=$domain --path_url=$path_url \ - || ynh_die --message="Path not available: ${domain}${path_url}" -test ! -d $final_path \ - || ynh_die --message="There is already a directory: $final_path " +test ! -d $final_path || ynh_die --message="There is already a directory: $final_path " #================================================= # STANDARD RESTORATION STEPS @@ -82,7 +79,13 @@ ynh_script_progression --message="Restoring the PHP-FPM configuration..." --weig ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" -ynh_add_fpm_config --package="$extra_php_dependencies" +#================================================= +# REINSTALL DEPENDENCIES +#================================================= +ynh_script_progression --message="Reinstalling dependencies..." --weight=1 + +# Define and install dependencies +ynh_install_app_dependencies $pkg_dependencies #================================================= # RESTORE THE MYSQL DATABASE diff --git a/scripts/upgrade b/scripts/upgrade index 85da7bc..dbfa210 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -19,7 +19,6 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) path_url=$(ynh_app_setting_get --app=$app --key=path) admin=$(ynh_app_setting_get --app=$app --key=admin) -is_public=$(ynh_app_setting_get --app=$app --key=is_public) final_path=$(ynh_app_setting_get --app=$app --key=final_path) language=$(ynh_app_setting_get --app=$app --key=language) db_name=$(ynh_app_setting_get --app=$app --key=db_name) @@ -35,17 +34,25 @@ timezone="$(cat /etc/timezone)" upgrade_type=$(ynh_check_app_version_changed) +#================================================= +# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +#================================================= +ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=3 + +# Backup the current version of the app +ynh_backup_before_upgrade +ynh_clean_setup () { + # restore it if the upgrade fails + ynh_restore_upgradebackup +} +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 -if [ -z "$is_public" ]; then - is_public=$(ynh_app_setting_get --app=$app --key=public_site) - ynh_app_setting_set --app=$app --key=is_public --value=$is_public - ynh_app_setting_delete --app=$app --key=public_site -fi - # If db_name doesn't exist, create it if [ -z "$db_name" ]; then db_name=$(ynh_sanitize_dbid --db_name=$app) @@ -75,19 +82,17 @@ if [ -z "$path_url" ]; then ynh_app_setting_delete --app=$app --key=path_url fi -#================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP -#================================================= -ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=3 +# Cleaning legacy permissions +if ynh_legacy_permissions_exists; then + ynh_legacy_permissions_delete_all -# Backup the current version of the app -ynh_backup_before_upgrade -ynh_clean_setup () { - # restore it if the upgrade fails - ynh_restore_upgradebackup -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors + ynh_app_setting_delete --app=$app --key=is_public +fi + +if ! ynh_permission_exists --permission="admin"; then + # Create the required permissions + ynh_permission_create --permission="admin" --url="/admin" --allowed=$admin +fi #================================================= # CREATE DEDICATED USER @@ -123,13 +128,20 @@ ynh_script_progression --message="Upgrading NGINX web server configuration..." - # Create a dedicated nginx config ynh_add_nginx_config +#================================================= +# UPGRADE DEPENDENCIES +#================================================= +ynh_script_progression --message="Upgrading dependencies..." --weight=1 + +ynh_install_app_dependencies $pkg_dependencies + #================================================= # PHP-FPM CONFIGURATION #================================================= ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=3 # Create a dedicated PHP-FPM config -ynh_add_fpm_config --package="$extra_php_dependencies" +ynh_add_fpm_config #================================================= # SPECIFIC UPGRADE @@ -142,10 +154,17 @@ then ynh_script_progression --message="Reconfiguring $app..." --weight=2 ynh_add_config --template="../conf/config.php" --destination="$final_path/app/inc/config.php" - chmod 400 "$final_path/app/inc/config.php" - chown $app:$app "$final_path/app/inc/config.php" + chmod 400 "$final_path/app/inc/config.php" + chown $app:$app "$final_path/app/inc/config.php" fi +#================================================= +# SETUP HOOKS FILE +#================================================= + +ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="../hooks/post_app_addaccess" +ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="../hooks/post_app_removeaccess" + #================================================= # REPLACE LOGO IMAGE (DEFAULT IS FRAMADATE) #================================================= @@ -180,26 +199,6 @@ fi chown -R $app: "$final_path/"{tpl_c,admin/stdout.log} -#================================================= -# SETUP SSOWAT -#================================================= -ynh_script_progression --message="Upgrading SSOwat configuration..." --weight=1 - -# Make app public if necessary -if [ $is_public -eq 1 ] -then - ynh_app_setting_set --app=$app --key=skipped_uris --value="/" - - # Keep /admin private - if [ "$path_url" == "/" ]; then - # If the path is /, clear it to prevent any error with the regex. - path_url="" - fi - # Modify the domain to be used in a regex - domain_regex=$(echo "$domain" | sed 's@-@.@g') - ynh_app_setting_set --app=$app --key=protected_regex --value="$domain_regex$path_url/admin/" -fi - #================================================= # RELOAD NGINX #=================================================