Add adminer badge handling to projects section and create check_adminer_badge script

This commit is contained in:
Fabian Schieder 2026-03-01 14:56:10 +01:00
parent 044546ad00
commit 142ae3b23f
2 changed files with 30 additions and 4 deletions

View File

@ -57,9 +57,15 @@ foreach ($serverStatusByUrl as $__u => $__svc) {
$status = null;
$statusKey = null;
// Für interne Tools (z.B. Adminer) keinen Status-Badge anzeigen
$isNoStatusBadge = false;
if (!empty($project['url']) && is_string($project['url']) && $project['url'] === '/adminer') {
$isNoStatusBadge = true;
}
// Für JS-Update: eine kanonische Status-URL bestimmen
$statusUrl = null;
if (!empty($project['url']) && is_string($project['url'])) {
if (!$isNoStatusBadge && !empty($project['url']) && is_string($project['url'])) {
if (substr($project['url'], 0, 1) === '/') {
$statusUrl = $__normalize_status_url('https://fabianschieder.com' . $project['url']);
} else {
@ -68,12 +74,12 @@ foreach ($serverStatusByUrl as $__u => $__svc) {
}
// 1) Externe absolute URL direkt matchen
if (!empty($project['url']) && isset($__serverStatusByUrlNormalized[$__normalize_status_url((string)$project['url'])])) {
if (!$isNoStatusBadge && !empty($project['url']) && isset($__serverStatusByUrlNormalized[$__normalize_status_url((string)$project['url'])])) {
$statusKey = $__normalize_status_url((string)$project['url']);
}
// 2) Interne Pfade (/git, /nextcloud) auf Domain mappen
if ($statusKey === null && !empty($project['url']) && is_string($project['url']) && substr($project['url'], 0, 1) === '/') {
if (!$isNoStatusBadge && $statusKey === null && !empty($project['url']) && is_string($project['url']) && substr($project['url'], 0, 1) === '/') {
$statusKeyCandidate = 'https://fabianschieder.com' . $project['url'];
$statusKeyCandidate = $__normalize_status_url($statusKeyCandidate);
if (isset($__serverStatusByUrlNormalized[$statusKeyCandidate])) {
@ -89,7 +95,7 @@ foreach ($serverStatusByUrl as $__u => $__svc) {
$detail = $status && !empty($status['detail']) ? (string)$status['detail'] : '';
$badgeText = null;
if ($category !== 'dienste') {
if (!$isNoStatusBadge && $category !== 'dienste') {
$badgeText = 'Unbekannt';
if ($state === 'up') $badgeText = 'Online';
elseif ($state === 'down') $badgeText = 'Offline';

View File

@ -0,0 +1,20 @@
<?php
declare(strict_types=1);
$html = file_get_contents(__DIR__ . '/_render.html');
if ($html === false) {
fwrite(STDERR, "missing _render.html\n");
exit(2);
}
echo (str_contains($html, 'href="/adminer"') ? "has_adminer\n" : "no_adminer\n");
// Find the adminer card chunk (rough)
$pos = strpos($html, 'href="/adminer"');
if ($pos === false) {
exit(0);
}
$chunk = substr($html, $pos, 800);
echo (str_contains($chunk, 'status-badge') ? "adminer_has_badge\n" : "adminer_no_badge\n");