From 102e67035c545d8691497789a608a931e0c79349 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Thu, 11 Aug 2022 19:48:34 +0200 Subject: [PATCH 01/10] allow connection to both github and gitlab --- check_process | 5 +++-- conf/settings.py | 8 ++++---- manifest.json | 24 +++++++++++++++++------- scripts/_common.sh | 14 ++++++++++++++ scripts/install | 12 ++++++++---- scripts/upgrade | 18 +++++++++++++++--- 6 files changed, 61 insertions(+), 20 deletions(-) diff --git a/check_process b/check_process index f566996..f332126 100644 --- a/check_process +++ b/check_process @@ -5,8 +5,9 @@ is_public=1 admin="john" password="1Strong-Password" - github_account="myaccount" - github_token="myoauthtoken" + used_forge="GitLab" + forge_account="myaccount" + forge_token="myoauthtoken" ; Checks pkg_linter=1 setup_sub_dir=1 diff --git a/conf/settings.py b/conf/settings.py index 2b9a054..232ba72 100644 --- a/conf/settings.py +++ b/conf/settings.py @@ -229,13 +229,13 @@ TEMPLATES = [ # GitHub username and token for sending pull requests. # Please see the documentation for more details. -GITHUB_USERNAME = "__GITHUB_ACCOUNT__" -GITHUB_TOKEN = "__GITHUB_TOKEN__" +GITHUB_USERNAME = __GITHUB_USERNAME__ +GITHUB_TOKEN = __GITHUB_TOKEN__ # GitLab username and token for sending merge requests. # Please see the documentation for more details. -GITLAB_USERNAME = None -GITLAB_TOKEN = None +GITLAB_USERNAME = __GITLAB_USERNAME__ +GITLAB_TOKEN = __GITLAB_TOKEN__ # Authentication configuration AUTHENTICATION_BACKENDS = ( diff --git a/manifest.json b/manifest.json index 5d3d38c..c971550 100644 --- a/manifest.json +++ b/manifest.json @@ -58,20 +58,30 @@ "type": "password" }, { - "name": "github_account", + "name": "used_forge", "type": "string", "ask": { - "en": "GitHub's username", - "fr": "Nom d'utilisateur de GitHub" + "en":"Choose the forge you use", + "fr":"Choisissez la forge que vous utilisez" }, - "example": "Github account" + "choices": ["GitHub", "GitLab"], + "default": "GitHub" }, { - "name": "github_token", + "name": "forge_username", "type": "string", "ask": { - "en": "GitHub's token (OAuth)", - "fr": "Jeton GitHub (OAuth)" + "en": "Your forge's username", + "fr": "Nom d'utilisateur sur votre forge" + }, + "example": "Your account" + }, + { + "name": "forge_token", + "type": "string", + "ask": { + "en": "Your forge's token (OAuth)", + "fr": "Jeton de votre forge (OAuth)" }, "example": "A secret token" } diff --git a/scripts/_common.sh b/scripts/_common.sh index d3179a7..6828dee 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -31,6 +31,20 @@ fi # PERSONAL HELPERS #================================================= +set_forge_variables() { + if [ $used_forge -eq "GitHub" ] + github_username="\"$forge_username\"" + github_token="\"$forge_token\"" + gitlab_username="None" + gitlab_token="None" + else + github_username="None" + github_token="None" + gitlab_username="\"$forge_username\"" + gitlab_token="\"$forge_token\"" + fi +} + #================================================= # EXPERIMENTAL HELPERS #================================================= diff --git a/scripts/install b/scripts/install index f376c45..96b3267 100755 --- a/scripts/install +++ b/scripts/install @@ -28,8 +28,9 @@ path_url=$YNH_APP_ARG_PATH is_public=$YNH_APP_ARG_IS_PUBLIC admin=$YNH_APP_ARG_ADMIN password=$YNH_APP_ARG_PASSWORD -github_account=$YNH_APP_ARG_GITHUB_ACCOUNT -github_token=$YNH_APP_ARG_GITHUB_TOKEN +used_forge=$YNH_APP_ARG_USED_FORGE +forge_account=$YNH_APP_ARG_FORGE_USERNAME +forge_token=$YNH_APP_ARG_FORGE_TOKEN app=$YNH_APP_INSTANCE_NAME @@ -55,8 +56,9 @@ ynh_script_progression --message="Storing installation settings..." --weight=1 ynh_app_setting_set --app=$app --key=domain --value=$domain 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=github_account --value=$github_account -ynh_app_setting_set --app=$app --key=github_token --value=$github_token +ynh_app_setting_set --app=$app --key=used_forge --value=$used_forge +ynh_app_setting_set --app=$app --key=forge_username --value=$forge_username +ynh_app_setting_set --app=$app --key=forge_token --value=$forge_token #================================================= # STANDARD MODIFICATIONS @@ -174,6 +176,8 @@ ynh_app_setting_set --app=$app --key=redis_db --value="$redis_db" path_url="${path_url%/}" settings="$final_path/venv/lib/$weblate_pypath/site-packages/weblate/settings.py" +set_forge_variables + ynh_add_config --template="../conf/settings.py" --destination="$settings" ynh_add_config --template="../conf/celery-weblate" --destination="$final_path/celery-weblate" ynh_add_config --template="../conf/uwsgi.ini" --destination="/etc/uwsgi/apps-available/$app.ini" diff --git a/scripts/upgrade b/scripts/upgrade index 1d0351e..3ea46f4 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -23,8 +23,9 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_user=$db_name db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) -github_account=$(ynh_app_setting_get --app=$app --key=github_account) -github_token=$(ynh_app_setting_get --app=$app --key=github_token) +used_forge=$(ynh_app_setting_get --app=$app --key=used_forge) +forge_account=$(ynh_app_setting_get --app=$app --key=forge_account) +forge_token=$(ynh_app_setting_get --app=$app --key=forge_token) redis_db=$(ynh_app_setting_get --app=$app --key=redis_db) admin_mail=$(ynh_user_get_info --username="$admin" --key=mail) @@ -33,7 +34,6 @@ key=$(ynh_string_random --length=50) #================================================= # CHECK VERSION #================================================= -ynh_script_progression --message="Checking version..." upgrade_type=$(ynh_check_app_version_changed) @@ -88,6 +88,16 @@ then ynh_secure_remove --file="/var/log/$app-celery" fi +# If used_forge, forge_account, forge_token don't exist, create them +if [ -z "$used_forge" ]; then + used_forge="GitHub" + forge_account=$(ynh_app_setting_get --app=$app --key=github_account) + forge_token=$(ynh_app_setting_get --app=$app --key=github_token) + ynh_app_setting_set --app=$app --key=used_forge --value=$used_forge + ynh_app_setting_set --app=$app --key=forge_account --value=$forge_account + ynh_app_setting_set --app=$app --key=forge_token --value=$forge_token +fi + #================================================= # CREATE DEDICATED USER #================================================= @@ -198,6 +208,8 @@ upgrade() { settings="$final_path/venv/lib/$weblate_pypath/site-packages/weblate/settings.py" path_url="${path_url%/}" + set_forge_variables + ynh_add_config --template="../conf/settings.py" --destination="$settings" ynh_app_setting_set --app=$app --key=redis_db --value="$redis_db" From 425ac4051f3d319741f9277901c979c378744da0 Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Thu, 11 Aug 2022 17:48:46 +0000 Subject: [PATCH 02/10] Auto-update README --- README.md | 1 + README_fr.md | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0d6980c..32c7bb1 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,7 @@ Weblate is a libre web-based translation tool with tight version control integra **Shipped version:** 4.13.1~ynh1 + **Demo:** https://hosted.weblate.org/ ## Screenshots diff --git a/README_fr.md b/README_fr.md index d2761f6..3511191 100644 --- a/README_fr.md +++ b/README_fr.md @@ -17,7 +17,8 @@ Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour Weblate est un outil de traduction libre avec une intégration étroite du contrôle de version. Il fournit deux interfaces utilisateur, la propagation des traductions entre les composants, les contrôles de qualité et la liaison automatique aux fichiers source. -**Version incluse :** 4.13.1~ynh1 +**Version incluse :** 4.13.1~ynh1 + **Démo :** https://hosted.weblate.org/ From 95025df4a3976d8226cef13770ac4c55d9037068 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Thu, 11 Aug 2022 19:54:16 +0200 Subject: [PATCH 03/10] fix check_process --- check_process | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/check_process b/check_process index f332126..53afd2b 100644 --- a/check_process +++ b/check_process @@ -6,7 +6,7 @@ admin="john" password="1Strong-Password" used_forge="GitLab" - forge_account="myaccount" + forge_username="myusername" forge_token="myoauthtoken" ; Checks pkg_linter=1 From 631ec7dd3ce6e968072fa1b16ea124dc10392f80 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Thu, 11 Aug 2022 20:00:25 +0200 Subject: [PATCH 04/10] fix variable names --- manifest.json | 2 +- scripts/_common.sh | 1 + scripts/install | 2 +- scripts/upgrade | 8 ++++---- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/manifest.json b/manifest.json index c971550..c8a86a4 100644 --- a/manifest.json +++ b/manifest.json @@ -74,7 +74,7 @@ "en": "Your forge's username", "fr": "Nom d'utilisateur sur votre forge" }, - "example": "Your account" + "example": "Your username" }, { "name": "forge_token", diff --git a/scripts/_common.sh b/scripts/_common.sh index 6828dee..8dcda10 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -33,6 +33,7 @@ fi set_forge_variables() { if [ $used_forge -eq "GitHub" ] + then github_username="\"$forge_username\"" github_token="\"$forge_token\"" gitlab_username="None" diff --git a/scripts/install b/scripts/install index 96b3267..7fb77c7 100755 --- a/scripts/install +++ b/scripts/install @@ -29,7 +29,7 @@ is_public=$YNH_APP_ARG_IS_PUBLIC admin=$YNH_APP_ARG_ADMIN password=$YNH_APP_ARG_PASSWORD used_forge=$YNH_APP_ARG_USED_FORGE -forge_account=$YNH_APP_ARG_FORGE_USERNAME +forge_username=$YNH_APP_ARG_FORGE_USERNAME forge_token=$YNH_APP_ARG_FORGE_TOKEN app=$YNH_APP_INSTANCE_NAME diff --git a/scripts/upgrade b/scripts/upgrade index 3ea46f4..5685444 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -24,7 +24,7 @@ db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_user=$db_name db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) used_forge=$(ynh_app_setting_get --app=$app --key=used_forge) -forge_account=$(ynh_app_setting_get --app=$app --key=forge_account) +forge_username=$(ynh_app_setting_get --app=$app --key=forge_username) forge_token=$(ynh_app_setting_get --app=$app --key=forge_token) redis_db=$(ynh_app_setting_get --app=$app --key=redis_db) @@ -88,13 +88,13 @@ then ynh_secure_remove --file="/var/log/$app-celery" fi -# If used_forge, forge_account, forge_token don't exist, create them +# If used_forge, forge_username, forge_token don't exist, create them if [ -z "$used_forge" ]; then used_forge="GitHub" - forge_account=$(ynh_app_setting_get --app=$app --key=github_account) + forge_username=$(ynh_app_setting_get --app=$app --key=github_account) forge_token=$(ynh_app_setting_get --app=$app --key=github_token) ynh_app_setting_set --app=$app --key=used_forge --value=$used_forge - ynh_app_setting_set --app=$app --key=forge_account --value=$forge_account + ynh_app_setting_set --app=$app --key=forge_username --value=$forge_username ynh_app_setting_set --app=$app --key=forge_token --value=$forge_token fi From 8ea4d0b0883af8f0d17bd5a5e990f926e76e5959 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Thu, 11 Aug 2022 20:32:44 +0200 Subject: [PATCH 05/10] Update _common.sh --- scripts/_common.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 8dcda10..bcf0711 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -32,8 +32,7 @@ fi #================================================= set_forge_variables() { - if [ $used_forge -eq "GitHub" ] - then + if [ $used_forge = "GitHub" ] ; then github_username="\"$forge_username\"" github_token="\"$forge_token\"" gitlab_username="None" From 60b25905c11444bfad0fb01cdfe7c496db60dec5 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Thu, 11 Aug 2022 20:36:00 +0200 Subject: [PATCH 06/10] Update manifest.json --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index c8a86a4..25b55ed 100644 --- a/manifest.json +++ b/manifest.json @@ -72,7 +72,7 @@ "type": "string", "ask": { "en": "Your forge's username", - "fr": "Nom d'utilisateur sur votre forge" + "fr": "Nom d'utilisateur de votre forge" }, "example": "Your username" }, From 58ca24f71b7c510f1526896e303dbefbf1d9636e Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Thu, 11 Aug 2022 20:43:28 +0200 Subject: [PATCH 07/10] Fix hub config --- conf/hub_config | 6 +++--- scripts/install | 6 ++++++ scripts/upgrade | 6 ++++++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/conf/hub_config b/conf/hub_config index 99df3d0..37d9b23 100644 --- a/conf/hub_config +++ b/conf/hub_config @@ -1,4 +1,4 @@ -github.com: -- user: __GITHUB_ACCOUNT__ - oauth_token: __GITHUB_TOKEN__ +__FORGE_WEBSITE__: +- user: __FORGE_USERNAME__ + oauth_token: __FORGE_TOKEN__ protocol: https diff --git a/scripts/install b/scripts/install index 7fb77c7..0824faf 100755 --- a/scripts/install +++ b/scripts/install @@ -132,6 +132,12 @@ ynh_secure_remove --file="$tempdir" #================================================= ynh_script_progression --message="Configure hub..." --weight=1 +if [ $used_forge = "GitHub" ] ; then + forge_website="github.com" +else + forge_website="gitlab.com" +fi + mkdir "$final_path/.config/" ynh_add_config --template="../conf/hub_config" --destination="$final_path/.config/hub" diff --git a/scripts/upgrade b/scripts/upgrade index 5685444..34b6691 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -141,6 +141,12 @@ ynh_secure_remove --file="$tempdir" #================================================= ynh_script_progression --message="Configure hub..." --weight=2 +if [ $used_forge = "GitHub" ] ; then + forge_website="github.com" +else + forge_website="gitlab.com" +fi + mkdir -p "$final_path/.config/" ynh_add_config --template="../conf/hub_config" --destination="$final_path/.config/hub" From 38111e84335d007074a2f03b28b223c41b70c4f6 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Thu, 11 Aug 2022 20:50:47 +0200 Subject: [PATCH 08/10] fix hub config --- conf/hub_config | 2 +- scripts/install | 17 +++++++---------- scripts/upgrade | 17 +++++++---------- 3 files changed, 15 insertions(+), 21 deletions(-) diff --git a/conf/hub_config b/conf/hub_config index 37d9b23..75944f2 100644 --- a/conf/hub_config +++ b/conf/hub_config @@ -1,4 +1,4 @@ -__FORGE_WEBSITE__: +github.com: - user: __FORGE_USERNAME__ oauth_token: __FORGE_TOKEN__ protocol: https diff --git a/scripts/install b/scripts/install index 0824faf..357b07f 100755 --- a/scripts/install +++ b/scripts/install @@ -130,20 +130,17 @@ ynh_secure_remove --file="$tempdir" #================================================= # CONFIGURE HUB #================================================= -ynh_script_progression --message="Configure hub..." --weight=1 if [ $used_forge = "GitHub" ] ; then - forge_website="github.com" -else - forge_website="gitlab.com" -fi + ynh_script_progression --message="Configure hub..." --weight=1 + + mkdir "$final_path/.config/" + ynh_add_config --template="../conf/hub_config" --destination="$final_path/.config/hub" -mkdir "$final_path/.config/" -ynh_add_config --template="../conf/hub_config" --destination="$final_path/.config/hub" - -cat < "$final_path/.bashrc" -eval "$(hub alias -s /bin/bash)" + cat < "$final_path/.bashrc" + eval "$(hub alias -s /bin/bash)" EOF +fi #================================================= # PIP INSTALLATION diff --git a/scripts/upgrade b/scripts/upgrade index 34b6691..6a5b8bb 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -139,20 +139,17 @@ ynh_secure_remove --file="$tempdir" #================================================= # CONFIGURE HUB #================================================= -ynh_script_progression --message="Configure hub..." --weight=2 if [ $used_forge = "GitHub" ] ; then - forge_website="github.com" -else - forge_website="gitlab.com" -fi + ynh_script_progression --message="Configure hub..." --weight=1 + + mkdir "$final_path/.config/" + ynh_add_config --template="../conf/hub_config" --destination="$final_path/.config/hub" -mkdir -p "$final_path/.config/" -ynh_add_config --template="../conf/hub_config" --destination="$final_path/.config/hub" - -cat < "$final_path/.bashrc" -eval "$(hub alias -s /bin/bash)" + cat < "$final_path/.bashrc" + eval "$(hub alias -s /bin/bash)" EOF +fi #================================================= # UPDATE A CONFIG FILE From 4d97b2399a38d19816259e47118a3e0faf32991b Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Fri, 12 Aug 2022 18:53:51 +0200 Subject: [PATCH 09/10] Update upgrade --- scripts/upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index 6a5b8bb..253c470 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -143,7 +143,7 @@ ynh_secure_remove --file="$tempdir" if [ $used_forge = "GitHub" ] ; then ynh_script_progression --message="Configure hub..." --weight=1 - mkdir "$final_path/.config/" + #mkdir "$final_path/.config/" ynh_add_config --template="../conf/hub_config" --destination="$final_path/.config/hub" cat < "$final_path/.bashrc" From a5640ad13b1944d51ea6717298454f8456b3afe5 Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Wed, 31 Aug 2022 15:05:56 +0000 Subject: [PATCH 10/10] Auto-update README --- README.md | 1 - README_fr.md | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 73cd040..2d6aabf 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,6 @@ Weblate is a libre web-based translation tool with tight version control integra **Shipped version:** 4.14~ynh1 - **Demo:** https://hosted.weblate.org/ ## Screenshots diff --git a/README_fr.md b/README_fr.md index 3511191..a4fcb0a 100644 --- a/README_fr.md +++ b/README_fr.md @@ -17,7 +17,7 @@ Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour Weblate est un outil de traduction libre avec une intégration étroite du contrôle de version. Il fournit deux interfaces utilisateur, la propagation des traductions entre les composants, les contrôles de qualité et la liaison automatique aux fichiers source. -**Version incluse :** 4.13.1~ynh1 +**Version incluse :** 4.14~ynh1 **Démo :** https://hosted.weblate.org/