mirror of
https://github.com/zedeus/nitter.git
synced 2025-03-28 20:06:53 +00:00
Add a `hostname` field under Server in your conf file, see the updated nitter.conf in the repo for an example. The compile-time option (-d:hostname) is no longer used.
41 lines
981 B
Nim
41 lines
981 B
Nim
import strutils, uri
|
|
|
|
import jester
|
|
|
|
import router_utils
|
|
import ".."/[types]
|
|
import ../views/[general, preferences]
|
|
|
|
export preferences
|
|
|
|
proc createPrefRouter*(cfg: Config) =
|
|
router preferences:
|
|
template savePrefs(): untyped =
|
|
setCookie("preferences", $prefs.id, daysForward(360), httpOnly=true, secure=cfg.useHttps)
|
|
|
|
get "/settings":
|
|
let html = renderPreferences(cookiePrefs(), refPath())
|
|
resp renderMain(html, request, cfg, "Preferences")
|
|
|
|
get "/settings/@i?":
|
|
redirect("/settings")
|
|
|
|
post "/saveprefs":
|
|
var prefs = cookiePrefs()
|
|
genUpdatePrefs()
|
|
savePrefs()
|
|
redirect(refPath())
|
|
|
|
post "/resetprefs":
|
|
var prefs = cookiePrefs()
|
|
resetPrefs(prefs, cfg.hostname)
|
|
savePrefs()
|
|
redirect($(parseUri("/settings") ? filterParams(request.params)))
|
|
|
|
post "/enablehls":
|
|
var prefs = cookiePrefs()
|
|
prefs.hlsPlayback = true
|
|
cache(prefs)
|
|
savePrefs()
|
|
redirect(refPath())
|