nitter/src/routes/embed.nim

37 lines
958 B
Nim
Raw Normal View History

2021-12-27 01:37:38 +00:00
# SPDX-License-Identifier: AGPL-3.0-only
2022-06-04 00:18:26 +00:00
import asyncdispatch, strutils, strformat, options
2022-01-14 17:01:47 +00:00
import jester, karax/vdom
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
get "/@user/status/@id/embed":
2022-01-14 17:01:47 +00:00
let
convo = await getTweet(@"id")
2022-01-14 17:01:47 +00:00
prefs = cookiePrefs()
path = getPath()
if convo == nil or convo.tweet == nil:
resp Http404
resp renderTweetEmbed(convo.tweet, path, prefs, cfg, request)
get "/embed/Tweet.html":
let id = @"id"
if id.len > 0:
2022-06-04 00:18:26 +00:00
redirect(&"/i/status/{id}/embed")
else:
resp Http404