video embeds: swap title and author if description is too long
This commit is contained in:
parent
379baa679d
commit
501b395f26
1 changed files with 11 additions and 5 deletions
|
@ -89,15 +89,16 @@ proc renderHead*(prefs: Prefs; cfg: Config; req: Request; titleText=""; desc="";
|
||||||
text cfg.title
|
text cfg.title
|
||||||
|
|
||||||
let finalizedTitleText = (if ogTitle.len > 0: ogTitle else: titleText)
|
let finalizedTitleText = (if ogTitle.len > 0: ogTitle else: titleText)
|
||||||
|
let finalizedDesc = stripHtml(desc)
|
||||||
|
|
||||||
meta(name="viewport", content="width=device-width, initial-scale=1.0")
|
meta(name="viewport", content="width=device-width, initial-scale=1.0")
|
||||||
meta(name="theme-color", content="#1F1F1F")
|
meta(name="theme-color", content="#1F1F1F")
|
||||||
meta(property="og:type", content=ogType)
|
meta(property="og:type", content=ogType)
|
||||||
if video.len > 0:
|
if video.len > 0 and len(finalizedDesc) <= 67:
|
||||||
meta(property="og:title", content=stripHtml(desc))
|
meta(property="og:title", content=finalizedDesc)
|
||||||
else:
|
else:
|
||||||
meta(property="og:title", content=finalizedTitleText)
|
meta(property="og:title", content=finalizedTitleText)
|
||||||
meta(property="og:description", content=stripHtml(desc))
|
meta(property="og:description", content=finalizedDesc)
|
||||||
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")
|
||||||
|
|
||||||
|
@ -114,7 +115,6 @@ proc renderHead*(prefs: Prefs; cfg: Config; req: Request; titleText=""; desc="";
|
||||||
meta(property="og:image", content=image)
|
meta(property="og:image", content=image)
|
||||||
if video.len == 0:
|
if video.len == 0:
|
||||||
meta(property="twitter:image:src", content=image)
|
meta(property="twitter:image:src", content=image)
|
||||||
|
|
||||||
if rss.len > 0:
|
if rss.len > 0:
|
||||||
meta(property="twitter:card", content="summary")
|
meta(property="twitter:card", content="summary")
|
||||||
elif video.len == 0:
|
elif video.len == 0:
|
||||||
|
@ -124,7 +124,13 @@ proc renderHead*(prefs: Prefs; cfg: Config; req: Request; titleText=""; desc="";
|
||||||
meta(property="og:video:url", content=video)
|
meta(property="og:video:url", content=video)
|
||||||
meta(property="og:video:secure_url", content=video)
|
meta(property="og:video:secure_url", content=video)
|
||||||
meta(property="og:video:type", content="video/mp4")
|
meta(property="og:video:type", content="video/mp4")
|
||||||
verbatim &"<link rel=\"alternate\" href=\"{getUrlPrefix(cfg)}/oembed.json?type=video&title={encodeUrl(stripHtml(desc))}&user={encodeUrl(finalizedTitleText)}&url={encodeUrl(req.path)}\" type=\"application/json+oembed\" />"
|
var title = encodeUrl(finalizedDesc)
|
||||||
|
var author = encodeUrl(finalizedTitleText)
|
||||||
|
if len(finalizedDesc) > 67:
|
||||||
|
title = author
|
||||||
|
author = encodeUrl(finalizedDesc)
|
||||||
|
|
||||||
|
verbatim &"<link rel=\"alternate\" href=\"{getUrlPrefix(cfg)}/oembed.json?type=video&title={title}&user={author}&url={encodeUrl(req.path)}\" type=\"application/json+oembed\" />"
|
||||||
#link(rel="alternate",
|
#link(rel="alternate",
|
||||||
# href=&"{getUrlPrefix(cfg)}/oembed.json?type=video&title={encodeUrl(stripHtml(desc))}&user={encodeUrl(finalizedTitleText)}&url={encodeUrl(req.path)}",
|
# href=&"{getUrlPrefix(cfg)}/oembed.json?type=video&title={encodeUrl(stripHtml(desc))}&user={encodeUrl(finalizedTitleText)}&url={encodeUrl(req.path)}",
|
||||||
# `type`="application/json+oembed")
|
# `type`="application/json+oembed")
|
||||||
|
|
Loading…
Reference in a new issue