From 6b3555e2ae0a7a93f7ab7be1b908a4c15350d460 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Fri, 3 Apr 2020 15:13:31 -0400 Subject: sql, sqlite internal site links --- org/default_regex.org | 3 ++- org/meta_conf_make_meta.org | 11 ++++++++++- org/out_sqlite.org | 38 ++++++++++++++++++++------------------ 3 files changed, 32 insertions(+), 20 deletions(-) (limited to 'org') diff --git a/org/default_regex.org b/org/default_regex.org index b406741..67d259a 100644 --- a/org/default_regex.org +++ b/org/default_regex.org @@ -478,9 +478,10 @@ static inline_link_anchor = ctRegex!(`┃(?P static inline_link = ctRegex!(`┥(?P.+?)┝┤(?P#?(\S+?))├`, "mg"); static inline_link_empty = ctRegex!(`┥(?P.+?)┝┤├`, "mg"); static inline_link_number = ctRegex!(`┥(?P.+?)┝┤(?P[0-9]+)├`, "mg"); // not used -static inline_link_number_only = ctRegex!(`(┥.+?┝)┤(?P[0-9]+)├`, "mg"); +static inline_link_number_only = ctRegex!(`(?P┥.+?┝)┤(?P[0-9]+)├`, "mg"); static inline_link_stow_uri = ctRegex!(`┥(?P.+?)┝┤(?P[^ 0-9#┥┝┤├][^ 0-9┥┝┤├]+)├`, "mg"); // will not stow (stowed links) or object number internal links static inline_link_hash = ctRegex!(`┥(?P.+?)┝┤(?P#(?P\S+?))├`, "mg"); +static inline_link_seg_and_hash = ctRegex!(`┥(?P.+?)┝┤(?P[^/]+?#(?P.+?))├`, "mg"); static inline_link_clean = ctRegex!(`┤(?:.+?)├|[┥┝]`, "mg"); static inline_link_toc_to_backmatter = ctRegex!(`┤#(?Pendnotes|bibliography|bookindex|glossary|blurb)├`, "mg"); static url = ctRegex!(`https?://`, "mg"); diff --git a/org/meta_conf_make_meta.org b/org/meta_conf_make_meta.org index 8777fde..4a5e610 100644 --- a/org/meta_conf_make_meta.org +++ b/org/meta_conf_make_meta.org @@ -257,6 +257,7 @@ struct ConfCompositeSiteLocal { string w_srv_data_domain; // if not set same as webserv_domain string w_srv_data_root_part; string w_srv_data_root_url; + string w_srv_data_root_url_html; string w_srv_data_root_path; string w_srv_images_root_part; // string w_srv_url_doc_path; @@ -650,9 +651,17 @@ if ("webserv" in _yaml && _yaml["webserv"]["data_root_url"].type.string && _yaml["webserv"]["data_root_url"].tag.match(rgx.yaml_tag_is_str) ) { - _struct_composite.conf.w_srv_data_root_url = _yaml["webserv"]["data_root_url"].get!string; + _struct_composite.conf.w_srv_data_root_url = _yaml["webserv"]["data_root_url"].get!string; + _struct_composite.conf.w_srv_data_root_url_html = + _yaml["webserv"]["data_root_url"].get!string ~ "/" + ~ _manifested.src.language ~ "/" + ~ "html"; } else { _struct_composite.conf.w_srv_data_root_url = _struct_composite.conf.w_srv_data_root_part; + _struct_composite.conf.w_srv_data_root_url_html = + _struct_composite.conf.w_srv_data_root_part ~ "/" + ~ _manifested.src.language ~ "/" + ~ "html"; } if ("cgi_domain" in _yaml["webserv"] && _yaml["webserv"]["cgi_domain"].type.string diff --git a/org/out_sqlite.org b/org/out_sqlite.org index 944ed18..e886fbd 100644 --- a/org/out_sqlite.org +++ b/org/out_sqlite.org @@ -106,7 +106,7 @@ template SQLiteHubDiscreteBuildTablesAndPopulate() { const D doc_abstraction, M doc_matters, ) { - auto url_html = spineUrlsHTML!()(doc_matters.conf_make_meta.conf.w_srv_data_root_url, doc_matters.src.language); + auto url_html = spineUrlsHTML!()(doc_matters.conf_make_meta.conf.w_srv_data_root_url_html, doc_matters.src.language); auto pth_sqlite = spinePathsSQLiteDiscrete!()(doc_matters.output_path, doc_matters.src.language); pth_sqlite.base.mkdirRecurse; auto db = Database(pth_sqlite.sqlite_file(doc_matters.src.filename)); @@ -257,7 +257,7 @@ template SQLiteInsertDocObjectsLoop() { M doc_matters, ) { string _uid = SQLinsertDelimiter!()(doc_matters.src.doc_uid); - auto url_html = spineUrlsHTML!()(doc_matters.conf_make_meta.conf.w_srv_data_root_url, doc_matters.src.language); + auto url_html = spineUrlsHTML!()(doc_matters.conf_make_meta.conf.w_srv_data_root_url_html, doc_matters.src.language); string insertDocObjectsRow(O)(O obj) { <> return _insert_doc_objects_row; @@ -594,7 +594,7 @@ string inline_links(M,O)( if (obj.has.inline_links) { if (obj.metainfo.is_a != "code") { _txt = replaceAll!(m => - m[1] ~ "┤" ~ to!string((obj.stow.link[m[2].to!ulong])).encode ~ "├" + m["linked_text"] ~ "┤" ~ to!string((obj.stow.link[m["num"].to!ulong])).encode ~ "├" )(_txt, rgx.inline_link_number_only); } if ((_txt.match(rgx.mark_internal_site_lnk)) @@ -605,24 +605,26 @@ string inline_links(M,O)( } auto pth_html = spinePathsHTML!()(doc_matters.output_path, doc_matters.src.language); if (_xml_type == "seg") { - foreach (m; _txt.match(rgx.inline_link_hash)) { - if (m.captures[3] in doc_matters.has.tag_associations) { - if (m.captures[3] == doc_matters.has.tag_associations[(m.captures[3])]["seg_lv4"]) { + foreach (m; _txt.match(rgx.inline_link_seg_and_hash)) { + if (m.captures["segname"] in doc_matters.has.tag_associations) { + if (m.captures["segname"] == doc_matters.has.tag_associations[(m.captures["segname"])]["seg_lv4"]) { _txt = _txt.replaceFirst( - rgx.inline_link_hash, + rgx.inline_link_seg_and_hash, "┥$1┝┤" - ~ doc_matters.conf_make_meta.conf.w_srv_data_root_url + ~ doc_matters.conf_make_meta.conf.w_srv_data_root_url_html ~ "/" - ~ pth_html.tail_fn_seg(doc_matters.src.filename, "$3.html") + ~ pth_html.tail_fn_seg(doc_matters.src.filename, "$2.html") ~ "├" ); } else { _txt = _txt.replaceFirst( - rgx.inline_link_hash, + rgx.inline_link_seg_and_hash, "┥$1┝┤" - ~ doc_matters.conf_make_meta.conf.w_srv_data_root_url + ~ doc_matters.conf_make_meta.conf.w_srv_data_root_url_html ~ "/" - ~ doc_matters.has.tag_associations[(m.captures[3])]["seg_lv4"] + ~ doc_matters.src.filename_base + ~ "/" + ~ doc_matters.has.tag_associations[(m.captures["segname"])]["seg_lv4"] ~ ".html" ~ "#" ~ "$3" ~ "├" @@ -632,20 +634,20 @@ string inline_links(M,O)( if (!(doc_matters.opt.action.quiet)) { writeln( "WARNING on internal document links, anchor to link <<" - ~ m.captures[3] + ~ m.captures["segname"] ~ ">> not found in document, " - ~ "anchor: " ~ m.captures[3] + ~ "anchor: " ~ m.captures["segname"] ~ " document: " ~ doc_matters.src.filename ); } } } } else { - if (auto m = _txt.match(rgx.inline_link_hash)) { + if (auto m = _txt.match(rgx.inline_link_seg_and_hash)) { _txt = _txt.replaceFirst( - rgx.inline_link_hash, + rgx.inline_link_seg_and_hash, "┥$1┝┤" - ~ doc_matters.conf_make_meta.conf.w_srv_data_root_url + ~ doc_matters.conf_make_meta.conf.w_srv_data_root_url_html ~ "/" ~ pth_html.tail_fn_scroll(doc_matters.src.filename) ~ "#" ~ "$3" @@ -1854,7 +1856,7 @@ string _insert_metadata = format(q"┃ SQLinsertDelimiter!()(doc_matters.conf_make_meta.meta.original_language_char), SQLinsertDelimiter!()(doc_matters.conf_make_meta.meta.original_source), SQLinsertDelimiter!()(doc_matters.conf_make_meta.meta.publisher), - SQLinsertDelimiter!()(doc_matters.conf_make_meta.conf.w_srv_data_root_url) + SQLinsertDelimiter!()(doc_matters.conf_make_meta.conf.w_srv_data_root_url_html) ); #+END_SRC -- cgit v1.2.3