diff options
author | bptato <nincsnevem662@gmail.com> | 2022-12-18 20:46:30 +0100 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2022-12-18 20:46:30 +0100 |
commit | bfaf210d87e90016f8f2521657bd04686170aa43 (patch) | |
tree | e9711cb2f72174058d88ce2d52a76239e3c54c62 /src/config | |
parent | 1fbe17eeddefb87bf8e819be7792ae7a6482d8f8 (diff) | |
download | chawan-bfaf210d87e90016f8f2521657bd04686170aa43.tar.gz |
Add JS support to documents
Diffstat (limited to 'src/config')
-rw-r--r-- | src/config/config.nim | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/config/config.nim b/src/config/config.nim index 4ab2d49b..7ed1441a 100644 --- a/src/config/config.nim +++ b/src/config/config.nim @@ -31,6 +31,7 @@ type thirdpartycookie: seq[string] sharecookiejar: Option[string] refererfrom*: Option[bool] + scripting: Option[bool] StaticOmniRule = object match: string @@ -44,6 +45,7 @@ type thirdpartycookie*: seq[Regex] sharecookiejar*: Option[string] refererfrom*: Option[bool] + scripting*: Option[bool] OmniRule* = object match*: Regex @@ -81,6 +83,7 @@ type headers*: HeaderList refererfrom*: bool referrerpolicy*: ReferrerPolicy + scripting*: bool ForkServerConfig* = object tmpdir*: string @@ -101,13 +104,14 @@ func getForkServerConfig*(config: Config): ForkServerConfig = ) proc getBufferConfig*(config: Config, location: URL, cookiejar: CookieJar = nil, - headers: HeaderList = nil, refererfrom = false): BufferConfig = + headers: HeaderList = nil, refererfrom = false, scripting = false): BufferConfig = result = BufferConfig( userstyle: config.stylesheet, filter: newURLFilter(scheme = some(location.scheme), default = true), cookiejar: cookiejar, headers: headers, - refererfrom: refererfrom + refererfrom: refererfrom, + scripting: scripting ) new(result.headers) result.headers[] = DefaultHeaders @@ -116,6 +120,7 @@ proc getSiteConfig*(config: Config, jsctx: JSContext): seq[SiteConfig] = for sc in config.siteconf: var conf = SiteConfig( cookie: sc.cookie, + scripting: sc.scripting, sharecookiejar: sc.sharecookiejar, refererfrom: sc.refererfrom ) @@ -127,7 +132,7 @@ proc getSiteConfig*(config: Config, jsctx: JSContext): seq[SiteConfig] = conf.thirdpartycookie.add(compileRegex(rule, 0).get) if sc.subst.isSome: let fun = jsctx.eval(sc.subst.get, "<siteconf>", JS_EVAL_TYPE_GLOBAL) - let f = getJSFunction[URL, URL](jsctx, fun.val) + let f = getJSFunction[URL, URL](jsctx, fun) conf.subst = f.get result.add(conf) @@ -138,7 +143,7 @@ proc getOmniRules*(config: Config, jsctx: JSContext): seq[OmniRule] = match: re.get ) let fun = jsctx.eval(rule.subst, "<siteconf>", JS_EVAL_TYPE_GLOBAL) - let f = getJSFunction[string, string](jsctx, fun.val) + let f = getJSFunction[string, string](jsctx, fun) conf.subst = f.get result.add(conf) @@ -357,6 +362,7 @@ proc parseConfig(config: Config, dir: string, t: TomlValue) = for v in v.a: conf.thirdpartycookie.add(v.s) of "share-cookie-jar": conf.sharecookiejar = some(v.s) + of "scripting": conf.scripting = some(v.b) assert conf.url.isSome != conf.host.isSome config.siteconf.add(conf) of "omnirule": |