More cleanup

This commit is contained in:
Zed 2022-01-02 11:21:03 +01:00
parent a9034928eb
commit 74c4377198
7 changed files with 11 additions and 11 deletions

View File

@ -5,7 +5,7 @@ import types, tokens, consts, parserutils, http_pool
const rl = "x-rate-limit-" const rl = "x-rate-limit-"
var pool {.threadvar.}: HttpPool var pool: HttpPool
proc genParams*(pars: openarray[(string, string)] = @[]; cursor=""; proc genParams*(pars: openarray[(string, string)] = @[]; cursor="";
count="20"; ext=true): seq[(string, string)] = count="20"; ext=true): seq[(string, string)] =

View File

@ -5,8 +5,8 @@ type
HttpPool* = ref object HttpPool* = ref object
conns*: seq[AsyncHttpClient] conns*: seq[AsyncHttpClient]
var maxConns {.threadvar.}: int var maxConns: int
var proxy {.threadvar.}: Proxy var proxy: Proxy
proc setMaxHttpConns*(n: int) = proc setMaxHttpConns*(n: int) =
maxConns = n maxConns = n

View File

@ -6,7 +6,7 @@ from parsecfg import nil
export genUpdatePrefs, genResetPrefs export genUpdatePrefs, genResetPrefs
var defaultPrefs* {.threadvar.}: Prefs var defaultPrefs*: Prefs
proc updateDefaultPrefs*(cfg: parsecfg.Config) = proc updateDefaultPrefs*(cfg: parsecfg.Config) =
genDefaultPrefs() genDefaultPrefs()

View File

@ -9,7 +9,7 @@ const
baseCacheTime = 60 * 60 baseCacheTime = 60 * 60
var var
pool {.threadvar.}: RedisPool pool: RedisPool
rssCacheTime: int rssCacheTime: int
listCacheTime*: int listCacheTime*: int

View File

@ -11,8 +11,8 @@ const
failDelay = initDuration(minutes=30) failDelay = initDuration(minutes=30)
var var
clientPool {.threadvar.}: HttpPool clientPool: HttpPool
tokenPool {.threadvar.}: seq[Token] tokenPool: seq[Token]
lastFailed: Time lastFailed: Time
proc getPoolInfo*: string = proc getPoolInfo*: string =

View File

@ -1,14 +1,15 @@
# SPDX-License-Identifier: AGPL-3.0-only # SPDX-License-Identifier: AGPL-3.0-only
import strutils, strformat, sequtils, uri, tables, base64 import strutils, strformat, uri, tables, base64
import nimcrypto, regex import nimcrypto, regex
var var
hmacKey {.threadvar.}: string hmacKey: string
base64Media = false base64Media = false
const const
https* = "https://" https* = "https://"
twimg* = "pbs.twimg.com/" twimg* = "pbs.twimg.com/"
nitterParams = ["name", "tab", "id", "list", "referer", "scroll"]
twitterDomains = @[ twitterDomains = @[
"twitter.com", "twitter.com",
"pic.twitter.com", "pic.twitter.com",
@ -17,7 +18,6 @@ const
"pbs.twimg.com", "pbs.twimg.com",
"video.twimg.com" "video.twimg.com"
] ]
nitterParams = ["name", "tab", "id", "list", "referer", "scroll"]
proc setHmacKey*(key: string) = proc setHmacKey*(key: string) =
hmacKey = key hmacKey = key

View File

@ -86,7 +86,7 @@ proc renderHead*(prefs: Prefs; cfg: Config; titleText=""; desc=""; video="";
if banner.len > 0: if banner.len > 0:
let bannerUrl = getPicUrl(banner) let bannerUrl = getPicUrl(banner)
link(rel="preload", type="image/png", href=getPicUrl(banner), `as`="image") link(rel="preload", type="image/png", href=bannerUrl, `as`="image")
for url in images: for url in images:
let suffix = if "400x400" in url: "" else: "?name=small" let suffix = if "400x400" in url: "" else: "?name=small"