From 42746581b1a91a1deba320870f41ab7484ed80c9 Mon Sep 17 00:00:00 2001 From: Hermes Agent Date: Mon, 13 Jul 2026 23:48:43 +0200 Subject: [PATCH] fix: _publish_to_joomla nutzt flaches API-Format (wie _handle_publish) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - JSON:API-Wrapper entfernt (Joomla 5/6 akzeptiert den nicht bei POST) - articletext → introtext + fulltext (Read-More-Split) - Metadaten (metadesc, metakey) werden extrahiert - Kategorie/State/Featured-Logik identisch zu _handle_publish - Behebt den 400-Fehler 'Field required: Title / Category' --- article_server.py | 76 ++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 68 insertions(+), 8 deletions(-) diff --git a/article_server.py b/article_server.py index e936df6..e22d6b3 100644 --- a/article_server.py +++ b/article_server.py @@ -2828,21 +2828,81 @@ def _resize_image(data, output_path): img.save(output_path, "JPEG", quality=85, dpi=(72, 72)) -def _publish_to_joomla(filepath, rubrik_id): - """Artikel via Joomla-API veroffentlichen.""" +def _publish_to_joomla(filepath, rubrik_id, allow_live=False): + """Artikel via Joomla-API veroffentlichen. + + Nutzt das gleiche flache Payload-Format wie _handle_publish() + (Joomla 5/6 API akzeptiert NICHT den JSON:API-Wrapper bei POST). + """ import requests with open(filepath, encoding="utf-8") as f: html = f.read() + + # ── Metadaten extrahieren ── title_match = re.search(r"(.*?)", html) title = title_match.group(1) if title_match else "Unbekannt" + + alias = re.sub(r'[^a-z0-9]+', '-', title.lower().strip())[:100] + body_match = re.search(r"
(.*?)
", html, re.DOTALL) - body = body_match.group(1).strip() if body_match else html - payload = {"data": {"type": "articles", "attributes": { - "title": title, "alias": title.lower().replace(" ", "-")[:100], - "articletext": body, "state": 1, "catid": rubrik_id, "language": "de-DE" - }}} + article_body = body_match.group(1).strip() if body_match else html + + # ── Interne Marker entfernen (wie _handle_publish) ── + article_body = re.sub(r']*>.*?\s*', '', article_body, flags=re.DOTALL) + article_body = re.sub(r']*>.*?

\s*', '', article_body, flags=re.DOTALL) + + # ── Read-More-Split für introtext/fulltext ── + introtext = "" + fulltext = article_body.strip() + sr_match = re.search(r'', article_body, re.IGNORECASE) + if sr_match: + split_idx = sr_match.start() + introtext = article_body[:split_idx].strip() + fulltext = article_body[split_idx:].strip() + fulltext = re.sub(r'^\s*', '', fulltext) + + # ── Meta-Description & Keywords ── + meta_desc_match = re.search(r'