fix(wiki): содержимое страниц через content_base64
wiki-sync / Publish docs/wiki to Gitea wiki (push) Successful in 24s

Gitea игнорирует поле content в POST/PATCH wiki API — страницы создавались
пустыми (0 байт, видно только по git clone вики-репозитория). Теперь содержимое
передаётся в content_base64; проверено — 9 страниц с реальным текстом, CI-прогон
и публикация зелёные. Питфолл записан в reference-wiki-publishing.
This commit is contained in:
2026-11-01 20:10:28 +00:00
parent b60759d38a
commit 1fa6aef6ab
2 changed files with 21 additions and 2 deletions
+13 -2
View File
@@ -29,6 +29,7 @@ wiki_publish.py — публикация docs/wiki в нативную вики
from __future__ import annotations
import argparse
import base64
import json
import os
import re
@@ -97,6 +98,14 @@ def api(method: str, endpoint: str, payload: dict | None = None) -> tuple[int, d
return exc.code, {"error": exc.read().decode("utf-8")[:200]}
def _b64(text: str) -> str:
"""Gitea wiki API принимает содержимое только в content_base64.
Поле `content` молча игнорируется — страница создаётся пустой (0 байт).
"""
return base64.b64encode(text.encode("utf-8")).decode("ascii")
def existing_pages() -> dict[str, str]:
"""title → sub_url для уже созданных страниц.
@@ -144,11 +153,13 @@ def main() -> int:
if name in pages:
target = urllib.parse.quote(pages[name], safe="")
status, body = api("PATCH", f"/page/{target}",
{"title": name, "content": content, "message": message})
{"title": name, "content_base64": _b64(content),
"message": message})
action = "обновлена"
else:
status, body = api("POST", "/new",
{"title": name, "content": content, "message": message})
{"title": name, "content_base64": _b64(content),
"message": message})
action = "создана"
if status in (200, 201):