From 52879ede31c92306da882bd9e922ddbd2b3d4128 Mon Sep 17 00:00:00 2001 From: Lars Gebhardt-Kusche Date: Thu, 25 Jun 2026 01:08:50 +0200 Subject: [PATCH] adasd --- docs/CONTENT.md | 2 + docs/README.md | 3 +- docs/WEITERENTWICKLUNG.md | 1 + public/api/system/deploy-status/index.php | 34 +--------------- src/App/App.php | 4 +- src/App/AppPaths.php | 10 +++++ system/addons/README.md | 19 +++++++++ .../GiteaDeployStatusService.php | 2 +- system/addons/gitea-deploy-status/README.md | 21 ++++++++++ system/addons/gitea-deploy-status/api.php | 40 +++++++++++++++++++ system/apps/README.md | 2 + 11 files changed, 103 insertions(+), 35 deletions(-) create mode 100644 system/addons/README.md rename {src/App => system/addons/gitea-deploy-status}/GiteaDeployStatusService.php (99%) create mode 100644 system/addons/gitea-deploy-status/README.md create mode 100644 system/addons/gitea-deploy-status/api.php diff --git a/docs/CONTENT.md b/docs/CONTENT.md index 2d0179f3..e2ecd613 100644 --- a/docs/CONTENT.md +++ b/docs/CONTENT.md @@ -106,9 +106,11 @@ Aus [README.md](/home/lars/Schreibtisch/Projekte/desktop.kusche.berlin/docs/READ - `custom/apps/` bleibt Zielort fuer installierbare Fach-Apps - `system/apps/` bleibt Zielort fuer System-Tools - `system/shell/` bleibt Zielort fuer globale Shell-Werkzeuge und shell-nahe Desktop-Helfer +- `system/addons/` bleibt Zielort fuer optionale System-Erweiterungen und Integrationen - `temp/nexus-module-import/` ist Rohbasis fuer importierte Nexus-Module - Keycloak bleibt das Auth-System - das globale Desktop-Debug ist als Shell-Werkzeug unter `system/shell/desktop-debug/` definiert +- der Gitea-Deploy-Status liegt als optionales Addon unter `system/addons/gitea-deploy-status/` ### Module diff --git a/docs/README.md b/docs/README.md index 771217dd..085114d7 100644 --- a/docs/README.md +++ b/docs/README.md @@ -28,6 +28,7 @@ Zentraler Dokumentationsindex fuer das Projekt. - `custom/apps/` Zielort fuer installierbare Fach-Apps - `system/apps/` Zielort fuer nicht installierbare System-Tools - `system/shell/` Zielort fuer globale Shell-Werkzeuge und shell-nahe Desktop-Helfer +- `system/addons/` Zielort fuer optionale System-Erweiterungen und Integrationen - `temp/nexus-module-import/` Rohbasis fuer importierte Nexus-Module - `config/gitea.php` Basis fuer serverseitige Gitea-API-Anbindung wie Deploy-Status im Tray @@ -61,7 +62,7 @@ Aktuell wichtig: - die API bleibt vorerst auf demselben Host und wird nicht auf `api.desktop.kusche.berlin` ausgelagert - das gemeinsame Admin-Debug-Widget neben der Uhr ist der Standard fuer Live-Debugging in Desktop und Native-Apps - der Waehrungs-Checker stellt zusaetzlich ein Desktop-Widget fuer manuelle Kursaktualisierung bereit -- der Gitea-Deploy-Status kann als Tray-Status unten rechts serverseitig ueber `config/gitea.php` angebunden werden +- der Gitea-Deploy-Status liegt als optionales Addon unter `system/addons/gitea-deploy-status/` und wird serverseitig ueber `config/gitea.php` angebunden - das Oeffnen des Waehrungs-Checkers darf keinen externen Kursabruf ausloesen; Refreshes laufen nur nach Altersregel oder mit `force` - `Systemtools` und installierbare `Module` werden getrennt behandelt; Systemtools sind nicht Teil der Benutzer-Installationsauswahl - das `Cron Tool` ist als globales Systemtool vorhanden und sammelt Modul-Cronjobs automatisch ueber Manifest-Metadaten diff --git a/docs/WEITERENTWICKLUNG.md b/docs/WEITERENTWICKLUNG.md index 180a19e7..37c15a81 100644 --- a/docs/WEITERENTWICKLUNG.md +++ b/docs/WEITERENTWICKLUNG.md @@ -59,6 +59,7 @@ Verbindlich ist: - `custom/apps//` bleibt Ort fuer installierbare Fach-Apps - `system/apps//` bleibt Ort fuer System-Tools und nicht installierbare App-Quellen - `system/shell//` bleibt Ort fuer globale Shell-Werkzeuge und shell-nahe Desktop-Helfer +- `system/addons//` bleibt Ort fuer optionale System-Erweiterungen und Integrationen - globale Desktop-Mechaniken liegen im gemeinsamen Kern - globale Modul-Helfer duerfen im gemeinsamen Kern liegen, Fachlogik aber nicht - globale Debug-Steuerung fuer Admins liegt im Desktop-Core; Aktivierung erfolgt ueber das gemeinsame Debug-Widget neben der Uhr diff --git a/public/api/system/deploy-status/index.php b/public/api/system/deploy-status/index.php index 55fe5404..dc824c04 100644 --- a/public/api/system/deploy-status/index.php +++ b/public/api/system/deploy-status/index.php @@ -4,36 +4,6 @@ declare(strict_types=1); require_once dirname(__DIR__, 4) . '/src/App/bootstrap.php'; -use App\ConfigLoader; -use App\GiteaDeployStatusService; +use App\AppPaths; -session_start(); - -$authUser = is_array($_SESSION['desktop_auth']['user'] ?? null) ? $_SESSION['desktop_auth']['user'] : []; -$groups = array_values(array_map('strval', (array) ($authUser['groups'] ?? []))); -$isAdmin = in_array('administrators', $groups, true); - -$projectRoot = dirname(__DIR__, 4); -$service = new GiteaDeployStatusService(ConfigLoader::load($projectRoot, 'gitea')); - -if (!$service->shouldShowInTray($isAdmin)) { - respond([ - 'error' => 'forbidden', - 'message' => 'Kein Zugriff auf den Gitea-Deploy-Status.', - ], 403); -} - -respond([ - 'data' => $service->status(), -]); - -/** - * @param array $payload - */ -function respond(array $payload, int $statusCode = 200): never -{ - http_response_code($statusCode); - header('Content-Type: application/json; charset=utf-8'); - echo json_encode($payload, JSON_THROW_ON_ERROR | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); - exit; -} +require AppPaths::systemAddonPath(dirname(__DIR__, 4), 'gitea-deploy-status') . '/api.php'; diff --git a/src/App/App.php b/src/App/App.php index 05a79ba3..ac5e3d5b 100644 --- a/src/App/App.php +++ b/src/App/App.php @@ -26,13 +26,15 @@ final class App */ public function desktopPayload(): array { + require_once AppPaths::systemAddonPath($this->projectRoot, 'gitea-deploy-status') . '/GiteaDeployStatusService.php'; + $keycloakConfig = ConfigLoader::load($this->projectRoot, 'keycloak'); $auth = new KeycloakAuth($keycloakConfig); $moduleRegistry = new ModuleRegistry(AppPaths::customAppsRoot($this->projectRoot)); $registry = new AppRegistry($this->projectRoot . '/config/apps.php', $moduleRegistry->desktopApps()); $widgetRegistry = new WidgetRegistry($this->projectRoot . '/config/widgets.php', $moduleRegistry->widgets()); $shellRegistry = new ShellAppRegistry(AppPaths::systemShellRoot($this->projectRoot)); - $giteaStatus = new GiteaDeployStatusService(ConfigLoader::load($this->projectRoot, 'gitea')); + $giteaStatus = new \SystemAddons\GiteaDeployStatus\GiteaDeployStatusService(ConfigLoader::load($this->projectRoot, 'gitea')); $skins = SkinResolver::all(); $isAuthenticated = isset($_SESSION['desktop_auth']) && is_array($_SESSION['desktop_auth']); $authUser = $isAuthenticated && is_array($_SESSION['desktop_auth']['user'] ?? null) diff --git a/src/App/AppPaths.php b/src/App/AppPaths.php index 54b4880e..d979e874 100644 --- a/src/App/AppPaths.php +++ b/src/App/AppPaths.php @@ -35,4 +35,14 @@ final class AppPaths { return self::systemShellRoot($projectRoot) . '/' . trim($shellName, '/'); } + + public static function systemAddonsRoot(string $projectRoot): string + { + return rtrim($projectRoot, '/') . '/system/addons'; + } + + public static function systemAddonPath(string $projectRoot, string $addonName): string + { + return self::systemAddonsRoot($projectRoot) . '/' . trim($addonName, '/'); + } } diff --git a/system/addons/README.md b/system/addons/README.md new file mode 100644 index 00000000..86b2a842 --- /dev/null +++ b/system/addons/README.md @@ -0,0 +1,19 @@ +# System Addons + +Optionale System-Erweiterungen und Integrationen liegen in diesem Projekt unter `system/addons//`. + +Ziel der Struktur: + +- optionale Systemfunktionen klar von Kern-Systemtools unter `system/apps/` trennen +- Integrationen wie externe Statusanzeigen, Monitoring oder Zusatz-Widgets als sichtbare Einheiten ablegen +- Backend-Logik, API-Shims und Dokumentation eines Addons an einem Ort halten + +Typische Bestandteile eines Addons: + +- `README.md` fuer Zweck und Konfiguration +- `Service.php` oder weitere PHP-Dateien fuer die Fachlogik +- `api.php` oder ein angebundener Web-Shim fuer API-Zugriffe + +Aktuelles Beispiel: + +- `gitea-deploy-status` diff --git a/src/App/GiteaDeployStatusService.php b/system/addons/gitea-deploy-status/GiteaDeployStatusService.php similarity index 99% rename from src/App/GiteaDeployStatusService.php rename to system/addons/gitea-deploy-status/GiteaDeployStatusService.php index f76cd3ce..4652a683 100644 --- a/src/App/GiteaDeployStatusService.php +++ b/system/addons/gitea-deploy-status/GiteaDeployStatusService.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App; +namespace SystemAddons\GiteaDeployStatus; final class GiteaDeployStatusService { diff --git a/system/addons/gitea-deploy-status/README.md b/system/addons/gitea-deploy-status/README.md new file mode 100644 index 00000000..21f2e0f6 --- /dev/null +++ b/system/addons/gitea-deploy-status/README.md @@ -0,0 +1,21 @@ +# Gitea Deploy Status + +Optionales System-Addon fuer den Deploy-Status im Tray des Desktop. + +Funktionen: + +- fragt den Gitea-Actions-Status serverseitig ab +- zeigt unten rechts im Tray einen Punkt fuer den Deploy-Status +- `gruen` wenn kein Deploy laeuft +- `gelb` wenn ein Deploy laeuft +- `orange` bei Fehler oder fehlender Konfiguration + +Konfiguration: + +- Basiswerte in `config/gitea.php` +- Umgebungswerte und Token in `config/staging/gitea.php` bzw. `config/prod/gitea.php` + +Web-Endpunkt: + +- oeffentlicher Shim: `/api/system/deploy-status/index.php` +- interne Addon-Logik: `system/addons/gitea-deploy-status/api.php` diff --git a/system/addons/gitea-deploy-status/api.php b/system/addons/gitea-deploy-status/api.php new file mode 100644 index 00000000..e2614c7a --- /dev/null +++ b/system/addons/gitea-deploy-status/api.php @@ -0,0 +1,40 @@ +shouldShowInTray($isAdmin)) { + respond([ + 'error' => 'forbidden', + 'message' => 'Kein Zugriff auf den Gitea-Deploy-Status.', + ], 403); +} + +respond([ + 'data' => $service->status(), +]); + +/** + * @param array $payload + */ +function respond(array $payload, int $statusCode = 200): never +{ + http_response_code($statusCode); + header('Content-Type: application/json; charset=utf-8'); + echo json_encode($payload, JSON_THROW_ON_ERROR | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); + exit; +} diff --git a/system/apps/README.md b/system/apps/README.md index a595b6c1..75958bcd 100644 --- a/system/apps/README.md +++ b/system/apps/README.md @@ -25,3 +25,5 @@ Verwandte, aber getrennte Struktur: - globale Shell-Werkzeuge und shell-nahe Desktop-Helfer liegen unter `system/shell/` - Beispiel: `system/shell/desktop-debug/` +- optionale Integrationen und System-Erweiterungen liegen unter `system/addons/` +- Beispiel: `system/addons/gitea-deploy-status/`