feat(manascore): add live uptime badges from status.mana.how

- generate-status-page.sh now also writes status.json alongside index.html
  Format: { updated, summary: {up, total}, services: { appName: bool } }
- nginx status.mana.how serves status.json with CORS headers (public read)
  and explicit location block to avoid rewrite to index.html
- ManaScore index page fetches status.json client-side on load and
  injects green ● LIVE / red ● DOWN badge next to each app's status chip

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Till JS 2026-03-31 18:47:55 +02:00
parent 259253e7b3
commit 08032c004b
3 changed files with 62 additions and 0 deletions

View file

@ -170,6 +170,7 @@ const statuses = [...new Set(sortedAudits.map((a) => a.data.status))];
<span class="text-muted-foreground truncate text-xs font-medium">
{data.app}
</span>
<span class="live-badge shrink-0" data-app={data.app} />
<span class="text-muted-foreground/50 text-[10px]">
{data.date.toLocaleDateString('de-DE', {
day: '2-digit',
@ -547,4 +548,25 @@ const statuses = [...new Set(sortedAudits.map((a) => a.data.status))];
// Sort select
sortSelect.addEventListener('change', applySort);
// Live uptime badges from status.mana.how/status.json
(async () => {
try {
const res = await fetch('https://status.mana.how/status.json', { cache: 'no-store' });
if (!res.ok) return;
const data = await res.json();
const services: Record<string, boolean> = data.services ?? {};
document.querySelectorAll<HTMLElement>('.live-badge').forEach((badge) => {
const app = badge.dataset.app;
if (!app || !(app in services)) return;
const up = services[app];
badge.innerHTML = up
? '<span style="color:#22c55e;font-size:9px;font-weight:600;letter-spacing:.04em">● LIVE</span>'
: '<span style="color:#ef4444;font-size:9px;font-weight:600;letter-spacing:.04em">● DOWN</span>';
});
} catch {
// status.mana.how unreachable — silently skip badges
}
})();
</script>

View file

@ -118,10 +118,22 @@ server {
add_header X-Content-Type-Options "nosniff" always;
add_header Cache-Control "no-store" always;
# Allow ManaScore page to fetch status.json
add_header Access-Control-Allow-Origin "*" always;
add_header Access-Control-Allow-Methods "GET" always;
location / {
try_files $uri /index.html;
}
# Serve status.json directly (do not rewrite to index.html)
location = /status.json {
add_header Content-Type "application/json" always;
add_header Cache-Control "no-store" always;
add_header Access-Control-Allow-Origin "*" always;
try_files $uri =404;
}
location /health {
access_log off;
return 200 "healthy\n";

View file

@ -368,3 +368,31 @@ HTMLEOF
mv "${OUTPUT}.tmp" "$OUTPUT"
echo "$(date '+%H:%M:%S') Status-Seite generiert → $OUTPUT (${total_up}/${total_all} online)"
# ── status.json für ManaScore Live-Badge ─────────────────────────────────────
JSON_OUTPUT="$(dirname "$OUTPUT")/status.json"
TIMESTAMP_ISO="$(date -u '+%Y-%m-%dT%H:%M:%SZ')"
echo "$SUCCESS_JSON" | jq \
--arg ts "$TIMESTAMP_ISO" \
--argjson total_up "$total_up" \
--argjson total_all "$total_all" \
'{
updated: $ts,
summary: { up: $total_up, total: $total_all },
services: (
.data.result | map({
key: (
.metric.instance
| ltrimstr("https://")
| if . == "mana.how" then "manacore"
else (. | rtrimstr(".mana.how") | rtrimstr("/health"))
end
),
value: (.value[1] == "1")
}) | from_entries
)
}' > "${JSON_OUTPUT}.tmp" && mv "${JSON_OUTPUT}.tmp" "$JSON_OUTPUT"
echo "$(date '+%H:%M:%S') status.json generiert → $JSON_OUTPUT"