mirror of
https://github.com/zedeus/nitter.git
synced 2024-12-12 02:56:29 +00:00
Add button to reset preferences
This commit is contained in:
parent
fdd71946da
commit
9fc512d88d
4 changed files with 27 additions and 6 deletions
|
@ -1092,10 +1092,6 @@ legend {
|
||||||
margin: .2em; 0;
|
margin: .2em; 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.pref-submit:hover {
|
|
||||||
background-color: #a8a8a8;
|
|
||||||
}
|
|
||||||
|
|
||||||
.pref-submit {
|
.pref-submit {
|
||||||
background-color: #e2e2e2;
|
background-color: #e2e2e2;
|
||||||
color: #000;
|
color: #000;
|
||||||
|
@ -1106,6 +1102,15 @@ legend {
|
||||||
margin-top: 4px;
|
margin-top: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.pref-submit:hover {
|
||||||
|
background-color: #a8a8a8;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pref-reset {
|
||||||
|
float: right;
|
||||||
|
margin-top: -25px;
|
||||||
|
}
|
||||||
|
|
||||||
.icon-container {
|
.icon-container {
|
||||||
display: inline;
|
display: inline;
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,6 +95,12 @@ routes:
|
||||||
setCookie("preferences", $prefs.id, daysForward(360), httpOnly=true, secure=true)
|
setCookie("preferences", $prefs.id, daysForward(360), httpOnly=true, secure=true)
|
||||||
redirect("/settings")
|
redirect("/settings")
|
||||||
|
|
||||||
|
post "/resetprefs":
|
||||||
|
var prefs = getCookiePrefs(request)
|
||||||
|
resetPrefs(prefs)
|
||||||
|
setCookie("preferences", $prefs.id, daysForward(360), httpOnly=true, secure=true)
|
||||||
|
redirect("/settings")
|
||||||
|
|
||||||
get "/settings":
|
get "/settings":
|
||||||
let prefs = getCookiePrefs(request)
|
let prefs = getCookiePrefs(request)
|
||||||
resp renderMain(renderPreferences(prefs), prefs, title=cfg.title, titleText="Preferences")
|
resp renderMain(renderPreferences(prefs), prefs, title=cfg.title, titleText="Preferences")
|
||||||
|
|
|
@ -96,6 +96,12 @@ proc getPrefs*(id: string): Prefs =
|
||||||
result = genDefaultPrefs()
|
result = genDefaultPrefs()
|
||||||
cache(result)
|
cache(result)
|
||||||
|
|
||||||
|
proc resetPrefs*(prefs: var Prefs) =
|
||||||
|
var defPrefs = genDefaultPrefs()
|
||||||
|
defPrefs.id = prefs.id
|
||||||
|
cache(defPrefs)
|
||||||
|
prefs = defPrefs
|
||||||
|
|
||||||
macro genUpdatePrefs*(): untyped =
|
macro genUpdatePrefs*(): untyped =
|
||||||
result = nnkStmtList.newTree()
|
result = nnkStmtList.newTree()
|
||||||
|
|
||||||
|
|
|
@ -53,9 +53,13 @@ macro renderPrefs*(): untyped =
|
||||||
|
|
||||||
proc renderPreferences*(prefs: Prefs): VNode =
|
proc renderPreferences*(prefs: Prefs): VNode =
|
||||||
buildHtml(tdiv(class="preferences-container")):
|
buildHtml(tdiv(class="preferences-container")):
|
||||||
form(class="preferences", `method`="post", action="saveprefs"):
|
fieldset(class="preferences"):
|
||||||
fieldset:
|
form(`method`="post", action="saveprefs"):
|
||||||
renderPrefs()
|
renderPrefs()
|
||||||
|
|
||||||
button(`type`="submit", class="pref-submit"):
|
button(`type`="submit", class="pref-submit"):
|
||||||
text "Save preferences"
|
text "Save preferences"
|
||||||
|
|
||||||
|
form(`method`="post", action="resetprefs", class="pref-reset"):
|
||||||
|
button(`type`="submit", class="pref-submit"):
|
||||||
|
text "Reset preferences"
|
||||||
|
|
Loading…
Reference in a new issue