crude implementation of embedding tweets

This commit is contained in:
Mitarashi 2022-01-14 15:23:53 +02:00
parent 888e965f41
commit 7f15993a74
2 changed files with 25 additions and 1 deletions

View file

@ -10,7 +10,7 @@ import types, config, prefs, formatters, redis_cache, http_pool, tokens
import views/[general, about] import views/[general, about]
import routes/[ import routes/[
preferences, timeline, status, media, search, rss, list, debug, preferences, timeline, status, media, search, rss, list, debug,
unsupported, embed, resolver, router_utils] unsupported, embed, resolver, router_utils, embedtweet]
const instancesUrl = "https://github.com/zedeus/nitter/wiki/Instances" const instancesUrl = "https://github.com/zedeus/nitter/wiki/Instances"
const issuesUrl = "https://github.com/zedeus/nitter/issues" const issuesUrl = "https://github.com/zedeus/nitter/issues"
@ -51,6 +51,7 @@ createMediaRouter(cfg)
createEmbedRouter(cfg) createEmbedRouter(cfg)
createRssRouter(cfg) createRssRouter(cfg)
createDebugRouter(cfg) createDebugRouter(cfg)
createEmbedTweetRouter(cfg)
settings: settings:
port = Port(cfg.port) port = Port(cfg.port)
@ -101,3 +102,4 @@ routes:
extend media, "" extend media, ""
extend embed, "" extend embed, ""
extend debug, "" extend debug, ""
extend embedtweet, ""

22
src/routes/embedtweet.nim Normal file
View file

@ -0,0 +1,22 @@
import asyncdispatch, strutils, uri, options
import jester, karax/vdom
import router_utils
import ".."/views/[general, tweet]
import ".."/[types, api]
export vdom
export router_utils
export api, tweet, general
proc createEmbedTweetRouter*(cfg: Config) =
router embedtweet:
get "/embed/Tweet.html":
let
prefs = cookiePrefs()
t = (await getTweet(@"id")).tweet
resp ($renderHead(prefs, cfg) & $renderTweet(t, prefs, getPath(), mainTweet=true))