1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/weblate_ynh.git synced 2024-10-01 13:35:04 +02:00

Merge pull request #67 from YunoHost-Apps/testing

Testing
This commit is contained in:
Kayou 2022-11-14 10:52:19 +01:00 committed by GitHub
commit d30f435fc0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 88 additions and 41 deletions

View file

@ -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. 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/ **Demo:** https://hosted.weblate.org/

View file

@ -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. 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/ **Démo :** https://hosted.weblate.org/

View file

@ -5,8 +5,9 @@
is_public=1 is_public=1
admin="john" admin="john"
password="1Strong-Password" password="1Strong-Password"
github_account="myaccount" used_forge="GitLab"
github_token="myoauthtoken" forge_username="myusername"
forge_token="myoauthtoken"
; Checks ; Checks
pkg_linter=1 pkg_linter=1
setup_sub_dir=1 setup_sub_dir=1

View file

@ -1,4 +1,4 @@
github.com: github.com:
- user: __GITHUB_ACCOUNT__ - user: __FORGE_USERNAME__
oauth_token: __GITHUB_TOKEN__ oauth_token: __FORGE_TOKEN__
protocol: https protocol: https

View file

@ -229,13 +229,13 @@ TEMPLATES = [
# GitHub username and token for sending pull requests. # GitHub username and token for sending pull requests.
# Please see the documentation for more details. # Please see the documentation for more details.
GITHUB_USERNAME = "__GITHUB_ACCOUNT__" GITHUB_USERNAME = __GITHUB_USERNAME__
GITHUB_TOKEN = "__GITHUB_TOKEN__" GITHUB_TOKEN = __GITHUB_TOKEN__
# GitLab username and token for sending merge requests. # GitLab username and token for sending merge requests.
# Please see the documentation for more details. # Please see the documentation for more details.
GITLAB_USERNAME = None GITLAB_USERNAME = __GITLAB_USERNAME__
GITLAB_TOKEN = None GITLAB_TOKEN = __GITLAB_TOKEN__
# Authentication configuration # Authentication configuration
AUTHENTICATION_BACKENDS = ( AUTHENTICATION_BACKENDS = (

View file

@ -6,7 +6,7 @@
"en": "Translation platform using Git and Python", "en": "Translation platform using Git and Python",
"fr": "Plateforme de traduction utilisant Git et Python" "fr": "Plateforme de traduction utilisant Git et Python"
}, },
"version": "4.14~ynh1", "version": "4.14.2~ynh1",
"url": "https://weblate.org", "url": "https://weblate.org",
"upstream": { "upstream": {
"license": "AGPL-3.0", "license": "AGPL-3.0",
@ -21,10 +21,12 @@
"name": "YunoHost Contributors", "name": "YunoHost Contributors",
"email": "apps@yunohost.org" "email": "apps@yunohost.org"
}, },
"previous_maintainers": [{ "previous_maintainers": [
{
"name": "Jean-Baptiste Holcroft", "name": "Jean-Baptiste Holcroft",
"email": "jean-baptiste@holcroft.fr" "email": "jean-baptiste@holcroft.fr"
}], }
],
"requirements": { "requirements": {
"yunohost": ">= 4.3.0" "yunohost": ">= 4.3.0"
}, },
@ -58,20 +60,30 @@
"type": "password" "type": "password"
}, },
{ {
"name": "github_account", "name": "used_forge",
"type": "string", "type": "string",
"ask": { "ask": {
"en": "GitHub's username", "en":"Choose the forge you use",
"fr": "Nom d'utilisateur de GitHub" "fr":"Choisissez la forge que vous utilisez"
}, },
"example": "Github account" "choices": ["GitHub", "GitLab"],
"default": "GitHub"
}, },
{ {
"name": "github_token", "name": "forge_username",
"type": "string", "type": "string",
"ask": { "ask": {
"en": "GitHub's token (OAuth)", "en": "Your forge's username",
"fr": "Jeton GitHub (OAuth)" "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" "example": "A secret token"
} }

View file

@ -31,6 +31,20 @@ fi
# PERSONAL HELPERS # 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 # EXPERIMENTAL HELPERS
#================================================= #=================================================

View file

@ -28,8 +28,9 @@ path_url=$YNH_APP_ARG_PATH
is_public=$YNH_APP_ARG_IS_PUBLIC is_public=$YNH_APP_ARG_IS_PUBLIC
admin=$YNH_APP_ARG_ADMIN admin=$YNH_APP_ARG_ADMIN
password=$YNH_APP_ARG_PASSWORD password=$YNH_APP_ARG_PASSWORD
github_account=$YNH_APP_ARG_GITHUB_ACCOUNT used_forge=$YNH_APP_ARG_USED_FORGE
github_token=$YNH_APP_ARG_GITHUB_TOKEN forge_username=$YNH_APP_ARG_FORGE_USERNAME
forge_token=$YNH_APP_ARG_FORGE_TOKEN
app=$YNH_APP_INSTANCE_NAME 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=domain --value=$domain
ynh_app_setting_set --app=$app --key=path --value=$path_url 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=admin --value=$admin
ynh_app_setting_set --app=$app --key=github_account --value=$github_account ynh_app_setting_set --app=$app --key=used_forge --value=$used_forge
ynh_app_setting_set --app=$app --key=github_token --value=$github_token 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 # STANDARD MODIFICATIONS
@ -128,6 +130,8 @@ ynh_secure_remove --file="$tempdir"
#================================================= #=================================================
# CONFIGURE HUB # CONFIGURE HUB
#================================================= #=================================================
if [ $used_forge = "GitHub" ] ; then
ynh_script_progression --message="Configure hub..." --weight=1 ynh_script_progression --message="Configure hub..." --weight=1
mkdir "$final_path/.config/" mkdir "$final_path/.config/"
@ -136,6 +140,7 @@ ynh_add_config --template="../conf/hub_config" --destination="$final_path/.confi
cat <<EOF > "$final_path/.bashrc" cat <<EOF > "$final_path/.bashrc"
eval "$(hub alias -s /bin/bash)" eval "$(hub alias -s /bin/bash)"
EOF EOF
fi
#================================================= #=================================================
# PIP INSTALLATION # PIP INSTALLATION
@ -174,6 +179,8 @@ ynh_app_setting_set --app=$app --key=redis_db --value="$redis_db"
path_url="${path_url%/}" path_url="${path_url%/}"
settings="$final_path/venv/lib/$weblate_pypath/site-packages/weblate/settings.py" 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/settings.py" --destination="$settings"
ynh_add_config --template="../conf/celery-weblate" --destination="$final_path/celery-weblate" 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" ynh_add_config --template="../conf/uwsgi.ini" --destination="/etc/uwsgi/apps-available/$app.ini"

View file

@ -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_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name db_user=$db_name
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
github_account=$(ynh_app_setting_get --app=$app --key=github_account) used_forge=$(ynh_app_setting_get --app=$app --key=used_forge)
github_token=$(ynh_app_setting_get --app=$app --key=github_token) 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) redis_db=$(ynh_app_setting_get --app=$app --key=redis_db)
admin_mail=$(ynh_user_get_info --username="$admin" --key=mail) admin_mail=$(ynh_user_get_info --username="$admin" --key=mail)
@ -33,7 +34,6 @@ key=$(ynh_string_random --length=50)
#================================================= #=================================================
# CHECK VERSION # CHECK VERSION
#================================================= #=================================================
ynh_script_progression --message="Checking version..."
upgrade_type=$(ynh_check_app_version_changed) upgrade_type=$(ynh_check_app_version_changed)
@ -88,6 +88,16 @@ then
ynh_secure_remove --file="/var/log/$app-celery" ynh_secure_remove --file="/var/log/$app-celery"
fi 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 # CREATE DEDICATED USER
#================================================= #=================================================
@ -129,14 +139,17 @@ ynh_secure_remove --file="$tempdir"
#================================================= #=================================================
# CONFIGURE HUB # CONFIGURE HUB
#================================================= #=================================================
ynh_script_progression --message="Configure hub..." --weight=2
mkdir -p "$final_path/.config/" 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" ynh_add_config --template="../conf/hub_config" --destination="$final_path/.config/hub"
cat <<EOF > "$final_path/.bashrc" cat <<EOF > "$final_path/.bashrc"
eval "$(hub alias -s /bin/bash)" eval "$(hub alias -s /bin/bash)"
EOF EOF
fi
#================================================= #=================================================
# UPDATE A CONFIG FILE # UPDATE A CONFIG FILE
@ -198,6 +211,8 @@ upgrade() {
settings="$final_path/venv/lib/$weblate_pypath/site-packages/weblate/settings.py" settings="$final_path/venv/lib/$weblate_pypath/site-packages/weblate/settings.py"
path_url="${path_url%/}" path_url="${path_url%/}"
set_forge_variables
ynh_add_config --template="../conf/settings.py" --destination="$settings" ynh_add_config --template="../conf/settings.py" --destination="$settings"
ynh_app_setting_set --app=$app --key=redis_db --value="$redis_db" ynh_app_setting_set --app=$app --key=redis_db --value="$redis_db"