feat: finish forecast rendering and account-authenticated API explorer
This commit is contained in:
@@ -71,6 +71,13 @@ class TemplateRenderer:
|
||||
)
|
||||
if "weather" not in values:
|
||||
values["weather"] = self.weather.get_current()
|
||||
if (
|
||||
any(b.get("field") == "forecast" for b in spec["blocks"])
|
||||
and "forecast" not in values
|
||||
):
|
||||
values["forecast"] = self.weather.get_forecast() or [
|
||||
"尚无天气预报 / No forecast available"
|
||||
]
|
||||
values["updated"] = current.strftime("%Y-%m-%d %H:%M")
|
||||
values["weather_attribution"] = (
|
||||
values.get("weather", {}).get("attribution", "")
|
||||
@@ -164,7 +171,15 @@ class TemplateRenderer:
|
||||
if isinstance(value, list):
|
||||
value = "\n".join(
|
||||
"• "
|
||||
+ (str(v.get("title", "")) if isinstance(v, dict) else str(v))
|
||||
+ (
|
||||
(
|
||||
f"{v.get('date', '')} · {v.get('summary', '')} · {v.get('minimum_c', '--')}–{v.get('maximum_c', '--')}°C · {v.get('rain_probability', '--')}%"
|
||||
if block.get("field") == "forecast"
|
||||
else str(v.get("title", ""))
|
||||
)
|
||||
if isinstance(v, dict)
|
||||
else str(v)
|
||||
)
|
||||
for v in value[:10]
|
||||
)
|
||||
if isinstance(value, dict):
|
||||
|
||||
Reference in New Issue
Block a user