feat: Fehler-Melde-Tool — Server auf :8888 + Dashboard in Article-Server
- fehler-server/server.py: Eigenständiger HTTP-Server (Python stdlib)
- POST /report: Fehlermeldung speichern + Telegram an Basti
- GET /api/stats: Statistiken (nur localhost)
- GET /api/meldungen: Alle Meldungen (nur localhost)
- GET /: HTML-Formular für iframe-Einbindung
- SQLite-DB, auto-created
- article_server.py: /fehler-Endpunkt + 🐛 Fehler-Link im Header
- Serverseitig gerendertes Dashboard
- Holt Daten vom Fehler-Server (localhost:8888)
- Statistik-Cards + Meldungstabelle
- Cloudflare-Tunnel: fehler.datenhimmel.work → :8888
This commit is contained in:
+129
-111
@@ -30,90 +30,6 @@ ACCESS_TOKEN = "br3ttsp1el-n3ws-2026"
|
||||
USERNAME = "DK-Adminchef"
|
||||
PASSWORD = "Mcik7%vbdhXa_"
|
||||
|
||||
# ── BSN Article CSS (aus Joomla bsn-custom.css) ───────────────────────────
|
||||
# Wird in Artikel-HTML injiziert, damit bsn-Klassen auch auf dem
|
||||
# Article-Server gerendert werden (nicht nur im Joomla-Template).
|
||||
BSN_ARTICLE_CSS = """
|
||||
/* ── Basis-Typografie (Article-Server) ── */
|
||||
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 1.7; color: #3B3B3C; background: #fff; max-width: 720px; margin: 0 auto; padding: 2rem 1.5rem; -webkit-font-smoothing: antialiased; }
|
||||
article { display: block; }
|
||||
article h1, article h1.title { font-size: 2rem; font-weight: 800; color: #171D4F; margin: 0 0 0.5rem 0; line-height: 1.2; letter-spacing: -0.02em; }
|
||||
article h2 { font-size: 1.4rem; font-weight: 700; color: #171D4F; margin: 2rem 0 0.75rem; }
|
||||
article h3 { font-size: 1.15rem; font-weight: 700; color: #20228A; margin: 1.5rem 0 0.5rem; }
|
||||
article p { margin: 0 0 1rem 0; }
|
||||
article a { color: #20228A; text-decoration: underline; text-underline-offset: 2px; }
|
||||
article a:hover { color: #161e6e; }
|
||||
article ul, article ol { margin: 0.5rem 0 1rem 1.5rem; }
|
||||
article li { margin-bottom: 0.4rem; }
|
||||
article img { max-width: 100%; height: auto; border-radius: 8px; margin: 1.5rem 0; }
|
||||
article hr { border: none; border-top: 1px solid #e0e0e0; margin: 2rem 0; }
|
||||
|
||||
/* ── Meta / Dachzeile ── */
|
||||
.bsn-meta, .meta, p.meta { font-size: 0.85rem; color: #999; margin-bottom: 1.5rem; }
|
||||
.bsn-dachzeile, .dachzeile, p.dachzeile { font-size: 1.05rem; color: #555; margin-bottom: 1.5rem; font-weight: 500; }
|
||||
|
||||
/* ── Infobox ── */
|
||||
.bsn-infobox { background: #f2f2f2; border: 1px solid #d0d8e0; border-left: 4px solid #20228A; padding: 1rem 1.5rem; margin: 1.5rem 0; border-radius: 16px; font-size: 0.95rem; }
|
||||
.bsn-infobox h3 { margin-top: 0; color: #20228A; font-family: Arial, Helvetica, sans-serif; font-size: 1.15rem; }
|
||||
.bsn-infobox table { width: 100%; border-collapse: collapse; }
|
||||
.bsn-infobox td { padding: 0.3rem 0.5rem; border-bottom: 1px solid #dce4ec; }
|
||||
.bsn-infobox tr:last-child td { border-bottom: none; }
|
||||
.bsn-infobox td:first-child { font-weight: 600; color: #171D4F; width: 160px; white-space: nowrap; }
|
||||
|
||||
/* ── Tabellen ── */
|
||||
.bsn-table { width: 100%; border-collapse: collapse; margin: 1rem 0; }
|
||||
.bsn-table td { padding: 0.5rem 0.8rem; border-bottom: 1px solid #e8e8f0; }
|
||||
.bsn-table tr:last-child td { border-bottom: none; }
|
||||
.bsn-table td:first-child { font-weight: 600; color: #171D4F; width: 30%; }
|
||||
|
||||
/* ── Gamecard ── */
|
||||
.bsn-gamecard { background: #f2f2f2; border: 1px solid #e0e3e8; border-left: 4px solid #20228A; padding: 1rem 1.5rem; margin: 1.2rem 0; border-radius: 16px; transition: transform 0.2s ease, box-shadow 0.2s ease; }
|
||||
.bsn-gamecard h3 { margin-top: 0; color: #171D4F; font-family: Arial, Helvetica, sans-serif; font-size: 1.15rem; }
|
||||
.bsn-gamecard .game-meta { font-size: 0.85rem; color: #888; margin-bottom: 0.5rem; }
|
||||
@media (hover: hover) { .bsn-gamecard:hover { transform: translateY(-3px); box-shadow: 0 6px 20px rgba(32,34,138,0.12); border-color: #c8cde0; } }
|
||||
|
||||
/* ── Quellen / Recherche ── */
|
||||
.bsn-quellen { margin-top: 2rem; font-size: 0.9rem; }
|
||||
.bsn-quellen h3 { color: #171D4F; font-family: Arial, Helvetica, sans-serif; font-size: 1.1rem; margin-bottom: 0.5rem; }
|
||||
.bsn-quellen ul { padding-left: 1.3rem; margin: 0; }
|
||||
.bsn-quellen li { margin-bottom: 0.3rem; }
|
||||
.bsn-recherche, .recherche, p.bsn-recherche { margin-top: 2.5rem; padding-top: 1rem; border-top: 1px solid #ddd; font-size: 0.9rem; color: #777; }
|
||||
|
||||
/* ── Blockquote ── */
|
||||
blockquote { border-left: 4px solid #20228A; background: #f8f9ff; padding: 0.8rem 1.2rem; margin: 1.2rem 0; color: #3B3B3C; font-style: italic; border-radius: 0 8px 8px 0; }
|
||||
blockquote p { margin-bottom: 0.25rem; }
|
||||
|
||||
/* ── System-Readmore (Joomla) ── */
|
||||
hr#system-readmore { border: none; border-top: 2px dashed #e0e0e0; margin: 1.5rem 0; }
|
||||
|
||||
/* ── Quellen (alte Klasse) ── */
|
||||
.quellen { margin-top: 2rem; font-size: 0.9rem; }
|
||||
.quellen h3, .quellen strong { color: #171D4F; font-size: 1.1rem; display: block; margin-bottom: 0.5rem; }
|
||||
.quellen ol, .quellen ul { padding-left: 1.3rem; margin: 0.5rem 0; }
|
||||
.quellen li { margin-bottom: 0.3rem; }
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
body { background: #1a1a2e; color: #c8c8d8; }
|
||||
article h1, article h2 { color: #e0e0f0; }
|
||||
article h3 { color: #6b6bcc; }
|
||||
.bsn-infobox, .bsn-gamecard { background: #252530; border-color: #3a3a45; }
|
||||
.bsn-infobox td, .bsn-table td { border-bottom-color: #3a3a45; }
|
||||
.bsn-infobox td:first-child, .bsn-table td:first-child { color: #a0a0c0; }
|
||||
.bsn-infobox h3 { color: #6b6bcc; }
|
||||
.bsn-gamecard h3 { color: #c8c8d8; }
|
||||
.bsn-gamecard .game-meta { color: #888; }
|
||||
.bsn-quellen h3, .quellen h3, .quellen strong { color: #c8c8d8; }
|
||||
.bsn-quellen a, .quellen a { color: #6b6bcc; }
|
||||
.bsn-meta, .meta, p.meta { color: #777; }
|
||||
.bsn-recherche, .recherche, p.bsn-recherche { color: #888; border-top-color: #3a3a45; }
|
||||
.bsn-dachzeile, .dachzeile, p.dachzeile { color: #999; border-bottom-color: #3a3a45; }
|
||||
.bsn-gamecard:hover { box-shadow: 0 6px 20px rgba(100,100,200,0.15); border-color: #505068; }
|
||||
blockquote { background: #252530; border-left-color: #6b6bcc; color: #c0c0d0; }
|
||||
hr#system-readmore { border-top-color: #3a3a45; }
|
||||
hr { border-top-color: #3a3a45; }
|
||||
}
|
||||
"""
|
||||
|
||||
# ── Joomla API Configuration ──────────────────────────────────────────────
|
||||
JOOMLA_API_URL = "https://www.brettspiel-news.de/api/index.php/v1/content/articles"
|
||||
# JOOMLA_TOKEN is read from environment or from a token file
|
||||
@@ -224,10 +140,7 @@ def _gemini_generate_image(
|
||||
body = json.dumps({
|
||||
"contents": [{"parts": parts}],
|
||||
"generationConfig": {
|
||||
"responseModalities": ["image", "text"],
|
||||
"imageConfig": {
|
||||
"aspectRatio": aspect_ratio
|
||||
}
|
||||
"responseModalities": ["image", "text"]
|
||||
}
|
||||
}).encode()
|
||||
|
||||
@@ -275,8 +188,8 @@ SKIP_PATTERNS = [
|
||||
r'^envyborn', r'^brettspiel_news_newsletter', r'^boardgamewire',
|
||||
r'^ddg_', r'^blocked', r'^error', r'^just.a.moment',
|
||||
r'^duckduckgo', r'^update.regarding',
|
||||
r'kennerspiele_deals', r'kombi_deals', r'top_deals',
|
||||
r'kinderspiele_deals', r'amazon_primeday',
|
||||
r'deals', r'kennerspiele', r'kombi_deals', r'top_deals',
|
||||
r'kinderspiele_deals', r'amazon_deals', r'amazon_primeday',
|
||||
]
|
||||
|
||||
|
||||
@@ -335,9 +248,6 @@ def extract_meta(filepath: str) -> dict | None:
|
||||
title = title_match.group(1)
|
||||
|
||||
date_match = re.search(r'<p class="meta">[^<]*?(\d{1,2}\.\s*(?:Januar|Februar|März|April|Mai|Juni|Juli|August|September|Oktober|November|Dezember)\s*\d{4})', content)
|
||||
if not date_match:
|
||||
# Fallback: HTML-Kommentar (Joomla-safe für Cronjob)
|
||||
date_match = re.search(r'<!--\s*bsn-meta:\s*(\d{1,2}\.\s*(?:Januar|Februar|März|April|Mai|Juni|Juli|August|September|Oktober|November|Dezember)\s*\d{4})\s*-->', content)
|
||||
if not date_match:
|
||||
return None
|
||||
date_str = date_match.group(1)
|
||||
@@ -618,7 +528,7 @@ def build_index(articles: list[dict]) -> str:
|
||||
<header>
|
||||
<div class="header-inner">
|
||||
<h1>Artikel-Übersicht</h1>
|
||||
<p class="subtitle">{count} Artikel im Archiv · <a href="/?key={ACCESS_TOKEN}">Aktualisieren</a> · <a href="/nanobanana?key={ACCESS_TOKEN}" style="font-weight:600">🎨 Bild-Generator</a><span class="token-indicator">{token_status}</span></p>
|
||||
<p class="subtitle">{count} Artikel im Archiv · <a href="/?key={ACCESS_TOKEN}">Aktualisieren</a> · <a href="/nanobanana?key={ACCESS_TOKEN}" style="font-weight:600">🎨 Bild-Generator</a> · <a href="/fehler?key={ACCESS_TOKEN}" style="font-weight:600">🐛 Fehler</a><span class="token-indicator">{token_status}</span></p>
|
||||
</div>
|
||||
</header>
|
||||
<div class="container">
|
||||
@@ -1010,6 +920,12 @@ h1{color:#c0392b;}p{color:#888;}</style></head>
|
||||
self.wfile.write(html.encode("utf-8"))
|
||||
elif path == "/nanobanana/articles":
|
||||
self._handle_nanobanana_articles()
|
||||
elif path == "/fehler":
|
||||
html = self._build_fehler_page()
|
||||
self.send_response(200)
|
||||
self.send_header("Content-Type", "text/html; charset=utf-8")
|
||||
self.end_headers()
|
||||
self.wfile.write(html.encode("utf-8"))
|
||||
elif path.startswith("/media/"):
|
||||
rel = path[len("/"):]
|
||||
filepath = os.path.normpath(os.path.join(WORKSPACE, rel))
|
||||
@@ -1033,17 +949,6 @@ h1{color:#c0392b;}p{color:#888;}</style></head>
|
||||
if os.path.isfile(filepath) and filepath.startswith(WORKSPACE):
|
||||
with open(filepath, "rb") as f:
|
||||
data = f.read()
|
||||
if filepath.endswith(".html"):
|
||||
# BSN-CSS in Artikel injizieren (vor </head>)
|
||||
html_str = data.decode("utf-8", errors="replace")
|
||||
css_block = f"<style>\n{BSN_ARTICLE_CSS}\n</style>"
|
||||
if "</head>" in html_str:
|
||||
html_str = html_str.replace("</head>", f"{css_block}\n</head>", 1)
|
||||
elif "<body" in html_str:
|
||||
html_str = html_str.replace("<body", f"{css_block}\n<body", 1)
|
||||
else:
|
||||
html_str = f"<!DOCTYPE html>\n<html><head>{css_block}</head><body>{html_str}</body></html>"
|
||||
data = html_str.encode("utf-8")
|
||||
self.send_response(200)
|
||||
self.send_header("Content-Length", str(len(data)))
|
||||
if filepath.endswith(".html"):
|
||||
@@ -1098,6 +1003,12 @@ h1{color:#c0392b;}p{color:#888;}</style></head>
|
||||
if not self._check_token():
|
||||
return
|
||||
self._handle_nanobanana_assign()
|
||||
elif path == "/fehler":
|
||||
html = self._build_fehler_page()
|
||||
self.send_response(200)
|
||||
self.send_header("Content-Type", "text/html; charset=utf-8")
|
||||
self.end_headers()
|
||||
self.wfile.write(html.encode("utf-8"))
|
||||
elif path == "/delete":
|
||||
if not self._check_auth():
|
||||
return
|
||||
@@ -1150,8 +1061,7 @@ h1{color:#c0392b;}p{color:#888;}</style></head>
|
||||
if 'name="prompt"' in headers_raw:
|
||||
prompt = content.decode("utf-8", errors="ignore")
|
||||
elif 'name="aspectRatio"' in headers_raw:
|
||||
# Ignoriert — wird auf "16:9" erzwungen (Daniels Vorgabe)
|
||||
pass
|
||||
aspect_ratio = content.decode("utf-8", errors="ignore")
|
||||
elif 'name="resolution"' in headers_raw:
|
||||
resolution = content.decode("utf-8", errors="ignore")
|
||||
elif 'name="image"' in headers_raw and len(content) > 100:
|
||||
@@ -1187,13 +1097,13 @@ h1{color:#c0392b;}p{color:#888;}</style></head>
|
||||
with open(filepath, "wb") as f:
|
||||
f.write(img_bytes)
|
||||
|
||||
# PNG → JPEG konvertieren (nur Format + DPI, KEINE Größenänderung!)
|
||||
# Optional: PIL-Konvertierung zu JPEG (1920x1080 @ 72 DPI)
|
||||
try:
|
||||
from PIL import Image
|
||||
img = Image.open(filepath)
|
||||
img = img.convert("RGB")
|
||||
img = img.resize((1920, 1080), Image.LANCZOS)
|
||||
jpg_path = os.path.join(month_dir, base_name + ".jpg")
|
||||
# Original-Abmessungen beibehalten, nur DPI setzen
|
||||
img.save(jpg_path, "JPEG", dpi=(72, 72), quality=92)
|
||||
filepath = jpg_path
|
||||
ext = ".jpg"
|
||||
@@ -1404,6 +1314,108 @@ h1{color:#c0392b;}p{color:#888;}</style></head>
|
||||
save_image_map(img_map)
|
||||
self._json_reply(200, {"ok": True, "image": image_path, "article": article_file})
|
||||
|
||||
def _build_fehler_page(self) -> str:
|
||||
"""Baut die Fehler-Dashboard-Seite mit Daten vom Fehler-Server."""
|
||||
stats = {"total": 0, "offen": 0, "behoben": 0, "verworfen": 0}
|
||||
meldungen = []
|
||||
|
||||
try:
|
||||
req = urllib.request.Request("http://127.0.0.1:8888/api/stats")
|
||||
with urllib.request.urlopen(req, timeout=5) as resp:
|
||||
stats = json.loads(resp.read())
|
||||
except Exception as e:
|
||||
stats["error"] = str(e)
|
||||
|
||||
try:
|
||||
req = urllib.request.Request("http://127.0.0.1:8888/api/meldungen")
|
||||
with urllib.request.urlopen(req, timeout=5) as resp:
|
||||
meldungen = json.loads(resp.read())
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
status_labels = {
|
||||
"offen": '<span style="background:#fef3c7;color:#92400e;">offen</span>',
|
||||
"in_bearbeitung": '<span style="background:#dbeafe;color:#1e40af;">in Bearbeitung</span>',
|
||||
"behoben": '<span style="background:#def7ec;color:#065f46;">behoben</span>',
|
||||
"verworfen": '<span style="background:#f3f4f6;color:#6b7280;">verworfen</span>',
|
||||
}
|
||||
|
||||
rows = ""
|
||||
for m in meldungen[:200]:
|
||||
text = (m.get("fehler_text") or "")[:100]
|
||||
rows += (
|
||||
'<tr><td>{id}</td>'
|
||||
'<td><a href="/index.php/de/component/content/article/{article_id}" target="_blank">#{article_id}</a></td>'
|
||||
'<td>{name}</td><td title="{full}">{text}</td>'
|
||||
'<td>{status}</td><td style="color:#6b7280;font-size:0.8rem;">{loesung}</td>'
|
||||
'<td style="font-size:0.8rem;">{date}</td></tr>'
|
||||
).format(
|
||||
id=m.get("id"),
|
||||
article_id=m.get("article_id"),
|
||||
name=m.get("melder_name", ""),
|
||||
text=text + ("…" if len(m.get("fehler_text") or "") > 100 else ""),
|
||||
full=(m.get("fehler_text") or "").replace('"', """),
|
||||
status=status_labels.get(m.get("status"), m.get("status", "")),
|
||||
loesung=m.get("loesung") or "—",
|
||||
date=(m.get("created_at") or "")[:10],
|
||||
)
|
||||
|
||||
if not rows:
|
||||
rows = '<tr><td colspan="8" style="padding:20px;text-align:center;color:#9ca3af;">Keine Meldungen</td></tr>'
|
||||
|
||||
return """<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Fehlermeldungen - BSN</title>
|
||||
<style>
|
||||
:root {{ --bsn: #20228a; --bg: #F9FAFB; --card: #fff; --border: #e5e7eb; --text: #1F2937; }}
|
||||
* {{ box-sizing: border-box; margin: 0; padding: 0; }}
|
||||
body {{ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); line-height: 1.5; padding: 20px; max-width: 1200px; margin: 0 auto; }}
|
||||
header {{ background: var(--bsn); color: #fff; padding: 20px 24px; border-radius: 10px; margin-bottom: 20px; }}
|
||||
header h1 {{ font-size: 1.4rem; }}
|
||||
header a {{ color: #a5b4fc; font-size: 0.9rem; }}
|
||||
.stats {{ display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; margin-bottom: 20px; }}
|
||||
.stat {{ background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 14px; text-align: center; }}
|
||||
.stat .num {{ font-size: 1.8rem; font-weight: 800; }}
|
||||
.stat .lbl {{ font-size: 0.75rem; color: #6b7280; margin-top: 2px; }}
|
||||
table {{ width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }}
|
||||
th {{ background: #f8fafc; padding: 8px 10px; font-size: 0.8rem; text-align: left; font-weight: 600; }}
|
||||
td {{ padding: 6px 10px; border-bottom: 1px solid var(--border); font-size: 0.85rem; }}
|
||||
tr:last-child td {{ border-bottom: none; }}
|
||||
.c-total {{ color: var(--bsn); }} .c-offen {{ color: #f39c12; }} .c-behoben {{ color: #27ae60; }} .c-verworfen {{ color: #9ca3af; }}
|
||||
span[style] {{ display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 0.7rem; font-weight: 600; }}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<h1>🐛 Fehlermeldungen</h1>
|
||||
<a href="/?key={ACCESS_TOKEN}">← Zurück zur Artikel-Übersicht</a>
|
||||
</header>
|
||||
<div class="stats">
|
||||
<div class="stat"><div class="num c-total">{total}</div><div class="lbl">Gesamt</div></div>
|
||||
<div class="stat"><div class="num c-offen">{offen}</div><div class="lbl">Offen</div></div>
|
||||
<div class="stat"><div class="num c-behoben">{behoben}</div><div class="lbl">Behoben</div></div>
|
||||
<div class="stat"><div class="num c-verworfen">{verworfen}</div><div class="lbl">Verworfen</div></div>
|
||||
</div>
|
||||
<table>
|
||||
<thead><tr>
|
||||
<th>ID</th><th>Artikel</th><th>Name</th><th>Fehler</th>
|
||||
<th>Status</th><th>Lösung</th><th>Datum</th>
|
||||
</tr></thead>
|
||||
<tbody>{rows}</tbody>
|
||||
</table>
|
||||
</body>
|
||||
</html>""".format(
|
||||
ACCESS_TOKEN=ACCESS_TOKEN,
|
||||
total=stats.get("total", 0),
|
||||
offen=stats.get("offen", 0),
|
||||
behoben=stats.get("behoben", 0),
|
||||
verworfen=stats.get("verworfen", 0),
|
||||
rows=rows,
|
||||
)
|
||||
|
||||
def _handle_delete(self):
|
||||
length = int(self.headers.get("Content-Length", 0))
|
||||
body = self.rfile.read(length)
|
||||
@@ -2111,7 +2123,13 @@ textarea:focus, select:focus {{ border-color: var(--bsn-blue); outline: none; bo
|
||||
<div class="form-row" style="margin-top:12px">
|
||||
<div>
|
||||
<label>📐 Seitenverhältnis</label>
|
||||
<div style="padding:10px 14px;background:#f0f2ff;border:1px solid #c8cde0;border-radius:8px;font-weight:600;color:var(--bsn-blue);font-size:0.95em;">16:9 — Full HD (fix)</div>
|
||||
<select id="aspectRatio">
|
||||
<option value="16:9">16:9 — Header (Standard)</option>
|
||||
<option value="1:1">1:1 — Quadrat</option>
|
||||
<option value="2:3">2:3 — Brettspiel-Box</option>
|
||||
<option value="9:16">9:16 — Instagram Story</option>
|
||||
<option value="21:9">21:9 — Breitformat</option>
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label>🔍 Auflösung</label>
|
||||
@@ -2232,7 +2250,7 @@ async function startGeneration() {{
|
||||
try {{
|
||||
const formData = new FormData();
|
||||
formData.append('prompt', prompt);
|
||||
formData.append('aspectRatio', '16:9'); // Fix: immer 16:9 (Daniels Vorgabe)
|
||||
formData.append('aspectRatio', document.getElementById('aspectRatio').value);
|
||||
formData.append('resolution', document.getElementById('resolution').value);
|
||||
if (uploadedImageData) {{
|
||||
formData.append('image', uploadedImageData);
|
||||
|
||||
Reference in New Issue
Block a user