mirror of
https://github.com/YunoHost/install-app.git
synced 2024-09-03 20:06:19 +02:00
fix install-apps
This commit is contained in:
parent
caa01cb6b1
commit
d6420c3243
3 changed files with 18 additions and 76 deletions
88
index.php
88
index.php
|
@ -8,40 +8,26 @@ $user_locale = substr(Locale::acceptFromHttp($_SERVER['HTTP_ACCEPT_LANGUAGE']),
|
||||||
if (!file_exists("locales/".$user_locale.".json")) { $user_locale = 'en'; }
|
if (!file_exists("locales/".$user_locale.".json")) { $user_locale = 'en'; }
|
||||||
$locale=json_decode(file_get_contents("locales/".$user_locale.".json"), true);
|
$locale=json_decode(file_get_contents("locales/".$user_locale.".json"), true);
|
||||||
|
|
||||||
// Parse the official app list
|
// Parse the apps list
|
||||||
$official_json=file_get_contents("https://app.yunohost.org/official.json");
|
$apps_list_json=file_get_contents("https://app.yunohost.org/apps.json");
|
||||||
$official=json_decode($official_json, true);
|
$apps_list=json_decode($apps_list_json, true);
|
||||||
|
|
||||||
// Check whether the app is official, community, or neither
|
// Check if the app is the apps list
|
||||||
if(array_key_exists($app, $official)) {
|
if(array_key_exists($app, $apps_list)) {
|
||||||
// The app is in the official list
|
// The app is in the apps list
|
||||||
$app_status = 'official'; // The app is in the official list
|
$app_status = 'apps_list'; // The app is in the apps list
|
||||||
$app_name = $official[$app]['manifest']['name']; // Saves the app name
|
$app_name = $apps_list[$app]['manifest']['name']; // Saves the app name
|
||||||
$app_git = $official[$app]['git']['url']; // Saves the git URL
|
$app_git = $apps_list[$app]['git']['url']; // Saves the git URL
|
||||||
$app_state = $official[$app]['state']; // Saves the app state
|
$app_state = $apps_list[$app]['state']; // Saves the app state
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Parse the community app list
|
// The app is not in the apps list
|
||||||
$community_json=file_get_contents("https://app.yunohost.org/community.json");
|
$app_status = null;
|
||||||
$community=json_decode($community_json, true);
|
$app_name = "";
|
||||||
|
|
||||||
// Check if the app is community
|
|
||||||
if(array_key_exists($app, $community)) {
|
|
||||||
// The app is in the community list
|
|
||||||
$app_status = 'community'; // The app is in the community list
|
|
||||||
$app_name = $community[$app]['manifest']['name']; // Saves the app name
|
|
||||||
$app_git = $community[$app]['git']['url']; // Saves the git URL
|
|
||||||
$app_state = $community[$app]['state']; // Saves the app state
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// The app is neither in the official, nor in the community list
|
|
||||||
$app_status = null;
|
|
||||||
$app_name = "";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the user submitted his or her server and the app is official, redirects to the server
|
// If the user submitted his or her server and the app is in apps ist, redirects to the server
|
||||||
if(isset($_POST['server']) AND !empty($_POST['server']) AND $app_status == 'official') {
|
if(isset($_POST['server']) AND !empty($_POST['server']) AND $app_status == 'apps_list') {
|
||||||
$server = rtrim(preg_replace('#^https?://#', '', $_POST['server']),"/");
|
$server = rtrim(preg_replace('#^https?://#', '', $_POST['server']),"/");
|
||||||
$url = 'https://'.$server.'/yunohost/admin/#/apps/install/'.$app;
|
$url = 'https://'.$server.'/yunohost/admin/#/apps/install/'.$app;
|
||||||
header('Location: '.$url);
|
header('Location: '.$url);
|
||||||
|
@ -92,8 +78,8 @@ if(isset($_POST['server']) AND !empty($_POST['server']) AND $app_status == 'offi
|
||||||
<div class="ynh-wrapper login">
|
<div class="ynh-wrapper login">
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
// The app is official, display an install form
|
// The app is in apps list, display an install form
|
||||||
if($app_status == 'official') {
|
if($app_status == 'apps_list') {
|
||||||
?>
|
?>
|
||||||
<form class="login-form" name="input" action="" method="post">
|
<form class="login-form" name="input" action="" method="post">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
@ -104,45 +90,7 @@ if($app_status == 'official') {
|
||||||
</form>
|
</form>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
// The app is community, display a specific form and a warning
|
// The app is not in the apps list
|
||||||
else if($app_status == 'community') {
|
|
||||||
?>
|
|
||||||
<div class="wrapper messages warning">
|
|
||||||
<p><?php echo str_replace(["{app_name}", "{app_state}"], [$app_name, $locale[$app_state]], $locale['community_warning']); ?></p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<?php
|
|
||||||
// If the user submitted his or her server and the app is community, redirects to the server
|
|
||||||
if(isset($_POST['server']) AND !empty($_POST['server']) AND $app_status == 'community') {
|
|
||||||
$server = rtrim(preg_replace('#^https?://#', '', $_POST['server']),"/");
|
|
||||||
$url = 'https://'.$server.'/yunohost/admin/#/apps/install';
|
|
||||||
?>
|
|
||||||
<form class="login-form" name="input" action="<?php echo $url; ?>" method="get">
|
|
||||||
<p style="text-align:center;color:white;"><?php echo $locale['community_instructions']; ?></p>
|
|
||||||
<div class="form-group">
|
|
||||||
<label class="icon icon-pencil" for="git"><span class="element-invisible"><?php echo $app_git; ?></span></label>
|
|
||||||
<input id="git" type="text" name="git" value="<?php echo $app_git; ?>" class="form-text" readonly onClick="this.select();">
|
|
||||||
</div>
|
|
||||||
<input type="submit" value="<?php echo $locale['community_redirect']; ?>" class="btn classic-btn large-btn">
|
|
||||||
</form>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// Display the server form
|
|
||||||
?>
|
|
||||||
|
|
||||||
<form class="login-form" name="input" action="" method="post">
|
|
||||||
<div class="form-group">
|
|
||||||
<label class="icon icon-connexion" for="server"><span class="element-invisible"><?php echo $locale['server_link']; ?></span></label>
|
|
||||||
<input id="server" type="text" name="server" placeholder="<?php echo $locale['server_link']; ?>" class="form-text" autofocus required>
|
|
||||||
</div>
|
|
||||||
<input type="submit" value="<?php echo str_replace("{app_name}", $app_name, $locale['install_button']); ?> (community)" class="btn classic-btn large-btn">
|
|
||||||
</form>
|
|
||||||
|
|
||||||
<?php } ?>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
// The app is neither official, nor community
|
|
||||||
else {
|
else {
|
||||||
?>
|
?>
|
||||||
<div class="wrapper messages danger">
|
<div class="wrapper messages danger">
|
||||||
|
|
|
@ -2,9 +2,6 @@
|
||||||
"title": "Install {app_name} with YunoHost",
|
"title": "Install {app_name} with YunoHost",
|
||||||
"server_link": "Link to your YunoHost server",
|
"server_link": "Link to your YunoHost server",
|
||||||
"install_button": "Install {app_name}",
|
"install_button": "Install {app_name}",
|
||||||
"community_warning": "<strong>WARNING</strong>: {app_name} is <strong>NOT officially supported</strong> by the YunoHost team yet. Install it <strong>at your own risk</strong>. The community maintainer has described this app to be in a {app_state} state.",
|
|
||||||
"community_instructions": "Copy the following link. You will then be redirected to your server apps installation page in which you will need to paste this link.",
|
|
||||||
"community_redirect": "Go to your server",
|
|
||||||
"app_notfound": "This application is neither officially nor community maintained.",
|
"app_notfound": "This application is neither officially nor community maintained.",
|
||||||
"working": "working",
|
"working": "working",
|
||||||
"inprogress": "in progress",
|
"inprogress": "in progress",
|
||||||
|
|
|
@ -2,9 +2,6 @@
|
||||||
"title": "Installer {app_name} avec YunoHost",
|
"title": "Installer {app_name} avec YunoHost",
|
||||||
"server_link": "Lien vers votre serveur YunoHost",
|
"server_link": "Lien vers votre serveur YunoHost",
|
||||||
"install_button": "Installer {app_name}",
|
"install_button": "Installer {app_name}",
|
||||||
"community_warning": "<strong>ATTENTION</strong> : {app_name} <strong>N'EST PAS officiellement prise en charge</strong> pour le moment par l'équipe YunoHost. Installez cette application <strong>à vos risques et périls</strong>. Le mainteneur de cette application la décrit comme étant dans un état {app_state}.",
|
|
||||||
"community_instructions": "Merci de copier le lien suivant. Vous serez ensuite redirigé vers la page d'installation d'applications de votre serveur dans laquelle vous devrez coller ce lien.",
|
|
||||||
"community_redirect": "Accéder au serveur",
|
|
||||||
"app_notfound": "Cette application n'est maintenue ni officiellemment, ni par la communauté.",
|
"app_notfound": "Cette application n'est maintenue ni officiellemment, ni par la communauté.",
|
||||||
"working": "fonctionnel",
|
"working": "fonctionnel",
|
||||||
"inprogress": "en cours de développement",
|
"inprogress": "en cours de développement",
|
||||||
|
|
Loading…
Reference in a new issue