2021-12-27 01:37:38 +00:00
|
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
2020-05-08 00:48:47 +00:00
|
|
|
import tables
|
|
|
|
import types, prefs_impl
|
|
|
|
from config import get
|
|
|
|
from parsecfg import nil
|
2019-08-13 17:44:29 +00:00
|
|
|
|
2020-05-08 00:48:47 +00:00
|
|
|
export genUpdatePrefs, genResetPrefs
|
2019-08-15 16:41:35 +00:00
|
|
|
|
2022-01-02 10:21:03 +00:00
|
|
|
var defaultPrefs*: Prefs
|
2019-10-23 10:32:23 +00:00
|
|
|
|
2020-05-08 00:48:47 +00:00
|
|
|
proc updateDefaultPrefs*(cfg: parsecfg.Config) =
|
|
|
|
genDefaultPrefs()
|
2019-09-08 10:22:52 +00:00
|
|
|
|
2020-05-08 00:48:47 +00:00
|
|
|
proc getPrefs*(cookies: Table[string, string]): Prefs =
|
|
|
|
result = defaultPrefs
|
2020-06-09 14:45:21 +00:00
|
|
|
genCookiePrefs(cookies)
|
|
|
|
|
|
|
|
template getPref*(cookies: Table[string, string], pref): untyped =
|
|
|
|
bind genCookiePref
|
|
|
|
var res = defaultPrefs.`pref`
|
|
|
|
genCookiePref(cookies, pref, res)
|
|
|
|
res
|