no more redis
This commit is contained in:
parent
be4c83bfb0
commit
5e2d126aea
6 changed files with 46 additions and 24 deletions
|
@ -28,6 +28,7 @@ maintained by the community.
|
||||||
* Image zooming/carousel (requires JavaScript)
|
* Image zooming/carousel (requires JavaScript)
|
||||||
* Up to date Twitter features, e.g. Community Notes
|
* Up to date Twitter features, e.g. Community Notes
|
||||||
* Embeds for chat services on-par with services like [FxTwitter](https://github.com/FixTweet/FxTwitter) and [vxTwitter](https://github.com/dylanpdx/BetterTwitFix)
|
* Embeds for chat services on-par with services like [FxTwitter](https://github.com/FixTweet/FxTwitter) and [vxTwitter](https://github.com/dylanpdx/BetterTwitFix)
|
||||||
|
* No dependency on Redis, as it has caused ratelimiting issues, but also forcably disables RSS
|
||||||
|
|
||||||
## Why use Nitter?
|
## Why use Nitter?
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ import jester
|
||||||
import types, config, prefs, formatters, redis_cache, http_pool
|
import types, config, prefs, formatters, redis_cache, http_pool
|
||||||
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, list, #rss, debug,
|
||||||
unsupported, embed, resolver, router_utils, home, follow, twitter_api]
|
unsupported, embed, resolver, router_utils, home, follow, twitter_api]
|
||||||
|
|
||||||
const instancesUrl = "https://github.com/zedeus/nitter/wiki/Instances"
|
const instancesUrl = "https://github.com/zedeus/nitter/wiki/Instances"
|
||||||
|
@ -35,9 +35,9 @@ setMaxHttpConns(cfg.httpMaxConns)
|
||||||
setHttpProxy(cfg.proxy, cfg.proxyAuth)
|
setHttpProxy(cfg.proxy, cfg.proxyAuth)
|
||||||
initAboutPage(cfg.staticDir)
|
initAboutPage(cfg.staticDir)
|
||||||
|
|
||||||
waitFor initRedisPool(cfg)
|
#waitFor initRedisPool(cfg)
|
||||||
stdout.write &"Connected to Redis at {cfg.redisHost}:{cfg.redisPort}\n"
|
#stdout.write &"Connected to Redis at {cfg.redisHost}:{cfg.redisPort}\n"
|
||||||
stdout.flushFile
|
#stdout.flushFile
|
||||||
|
|
||||||
createUnsupportedRouter(cfg)
|
createUnsupportedRouter(cfg)
|
||||||
createResolverRouter(cfg)
|
createResolverRouter(cfg)
|
||||||
|
@ -48,7 +48,7 @@ createStatusRouter(cfg)
|
||||||
createSearchRouter(cfg)
|
createSearchRouter(cfg)
|
||||||
createMediaRouter(cfg)
|
createMediaRouter(cfg)
|
||||||
createEmbedRouter(cfg)
|
createEmbedRouter(cfg)
|
||||||
createRssRouter(cfg)
|
#createRssRouter(cfg)
|
||||||
#createDebugRouter(cfg)
|
#createDebugRouter(cfg)
|
||||||
createTwitterApiRouter(cfg)
|
createTwitterApiRouter(cfg)
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ routes:
|
||||||
|
|
||||||
extend home, ""
|
extend home, ""
|
||||||
extend follow, ""
|
extend follow, ""
|
||||||
extend rss, ""
|
#extend rss, ""
|
||||||
extend status, ""
|
extend status, ""
|
||||||
extend search, ""
|
extend search, ""
|
||||||
extend timeline, ""
|
extend timeline, ""
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import jester
|
import jester
|
||||||
import asyncdispatch, strutils, options, router_utils, timeline
|
import asyncdispatch, strutils, options, router_utils, timeline
|
||||||
import ".."/[prefs, types, utils, redis_cache]
|
import ".."/[prefs, types, utils]
|
||||||
import ../views/[general, home, search]
|
import ../views/[general, home, search]
|
||||||
|
|
||||||
export home
|
export home
|
||||||
|
@ -43,7 +43,7 @@ proc createHomeRouter*(cfg: Config) =
|
||||||
query.kind = userList
|
query.kind = userList
|
||||||
|
|
||||||
for name in names:
|
for name in names:
|
||||||
let prof = await getCachedUser(name)
|
let prof = await getGraphUser(name)
|
||||||
profs &= @[prof]
|
profs &= @[prof]
|
||||||
|
|
||||||
resp renderMain(renderFollowing(query, profs, prefs), request, cfg, prefs)
|
resp renderMain(renderFollowing(query, profs, prefs), request, cfg, prefs)
|
||||||
|
|
|
@ -4,7 +4,7 @@ import strutils, strformat, uri
|
||||||
import jester
|
import jester
|
||||||
|
|
||||||
import router_utils
|
import router_utils
|
||||||
import ".."/[types, redis_cache, api]
|
import ".."/[types, api]
|
||||||
import ../views/[general, timeline, list]
|
import ../views/[general, timeline, list]
|
||||||
|
|
||||||
template respList*(list, timeline, title, vnode: typed) =
|
template respList*(list, timeline, title, vnode: typed) =
|
||||||
|
@ -20,6 +20,14 @@ template respList*(list, timeline, title, vnode: typed) =
|
||||||
proc title*(list: List): string =
|
proc title*(list: List): string =
|
||||||
&"@{list.username}/{list.name}"
|
&"@{list.username}/{list.name}"
|
||||||
|
|
||||||
|
|
||||||
|
proc getList*(username=""; slug=""; id=""): Future[List] {.async.} =
|
||||||
|
if id.len > 0:
|
||||||
|
result = await getGraphList(id)
|
||||||
|
else:
|
||||||
|
result = await getGraphListBySlug(username, slug)
|
||||||
|
|
||||||
|
|
||||||
proc createListRouter*(cfg: Config) =
|
proc createListRouter*(cfg: Config) =
|
||||||
router list:
|
router list:
|
||||||
get "/@name/lists/@slug/?":
|
get "/@name/lists/@slug/?":
|
||||||
|
@ -28,7 +36,7 @@ proc createListRouter*(cfg: Config) =
|
||||||
cond @"slug" != "memberships"
|
cond @"slug" != "memberships"
|
||||||
let
|
let
|
||||||
slug = decodeUrl(@"slug")
|
slug = decodeUrl(@"slug")
|
||||||
list = await getCachedList(@"name", slug)
|
list = await getList(@"name", slug)
|
||||||
if list.id.len == 0:
|
if list.id.len == 0:
|
||||||
resp Http404, showError(&"""List "{@"slug"}" not found""", cfg)
|
resp Http404, showError(&"""List "{@"slug"}" not found""", cfg)
|
||||||
redirect(&"/i/lists/{list.id}")
|
redirect(&"/i/lists/{list.id}")
|
||||||
|
@ -37,7 +45,7 @@ proc createListRouter*(cfg: Config) =
|
||||||
cond '.' notin @"id"
|
cond '.' notin @"id"
|
||||||
let
|
let
|
||||||
prefs = cookiePrefs()
|
prefs = cookiePrefs()
|
||||||
list = await getCachedList(id=(@"id"))
|
list = await getList(id=(@"id"))
|
||||||
timeline = await getGraphListTweets(list.id, getCursor())
|
timeline = await getGraphListTweets(list.id, getCursor())
|
||||||
vnode = renderTimelineTweets(timeline, prefs, request.path)
|
vnode = renderTimelineTweets(timeline, prefs, request.path)
|
||||||
respList(list, timeline, list.title, vnode)
|
respList(list, timeline, list.title, vnode)
|
||||||
|
@ -46,6 +54,6 @@ proc createListRouter*(cfg: Config) =
|
||||||
cond '.' notin @"id"
|
cond '.' notin @"id"
|
||||||
let
|
let
|
||||||
prefs = cookiePrefs()
|
prefs = cookiePrefs()
|
||||||
list = await getCachedList(id=(@"id"))
|
list = await getList(id=(@"id"))
|
||||||
members = await getGraphListMembers(list, getCursor())
|
members = await getGraphListMembers(list, getCursor())
|
||||||
respList(list, members, list.title, renderTimelineUsers(members, prefs, request.path))
|
respList(list, members, list.title, renderTimelineUsers(members, prefs, request.path))
|
||||||
|
|
|
@ -3,13 +3,13 @@ import asyncdispatch, strutils, sequtils, uri, options, times
|
||||||
import jester, karax/vdom
|
import jester, karax/vdom
|
||||||
|
|
||||||
import router_utils
|
import router_utils
|
||||||
import ".."/[types, redis_cache, formatters, query, api]
|
import ".."/[types, formatters, query, api]
|
||||||
import ../views/[general, profile, timeline, status, search]
|
import ../views/[general, profile, timeline, status, search]
|
||||||
|
|
||||||
export vdom
|
export vdom
|
||||||
export uri, sequtils
|
export uri, sequtils
|
||||||
export router_utils
|
export router_utils
|
||||||
export redis_cache, formatters, query, api
|
export formatters, query, api
|
||||||
export profile, timeline, status
|
export profile, timeline, status
|
||||||
|
|
||||||
proc getQuery*(request: Request; tab, name: string): Query =
|
proc getQuery*(request: Request; tab, name: string): Query =
|
||||||
|
@ -28,6 +28,19 @@ template skipIf[T](cond: bool; default; body: Future[T]): Future[T] =
|
||||||
else:
|
else:
|
||||||
body
|
body
|
||||||
|
|
||||||
|
proc getUserId(username: string): Future[string] {.async.} =
|
||||||
|
let user = await getGraphUser(username)
|
||||||
|
if user.suspended:
|
||||||
|
return "suspended"
|
||||||
|
else:
|
||||||
|
return user.id
|
||||||
|
|
||||||
|
|
||||||
|
proc getUsername*(userId: string): Future[string] {.async.} =
|
||||||
|
let user = await getGraphUserById(userId)
|
||||||
|
result = user.username
|
||||||
|
|
||||||
|
|
||||||
proc fetchProfile*(after: string; query: Query; cfg: Config; skipRail=false;
|
proc fetchProfile*(after: string; query: Query; cfg: Config; skipRail=false;
|
||||||
skipPinned=false): Future[Profile] {.async.} =
|
skipPinned=false): Future[Profile] {.async.} =
|
||||||
let
|
let
|
||||||
|
@ -48,9 +61,9 @@ proc fetchProfile*(after: string; query: Query; cfg: Config; skipRail=false;
|
||||||
let
|
let
|
||||||
rail =
|
rail =
|
||||||
skipIf(skipRail or query.kind == media, @[]):
|
skipIf(skipRail or query.kind == media, @[]):
|
||||||
getCachedPhotoRail(name)
|
getPhotoRail(name)
|
||||||
|
|
||||||
user = getCachedUser(name)
|
user = getGraphUser(name)
|
||||||
|
|
||||||
result =
|
result =
|
||||||
case query.kind
|
case query.kind
|
||||||
|
@ -94,7 +107,7 @@ template respTimeline*(timeline: typed) =
|
||||||
|
|
||||||
template respUserId*() =
|
template respUserId*() =
|
||||||
cond @"user_id".len > 0
|
cond @"user_id".len > 0
|
||||||
let username = await getCachedUsername(@"user_id")
|
let username = await getUsername(@"user_id")
|
||||||
if username.len > 0:
|
if username.len > 0:
|
||||||
redirect("/" & username)
|
redirect("/" & username)
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -29,8 +29,8 @@ proc renderNavbar(cfg: Config; req: Request; rss, canonical: string): VNode =
|
||||||
|
|
||||||
tdiv(class="nav-item right"):
|
tdiv(class="nav-item right"):
|
||||||
icon "search", title="Search", href="/search"
|
icon "search", title="Search", href="/search"
|
||||||
if cfg.enableRss and rss.len > 0:
|
#if cfg.enableRss and rss.len > 0:
|
||||||
icon "rss-feed", title="RSS Feed", href=rss
|
#icon "rss-feed", title="RSS Feed", href=rss
|
||||||
icon "bird", title="Open in Twitter", href=canonical
|
icon "bird", title="Open in Twitter", href=canonical
|
||||||
a(href="https://liberapay.com/zedeus"): verbatim lp
|
a(href="https://liberapay.com/zedeus"): verbatim lp
|
||||||
icon "info", title="About", href="/about"
|
icon "info", title="About", href="/about"
|
||||||
|
@ -46,7 +46,7 @@ proc renderHead*(prefs: Prefs; cfg: Config; req: Request; titleText=""; desc="";
|
||||||
|
|
||||||
let ogType =
|
let ogType =
|
||||||
if video.len > 0: "video.other"
|
if video.len > 0: "video.other"
|
||||||
elif rss.len > 0: "object"
|
#elif rss.len > 0: "object"
|
||||||
elif images.len > 0: "photo"
|
elif images.len > 0: "photo"
|
||||||
else: "article"
|
else: "article"
|
||||||
|
|
||||||
|
@ -73,8 +73,8 @@ proc renderHead*(prefs: Prefs; cfg: Config; req: Request; titleText=""; desc="";
|
||||||
if canonical.len > 0:
|
if canonical.len > 0:
|
||||||
link(rel="canonical", href=canonical)
|
link(rel="canonical", href=canonical)
|
||||||
|
|
||||||
if cfg.enableRss and rss.len > 0:
|
#if cfg.enableRss and rss.len > 0:
|
||||||
link(rel="alternate", type="application/rss+xml", href=rss, title="RSS feed")
|
#link(rel="alternate", type="application/rss+xml", href=rss, title="RSS feed")
|
||||||
|
|
||||||
if prefs.hlsPlayback:
|
if prefs.hlsPlayback:
|
||||||
script(src="/js/hls.light.min.js", `defer`="")
|
script(src="/js/hls.light.min.js", `defer`="")
|
||||||
|
@ -128,8 +128,8 @@ proc renderHead*(prefs: Prefs; cfg: Config; req: Request; titleText=""; desc="";
|
||||||
meta(property="og:image", content=image)
|
meta(property="og:image", content=image)
|
||||||
if video.len == 0:
|
if video.len == 0:
|
||||||
meta(property="twitter:image:src", content=image)
|
meta(property="twitter:image:src", content=image)
|
||||||
if rss.len > 0:
|
#if rss.len > 0:
|
||||||
meta(property="twitter:card", content="summary")
|
#meta(property="twitter:card", content="summary")
|
||||||
elif video.len == 0:
|
elif video.len == 0:
|
||||||
meta(property="twitter:card", content="summary_large_image")
|
meta(property="twitter:card", content="summary_large_image")
|
||||||
elif avatar.len > 0:
|
elif avatar.len > 0:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue