From 0da26ab1974edafd74b87c1535dbdb15f7d0a251 Mon Sep 17 00:00:00 2001 From: Zed Date: Wed, 7 Aug 2019 22:27:24 +0200 Subject: [PATCH] Support gif link previews --- src/formatters.nim | 4 ++-- src/nitter.nim | 7 ++++++- src/views/general.nim | 18 ++++++++---------- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/formatters.nim b/src/formatters.nim index 5e5d134..6db37d3 100644 --- a/src/formatters.nim +++ b/src/formatters.nim @@ -68,8 +68,8 @@ proc getUserpic*(userpic: string; style=""): string = proc getUserpic*(profile: Profile; style=""): string = getUserPic(profile.userpic, style) -proc getVideoEmbed*(video: Video): string = - &"https://twitter.com/i/videos/{video.videoId}?embed_source=facebook" +proc getVideoEmbed*(id: string): string = + &"https://twitter.com/i/videos/{id}?embed_source=facebook" proc pageTitle*(profile: Profile): string = &"{profile.fullname} (@{profile.username})" diff --git a/src/nitter.nim b/src/nitter.nim index 19b00a7..d225434 100644 --- a/src/nitter.nim +++ b/src/nitter.nim @@ -96,7 +96,12 @@ routes: if conversation.tweet.video.isSome(): 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, images = @[thumb], `type`="video", video=vidUrl) else: diff --git a/src/views/general.nim b/src/views/general.nim index c86dc34..6b76fcd 100644 --- a/src/views/general.nim +++ b/src/views/general.nim @@ -16,20 +16,18 @@ proc renderMain*(body: VNode; title="Nitter"; titleText=""; desc=""; else: text title - meta(name="og:type", content=`type`) - meta(name="og:title", content=titleText) - meta(name="og:description", content=desc) - meta(name="og:site_name", content="Twitter") + meta(property="og:type", content=`type`) + meta(property="og:title", content=titleText) + meta(property="og:url", content="https://t.co/VOkeVRgJgc") + meta(property="og:description", content=desc) + meta(property="og:site_name", content="Twitter") for url in images: - meta(name="og:image", content=getSigUrl(url, "pic")) + meta(property="og:image", content=getSigUrl(url, "pic")) if video.len > 0: - meta(name="og:video:url", content=video) - meta(name="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") + meta(property="og:video:url", content=video) + meta(property="og:video:secure_url", content=video) body: nav(id="nav", class="nav-bar container"):