mirror of
https://github.com/YunoHost-Apps/flarum_ynh.git
synced 2024-09-03 18:36:24 +02:00
Merge pull request #70 from YunoHost-Apps/patch-language
Implement language selection
This commit is contained in:
commit
e8af9ef067
3 changed files with 139 additions and 94 deletions
171
manifest.json
171
manifest.json
|
@ -1,83 +1,92 @@
|
||||||
{
|
{
|
||||||
"name": "Flarum",
|
"name": "Flarum",
|
||||||
"id": "flarum",
|
"id": "flarum",
|
||||||
"packaging_format": 1,
|
"packaging_format": 1,
|
||||||
"description": {
|
"description": {
|
||||||
"en": "Flarum (open-source forum software) package for YunoHost.",
|
"en": "Flarum (open-source forum software) package for YunoHost.",
|
||||||
"fr": "Package Flarum (système de forum libre) pour YunoHost.",
|
"fr": "Package Flarum (système de forum libre) pour YunoHost.",
|
||||||
"de": "Flarum (Open Source) ist ein Programmpaket für Yunohost."
|
"de": "Flarum (Open Source) ist ein Programmpaket für Yunohost."
|
||||||
},
|
},
|
||||||
"url": "http://flarum.org/",
|
"url": "http://flarum.org/",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"version": "0.1.0-beta.7",
|
"version": "0.1.0-beta.7",
|
||||||
"maintainer": {
|
"maintainer": {
|
||||||
"name": "Titus PiJean",
|
"name": "Titus PiJean",
|
||||||
"email": "tituspijean@outlook.com"
|
"email": "tituspijean@outlook.com"
|
||||||
},
|
},
|
||||||
"requirements": {
|
"requirements": {
|
||||||
"yunohost": ">= 2.4.0"
|
"yunohost": ">= 2.4.0"
|
||||||
},
|
},
|
||||||
"multi_instance": true,
|
"multi_instance": true,
|
||||||
"services": [
|
"services": [
|
||||||
"nginx",
|
"nginx",
|
||||||
"php5-fpm",
|
"php5-fpm",
|
||||||
"mysql"
|
"mysql"
|
||||||
],
|
],
|
||||||
"arguments": {
|
"arguments": {
|
||||||
"install" : [
|
"install": [{
|
||||||
{
|
"name": "domain",
|
||||||
"name": "domain",
|
"type": "domain",
|
||||||
"type": "domain",
|
"ask": {
|
||||||
"ask": {
|
"en": "Choose a domain name for Flarum",
|
||||||
"en": "Choose a domain name for Flarum",
|
"fr": "Choisissez un nom de domaine pour Flarum",
|
||||||
"fr": "Choisissez un nom de domaine pour Flarum",
|
"de": "Wählen einen Domain-Namen für Flarum"
|
||||||
"de": "Wählen einen Domain-Namen für Flarum"
|
},
|
||||||
},
|
"example": "example.com"
|
||||||
"example": "example.com"
|
},
|
||||||
},
|
{
|
||||||
{
|
"name": "path",
|
||||||
"name": "path",
|
"type": "path",
|
||||||
"type": "path",
|
"ask": {
|
||||||
"ask": {
|
"en": "Choose a path for Flarum",
|
||||||
"en": "Choose a path for Flarum",
|
"fr": "Choisissez un chemin pour Flarum",
|
||||||
"fr": "Choisissez un chemin pour Flarum",
|
"de": "Wählen einen Pfad für Flarum"
|
||||||
"de": "Wählen einen Pfad für Flarum"
|
},
|
||||||
},
|
"example": "/flarum",
|
||||||
"example": "/flarum",
|
"default": "/flarum"
|
||||||
"default": "/flarum"
|
},
|
||||||
},
|
{
|
||||||
{
|
"name": "admin",
|
||||||
"name": "admin",
|
"type": "user",
|
||||||
"type": "user",
|
"ask": {
|
||||||
"ask": {
|
"en": "Choose the admin user (required for automatic post-installation)",
|
||||||
"en": "Choose the admin user (required for automatic post-installation)",
|
"fr": "Choisissez l’administrateur (nécessaire pour la post-installation automatique)",
|
||||||
"fr": "Choisissez l’administrateur (nécessaire pour la post-installation automatique)",
|
"de": "Wählen einen Administrator (erforderlich für die automatische Nachinstallation)"
|
||||||
"de": "Wählen einen Administrator (erforderlich für die automatische Nachinstallation)"
|
},
|
||||||
},
|
"example": "johndoe",
|
||||||
"example": "johndoe",
|
"optional": true
|
||||||
"optional": true
|
},
|
||||||
},
|
{
|
||||||
{
|
"name": "title",
|
||||||
"name": "title",
|
"ask": {
|
||||||
"ask": {
|
"en": "Choose a title for your forum (required for automatic post-installation)",
|
||||||
"en": "Choose a title for your forum (required for automatic post-installation)",
|
"fr": "Choisissez un titre pour votre forum (nécessaire pour la post-installation automatique)",
|
||||||
"fr": "Choisissez un titre pour votre forum (nécessaire pour la post-installation automatique)",
|
"de": "Wählen einen Titel für eure Internetforum (erforderlich für die automatische Nachinstallation)"
|
||||||
"de": "Wählen einen Titel für eure Internetforum (erforderlich für die automatische Nachinstallation)"
|
},
|
||||||
},
|
"example": "My forum",
|
||||||
"example": "My forum",
|
"default": "",
|
||||||
"default": "",
|
"optional": true
|
||||||
"optional": true
|
},
|
||||||
},
|
{
|
||||||
{
|
"name": "is_public",
|
||||||
"name": "is_public",
|
"type": "boolean",
|
||||||
"type": "boolean",
|
"ask": {
|
||||||
"ask": {
|
"en": "Is it a public application?",
|
||||||
"en": "Is it a public application?",
|
"fr": "Est-ce une application publique ?",
|
||||||
"fr": "Est-ce une application publique ?",
|
"de": "Ist es eine öffentliche Applikation ?"
|
||||||
"de": "Ist es eine öffentliche Applikation ?"
|
},
|
||||||
},
|
"default": true
|
||||||
"default": true
|
},
|
||||||
}
|
{
|
||||||
]
|
"name": "language",
|
||||||
}
|
"ask": {
|
||||||
|
"en": "Choose the application language",
|
||||||
|
"fr": "Choisissez la langue de l'application",
|
||||||
|
"de": "Wählen Sie eine Sprache"
|
||||||
|
},
|
||||||
|
"choices": ["fr", "en", "de"],
|
||||||
|
"default": "en"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -47,6 +47,37 @@ init_composer() {
|
||||||
# || ynh_die "Unable to update core dependencies with Composer"
|
# || ynh_die "Unable to update core dependencies with Composer"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Install extension, and activate it in database
|
||||||
|
# usage: install_and_activate_extension $user $final_path $db_name $extension $short_extension
|
||||||
|
# $extension is the "vendor/extension-name" string from packagist
|
||||||
|
# $short_extension is the extension name written in database, how it is shortened is still a mystery
|
||||||
|
install_and_activate_extension() {
|
||||||
|
local AS_USER=$1
|
||||||
|
local WORKDIR=$2
|
||||||
|
local DB_NAME=$3
|
||||||
|
local EXTENSION=$4
|
||||||
|
local SHORT_EXTENSION=$5
|
||||||
|
local sql_command
|
||||||
|
local old_extensions_enabled
|
||||||
|
local addition
|
||||||
|
local new_extensions_enabled
|
||||||
|
|
||||||
|
# Install extension
|
||||||
|
exec_composer $AS_USER $WORKDIR "require $EXTENSION --ansi"
|
||||||
|
|
||||||
|
# Retrieve current extensions
|
||||||
|
sql_command="SELECT \`value\` FROM settings WHERE \`key\` = 'extensions_enabled'"
|
||||||
|
old_extensions_enabled=$(ynh_mysql_execute_as_root "$sql_command" $db_name | tail -1)
|
||||||
|
|
||||||
|
# Append the extension name at the end of the list
|
||||||
|
addition=",\"${SHORT_EXTENSION}\"]"
|
||||||
|
new_extensions_enabled=${old_extensions_enabled::-1}$addition
|
||||||
|
# Update activated extensions list
|
||||||
|
sql_command="UPDATE \`settings\` SET \`value\`='$new_extensions_enabled' WHERE \`key\`='extensions_enabled';"
|
||||||
|
ynh_mysql_execute_as_root "$sql_command" $DB_NAME
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
# Send an email to inform the administrator
|
# Send an email to inform the administrator
|
||||||
#
|
#
|
||||||
# usage: ynh_send_readme_to_admin app_message [recipients]
|
# usage: ynh_send_readme_to_admin app_message [recipients]
|
||||||
|
|
|
@ -39,6 +39,7 @@ path_url=$YNH_APP_ARG_PATH
|
||||||
admin=$YNH_APP_ARG_ADMIN
|
admin=$YNH_APP_ARG_ADMIN
|
||||||
title=$YNH_APP_ARG_TITLE
|
title=$YNH_APP_ARG_TITLE
|
||||||
is_public=$YNH_APP_ARG_IS_PUBLIC
|
is_public=$YNH_APP_ARG_IS_PUBLIC
|
||||||
|
language=$YNH_APP_ARG_LANGUAGE
|
||||||
flarum_version="v0.1.0-beta.7"
|
flarum_version="v0.1.0-beta.7"
|
||||||
|
|
||||||
#===================================================
|
#===================================================
|
||||||
|
@ -66,6 +67,7 @@ ynh_app_setting_set $app domain $domain
|
||||||
ynh_app_setting_set $app path $path_url
|
ynh_app_setting_set $app path $path_url
|
||||||
ynh_app_setting_set $app admin $admin
|
ynh_app_setting_set $app admin $admin
|
||||||
ynh_app_setting_set $app is_public $is_public
|
ynh_app_setting_set $app is_public $is_public
|
||||||
|
ynh_app_setting_set $app language $language
|
||||||
ynh_app_setting_set $app final_path $final_path
|
ynh_app_setting_set $app final_path $final_path
|
||||||
ynh_app_setting_set $app flarum_version $flarum_version
|
ynh_app_setting_set $app flarum_version $flarum_version
|
||||||
|
|
||||||
|
@ -200,23 +202,26 @@ if [[ -n $admin && -n $title ]]; then
|
||||||
('mail_port', '587');"
|
('mail_port', '587');"
|
||||||
ynh_mysql_execute_as_root "$sql_command" $db_name
|
ynh_mysql_execute_as_root "$sql_command" $db_name
|
||||||
|
|
||||||
# Install the SSOwat auth extension
|
# Install and active the SSOwat auth extension
|
||||||
exec_composer $app $final_path "require tituspijean/flarum-ext-auth-ssowat:0.4.x-dev --ansi"
|
install_and_activate_extension $app $final_path $db_name "tituspijean/flarum-ext-auth-ssowat:0.4.x-dev" "tituspijean-auth-ssowat"
|
||||||
|
|
||||||
# Configure SSOwat auth extension
|
# Configure SSOwat auth extension
|
||||||
ssowatdomain=$(</etc/yunohost/current_host)
|
ssowatdomain=$(</etc/yunohost/current_host)
|
||||||
sql_command="INSERT INTO \`settings\` (\`key\`, \`value\`) VALUES ('flarum-ext-auth-ssowat.address', '$ssowatdomain'), ('flarum-ext-auth-ssowat.onlyUse', '0');"
|
sql_command="INSERT INTO \`settings\` (\`key\`, \`value\`) VALUES ('flarum-ext-auth-ssowat.address', '$ssowatdomain'), ('flarum-ext-auth-ssowat.onlyUse', '0');"
|
||||||
ynh_mysql_execute_as_root "$sql_command" $db_name
|
ynh_mysql_execute_as_root "$sql_command" $db_name
|
||||||
|
|
||||||
# Enable SSOwat auth extension
|
# Install, activate and set language extensions
|
||||||
# Retrieve current enabled extensions
|
case $language in
|
||||||
sql_command="SELECT \`value\` FROM settings WHERE \`key\` = 'extensions_enabled'"
|
fr)
|
||||||
old_extensions_enabled=$(ynh_mysql_execute_as_root "$sql_command" $db_name | tail -1)
|
install_and_activate_extension $app $final_path $db_name "milescellar/flarum-ext-french" "milescellar-french"
|
||||||
# Append the extension name at the end of the list
|
sql_command="UPDATE \`settings\` SET \`value\` = 'fr' WHERE \`settings\`.\`key\` = 'default_locale'"
|
||||||
addition=",\"tituspijean-auth-ssowat\"]"
|
ynh_mysql_execute_as_root "$sql_command" $db_name
|
||||||
new_extensions_enabled=${old_extensions_enabled::-1}$addition
|
;;
|
||||||
sql_command="UPDATE \`settings\` SET \`value\`='$new_extensions_enabled' WHERE \`key\`='extensions_enabled';"
|
de)
|
||||||
ynh_mysql_execute_as_root "$sql_command" $db_name
|
install_and_activate_extension $app $final_path $db_name "cbmainz/flarum-de" "cbmainz-de"
|
||||||
|
sql_command="UPDATE \`settings\` SET \`value\` = 'de' WHERE \`settings\`.\`key\` = 'default_locale'"
|
||||||
|
ynh_mysql_execute_as_root "$sql_command" $db_name
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
# Send login credentials to admin
|
# Send login credentials to admin
|
||||||
app_message="User : $admin, password : $admin_pwd
|
app_message="User : $admin, password : $admin_pwd
|
||||||
|
|
Loading…
Add table
Reference in a new issue