Support gif link previews

This commit is contained in:
Zed 2019-08-07 22:27:24 +02:00
parent ec5f67123a
commit 0da26ab197
3 changed files with 16 additions and 13 deletions

View file

@ -68,8 +68,8 @@ proc getUserpic*(userpic: string; style=""): string =
proc getUserpic*(profile: Profile; style=""): string = proc getUserpic*(profile: Profile; style=""): string =
getUserPic(profile.userpic, style) getUserPic(profile.userpic, style)
proc getVideoEmbed*(video: Video): string = proc getVideoEmbed*(id: string): string =
&"https://twitter.com/i/videos/{video.videoId}?embed_source=facebook" &"https://twitter.com/i/videos/{id}?embed_source=facebook"
proc pageTitle*(profile: Profile): string = proc pageTitle*(profile: Profile): string =
&"{profile.fullname} (@{profile.username})" &"{profile.fullname} (@{profile.username})"

View file

@ -96,7 +96,12 @@ routes:
if conversation.tweet.video.isSome(): if conversation.tweet.video.isSome():
let thumb = get(conversation.tweet.video).thumb let thumb = get(conversation.tweet.video).thumb
let vidUrl = getVideoEmbed(get(conversation.tweet.video)) let vidUrl = getVideoEmbed(conversation.tweet.id)
resp renderMain(html, title=cfg.title, titleText=title, desc=desc,
images = @[thumb], `type`="video", video=vidUrl)
elif conversation.tweet.gif.isSome():
let thumb = get(conversation.tweet.gif).thumb
let vidUrl = getVideoEmbed(conversation.tweet.id)
resp renderMain(html, title=cfg.title, titleText=title, desc=desc, resp renderMain(html, title=cfg.title, titleText=title, desc=desc,
images = @[thumb], `type`="video", video=vidUrl) images = @[thumb], `type`="video", video=vidUrl)
else: else:

View file

@ -16,20 +16,18 @@ proc renderMain*(body: VNode; title="Nitter"; titleText=""; desc="";
else: else:
text title text title
meta(name="og:type", content=`type`) meta(property="og:type", content=`type`)
meta(name="og:title", content=titleText) meta(property="og:title", content=titleText)
meta(name="og:description", content=desc) meta(property="og:url", content="https://t.co/VOkeVRgJgc")
meta(name="og:site_name", content="Twitter") meta(property="og:description", content=desc)
meta(property="og:site_name", content="Twitter")
for url in images: for url in images:
meta(name="og:image", content=getSigUrl(url, "pic")) meta(property="og:image", content=getSigUrl(url, "pic"))
if video.len > 0: if video.len > 0:
meta(name="og:video:url", content=video) meta(property="og:video:url", content=video)
meta(name="og:video:secure_url", content=video) meta(property="og:video:secure_url", content=video)
meta(name="og:video:type", content="text/html")
meta(name="og:video:width", content="1200")
meta(name="og:video:height", content="675")
body: body:
nav(id="nav", class="nav-bar container"): nav(id="nav", class="nav-bar container"):