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
173
manifest.json
173
manifest.json
|
@ -1,83 +1,92 @@
|
|||
{
|
||||
"name": "Flarum",
|
||||
"id": "flarum",
|
||||
"packaging_format": 1,
|
||||
"description": {
|
||||
"en": "Flarum (open-source forum software) package for YunoHost.",
|
||||
"fr": "Package Flarum (système de forum libre) pour YunoHost.",
|
||||
"de": "Flarum (Open Source) ist ein Programmpaket für Yunohost."
|
||||
},
|
||||
"url": "http://flarum.org/",
|
||||
"license": "MIT",
|
||||
"version": "0.1.0-beta.7",
|
||||
"maintainer": {
|
||||
"name": "Titus PiJean",
|
||||
"email": "tituspijean@outlook.com"
|
||||
},
|
||||
"requirements": {
|
||||
"yunohost": ">= 2.4.0"
|
||||
},
|
||||
"multi_instance": true,
|
||||
"services": [
|
||||
"nginx",
|
||||
"php5-fpm",
|
||||
"mysql"
|
||||
],
|
||||
"arguments": {
|
||||
"install" : [
|
||||
{
|
||||
"name": "domain",
|
||||
"type": "domain",
|
||||
"ask": {
|
||||
"en": "Choose a domain name for Flarum",
|
||||
"fr": "Choisissez un nom de domaine pour Flarum",
|
||||
"de": "Wählen einen Domain-Namen für Flarum"
|
||||
},
|
||||
"example": "example.com"
|
||||
},
|
||||
{
|
||||
"name": "path",
|
||||
"type": "path",
|
||||
"ask": {
|
||||
"en": "Choose a path for Flarum",
|
||||
"fr": "Choisissez un chemin pour Flarum",
|
||||
"de": "Wählen einen Pfad für Flarum"
|
||||
},
|
||||
"example": "/flarum",
|
||||
"default": "/flarum"
|
||||
},
|
||||
{
|
||||
"name": "admin",
|
||||
"type": "user",
|
||||
"ask": {
|
||||
"en": "Choose the admin user (required for automatic post-installation)",
|
||||
"fr": "Choisissez l’administrateur (nécessaire pour la post-installation automatique)",
|
||||
"de": "Wählen einen Administrator (erforderlich für die automatische Nachinstallation)"
|
||||
},
|
||||
"example": "johndoe",
|
||||
"optional": true
|
||||
},
|
||||
{
|
||||
"name": "title",
|
||||
"ask": {
|
||||
"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)",
|
||||
"de": "Wählen einen Titel für eure Internetforum (erforderlich für die automatische Nachinstallation)"
|
||||
},
|
||||
"example": "My forum",
|
||||
"default": "",
|
||||
"optional": true
|
||||
},
|
||||
{
|
||||
"name": "is_public",
|
||||
"type": "boolean",
|
||||
"ask": {
|
||||
"en": "Is it a public application?",
|
||||
"fr": "Est-ce une application publique ?",
|
||||
"de": "Ist es eine öffentliche Applikation ?"
|
||||
},
|
||||
"default": true
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
"name": "Flarum",
|
||||
"id": "flarum",
|
||||
"packaging_format": 1,
|
||||
"description": {
|
||||
"en": "Flarum (open-source forum software) package for YunoHost.",
|
||||
"fr": "Package Flarum (système de forum libre) pour YunoHost.",
|
||||
"de": "Flarum (Open Source) ist ein Programmpaket für Yunohost."
|
||||
},
|
||||
"url": "http://flarum.org/",
|
||||
"license": "MIT",
|
||||
"version": "0.1.0-beta.7",
|
||||
"maintainer": {
|
||||
"name": "Titus PiJean",
|
||||
"email": "tituspijean@outlook.com"
|
||||
},
|
||||
"requirements": {
|
||||
"yunohost": ">= 2.4.0"
|
||||
},
|
||||
"multi_instance": true,
|
||||
"services": [
|
||||
"nginx",
|
||||
"php5-fpm",
|
||||
"mysql"
|
||||
],
|
||||
"arguments": {
|
||||
"install": [{
|
||||
"name": "domain",
|
||||
"type": "domain",
|
||||
"ask": {
|
||||
"en": "Choose a domain name for Flarum",
|
||||
"fr": "Choisissez un nom de domaine pour Flarum",
|
||||
"de": "Wählen einen Domain-Namen für Flarum"
|
||||
},
|
||||
"example": "example.com"
|
||||
},
|
||||
{
|
||||
"name": "path",
|
||||
"type": "path",
|
||||
"ask": {
|
||||
"en": "Choose a path for Flarum",
|
||||
"fr": "Choisissez un chemin pour Flarum",
|
||||
"de": "Wählen einen Pfad für Flarum"
|
||||
},
|
||||
"example": "/flarum",
|
||||
"default": "/flarum"
|
||||
},
|
||||
{
|
||||
"name": "admin",
|
||||
"type": "user",
|
||||
"ask": {
|
||||
"en": "Choose the admin user (required for automatic post-installation)",
|
||||
"fr": "Choisissez l’administrateur (nécessaire pour la post-installation automatique)",
|
||||
"de": "Wählen einen Administrator (erforderlich für die automatische Nachinstallation)"
|
||||
},
|
||||
"example": "johndoe",
|
||||
"optional": true
|
||||
},
|
||||
{
|
||||
"name": "title",
|
||||
"ask": {
|
||||
"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)",
|
||||
"de": "Wählen einen Titel für eure Internetforum (erforderlich für die automatische Nachinstallation)"
|
||||
},
|
||||
"example": "My forum",
|
||||
"default": "",
|
||||
"optional": true
|
||||
},
|
||||
{
|
||||
"name": "is_public",
|
||||
"type": "boolean",
|
||||
"ask": {
|
||||
"en": "Is it a public application?",
|
||||
"fr": "Est-ce une application publique ?",
|
||||
"de": "Ist es eine öffentliche Applikation ?"
|
||||
},
|
||||
"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"
|
||||
}
|
||||
|
||||
# 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
|
||||
#
|
||||
# usage: ynh_send_readme_to_admin app_message [recipients]
|
||||
|
|
|
@ -39,6 +39,7 @@ path_url=$YNH_APP_ARG_PATH
|
|||
admin=$YNH_APP_ARG_ADMIN
|
||||
title=$YNH_APP_ARG_TITLE
|
||||
is_public=$YNH_APP_ARG_IS_PUBLIC
|
||||
language=$YNH_APP_ARG_LANGUAGE
|
||||
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 admin $admin
|
||||
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 flarum_version $flarum_version
|
||||
|
||||
|
@ -200,23 +202,26 @@ if [[ -n $admin && -n $title ]]; then
|
|||
('mail_port', '587');"
|
||||
ynh_mysql_execute_as_root "$sql_command" $db_name
|
||||
|
||||
# Install the SSOwat auth extension
|
||||
exec_composer $app $final_path "require tituspijean/flarum-ext-auth-ssowat:0.4.x-dev --ansi"
|
||||
|
||||
# Install and active the SSOwat auth extension
|
||||
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
|
||||
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');"
|
||||
ynh_mysql_execute_as_root "$sql_command" $db_name
|
||||
|
||||
# Enable SSOwat auth extension
|
||||
# Retrieve current enabled 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=",\"tituspijean-auth-ssowat\"]"
|
||||
new_extensions_enabled=${old_extensions_enabled::-1}$addition
|
||||
sql_command="UPDATE \`settings\` SET \`value\`='$new_extensions_enabled' WHERE \`key\`='extensions_enabled';"
|
||||
ynh_mysql_execute_as_root "$sql_command" $db_name
|
||||
# Install, activate and set language extensions
|
||||
case $language in
|
||||
fr)
|
||||
install_and_activate_extension $app $final_path $db_name "milescellar/flarum-ext-french" "milescellar-french"
|
||||
sql_command="UPDATE \`settings\` SET \`value\` = 'fr' WHERE \`settings\`.\`key\` = 'default_locale'"
|
||||
ynh_mysql_execute_as_root "$sql_command" $db_name
|
||||
;;
|
||||
de)
|
||||
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
|
||||
app_message="User : $admin, password : $admin_pwd
|
||||
|
|
Loading…
Reference in a new issue