2021-12-27 01:37:38 +00:00
|
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
2021-12-20 02:11:12 +00:00
|
|
|
import asyncdispatch, strutils, options
|
2022-01-14 17:01:47 +00:00
|
|
|
import jester, karax/vdom
|
2022-01-14 18:33:01 +00:00
|
|
|
import ".."/[types, api]
|
|
|
|
import ../views/[embed, tweet, general]
|
2022-01-14 17:01:47 +00:00
|
|
|
import router_utils
|
2019-12-06 14:15:56 +00:00
|
|
|
|
2022-01-14 18:35:01 +00:00
|
|
|
export api, embed, vdom, tweet, general, router_utils
|
2019-12-06 14:15:56 +00:00
|
|
|
|
|
|
|
proc createEmbedRouter*(cfg: Config) =
|
|
|
|
router embed:
|
|
|
|
get "/i/videos/tweet/@id":
|
2020-06-01 00:22:56 +00:00
|
|
|
let convo = await getTweet(@"id")
|
|
|
|
if convo == nil or convo.tweet == nil or convo.tweet.video.isNone:
|
|
|
|
resp Http404
|
|
|
|
|
2022-01-14 18:45:02 +00:00
|
|
|
resp renderVideoEmbed(convo.tweet, cfg, request)
|
2022-01-14 17:01:47 +00:00
|
|
|
|
2022-01-14 17:34:10 +00:00
|
|
|
get "/@user/status/@id/embed":
|
2022-01-14 17:01:47 +00:00
|
|
|
let
|
2022-01-14 17:34:10 +00:00
|
|
|
convo = await getTweet(@"id")
|
2022-01-14 17:01:47 +00:00
|
|
|
prefs = cookiePrefs()
|
|
|
|
path = getPath()
|
|
|
|
|
2022-01-14 17:34:10 +00:00
|
|
|
if convo == nil or convo.tweet == nil:
|
|
|
|
resp Http404
|
|
|
|
|
2022-01-14 18:45:02 +00:00
|
|
|
resp $renderTweetEmbed(convo.tweet, path, prefs, cfg, request)
|
2022-01-14 18:24:06 +00:00
|
|
|
|
|
|
|
get "/embed/Tweet.html":
|
|
|
|
let id = @"id"
|
|
|
|
|
|
|
|
if id.len > 0:
|
|
|
|
redirect("/i/status/" & id & "/embed")
|
|
|
|
else:
|
|
|
|
resp Http404
|