Go back to previous page when saving settings
This commit is contained in:
parent
ed327bac24
commit
3f7ccb5525
2 changed files with 10 additions and 3 deletions
|
@ -90,7 +90,7 @@ routes:
|
||||||
var prefs = cookiePrefs()
|
var prefs = cookiePrefs()
|
||||||
genUpdatePrefs()
|
genUpdatePrefs()
|
||||||
setCookie("preferences", $prefs.id, daysForward(360), httpOnly=true, secure=cfg.useHttps)
|
setCookie("preferences", $prefs.id, daysForward(360), httpOnly=true, secure=cfg.useHttps)
|
||||||
redirect("/")
|
redirect(decodeUrl(@"referer"))
|
||||||
|
|
||||||
post "/resetprefs":
|
post "/resetprefs":
|
||||||
var prefs = cookiePrefs()
|
var prefs = cookiePrefs()
|
||||||
|
@ -99,7 +99,12 @@ routes:
|
||||||
redirect("/settings")
|
redirect("/settings")
|
||||||
|
|
||||||
get "/settings":
|
get "/settings":
|
||||||
resp renderMain(renderPreferences(cookiePrefs()), cfg.title, "Preferences")
|
let refUri = request.headers.getOrDefault("Referer").parseUri()
|
||||||
|
var path =
|
||||||
|
if refUri.path.len > 0 and "/settings" notin refUri.path: refUri.path
|
||||||
|
else: "/"
|
||||||
|
if refUri.query.len > 0: path &= &"?{refUri.query}"
|
||||||
|
resp renderMain(renderPreferences(cookiePrefs(), path), cfg.title, "Preferences")
|
||||||
|
|
||||||
get "/@name/?":
|
get "/@name/?":
|
||||||
cond '.' notin @"name"
|
cond '.' notin @"name"
|
||||||
|
|
|
@ -51,10 +51,12 @@ macro renderPrefs*(): untyped =
|
||||||
|
|
||||||
result[2].add stmt
|
result[2].add stmt
|
||||||
|
|
||||||
proc renderPreferences*(prefs: Prefs): VNode =
|
proc renderPreferences*(prefs: Prefs; path: string): VNode =
|
||||||
buildHtml(tdiv(class="preferences-container")):
|
buildHtml(tdiv(class="preferences-container")):
|
||||||
fieldset(class="preferences"):
|
fieldset(class="preferences"):
|
||||||
form(`method`="post", action="saveprefs"):
|
form(`method`="post", action="saveprefs"):
|
||||||
|
verbatim "<input name=\"referer\" style=\"display: none\" value=\"$1\"/>" % path
|
||||||
|
|
||||||
renderPrefs()
|
renderPrefs()
|
||||||
|
|
||||||
button(`type`="submit", class="pref-submit"):
|
button(`type`="submit", class="pref-submit"):
|
||||||
|
|
Loading…
Reference in a new issue