first commit
This commit is contained in:
commit
34ea15a54d
246 changed files with 18660 additions and 0 deletions
37
backend/app/services/share_preview.py
Normal file
37
backend/app/services/share_preview.py
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
from html import escape
|
||||
|
||||
from app.config import settings
|
||||
from app.schemas import EventEditionPublic
|
||||
|
||||
|
||||
def render_share_html(public: EventEditionPublic, slug: str) -> str:
|
||||
title = escape(public.title)
|
||||
desc = escape(
|
||||
public.meta_description
|
||||
or public.description
|
||||
or f"{public.title} — Desi Clans, Bengaluru"
|
||||
)
|
||||
page_url = f"{settings.public_site_url.rstrip('/')}/events/{slug}"
|
||||
image = public.cover_image_url or (public.media[0].url if public.media else "")
|
||||
if image and image.startswith("/"):
|
||||
image = f"{settings.public_api_url.rstrip('/')}{image}"
|
||||
image_tag = f'<meta property="og:image" content="{escape(image)}" />' if image else ""
|
||||
|
||||
return f"""<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>{title} | Desi Clans</title>
|
||||
<meta name="description" content="{desc}" />
|
||||
<meta property="og:title" content="{title}" />
|
||||
<meta property="og:description" content="{desc}" />
|
||||
<meta property="og:type" content="website" />
|
||||
<meta property="og:url" content="{escape(page_url)}" />
|
||||
{image_tag}
|
||||
<meta name="twitter:card" content="summary_large_image" />
|
||||
<meta http-equiv="refresh" content="0;url={escape(page_url)}" />
|
||||
</head>
|
||||
<body>
|
||||
<p><a href="{escape(page_url)}">{title}</a> — Bengaluru</p>
|
||||
</body>
|
||||
</html>"""
|
||||
Loading…
Add table
Add a link
Reference in a new issue