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]
|
[Config]
|
||||||
hmacKey = "secretkey" # random key for cryptographic signing of video urls
|
hmacKey = "secretkey" # random key for cryptographic signing of video urls
|
||||||
base64Media = false # use base64 encoding for proxied media urls
|
base64Media = false # use base64 encoding for proxied media urls
|
||||||
|
enableRSS = true # set this to false to disable RSS feeds
|
||||||
tokenCount = 10
|
tokenCount = 10
|
||||||
# minimum amount of usable tokens. tokens are used to authorize API requests,
|
# 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.
|
# 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
|
# 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
|
# always at least $tokenCount usable tokens. again, only increase this if
|
||||||
# you receive major bursts all the time
|
# 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
|
# Change default preferences here, see src/prefs_impl.nim for a complete list
|
||||||
[Preferences]
|
[Preferences]
|
||||||
|
|
|
@ -26,7 +26,7 @@ proc getConfig*(path: string): (Config, parseCfg.Config) =
|
||||||
hmacKey: cfg.get("Config", "hmacKey", "secretkey"),
|
hmacKey: cfg.get("Config", "hmacKey", "secretkey"),
|
||||||
base64Media: cfg.get("Config", "base64Media", false),
|
base64Media: cfg.get("Config", "base64Media", false),
|
||||||
minTokens: cfg.get("Config", "tokenCount", 10),
|
minTokens: cfg.get("Config", "tokenCount", 10),
|
||||||
enableRSS: cfg.get("Config", "enableRSS", true),
|
enableRss: cfg.get("Config", "enableRSS", true),
|
||||||
|
|
||||||
listCacheTime: cfg.get("Cache", "listMinutes", 120),
|
listCacheTime: cfg.get("Cache", "listMinutes", 120),
|
||||||
rssCacheTime: cfg.get("Cache", "rssMinutes", 10),
|
rssCacheTime: cfg.get("Cache", "rssMinutes", 10),
|
||||||
|
|
|
@ -48,7 +48,6 @@ createStatusRouter(cfg)
|
||||||
createSearchRouter(cfg)
|
createSearchRouter(cfg)
|
||||||
createMediaRouter(cfg)
|
createMediaRouter(cfg)
|
||||||
createEmbedRouter(cfg)
|
createEmbedRouter(cfg)
|
||||||
if cfg.enableRSS:
|
|
||||||
createRssRouter(cfg)
|
createRssRouter(cfg)
|
||||||
|
|
||||||
settings:
|
settings:
|
||||||
|
|
|
@ -52,6 +52,7 @@ template respRss*(rss) =
|
||||||
proc createRssRouter*(cfg: Config) =
|
proc createRssRouter*(cfg: Config) =
|
||||||
router rss:
|
router rss:
|
||||||
get "/search/rss":
|
get "/search/rss":
|
||||||
|
cond cfg.enableRss
|
||||||
if @"q".len > 200:
|
if @"q".len > 200:
|
||||||
resp Http400, showError("Search input too long.", cfg)
|
resp Http400, showError("Search input too long.", cfg)
|
||||||
|
|
||||||
|
@ -76,6 +77,7 @@ proc createRssRouter*(cfg: Config) =
|
||||||
respRss(rss)
|
respRss(rss)
|
||||||
|
|
||||||
get "/@name/rss":
|
get "/@name/rss":
|
||||||
|
cond cfg.enableRss
|
||||||
cond '.' notin @"name"
|
cond '.' notin @"name"
|
||||||
let
|
let
|
||||||
cursor = getCursor()
|
cursor = getCursor()
|
||||||
|
@ -92,6 +94,7 @@ proc createRssRouter*(cfg: Config) =
|
||||||
respRss(rss)
|
respRss(rss)
|
||||||
|
|
||||||
get "/@name/@tab/rss":
|
get "/@name/@tab/rss":
|
||||||
|
cond cfg.enableRss
|
||||||
cond '.' notin @"name"
|
cond '.' notin @"name"
|
||||||
cond @"tab" in ["with_replies", "media", "search"]
|
cond @"tab" in ["with_replies", "media", "search"]
|
||||||
let name = @"name"
|
let name = @"name"
|
||||||
|
@ -117,6 +120,7 @@ proc createRssRouter*(cfg: Config) =
|
||||||
respRss(rss)
|
respRss(rss)
|
||||||
|
|
||||||
get "/@name/lists/@list/rss":
|
get "/@name/lists/@list/rss":
|
||||||
|
cond cfg.enableRss
|
||||||
cond '.' notin @"name"
|
cond '.' notin @"name"
|
||||||
let
|
let
|
||||||
cursor = getCursor()
|
cursor = getCursor()
|
||||||
|
|
|
@ -216,7 +216,7 @@ type
|
||||||
hmacKey*: string
|
hmacKey*: string
|
||||||
base64Media*: bool
|
base64Media*: bool
|
||||||
minTokens*: int
|
minTokens*: int
|
||||||
enableRSS*: bool
|
enableRss*: bool
|
||||||
|
|
||||||
rssCacheTime*: int
|
rssCacheTime*: int
|
||||||
listCacheTime*: int
|
listCacheTime*: int
|
||||||
|
|
|
@ -25,7 +25,7 @@ proc renderNavbar*(cfg: Config, rss: string; req: Request): 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=twitterPath
|
icon "bird", title="Open in Twitter", href=twitterPath
|
||||||
a(href="https://liberapay.com/zedeus"): verbatim lp
|
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,
|
link(rel="search", type="application/opensearchdescription+xml", title=cfg.title,
|
||||||
href=opensearchUrl)
|
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")
|
link(rel="alternate", type="application/rss+xml", href=rss, title="RSS feed")
|
||||||
|
|
||||||
if prefs.hlsPlayback:
|
if prefs.hlsPlayback:
|
||||||
|
|
Loading…
Reference in a new issue