From eed0938b23d13ec4f2ef4588ccdb2e7abc0c1552 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Sun, 29 Mar 2020 18:29:44 -0400 Subject: 0.10.0 search sqlite & cgi --- src/doc_reform/io_out/cgi_sqlite_search_form.d | 988 +++++++++++++++++++++++++ src/doc_reform/io_out/defaults.d | 2 +- src/doc_reform/io_out/hub.d | 26 +- src/doc_reform/io_out/metadata.d | 16 +- src/doc_reform/io_out/odt.d | 1 - src/doc_reform/io_out/paths_output.d | 60 +- src/doc_reform/io_out/sqlite.d | 56 +- src/doc_reform/io_out/xmls.d | 49 +- 8 files changed, 1133 insertions(+), 65 deletions(-) create mode 100644 src/doc_reform/io_out/cgi_sqlite_search_form.d (limited to 'src/doc_reform/io_out') diff --git a/src/doc_reform/io_out/cgi_sqlite_search_form.d b/src/doc_reform/io_out/cgi_sqlite_search_form.d new file mode 100644 index 0000000..b1c64eb --- /dev/null +++ b/src/doc_reform/io_out/cgi_sqlite_search_form.d @@ -0,0 +1,988 @@ +module doc_reform.io_out.cgi_sqlite_search_form; +template CGIsearchSQLite() { + void CGIsearchSQLite(E,O,M)(E env, O opt_action, M make_and_meta_struct) { + import + std.file, + std.format; + import doc_reform.io_out; + string _sqlite_db_fn = (opt_action.sqlite_filename.empty) + ? make_and_meta_struct.conf.w_srv_db_sqlite + : opt_action.sqlite_filename; + string _cgi_search_script = (opt_action.cgi_sqlite_search_filename.empty) + ? make_and_meta_struct.conf.w_srv_cgi_search_script + : opt_action.cgi_sqlite_search_filename; + string _cgi_search_script_raw_fn_d = (opt_action.cgi_sqlite_search_filename_d.empty) + ? make_and_meta_struct.conf.w_srv_cgi_search_script_raw_fn_d + : opt_action.cgi_sqlite_search_filename_d; + string the_cgi_search_form = format(q"≓ +/+ dub.sdl + name "spine search" + description "spine cgi search" ++/ +import std.format; +import std.range; +import std.regex; +import arsd.cgi; +import d2sqlite3; +import std.process : environment; +void cgi_function_intro(Cgi cgi) { + string header; + string table; + string form; + struct Config { + string http_request_type; + string http_host; + // string server_name; + string doc_root; + string cgi_root; + string cgi_script; + string data_path_html; + string db_path; + string query_string; + string http_url; + string request_method; + } + auto conf = Config(); + conf.http_request_type = environment.get("REQUEST_SCHEME", "http"); + conf.http_host = environment.get("HTTP_HOST", "localhost"); + // conf.server_name = environment.get("SERVER_NAME", "localhost"); + conf.doc_root = environment.get("DOCUMENT_ROOT", "/var/www/html"); + conf.cgi_root = environment.get("CONTEXT_DOCUMENT_ROOT", "/usr/lib/cgi-bin/"); + // conf.cgi_script = environment.get("SCRIPT_NAME", "/cgi-bin/spine-search"); + conf.query_string = environment.get("QUERY_STRING", ""); + conf.http_url = environment.get("HTTP_REFERER", conf.http_request_type ~ "://" ~ conf.http_host ~ conf.cgi_script ~ "?" ~ conf.query_string); + conf.db_path = "/var/www/html/sqlite/"; // conf.http_host ~ "/sqlite/"; + conf.request_method = environment.get("REQUEST_METHOD", "POST"); + struct CGI_val { + string db_selected = ""; + string sql_match_limit = ""; // radio: ( 1000 | 2500 ) + string sql_match_offset = ""; + string search_text = ""; + string results_type = ""; // index + bool checked_echo = false; + bool checked_stats = false; + bool checked_url = false; + bool checked_searched = false; + bool checked_tip = false; + bool checked_sql = false; + } + auto cv = CGI_val(); + cv.db_selected = "%s"; + auto text_fields() { + string canned_query_str = environment.get("QUERY_STRING", ""); + if ("query_string" in cgi.post) { + canned_query_str = environment.get("QUERY_STRING", ""); + } + string[string] canned_query; + if (conf.request_method == "POST") { + } else if (conf.request_method == "GET") { + foreach (pair_str; canned_query_str.split("&")) { + // cgi.write(pair_str ~ "
"); + string[] pair = pair_str.split("="); + canned_query[pair[0]] = pair[1]; + } + // foreach (field, content; canned_query) { + // cgi.write(field ~ ": " ~ content ~ "
"); + // } + } + static struct Rgx { + // static canned_query = ctRegex!(`\A(?P.+)\Z`, "m"); + static search_text_area = ctRegex!(`\A(?P.+)\Z`, "m"); + // static fulltext = ctRegex!(`\A(?P.+)\Z`, "m"); + static line = ctRegex!(`^(?P.+?)(?: ~|$)`, "m"); + static text = ctRegex!(`(?:^|\s~\s*)text:\s+(?P.+?)(?: ~|$)`, "m"); + static author = ctRegex!(`(?:^|\s~\s*)author:\s+(?P.+)$`, "m"); + static title = ctRegex!(`(?:^|\s~\s*)title:\s+(?P.+)$`, "m"); + static uid = ctRegex!(`(?:^|\s~\s*)uid:\s+(?P.+)$`, "m"); + static fn = ctRegex!(`(?:^|\s~\s*)fn:\s+(?P.+)$`, "m"); + static keywords = ctRegex!(`(?:^|\s~\s*)keywords:\s+(?P.+)$`, "m"); + static topic_register = ctRegex!(`(?:^|\s~\s*)topic_register:\s+(?P.+)$`, "m"); + static subject = ctRegex!(`(?:^|\s~\s*)subject:\s+(?P.+)$`, "m"); + static description = ctRegex!(`(?:^|\s~\s*)description:\s+(?P.+)$`, "m"); + static publisher = ctRegex!(`(?:^|\s~\s*)publisher:\s+(?P.+)$`, "m"); + static editor = ctRegex!(`(?:^|\s~\s*)editor:\s+(?P.+)$`, "m"); + static contributor = ctRegex!(`(?:^|\s~\s*)contributor:\s+(?P.+)$`, "m"); + static date = ctRegex!(`(?:^|\s~\s*)date:\s+(?P.+)$`, "m"); + static results_type = ctRegex!(`(?:^|\s~\s*)type:\s+(?P.+)$`, "m"); + static format = ctRegex!(`(?:^|\s~\s*)format:\s+(?P.+)$`, "m"); + static identifier = ctRegex!(`(?:^|\s~\s*)identifier:\s+(?P.+)$`, "m"); + static source = ctRegex!(`(?:^|\s~\s*)source:\s+(?P.+)$`, "m"); + static language = ctRegex!(`(?:^|\s~\s*)language:\s+(?P.+)$`, "m"); + static relation = ctRegex!(`(?:^|\s~\s*)relation:\s+(?P.+)$`, "m"); + static coverage = ctRegex!(`(?:^|\s~\s*)coverage:\s+(?P.+)$`, "m"); + static rights = ctRegex!(`(?:^|\s~\s*)rights:\s+(?P.+)$`, "m"); + static comment = ctRegex!(`(?:^|\s~\s*)comment:\s+(?P.+)$`, "m"); + // static abstract_ = ctRegex!(`(?:^|\s~\s*)abstract:\s+(?P.+)$`, "m"); + static src_filename_base = ctRegex!(`^src_filename_base:\s+(?P.+)$`, "m"); + } + struct searchFields { + string canned_query = ""; // GET canned_query == cq + string search_text_area = ""; // POST search_text_area == tsa + string text = ""; // text == txt + string author = ""; // author == au + string title = ""; // title == ti + string uid = ""; // uid == uid + string fn = ""; // fn == fn + string keywords = ""; // keywords == kw + string topic_register = ""; // topic_register == tr + string subject = ""; // subject == su + string description = ""; // description == de + string publisher = ""; // publisher == pb + string editor = ""; // editor == ed + string contributor = ""; // contributor == ct + string date = ""; // date == dt + string format = ""; // format == fmt + string identifier = ""; // identifier == id + string source = ""; // source == src sfn + string language = ""; // language == lng + string relation = ""; // relation == rl + string coverage = ""; // coverage == cv + string rights = ""; // rights == rgt + string comment = ""; // comment == cmt + // string abstract = ""; + string src_filename_base = ""; // src_filename_base == bfn + string results_type = ""; // results_type == rt radio + string sql_match_limit = ""; // sql_match_limit == sml radio + string sql_match_offset = ""; // sql_match_offset == smo + string stats = ""; // stats == sts checked + string echo = ""; // echo == ec checked + string url = ""; // url == url checked + string searched = ""; // searched == se checked + string sql = ""; // sql == sql checked + } + auto rgx = Rgx(); + auto got = searchFields(); + if (environment.get("REQUEST_METHOD", "POST") == "POST") { + if ("sf" in cgi.post) { + got.search_text_area = cgi.post["sf"]; + if (auto m = got.search_text_area.matchFirst(rgx.text)) { + got.text = m["matched"]; + got.canned_query ~= "sf=" ~ m["matched"]; + } else if (auto m = got.search_text_area.matchFirst(rgx.line)) { + if ( + !(m["matched"].matchFirst(rgx.author)) + && !(m["matched"].matchFirst(rgx.title)) + ) { + got.text = m["matched"]; + got.canned_query ~= "sf=" ~ m["matched"]; + } + } + if (auto m = got.search_text_area.matchFirst(rgx.author)) { + got.author = m["matched"]; + got.canned_query ~= "&au=" ~ m["matched"]; + } + if (auto m = got.search_text_area.matchFirst(rgx.title)) { + got.title = m["matched"]; + got.canned_query ~= "&ti=" ~ m["matched"]; + } + if (auto m = got.search_text_area.matchFirst(rgx.uid)) { + got.uid = m["matched"]; + got.canned_query ~= "&uid=" ~ m["matched"]; + } + if (auto m = got.search_text_area.matchFirst(rgx.fn)) { + got.fn = m["matched"]; + got.canned_query ~= "&fn=" ~ m["matched"]; + } + if (auto m = got.search_text_area.matchFirst(rgx.keywords)) { + got.keywords = m["matched"]; + got.canned_query ~= "&kw=" ~ m["matched"]; + } + if (auto m = got.search_text_area.matchFirst(rgx.topic_register)) { + got.topic_register = m["matched"]; + got.canned_query ~= "&tr=" ~ m["matched"]; + } + if (auto m = got.search_text_area.matchFirst(rgx.subject)) { + got.subject = m["matched"]; + got.canned_query ~= "&su=" ~ m["matched"]; + } + if (auto m = got.search_text_area.matchFirst(rgx.description)) { + got.description = m["matched"]; + got.canned_query ~= "&de=" ~ m["matched"]; + } + if (auto m = got.search_text_area.matchFirst(rgx.publisher)) { + got.publisher = m["matched"]; + got.canned_query ~= "&pb=" ~ m["matched"]; + } + if (auto m = got.search_text_area.matchFirst(rgx.editor)) { + got.editor = m["matched"]; + got.canned_query ~= "&ed=" ~ m["matched"]; + } + if (auto m = got.search_text_area.matchFirst(rgx.contributor)) { + got.contributor = m["matched"]; + got.canned_query ~= "&ct=" ~ m["matched"]; + } + if (auto m = got.search_text_area.matchFirst(rgx.date)) { + got.date = m["matched"]; + got.canned_query ~= "&dt=" ~ m["matched"]; + } + // if (auto m = got.search_text_area.matchFirst(rgx.results_type)) { + // got.results_type = m["matched"]; + // got.canned_query ~= "&rt=" ~ m["matched"]; + // } + if (auto m = got.search_text_area.matchFirst(rgx.format)) { + got.format = m["matched"]; + got.canned_query ~= "&fmt=" ~ m["matched"]; + } + if (auto m = got.search_text_area.matchFirst(rgx.identifier)) { + got.identifier = m["matched"]; + got.canned_query ~= "&id=" ~ m["matched"]; + } + if (auto m = got.search_text_area.matchFirst(rgx.source)) { + got.source = m["matched"]; + got.canned_query ~= "&src=" ~ m["matched"]; + } + if (auto m = got.search_text_area.matchFirst(rgx.language)) { + got.language = m["matched"]; + got.canned_query ~= "&lng=" ~ m["matched"]; + } + if (auto m = got.search_text_area.matchFirst(rgx.relation)) { + got.relation = m["matched"]; + got.canned_query ~= "&rl=" ~ m["matched"]; + } + if (auto m = got.search_text_area.matchFirst(rgx.coverage)) { + got.coverage = m["matched"]; + got.canned_query ~= "&cv=" ~ m["matched"]; + } + if (auto m = got.search_text_area.matchFirst(rgx.rights)) { + got.rights = m["matched"]; + got.canned_query ~= "&rgt=" ~ m["matched"]; + } + if (auto m = got.search_text_area.matchFirst(rgx.comment)) { + got.comment = m["matched"]; + got.canned_query ~= "&cmt=" ~ m["matched"]; + } + // if (auto m = search_text_area.matchFirst(rgx.abstract)) { + // got.abstract = m["matched"]; + // } + if (auto m = got.search_text_area.matchFirst(rgx.src_filename_base)) { + got.src_filename_base = m["matched"]; + got.canned_query ~= "&bfn=" ~ m["matched"]; + } + } + if ("fn" in cgi.post) { + got.fn = cgi.post["fn"]; + got.canned_query ~= "&fn=" ~ cgi.post["fn"]; + } + if ("rt" in cgi.post) { + got.results_type = cgi.post["rt"]; + got.canned_query ~= "&rt=" ~ cgi.post["rt"]; + } + if ("sts" in cgi.post) { + got.stats = cgi.post["sts"]; + got.canned_query ~= "&sts=" ~ cgi.post["sts"]; + } + if ("ec" in cgi.post) { + got.echo = cgi.post["ec"]; + got.canned_query ~= "&ec=" ~ cgi.post["ec"]; + } + if ("url" in cgi.post) { + got.url = cgi.post["url"]; + got.canned_query ~= "&url=" ~ cgi.post["url"]; + } + if ("se" in cgi.post) { + got.searched = cgi.post["se"]; + got.canned_query ~= "&se=" ~ cgi.post["se"]; + } + if ("sql" in cgi.post) { + got.sql = cgi.post["sql"]; + got.canned_query ~= "&sql=" ~ cgi.post["sql"]; + } + if ("sml" in cgi.post) { + got.sql_match_limit = cgi.post["sml"]; + got.canned_query ~= "&sml=" ~ cgi.post["sml"]; + } + if ("smo" in cgi.post) { + got.sql_match_offset = "0"; // cgi.post["smo"]; + got.canned_query ~= "&smo=0"; // ~ cgi.post["smo"]; + } + got.canned_query = got.canned_query.strip.split(" ").join("%%20"); + conf.query_string = got.canned_query; + // cgi.write("f.canned_query: " ~ got.canned_query ~ "
"); + } else if (environment.get("REQUEST_METHOD", "POST") == "GET") { + got.canned_query = environment.get("QUERY_STRING", ""); + // cgi.write("f.canned_query: " ~ got.canned_query ~ "
"); + got.search_text_area = ""; + if ("sf" in canned_query && !(canned_query["sf"]).empty) { + got.text = canned_query["sf"].split("%%20").join(" "); + got.search_text_area ~= "text: " ~ got.text ~ "\n"; + } + if ("au" in canned_query && !(canned_query["au"]).empty) { + got.author = canned_query["au"].split("%%20").join(" "); + got.search_text_area ~= "author: " ~ got.author ~ "\n"; + } + if ("ti" in canned_query && !(canned_query["ti"]).empty) { + got.title = canned_query["ti"].split("%%20").join(" "); + got.search_text_area ~= "title: " ~ got.title ~ "\n"; + } + if ("uid" in canned_query && !(canned_query["uid"]).empty) { + got.uid = canned_query["uid"].split("%%20").join(" "); + got.search_text_area ~= "uid: " ~ got.uid ~ "\n"; + } + if ("fn" in canned_query && !(canned_query["fn"]).empty) { + got.fn = canned_query["fn"].split("%%20").join(" "); + got.search_text_area ~= "fn: " ~ got.fn ~ "\n"; + } + if ("kw" in canned_query && !(canned_query["kw"]).empty) { + got.keywords = canned_query["kw"].split("%%20").join(" "); + got.search_text_area ~= "keywords: " ~ got.keywords ~ "\n"; + } + if ("tr" in canned_query && !(canned_query["tr"]).empty) { + got.topic_register = canned_query["tr"].split("%%20").join(" "); + got.search_text_area ~= "topic_register: " ~ got.topic_register ~ "\n"; + } + if ("su" in canned_query && !(canned_query["su"]).empty) { + got.subject = canned_query["su"].split("%%20").join(" "); + got.search_text_area ~= "subject: " ~ got.subject ~ "\n"; + } + if ("de" in canned_query && !(canned_query["de"]).empty) { + got.description = canned_query["de"].split("%%20").join(" "); + got.search_text_area ~= "description: " ~ got.description ~ "\n"; + } + if ("pb" in canned_query && !(canned_query["pb"]).empty) { + got.publisher = canned_query["pb"].split("%%20").join(" "); + got.search_text_area ~= "publisher: " ~ got.publisher ~ "\n"; + } + if ("ed" in canned_query && !(canned_query["ed"]).empty) { + got.editor = canned_query["ed"].split("%%20").join(" "); + got.search_text_area ~= "editor: " ~ got.editor ~ "\n"; + } + if ("ct" in canned_query && !(canned_query["ct"]).empty) { + got.contributor = canned_query["ct"].split("%%20").join(" "); + got.search_text_area ~= "contributor: " ~ got.contributor ~ "\n"; + } + if ("dt" in canned_query && !(canned_query["dt"]).empty) { + got.date = canned_query["dt"].split("%%20").join(" "); + got.search_text_area ~= "date: " ~ got.date ~ "\n"; + } + if ("rt" in canned_query && !(canned_query["rt"]).empty) { + got.results_type = canned_query["rt"].split("%%20").join(" "); + // got.search_text_area ~= "results_type: " ~ got.results_type ~ "\n"; + } + if ("fmt" in canned_query && !(canned_query["fmt"]).empty) { + got.format = canned_query["fmt"].split("%%20").join(" "); + got.search_text_area ~= "format: " ~ got.format ~ "\n"; + } + if ("id" in canned_query && !(canned_query["id"]).empty) { + got.identifier = canned_query["id"].split("%%20").join(" "); + got.search_text_area ~= "identifier: " ~ got.identifier ~ "\n"; + } + if ("src" in canned_query && !(canned_query["src"]).empty) { + got.source = canned_query["src"].split("%%20").join(" "); + got.search_text_area ~= "source: " ~ got.source ~ "\n"; + } + if ("lng" in canned_query && !(canned_query["lng"]).empty) { + got.language = canned_query["lng"].split("%%20").join(" "); + got.search_text_area ~= "language: " ~ got.language ~ "\n"; + } + if ("rl" in canned_query && !(canned_query["rl"]).empty) { + got.relation = canned_query["rl"].split("%%20").join(" "); + got.search_text_area ~= "relation: " ~ got.relation ~ "\n"; + } + if ("cv" in canned_query && !(canned_query["cv"]).empty) { + got.coverage = canned_query["cv"].split("%%20").join(" "); + got.search_text_area ~= "coverage: " ~ got.coverage ~ "\n"; + } + if ("rgt" in canned_query && !(canned_query["rgt"]).empty) { + got.rights = canned_query["rgt"].split("%%20").join(" "); + got.search_text_area ~= "rights: " ~ got.rights ~ "\n"; + } + if ("cmt" in canned_query && !(canned_query["cmt"]).empty) { + got.comment = canned_query["cmt"].split("%%20").join(" "); + got.search_text_area ~= "comment: " ~ got.comment ~ "\n"; + } + // if ("abstract" in canned_query && !(canned_query["abstract"]).empty) { + // got.abstract = canned_query["abstract"]; + // } + if ("bfn" in canned_query && !(canned_query["bfn"]).empty) { // search_field + got.src_filename_base = canned_query["bfn"].split("%%20").join(" "); + got.search_text_area ~= "src_filename_base: " ~ got.src_filename_base ~ "\n"; + } + if ("sml" in canned_query && !(canned_query["sml"]).empty) { + got.sql_match_limit = canned_query["sml"].split("%%20").join(" "); + // got.search_text_area ~= "sql_match_limit: " ~ got.sql_match_limit ~ "\n"; + } + // cgi.write("f.search_text_area: " ~ got.search_text_area ~ "
"); + } + return got; + } + auto tf = text_fields; // + struct SQL_select { + string the_body = ""; + string the_range = ""; + } + auto sql_select = SQL_select(); + string base ; // = ""; + string tip ; // = ""; + string search_note ; // = ""; + uint sql_match_offset_count = 0; + string previous_next () { + static struct Rgx { + static track_offset = ctRegex!(`(?P[&]smo=)(?P[0-9]+)`, "m"); + } + auto rgx = Rgx(); + string _previous_next = ""; + int _current_offset_value = 0; + string _set_offset_next = ""; + string _set_offset_previous = ""; + string _url = ""; + string _url_previous = ""; + string _url_next = ""; + string arrow_previous = ""; + string arrow_next = ""; + if (environment.get("REQUEST_METHOD", "POST") == "POST") { + _url = conf.http_request_type ~ "://" ~ conf.http_host ~ conf.cgi_script ~ "?" ~ tf.canned_query; + } else if (environment.get("REQUEST_METHOD", "POST") == "GET") { + _url = conf.http_request_type ~ "://" ~ conf.http_host ~ conf.cgi_script ~ "?" ~ environment.get("QUERY_STRING", ""); + } + if (auto m = _url.matchFirst(rgx.track_offset)) { + _current_offset_value = m.captures["offset_val"].to!int; + _set_offset_next = m.captures["offset_key"] ~ ((m.captures["offset_val"]).to!int + cv.sql_match_limit.to!int).to!string; + _url_next = _url.replace(rgx.track_offset, _set_offset_next); + if (_current_offset_value < cv.sql_match_limit.to!int) { + _url_previous = ""; + } else { + _url_previous = ""; + _set_offset_previous = m.captures["offset_key"] ~ ((m.captures["offset_val"]).to!int - cv.sql_match_limit.to!int).to!string; + _url_previous = _url.replace(rgx.track_offset, _set_offset_previous); + } + } else {// _current_offset_value = 0; + _url_next = _url ~= "&smo=" ~ cv.sql_match_limit.to!string; + } + if (_url_previous.empty) { + arrow_previous = ""; + } else { + arrow_previous = + "" + ~ "" + ~ "<< prev" + ~ " || "; + } + arrow_next = + "" + ~ "" + ~ "next >>" + ~ ""; + _previous_next = "
" ~ arrow_previous ~ arrow_next; + return _previous_next; + } + { + header = format(q"┃ + + + + + + ≅ SiSU spine search form + + + + + + + +┃", + conf.http_host, + ); + } + { + table = format(q"┃ + + + +
+ + +
+
+ SiSU + +
+ git + +
+
+ +
+ ┃"); + } + { + string post_value(string field_name, string type="box", string set="on") { + string val = ""; + switch (type) { + case "field": + val = ((field_name in cgi.post && !(cgi.post[field_name]).empty) + ? cgi.post[field_name] + : (field_name in cgi.get) + ? cgi.get[field_name] + : ""); + val = tf.search_text_area; + break; + case "box": // generic for checkbox or radio; checkbox set == "on" radio set == "name set" + val = ((field_name in cgi.post && !(cgi.post[field_name]).empty) + ? (cgi.post[field_name] == set ? "checked" : "off") + : (field_name in cgi.get) + ? (cgi.get[field_name] == set ? "checked" : "off") + : "off"); + break; + case "radio": // used generic bo + val = ((field_name in cgi.post && !(cgi.post[field_name]).empty) + ? (cgi.post[field_name] == set ? "checked" : "off") + : (field_name in cgi.get) + ? (cgi.get[field_name] == set ? "checked" : "off") + : "checked"); + break; + case "checkbox": // used generic bo + val = ((field_name in cgi.post && !(cgi.post[field_name]).empty) + ? (cgi.post[field_name] == set ? "checked" : "off") + : (field_name in cgi.get) + ? (cgi.get[field_name] == set ? "checked" : "off") + : "checked"); + break; + default: + } + return val; + } + string the_can(string fv) { + string show_the_can = post_value("url"); + string _the_can = ""; + if (show_the_can == "checked") { + tf = text_fields; + string method_get_url = conf.http_request_type ~ "://" ~ conf.http_host ~ conf.cgi_script ~ "?" ~ environment.get("QUERY_STRING", ""); + string method_post_url_construct = conf.http_request_type ~ "://" ~ conf.http_host ~ conf.cgi_script ~ "?" ~ tf.canned_query; + // assert(method_get_url == environment.get("HTTP_REFERER", conf.http_request_type ~ "://" ~ conf.http_host ~ conf.cgi_script ~ "?" ~ conf.query_string)); + if (conf.request_method == "POST") { + _the_can = + "" + ~ "POST: " + ~ "" + ~ method_post_url_construct + ~ "" + ~ "
"; + } else if (conf.request_method == "GET") { + _the_can = + "" + ~ "GET:  " + ~ "" + ~ method_get_url + ~ ""; + } + conf.http_url = conf.http_request_type ~ "://" ~ conf.http_host ~ conf.cgi_script ~ tf.canned_query; + } + return _the_can; + } + string provide_tip() { + string searched_tip = post_value("se"); + string tip = ""; + if (searched_tip == "checked") { + string search_field = post_value("sf", "field"); + tf = text_fields; + tip = format(q"┃ + +database: %%s; selected view: index +search string: %%s %%s %%s %%s %%s %%s
+%%s %%s %%s %%s %%s %%s +
+┃", + cv.db_selected, + (tf.text.empty ? "" : "\"text: " ~ tf.text ~ "; "), + (tf.title.empty ? "" : "\"title: " ~ tf.title ~ "; "), + (tf.author.empty ? "" : "\"author: " ~ tf.author ~ "; "), + (tf.date.empty ? "" : "\"date " ~ tf.date ~ "; "), + (tf.uid.empty ? "" : "\"uid: " ~ tf.uid ~ "; "), + (tf.fn.empty ? "" : "\"fn: " ~ tf.fn ~ "; "), + (tf.text.empty ? "" : "text: " ~ tf.text ~ "
"), + (tf.title.empty ? "" : "title: " ~ tf.title ~ "
"), + (tf.author.empty ? "" : "author: " ~ tf.author ~ "
"), + (tf.date.empty ? "" : "date: " ~ tf.date ~ "
"), + (tf.uid.empty ? "" : "\"uid: " ~ tf.uid ~ "; "), + (tf.fn.empty ? "" : "\"fn: " ~ tf.fn ~ "; "), + ); + } + return tip; + } + form = format(q"┃ +
+ + +
+ + + %%s + %%s + %%s +
+ + + to search: select which database to search (drop-down menu below); enter your search query (in the form above); and click on the search button (below) +
+ + + index + text / grep; + match limit: + 1,000 + 2,500 +
+ echo query + result stats + search url + searched + available fields + sql statement + +
+
+ + +
+┃", + "%s", + (post_value("ec") == "checked") ? post_value("sf", "field") : "", + provide_tip, + search_note, + the_can(post_value("sf", "field")), + cv.db_selected, + cv.db_selected, + post_value("rt", "box", "idx"), + post_value("rt", "box", "txt"), + post_value("sml", "box", "1000"), + post_value("sml", "box", "2500"), + post_value("ec"), + post_value("sts"), + post_value("url"), + post_value("se"), + post_value("tip"), + post_value("sql"), + ); + { + string set_value(string field_name, string default_val) { + string val; + if (field_name in cgi.post) { + val = cgi.post[field_name]; + } else if (field_name in cgi.get) { + val = cgi.get[field_name]; + } else { val = default_val; } + return val; + } + bool set_bool(string field_name) { + bool val; + if (field_name in cgi.post + && cgi.post[field_name] == "on") { + val = true; + } else if (field_name in cgi.get + && cgi.get[field_name] == "on") { + val = true; + } else { val = false; } + return val; + } + cv.db_selected = set_value("selected_db", "spine.search.db"); // selected_db == db + cv.sql_match_limit = set_value("sml", "1000"); + cv.sql_match_offset = set_value("smo", "0"); + cv.search_text = set_value("sf", ""); + cv.results_type = set_value("rt", "idx"); + cv.checked_echo = set_bool("ec"); + cv.checked_stats = set_bool("sts"); + cv.checked_url = set_bool("url"); + cv.checked_searched = set_bool("se"); + cv.checked_tip = set_bool("tip"); + cv.checked_sql = set_bool("sql"); + tf = text_fields; + } + } + { + cgi.write(header); + cgi.write(table); + cgi.write(form); + // cgi.write(previous_next); + { // debug environment + // foreach (k, d; environment.toAA) { + // cgi.write(k ~ ": " ~ d ~ "
"); + // } + } + { // debug cgi info + // cgi.write("db_selected: " ~ cv.db_selected ~ "
\n"); + // cgi.write("search_text: " ~ cv.search_text ~ "
\n"); + // cgi.write("sql_match_limit: " ~ cv.sql_match_limit ~ ";\n"); + // cgi.write("sql_match_offset: " ~ cv.sql_match_offset ~ ";\n"); + // cgi.write("results_type: " ~ cv.results_type ~ "
\n"); + // cgi.write("cv.checked_echo: " ~ (cv.checked_echo ? "checked" : "off") ~ "; \n"); + // cgi.write("cv.checked_stats: " ~ (cv.checked_stats ? "checked" : "off") ~ "; \n"); + // cgi.write("cv.checked_url: " ~ (cv.checked_url ? "checked" : "off") ~ "; \n"); + // cgi.write("cv.checked_searched: " ~ (cv.checked_searched ? "checked" : "off") ~ ";
\n"); + // cgi.write("cv.checked_tip: " ~ (cv.checked_tip ? "checked" : "off") ~ "; \n"); + // cgi.write("cv.checked_sql: " ~ (cv.checked_sql ? "checked" : "off") ~ "
\n"); + } + } + auto db = Database(conf.db_path ~ cv.db_selected); + { + uint sql_match_offset_counter(T)(T cv) { + sql_match_offset_count += cv.sql_match_limit.to!uint; + return sql_match_offset_count; + } + void sql_search_query() { + string select_field_like(string db_field, string search_field) { + string where_ = ""; + if (!(search_field.empty)) { + string _sf = search_field.strip.split("%%20").join(" "); + if (_sf.match(r" OR ")) { + _sf = _sf.split(" OR ").join("%%' OR " ~ db_field ~ " LIKE '%%"); + } + if (_sf.match(r" AND ")) { + _sf = _sf.split(" AND ").join("%%' AND " ~ db_field ~ " LIKE '%%"); + } + _sf = "( " ~ db_field ~ " LIKE\n '%%" ~ _sf ~ "%%' )"; + where_ ~= format(q"┃ + %%s +┃", + _sf + ); + } + return where_; + } + string[] _fields; + _fields ~= select_field_like("doc_objects.clean", tf.text); + _fields ~= select_field_like("metadata_and_text.title", tf.title); + _fields ~= select_field_like("metadata_and_text.creator_author", tf.author); + _fields ~= select_field_like("metadata_and_text.uid", tf.uid); + _fields ~= select_field_like("metadata_and_text.src_filename_base", tf.fn); + _fields ~= select_field_like("metadata_and_text.src_filename_base", tf.src_filename_base); + _fields ~= select_field_like("metadata_and_text.language_document_char", tf.language); + _fields ~= select_field_like("metadata_and_text.date_published", tf.date); + _fields ~= select_field_like("metadata_and_text.classify_keywords", tf.keywords); + _fields ~= select_field_like("metadata_and_text.classify_topic_register", tf.topic_register); + string[] fields; + foreach (f; _fields) { + if (!(f.empty)) { fields ~= f; } + } + string fields_str = ""; + fields_str ~= fields.join(" AND "); + sql_select.the_body ~= format(q"┃ +SELECT + metadata_and_text.uid, + metadata_and_text.title, + metadata_and_text.creator_author_last_first, + metadata_and_text.creator_author, + metadata_and_text.src_filename_base, + metadata_and_text.language_document_char, + metadata_and_text.date_published, + metadata_and_text.classify_keywords, + metadata_and_text.classify_topic_register, + doc_objects.body, + doc_objects.seg_name, + doc_objects.ocn, + metadata_and_text.uid +FROM + doc_objects, + metadata_and_text +WHERE ( + %%s + ) +AND + doc_objects.uid_metadata_and_text = metadata_and_text.uid +ORDER BY + metadata_and_text.creator_author_last_first, + metadata_and_text.date_published DESC, + metadata_and_text.title, + metadata_and_text.language_document_char, + metadata_and_text.src_filename_base, + doc_objects.ocn +LIMIT %%s OFFSET %%s +;┃", + fields_str, + cv.sql_match_limit, + cv.sql_match_offset, + ); + (cv.checked_sql) + ? cgi.write(previous_next ~ "
" ~ sql_select.the_body.split("\n ").join(" ").split("\n").join("
") ~ "
\n") + : ""; + cgi.write(previous_next); + auto select_query_results = db.execute(sql_select.the_body).cached; + string _old_uid = ""; + if (!select_query_results.empty) { + foreach (row; select_query_results) { + if (row["uid"].as!string != _old_uid) { + _old_uid = row["uid"].as!string; + auto m = (row["date_published"].as!string).match(regex(r"^([0-9]{4})")); // breaks if row missing or no match? + cgi.write( + "
\"" + ~ row["title"].as!string ~ "\"" + ~ " (" + ~ m.hit + ~ ") " + ~ "[" + ~ row["language_document_char"].as!string + ~ "] " + ~ row["creator_author_last_first"].as!string + ~ ":
\n" + ); + } + if (cv.results_type == "txt") { + cgi.write( + "
" + ~ row["ocn"].as!string + ~ "" + ~ "
" + ~ row["body"].as!string + ); + } else { + cgi.write( + "" + ~ row["ocn"].as!string + ~ ", " + ); + } + } + cgi.write( previous_next); + } else { // offset_not_beyond_limit = false; + cgi.write("select_query_results empty

\n"); + } + } + sql_search_query; + } + { + db.close; + } + { + string tail = format(q"┃ + +┃"); + cgi.write(tail); + } +} +mixin GenericMain!cgi_function_intro; +≓", + _sqlite_db_fn, + _cgi_search_script, +).strip; + auto pth_sqlite_cgi = spinePathsSQLiteCGI!()(_cgi_search_script_raw_fn_d, _cgi_search_script, opt_action.output_dir_set); // TODO + { // cgi-bin search form src d + try { + if (!exists(pth_sqlite_cgi.src)) { + pth_sqlite_cgi.src.mkdirRecurse; + } + if (!exists(pth_sqlite_cgi.cgi_bin)) { + pth_sqlite_cgi.cgi_bin.mkdirRecurse; + } + auto f = File(pth_sqlite_cgi.search_form_path_out, "w"); + f.write(the_cgi_search_form); + // foreach (o; metadata_) { + // f.writeln(o); + // } + } catch (ErrnoException ex) { + // Handle error + } + // if (!(opt_action.quiet)) { + // writeln(" ", pth_sqlite_cgi.search_form); + // } + } + string the_dub_sdl = format(q"≓ +name "spine_cgi_sqlite_search" +description "spine cgi sqlite search" +authors "Ralph Amissah" +copyright "Copyright © 2020, Ralph Amissah" +license "GPL-3.0+" +dependency "d2sqlite3" version="%s" +targetType "executable" +targetPath "./cgi-bin" +mainSourceFile "%s" +configuration "default" { + targetType "executable" + targetName "%s" + postGenerateCommands "/usr/bin/notify-send -t 0 'D executable ready' 'spine cgi sqlite search d'" +} +≓", + "~>0.18.3", // d2sqlite3 dependency version + "src/" ~ _cgi_search_script_raw_fn_d, + _cgi_search_script +).strip; + { // dub.sdl + try { + auto f = File(pth_sqlite_cgi.dub_sdl_path_out, "w"); + f.write(the_dub_sdl); + // foreach (o; metadata_) { + // f.writeln(o); + // } + } catch (ErrnoException ex) { + // Handle error + } + } + } +} diff --git a/src/doc_reform/io_out/defaults.d b/src/doc_reform/io_out/defaults.d index 84bac73..36e1428 100644 --- a/src/doc_reform/io_out/defaults.d +++ b/src/doc_reform/io_out/defaults.d @@ -34,7 +34,7 @@ template InternalMarkup() { string tc_c = "┚"; string tc_p = "┆"; string img = "☼"; - string sep = "␣"; + string sep = "␣"; // "~"; string on_o = "「"; string on_c = "」"; string mk_bullet = "● "; static string indent_by_spaces_provided(int indent, string _indent_spaces ="░░") { diff --git a/src/doc_reform/io_out/hub.d b/src/doc_reform/io_out/hub.d index 548cceb..50ee897 100644 --- a/src/doc_reform/io_out/hub.d +++ b/src/doc_reform/io_out/hub.d @@ -7,7 +7,6 @@ template outputHub() { import doc_reform.io_out, doc_reform.io_out.metadata, doc_reform.io_out.xmls, - doc_reform.io_out.odt, doc_reform.io_out.create_zip_file, doc_reform.io_out.paths_output; @system void outputHub(D,I)( @@ -114,10 +113,9 @@ template outputHubOp() { import doc_reform.io_out, doc_reform.io_out.metadata, doc_reform.io_out.xmls, - doc_reform.io_out.odt, doc_reform.io_out.create_zip_file, doc_reform.io_out.paths_output; - @system void outputHubOp(E,O)(E env, O opt_action) { + @system void outputHubOp(E,O,M)(E env, O opt_action, M make_and_meta_struct) { mixin spineRgxOut; static auto rgx = RgxO(); if ((opt_action.sqlite_db_drop)) { @@ -132,6 +130,7 @@ template outputHubOp() { } if ((opt_action.sqlite_db_create)) { if ((opt_action.verbose)) { + auto pth_sqlite_db = spinePathsSQLite!()(opt_action.cgi_sqlite_search_filename, opt_action.output_dir_set); writeln("sqlite create table..."); } import doc_reform.io_out.sqlite; @@ -140,5 +139,26 @@ template outputHubOp() { writeln("sqlite create table done"); } } + if ((opt_action.cgi_search_form_codegen)) { + if ((opt_action.verbose)) { + string _sqlite_db_fn = (opt_action.sqlite_filename.empty) + ? make_and_meta_struct.conf.w_srv_db_sqlite + : opt_action.sqlite_filename; + string _cgi_search_script = (opt_action.cgi_sqlite_search_filename.empty) + ? make_and_meta_struct.conf.w_srv_cgi_search_script + : opt_action.cgi_sqlite_search_filename; + string _cgi_search_script_raw_fn_d = (opt_action.cgi_sqlite_search_filename_d.empty) + ? make_and_meta_struct.conf.w_srv_cgi_search_script_raw_fn_d + : opt_action.cgi_sqlite_search_filename_d; + auto pth_sqlite_cgi = spinePathsSQLiteCGI!()(_cgi_search_script_raw_fn_d, _cgi_search_script, opt_action.output_dir_set); + writeln("sqlite cgi search form..."); + writeln(" ", pth_sqlite_cgi.search_form_path_out); + } + import doc_reform.io_out.cgi_sqlite_search_form; + CGIsearchSQLite!()(env, opt_action, make_and_meta_struct); + if ((opt_action.very_verbose)) { + writeln("sqlite cgi search form done"); + } + } } } diff --git a/src/doc_reform/io_out/metadata.d b/src/doc_reform/io_out/metadata.d index 65f40b2..6c059ce 100644 --- a/src/doc_reform/io_out/metadata.d +++ b/src/doc_reform/io_out/metadata.d @@ -84,7 +84,7 @@ string theme_light_1 = format(q"┃ Metadata Harvest - Topics - + @@ -230,7 +230,7 @@ string theme_light_1 = format(q"┃ ┃"); - if (doc_matters.opt.action.harvest_link) { + if (doc_matters.opt.action.html_harvest_link) { metadata_ ~= format(q"┃

[ HOME ] Metadata Harvest [ Authors ] [ Topics ]

@@ -247,7 +247,7 @@ string theme_light_1 = format(q"┃ writeln("ERROR no Title information provided in document header ", doc_matters.src.filename_base); } if (!(doc_matters.conf_make_meta.meta.creator_author.empty)) { - if (doc_matters.opt.action.harvest_link) { + if (doc_matters.opt.action.html_harvest_link) { metadata_ ~= "

Author: " ~ doc_matters.conf_make_meta.meta.creator_author ~ "

"; } else { @@ -292,7 +292,7 @@ string theme_light_1 = format(q"┃ if (subject_tree.length > 0) { if (subject_tree[0] != _top[0]) { _top[0] = subject_tree[0]; - if (doc_matters.opt.action.harvest_link) { + if (doc_matters.opt.action.html_harvest_link) { metadata_ ~= "

" @@ -307,7 +307,7 @@ string theme_light_1 = format(q"┃ if (subject_tree[1] != _top[1]) { _top[1] = subject_tree[1]; _top[2] = ""; _top[3] = ""; _top[4] = ""; - if (doc_matters.opt.action.harvest_link) { + if (doc_matters.opt.action.html_harvest_link) { metadata_ ~= "

4) { if (subject_tree[4] != _top[4]) { _top[4] = subject_tree[4]; - if (doc_matters.opt.action.harvest_link) { + if (doc_matters.opt.action.html_harvest_link) { metadata_ ~= "

0) + ? output_pth_root : ""; + } + string output_base() { + return ((output_root).asNormalizedPath).array; + } + } + return _PathsStruct(); + } +} template spineOutPathsFnPd() { /+ TODO stuff to work out here +/ auto spineOutPathsFnPd(Fn,Pn)( @@ -535,9 +551,9 @@ template spinePathsSQLiteDiscrete() { template spinePathsSQLite() { mixin spineRgxIn; static auto rgx = RgxI(); - auto spinePathsSQLite(DbN, Po)( - DbN db_name, - Po output_pth_root, + auto spinePathsSQLite()( + string db_name, + string output_pth_root, ) { struct _PathsStruct { string base_filename(string fn_src) { @@ -549,7 +565,43 @@ template spinePathsSQLite() { return (((out_pth.output_root).chainPath(base_dir)).asNormalizedPath).array; } string sqlite_file() { - return ((base.chainPath(base_filename(db_name) ~ ".sql.db")).asNormalizedPath).array; + return (base.chainPath(db_name).asNormalizedPath).array; + } + } + return _PathsStruct(); + } +} +template spinePathsSQLiteCGI() { + mixin spineRgxIn; + static auto rgx = RgxI(); + auto spinePathsSQLiteCGI()( + string cgi_search_form_d, + string cgi_search_form, + string output_pth_root, + ) { + struct _PathsStruct { + string base_filename(string fn_src) { + return fn_src.baseName.stripExtension; + } + string base() { + auto out_pth = spineOutPathSQLiteCGI!()(output_pth_root); + string base_dir = "cgi"; + return (((out_pth.output_root).chainPath(base_dir)).asNormalizedPath).array; + } + string src() { + return ((base.chainPath("src")).asNormalizedPath).array; + } + string cgi_bin() { + return ((base.chainPath("cgi-bin")).asNormalizedPath).array; + } + string dub_sdl_path_out() { + return ((base.chainPath("dub.sdl")).asNormalizedPath).array; + } + string search_form_dub_path() { + return ("src/".chainPath(base_filename(cgi_search_form_d)).asNormalizedPath).array; + } + string search_form_path_out() { + return (src.chainPath((cgi_search_form_d)).asNormalizedPath).array; } } return _PathsStruct(); diff --git a/src/doc_reform/io_out/sqlite.d b/src/doc_reform/io_out/sqlite.d index 1a30204..ce8f688 100644 --- a/src/doc_reform/io_out/sqlite.d +++ b/src/doc_reform/io_out/sqlite.d @@ -63,7 +63,7 @@ template SQLiteHubDiscreteBuildTablesAndPopulate() { const D doc_abstraction, M doc_matters, ) { - auto url_html = spineUrlsHTML!()(doc_matters.conf_make_meta.conf.webserv_url_doc_root, doc_matters.src.language); + auto url_html = spineUrlsHTML!()(doc_matters.conf_make_meta.conf.w_srv_data_root_url, 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)); @@ -261,7 +261,7 @@ template SQLiteFormatAndLoadObject() { M doc_matters, const O obj, string _txt, - string _suffix = ".html", + string _suffix = ".html", string _xml_type = "seg", ) { string _img_pth; @@ -307,7 +307,7 @@ template SQLiteFormatAndLoadObject() { _txt = _txt.replaceFirst( rgx.inline_link_hash, "┥$1┝┤" - ~ doc_matters.conf_make_meta.conf.webserv_url_doc_root + ~ doc_matters.conf_make_meta.conf.w_srv_data_root_url ~ "/" ~ pth_html.tail_fn_seg(doc_matters.src.filename, "$3.html") ~ "├" @@ -316,7 +316,7 @@ template SQLiteFormatAndLoadObject() { _txt = _txt.replaceFirst( rgx.inline_link_hash, "┥$1┝┤" - ~ doc_matters.conf_make_meta.conf.webserv_url_doc_root + ~ doc_matters.conf_make_meta.conf.w_srv_data_root_url ~ "/" ~ doc_matters.has.tag_associations[(m.captures[3])]["seg_lv4"] ~ ".html" @@ -341,7 +341,7 @@ template SQLiteFormatAndLoadObject() { _txt = _txt.replaceFirst( rgx.inline_link_hash, "┥$1┝┤" - ~ doc_matters.conf_make_meta.conf.webserv_url_doc_root + ~ doc_matters.conf_make_meta.conf.w_srv_data_root_url ~ "/" ~ pth_html.tail_fn_scroll(doc_matters.src.filename) ~ "#" ~ "$3" @@ -865,8 +865,8 @@ template SQLiteTablesReCreate() { DROP INDEX IF EXISTS idx_digest_all; DROP INDEX IF EXISTS idx_clean; DROP INDEX IF EXISTS idx_title; - DROP INDEX IF EXISTS idx_creator_author; - DROP INDEX IF EXISTS src_filename; + DROP INDEX IF EXISTS idx_author; + DROP INDEX IF EXISTS src_filename_base; DROP INDEX IF EXISTS idx_language_document_char; DROP INDEX IF EXISTS idx_classify_topic_register; DROP TABLE IF EXISTS metadata_and_text; @@ -885,6 +885,7 @@ template SQLiteTablesReCreate() { title_language VARCHAR(100) NULL, title_language_char VARCHAR(6) NULL, creator_author VARCHAR(600) NOT NULL, + creator_author_last_first VARCHAR(600) NOT NULL, creator_author_email VARCHAR(100) NULL, creator_author_hon VARCHAR(100) NULL, creator_author_nationality VARCHAR(100) NULL, @@ -947,7 +948,8 @@ template SQLiteTablesReCreate() { notes_prefix_b TEXT NULL, notes_suffix TEXT NULL, publisher VARCHAR(600) NULL, - src_filename VARCHAR(256) NOT NULL, + src_filename_base VARCHAR(256) NOT NULL, + src_filename_suffix VARCHAR(6) NOT NULL, src_fingerprint VARCHAR(256) NULL, src_filesize VARCHAR(10) NULL, src_wordcount VARCHAR(10) NULL, @@ -991,7 +993,7 @@ template SQLiteTablesReCreate() { last_decendant VARCHAR(16) NULL, -- headings only digest_clean CHAR(256), digest_all CHAR(256), - html_seg_url CHAR(256), + seg_name CHAR(256), types CHAR(1) NULL ); CREATE INDEX idx_ocn ON doc_objects(ocn); @@ -999,9 +1001,9 @@ template SQLiteTablesReCreate() { CREATE INDEX idx_digest_all ON doc_objects(digest_all); CREATE INDEX idx_clean ON doc_objects(clean); CREATE INDEX idx_title ON metadata_and_text(title); - CREATE INDEX idx_author ON metadata_and_text(creator_author); + CREATE INDEX idx_author ON metadata_and_text(creator_author_last_first); CREATE INDEX idx_uid ON metadata_and_text(uid); - CREATE INDEX idx_filename ON metadata_and_text(src_filename); + CREATE INDEX idx_filename ON metadata_and_text(src_filename_base); CREATE INDEX idx_language ON metadata_and_text(language_document_char); CREATE INDEX idx_topics ON metadata_and_text(classify_topic_register); ┃",); @@ -1033,7 +1035,8 @@ template SQLiteInsertMetadata() { string _insert_metadata = format(q"┃ INSERT INTO metadata_and_text ( uid, - src_filename, + src_filename_base, + src_filename_suffix, src_composite_id_per_txt, src_composite_id_per_pod, title, @@ -1043,6 +1046,7 @@ template SQLiteInsertMetadata() { title_edition, title_language, creator_author, + creator_author_last_first, creator_author_email, creator_illustrator, creator_translator, @@ -1082,11 +1086,12 @@ template SQLiteInsertMetadata() { site_url_doc_root ) VALUES ( - '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' + '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' ); ┃", _uid, - SQLinsertDelimiter!()(doc_matters.src.filename), + SQLinsertDelimiter!()(doc_matters.src.filename_base), + SQLinsertDelimiter!()(doc_matters.src.filename_extension), SQLinsertDelimiter!()(doc_matters.src.docname_composite_unique_per_src_doc), SQLinsertDelimiter!()(doc_matters.src.docname_composite_unique_per_src_pod), SQLinsertDelimiter!()(doc_matters.conf_make_meta.meta.title_full), @@ -1096,6 +1101,7 @@ template SQLiteInsertMetadata() { SQLinsertDelimiter!()(doc_matters.conf_make_meta.meta.title_edition), SQLinsertDelimiter!()(doc_matters.conf_make_meta.meta.title_language), SQLinsertDelimiter!()(doc_matters.conf_make_meta.meta.creator_author), + SQLinsertDelimiter!()(doc_matters.conf_make_meta.meta.creator_author_surname_fn), SQLinsertDelimiter!()(doc_matters.conf_make_meta.meta.creator_author_email), SQLinsertDelimiter!()(doc_matters.conf_make_meta.meta.creator_illustrator), SQLinsertDelimiter!()(doc_matters.conf_make_meta.meta.creator_translator), @@ -1132,7 +1138,7 @@ template SQLiteInsertMetadata() { 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.webserv_url_doc_root) + SQLinsertDelimiter!()(doc_matters.conf_make_meta.conf.w_srv_data_root_url) ); if (doc_matters.conf_make_meta.meta.classify_topic_register_arr.length > 0) { @@ -1170,7 +1176,7 @@ template SQLiteInsertDocObjectsLoop() { M doc_matters, ) { string _uid = SQLinsertDelimiter!()(doc_matters.src.doc_uid); - auto url_html = spineUrlsHTML!()(doc_matters.conf_make_meta.conf.webserv_url_doc_root, doc_matters.src.language); + auto url_html = spineUrlsHTML!()(doc_matters.conf_make_meta.conf.w_srv_data_root_url, doc_matters.src.language); string insertDocObjectsRow(O)(O obj) { string _insert_doc_objects_row = format(q"┃ INSERT INTO doc_objects ( @@ -1182,7 +1188,7 @@ template SQLiteInsertDocObjectsLoop() { lev, is_of_type, is_a, - html_seg_url + seg_name ) VALUES ( '%s', %s, '%s', '%s', '%s', %s, '%s', '%s', '%s' @@ -1196,7 +1202,7 @@ template SQLiteInsertDocObjectsLoop() { obj.metainfo.heading_lev_markup, obj.metainfo.is_of_type, obj.metainfo.is_a, - url_html.fn_seg_obj_num(doc_matters.src.filename, obj.tags.html_segment_anchor_tag_is, obj.metainfo.identifier), + obj.tags.html_segment_anchor_tag_is ); return _insert_doc_objects_row; } @@ -1390,8 +1396,8 @@ template SQLiteTablesCreate() { DROP INDEX IF EXISTS idx_digest_all; DROP INDEX IF EXISTS idx_clean; DROP INDEX IF EXISTS idx_title; - DROP INDEX IF EXISTS idx_creator_author; - DROP INDEX IF EXISTS src_filename; + DROP INDEX IF EXISTS idx_author; + DROP INDEX IF EXISTS src_filename_base; DROP INDEX IF EXISTS idx_language_document_char; DROP INDEX IF EXISTS idx_classify_topic_register; DROP TABLE IF EXISTS metadata_and_text; @@ -1410,6 +1416,7 @@ template SQLiteTablesCreate() { title_language VARCHAR(100) NULL, title_language_char VARCHAR(6) NULL, creator_author VARCHAR(600) NOT NULL, + creator_author_last_first VARCHAR(600) NOT NULL, creator_author_email VARCHAR(100) NULL, creator_author_hon VARCHAR(100) NULL, creator_author_nationality VARCHAR(100) NULL, @@ -1472,7 +1479,8 @@ template SQLiteTablesCreate() { notes_prefix_b TEXT NULL, notes_suffix TEXT NULL, publisher VARCHAR(600) NULL, - src_filename VARCHAR(256) NOT NULL, + src_filename_base VARCHAR(256) NOT NULL, + src_filename_suffix VARCHAR(6) NOT NULL, src_fingerprint VARCHAR(256) NULL, src_filesize VARCHAR(10) NULL, src_wordcount VARCHAR(10) NULL, @@ -1516,7 +1524,7 @@ template SQLiteTablesCreate() { last_decendant VARCHAR(16) NULL, -- headings only digest_clean CHAR(256), digest_all CHAR(256), - html_seg_url CHAR(256), + seg_name CHAR(256), types CHAR(1) NULL ); CREATE INDEX idx_ocn ON doc_objects(ocn); @@ -1524,9 +1532,9 @@ template SQLiteTablesCreate() { CREATE INDEX idx_digest_all ON doc_objects(digest_all); CREATE INDEX idx_clean ON doc_objects(clean); CREATE INDEX idx_title ON metadata_and_text(title); - CREATE INDEX idx_author ON metadata_and_text(creator_author); + CREATE INDEX idx_author ON metadata_and_text(creator_author_last_first); CREATE INDEX idx_uid ON metadata_and_text(uid); - CREATE INDEX idx_filename ON metadata_and_text(src_filename); + CREATE INDEX idx_filename ON metadata_and_text(src_filename_base); CREATE INDEX idx_language ON metadata_and_text(language_document_char); CREATE INDEX idx_topics ON metadata_and_text(classify_topic_register); ┃",); diff --git a/src/doc_reform/io_out/xmls.d b/src/doc_reform/io_out/xmls.d index 89180eb..fb33fd0 100644 --- a/src/doc_reform/io_out/xmls.d +++ b/src/doc_reform/io_out/xmls.d @@ -94,7 +94,7 @@ template outputXHTMLs() { string _publisher="Publisher"; // TODO string o; o = format(q"┃ - + @@ -152,28 +152,28 @@ template outputXHTMLs() { @safe string inline_search_form(M)( M doc_matters, ) { - string _action="http://www.sisudoc.org/cgi-bin/search.cgi"; - string _db="spine.7a.manual"; string o; string _form; - if (doc_matters.opt.action.workon) { + if (doc_matters.opt.action.html_search_link) { o = format(q"┃

+ -
+ - + - - -
- - + + + + +
-
- ┃", - _action, - _db, + + ┃", + doc_matters.conf_make_meta.conf.w_srv_cgi_action, + doc_matters.conf_make_meta.conf.w_srv_db_sqlite, + doc_matters.src.filename_base, ); } else { o = ""; @@ -185,10 +185,18 @@ template outputXHTMLs() { string type, ) { string o; + string metadata_links = ((doc_matters.opt.action.html_harvest_link) + ? format(q"┃

[ m | A | T ]

┃", + (type == "seg") ? "../" : "", + doc_matters.src.filename_base, + (type == "seg") ? "../" : "", + (type == "seg") ? "../" : "", + ) + : ""); o = format(q"┃ - + %s%s @@ -217,14 +225,7 @@ template outputXHTMLs() { : "../../css/html_scroll.css"), doc_matters.src.language, site_info_button(doc_matters), - ((doc_matters.opt.action.harvest_link) - ? format(q"┃

[ m | A | T ]

┃", - (type == "seg") ? "../" : "", - doc_matters.src.filename_base, - (type == "seg") ? "../" : "", - (type == "seg") ? "../" : "", - ) - : ""), + metadata_links, inline_search_form(doc_matters), (type == "seg") ? "" : "\n", ); -- cgit v1.2.3