Revert og:title for tweets

This commit is contained in:
Zed 2020-03-29 23:20:00 +02:00
parent 2458a067ef
commit 240ce15651
2 changed files with 7 additions and 5 deletions

View file

@ -26,6 +26,7 @@ proc createStatusRouter*(cfg: Config) =
var var
title = pageTitle(conversation.tweet) title = pageTitle(conversation.tweet)
ogTitle = pageTitle(conversation.tweet.profile)
desc = conversation.tweet.text desc = conversation.tweet.text
images = conversation.tweet.photos images = conversation.tweet.photos
video = "" video = ""
@ -38,7 +39,8 @@ proc createStatusRouter*(cfg: Config) =
video = getGifUrl(get(conversation.tweet.gif).url) video = getGifUrl(get(conversation.tweet.gif).url)
let html = renderConversation(conversation, prefs, getPath() & "#m") let html = renderConversation(conversation, prefs, getPath() & "#m")
resp renderMain(html, request, cfg, title, desc, images=images, video=video) resp renderMain(html, request, cfg, title, desc,
images=images, video=video, ogTitle=ogTitle)
get "/@name/@s/@id/@m/?@i?": get "/@name/@s/@id/@m/?@i?":
cond @"s" in ["status", "statuses"] cond @"s" in ["status", "statuses"]

View file

@ -29,7 +29,7 @@ proc renderNavbar*(title, rss: string; req: Request): VNode =
iconReferer "cog", "/settings", path, title="Preferences" iconReferer "cog", "/settings", path, title="Preferences"
proc renderHead*(prefs: Prefs; cfg: Config; titleText=""; desc=""; video=""; proc renderHead*(prefs: Prefs; cfg: Config; titleText=""; desc=""; video="";
images: seq[string] = @[]): VNode = images: seq[string] = @[]; ogTitle=""): VNode =
let ogType = let ogType =
if video.len > 0: "video" if video.len > 0: "video"
elif images.len > 0: "photo" elif images.len > 0: "photo"
@ -67,7 +67,7 @@ proc renderHead*(prefs: Prefs; cfg: Config; titleText=""; desc=""; video="";
meta(name="viewport", content="width=device-width, initial-scale=1.0") meta(name="viewport", content="width=device-width, initial-scale=1.0")
meta(property="og:type", content=ogType) meta(property="og:type", content=ogType)
meta(property="og:title", content=titleText) meta(property="og:title", content=(if ogTitle.len > 0: ogTitle else: titleText))
meta(property="og:description", content=stripHtml(desc)) meta(property="og:description", content=stripHtml(desc))
meta(property="og:site_name", content="Nitter") meta(property="og:site_name", content="Nitter")
meta(property="og:locale", content="en_US") meta(property="og:locale", content="en_US")
@ -81,12 +81,12 @@ proc renderHead*(prefs: Prefs; cfg: Config; titleText=""; desc=""; video="";
meta(property="og:video:type", content="text/html") meta(property="og:video:type", content="text/html")
proc renderMain*(body: VNode; req: Request; cfg: Config; titleText=""; desc=""; proc renderMain*(body: VNode; req: Request; cfg: Config; titleText=""; desc="";
rss=""; video=""; images: seq[string] = @[]): string = rss=""; video=""; images: seq[string] = @[]; ogTitle=""): string =
let prefs = getPrefs(req.cookies.getOrDefault("preferences"), cfg) let prefs = getPrefs(req.cookies.getOrDefault("preferences"), cfg)
let theme = toLowerAscii(prefs.theme).replace(" ", "_") let theme = toLowerAscii(prefs.theme).replace(" ", "_")
let node = buildHtml(html(lang="en")): let node = buildHtml(html(lang="en")):
renderHead(prefs, cfg, titleText, desc, video, images): renderHead(prefs, cfg, titleText, desc, video, images, ogTitle):
if theme.len > 0: if theme.len > 0:
link(rel="stylesheet", `type`="text/css", href=(&"/css/themes/{theme}.css")) link(rel="stylesheet", `type`="text/css", href=(&"/css/themes/{theme}.css"))