From 5e827c91aa1b5f41cc03c5bb07b6fe629002430b Mon Sep 17 00:00:00 2001 From: HookedBehemoth Date: Thu, 16 Jun 2022 18:46:41 +0200 Subject: [PATCH] emit body and doctype on iframe embed endpoint (#640) --- src/routes/embed.nim | 2 +- src/views/embed.nim | 5 +++-- src/views/tweet.nim | 14 +++++++++++--- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/routes/embed.nim b/src/routes/embed.nim index 8690357..baaec68 100644 --- a/src/routes/embed.nim +++ b/src/routes/embed.nim @@ -25,7 +25,7 @@ proc createEmbedRouter*(cfg: Config) = if convo == nil or convo.tweet == nil: resp Http404 - resp $renderTweetEmbed(convo.tweet, path, prefs, cfg, request) + resp renderTweetEmbed(convo.tweet, path, prefs, cfg, request) get "/embed/Tweet.html": let id = @"id" diff --git a/src/views/embed.nim b/src/views/embed.nim index e6afffd..a884cf3 100644 --- a/src/views/embed.nim +++ b/src/views/embed.nim @@ -15,7 +15,8 @@ proc renderVideoEmbed*(tweet: Tweet; cfg: Config; req: Request): string = let node = buildHtml(html(lang="en")): renderHead(prefs, cfg, req, video=vidUrl, images=(@[thumb])) - tdiv(class="embed-video"): - renderVideo(get(tweet.video), prefs, "") + body: + tdiv(class="embed-video"): + renderVideo(get(tweet.video), prefs, "") result = doctype & $node diff --git a/src/views/tweet.nim b/src/views/tweet.nim index 5bee864..daad61a 100644 --- a/src/views/tweet.nim +++ b/src/views/tweet.nim @@ -7,6 +7,9 @@ import renderutils import ".."/[types, utils, formatters] import general +const + doctype = "\n" + proc getSmallPic(url: string): string = result = url if "?" notin url and not url.endsWith("placeholder.png"): @@ -364,7 +367,12 @@ proc renderTweet*(tweet: Tweet; prefs: Prefs; path: string; class=""; index=0; a(class="show-thread", href=("/i/status/" & $tweet.threadId)): text "Show this thread" -proc renderTweetEmbed*(tweet: Tweet; path: string; prefs: Prefs; cfg: Config; req: Request): VNode = - buildHtml(tdiv(class="tweet-embed")): +proc renderTweetEmbed*(tweet: Tweet; path: string; prefs: Prefs; cfg: Config; req: Request): string = + let node = buildHtml(html(lang="en")): renderHead(prefs, cfg, req) - renderTweet(tweet, prefs, path, mainTweet=true) + + body: + tdiv(class="tweet-embed"): + renderTweet(tweet, prefs, path, mainTweet=true) + + result = doctype & $node