Restyle link cards as a uniform tile grid
Cards previously had ragged heights because summaries vary in length. Follow the community-scripts.org card pattern instead: fixed-height title and summary blocks (clamped to 2 and 3 lines with an ellipsis), a colored letter avatar derived from the domain, category and manufacturer as badges in the header, tags in a single clipped row, and domain plus added-date in a footer. The avatar color is derived locally from the domain, so no external favicon requests are made. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
14
app/main.py
14
app/main.py
@@ -1,6 +1,7 @@
|
||||
import json
|
||||
from datetime import datetime, timezone
|
||||
from pathlib import Path
|
||||
from urllib.parse import urlparse
|
||||
|
||||
from fastapi import Depends, FastAPI, Form, Request
|
||||
from fastapi.responses import HTMLResponse, RedirectResponse, Response
|
||||
@@ -36,7 +37,20 @@ def format_datum(value: datetime | None) -> str:
|
||||
return value.astimezone().strftime("%d.%m.%Y, %H:%M")
|
||||
|
||||
|
||||
def domain_of(url: str) -> str:
|
||||
"""Hostname ohne 'www.' – dient als Kürzel/Beschriftung der Karten."""
|
||||
host = urlparse(url or "").hostname or ""
|
||||
return host[4:] if host.startswith("www.") else host
|
||||
|
||||
|
||||
def avatar_hue(url: str) -> int:
|
||||
"""Stabile Farbe pro Domain, damit Karten wiedererkennbar sind."""
|
||||
return sum(ord(c) for c in domain_of(url)) % 360
|
||||
|
||||
|
||||
templates.env.filters["datum"] = format_datum
|
||||
templates.env.filters["domain"] = domain_of
|
||||
templates.env.filters["hue"] = avatar_hue
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user