diff --git a/README.md b/README.md index 2d6aabf..3eaec0e 100644 --- a/README.md +++ b/README.md @@ -17,8 +17,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in Weblate is a libre web-based translation tool with tight version control integration. It provides two user interfaces, propagation of translations across components, quality checks and automatic linking to source files. -**Shipped version:** 4.14~ynh1 - +**Shipped version:** 4.14.2~ynh1 **Demo:** https://hosted.weblate.org/ diff --git a/README_fr.md b/README_fr.md index a4fcb0a..cf74e34 100644 --- a/README_fr.md +++ b/README_fr.md @@ -17,8 +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.14~ynh1 - +**Version incluse :** 4.14.2~ynh1 **Démo :** https://hosted.weblate.org/ diff --git a/check_process b/check_process index f566996..53afd2b 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_username="myusername" + forge_token="myoauthtoken" ; Checks pkg_linter=1 setup_sub_dir=1 diff --git a/conf/hub_config b/conf/hub_config index 99df3d0..75944f2 100644 --- a/conf/hub_config +++ b/conf/hub_config @@ -1,4 +1,4 @@ github.com: -- user: __GITHUB_ACCOUNT__ - oauth_token: __GITHUB_TOKEN__ +- user: __FORGE_USERNAME__ + oauth_token: __FORGE_TOKEN__ protocol: https 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 e687436..18bdda3 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Translation platform using Git and Python", "fr": "Plateforme de traduction utilisant Git et Python" }, - "version": "4.14~ynh1", + "version": "4.14.2~ynh1", "url": "https://weblate.org", "upstream": { "license": "AGPL-3.0", @@ -21,10 +21,12 @@ "name": "YunoHost Contributors", "email": "apps@yunohost.org" }, - "previous_maintainers": [{ - "name": "Jean-Baptiste Holcroft", - "email": "jean-baptiste@holcroft.fr" - }], + "previous_maintainers": [ + { + "name": "Jean-Baptiste Holcroft", + "email": "jean-baptiste@holcroft.fr" + } + ], "requirements": { "yunohost": ">= 4.3.0" }, @@ -58,20 +60,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 de votre forge" + }, + "example": "Your username" + }, + { + "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..bcf0711 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -31,6 +31,20 @@ fi # PERSONAL HELPERS #================================================= +set_forge_variables() { + if [ $used_forge = "GitHub" ] ; then + 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..357b07f 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_username=$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 @@ -128,14 +130,17 @@ ynh_secure_remove --file="$tempdir" #================================================= # CONFIGURE HUB #================================================= -ynh_script_progression --message="Configure hub..." --weight=1 -mkdir "$final_path/.config/" -ynh_add_config --template="../conf/hub_config" --destination="$final_path/.config/hub" +if [ $used_forge = "GitHub" ] ; then + ynh_script_progression --message="Configure hub..." --weight=1 + + 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 @@ -174,6 +179,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..253c470 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_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) 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_username, forge_token don't exist, create them +if [ -z "$used_forge" ]; then + used_forge="GitHub" + 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_username --value=$forge_username + ynh_app_setting_set --app=$app --key=forge_token --value=$forge_token +fi + #================================================= # CREATE DEDICATED USER #================================================= @@ -129,14 +139,17 @@ ynh_secure_remove --file="$tempdir" #================================================= # CONFIGURE HUB #================================================= -ynh_script_progression --message="Configure hub..." --weight=2 -mkdir -p "$final_path/.config/" -ynh_add_config --template="../conf/hub_config" --destination="$final_path/.config/hub" +if [ $used_forge = "GitHub" ] ; then + ynh_script_progression --message="Configure hub..." --weight=1 + + #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 #================================================= # UPDATE A CONFIG FILE @@ -198,6 +211,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"