aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/doc_reform
diff options
context:
space:
mode:
Diffstat (limited to 'src/doc_reform')
-rw-r--r--src/doc_reform/io_in/read_config_files.d58
-rwxr-xr-xsrc/doc_reform/spine.d6
2 files changed, 52 insertions, 12 deletions
diff --git a/src/doc_reform/io_in/read_config_files.d b/src/doc_reform/io_in/read_config_files.d
index c0893de..cb673e0 100644
--- a/src/doc_reform/io_in/read_config_files.d
+++ b/src/doc_reform/io_in/read_config_files.d
@@ -14,24 +14,45 @@ static template readConfigSite() {
std.file,
std.path;
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[]);
@@ -54,6 +75,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;
diff --git a/src/doc_reform/spine.d b/src/doc_reform/spine.d
index 9dae5c4..4476b6d 100755
--- a/src/doc_reform/spine.d
+++ b/src/doc_reform/spine.d
@@ -537,13 +537,15 @@ void main(string[] args) {
];
auto _manifested = PathMatters!()(_opt_action, _env, "");
auto _manifests = [ _manifested ];
+ auto _conf_file_details = ConfigFilePaths!()(_manifested, _env, _opt_action.config_path_set);
ConfComposite _make_and_meta_struct;
if (_opt_action.config_path_set.empty) {
foreach(arg; args[1..$]) {
if (!(arg.match(rgx.flag_action))) { /+ cli markup source path +/ // get first input markup source file names for processing
_manifested = PathMatters!()(_opt_action, _env, arg);
{ /+ local site config +/
- auto _config_local_site_struct = readConfigSite!()(_manifested, _env);
+ _conf_file_details = ConfigFilePaths!()(_manifested, _env, _opt_action.config_path_set);
+ auto _config_local_site_struct = readConfigSite!()(_conf_file_details);
if (_config_local_site_struct.filetype == "yaml") {
import doc_reform.meta.conf_make_meta_yaml;
_make_and_meta_struct = _config_local_site_struct.configParseYAMLreturnSpineStruct!()(_make_and_meta_struct, _manifested); // - get local site config
@@ -554,7 +556,7 @@ void main(string[] args) {
}
} else {
{ /+ local site config +/
- auto _config_local_site_struct = readConfigSite!()(_manifested, _env, _opt_action.config_path_set);
+ auto _config_local_site_struct = readConfigSite!()(_conf_file_details);
if (_config_local_site_struct.filetype == "yaml") {
import doc_reform.meta.conf_make_meta_yaml;
_make_and_meta_struct = _config_local_site_struct.configParseYAMLreturnSpineStruct!()(_make_and_meta_struct, _manifested); // - get local site config