about summary refs log tree commit diff stats
path: root/src/config
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2023-05-29 01:41:15 +0200
committerbptato <nincsnevem662@gmail.com>2023-06-01 13:01:44 +0200
commit245a2067ef8204dd6a260e1bdc415981243f549b (patch)
tree46ca4b7618766df1a358fa33567a00739b9772be /src/config
parentd48aa61fd8e3595a8ae90cfacc9f35318acbe8d4 (diff)
downloadchawan-245a2067ef8204dd6a260e1bdc415981243f549b.tar.gz
Fix more config inconsistencies
So that the default config actually works again. Also some doc updates.
Diffstat (limited to 'src/config')
-rw-r--r--src/config/config.nim45
1 files changed, 23 insertions, 22 deletions
diff --git a/src/config/config.nim b/src/config/config.nim
index 5817bdc2..90402149 100644
--- a/src/config/config.nim
+++ b/src/config/config.nim
@@ -28,32 +28,32 @@ type
   StaticSiteConfig = object
     url: Option[string]
     host: Option[string]
-    subst: Option[string]
+    rewrite_url: Option[string]
     cookie: Option[bool]
-    thirdpartycookie: seq[string]
-    sharecookiejar: Option[string]
-    refererfrom*: Option[bool]
+    third_party_cookie: seq[string]
+    share_cookie_jar: Option[string]
+    referer_from*: Option[bool]
     scripting: Option[bool]
     document_charset: seq[Charset]
 
   StaticOmniRule = object
     match: string
-    subst: string
+    substitute_url: string
 
   SiteConfig* = object
     url*: Option[Regex]
     host*: Option[Regex]
-    subst*: (proc(s: URL): Option[URL])
+    rewrite_url*: (proc(s: URL): Option[URL])
     cookie*: Option[bool]
-    thirdpartycookie*: seq[Regex]
-    sharecookiejar*: Option[string]
-    refererfrom*: Option[bool]
+    third_party_cookie*: seq[Regex]
+    share_cookie_jar*: Option[string]
+    referer_from*: Option[bool]
     scripting*: Option[bool]
     document_charset*: seq[Charset]
 
   OmniRule* = object
     match*: Regex
-    subst*: (proc(s: string): Option[string])
+    substitute_url*: (proc(s: string): Option[string])
 
   StartConfig = object
     visual_home*: string
@@ -110,7 +110,7 @@ type
     filter*: URLFilter
     cookiejar*: CookieJar
     headers*: Headers
-    refererfrom*: bool
+    referer_from*: bool
     referrerpolicy*: ReferrerPolicy
     scripting*: bool
     charsets*: seq[Charset]
@@ -134,14 +134,14 @@ func getForkServerConfig*(config: Config): ForkServerConfig =
   )
 
 proc getBufferConfig*(config: Config, location: URL, cookiejar: CookieJar = nil,
-      headers: Headers = nil, refererfrom = false, scripting = false,
+      headers: Headers = nil, referer_from = false, scripting = false,
       charsets = config.encoding.document_charset): BufferConfig =
   result = BufferConfig(
     userstyle: config.css.stylesheet,
     filter: newURLFilter(scheme = some(location.scheme), default = true),
     cookiejar: cookiejar,
     headers: headers,
-    refererfrom: refererfrom,
+    referer_from: referer_from,
     scripting: scripting,
     charsets: charsets
   )
@@ -153,20 +153,21 @@ proc getSiteConfig*(config: Config, jsctx: JSContext): seq[SiteConfig] =
     var conf = SiteConfig(
       cookie: sc.cookie,
       scripting: sc.scripting,
-      sharecookiejar: sc.sharecookiejar,
-      refererfrom: sc.refererfrom,
+      share_cookie_jar: sc.share_cookie_jar,
+      referer_from: sc.referer_from,
       document_charset: sc.document_charset
     )
     if sc.url.isSome:
       conf.url = compileRegex(sc.url.get, 0)
     elif sc.host.isSome:
       conf.host = compileRegex(sc.host.get, 0)
-    for rule in sc.thirdpartycookie:
-      conf.thirdpartycookie.add(compileRegex(rule, 0).get)
-    if sc.subst.isSome:
-      let fun = jsctx.eval(sc.subst.get, "<siteconf>", JS_EVAL_TYPE_GLOBAL)
+    for rule in sc.third_party_cookie:
+      conf.third_party_cookie.add(compileRegex(rule, 0).get)
+    if sc.rewrite_url.isSome:
+      let fun = jsctx.eval(sc.rewrite_url.get, "<siteconf>",
+        JS_EVAL_TYPE_GLOBAL)
       let f = getJSFunction[URL, URL](jsctx, fun)
-      conf.subst = f.get
+      conf.rewrite_url = f.get
     result.add(conf)
 
 proc getOmniRules*(config: Config, jsctx: JSContext): seq[OmniRule] =
@@ -175,9 +176,9 @@ proc getOmniRules*(config: Config, jsctx: JSContext): seq[OmniRule] =
     var conf = OmniRule(
       match: re.get
     )
-    let fun = jsctx.eval(rule.subst, "<siteconf>", JS_EVAL_TYPE_GLOBAL)
+    let fun = jsctx.eval(rule.substitute_url, "<siteconf>", JS_EVAL_TYPE_GLOBAL)
     let f = getJSFunction[string, string](jsctx, fun)
-    conf.subst = f.get
+    conf.substitute_url = f.get
     result.add(conf)
 
 func getRealKey(key: string): string =