From 1c73ddf3894085c646b55d63e61a2483e03a3b4d Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Fri, 9 Feb 2018 22:03:10 -0500 Subject: 0.24.0 toml or sdlang for configuration --- src/sdp/output/paths_output.d | 2 +- src/sdp/output/paths_source.d | 49 +++++++++++++++++++++++++++------- src/sdp/output/rgx.d | 6 ++++- src/sdp/output/source_sisupod.d | 58 +++++++++++++++++++++-------------------- 4 files changed, 75 insertions(+), 40 deletions(-) (limited to 'src/sdp/output') diff --git a/src/sdp/output/paths_output.d b/src/sdp/output/paths_output.d index 537de45..1db74d9 100644 --- a/src/sdp/output/paths_output.d +++ b/src/sdp/output/paths_output.d @@ -185,7 +185,7 @@ template SiSUpathsSQLiteDiscrete() { return fn_src.baseName.stripExtension; } string base() { - return asNormalizedPath((out_pth.output_base).chainPath(base_dir)).array; + return asNormalizedPath((out_pth.output_root).chainPath(base_dir)).array; } string seg(string fn_src) { return asNormalizedPath(base.chainPath(base_filename(fn_src))).array; diff --git a/src/sdp/output/paths_source.d b/src/sdp/output/paths_source.d index 731fff3..3292e6f 100644 --- a/src/sdp/output/paths_source.d +++ b/src/sdp/output/paths_source.d @@ -29,9 +29,15 @@ template PodManifest() { && (_pth.chainPath(pod_manifest_filename).array).isFile)) { _manifest_path = _pth; } else if (_pth.match(rgx.src_pth_contents) - && exists(_pth)!=0 && _pth.isDir && (_pth.isFile)) { + && exists(_pth)!=0 && _pth.isDir) { _manifest_path = dirName(_pth); + } else if (_pth.match(rgx.src_pth_pod_sst_or_ssm) + && exists(_pth)!=0 && (_pth.isFile)) { + if (auto m = _pth.match(rgx.src_pth_pod_sst_or_ssm)) { + _manifest_path = m.captures["podpath"]; + } } else { + writeln("WARNING, issue with manifest_path: ", _pth); _manifest_path = _pth; // _manifest_path = null; } return _manifest_path; @@ -94,6 +100,15 @@ template PathMatters() { auto _src_is_pod = (_manifest.pod_manifest_path.length > 0) ? true : false; return _src_is_pod; } + auto collection_root() { + auto _collection_root = asNormalizedPath(chainPath(_manifest.pod_manifest_path, "..")).array; + if (auto m = (_collection_root).match(rgx.src_pth_pod_root)) { + // consider testing for last dir in path name being sisupod, and giving warning if not + } else { + writeln("WARNING, collection_root not named \"sisupod\""); + } + return _collection_root; + } auto manifest_filename() { return _manifest.pod_manifest_filename; } @@ -103,7 +118,11 @@ template PathMatters() { auto manifest_file_with_path() { return _manifest.pod_manifest_file_with_path; } - auto config_dirs() { // TODO + auto config_sisu_document_make_dirs() { // TODO sisu_document_make + string[] _config_dirs; + return _config_dirs; + } + auto config_local_site_dirs() { // TODO sisu_document_make string[] _config_dirs; return _config_dirs; } @@ -292,12 +311,21 @@ template ConfigFilePaths() { E _env, ) { struct ConfFilePaths { - auto config_filename_document() { - return "config_document"; + auto config_filename_document_sdl() { + return "sisu_document_make.sdl"; + } + auto config_filename_site_sdl() { + return "config_local_site.sdl"; + } + auto config_filename_document_toml() { + return "sisu_document_make.toml"; + } + auto config_filename_site_toml() { + return "config_local_site.toml"; } auto possible_config_path_locations() { struct _ConfFilePaths { - auto document() { + auto sisu_document_make() { /+ FIX clean up conf paths ↓ +/ /+ config local site (file system only, not in pod) +/ /+ return paths +/ @@ -340,10 +368,7 @@ template ConfigFilePaths() { +/ return _possible_config_path_locations; } - auto config_filename_site() { - return "config_local_site"; - } - auto local_site() { + auto config_local_site() { /+ FIX clean up conf paths ↓ +/ /+ config local site (file system only, not in pod) +/ string _dot_pwd = asNormalizedPath(chainPath(to!string(_env["pwd"]), ".sisu")).array; @@ -352,11 +377,15 @@ template ConfigFilePaths() { /+ return paths +/ string[] _possible_config_path_locations; if (_manifest.src.is_pod) { + string _collection_root_a = asNormalizedPath(chainPath(to!string(_manifest.pod.collection_root.to!string), ".sisu")).array; + string _collection_root_b = asNormalizedPath(chainPath(to!string(_manifest.pod.collection_root.to!string), "_sisu")).array; _possible_config_path_locations = [ _dot_pwd, _underscore_pwd, _dot_home, - "/etc/sisu" + "/etc/sisu", + _collection_root_a, // set priority higher? + _collection_root_b // set priority higher? ]; } else { /+ config document (& or local site) on filesystem +/ diff --git a/src/sdp/output/rgx.d b/src/sdp/output/rgx.d index c962937..c125b7e 100644 --- a/src/sdp/output/rgx.d +++ b/src/sdp/output/rgx.d @@ -16,7 +16,9 @@ static template SiSUoutputRgxInit() { static nbsp_and_space = ctRegex!(` [ ]`, "mg"); static nbsp_char_and_space = ctRegex!(`░[ ]`, "mg"); static src_pth_sst_or_ssm = ctRegex!(`^(?P[/]?(?:[a-zA-Z0-9._-]+/)*)(?P[a-zA-Z0-9._-]+[.]ss[tm])$`); + static src_pth_pod_sst_or_ssm = ctRegex!(`^(?P[/]?(?:[a-zA-Z0-9._-]+/)*)media/text/[a-z]{2}/(?P[a-zA-Z0-9._-]+[.]ss[tm])$`); static src_pth_contents = ctRegex!(`^(?P[/]?(?:[a-zA-Z0-9._-]+/)*)(?P[a-zA-Z0-9._-]+)/sisupod[.]manifest$`); + static src_pth_pod_root = ctRegex!(`^(?P(?:[/]?(?:[a-zA-Z0-9._-]+/)*)(sisupod))$`); static src_pth_zip = ctRegex!(`^(?P[/]?(?:[a-zA-Z0-9._-]+/)*)(?P[a-zA-Z0-9._-]+[.]zip)$`); static src_pth_unzip_pod = ctRegex!(`^(?Pmedia/text/[a-z]{2}/)*(?P[a-zA-Z0-9._-]+[.]ss[im])$`); static src_pth_types = @@ -31,7 +33,8 @@ static template SiSUoutputRgxInit() { static src_fn_find_inserts = ctRegex!(`^(?P[a-zA-Z0-9._-]+/)*(?P[a-zA-Z0-9._-]+[.]ss[im])$`); static insert_src_fn_ssi_or_sst = ctRegex!(`^<<\s*(?P[a-zA-Z0-9._-]+/)*(?P[a-zA-Z0-9._-]+[.]ss[ti])$`); static src_base_parent_dir_name = ctRegex!(`[/](?P(?:[a-zA-Z0-9._-]+))(?:/media/text/[a-z]{2})$`); // formalizes dir structure - static src_formalised_file_path_parts = ctRegex!(`(?P(?:[/a-zA-Z0-9._-]+?)(?P[a-zA-Z0-9._-]+))(?:/media/text/[a-z]{2})$`); // formalized dir structure + static src_base_parent_path = ctRegex!(`(?P(?:[/a-zA-Z0-9._-]+))(?:/media/text/[a-z]{2})$`); // formalizes dir structure + static src_formalised_file_path_parts = ctRegex!(`(?P(?:[/a-zA-Z0-9._-]+?)(?P[a-zA-Z0-9._-]+))(?:/media/text/[a-z]{2})$`); // formalizes dir structure /+ inline markup footnotes endnotes +/ static inline_notes_al = ctRegex!(`【(?:[*+]\s+|\s*)(.+?)】`, "mg"); static inline_notes_al_gen = ctRegex!(`【.+?】`, "m"); @@ -77,6 +80,7 @@ static template SiSUoutputRgxInit() { static inline_italics_line = ctRegex!(`^/_ (?P.+?)((?: [\\]{2}|[~]#){0,2}$)`); static inline_underscore_line = ctRegex!(`^__ (?P.+?)((?: [\\]{2}|[~]#){0,2}$)`); static inline_fontface_clean = ctRegex!(`[*!_/^,+#■"-]\{|\}[*!_/^,+#■"-]`, "mg"); + static no_header_rgx = ctRegex!(`^=NULL$`); /+ table delimiters +/ static table_delimiter_col = ctRegex!("[ ]*[┊][ ]*", "mg"); static table_delimiter_row = ctRegex!("[ ]*\n", "mg"); diff --git a/src/sdp/output/source_sisupod.d b/src/sdp/output/source_sisupod.d index 4e3bfc1..3f95b62 100644 --- a/src/sdp/output/source_sisupod.d +++ b/src/sdp/output/source_sisupod.d @@ -97,34 +97,36 @@ template SiSUpod() { } } } { /+ bundle sisu_document_make +/ - auto fn_src_in = ((doc_matters.src.is_pod) - ? doc_matters.src.conf_dir_path - : pth_sisudoc_src.conf_root).to!string - ~ "/" ~ "sisu_document_make"; - auto fn_src_out_sisupod_zip_base - = pths_sisupod.conf_root(doc_matters.src.filename).zpod.to!string ~ "/" ~ "sisu_document_make"; - auto fn_src_out_filesystem - = pths_sisupod.conf_root(doc_matters.src.filename).filesystem_open_zpod.to!string - ~ "/" ~ "sisu_document_make"; // TODO - if (exists(fn_src_in)) { - debug(io) { - writeln("WARNING (io debug) src out found: ", fn_src_in); - } - if (doc_matters.opt.action.source) { - fn_src_in.copy(fn_src_out_filesystem); - } - if (doc_matters.opt.action.sisupod) { - auto zip_arc_member_file = new ArchiveMember(); - zip_arc_member_file.name = fn_src_out_sisupod_zip_base; - auto zip_data = new OutBuffer(); - zip_data.write((fn_src_in).readText); - zip_arc_member_file.expandedData = zip_data.toBytes(); - zip.addMember(zip_arc_member_file); - } - } else { - if (doc_matters.opt.action.verbose - || doc_matters.opt.action.debug_do) { - writeln("WARNING (io) src out NOT found (document make): ", fn_src_in); + foreach (extension; [".sdl", ".toml"]) { + auto fn_src_in = ((doc_matters.src.is_pod) + ? doc_matters.src.conf_dir_path + : pth_sisudoc_src.conf_root).to!string + ~ "/" ~ "sisu_document_make" ~ extension; + auto fn_src_out_sisupod_zip_base + = pths_sisupod.conf_root(doc_matters.src.filename).zpod.to!string ~ "/" ~ "sisu_document_make"; + auto fn_src_out_filesystem + = pths_sisupod.conf_root(doc_matters.src.filename).filesystem_open_zpod.to!string + ~ "/" ~ "sisu_document_make" ~ extension; // TODO + if (exists(fn_src_in)) { + debug(io) { + writeln("WARNING (io debug) src out found: ", fn_src_in); + } + if (doc_matters.opt.action.source) { + fn_src_in.copy(fn_src_out_filesystem); + } + if (doc_matters.opt.action.sisupod) { + auto zip_arc_member_file = new ArchiveMember(); + zip_arc_member_file.name = fn_src_out_sisupod_zip_base; + auto zip_data = new OutBuffer(); + zip_data.write((fn_src_in).readText); + zip_arc_member_file.expandedData = zip_data.toBytes(); + zip.addMember(zip_arc_member_file); + } + } else { + if (doc_matters.opt.action.verbose + || doc_matters.opt.action.debug_do) { + writeln("WARNING (io) src out NOT found (document make): ", fn_src_in); + } } } } { /+ TODO bundle primary file +/ -- cgit v1.2.3