mirror of
https://github.com/zedeus/nitter.git
synced 2024-12-13 03:26:30 +00:00
Improve and simplify preferences page behavior
This commit is contained in:
parent
ab51ff06c8
commit
bb981df657
5 changed files with 8 additions and 12 deletions
|
@ -118,7 +118,7 @@ proc getBanner*(js: JsonNode): string =
|
||||||
if color.len > 0:
|
if color.len > 0:
|
||||||
return '#' & color
|
return '#' & color
|
||||||
|
|
||||||
# use primary color from profile picture color histrogram
|
# use primary color from profile picture color histogram
|
||||||
with p, js{"profile_image_extensions", "mediaColor", "r", "ok", "palette"}:
|
with p, js{"profile_image_extensions", "mediaColor", "r", "ok", "palette"}:
|
||||||
if p.len > 0:
|
if p.len > 0:
|
||||||
let pal = p[0]{"rgb"}
|
let pal = p[0]{"rgb"}
|
||||||
|
|
|
@ -32,7 +32,7 @@ proc createPrefRouter*(cfg: Config) =
|
||||||
|
|
||||||
post "/resetprefs":
|
post "/resetprefs":
|
||||||
genResetPrefs()
|
genResetPrefs()
|
||||||
redirect($(parseUri("/settings") ? filterParams(request.params)))
|
redirect("/settings?referer=" & encodeUrl(refPath()))
|
||||||
|
|
||||||
post "/enablehls":
|
post "/enablehls":
|
||||||
savePref("hlsPlayback", "on", request)
|
savePref("hlsPlayback", "on", request)
|
||||||
|
|
|
@ -12,8 +12,10 @@ const
|
||||||
lp = readFile("public/lp.svg")
|
lp = readFile("public/lp.svg")
|
||||||
|
|
||||||
proc renderNavbar(cfg: Config; req: Request; rss, canonical: string): VNode =
|
proc renderNavbar(cfg: Config; req: Request; rss, canonical: string): VNode =
|
||||||
var path = $(parseUri(req.path) ? filterParams(req.params))
|
var path = req.params.getOrDefault("referer")
|
||||||
if "/status" in path: path.add "#m"
|
if path.len == 0:
|
||||||
|
path = $(parseUri(req.path) ? filterParams(req.params))
|
||||||
|
if "/status/" in path: path.add "#m"
|
||||||
|
|
||||||
buildHtml(nav):
|
buildHtml(nav):
|
||||||
tdiv(class="inner-nav"):
|
tdiv(class="inner-nav"):
|
||||||
|
@ -29,7 +31,7 @@ proc renderNavbar(cfg: Config; req: Request; rss, canonical: string): VNode =
|
||||||
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"
|
||||||
iconReferer "cog", "/settings", path, title="Preferences"
|
icon "cog", title="Preferences", href=("/settings?referer=" & encodeUrl(path))
|
||||||
|
|
||||||
proc renderHead*(prefs: Prefs; cfg: Config; titleText=""; desc=""; video="";
|
proc renderHead*(prefs: Prefs; cfg: Config; titleText=""; desc=""; video="";
|
||||||
images: seq[string] = @[]; banner=""; ogTitle=""; theme="";
|
images: seq[string] = @[]; banner=""; ogTitle=""; theme="";
|
||||||
|
|
|
@ -46,4 +46,4 @@ proc renderPreferences*(prefs: Prefs; path: string; themes: seq[string]): VNode
|
||||||
button(`type`="submit", class="pref-submit"):
|
button(`type`="submit", class="pref-submit"):
|
||||||
text "Save preferences"
|
text "Save preferences"
|
||||||
|
|
||||||
buttonReferer "/resetprefs", "Reset Preferences", path, class="pref-reset"
|
buttonReferer "/resetprefs", "Reset preferences", path, class="pref-reset"
|
||||||
|
|
|
@ -42,12 +42,6 @@ proc hiddenField*(name, value: string): VNode =
|
||||||
proc refererField*(path: string): VNode =
|
proc refererField*(path: string): VNode =
|
||||||
hiddenField("referer", path)
|
hiddenField("referer", path)
|
||||||
|
|
||||||
proc iconReferer*(icon, action, path: string, title=""): VNode =
|
|
||||||
buildHtml(form(`method`="get", action=action, class="icon-button")):
|
|
||||||
refererField path
|
|
||||||
button(`type`="submit"):
|
|
||||||
icon icon, title=title
|
|
||||||
|
|
||||||
proc buttonReferer*(action, text, path: string; class=""; `method`="post"): VNode =
|
proc buttonReferer*(action, text, path: string; class=""; `method`="post"): VNode =
|
||||||
buildHtml(form(`method`=`method`, action=action, class=class)):
|
buildHtml(form(`method`=`method`, action=action, class=class)):
|
||||||
refererField path
|
refererField path
|
||||||
|
|
Loading…
Reference in a new issue