Fix page spacing and add daily poetry with manual write testing

This commit is contained in:
Pigway
2026-10-02 09:57:42 +08:00
parent d10b07c464
commit 42ae00268b
16 changed files with 403 additions and 6 deletions
+20 -1
View File
@@ -69,7 +69,26 @@ class TemplateRenderer:
"星期日 / Sunday",
][current.weekday()],
)
if "weather" not in values:
if template_id == "daily-poetry" and not values.get("poem_lines"):
from pigway_frame_flow.providers.poetry import get_poem
try:
poem = get_poem(values["date"], values.get("poem_id"))
except ValueError:
raise FlowError(
E.INVALID_REQUEST, "Invalid poetry date or poem selection"
) from None
values.update(
poem_id=poem["id"],
poem_title=poem["title"],
poem_author=poem["author"],
poem_lines=poem["lines"],
poem_source=poem["source"],
poem_edition=poem["edition"],
)
if "weather" not in values and any(
b.get("field") in ("weather", "forecast") for b in spec["blocks"]
):
values["weather"] = self.weather.get_current()
if (
any(b.get("field") == "forecast" for b in spec["blocks"])