Canviar el preview de la pàgina de tema
This commit is contained in:
@@ -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
Reference in New Issue
Block a user