Improve enableRSS logic
This commit is contained in:
parent
9b202e414b
commit
0a8fd2fce2
6 changed files with 10 additions and 7 deletions
|
@ -22,13 +22,13 @@ redisMaxConnections = 30
|
|||
[Config]
|
||||
hmacKey = "secretkey" # random key for cryptographic signing of video urls
|
||||
base64Media = false # use base64 encoding for proxied media urls
|
||||
enableRSS = true # set this to false to disable RSS feeds
|
||||
tokenCount = 10
|
||||
# minimum amount of usable tokens. tokens are used to authorize API requests,
|
||||
# but they expire after ~1 hour, and have a limit of 187 requests.
|
||||
# the limit gets reset every 15 minutes, and the pool is filled up so there's
|
||||
# always at least $tokenCount usable tokens. again, only increase this if
|
||||
# you receive major bursts all the time
|
||||
enableRSS = true # set this to false to disable RSS feeds
|
||||
|
||||
# Change default preferences here, see src/prefs_impl.nim for a complete list
|
||||
[Preferences]
|
||||
|
|
|
@ -26,7 +26,7 @@ proc getConfig*(path: string): (Config, parseCfg.Config) =
|
|||
hmacKey: cfg.get("Config", "hmacKey", "secretkey"),
|
||||
base64Media: cfg.get("Config", "base64Media", false),
|
||||
minTokens: cfg.get("Config", "tokenCount", 10),
|
||||
enableRSS: cfg.get("Config", "enableRSS", true),
|
||||
enableRss: cfg.get("Config", "enableRSS", true),
|
||||
|
||||
listCacheTime: cfg.get("Cache", "listMinutes", 120),
|
||||
rssCacheTime: cfg.get("Cache", "rssMinutes", 10),
|
||||
|
|
|
@ -48,7 +48,6 @@ createStatusRouter(cfg)
|
|||
createSearchRouter(cfg)
|
||||
createMediaRouter(cfg)
|
||||
createEmbedRouter(cfg)
|
||||
if cfg.enableRSS:
|
||||
createRssRouter(cfg)
|
||||
|
||||
settings:
|
||||
|
|
|
@ -52,6 +52,7 @@ template respRss*(rss) =
|
|||
proc createRssRouter*(cfg: Config) =
|
||||
router rss:
|
||||
get "/search/rss":
|
||||
cond cfg.enableRss
|
||||
if @"q".len > 200:
|
||||
resp Http400, showError("Search input too long.", cfg)
|
||||
|
||||
|
@ -76,6 +77,7 @@ proc createRssRouter*(cfg: Config) =
|
|||
respRss(rss)
|
||||
|
||||
get "/@name/rss":
|
||||
cond cfg.enableRss
|
||||
cond '.' notin @"name"
|
||||
let
|
||||
cursor = getCursor()
|
||||
|
@ -92,6 +94,7 @@ proc createRssRouter*(cfg: Config) =
|
|||
respRss(rss)
|
||||
|
||||
get "/@name/@tab/rss":
|
||||
cond cfg.enableRss
|
||||
cond '.' notin @"name"
|
||||
cond @"tab" in ["with_replies", "media", "search"]
|
||||
let name = @"name"
|
||||
|
@ -117,6 +120,7 @@ proc createRssRouter*(cfg: Config) =
|
|||
respRss(rss)
|
||||
|
||||
get "/@name/lists/@list/rss":
|
||||
cond cfg.enableRss
|
||||
cond '.' notin @"name"
|
||||
let
|
||||
cursor = getCursor()
|
||||
|
|
|
@ -216,7 +216,7 @@ type
|
|||
hmacKey*: string
|
||||
base64Media*: bool
|
||||
minTokens*: int
|
||||
enableRSS*: bool
|
||||
enableRss*: bool
|
||||
|
||||
rssCacheTime*: int
|
||||
listCacheTime*: int
|
||||
|
|
|
@ -25,7 +25,7 @@ proc renderNavbar*(cfg: Config, rss: string; req: Request): VNode =
|
|||
|
||||
tdiv(class="nav-item right"):
|
||||
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 "bird", title="Open in Twitter", href=twitterPath
|
||||
a(href="https://liberapay.com/zedeus"): verbatim lp
|
||||
|
@ -58,7 +58,7 @@ proc renderHead*(prefs: Prefs; cfg: Config; titleText=""; desc=""; video="";
|
|||
link(rel="search", type="application/opensearchdescription+xml", title=cfg.title,
|
||||
href=opensearchUrl)
|
||||
|
||||
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")
|
||||
|
||||
if prefs.hlsPlayback:
|
||||
|
|
Loading…
Reference in a new issue