From 2e852762085122d1b36641a04bcc63d5235139cd Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Fri, 15 Dec 2017 14:06:16 -0500 Subject: 0.23.2 config paths for pod --- org/default_paths.org | 87 ++++++--- org/default_regex.org | 2 +- org/meta_read_source_files.org | 14 +- org/output_sisupod.org | 4 +- org/sdp.org | 378 +++++++++++++++++++-------------------- src/sdp/meta/metadoc.d | 12 +- src/sdp/meta/read_config_files.d | 8 +- src/sdp/meta/read_source_files.d | 6 +- src/sdp/meta/rgx.d | 2 +- src/sdp/output/paths_source.d | 87 ++++++--- src/sdp/output/rgx.d | 2 +- src/sdp/output/source_sisupod.d | 4 +- src/sdp/sdp.d | 6 +- views/version.txt | 2 +- 14 files changed, 350 insertions(+), 264 deletions(-) diff --git a/org/default_paths.org b/org/default_paths.org index f40ebdf..e18d3a5 100644 --- a/org/default_paths.org +++ b/org/default_paths.org @@ -154,9 +154,16 @@ template PodMatters() { ) { _output_path = asNormalizedPath(_opt_actions.output_dir_set).array; if (!exists(_output_path)) { - _output_path.mkdirRecurse; + try { + _output_path.mkdirRecurse; + } + catch (Exception ex) { + // Handle error + } } - assert(_output_path.isDir); + assert(_output_path.isDir, + "not a directory: " ~ _output_path); + // TODO always test that is a directory and it is writable } return _output_path; } @@ -187,34 +194,70 @@ template PodMatters() { template ConfigFilePaths() { mixin SiSUrgxInit; static auto rgx = Rgx(); - auto ConfigFilePaths(E)( + auto ConfigFilePaths(M,E)( + M _manifest, E _env, ) { struct ConfFilePaths { auto possible_config_path_locations() { /+ FIX clean up conf paths ↓ +/ - string _sisudoc_conf_pwd = chainPath(to!string(_env["pwd"]), "sisudoc/conf").array; - string _sisudoc_conf_pwd_a = chainPath(to!string(_env["pwd"]), "conf").array; - string _sisudoc_conf_pwd_b = chainPath(to!string(_env["pwd"]), "../conf").array; - string _sisudoc_conf_pwd_c = chainPath(to!string(_env["pwd"]), "../../conf").array; - string _sisudoc_conf_pwd_d = chainPath(to!string(_env["pwd"]), "../../../conf").array; + /+ config local site (file system only, not in pod) +/ + string _dot_pwd; + string _underscore_pwd; + string _dot_home; + /+ config document (& or local site) on filesystem +/ + string _sisudoc_conf_pwd; // think about + string _sisudoc_conf_pwd_a; + string _sisudoc_conf_pwd_b; + string _sisudoc_conf_pwd_c; + string _sisudoc_conf_pwd_d; + /+ config document in pod +/ + string _sisudoc_conf_pod; + string _sisudoc_conf_pod_text; + /+ return paths +/ + string[] _possible_config_path_locations; + if (_manifest.is_pod) { + /+ config document in pod +/ + _sisudoc_conf_pod = asNormalizedPath(chainPath( + to!string(_env["pwd"]), + _manifest.pod_manifest_path ~ "/conf" + )).array; + _sisudoc_conf_pod_text = asNormalizedPath(chainPath( + to!string(_env["pwd"]), + _manifest.pod_manifest_path ~ "/media/text/" ~ _manifest.src_lng ~ "/conf" + )).array; + /+ return paths +/ + _possible_config_path_locations = [ + _sisudoc_conf_pod_text, + _sisudoc_conf_pod, + ]; + } else { + /+ config local site (file system only, not in pod) +/ + _dot_pwd = asNormalizedPath(chainPath(to!string(_env["pwd"]), ".sisu")).array; + _underscore_pwd = asNormalizedPath(chainPath(to!string(_env["pwd"]), "_sisu")).array; + _dot_home = asNormalizedPath(chainPath(to!string(_env["home"]), ".sisu")).array; + /+ config document (& or local site) on filesystem +/ + _sisudoc_conf_pwd = asNormalizedPath(chainPath(to!string(_env["pwd"]), "sisudoc/conf")).array; // think about + _sisudoc_conf_pwd_a = asNormalizedPath(chainPath(to!string(_env["pwd"]), "conf")).array; + _sisudoc_conf_pwd_b = asNormalizedPath(chainPath(to!string(_env["pwd"]), "../conf")).array; + _sisudoc_conf_pwd_c = asNormalizedPath(chainPath(to!string(_env["pwd"]), "../../conf")).array; + _sisudoc_conf_pwd_d = asNormalizedPath(chainPath(to!string(_env["pwd"]), "../../../conf")).array; + /+ return paths +/ + _possible_config_path_locations = [ + _sisudoc_conf_pwd, + _sisudoc_conf_pwd_a, + _sisudoc_conf_pwd_b, + _sisudoc_conf_pwd_c, + _sisudoc_conf_pwd_d, + _dot_pwd, + _underscore_pwd, + _dot_home, + "/etc/sisu" + ]; + } /+ FIX clean up conf paths ↑ (compare pwd to doc path location, and build config path) +/ - string _dot_pwd = chainPath(to!string(_env["pwd"]), ".sisu").array; - string _underscore_pwd = chainPath(to!string(_env["pwd"]), "_sisu").array; - string _dot_home = chainPath(to!string(_env["home"]), ".sisu").array; - string[] _possible_config_path_locations = [ - _sisudoc_conf_pwd, - _sisudoc_conf_pwd_a, - _sisudoc_conf_pwd_b, - _sisudoc_conf_pwd_c, - _sisudoc_conf_pwd_d, - _dot_pwd, - _underscore_pwd, - _dot_home, - "/etc/sisu" - ]; return _possible_config_path_locations; } } diff --git a/org/default_regex.org b/org/default_regex.org index 92197ef..bf86258 100644 --- a/org/default_regex.org +++ b/org/default_regex.org @@ -411,7 +411,7 @@ static nbsp_char_and_space = ctRegex!(`░[ ]`, "mg") #+name: prgmkup_rgx #+BEGIN_SRC d -static src_pth = ctRegex!(`^(?P[/]?(?:[a-zA-Z0-9._-]+/)*)(?P[a-zA-Z0-9._-]+[.]ss[tm])$`); +static src_pth_sst_or_ssm = ctRegex!(`^(?P[/]?(?:[a-zA-Z0-9._-]+/)*)(?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_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])$`); diff --git a/org/meta_read_source_files.org b/org/meta_read_source_files.org index 8062f46..b4b4d69 100644 --- a/org/meta_read_source_files.org +++ b/org/meta_read_source_files.org @@ -47,8 +47,8 @@ module sdp.meta.read_config_files; #+BEGIN_SRC d static template configIn() { <> - final string configIn(C,E)(C conf_sdl, E env) { - auto possible_config_path_locations = ConfigFilePaths!()(env).possible_config_path_locations; + final string configIn(M,E,C)(M manifest, E env, C conf_sdl) { + auto possible_config_path_locations = ConfigFilePaths!()(manifest, env).possible_config_path_locations; string config_file_str; foreach(pth; possible_config_path_locations) { auto conf_file = format( @@ -135,8 +135,8 @@ Read in sdl config file name given, and return sdl root #+name: meta_config_file_sdlang_hub #+BEGIN_SRC d -final auto configRead(C,E)(C conf_sdl, E env) { - auto configuration = configIn!()(conf_sdl, env); +final auto configRead(M,E,C)(M manifest, E env, C conf_sdl) { + auto configuration = configIn!()(manifest, env, conf_sdl); auto sdl_root = ConfigSDLang!()(configuration, conf_sdl); return sdl_root; } @@ -333,7 +333,7 @@ final private char[][] markupSourceLineArray(in char[] src_text) { auto markupSourceReadIn(in string fn_src) { static auto rgx = Rgx(); enforce( - fn_src.match(rgx.src_pth), + fn_src.match(rgx.src_pth_sst_or_ssm), "not a sisu markup filename: «" ~ fn_src ~ "»" ); @@ -397,7 +397,7 @@ final char[][] getInsertMarkupSourceContentRawLineArray( #+BEGIN_SRC d char[][] contents_insert; auto type1 = flags_type_init; -auto fn_pth_full = fn_src.match(rgx.src_pth); +auto fn_pth_full = fn_src.match(rgx.src_pth_sst_or_ssm); auto markup_src_file_path = fn_pth_full.captures[1]; #+END_SRC @@ -505,7 +505,7 @@ return t; #+BEGIN_SRC d char[][] contents; auto type = flags_type_init; -auto fn_pth_full = fn_src.match(rgx.src_pth); +auto fn_pth_full = fn_src.match(rgx.src_pth_sst_or_ssm); auto markup_src_file_path = fn_pth_full.captures[1]; char[][] contents_insert; string[] _images =[]; diff --git a/org/output_sisupod.org b/org/output_sisupod.org index deb1c82..8e6aeb7 100644 --- a/org/output_sisupod.org +++ b/org/output_sisupod.org @@ -251,7 +251,7 @@ if (exists(fn_sisupod)) { catch (ZipException ex) { // Handle errors } - if (doc_matters.source_filename == "sisudoc/text/en/the_wealth_of_networks.yochai_benkler.sst") { + if (doc_matters.source_filename == "sisudoc/media/text/en/the_wealth_of_networks.yochai_benkler.sst") { assert( ((data).sha256Of).toHexString == "626F83A31ED82F42CF528E922C1643498A137ABA3F2E5AFF8A379EA79EA22A1E", @@ -261,7 +261,7 @@ if (exists(fn_sisupod)) { ~ ((data).sha256Of).toHexString ); } - if (doc_matters.source_filename == "sisudoc/text/en/sisu_markup_stress_test.sst") { + if (doc_matters.source_filename == "sisudoc/media/text/en/sisu_markup_stress_test.sst") { assert( ((data).sha256Of).toHexString == "AAE0C87AB3F6D5F7385AEEA6EE661F56D40475CFE87AD930C78C9FE07FFB0D91", diff --git a/org/sdp.org b/org/sdp.org index 4afed8b..13ce647 100644 --- a/org/sdp.org +++ b/org/sdp.org @@ -26,7 +26,7 @@ struct Version { int minor; int patch; } -enum ver = Version(0, 23, 1); +enum ver = Version(0, 23, 2); #+END_SRC ** compilation restrictions (supported compilers) @@ -492,7 +492,7 @@ foreach(arg; args[1..$]) { _manifest_start = PodManifest!()(arg); if (arg.match(rgx.flag_action)) { flag_action ~= " " ~ arg; // flags not taken by getopt - } else if (arg.match(rgx.src_pth)) { + } else if (arg.match(rgx.src_pth_sst_or_ssm)) { _manifests ~= PodMatters!()(_opt_action, _env, arg, arg); // gather input markup source file names for processing } else if (_manifest_start.pod_manifest_file_with_path) { string contents_location_raw_; @@ -526,7 +526,7 @@ foreach(arg; args[1..$]) { (cast(char[]) contents_location_).split; auto tmp_dir_ = (sisudoc_txt_).dirName.array; foreach (contents_location; contents_locations_arr) { - assert(contents_location.match(rgx.src_pth), + assert(contents_location.match(rgx.src_pth_sst_or_ssm), "not a recognised file: «" ~ contents_location ~ "»" ); @@ -552,9 +552,9 @@ foreach(arg; args[1..$]) { #+NAME: sdp_conf_files #+BEGIN_SRC d -auto sdl_root_config_share = configRead!()("config_share", _env); -auto sdl_root_config_local = configRead!()("config_local", _env); -auto conf_files_composite_make = confFilesSDLtoStruct!()(sdl_root_config_share, sdl_root_config_local); +auto sdl_root_config_document = configRead!()(_manifest, _env, "config_document"); // document config file +auto sdl_root_config_local_site = configRead!()(_manifest, _env, "config_local_site"); // local site config +auto conf_files_composite_make = confFilesSDLtoStruct!()(sdl_root_config_document, sdl_root_config_local_site); #+END_SRC ** 2a. actions independent of processing files @@ -603,7 +603,7 @@ enforce( #+NAME: sdp_abstraction #+BEGIN_SRC d -auto t = SiSUabstraction!()(manifest, _opt_action, _env); +auto t = SiSUabstraction!()(_env, _opt_action, manifest); static assert(!isTypeTuple!(t)); static assert(t.length==2); auto doc_abstraction = t[dAM.abstraction]; @@ -680,10 +680,10 @@ template SiSUabstraction() { enum makeMeta { make, meta } enum docAbst { doc_abstraction, section_keys, segnames, segnames_0_4, images } static auto rgx = Rgx(); - auto SiSUabstraction(M,O,E)( - M _manifest, - O _opt_action, + auto SiSUabstraction(E,O,M)( E _env, + O _opt_action, + M _manifest, ){ <> <> @@ -1245,10 +1245,10 @@ provide the result as a single set of make instructions for each document parsed | | set of make instructions | provided below, provide interface | | | |----+---------------------------------+----------------------------------------+---------------------+---| | 1. | document_make file | to be applied to all documents | per directory | | -| | "config_share" | (unless subsequently overridden) | (all docs within) | | +| | "config_document" | (unless subsequently overridden) | (all docs within) | | |----+---------------------------------+----------------------------------------+---------------------+---| | 2. | config file | local site specific | per directory | | -| | "config_local" | | (all docs within) | | +| | "config_local_site" | | (all docs within) | | |----+---------------------------------+----------------------------------------+---------------------+---| | 3. | document header make | make instructions contained | per document | | | | | in document header | (single doc) | | @@ -1259,180 +1259,180 @@ provide the result as a single set of make instructions for each document parsed *** config & metadata (from instruction sources) -|---------------------+-----------------------+-------------------------+------------------------+-----------------------------| -| | 1. document make file | 2. config file | 3. document header | 4. command line instruction | -|---------------------+-----------------------+-------------------------+------------------------+-----------------------------| -| comment, fixed: | per dir (sisupod) | per dir | per document (sisupod) | per command instruction | -|---------------------+-----------------------+-------------------------+------------------------+-----------------------------| -| | sdl_root_config_share | sdl_root_config_local | | | -|---------------------+-----------------------+-------------------------+------------------------+-----------------------------| -| local site specific | | * | | *? | -|---------------------+-----------------------+-------------------------+------------------------+-----------------------------| -| | | webserv | | | -| | | - url_root | | | -| | | - path | | | -| | | - images | | | -| | | - cgi | | | -|---------------------+-----------------------+-------------------------+------------------------+-----------------------------| -| | | webserv_cgi | | | -| | | - host | | | -| | | - base_path | | | -| | | - port | | | -| | | - user | | | -| | | - file_links | | | -|---------------------+-----------------------+-------------------------+------------------------+-----------------------------| -| | | processing | | | -| | | - path | | | -| | | - dir | | | -| | | - concord_max | | | -|---------------------+-----------------------+-------------------------+------------------------+-----------------------------| -| | | flag (configure) | | (call) | -| | | - act0 | | act0 | -| | | - act1 | | act1 | -| | | - act2 | | act2 | -| | | - act3 | | act3 | -| | | - act4 | | act4 | -| | | - act5 | | act5 | -| | | - act6 | | act6 | -| | | - act7 | | act7 | -| | | - act8 | | act8 | -| | | - act9 | | act9 | -|---------------------+-----------------------+-------------------------+------------------------+-----------------------------| -| | | default | | | -| | | - papersize | | | -| | | - text_wrap | | | -| | | - emphasis | | | -| | | - language | | | -| | | - digest | | | -|---------------------+-----------------------+-------------------------+------------------------+-----------------------------| -| | | permission | | | -| | | - share_source | | | -|---------------------+-----------------------+-------------------------+------------------------+-----------------------------| -| | | program_select | | | -| | | - editor | | | -| | | - epub_viewer | | | -| | | - html_viewer | | | -| | | - odf_viewer | | | -| | | - pdf_viewer | | | -| | | - xml_viewer | | | -|---------------------+-----------------------+-------------------------+------------------------+-----------------------------| -| | | search | | | -| | | - flag | | | -| | | - action | | | -| | | - db | | | -| | | - title | | | -|---------------------+-----------------------+-------------------------+------------------------+-----------------------------| -| make instruction | ** | omit or override share? | ** | *? | -|---------------------+-----------------------+-------------------------+------------------------+-----------------------------| -| | make | make | make | | -| | - bold | - bold | - bold | | -| | - breaks | - breaks | - breaks | | -| | - cover_image | - cover_image | - cover_image | | -| | - css | - css | - css | | -| | - emphasis | - emphasis | - emphasis | | -| | - footer | - footer | - footer | | -| | - headings | - headings | - headings | | -| | - home_button_image | - home_button_image | - home_button_image | | -| | - home_button_text | - home_button_text | - home_button_text | | -| | - italics | - italics | - italics | | -| | - num_top | - num_top | - num_top | | -| | - num_depth | - num_depth | - num_depth | | -| | - substitute | - substitute | - substitute | | -| | - texpdf_font | - texpdf_font | - texpdf_font | | -|---------------------+-----------------------+-------------------------+------------------------+-----------------------------| -| actions | | | | * | -|---------------------+-----------------------+-------------------------+------------------------+-----------------------------| -| | | | | assertions | -| | | | | concordance | -| | | | | debug | -| | | | | digest | -| | | | | docbook | -| | | | | epub | -| | | | | html | -| | | | | html-seg | -| | | | | html-scroll | -| | | | | manifest | -| | | | | ocn | -| | | | | odt | -| | | | | pdf | -| | | | | postgresql | -| | | | | qrcode | -| | | | | sisupod | -| | | | | source | -| | | | | sqlite | -| | | | | sqlite-create | -| | | | | sqlite-drop | -| | | | | text | -| | | | | verbose | -| | | | | xhtml | -| | | | | xml-dom | -| | | | | xml-sax | -| | | | | section_toc | -| | | | | section_body | -| | | | | section_endnotes | -| | | | | section_glossary | -| | | | | section_biblio | -| | | | | section_bookindex | -| | | | | section_blurb | -| | | | | backmatter | -| | | | | skip-output | -|---------------------+-----------------------+-------------------------+------------------------+-----------------------------| -| metadata | | | * | | -|---------------------+-----------------------+-------------------------+------------------------+-----------------------------| -| | | | classify | | -| | | | - dewey | | -| | | | - keywords | | -| | | | - loc | | -| | | | - subject | | -| | | | - topic_register | | -|---------------------+-----------------------+-------------------------+------------------------+-----------------------------| -| | | | creator | | -| | | | - author | | -| | | | - author_email | | -| | | | - illustrator | | -| | | | - translator | | -|---------------------+-----------------------+-------------------------+------------------------+-----------------------------| -| | | | date | | -| | | | - added_to_site | | -| | | | - available | | -| | | | - created | | -| | | | - issued | | -| | | | - modified | | -| | | | - published | | -| | | | - valid | | -|---------------------+-----------------------+-------------------------+------------------------+-----------------------------| -| | | | identifier | | -| | | | - isbn | | -| | | | - oclc | | -| | | | - pg | | -|---------------------+-----------------------+-------------------------+------------------------+-----------------------------| -| | | | links | | -| | | | - link | | -|---------------------+-----------------------+-------------------------+------------------------+-----------------------------| -| | | | notes | | -| | | | - abstract | | -| | | | - description | | -|---------------------+-----------------------+-------------------------+------------------------+-----------------------------| -| | | | original | | -| | | | - language | | -| | | | - source | | -| | | | - title | | -|---------------------+-----------------------+-------------------------+------------------------+-----------------------------| -| | | | publisher | | -| | | | - name | | -|---------------------+-----------------------+-------------------------+------------------------+-----------------------------| -| | | | rights | | -| | | | - copyright | | -| | | | - cover | | -| | | | - illustrations | | -| | | | - license | | -|---------------------+-----------------------+-------------------------+------------------------+-----------------------------| -| | | | title | | -| | | | - edition | | -| | | | - full | | -| | | | - language | | -| | | | - main | | -| | | | - note | | -| | | | - sub | | -| | | | - subtitle | | -|---------------------+-----------------------+-------------------------+------------------------+-----------------------------| +|---------------------+--------------------------+----------------------------+------------------------+-----------------------------| +| | 1. document make file | 2. config file | 3. document header | 4. command line instruction | +|---------------------+--------------------------+----------------------------+------------------------+-----------------------------| +| comment, fixed: | per dir (sisupod) | per dir | per document (sisupod) | per command instruction | +|---------------------+--------------------------+----------------------------+------------------------+-----------------------------| +| | sdl_root_config_document | sdl_root_config_local_site | | | +|---------------------+--------------------------+----------------------------+------------------------+-----------------------------| +| local site specific | | * | | *? | +|---------------------+--------------------------+----------------------------+------------------------+-----------------------------| +| | | webserv | | | +| | | - url_root | | | +| | | - path | | | +| | | - images | | | +| | | - cgi | | | +|---------------------+--------------------------+----------------------------+------------------------+-----------------------------| +| | | webserv_cgi | | | +| | | - host | | | +| | | - base_path | | | +| | | - port | | | +| | | - user | | | +| | | - file_links | | | +|---------------------+--------------------------+----------------------------+------------------------+-----------------------------| +| | | processing | | | +| | | - path | | | +| | | - dir | | | +| | | - concord_max | | | +|---------------------+--------------------------+----------------------------+------------------------+-----------------------------| +| | | flag (configure) | | (call) | +| | | - act0 | | act0 | +| | | - act1 | | act1 | +| | | - act2 | | act2 | +| | | - act3 | | act3 | +| | | - act4 | | act4 | +| | | - act5 | | act5 | +| | | - act6 | | act6 | +| | | - act7 | | act7 | +| | | - act8 | | act8 | +| | | - act9 | | act9 | +|---------------------+--------------------------+----------------------------+------------------------+-----------------------------| +| | | default | | | +| | | - papersize | | | +| | | - text_wrap | | | +| | | - emphasis | | | +| | | - language | | | +| | | - digest | | | +|---------------------+--------------------------+----------------------------+------------------------+-----------------------------| +| | | permission | | | +| | | - share_source | | | +|---------------------+--------------------------+----------------------------+------------------------+-----------------------------| +| | | program_select | | | +| | | - editor | | | +| | | - epub_viewer | | | +| | | - html_viewer | | | +| | | - odf_viewer | | | +| | | - pdf_viewer | | | +| | | - xml_viewer | | | +|---------------------+--------------------------+----------------------------+------------------------+-----------------------------| +| | | search | | | +| | | - flag | | | +| | | - action | | | +| | | - db | | | +| | | - title | | | +|---------------------+--------------------------+----------------------------+------------------------+-----------------------------| +| make instruction | ** | omit or override share? | ** | *? | +|---------------------+--------------------------+----------------------------+------------------------+-----------------------------| +| | make | make | make | | +| | - bold | - bold | - bold | | +| | - breaks | - breaks | - breaks | | +| | - cover_image | - cover_image | - cover_image | | +| | - css | - css | - css | | +| | - emphasis | - emphasis | - emphasis | | +| | - footer | - footer | - footer | | +| | - headings | - headings | - headings | | +| | - home_button_image | - home_button_image | - home_button_image | | +| | - home_button_text | - home_button_text | - home_button_text | | +| | - italics | - italics | - italics | | +| | - num_top | - num_top | - num_top | | +| | - num_depth | - num_depth | - num_depth | | +| | - substitute | - substitute | - substitute | | +| | - texpdf_font | - texpdf_font | - texpdf_font | | +|---------------------+--------------------------+----------------------------+------------------------+-----------------------------| +| actions | | | | * | +|---------------------+--------------------------+----------------------------+------------------------+-----------------------------| +| | | | | assertions | +| | | | | concordance | +| | | | | debug | +| | | | | digest | +| | | | | docbook | +| | | | | epub | +| | | | | html | +| | | | | html-seg | +| | | | | html-scroll | +| | | | | manifest | +| | | | | ocn | +| | | | | odt | +| | | | | pdf | +| | | | | postgresql | +| | | | | qrcode | +| | | | | sisupod | +| | | | | source | +| | | | | sqlite | +| | | | | sqlite-create | +| | | | | sqlite-drop | +| | | | | text | +| | | | | verbose | +| | | | | xhtml | +| | | | | xml-dom | +| | | | | xml-sax | +| | | | | section_toc | +| | | | | section_body | +| | | | | section_endnotes | +| | | | | section_glossary | +| | | | | section_biblio | +| | | | | section_bookindex | +| | | | | section_blurb | +| | | | | backmatter | +| | | | | skip-output | +|---------------------+--------------------------+----------------------------+------------------------+-----------------------------| +| metadata | | | * | | +|---------------------+--------------------------+----------------------------+------------------------+-----------------------------| +| | | | classify | | +| | | | - dewey | | +| | | | - keywords | | +| | | | - loc | | +| | | | - subject | | +| | | | - topic_register | | +|---------------------+--------------------------+----------------------------+------------------------+-----------------------------| +| | | | creator | | +| | | | - author | | +| | | | - author_email | | +| | | | - illustrator | | +| | | | - translator | | +|---------------------+--------------------------+----------------------------+------------------------+-----------------------------| +| | | | date | | +| | | | - added_to_site | | +| | | | - available | | +| | | | - created | | +| | | | - issued | | +| | | | - modified | | +| | | | - published | | +| | | | - valid | | +|---------------------+--------------------------+----------------------------+------------------------+-----------------------------| +| | | | identifier | | +| | | | - isbn | | +| | | | - oclc | | +| | | | - pg | | +|---------------------+--------------------------+----------------------------+------------------------+-----------------------------| +| | | | links | | +| | | | - link | | +|---------------------+--------------------------+----------------------------+------------------------+-----------------------------| +| | | | notes | | +| | | | - abstract | | +| | | | - description | | +|---------------------+--------------------------+----------------------------+------------------------+-----------------------------| +| | | | original | | +| | | | - language | | +| | | | - source | | +| | | | - title | | +|---------------------+--------------------------+----------------------------+------------------------+-----------------------------| +| | | | publisher | | +| | | | - name | | +|---------------------+--------------------------+----------------------------+------------------------+-----------------------------| +| | | | rights | | +| | | | - copyright | | +| | | | - cover | | +| | | | - illustrations | | +| | | | - license | | +|---------------------+--------------------------+----------------------------+------------------------+-----------------------------| +| | | | title | | +| | | | - edition | | +| | | | - full | | +| | | | - language | | +| | | | - main | | +| | | | - note | | +| | | | - sub | | +| | | | - subtitle | | +|---------------------+--------------------------+----------------------------+------------------------+-----------------------------| diff --git a/src/sdp/meta/metadoc.d b/src/sdp/meta/metadoc.d index e3947e5..8fafc24 100644 --- a/src/sdp/meta/metadoc.d +++ b/src/sdp/meta/metadoc.d @@ -31,14 +31,14 @@ template SiSUabstraction() { enum makeMeta { make, meta } enum docAbst { doc_abstraction, section_keys, segnames, segnames_0_4, images } static auto rgx = Rgx(); - auto SiSUabstraction(M,O,E)( - M _manifest, - O _opt_action, + auto SiSUabstraction(E,O,M)( E _env, + O _opt_action, + M _manifest, ){ - auto sdl_root_config_share = configRead!()("config_share", _env); - auto sdl_root_config_local = configRead!()("config_local", _env); - auto conf_files_composite_make = confFilesSDLtoStruct!()(sdl_root_config_share, sdl_root_config_local); + auto sdl_root_config_document = configRead!()(_manifest, _env, "config_document"); // document config file + auto sdl_root_config_local_site = configRead!()(_manifest, _env, "config_local_site"); // local site config + auto conf_files_composite_make = confFilesSDLtoStruct!()(sdl_root_config_document, sdl_root_config_local_site); /+ ↓ read file (filename with path) +/ /+ ↓ file tuple of header and content +/ debug(steps) { diff --git a/src/sdp/meta/read_config_files.d b/src/sdp/meta/read_config_files.d index 369d9c2..b3c7f1b 100644 --- a/src/sdp/meta/read_config_files.d +++ b/src/sdp/meta/read_config_files.d @@ -10,8 +10,8 @@ static template configIn() { sdp.output.paths_source, std.file, std.path; - final string configIn(C,E)(C conf_sdl, E env) { - auto possible_config_path_locations = ConfigFilePaths!()(env).possible_config_path_locations; + final string configIn(M,E,C)(M manifest, E env, C conf_sdl) { + auto possible_config_path_locations = ConfigFilePaths!()(manifest, env).possible_config_path_locations; string config_file_str; foreach(pth; possible_config_path_locations) { auto conf_file = format( @@ -70,8 +70,8 @@ static template configRead() { std.file, std.path; - final auto configRead(C,E)(C conf_sdl, E env) { - auto configuration = configIn!()(conf_sdl, env); + final auto configRead(M,E,C)(M manifest, E env, C conf_sdl) { + auto configuration = configIn!()(manifest, env, conf_sdl); auto sdl_root = ConfigSDLang!()(configuration, conf_sdl); return sdl_root; } diff --git a/src/sdp/meta/read_source_files.d b/src/sdp/meta/read_source_files.d index 2fce0be..95a9dbe 100644 --- a/src/sdp/meta/read_source_files.d +++ b/src/sdp/meta/read_source_files.d @@ -115,7 +115,7 @@ static template SiSUrawMarkupContent() { auto markupSourceReadIn(in string fn_src) { static auto rgx = Rgx(); enforce( - fn_src.match(rgx.src_pth), + fn_src.match(rgx.src_pth_sst_or_ssm), "not a sisu markup filename: «" ~ fn_src ~ "»" ); @@ -161,7 +161,7 @@ static template SiSUrawMarkupContent() { mixin SiSUrgxInitFlags; char[][] contents_insert; auto type1 = flags_type_init; - auto fn_pth_full = fn_src.match(rgx.src_pth); + auto fn_pth_full = fn_src.match(rgx.src_pth_sst_or_ssm); auto markup_src_file_path = fn_pth_full.captures[1]; foreach (line; markup_sourcefile_insert_content) { if (type1["curly_code"] == 1) { @@ -260,7 +260,7 @@ static template SiSUrawMarkupContent() { mixin SiSUrgxInitFlags; char[][] contents; auto type = flags_type_init; - auto fn_pth_full = fn_src.match(rgx.src_pth); + auto fn_pth_full = fn_src.match(rgx.src_pth_sst_or_ssm); auto markup_src_file_path = fn_pth_full.captures[1]; char[][] contents_insert; string[] _images =[]; diff --git a/src/sdp/meta/rgx.d b/src/sdp/meta/rgx.d index 73f7bfe..37db8e7 100644 --- a/src/sdp/meta/rgx.d +++ b/src/sdp/meta/rgx.d @@ -196,7 +196,7 @@ static template SiSUrgxInit() { static nbsp_chars_line_start = ctRegex!(`^░+`, "mg"); static nbsp_and_space = ctRegex!(` [ ]`, "mg"); static nbsp_char_and_space = ctRegex!(`░[ ]`, "mg"); - static src_pth = ctRegex!(`^(?P[/]?(?:[a-zA-Z0-9._-]+/)*)(?P[a-zA-Z0-9._-]+[.]ss[tm])$`); + static src_pth_sst_or_ssm = ctRegex!(`^(?P[/]?(?:[a-zA-Z0-9._-]+/)*)(?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_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])$`); diff --git a/src/sdp/output/paths_source.d b/src/sdp/output/paths_source.d index 0a8b447..4f8eb54 100644 --- a/src/sdp/output/paths_source.d +++ b/src/sdp/output/paths_source.d @@ -117,9 +117,16 @@ template PodMatters() { ) { _output_path = asNormalizedPath(_opt_actions.output_dir_set).array; if (!exists(_output_path)) { - _output_path.mkdirRecurse; + try { + _output_path.mkdirRecurse; + } + catch (Exception ex) { + // Handle error + } } - assert(_output_path.isDir); + assert(_output_path.isDir, + "not a directory: " ~ _output_path); + // TODO always test that is a directory and it is writable } return _output_path; } @@ -144,34 +151,70 @@ template PodMatters() { template ConfigFilePaths() { mixin SiSUrgxInit; static auto rgx = Rgx(); - auto ConfigFilePaths(E)( + auto ConfigFilePaths(M,E)( + M _manifest, E _env, ) { struct ConfFilePaths { auto possible_config_path_locations() { /+ FIX clean up conf paths ↓ +/ - string _sisudoc_conf_pwd = chainPath(to!string(_env["pwd"]), "sisudoc/conf").array; - string _sisudoc_conf_pwd_a = chainPath(to!string(_env["pwd"]), "conf").array; - string _sisudoc_conf_pwd_b = chainPath(to!string(_env["pwd"]), "../conf").array; - string _sisudoc_conf_pwd_c = chainPath(to!string(_env["pwd"]), "../../conf").array; - string _sisudoc_conf_pwd_d = chainPath(to!string(_env["pwd"]), "../../../conf").array; + /+ config local site (file system only, not in pod) +/ + string _dot_pwd; + string _underscore_pwd; + string _dot_home; + /+ config document (& or local site) on filesystem +/ + string _sisudoc_conf_pwd; // think about + string _sisudoc_conf_pwd_a; + string _sisudoc_conf_pwd_b; + string _sisudoc_conf_pwd_c; + string _sisudoc_conf_pwd_d; + /+ config document in pod +/ + string _sisudoc_conf_pod; + string _sisudoc_conf_pod_text; + /+ return paths +/ + string[] _possible_config_path_locations; + if (_manifest.is_pod) { + /+ config document in pod +/ + _sisudoc_conf_pod = asNormalizedPath(chainPath( + to!string(_env["pwd"]), + _manifest.pod_manifest_path ~ "/conf" + )).array; + _sisudoc_conf_pod_text = asNormalizedPath(chainPath( + to!string(_env["pwd"]), + _manifest.pod_manifest_path ~ "/media/text/" ~ _manifest.src_lng ~ "/conf" + )).array; + /+ return paths +/ + _possible_config_path_locations = [ + _sisudoc_conf_pod_text, + _sisudoc_conf_pod, + ]; + } else { + /+ config local site (file system only, not in pod) +/ + _dot_pwd = asNormalizedPath(chainPath(to!string(_env["pwd"]), ".sisu")).array; + _underscore_pwd = asNormalizedPath(chainPath(to!string(_env["pwd"]), "_sisu")).array; + _dot_home = asNormalizedPath(chainPath(to!string(_env["home"]), ".sisu")).array; + /+ config document (& or local site) on filesystem +/ + _sisudoc_conf_pwd = asNormalizedPath(chainPath(to!string(_env["pwd"]), "sisudoc/conf")).array; // think about + _sisudoc_conf_pwd_a = asNormalizedPath(chainPath(to!string(_env["pwd"]), "conf")).array; + _sisudoc_conf_pwd_b = asNormalizedPath(chainPath(to!string(_env["pwd"]), "../conf")).array; + _sisudoc_conf_pwd_c = asNormalizedPath(chainPath(to!string(_env["pwd"]), "../../conf")).array; + _sisudoc_conf_pwd_d = asNormalizedPath(chainPath(to!string(_env["pwd"]), "../../../conf")).array; + /+ return paths +/ + _possible_config_path_locations = [ + _sisudoc_conf_pwd, + _sisudoc_conf_pwd_a, + _sisudoc_conf_pwd_b, + _sisudoc_conf_pwd_c, + _sisudoc_conf_pwd_d, + _dot_pwd, + _underscore_pwd, + _dot_home, + "/etc/sisu" + ]; + } /+ FIX clean up conf paths ↑ (compare pwd to doc path location, and build config path) +/ - string _dot_pwd = chainPath(to!string(_env["pwd"]), ".sisu").array; - string _underscore_pwd = chainPath(to!string(_env["pwd"]), "_sisu").array; - string _dot_home = chainPath(to!string(_env["home"]), ".sisu").array; - string[] _possible_config_path_locations = [ - _sisudoc_conf_pwd, - _sisudoc_conf_pwd_a, - _sisudoc_conf_pwd_b, - _sisudoc_conf_pwd_c, - _sisudoc_conf_pwd_d, - _dot_pwd, - _underscore_pwd, - _dot_home, - "/etc/sisu" - ]; return _possible_config_path_locations; } } diff --git a/src/sdp/output/rgx.d b/src/sdp/output/rgx.d index 9daaa3b..3e03620 100644 --- a/src/sdp/output/rgx.d +++ b/src/sdp/output/rgx.d @@ -15,7 +15,7 @@ static template SiSUoutputRgxInit() { static nbsp_chars_line_start = ctRegex!(`^░+`, "mg"); static nbsp_and_space = ctRegex!(` [ ]`, "mg"); static nbsp_char_and_space = ctRegex!(`░[ ]`, "mg"); - static src_pth = ctRegex!(`^(?P[/]?(?:[a-zA-Z0-9._-]+/)*)(?P[a-zA-Z0-9._-]+[.]ss[tm])$`); + static src_pth_sst_or_ssm = ctRegex!(`^(?P[/]?(?:[a-zA-Z0-9._-]+/)*)(?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_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])$`); diff --git a/src/sdp/output/source_sisupod.d b/src/sdp/output/source_sisupod.d index 20eaf39..0d529b6 100644 --- a/src/sdp/output/source_sisupod.d +++ b/src/sdp/output/source_sisupod.d @@ -190,7 +190,7 @@ template SiSUpod() { catch (ZipException ex) { // Handle errors } - if (doc_matters.source_filename == "sisudoc/text/en/the_wealth_of_networks.yochai_benkler.sst") { + if (doc_matters.source_filename == "sisudoc/media/text/en/the_wealth_of_networks.yochai_benkler.sst") { assert( ((data).sha256Of).toHexString == "626F83A31ED82F42CF528E922C1643498A137ABA3F2E5AFF8A379EA79EA22A1E", @@ -200,7 +200,7 @@ template SiSUpod() { ~ ((data).sha256Of).toHexString ); } - if (doc_matters.source_filename == "sisudoc/text/en/sisu_markup_stress_test.sst") { + if (doc_matters.source_filename == "sisudoc/media/text/en/sisu_markup_stress_test.sst") { assert( ((data).sha256Of).toHexString == "AAE0C87AB3F6D5F7385AEEA6EE661F56D40475CFE87AD930C78C9FE07FFB0D91", diff --git a/src/sdp/sdp.d b/src/sdp/sdp.d index f4d738f..418eb1f 100755 --- a/src/sdp/sdp.d +++ b/src/sdp/sdp.d @@ -309,7 +309,7 @@ void main(string[] args) { _manifest_start = PodManifest!()(arg); if (arg.match(rgx.flag_action)) { flag_action ~= " " ~ arg; // flags not taken by getopt - } else if (arg.match(rgx.src_pth)) { + } else if (arg.match(rgx.src_pth_sst_or_ssm)) { _manifests ~= PodMatters!()(_opt_action, _env, arg, arg); // gather input markup source file names for processing } else if (_manifest_start.pod_manifest_file_with_path) { string contents_location_raw_; @@ -343,7 +343,7 @@ void main(string[] args) { (cast(char[]) contents_location_).split; auto tmp_dir_ = (sisudoc_txt_).dirName.array; foreach (contents_location; contents_locations_arr) { - assert(contents_location.match(rgx.src_pth), + assert(contents_location.match(rgx.src_pth_sst_or_ssm), "not a recognised file: «" ~ contents_location ~ "»" ); @@ -393,7 +393,7 @@ void main(string[] args) { "not a sisu markup filename: «" ~ manifest.src_fn ~ "»" ); - auto t = SiSUabstraction!()(manifest, _opt_action, _env); + auto t = SiSUabstraction!()(_env, _opt_action, manifest); static assert(!isTypeTuple!(t)); static assert(t.length==2); auto doc_abstraction = t[dAM.abstraction]; diff --git a/views/version.txt b/views/version.txt index df1ff31..75c3ff7 100644 --- a/views/version.txt +++ b/views/version.txt @@ -4,7 +4,7 @@ struct Version { int minor; int patch; } -enum ver = Version(0, 23, 1); +enum ver = Version(0, 23, 2); version (Posix) { version (DigitalMars) { } else version (LDC) { -- cgit v1.2.3