"""Server-rendered HTML for company detail pages (SEO-friendly).""" import os from html import escape SITE_URL = os.environ.get("SITE_URL", "https://amanydv2112-suggest-orgs.hf.space").rstrip("/") SOURCE_LABELS = { "yc": "Y Combinator", "a16z": "a16z", "spc": "South Park Commons", "sequoia": "Sequoia", } def _esc(v) -> str: return escape(str(v)) if v else "" def _truncate(text: str, n: int) -> str: text = (text or "").strip() return text if len(text) <= n else text[: n - 1].rstrip() + "…" def company_path(c: dict) -> str: return f"/company/{c['source']}/{c['slug']}" def company_url(c: dict) -> str: return SITE_URL + company_path(c) # ── section builders (each returns "" when there's nothing to show) ───────── def _pills(c: dict) -> str: parts = [] label = SOURCE_LABELS.get(c.get("source"), c.get("source") or "") parts.append(f'{_esc(label)}') if c.get("batch"): parts.append(f'{_esc(c["batch"])}') if c.get("status"): parts.append(f'{_esc(c["status"])}') for ind in (c.get("industries") or [])[:3]: parts.append(f'{_esc(ind)}') for tag in (c.get("tags") or [])[:4]: parts.append(f'{_esc(tag)}') return "".join(parts) def _socials(c: dict) -> str: s = c.get("_socials") or {} links = [] if c.get("website"): links.append(f'Visit website ↗') for key, label in [("linkedin", "LinkedIn"), ("twitter", "X"), ("github", "GitHub"), ("crunchbase", "Crunchbase")]: if s.get(key): links.append(f'{label} ↗') return f'
' if links else "" def _narrative(c: dict) -> str: rows = [] for label, key in [("Problem", "_problem"), ("Solution", "_solution"), ("Who it's for", "_customer")]: if c.get(key): rows.append(f'{_esc(c[key])}
{_esc(c["long_description"])}
{_esc(f["bio"])}
' if f.get("bio") else "" cards.append( f'{_esc(one_liner)}