From 636859be4b18724a6b14abe2e122b5db9aa083ce Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Tue, 28 Apr 2020 04:15:04 +0200 Subject: [PATCH] Also check state + app level, only handle working app, display a warning for app with level <= 4 --- assets/css/ynh-style.css | 2 + index.php | 83 +++++++++++++++++------------- install-with-yunohost.svg | 104 ++++++++++++++++++++++++++++++++++++++ locales/en.json | 3 +- locales/fr.json | 3 +- 5 files changed, 158 insertions(+), 37 deletions(-) create mode 100644 install-with-yunohost.svg diff --git a/assets/css/ynh-style.css b/assets/css/ynh-style.css index 6b74919..24367f0 100644 --- a/assets/css/ynh-style.css +++ b/assets/css/ynh-style.css @@ -114,11 +114,13 @@ img { /* Layout */ .overlay { padding: 2%; + padding-top: 0; } .ynh-wrapper { width: 90%; margin: 2% 5%; + margin-top: 20px; position: relative; z-index: 1; } diff --git a/index.php b/index.php index da2501f..a8c6058 100644 --- a/index.php +++ b/index.php @@ -9,28 +9,34 @@ if (!file_exists("locales/".$user_locale.".json")) { $user_locale = 'en'; } $locale=json_decode(file_get_contents("locales/".$user_locale.".json"), true); // Parse the apps list -$apps_list_json=file_get_contents("https://app.yunohost.org/apps.json"); +$apps_list_json=file_get_contents("http://app.yunohost.org/apps.json"); $apps_list=json_decode($apps_list_json, true); // Check if the app is the apps list if(array_key_exists($app, $apps_list)) { - // The app is in the apps list - $app_status = 'apps_list'; // The app is in the apps list - $app_name = $apps_list[$app]['manifest']['name']; // Saves the app name - $app_git = $apps_list[$app]['git']['url']; // Saves the git URL - $app_state = $apps_list[$app]['state']; // Saves the app state + // The app is in the apps list + $app_status = $apps_list[$app]['state']; // Saves the app state + $app_name = $apps_list[$app]['manifest']['name']; // Saves the app name + $app_git = $apps_list[$app]['git']['url']; // Saves the git URL + if (array_key_exists("level", $apps_list[$app])) { + $app_level = $apps_list[$app]['level']; + } + else { + $app_level = 0; + $app_status = null; + } } else { - // The app is not in the apps list - $app_status = null; - $app_name = ""; + // The app is not in the apps list + $app_status = null; + $app_name = ""; } // 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 == 'apps_list') { - $server = rtrim(preg_replace('#^https?://#', '', $_POST['server']),"/"); - $url = 'https://'.$server.'/yunohost/admin/#/apps/install/'.$app; - header('Location: '.$url); +if(isset($_POST['server']) AND !empty($_POST['server']) AND $app_status == 'working') { + $server = rtrim(preg_replace('#^https?://#', '', $_POST['server']),"/"); + $url = 'https://'.$server.'/yunohost/admin/#/apps/install/'.$app; + header('Location: '.$url); } ?> @@ -48,7 +54,7 @@ if(isset($_POST['server']) AND !empty($_POST['server']) AND $app_status == 'apps - + @@ -69,42 +75,49 @@ if(isset($_POST['server']) AND !empty($_POST['server']) AND $app_status == 'apps -

+

Yunohost -

+
- diff --git a/install-with-yunohost.svg b/install-with-yunohost.svg new file mode 100644 index 0000000..b087d98 --- /dev/null +++ b/install-with-yunohost.svg @@ -0,0 +1,104 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + Installwith + + + diff --git a/locales/en.json b/locales/en.json index f254ec4..9f535e4 100644 --- a/locales/en.json +++ b/locales/en.json @@ -8,5 +8,6 @@ "notworking": "not working", "noserver": "No YunoHost server yet?", "yunohost": "YunoHost is a server operating system aiming to make self-hosting accessible to everyone.", - "discover": "Discover YunoHost" + "discover": "Click here to discover YunoHost", + "app_state_warning": "WARNING: This app is bad-quality for now. Installation could maybe work, but it may lack important features like backup/restore, and/or it uses deprecated practices that may cause issues on your server. Please be careful." } diff --git a/locales/fr.json b/locales/fr.json index 2761031..eae645b 100644 --- a/locales/fr.json +++ b/locales/fr.json @@ -8,5 +8,6 @@ "notworking": "non fonctionnel", "noserver": "Pas encore de serveur YunoHost ?", "yunohost": "YunoHost est un outil qui vous permet d’installer et d’utiliser facilement votre propre serveur.", - "discover": "Découvrez YunoHost" + "discover": "Cliquez ici pour découvrir YunoHost", + "app_state_warning": "ATTENTION: Cette application est pour le moment de mauvaise qualité. L'installation va peut-être fonctionner, mais certaines fonctionnalités importantes telles que la sauvegarde/restauration peuvent être manquante, et/ou l'application ne respecte pas les bonnes pratiques ce qui peut créer des problèmes sur votre serveur. Soyez prudent." }