moved themes to be handled in renderHead and changed path to /embed
This commit is contained in:
parent
3579bd8e30
commit
875a2c5387
4 changed files with 24 additions and 15 deletions
|
@ -15,12 +15,15 @@ proc createEmbedRouter*(cfg: Config) =
|
|||
if convo == nil or convo.tweet == nil or convo.tweet.video.isNone:
|
||||
resp Http404
|
||||
|
||||
resp renderVideoEmbed(cfg, convo.tweet)
|
||||
resp renderVideoEmbed(cfg, request, convo.tweet)
|
||||
|
||||
get "/@user/status/@id/embedded":
|
||||
get "/@user/status/@id/embed":
|
||||
let
|
||||
tweet = (await getTweet(@"id")).tweet
|
||||
convo = await getTweet(@"id")
|
||||
prefs = cookiePrefs()
|
||||
path = getPath()
|
||||
|
||||
resp $renderEmbeddedTweet(tweet, cfg, prefs, path)
|
||||
if convo == nil or convo.tweet == nil:
|
||||
resp Http404
|
||||
|
||||
resp $renderEmbeddedTweet(convo.tweet, cfg, request, prefs, path)
|
||||
|
|
|
@ -1,18 +1,19 @@
|
|||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
import options
|
||||
import karax/[karaxdsl, vdom]
|
||||
from jester import Request
|
||||
|
||||
import ".."/[types, formatters]
|
||||
import general, tweet
|
||||
|
||||
const doctype = "<!DOCTYPE html>\n"
|
||||
|
||||
proc renderVideoEmbed*(cfg: Config; tweet: Tweet): string =
|
||||
proc renderVideoEmbed*(cfg: Config; req: Request; tweet: Tweet): string =
|
||||
let thumb = get(tweet.video).thumb
|
||||
let vidUrl = getVideoEmbed(cfg, tweet.id)
|
||||
let prefs = Prefs(hlsPlayback: true)
|
||||
let node = buildHtml(html(lang="en")):
|
||||
renderHead(prefs, cfg, video=vidUrl, images=(@[thumb]))
|
||||
renderHead(prefs, cfg, req, video=vidUrl, images=(@[thumb]))
|
||||
|
||||
tdiv(class="embed-video"):
|
||||
renderVideo(get(tweet.video), prefs, "")
|
||||
|
|
|
@ -11,6 +11,9 @@ const
|
|||
doctype = "<!DOCTYPE html>\n"
|
||||
lp = readFile("public/lp.svg")
|
||||
|
||||
proc toTheme(theme: string): string =
|
||||
theme.toLowerAscii.replace(" ", "_")
|
||||
|
||||
proc renderNavbar(cfg: Config; req: Request; rss, canonical: string): VNode =
|
||||
var path = req.params.getOrDefault("referer")
|
||||
if path.len == 0:
|
||||
|
@ -33,9 +36,13 @@ proc renderNavbar(cfg: Config; req: Request; rss, canonical: string): VNode =
|
|||
icon "info", title="About", href="/about"
|
||||
icon "cog", title="Preferences", href=("/settings?referer=" & encodeUrl(path))
|
||||
|
||||
proc renderHead*(prefs: Prefs; cfg: Config; titleText=""; desc=""; video="";
|
||||
images: seq[string] = @[]; banner=""; ogTitle=""; theme="";
|
||||
proc renderHead*(prefs: Prefs; cfg: Config; req: Request; titleText=""; desc="";
|
||||
video=""; images: seq[string] = @[]; banner=""; ogTitle="";
|
||||
rss=""; canonical=""): VNode =
|
||||
var theme = prefs.theme.toTheme
|
||||
if "theme" in req.params:
|
||||
theme = req.params["theme"].toTheme
|
||||
|
||||
let ogType =
|
||||
if video.len > 0: "video"
|
||||
elif rss.len > 0: "object"
|
||||
|
@ -118,15 +125,12 @@ proc renderHead*(prefs: Prefs; cfg: Config; titleText=""; desc=""; video="";
|
|||
proc renderMain*(body: VNode; req: Request; cfg: Config; prefs=defaultPrefs;
|
||||
titleText=""; desc=""; ogTitle=""; rss=""; video="";
|
||||
images: seq[string] = @[]; banner=""): string =
|
||||
var theme = toLowerAscii(prefs.theme).replace(" ", "_")
|
||||
if "theme" in req.params:
|
||||
theme = toLowerAscii(req.params["theme"]).replace(" ", "_")
|
||||
|
||||
let canonical = getTwitterLink(req.path, req.params)
|
||||
|
||||
let node = buildHtml(html(lang="en")):
|
||||
renderHead(prefs, cfg, titleText, desc, video, images, banner, ogTitle,
|
||||
theme, rss, canonical)
|
||||
renderHead(prefs, cfg, req, titleText, desc, video, images, banner, ogTitle,
|
||||
rss, canonical)
|
||||
|
||||
body:
|
||||
renderNavbar(cfg, req, rss, canonical)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
import strutils, sequtils, strformat, options
|
||||
import karax/[karaxdsl, vdom, vstyles]
|
||||
from jester import Request
|
||||
|
||||
import renderutils
|
||||
import ".."/[types, utils, formatters]
|
||||
|
@ -276,7 +277,7 @@ proc renderLocation*(tweet: Tweet): string =
|
|||
text place
|
||||
return $node
|
||||
|
||||
proc renderEmbeddedTweet*(tweet: Tweet; cfg: Config; prefs: Prefs; path: string): VNode =
|
||||
proc renderEmbeddedTweet*(tweet: Tweet; cfg: Config; req: Request; prefs: Prefs; path: string): VNode =
|
||||
let fullTweet = tweet
|
||||
var retweet: string
|
||||
var tweet = fullTweet
|
||||
|
@ -298,7 +299,7 @@ proc renderEmbeddedTweet*(tweet: Tweet; cfg: Config; prefs: Prefs; path: string)
|
|||
renderQuote(tweet.quote.get(), prefs, path)
|
||||
|
||||
buildHtml(tdiv(class="timeline-item")):
|
||||
renderHead(prefs, cfg)
|
||||
renderHead(prefs, cfg, req)
|
||||
tdiv(class="tweet-body"):
|
||||
var views = ""
|
||||
renderHeader(tweet, retweet, prefs)
|
||||
|
|
Loading…
Reference in a new issue