From fb3a5d3e04970c7631253f2530693d0cf21b33db Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Tue, 27 Feb 2018 18:19:53 -0500 Subject: (header, doc make, config) add checks to toml --- makefile | 6 +- maker.org | 6 +- org/default_paths.org | 2 +- org/meta_abstraction.org | 38 ++++ org/meta_conf_make_meta.org | 366 ++++++++++++++++++++++++---------- src/sdp/meta/conf_make_meta_json.d | 388 ++++++++++++++++++++++++++----------- src/sdp/meta/metadoc_from_src.d | 29 +++ src/sdp/output/paths_source.d | 2 +- 8 files changed, 616 insertions(+), 221 deletions(-) diff --git a/makefile b/makefile index 08189de..b090f63 100644 --- a/makefile +++ b/makefile @@ -16,7 +16,7 @@ ORGFILELIST=$(shell echo `ls -1 maker.org org/*.org`) ORGFILES="" ORGDIR :=$(shell echo `pwd`) SiSU_MARKUP_SAMPLES_PODS_FOUND= \ -find data/sisupod -maxdepth 2 -name sisupod.manifest | cut -f 1-4 -d / | sort | xargs +find data/sisupod -maxdepth 2 -name sisupod.manifest | cut -f 1-3 -d / | sort | xargs SiSU_MARKUP_SAMPLES_POD = \ data/sisupod/accelerando.charles_stross \ @@ -73,10 +73,10 @@ data/sisudir/media/text/two_bits.christopher_kelty.sst \ data/sisudir/media/text/un_contracts_international_sale_of_goods_convention_1980.sst \ data/sisudir/media/text/viral_spiral.david_bollier.sst markup_samples: - find data/sisupod -name sisupod.manifest | cut -f 1-4 -d / | sort; \ + find data/sisupod -name sisupod.manifest | cut -f 1-3 -d / | sort; \ find data/sisudir/media/text -name *.ss[tm] | sort markup_pod_samples: - find data/sisupod -name sisupod.manifest | cut -f 1-4 -d / | sort + find data/sisupod -name sisupod.manifest | cut -f 1-3 -d / | sort markup_dir_samples: find data/sisudir/media/text -name *.ss[tm] | sort all: dmd ldc gdc diff --git a/maker.org b/maker.org index 9ae8a4f..23589ab 100644 --- a/maker.org +++ b/maker.org @@ -58,7 +58,7 @@ ORGDIR :=$(shell echo `pwd`) #+BEGIN_SRC makefile :tangle makefile SiSU_MARKUP_SAMPLES_PODS_FOUND= \ -find data/sisupod -maxdepth 2 -name sisupod.manifest | cut -f 1-4 -d / | sort | xargs +find data/sisupod -maxdepth 2 -name sisupod.manifest | cut -f 1-3 -d / | sort | xargs SiSU_MARKUP_SAMPLES_POD = \ data/sisupod/accelerando.charles_stross \ @@ -146,13 +146,13 @@ data/sisudir/media/text/viral_spiral.david_bollier.sst #+BEGIN_SRC makefile :tangle makefile markup_samples: - find data/sisupod -name sisupod.manifest | cut -f 1-4 -d / | sort; \ + find data/sisupod -name sisupod.manifest | cut -f 1-3 -d / | sort; \ find data/sisudir/media/text -name *.ss[tm] | sort #+END_SRC #+BEGIN_SRC makefile :tangle makefile markup_pod_samples: - find data/sisupod -name sisupod.manifest | cut -f 1-4 -d / | sort + find data/sisupod -name sisupod.manifest | cut -f 1-3 -d / | sort #+END_SRC #+BEGIN_SRC makefile :tangle makefile diff --git a/org/default_paths.org b/org/default_paths.org index f1d3301..9bb5c28 100644 --- a/org/default_paths.org +++ b/org/default_paths.org @@ -60,7 +60,7 @@ 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) { + && exists(_pth)!=0 && _pth.isFile) { _manifest_path = dirName(_pth); } else if (_pth.match(rgx.src_pth_pod_sst_or_ssm) && exists(_pth)!=0 && (_pth.isFile)) { diff --git a/org/meta_abstraction.org b/org/meta_abstraction.org index a1e5a95..d112a51 100644 --- a/org/meta_abstraction.org +++ b/org/meta_abstraction.org @@ -47,6 +47,7 @@ template SiSUdocAbstraction() { /+ ↓ abstraction init +/ <> /+ abstraction init ↑ +/ + <> /+ ↓ loop markup document/text line by line +/ srcDocLoop: foreach (line; markup_sourcefile_content) { @@ -533,6 +534,33 @@ string[] html_segnames=["toc"]; int cnt1 = 1; int cnt2 = 1; int cnt3 = 1; #+END_SRC +*** make tests + +#+name: make_tests +#+BEGIN_SRC d +debug (substitutions) { + writeln(__LINE__, ":", __FILE__, ": DEBUG substitutions:"); + if (conf_make_meta.make.substitute) { + foreach(substitution_pair; conf_make_meta.make.substitute) { + writeln("regex to match: ", substitution_pair[0]); + writeln("substitution to make: ", substitution_pair[1]); + } + } + if (!(conf_make_meta.make.bold_rgxmatch == "=NULL" || conf_make_meta.make.bold_rgxmatch.empty)) { + writeln("regex to match: ", conf_make_meta.make.bold_rgxmatch); + writeln("substitution to make: ", conf_make_meta.make.bold_substitute_html); + } + if (!(conf_make_meta.make.emphasis_rgxmatch == "=NULL" || conf_make_meta.make.emphasis_rgxmatch.empty)) { + writeln("regex to match: ", conf_make_meta.make.emphasis_rgxmatch); + writeln("substitution to make: ", conf_make_meta.make.emphasis_substitute_html); + } + if (!(conf_make_meta.make.italics_rgxmatch == "=NULL" || conf_make_meta.make.italics_rgxmatch.empty)) { + writeln("regex to match: ", conf_make_meta.make.italics_rgxmatch); + writeln("substitution to make: ", conf_make_meta.make.italics_substitute_html); + } +} +#+END_SRC + ** 2. _loop: process document body_ [+6] :loop: *** loop scope :scope: @@ -2531,6 +2559,8 @@ static auto _check_ocn_status_(L,T)( } #+END_SRC +*** make substitutions + #+name: abs_functions_substitutions #+BEGIN_SRC d auto _doc_header_and_make_substitutions_(L,CMM)( @@ -2540,6 +2570,14 @@ auto _doc_header_and_make_substitutions_(L,CMM)( debug(asserts) { static assert(is(typeof(line) == char[])); } + if (conf_make_meta.make.substitute) { + foreach(substitution_pair; conf_make_meta.make.substitute) { + line = line.replaceAll( + regex(substitution_pair[0]), + substitution_pair[1] + ); + } + } if (!( conf_make_meta.make.bold_rgxmatch == "=NULL" || conf_make_meta.make.bold_rgxmatch.empty diff --git a/org/meta_conf_make_meta.org b/org/meta_conf_make_meta.org index c23d3aa..bd18695 100644 --- a/org/meta_conf_make_meta.org +++ b/org/meta_conf_make_meta.org @@ -458,41 +458,65 @@ static template contentJSONtoSiSUstruct() { #+BEGIN_SRC d /+ make ------------------------------------------------------------------- +/ if ("make" in _json.object) { - if ("bold" in _json.object["make"]) { - _struct_composite.make_str.bold = _json.object["make"]["bold"].str; + if ("bold" in _json.object["make"] + && (_json.object["make"]["bold"].type().to!string == "STRING") + ) { + _struct_composite.make_str.bold = _json.object["make"]["bold"].str; } - if ("breaks" in _json.object["make"]) { - _struct_composite.make_str.breaks = _json.object["make"]["breaks"].str; + if ("breaks" in _json.object["make"] + && (_json.object["make"]["breaks"].type().to!string == "STRING") + ) { + _struct_composite.make_str.breaks = _json.object["make"]["breaks"].str; } - if ("cover_image" in _json.object["make"]) { - _struct_composite.make_str.cover_image = _json.object["make"]["cover_image"].str; + if ("cover_image" in _json.object["make"] + && (_json.object["make"]["cover_image"].type().to!string == "STRING") + ) { + _struct_composite.make_str.cover_image = _json.object["make"]["cover_image"].str; } - if ("css" in _json.object["make"]) { - _struct_composite.make_str.css = _json.object["make"]["css"].str; + if ("css" in _json.object["make"] + && (_json.object["make"]["css"].type().to!string == "STRING") + ) { + _struct_composite.make_str.css = _json.object["make"]["css"].str; } - if ("emphasis" in _json.object["make"]) { - _struct_composite.make_str.emphasis = _json.object["make"]["emphasis"].str; + if ("emphasis" in _json.object["make"] + && (_json.object["make"]["emphasis"].type().to!string == "STRING") + ) { + _struct_composite.make_str.emphasis = _json.object["make"]["emphasis"].str; } - if ("footer" in _json.object["make"]) { - _struct_composite.make_str.footer = _json.object["make"]["footer"].str; + if ("footer" in _json.object["make"] + && (_json.object["make"]["footer"].type().to!string == "STRING") + ) { + _struct_composite.make_str.footer = _json.object["make"]["footer"].str; } - if ("headings" in _json.object["make"]) { - _struct_composite.make_str.headings = _json.object["make"]["headings"].str; + if ("headings" in _json.object["make"] + && (_json.object["make"]["headings"].type().to!string == "STRING") + ) { + _struct_composite.make_str.headings = _json.object["make"]["headings"].str; } - if ("home_button_image" in _json.object["make"]) { - _struct_composite.make_str.home_button_image = _json.object["make"]["home_button_image"].str; + if ("home_button_image" in _json.object["make"] + && (_json.object["make"]["home_button_image"].type().to!string == "STRING") + ) { + _struct_composite.make_str.home_button_image = _json.object["make"]["home_button_image"].str; } - if ("home_button_text" in _json.object["make"]) { - _struct_composite.make_str.home_button_text = _json.object["make"]["home_button_text"].str; + if ("home_button_text" in _json.object["make"] + && (_json.object["make"]["home_button_text"].type().to!string == "STRING") + ) { + _struct_composite.make_str.home_button_text = _json.object["make"]["home_button_text"].str; } - if ("italics" in _json.object["make"]) { - _struct_composite.make_str.italics = _json.object["make"]["italics"].str; + if ("italics" in _json.object["make"] + && (_json.object["make"]["italics"].type().to!string == "STRING") + ) { + _struct_composite.make_str.italics = _json.object["make"]["italics"].str; } - if ("num_top" in _json.object["make"]) { - _struct_composite.make_str.num_top = _json.object["make"]["num_top"].str; + if ("num_top" in _json.object["make"] + && (_json.object["make"]["num_top"].type().to!string == "STRING") + ) { + _struct_composite.make_str.num_top = _json.object["make"]["num_top"].str; } - if ("num_depth" in _json.object["make"]) { - _struct_composite.make_str.num_depth = _json.object["num_depth"][""].str; + if ("num_depth" in _json.object["make"] + && (_json.object["make"]["num_depth"].type().to!string == "STRING") + ) { + _struct_composite.make_str.num_depth = _json.object["num_depth"][""].str; } if ("substitute" in _json.object["make"]) { string[][] _sub; @@ -518,7 +542,9 @@ if ("make" in _json.object) { // writeln(_sub); _struct_composite.make_str.substitute = _sub; } - if ("texpdf_font" in _json.object["make"]) { + if ("texpdf_font" in _json.object["make"] + && (_json.object["make"]["texpdf_font"].type().to!string == "STRING") + ) { _struct_composite.make_str.texpdf_font = _json.object["make"]["texpdf_font"].str; } _struct_composite.make.bold_rgxmatch = _mk.bold_rgxmatch(_struct_composite.make_str.bold); @@ -544,105 +570,167 @@ if ("make" in _json.object) { #+BEGIN_SRC d /+ conf ------------------------------------------------------------------- +/ if ("webserv" in _json.object) { - if ("url_root" in _json.object["webserv"]) { + if ("url_root" in _json.object["webserv"] + && (_json.object["webserv"]["url_root"].type().to!string == "STRING") + ) { _struct_composite.conf.webserv_url_root = _json.object["webserv"]["url_root"].str; } - if ("path" in _json.object["webserv"]) { + if ("path" in _json.object["webserv"] + && (_json.object["webserv"]["path"].type().to!string == "STRING") + ) { _struct_composite.conf.webserv_path = _json.object["webserv"]["path"].str; } - if ("images" in _json.object["webserv"]) { + if ("images" in _json.object["webserv"] + && (_json.object["webserv"]["images"].type().to!string == "STRING") + ) { _struct_composite.conf.webserv_images = _json.object["webserv"]["images"].str; } - if ("cgi" in _json.object["webserv"]) { + if ("cgi" in _json.object["webserv"] + && (_json.object["webserv"]["cgi"].type().to!string == "STRING") + ) { _struct_composite.conf.webserv_cgi = _json.object["webserv"]["cgi"].str; } - if ("cgi_host" in _json.object["webserv"]) { + if ("cgi_host" in _json.object["webserv"] + && (_json.object["webserv"]["cgi_host"].type().to!string == "STRING") + ) { _struct_composite.conf.webserv_cgi_host = _json.object["webserv"]["cgi_host"].str; } - if ("cgi_host_path" in _json.object["webserv"]) { + if ("cgi_host_path" in _json.object["webserv"] + && (_json.object["webserv"]["cgi_host_path"].type().to!string == "STRING") + ) { _struct_composite.conf.webserv_cgi_host_path = _json.object["webserv"]["cgi_host_path"].str; } - if ("cgi_port" in _json.object["webserv"]) { + if ("cgi_port" in _json.object["webserv"] + && (_json.object["webserv"]["cgi_port"].type().to!string == "STRING") + ) { _struct_composite.conf.webserv_cgi_port = _json.object["webserv"]["cgi_port"].str; } - if ("cgi_user" in _json.object["webserv"]) { + if ("cgi_user" in _json.object["webserv"] + && (_json.object["webserv"]["cgi_user"].type().to!string == "STRING") + ) { _struct_composite.conf.webserv_cgi_user = _json.object["webserv"]["cgi_user"].str; } - if ("cgi_file_links" in _json.object["webserv"]) { + if ("cgi_file_links" in _json.object["webserv"] + && (_json.object["webserv"]["cgi_file_links"].type().to!string == "STRING") + ) { _struct_composite.conf.webserv_cgi_file_links = _json.object["webserv"]["cgi_file_links"].str; } } if ("processing" in _json.object) { // TODO check & match logic with sdlang - if ("path" in _json.object["processing"]) { + if ("path" in _json.object["processing"] + && (_json.object["processing"]["path"].type().to!string == "STRING") + ) { _struct_composite.conf.processing_path = _json.object["processing"]["path"].str; } - if ("dir" in _json.object["processing"]) { + if ("dir" in _json.object["processing"] + && (_json.object["processing"]["dir"].type().to!string == "STRING") + ) { _struct_composite.conf.processing_dir = _json.object["processing"]["dir"].str; } - if ("concord_max" in _json.object["processing"]) { + if ("concord_max" in _json.object["processing"] + && (_json.object["processing"]["concord_max"].type().to!string == "STRING") + ) { _struct_composite.conf.processing_concord_max = _json.object["processing"]["concord_max"].str; } } if ("flag" in _json.object) { - if ("act0" in _json.object["flag"]) { + if ("act0" in _json.object["flag"] + && (_json.object["flag"]["act0"].type().to!string == "STRING") + ) { _struct_composite.conf.flag_act0 = _json.object["flag"]["act0"].str; } - if ("act1" in _json.object["flag"]) { + if ("act1" in _json.object["flag"] + && (_json.object["flag"]["act1"].type().to!string == "STRING") + ) { _struct_composite.conf.flag_act1 = _json.object["flag"]["act1"].str; } - if ("act2" in _json.object["flag"]) { + if ("act2" in _json.object["flag"] + && (_json.object["flag"]["act2"].type().to!string == "STRING") + ) { _struct_composite.conf.flag_act2 = _json.object["flag"]["act2"].str; } - if ("act3" in _json.object["flag"]) { + if ("act3" in _json.object["flag"] + && (_json.object["flag"]["act3"].type().to!string == "STRING") + ) { _struct_composite.conf.flag_act3 = _json.object["flag"]["act3"].str; } - if ("act4" in _json.object["flag"]) { + if ("act4" in _json.object["flag"] + && (_json.object["flag"]["act4"].type().to!string == "STRING") + ) { _struct_composite.conf.flag_act4 = _json.object["flag"]["act4"].str; } - if ("act5" in _json.object["flag"]) { + if ("act5" in _json.object["flag"] + && (_json.object["flag"]["act5"].type().to!string == "STRING") + ) { _struct_composite.conf.flag_act5 = _json.object["flag"]["act5"].str; } - if ("act6" in _json.object["flag"]) { + if ("act6" in _json.object["flag"] + && (_json.object["flag"]["act6"].type().to!string == "STRING") + ) { _struct_composite.conf.flag_act6 = _json.object["flag"]["act6"].str; } - if ("act7" in _json.object["flag"]) { + if ("act7" in _json.object["flag"] + && (_json.object["flag"]["act7"].type().to!string == "STRING") + ) { _struct_composite.conf.flag_act7 = _json.object["flag"]["act7"].str; } - if ("act8" in _json.object["flag"]) { + if ("act8" in _json.object["flag"] + && (_json.object["flag"]["act8"].type().to!string == "STRING") + ) { _struct_composite.conf.flag_act8 = _json.object["flag"]["act8"].str; } - if ("act9" in _json.object["flag"]) { + if ("act9" in _json.object["flag"] + && (_json.object["flag"]["act9"].type().to!string == "STRING") + ) { _struct_composite.conf.flag_act9 = _json.object["flag"]["act9"].str; } } if ("default" in _json.object) { - if ("papersize" in _json.object["default"]) { + if ("papersize" in _json.object["default"] + && (_json.object["default"]["papersize"].type().to!string == "STRING") + ) { _struct_composite.conf.default_papersize = _json.object["default"]["papersize"].str; } - if ("text_wrap" in _json.object["default"]) { + if ("text_wrap" in _json.object["default"] + && (_json.object["default"]["text_wrap"].type().to!string == "STRING") + ) { _struct_composite.conf.default_text_wrap = _json.object["default"]["text_wrap"].str; } - if ("emphasis" in _json.object["default"]) { + if ("emphasis" in _json.object["default"] + && (_json.object["default"]["emphasis"].type().to!string == "STRING") + ) { _struct_composite.conf.default_emphasis = _json.object["default"]["emphasis"].str; } - if ("language" in _json.object["default"]) { + if ("language" in _json.object["default"] + && (_json.object["default"]["language"].type().to!string == "STRING") + ) { _struct_composite.conf.default_language = _json.object["default"]["language"].str; } - if ("digest" in _json.object["default"]) { + if ("digest" in _json.object["default"] + && (_json.object["default"]["digest"].type().to!string == "STRING") + ) { _struct_composite.conf.default_digest = _json.object["default"]["digest"].str; } } if ("search" in _json.object) { - if ("flag" in _json.object["search"]) { + if ("flag" in _json.object["search"] + && (_json.object["search"]["flag"].type().to!string == "STRING") + ) { _struct_composite.conf.search_flag = _json.object["search"]["flag"].str; } - if ("action" in _json.object["search"]) { + if ("action" in _json.object["search"] + && (_json.object["search"]["action"].type().to!string == "STRING") + ) { _struct_composite.conf.search_action = _json.object["search"]["action"].str; } - if ("db" in _json.object["search"]) { + if ("db" in _json.object["search"] + && (_json.object["search"]["db"].type().to!string == "STRING") + ) { _struct_composite.conf.search_db = _json.object["search"]["db"].str; } - if ("title" in _json.object["search"]) { + if ("title" in _json.object["search"] + && (_json.object["search"]["title"].type().to!string == "STRING") + ) { _struct_composite.conf.search_title = _json.object["search"]["title"].str; } } @@ -654,42 +742,66 @@ if ("search" in _json.object) { #+BEGIN_SRC d /+ meta ------------------------------------------------------------------- +/ if ("classify" in _json.object) { - if ("dewey" in _json.object["classify"]) { + if ("dewey" in _json.object["classify"] + && (_json.object["classify"]["dewey"].type().to!string == "STRING") + ) { _struct_composite.meta.classify_dewey = _json.object["classify"]["dewey"].str; } - if ("keywords" in _json.object["classify"]) { + if ("keywords" in _json.object["classify"] + && (_json.object["classify"]["keywords"].type().to!string == "STRING") + ) { _struct_composite.meta.classify_keywords = _json.object["classify"]["keywords"].str; } - if ("loc" in _json.object["classify"]) { + if ("loc" in _json.object["classify"] + && (_json.object["classify"]["loc"].type().to!string == "STRING") + ) { _struct_composite.meta.classify_loc = _json.object["classify"]["loc"].str; } - if ("subject" in _json.object["classify"]) { + if ("subject" in _json.object["classify"] + && (_json.object["classify"]["subject"].type().to!string == "STRING") + ) { _struct_composite.meta.classify_subject = _json.object["classify"]["subject"].str; } - if ("topic_register" in _json.object["classify"]) { + if ("topic_register" in _json.object["classify"] + && (_json.object["classify"]["topic_register"].type().to!string == "STRING") + ) { _struct_composite.meta.classify_topic_register = _json.object["classify"]["topic_register"].str; } } if ("date" in _json.object) { - if ("added_to_site" in _json.object["date"]) { + if ("added_to_site" in _json.object["date"] + && (_json.object["date"]["added_to_site"].type().to!string == "STRING") + ) { _struct_composite.meta.date_added_to_site = _json.object["date"]["added_to_site"].str; } - if ("available" in _json.object["date"]) { + if ("available" in _json.object["date"] + && (_json.object["date"]["available"].type().to!string == "STRING") + ) { _struct_composite.meta.date_available = _json.object["date"]["available"].str; } - if ("created" in _json.object["date"]) { + if ("created" in _json.object["date"] + && (_json.object["date"]["created"].type().to!string == "STRING") + ) { _struct_composite.meta.date_created = _json.object["date"]["created"].str; } - if ("issued" in _json.object["date"]) { + if ("issued" in _json.object["date"] + && (_json.object["date"]["issued"].type().to!string == "STRING") + ) { _struct_composite.meta.date_issued = _json.object["date"]["issued"].str; } - if ("modified" in _json.object["date"]) { + if ("modified" in _json.object["date"] + && (_json.object["date"]["modified"].type().to!string == "STRING") + ) { _struct_composite.meta.date_modified = _json.object["date"]["modified"].str; } - if ("published" in _json.object["date"]) { + if ("published" in _json.object["date"] + && (_json.object["date"]["published"].type().to!string == "STRING") + ) { _struct_composite.meta.date_published = _json.object["date"]["published"].str; } - if ("valid" in _json.object["date"]) { + if ("valid" in _json.object["date"] + && (_json.object["date"]["valid"].type().to!string == "STRING") + ) { _struct_composite.meta.date_valid = _json.object["date"]["valid"].str; } } @@ -699,24 +811,36 @@ if ("links" in _json.object) { // } } if ("notes" in _json.object) { - if ("abstract" in _json.object["notes"]) { + if ("abstract" in _json.object["notes"] + && (_json.object["notes"]["abstract"].type().to!string == "STRING") + ) { _struct_composite.meta.notes_abstract = _json.object["notes"]["abstract"].str; } - if ("description" in _json.object["notes"]) { + if ("description" in _json.object["notes"] + && (_json.object["notes"]["description"].type().to!string == "STRING") + ) { _struct_composite.meta.notes_description = _json.object["notes"]["description"].str; } } if ("original" in _json.object) { - if ("language" in _json.object["original"]) { + if ("language" in _json.object["original"] + && (_json.object["original"]["language"].type().to!string == "STRING") + ) { _struct_composite.meta.original_language = _json.object["original"]["language"].str; } - if ("language_char" in _json.object["original"]) { + if ("language_char" in _json.object["original"] + && (_json.object["original"]["language_char"].type().to!string == "STRING") + ) { _struct_composite.meta.original_language_char = _json.object["original"]["language_char"].str; } - if ("source" in _json.object["original"]) { + if ("source" in _json.object["original"] + && (_json.object["original"]["source"].type().to!string == "STRING") + ) { _struct_composite.meta.original_source = _json.object["original"]["source"].str; } - if ("title" in _json.object["original"]) { + if ("title" in _json.object["original"] + && (_json.object["original"]["title"].type().to!string == "STRING") + ) { _struct_composite.meta.original_title = _json.object["original"]["title"].str; } } @@ -726,46 +850,72 @@ if ("publisher" in _json.object) { // } } if ("rights" in _json.object) { - if ("copyright" in _json.object["rights"]) { + if ("copyright" in _json.object["rights"] + && (_json.object["rights"]["copyright"].type().to!string == "STRING") + ) { _struct_composite.meta.rights_copyright = _json.object["rights"]["copyright"].str; } - if ("copyright_text" in _json.object["rights"]) { + if ("copyright_text" in _json.object["rights"] + && (_json.object["rights"]["copyright_text"].type().to!string == "STRING") + ) { _struct_composite.meta.rights_copyright_text = _json.object["rights"]["copyright_text"].str; } - if ("copyright_audio" in _json.object["rights"]) { + if ("copyright_audio" in _json.object["rights"] + && (_json.object["rights"]["copyright_audio"].type().to!string == "STRING") + ) { _struct_composite.meta.rights_copyright_audio = _json.object["rights"]["copyright_audio"].str; } - if ("copyright_cover" in _json.object["rights"]) { + if ("copyright_cover" in _json.object["rights"] + && (_json.object["rights"]["copyright_cover"].type().to!string == "STRING") + ) { _struct_composite.meta.rights_copyright_cover = _json.object["rights"]["copyright_cover"].str; } - if ("copyright_illustrations" in _json.object["rights"]) { + if ("copyright_illustrations" in _json.object["rights"] + && (_json.object["rights"]["copyright_illustrations"].type().to!string == "STRING") + ) { _struct_composite.meta.rights_copyright_illustrations = _json.object["rights"]["copyright_illustrations"].str; } - if ("copyright_photographs" in _json.object["rights"]) { + if ("copyright_photographs" in _json.object["rights"] + && (_json.object["rights"]["copyright_photographs"].type().to!string == "STRING") + ) { _struct_composite.meta.rights_copyright_photographs = _json.object["rights"]["copyright_photographs"].str; } - if ("copyright_translation" in _json.object["rights"]) { + if ("copyright_translation" in _json.object["rights"] + && (_json.object["rights"]["copyright_translation"].type().to!string == "STRING") + ) { _struct_composite.meta.rights_copyright_translation = _json.object["rights"]["copyright_translation"].str; } - if ("copyright_video" in _json.object["rights"]) { + if ("copyright_video" in _json.object["rights"] + && (_json.object["rights"]["copyright_video"].type().to!string == "STRING") + ) { _struct_composite.meta.rights_copyright_video = _json.object["rights"]["copyright_video"].str; } - if ("license" in _json.object["rights"]) { + if ("license" in _json.object["rights"] + && (_json.object["rights"]["license"].type().to!string == "STRING") + ) { _struct_composite.meta.rights_license = _json.object["rights"]["license"].str; } } if (_struct_composite.meta.creator_author.empty) { if ("creator" in _json.object) { - if ("author" in _json.object["creator"]) { + if ("author" in _json.object["creator"] + && (_json.object["creator"]["author"].type().to!string == "STRING") + ) { _struct_composite.meta.creator_author = _json.object["creator"]["author"].str; } - if ("email" in _json.object["creator"]) { + if ("email" in _json.object["creator"] + && (_json.object["creator"]["email"].type().to!string == "STRING") + ) { _struct_composite.meta.creator_author_email = _json.object["creator"]["email"].str; } - if ("illustrator" in _json.object["creator"]) { + if ("illustrator" in _json.object["creator"] + && (_json.object["creator"]["illustrator"].type().to!string == "STRING") + ) { _struct_composite.meta.creator_illustrator = _json.object["creator"]["illustrator"].str; } - if ("translator" in _json.object["creator"]) { + if ("translator" in _json.object["creator"] + && (_json.object["creator"]["translator"].type().to!string == "STRING") + ) { _struct_composite.meta.creator_translator = _json.object["creator"]["translator"].str; } } @@ -780,28 +930,42 @@ if (_struct_composite.meta.creator_author.empty) { if (_struct_composite.meta.title_main.empty) { if ("title" in _json.object) { if ((_json.object["title"].type().to!string) == "STRING") { - _struct_composite.meta.title_main = _json.object["title"].str; + _struct_composite.meta.title_main = _json.object["title"].str; } else { - if ("edition" in _json.object["title"]) { - _struct_composite.meta.title_edition = _json.object["title"]["edition"].str; + if ("edition" in _json.object["title"] + && (_json.object["title"]["edition"].type().to!string == "STRING") + ) { + _struct_composite.meta.title_edition = _json.object["title"]["edition"].str; } - if ("full" in _json.object["title"]) { + if ("full" in _json.object["title"] + && (_json.object["title"]["full"].type().to!string == "STRING") + ) { // _struct_composite.meta.title_full = _json.object["title"]["full"].str; } - if ("language" in _json.object["title"]) { - _struct_composite.meta.title_language = _json.object["title"]["language"].str; + if ("language" in _json.object["title"] + && (_json.object["title"]["language"].type().to!string == "STRING") + ) { + _struct_composite.meta.title_language = _json.object["title"]["language"].str; } - if ("main" in _json.object["title"]) { - _struct_composite.meta.title_main = _json.object["title"]["main"].str; + if ("main" in _json.object["title"] + && (_json.object["title"]["main"].type().to!string == "STRING") + ) { + _struct_composite.meta.title_main = _json.object["title"]["main"].str; } - if ("note" in _json.object["title"]) { - _struct_composite.meta.title_note = _json.object["title"]["note"].str; + if ("note" in _json.object["title"] + && (_json.object["title"]["note"].type().to!string == "STRING") + ) { + _struct_composite.meta.title_note = _json.object["title"]["note"].str; } - if ("sub" in _json.object["title"]) { - _struct_composite.meta.title_sub = _json.object["title"]["sub"].str; + if ("sub" in _json.object["title"] + && (_json.object["title"]["sub"].type().to!string == "STRING") + ) { + _struct_composite.meta.title_sub = _json.object["title"]["sub"].str; } - if ("subtitle" in _json.object["title"]) { - _struct_composite.meta.title_subtitle = _json.object["title"]["subtitle"].str; + if ("subtitle" in _json.object["title"] + && (_json.object["title"]["subtitle"].type().to!string == "STRING") + ) { + _struct_composite.meta.title_subtitle = _json.object["title"]["subtitle"].str; } } } diff --git a/src/sdp/meta/conf_make_meta_json.d b/src/sdp/meta/conf_make_meta_json.d index c5585ce..2ccf2c3 100644 --- a/src/sdp/meta/conf_make_meta_json.d +++ b/src/sdp/meta/conf_make_meta_json.d @@ -38,41 +38,65 @@ static template contentJSONtoSiSUstruct() { confCompositeMakeBuild _mk; /+ make ------------------------------------------------------------------- +/ if ("make" in _json.object) { - if ("bold" in _json.object["make"]) { - _struct_composite.make_str.bold = _json.object["make"]["bold"].str; - } - if ("breaks" in _json.object["make"]) { - _struct_composite.make_str.breaks = _json.object["make"]["breaks"].str; - } - if ("cover_image" in _json.object["make"]) { - _struct_composite.make_str.cover_image = _json.object["make"]["cover_image"].str; - } - if ("css" in _json.object["make"]) { - _struct_composite.make_str.css = _json.object["make"]["css"].str; - } - if ("emphasis" in _json.object["make"]) { - _struct_composite.make_str.emphasis = _json.object["make"]["emphasis"].str; - } - if ("footer" in _json.object["make"]) { - _struct_composite.make_str.footer = _json.object["make"]["footer"].str; - } - if ("headings" in _json.object["make"]) { - _struct_composite.make_str.headings = _json.object["make"]["headings"].str; - } - if ("home_button_image" in _json.object["make"]) { - _struct_composite.make_str.home_button_image = _json.object["make"]["home_button_image"].str; - } - if ("home_button_text" in _json.object["make"]) { - _struct_composite.make_str.home_button_text = _json.object["make"]["home_button_text"].str; - } - if ("italics" in _json.object["make"]) { - _struct_composite.make_str.italics = _json.object["make"]["italics"].str; - } - if ("num_top" in _json.object["make"]) { - _struct_composite.make_str.num_top = _json.object["make"]["num_top"].str; - } - if ("num_depth" in _json.object["make"]) { - _struct_composite.make_str.num_depth = _json.object["num_depth"][""].str; + if ("bold" in _json.object["make"] + && (_json.object["make"]["bold"].type().to!string == "STRING") + ) { + _struct_composite.make_str.bold = _json.object["make"]["bold"].str; + } + if ("breaks" in _json.object["make"] + && (_json.object["make"]["breaks"].type().to!string == "STRING") + ) { + _struct_composite.make_str.breaks = _json.object["make"]["breaks"].str; + } + if ("cover_image" in _json.object["make"] + && (_json.object["make"]["cover_image"].type().to!string == "STRING") + ) { + _struct_composite.make_str.cover_image = _json.object["make"]["cover_image"].str; + } + if ("css" in _json.object["make"] + && (_json.object["make"]["css"].type().to!string == "STRING") + ) { + _struct_composite.make_str.css = _json.object["make"]["css"].str; + } + if ("emphasis" in _json.object["make"] + && (_json.object["make"]["emphasis"].type().to!string == "STRING") + ) { + _struct_composite.make_str.emphasis = _json.object["make"]["emphasis"].str; + } + if ("footer" in _json.object["make"] + && (_json.object["make"]["footer"].type().to!string == "STRING") + ) { + _struct_composite.make_str.footer = _json.object["make"]["footer"].str; + } + if ("headings" in _json.object["make"] + && (_json.object["make"]["headings"].type().to!string == "STRING") + ) { + _struct_composite.make_str.headings = _json.object["make"]["headings"].str; + } + if ("home_button_image" in _json.object["make"] + && (_json.object["make"]["home_button_image"].type().to!string == "STRING") + ) { + _struct_composite.make_str.home_button_image = _json.object["make"]["home_button_image"].str; + } + if ("home_button_text" in _json.object["make"] + && (_json.object["make"]["home_button_text"].type().to!string == "STRING") + ) { + _struct_composite.make_str.home_button_text = _json.object["make"]["home_button_text"].str; + } + if ("italics" in _json.object["make"] + && (_json.object["make"]["italics"].type().to!string == "STRING") + ) { + _struct_composite.make_str.italics = _json.object["make"]["italics"].str; + } + if ("num_top" in _json.object["make"] + && (_json.object["make"]["num_top"].type().to!string == "STRING") + ) { + _struct_composite.make_str.num_top = _json.object["make"]["num_top"].str; + } + if ("num_depth" in _json.object["make"] + && (_json.object["make"]["num_depth"].type().to!string == "STRING") + ) { + _struct_composite.make_str.num_depth = _json.object["num_depth"][""].str; } if ("substitute" in _json.object["make"]) { string[][] _sub; @@ -98,7 +122,9 @@ static template contentJSONtoSiSUstruct() { // writeln(_sub); _struct_composite.make_str.substitute = _sub; } - if ("texpdf_font" in _json.object["make"]) { + if ("texpdf_font" in _json.object["make"] + && (_json.object["make"]["texpdf_font"].type().to!string == "STRING") + ) { _struct_composite.make_str.texpdf_font = _json.object["make"]["texpdf_font"].str; } _struct_composite.make.bold_rgxmatch = _mk.bold_rgxmatch(_struct_composite.make_str.bold); @@ -118,146 +144,232 @@ static template contentJSONtoSiSUstruct() { } /+ conf ------------------------------------------------------------------- +/ if ("webserv" in _json.object) { - if ("url_root" in _json.object["webserv"]) { + if ("url_root" in _json.object["webserv"] + && (_json.object["webserv"]["url_root"].type().to!string == "STRING") + ) { _struct_composite.conf.webserv_url_root = _json.object["webserv"]["url_root"].str; } - if ("path" in _json.object["webserv"]) { + if ("path" in _json.object["webserv"] + && (_json.object["webserv"]["path"].type().to!string == "STRING") + ) { _struct_composite.conf.webserv_path = _json.object["webserv"]["path"].str; } - if ("images" in _json.object["webserv"]) { + if ("images" in _json.object["webserv"] + && (_json.object["webserv"]["images"].type().to!string == "STRING") + ) { _struct_composite.conf.webserv_images = _json.object["webserv"]["images"].str; } - if ("cgi" in _json.object["webserv"]) { + if ("cgi" in _json.object["webserv"] + && (_json.object["webserv"]["cgi"].type().to!string == "STRING") + ) { _struct_composite.conf.webserv_cgi = _json.object["webserv"]["cgi"].str; } - if ("cgi_host" in _json.object["webserv"]) { + if ("cgi_host" in _json.object["webserv"] + && (_json.object["webserv"]["cgi_host"].type().to!string == "STRING") + ) { _struct_composite.conf.webserv_cgi_host = _json.object["webserv"]["cgi_host"].str; } - if ("cgi_host_path" in _json.object["webserv"]) { + if ("cgi_host_path" in _json.object["webserv"] + && (_json.object["webserv"]["cgi_host_path"].type().to!string == "STRING") + ) { _struct_composite.conf.webserv_cgi_host_path = _json.object["webserv"]["cgi_host_path"].str; } - if ("cgi_port" in _json.object["webserv"]) { + if ("cgi_port" in _json.object["webserv"] + && (_json.object["webserv"]["cgi_port"].type().to!string == "STRING") + ) { _struct_composite.conf.webserv_cgi_port = _json.object["webserv"]["cgi_port"].str; } - if ("cgi_user" in _json.object["webserv"]) { + if ("cgi_user" in _json.object["webserv"] + && (_json.object["webserv"]["cgi_user"].type().to!string == "STRING") + ) { _struct_composite.conf.webserv_cgi_user = _json.object["webserv"]["cgi_user"].str; } - if ("cgi_file_links" in _json.object["webserv"]) { + if ("cgi_file_links" in _json.object["webserv"] + && (_json.object["webserv"]["cgi_file_links"].type().to!string == "STRING") + ) { _struct_composite.conf.webserv_cgi_file_links = _json.object["webserv"]["cgi_file_links"].str; } } if ("processing" in _json.object) { // TODO check & match logic with sdlang - if ("path" in _json.object["processing"]) { + if ("path" in _json.object["processing"] + && (_json.object["processing"]["path"].type().to!string == "STRING") + ) { _struct_composite.conf.processing_path = _json.object["processing"]["path"].str; } - if ("dir" in _json.object["processing"]) { + if ("dir" in _json.object["processing"] + && (_json.object["processing"]["dir"].type().to!string == "STRING") + ) { _struct_composite.conf.processing_dir = _json.object["processing"]["dir"].str; } - if ("concord_max" in _json.object["processing"]) { + if ("concord_max" in _json.object["processing"] + && (_json.object["processing"]["concord_max"].type().to!string == "STRING") + ) { _struct_composite.conf.processing_concord_max = _json.object["processing"]["concord_max"].str; } } if ("flag" in _json.object) { - if ("act0" in _json.object["flag"]) { + if ("act0" in _json.object["flag"] + && (_json.object["flag"]["act0"].type().to!string == "STRING") + ) { _struct_composite.conf.flag_act0 = _json.object["flag"]["act0"].str; } - if ("act1" in _json.object["flag"]) { + if ("act1" in _json.object["flag"] + && (_json.object["flag"]["act1"].type().to!string == "STRING") + ) { _struct_composite.conf.flag_act1 = _json.object["flag"]["act1"].str; } - if ("act2" in _json.object["flag"]) { + if ("act2" in _json.object["flag"] + && (_json.object["flag"]["act2"].type().to!string == "STRING") + ) { _struct_composite.conf.flag_act2 = _json.object["flag"]["act2"].str; } - if ("act3" in _json.object["flag"]) { + if ("act3" in _json.object["flag"] + && (_json.object["flag"]["act3"].type().to!string == "STRING") + ) { _struct_composite.conf.flag_act3 = _json.object["flag"]["act3"].str; } - if ("act4" in _json.object["flag"]) { + if ("act4" in _json.object["flag"] + && (_json.object["flag"]["act4"].type().to!string == "STRING") + ) { _struct_composite.conf.flag_act4 = _json.object["flag"]["act4"].str; } - if ("act5" in _json.object["flag"]) { + if ("act5" in _json.object["flag"] + && (_json.object["flag"]["act5"].type().to!string == "STRING") + ) { _struct_composite.conf.flag_act5 = _json.object["flag"]["act5"].str; } - if ("act6" in _json.object["flag"]) { + if ("act6" in _json.object["flag"] + && (_json.object["flag"]["act6"].type().to!string == "STRING") + ) { _struct_composite.conf.flag_act6 = _json.object["flag"]["act6"].str; } - if ("act7" in _json.object["flag"]) { + if ("act7" in _json.object["flag"] + && (_json.object["flag"]["act7"].type().to!string == "STRING") + ) { _struct_composite.conf.flag_act7 = _json.object["flag"]["act7"].str; } - if ("act8" in _json.object["flag"]) { + if ("act8" in _json.object["flag"] + && (_json.object["flag"]["act8"].type().to!string == "STRING") + ) { _struct_composite.conf.flag_act8 = _json.object["flag"]["act8"].str; } - if ("act9" in _json.object["flag"]) { + if ("act9" in _json.object["flag"] + && (_json.object["flag"]["act9"].type().to!string == "STRING") + ) { _struct_composite.conf.flag_act9 = _json.object["flag"]["act9"].str; } } if ("default" in _json.object) { - if ("papersize" in _json.object["default"]) { + if ("papersize" in _json.object["default"] + && (_json.object["default"]["papersize"].type().to!string == "STRING") + ) { _struct_composite.conf.default_papersize = _json.object["default"]["papersize"].str; } - if ("text_wrap" in _json.object["default"]) { + if ("text_wrap" in _json.object["default"] + && (_json.object["default"]["text_wrap"].type().to!string == "STRING") + ) { _struct_composite.conf.default_text_wrap = _json.object["default"]["text_wrap"].str; } - if ("emphasis" in _json.object["default"]) { + if ("emphasis" in _json.object["default"] + && (_json.object["default"]["emphasis"].type().to!string == "STRING") + ) { _struct_composite.conf.default_emphasis = _json.object["default"]["emphasis"].str; } - if ("language" in _json.object["default"]) { + if ("language" in _json.object["default"] + && (_json.object["default"]["language"].type().to!string == "STRING") + ) { _struct_composite.conf.default_language = _json.object["default"]["language"].str; } - if ("digest" in _json.object["default"]) { + if ("digest" in _json.object["default"] + && (_json.object["default"]["digest"].type().to!string == "STRING") + ) { _struct_composite.conf.default_digest = _json.object["default"]["digest"].str; } } if ("search" in _json.object) { - if ("flag" in _json.object["search"]) { + if ("flag" in _json.object["search"] + && (_json.object["search"]["flag"].type().to!string == "STRING") + ) { _struct_composite.conf.search_flag = _json.object["search"]["flag"].str; } - if ("action" in _json.object["search"]) { + if ("action" in _json.object["search"] + && (_json.object["search"]["action"].type().to!string == "STRING") + ) { _struct_composite.conf.search_action = _json.object["search"]["action"].str; } - if ("db" in _json.object["search"]) { + if ("db" in _json.object["search"] + && (_json.object["search"]["db"].type().to!string == "STRING") + ) { _struct_composite.conf.search_db = _json.object["search"]["db"].str; } - if ("title" in _json.object["search"]) { + if ("title" in _json.object["search"] + && (_json.object["search"]["title"].type().to!string == "STRING") + ) { _struct_composite.conf.search_title = _json.object["search"]["title"].str; } } /+ meta ------------------------------------------------------------------- +/ if ("classify" in _json.object) { - if ("dewey" in _json.object["classify"]) { + if ("dewey" in _json.object["classify"] + && (_json.object["classify"]["dewey"].type().to!string == "STRING") + ) { _struct_composite.meta.classify_dewey = _json.object["classify"]["dewey"].str; } - if ("keywords" in _json.object["classify"]) { + if ("keywords" in _json.object["classify"] + && (_json.object["classify"]["keywords"].type().to!string == "STRING") + ) { _struct_composite.meta.classify_keywords = _json.object["classify"]["keywords"].str; } - if ("loc" in _json.object["classify"]) { + if ("loc" in _json.object["classify"] + && (_json.object["classify"]["loc"].type().to!string == "STRING") + ) { _struct_composite.meta.classify_loc = _json.object["classify"]["loc"].str; } - if ("subject" in _json.object["classify"]) { + if ("subject" in _json.object["classify"] + && (_json.object["classify"]["subject"].type().to!string == "STRING") + ) { _struct_composite.meta.classify_subject = _json.object["classify"]["subject"].str; } - if ("topic_register" in _json.object["classify"]) { + if ("topic_register" in _json.object["classify"] + && (_json.object["classify"]["topic_register"].type().to!string == "STRING") + ) { _struct_composite.meta.classify_topic_register = _json.object["classify"]["topic_register"].str; } } if ("date" in _json.object) { - if ("added_to_site" in _json.object["date"]) { + if ("added_to_site" in _json.object["date"] + && (_json.object["date"]["added_to_site"].type().to!string == "STRING") + ) { _struct_composite.meta.date_added_to_site = _json.object["date"]["added_to_site"].str; } - if ("available" in _json.object["date"]) { + if ("available" in _json.object["date"] + && (_json.object["date"]["available"].type().to!string == "STRING") + ) { _struct_composite.meta.date_available = _json.object["date"]["available"].str; } - if ("created" in _json.object["date"]) { + if ("created" in _json.object["date"] + && (_json.object["date"]["created"].type().to!string == "STRING") + ) { _struct_composite.meta.date_created = _json.object["date"]["created"].str; } - if ("issued" in _json.object["date"]) { + if ("issued" in _json.object["date"] + && (_json.object["date"]["issued"].type().to!string == "STRING") + ) { _struct_composite.meta.date_issued = _json.object["date"]["issued"].str; } - if ("modified" in _json.object["date"]) { + if ("modified" in _json.object["date"] + && (_json.object["date"]["modified"].type().to!string == "STRING") + ) { _struct_composite.meta.date_modified = _json.object["date"]["modified"].str; } - if ("published" in _json.object["date"]) { + if ("published" in _json.object["date"] + && (_json.object["date"]["published"].type().to!string == "STRING") + ) { _struct_composite.meta.date_published = _json.object["date"]["published"].str; } - if ("valid" in _json.object["date"]) { + if ("valid" in _json.object["date"] + && (_json.object["date"]["valid"].type().to!string == "STRING") + ) { _struct_composite.meta.date_valid = _json.object["date"]["valid"].str; } } @@ -267,24 +379,36 @@ static template contentJSONtoSiSUstruct() { // } } if ("notes" in _json.object) { - if ("abstract" in _json.object["notes"]) { + if ("abstract" in _json.object["notes"] + && (_json.object["notes"]["abstract"].type().to!string == "STRING") + ) { _struct_composite.meta.notes_abstract = _json.object["notes"]["abstract"].str; } - if ("description" in _json.object["notes"]) { + if ("description" in _json.object["notes"] + && (_json.object["notes"]["description"].type().to!string == "STRING") + ) { _struct_composite.meta.notes_description = _json.object["notes"]["description"].str; } } if ("original" in _json.object) { - if ("language" in _json.object["original"]) { + if ("language" in _json.object["original"] + && (_json.object["original"]["language"].type().to!string == "STRING") + ) { _struct_composite.meta.original_language = _json.object["original"]["language"].str; } - if ("language_char" in _json.object["original"]) { + if ("language_char" in _json.object["original"] + && (_json.object["original"]["language_char"].type().to!string == "STRING") + ) { _struct_composite.meta.original_language_char = _json.object["original"]["language_char"].str; } - if ("source" in _json.object["original"]) { + if ("source" in _json.object["original"] + && (_json.object["original"]["source"].type().to!string == "STRING") + ) { _struct_composite.meta.original_source = _json.object["original"]["source"].str; } - if ("title" in _json.object["original"]) { + if ("title" in _json.object["original"] + && (_json.object["original"]["title"].type().to!string == "STRING") + ) { _struct_composite.meta.original_title = _json.object["original"]["title"].str; } } @@ -294,46 +418,72 @@ static template contentJSONtoSiSUstruct() { // } } if ("rights" in _json.object) { - if ("copyright" in _json.object["rights"]) { + if ("copyright" in _json.object["rights"] + && (_json.object["rights"]["copyright"].type().to!string == "STRING") + ) { _struct_composite.meta.rights_copyright = _json.object["rights"]["copyright"].str; } - if ("copyright_text" in _json.object["rights"]) { + if ("copyright_text" in _json.object["rights"] + && (_json.object["rights"]["copyright_text"].type().to!string == "STRING") + ) { _struct_composite.meta.rights_copyright_text = _json.object["rights"]["copyright_text"].str; } - if ("copyright_audio" in _json.object["rights"]) { + if ("copyright_audio" in _json.object["rights"] + && (_json.object["rights"]["copyright_audio"].type().to!string == "STRING") + ) { _struct_composite.meta.rights_copyright_audio = _json.object["rights"]["copyright_audio"].str; } - if ("copyright_cover" in _json.object["rights"]) { + if ("copyright_cover" in _json.object["rights"] + && (_json.object["rights"]["copyright_cover"].type().to!string == "STRING") + ) { _struct_composite.meta.rights_copyright_cover = _json.object["rights"]["copyright_cover"].str; } - if ("copyright_illustrations" in _json.object["rights"]) { + if ("copyright_illustrations" in _json.object["rights"] + && (_json.object["rights"]["copyright_illustrations"].type().to!string == "STRING") + ) { _struct_composite.meta.rights_copyright_illustrations = _json.object["rights"]["copyright_illustrations"].str; } - if ("copyright_photographs" in _json.object["rights"]) { + if ("copyright_photographs" in _json.object["rights"] + && (_json.object["rights"]["copyright_photographs"].type().to!string == "STRING") + ) { _struct_composite.meta.rights_copyright_photographs = _json.object["rights"]["copyright_photographs"].str; } - if ("copyright_translation" in _json.object["rights"]) { + if ("copyright_translation" in _json.object["rights"] + && (_json.object["rights"]["copyright_translation"].type().to!string == "STRING") + ) { _struct_composite.meta.rights_copyright_translation = _json.object["rights"]["copyright_translation"].str; } - if ("copyright_video" in _json.object["rights"]) { + if ("copyright_video" in _json.object["rights"] + && (_json.object["rights"]["copyright_video"].type().to!string == "STRING") + ) { _struct_composite.meta.rights_copyright_video = _json.object["rights"]["copyright_video"].str; } - if ("license" in _json.object["rights"]) { + if ("license" in _json.object["rights"] + && (_json.object["rights"]["license"].type().to!string == "STRING") + ) { _struct_composite.meta.rights_license = _json.object["rights"]["license"].str; } } if (_struct_composite.meta.creator_author.empty) { if ("creator" in _json.object) { - if ("author" in _json.object["creator"]) { + if ("author" in _json.object["creator"] + && (_json.object["creator"]["author"].type().to!string == "STRING") + ) { _struct_composite.meta.creator_author = _json.object["creator"]["author"].str; } - if ("email" in _json.object["creator"]) { + if ("email" in _json.object["creator"] + && (_json.object["creator"]["email"].type().to!string == "STRING") + ) { _struct_composite.meta.creator_author_email = _json.object["creator"]["email"].str; } - if ("illustrator" in _json.object["creator"]) { + if ("illustrator" in _json.object["creator"] + && (_json.object["creator"]["illustrator"].type().to!string == "STRING") + ) { _struct_composite.meta.creator_illustrator = _json.object["creator"]["illustrator"].str; } - if ("translator" in _json.object["creator"]) { + if ("translator" in _json.object["creator"] + && (_json.object["creator"]["translator"].type().to!string == "STRING") + ) { _struct_composite.meta.creator_translator = _json.object["creator"]["translator"].str; } } @@ -348,28 +498,42 @@ static template contentJSONtoSiSUstruct() { if (_struct_composite.meta.title_main.empty) { if ("title" in _json.object) { if ((_json.object["title"].type().to!string) == "STRING") { - _struct_composite.meta.title_main = _json.object["title"].str; + _struct_composite.meta.title_main = _json.object["title"].str; } else { - if ("edition" in _json.object["title"]) { - _struct_composite.meta.title_edition = _json.object["title"]["edition"].str; + if ("edition" in _json.object["title"] + && (_json.object["title"]["edition"].type().to!string == "STRING") + ) { + _struct_composite.meta.title_edition = _json.object["title"]["edition"].str; } - if ("full" in _json.object["title"]) { + if ("full" in _json.object["title"] + && (_json.object["title"]["full"].type().to!string == "STRING") + ) { // _struct_composite.meta.title_full = _json.object["title"]["full"].str; } - if ("language" in _json.object["title"]) { - _struct_composite.meta.title_language = _json.object["title"]["language"].str; + if ("language" in _json.object["title"] + && (_json.object["title"]["language"].type().to!string == "STRING") + ) { + _struct_composite.meta.title_language = _json.object["title"]["language"].str; } - if ("main" in _json.object["title"]) { - _struct_composite.meta.title_main = _json.object["title"]["main"].str; + if ("main" in _json.object["title"] + && (_json.object["title"]["main"].type().to!string == "STRING") + ) { + _struct_composite.meta.title_main = _json.object["title"]["main"].str; } - if ("note" in _json.object["title"]) { - _struct_composite.meta.title_note = _json.object["title"]["note"].str; + if ("note" in _json.object["title"] + && (_json.object["title"]["note"].type().to!string == "STRING") + ) { + _struct_composite.meta.title_note = _json.object["title"]["note"].str; } - if ("sub" in _json.object["title"]) { - _struct_composite.meta.title_sub = _json.object["title"]["sub"].str; + if ("sub" in _json.object["title"] + && (_json.object["title"]["sub"].type().to!string == "STRING") + ) { + _struct_composite.meta.title_sub = _json.object["title"]["sub"].str; } - if ("subtitle" in _json.object["title"]) { - _struct_composite.meta.title_subtitle = _json.object["title"]["subtitle"].str; + if ("subtitle" in _json.object["title"] + && (_json.object["title"]["subtitle"].type().to!string == "STRING") + ) { + _struct_composite.meta.title_subtitle = _json.object["title"]["subtitle"].str; } } } diff --git a/src/sdp/meta/metadoc_from_src.d b/src/sdp/meta/metadoc_from_src.d index 97e5f78..816f479 100644 --- a/src/sdp/meta/metadoc_from_src.d +++ b/src/sdp/meta/metadoc_from_src.d @@ -358,6 +358,27 @@ template SiSUdocAbstraction() { string[] html_segnames=["toc"]; int cnt1 = 1; int cnt2 = 1; int cnt3 = 1; /+ abstraction init ↑ +/ + debug (substitutions) { + writeln(__LINE__, ":", __FILE__, ": DEBUG substitutions:"); + if (conf_make_meta.make.substitute) { + foreach(substitution_pair; conf_make_meta.make.substitute) { + writeln("regex to match: ", substitution_pair[0]); + writeln("substitution to make: ", substitution_pair[1]); + } + } + if (!(conf_make_meta.make.bold_rgxmatch == "=NULL" || conf_make_meta.make.bold_rgxmatch.empty)) { + writeln("regex to match: ", conf_make_meta.make.bold_rgxmatch); + writeln("substitution to make: ", conf_make_meta.make.bold_substitute_html); + } + if (!(conf_make_meta.make.emphasis_rgxmatch == "=NULL" || conf_make_meta.make.emphasis_rgxmatch.empty)) { + writeln("regex to match: ", conf_make_meta.make.emphasis_rgxmatch); + writeln("substitution to make: ", conf_make_meta.make.emphasis_substitute_html); + } + if (!(conf_make_meta.make.italics_rgxmatch == "=NULL" || conf_make_meta.make.italics_rgxmatch.empty)) { + writeln("regex to match: ", conf_make_meta.make.italics_rgxmatch); + writeln("substitution to make: ", conf_make_meta.make.italics_substitute_html); + } + } /+ ↓ loop markup document/text line by line +/ srcDocLoop: foreach (line; markup_sourcefile_content) { @@ -1931,6 +1952,14 @@ template SiSUdocAbstraction() { debug(asserts) { static assert(is(typeof(line) == char[])); } + if (conf_make_meta.make.substitute) { + foreach(substitution_pair; conf_make_meta.make.substitute) { + line = line.replaceAll( + regex(substitution_pair[0]), + substitution_pair[1] + ); + } + } if (!( conf_make_meta.make.bold_rgxmatch == "=NULL" || conf_make_meta.make.bold_rgxmatch.empty diff --git a/src/sdp/output/paths_source.d b/src/sdp/output/paths_source.d index 475df3e..1be04d2 100644 --- a/src/sdp/output/paths_source.d +++ b/src/sdp/output/paths_source.d @@ -29,7 +29,7 @@ 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) { + && exists(_pth)!=0 && _pth.isFile) { _manifest_path = dirName(_pth); } else if (_pth.match(rgx.src_pth_pod_sst_or_ssm) && exists(_pth)!=0 && (_pth.isFile)) { -- cgit v1.2.3