Canviar el preview de la pàgina de tema

This commit is contained in:
marc
2026-01-05 10:40:43 +01:00
parent 4e7a6b18d6
commit 443c1b1391
2 changed files with 17 additions and 1178 deletions

View File

@@ -21,18 +21,31 @@ from folkugat_web.utils import FnChain
router = get_router()
def _build_page_description(tema: Tema) -> str:
info_lines = []
if composer := tema.composer():
info_lines.append(f"Autor: {composer}")
if origin := tema.origin():
info_lines.append(f"Orígen: {origin}")
return "\n".join(info_lines)
@router.get("/tema/{tema_id}")
def page(request: Request, logged_in: auth.LoggedIn, tema_id: int):
tema = temes_q.get_tema_by_id(tema_id)
if not tema:
raise HTTPException(status_code=404, detail="Could not find tune")
tema = scores_service.add_scores_to_tema(tema)
tema = (
FnChain.transform(tema) |
scores_service.add_scores_to_tema |
properties_service.add_properties_to_tema
).result()
return templates.TemplateResponse(
"index.html",
{
"request": request,
"page_title": "Folkugat - Tema",
"page_description": tema.title,
"page_title": f"Folkugat - {tema.title}",
"page_description": _build_page_description(tema),
"page_card": "",
"content": f"/api/tema/{tema_id}",
"logged_in": logged_in,

File diff suppressed because one or more lines are too long