From 7f15993a74c8dacd8177801ee46fde7e7e666e32 Mon Sep 17 00:00:00 2001 From: Mitarashi Date: Fri, 14 Jan 2022 15:23:53 +0200 Subject: [PATCH] crude implementation of embedding tweets --- src/nitter.nim | 4 +++- src/routes/embedtweet.nim | 22 ++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 src/routes/embedtweet.nim diff --git a/src/nitter.nim b/src/nitter.nim index 9f8fcb7..411c9a3 100644 --- a/src/nitter.nim +++ b/src/nitter.nim @@ -10,7 +10,7 @@ import types, config, prefs, formatters, redis_cache, http_pool, tokens import views/[general, about] import routes/[ 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 issuesUrl = "https://github.com/zedeus/nitter/issues" @@ -51,6 +51,7 @@ createMediaRouter(cfg) createEmbedRouter(cfg) createRssRouter(cfg) createDebugRouter(cfg) +createEmbedTweetRouter(cfg) settings: port = Port(cfg.port) @@ -101,3 +102,4 @@ routes: extend media, "" extend embed, "" extend debug, "" + extend embedtweet, "" diff --git a/src/routes/embedtweet.nim b/src/routes/embedtweet.nim new file mode 100644 index 0000000..d318e67 --- /dev/null +++ b/src/routes/embedtweet.nim @@ -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)) + + +