diff options
Diffstat (limited to 'org/in_source_files.org')
-rw-r--r-- | org/in_source_files.org | 58 |
1 files changed, 48 insertions, 10 deletions
diff --git a/org/in_source_files.org b/org/in_source_files.org index b5496b5..4c61ecc 100644 --- a/org/in_source_files.org +++ b/org/in_source_files.org @@ -51,24 +51,45 @@ static template readConfigSite() { doc_reform.meta.rgx; <<imports_std>> mixin spineRgxInit; - final auto readConfigSite(M,E)( - M _manifested, - E _env, - string _cli_config_path_set = "" - ) { + final auto readConfigSite(C)(C _conf_file_details) { static auto rgx = Rgx(); - string config_file_str; string conf_filename = "NONE"; - auto _conf_file_details = ConfigFilePaths!()(_manifested, _env, _cli_config_path_set); - string[] possible_config_path_locations = _conf_file_details.possible_config_path_locations.config_local_site; + string config_file_str; + string default_config_file_str = format(q"┃ +flag: + act0: --html + act1: --html --epub +#output: +# path: "" +default: + language: "en" + papersize: "a4" + text_wrap: "80" + digest: "sha256" +search: + title: "" + flag: "" + action: "" + db: "" +webserv: + url_domain: "not-configured" + url_root: "doc" + doc_path: "doc" + images: "" + cgi: "" + cgi_host: "" + cgi_host_path: "" + cgi_port: "" + cgi_user: "" +┃"); foreach(conf_fn; [_conf_file_details.config_filename_site]) { - foreach(pth; possible_config_path_locations) { + foreach(pth; _conf_file_details.possible_config_path_locations.config_local_site) { char[] conf_file; conf_filename = conf_fn; if (exists(pth)) { auto f_attrib = pth.getLinkAttributes; if ( - possible_config_path_locations.length == 1 + _conf_file_details.possible_config_path_locations.config_local_site.length == 1 && f_attrib.attrIsFile ) { conf_file = pth.to!(char[]); @@ -91,6 +112,23 @@ static template readConfigSite() { } if (config_file_str.length > 0) { break; } } + if (config_file_str.length > 0) { + import dyaml; + Node yaml_root; + try { + yaml_root = Loader.fromString(config_file_str).load(); + } catch { + import std.stdio; + writeln("ERROR failed to read config file content, not parsed as yaml, program default used"); + conf_filename = "VIRTUAL"; + config_file_str = default_config_file_str; + } + } + if (config_file_str.length == 0) { /+ create dummy default config file +/ + writeln("WARNING config file NOT found, default provided"); + conf_filename = "VIRTUAL"; + config_file_str = default_config_file_str; + } struct _ConfContent { string filename() { return conf_filename; |