From 0ff37b772594b21a26b4b878a5ddbc6f1e0d1e67 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Wed, 13 Oct 2021 13:33:08 -0400 Subject: org files, tangle output, some fixes --- org/cgi_spine_search.org | 33 +- org/config_git.org | 2 + org/config_make.org | 32 +- org/meta_conf_make_meta.org | 9 +- org/out_cgi_search_sqlite.org | 1074 ++++++++++++------------ org/out_latex.org | 420 ++++----- org/out_sqlite.org | 172 ++-- org/out_src_pod.org | 7 + org/out_xmls.org | 9 +- org/spine.org | 256 +++--- org/spine_info.org | 470 +++++++---- org/util_cgi_d_sqlite_search.org | 1000 +++++++++++----------- org/util_cgi_rb_fcgi_sqlite_search.org | 916 ++++++++++---------- org/util_spine_markup_conversion_from_sisu.org | 8 +- org/util_spine_syntax_highlighting_emacs.org | 6 +- org/util_spine_syntax_highlighting_vim.org | 20 +- 16 files changed, 2326 insertions(+), 2108 deletions(-) (limited to 'org') diff --git a/org/cgi_spine_search.org b/org/cgi_spine_search.org index 75d0ca1..a7265bd 100644 --- a/org/cgi_spine_search.org +++ b/org/cgi_spine_search.org @@ -140,7 +140,7 @@ void cgi_function_intro(Cgi cgi) { <> } { -<> + <> } { string post_value(string field_name, string type="box", string set="on") { @@ -757,21 +757,21 @@ return _previous_next; #+NAME: spine_search_format_html_table #+BEGIN_SRC d - table = format(q"┃ - - - -
- - -
- %s -
-
-
- ┃", - conf.cgi_search_form_html_title, - ); + table = format(q"┃ + + + +
+ + +
+ %s +
+
+
+ ┃", + conf.cgi_search_form_html_title, + ); #+END_SRC **** post_value(string field_name, string type="box", string set="on") {} @@ -1235,7 +1235,6 @@ if (!select_query_results.empty) { } } cgi.write( previous_next); - } else { // offset_not_beyond_limit = false; cgi.write("select_query_results empty

\n"); } diff --git a/org/config_git.org b/org/config_git.org index 12bc0ce..a67cacd 100644 --- a/org/config_git.org +++ b/org/config_git.org @@ -25,6 +25,7 @@ ,* !.gitignore !README.md +!README !COPYRIGHT !CHANGELOG !makefile @@ -109,6 +110,7 @@ tmp/** ,* !.gitignore !README.md +!README !COPYRIGHT !CHANGELOG !makefile diff --git a/org/config_make.org b/org/config_make.org index e7aaeab..256e4e9 100644 --- a/org/config_make.org +++ b/org/config_make.org @@ -581,14 +581,14 @@ skel: mkdir -p build; \ mkdir -p views; \ mkdir -p data; \ - mkdir -p sundry/util/d/cgi/search/cgi-bin/src; \ - mkdir -p sundry/util/d/tools/markup_conversion; \ - mkdir -p sundry/editor-syntax-etc/emacs; \ - mkdir -p sundry/editor-syntax-etc/vim/syntax; \ - mkdir -p sundry/editor-syntax-etc/vim/colors; \ - mkdir -p sundry/editor-syntax-etc/vim/ftplugin; \ - mkdir -p sundry/editor-syntax-etc/vim/rc; \ - mkdir -p sundry/editor-syntax-etc/vim/templates; \ + mkdir -p sundry/misc/util/d/cgi/search/cgi-bin/src; \ + mkdir -p sundry/misc/util/d/tools/markup_conversion; \ + mkdir -p sundry/misc/editor-syntax-etc/emacs; \ + mkdir -p sundry/misc/editor-syntax-etc/vim/syntax; \ + mkdir -p sundry/misc/editor-syntax-etc/vim/colors; \ + mkdir -p sundry/misc/editor-syntax-etc/vim/ftplugin; \ + mkdir -p sundry/misc/editor-syntax-etc/vim/rc; \ + mkdir -p sundry/misc/editor-syntax-etc/vim/templates; \ mkdir -p $(PRG_SRCDIR)/$(PRG_NAME_DIR)/conf; \ mkdir -p $(PRG_SRCDIR)/$(PRG_NAME_DIR)/io_in; \ mkdir -p $(PRG_SRCDIR)/$(PRG_NAME_DIR)/io_out; \ @@ -616,14 +616,14 @@ expunge: distclean: expunge distclean_and_init: expunge mkdir -p views; \ - mkdir -p sundry/util/d/cgi/search/cgi-bin/src; \ - mkdir -p sundry/util/d/tools/markup_conversion; \ - mkdir -p sundry/editor-syntax-etc/emacs; \ - mkdir -p sundry/editor-syntax-etc/vim/syntax; \ - mkdir -p sundry/editor-syntax-etc/vim/colors; \ - mkdir -p sundry/editor-syntax-etc/vim/ftplugin; \ - mkdir -p sundry/editor-syntax-etc/vim/rc; \ - mkdir -p sundry/editor-syntax-etc/vim/templates; \ + mkdir -p sundry/misc/util/d/cgi/search/cgi-bin/src; \ + mkdir -p sundry/misc/util/d/tools/markup_conversion; \ + mkdir -p sundry/misc/editor-syntax-etc/emacs; \ + mkdir -p sundry/misc/editor-syntax-etc/vim/syntax; \ + mkdir -p sundry/misc/editor-syntax-etc/vim/colors; \ + mkdir -p sundry/misc/editor-syntax-etc/vim/ftplugin; \ + mkdir -p sundry/misc/editor-syntax-etc/vim/rc; \ + mkdir -p sundry/misc/editor-syntax-etc/vim/templates; \ mkdir -p $(PRG_SRCDIR)/$(PRG_NAME_DIR); \ mkdir -p $(PRG_BINDIR); #+END_SRC diff --git a/org/meta_conf_make_meta.org b/org/meta_conf_make_meta.org index 118219e..31a4bd4 100644 --- a/org/meta_conf_make_meta.org +++ b/org/meta_conf_make_meta.org @@ -580,6 +580,8 @@ template contentYAMLtoSpineStruct() { return _struct_composite; } } +<> +<> #+END_SRC ** conf @@ -1295,7 +1297,6 @@ if ("make" in _yaml _struct_composite.make.substitute = _mk.substitute(_struct_composite.make_str.substitute); _struct_composite.make.texpdf_font = _mk.texpdf_font(_struct_composite.make_str.texpdf_font); } - #+END_SRC ** meta @@ -2347,9 +2348,8 @@ if ("rights" in _json.object) { ** 1. parse Yaml config return spineStruct -#+HEADER: :tangle "../src/doc_reform/meta/conf_make_meta_yaml.d" +#+NAME: parse_yaml_return_spineStruct #+BEGIN_SRC d -<> template configParseYAMLreturnSpineStruct() { import dyaml; import @@ -2387,9 +2387,8 @@ template configParseYAMLreturnSpineStruct() { ** 2. parse YAML header to +(JSON then)+ Struct -#+HEADER: :tangle "../src/doc_reform/meta/conf_make_meta_yaml.d" +#+NAME: doc_header_convert_to_struct #+BEGIN_SRC d -<> template docHeaderMakeAndMetaTupYamlExtractAndConvertToStruct() { import std.exception, diff --git a/org/out_cgi_search_sqlite.org b/org/out_cgi_search_sqlite.org index f65b1b7..cc58bfc 100644 --- a/org/out_cgi_search_sqlite.org +++ b/org/out_cgi_search_sqlite.org @@ -102,34 +102,34 @@ void cgi_function_intro(Cgi cgi) { <> cv.db_selected = "%s"; <> - <> - <> - <> - <> + <> + <> + <> + <> <> <> <> <> <> <> -<> + <> <> <> <> -<> -<> + <> + <> <> <> "%s", -<> -<> + <> + <> <> <> <> <> -<> -<> -<> + <> + <> + <> <> <> <> @@ -350,77 +350,77 @@ auto text_fields() { #+NAME: cgi_sqlite_initialize_rgx #+BEGIN_SRC d - 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 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"); - } +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 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"); +} #+END_SRC ***** searchfields #+NAME: cgi_sqlite_initialize_fields #+BEGIN_SRC d - 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 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(); +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 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(); #+END_SRC ***** env @@ -428,258 +428,258 @@ auto text_fields() { #+NAME: cgi_sqlite_initialize_env_0 #+BEGIN_SRC d - 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)) { +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"]; - } 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"]; - } else if ("fn" in cgi.post) { - got.search_text_area ~= "\nfn: " ~ cgi.post["fn"] ~ "\n"; - } - 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.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 (auto m = got.search_text_area.matchFirst(rgx.author)) { + got.author = m["matched"]; + got.canned_query ~= "&au=" ~ m["matched"]; } - if ("rt" in cgi.post) { - got.results_type = cgi.post["rt"]; - got.canned_query ~= "&rt=" ~ cgi.post["rt"]; + if (auto m = got.search_text_area.matchFirst(rgx.title)) { + got.title = m["matched"]; + got.canned_query ~= "&ti=" ~ m["matched"]; } - if ("sts" in cgi.post) { - got.stats = cgi.post["sts"]; - got.canned_query ~= "&sts=" ~ cgi.post["sts"]; + if (auto m = got.search_text_area.matchFirst(rgx.uid)) { + got.uid = m["matched"]; + got.canned_query ~= "&uid=" ~ m["matched"]; } - if ("ec" in cgi.post) { - got.echo = cgi.post["ec"]; - got.canned_query ~= "&ec=" ~ cgi.post["ec"]; + if (auto m = got.search_text_area.matchFirst(rgx.fn)) { + got.fn = m["matched"]; + got.canned_query ~= "&fn=" ~ m["matched"]; + } else if ("fn" in cgi.post) { + got.search_text_area ~= "\nfn: " ~ cgi.post["fn"] ~ "\n"; } - if ("url" in cgi.post) { - got.url = cgi.post["url"]; - got.canned_query ~= "&url=" ~ cgi.post["url"]; + if (auto m = got.search_text_area.matchFirst(rgx.keywords)) { + got.keywords = m["matched"]; + got.canned_query ~= "&kw=" ~ m["matched"]; } - if ("se" in cgi.post) { - got.searched = cgi.post["se"]; - got.canned_query ~= "&se=" ~ cgi.post["se"]; + if (auto m = got.search_text_area.matchFirst(rgx.topic_register)) { + got.topic_register = m["matched"]; + got.canned_query ~= "&tr=" ~ m["matched"]; } - if ("sql" in cgi.post) { - got.sql = cgi.post["sql"]; - got.canned_query ~= "&sql=" ~ cgi.post["sql"]; + if (auto m = got.search_text_area.matchFirst(rgx.subject)) { + got.subject = m["matched"]; + got.canned_query ~= "&su=" ~ m["matched"]; } - if ("sml" in cgi.post) { - got.sql_match_limit = cgi.post["sml"]; - got.canned_query ~= "&sml=" ~ cgi.post["sml"]; + if (auto m = got.search_text_area.matchFirst(rgx.description)) { + got.description = m["matched"]; + got.canned_query ~= "&de=" ~ m["matched"]; } - if ("smo" in cgi.post) { - got.sql_match_offset = "0"; // cgi.post["smo"]; - got.canned_query ~= "&smo=0"; // ~ cgi.post["smo"]; + if (auto m = got.search_text_area.matchFirst(rgx.publisher)) { + got.publisher = m["matched"]; + got.canned_query ~= "&pb=" ~ m["matched"]; } - got.canned_query = got.canned_query.strip.split(" ").join("%%20"); - conf.query_string = got.canned_query; - // cgi.write("f.canned_query: " ~ got.canned_query ~ "
"); -#+END_SRC - -****** GET - -#+NAME: cgi_sqlite_initialize_env_1 -#+BEGIN_SRC d - } 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 (auto m = got.search_text_area.matchFirst(rgx.editor)) { + got.editor = m["matched"]; + got.canned_query ~= "&ed=" ~ m["matched"]; } - 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 (auto m = got.search_text_area.matchFirst(rgx.contributor)) { + got.contributor = m["matched"]; + got.canned_query ~= "&ct=" ~ m["matched"]; } - 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 (auto m = got.search_text_area.matchFirst(rgx.date)) { + got.date = m["matched"]; + got.canned_query ~= "&dt=" ~ m["matched"]; } - 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 (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 ("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 (auto m = got.search_text_area.matchFirst(rgx.source)) { + got.source = m["matched"]; + got.canned_query ~= "&src=" ~ m["matched"]; } - 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 (auto m = got.search_text_area.matchFirst(rgx.language)) { + got.language = m["matched"]; + got.canned_query ~= "&lng=" ~ m["matched"]; } - 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 (auto m = got.search_text_area.matchFirst(rgx.relation)) { + got.relation = m["matched"]; + got.canned_query ~= "&rl=" ~ m["matched"]; } - 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 (auto m = got.search_text_area.matchFirst(rgx.coverage)) { + got.coverage = m["matched"]; + got.canned_query ~= "&cv=" ~ m["matched"]; } - 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 (auto m = got.search_text_area.matchFirst(rgx.rights)) { + got.rights = m["matched"]; + got.canned_query ~= "&rgt=" ~ m["matched"]; } - 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 (auto m = got.search_text_area.matchFirst(rgx.comment)) { + got.comment = m["matched"]; + got.canned_query ~= "&cmt=" ~ m["matched"]; } - // if ("abstract" in canned_query && !(canned_query["abstract"]).empty) { - // got.abstract = canned_query["abstract"]; + // if (auto m = search_text_area.matchFirst(rgx.abstract)) { + // got.abstract = m["matched"]; // } - 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"; + if (auto m = got.search_text_area.matchFirst(rgx.src_filename_base)) { + got.src_filename_base = m["matched"]; + got.canned_query ~= "&bfn=" ~ m["matched"]; } - // cgi.write("f.search_text_area: " ~ got.search_text_area ~ "
"); } - return got; + 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 ~ "
"); +#+END_SRC + +****** GET + +#+NAME: cgi_sqlite_initialize_env_1 +#+BEGIN_SRC d +} 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 ("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; #+END_SRC ***** tail @@ -833,8 +833,8 @@ string show_matched_objects (string fn) { #+NAME: cgi_sqlite_header_0 #+BEGIN_SRC d - { - header = format(q"┃ +{ + header = format(q"┃ #+END_SRC **** html @@ -1667,18 +1667,18 @@ string show_matched_objects (string fn) { #+BEGIN_SRC html { table = format(q"┃ - - -
- - -
- %s -
-
+ + + +
+ +
+ %s
- ┃"); +
+
+┃"); } #+END_SRC @@ -1686,81 +1686,81 @@ string show_matched_objects (string fn) { #+NAME: cgi_sqlite_form_0 #+BEGIN_SRC d - { - 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 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; + } #+END_SRC **** canned search #+NAME: cgi_sqlite_form_1 #+BEGIN_SRC d - 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 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; +} #+END_SRC **** provide tip @@ -1842,61 +1842,61 @@ string show_matched_objects (string fn) { #+NAME: cgi_sqlite_form_post_0 #+BEGIN_SRC d - (post_value("ec") == "checked") ? post_value("sf", "field") : "", - provide_tip, - search_note, - the_can(post_value("sf", "field")), - 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("url"), - post_value("se"), - post_value("sql"), - ); + (post_value("ec") == "checked") ? post_value("sf", "field") : "", + provide_tip, + search_note, + the_can(post_value("sf", "field")), + 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("url"), + post_value("se"), + post_value("sql"), +); #+END_SRC **** set value (debug) #+NAME: cgi_sqlite_form_post_1 #+BEGIN_SRC d - { - 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", "%s"); // selected_db_name == db (spine.search.db or whatever) - 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; + { + 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", "%s"); // selected_db_name == db (spine.search.db or whatever) + 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; } +} #+END_SRC *** cgi write @@ -2070,125 +2070,125 @@ LIMIT %%s OFFSET %%s #+NAME: cgi_sqlite_select_statement_2 #+BEGIN_SRC d - (cv.checked_sql) - ? cgi.write(previous_next - ~ "
" - ~ sql_select.the_body.strip.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) { - string _date_published = "0000"; - string _close_para = ""; - string _matched_ocn_open = ""; - foreach (idx, row; select_query_results) { - if (row["uid"].as!string != _old_uid) { - _close_para = (idx == 1) ? "" : "

"; - _matched_ocn_open = (idx == 1) ? "" : "

"; - _old_uid = row["uid"].as!string; - _date_published = (row["date_published"].as!string.match(regex(r"^([0-9]{4})"))) - ? row["date_published"].as!string : "0000"; // used in regex that breaks if no match - auto m = _date_published.match(regex(r"^([0-9]{4})")); - string _date = (m.hit == "0000") ? "(year?) " : "(" ~ m.hit ~ ") "; - cgi.write( - _close_para - ~ "


" - ~ "

\"" - ~ row["title"].as!string ~ "\"" - ~ " " - ~ _date - ~ "[" ~ row["language_document_char"].as!string ~ "] " - ~ row["creator_author_last_first"].as!string - ~ " " - ~ show_matched_objects(row["src_filename_base"].as!string) - ~ "

" - ~ "
" - ); - } +(cv.checked_sql) +? cgi.write(previous_next + ~ "
" + ~ sql_select.the_body.strip.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) { + string _date_published = "0000"; + string _close_para = ""; + string _matched_ocn_open = ""; + foreach (idx, row; select_query_results) { + if (row["uid"].as!string != _old_uid) { + _close_para = (idx == 1) ? "" : "

"; + _matched_ocn_open = (idx == 1) ? "" : "

"; + _old_uid = row["uid"].as!string; + _date_published = (row["date_published"].as!string.match(regex(r"^([0-9]{4})"))) + ? row["date_published"].as!string : "0000"; // used in regex that breaks if no match + auto m = _date_published.match(regex(r"^([0-9]{4})")); + string _date = (m.hit == "0000") ? "(year?) " : "(" ~ m.hit ~ ") "; + cgi.write( + _close_para + ~ "


" + ~ "

\"" + ~ row["title"].as!string ~ "\"" + ~ " " + ~ _date + ~ "[" ~ row["language_document_char"].as!string ~ "] " + ~ row["creator_author_last_first"].as!string + ~ " " + ~ show_matched_objects(row["src_filename_base"].as!string) + ~ "

" + ~ "
" + ); + } #+END_SRC ***** text found #+NAME: cgi_sqlite_select_statement_3 #+BEGIN_SRC d - if (cv.results_type == "txt") { - if (row["ocn"].as!string != "0") { - cgi.write( - "
" - ~ "" - ~ "
" - ~ highlight_text_matched(row["body"].as!string, tf.text) - ~ "
" - ~ "
" - ); - } else { - cgi.write( - "
" - ~ "" - ~ "
" - ~ highlight_text_matched(row["body"].as!string, tf.text) - ~ "
" - ~ "
" - ); - } +if (cv.results_type == "txt") { + if (row["ocn"].as!string != "0") { + cgi.write( + "
" + ~ "" + ~ "
" + ~ highlight_text_matched(row["body"].as!string, tf.text) + ~ "
" + ~ "
" + ); + } else { + cgi.write( + "
" + ~ "" + ~ "
" + ~ highlight_text_matched(row["body"].as!string, tf.text) + ~ "
" + ~ "
" + ); + } #+END_SRC ***** ocn index #+NAME: cgi_sqlite_select_statement_4 #+BEGIN_SRC d - } else { - if (row["ocn"].as!string != "0") { - cgi.write( - _matched_ocn_open - ~ "" - ~ row["ocn"].as!string - ~ ", " - ); - } else { - cgi.write( - _matched_ocn_open - ~ "" - ~ row["ocn"].as!string - ~ ", " - ); - } - _matched_ocn_open = ""; - } +} else { + if (row["ocn"].as!string != "0") { + cgi.write( + _matched_ocn_open + ~ "" + ~ row["ocn"].as!string + ~ ", " + ); + } else { + cgi.write( + _matched_ocn_open + ~ "" + ~ row["ocn"].as!string + ~ ", " + ); + } + _matched_ocn_open = ""; +} #+END_SRC ***** tail @@ -2272,7 +2272,7 @@ configuration "default" { * cgi-search README -#+HEADER: :NO-tangle "../sundry/util/d/cgi/search/README" +#+HEADER: :NO-tangle "../sundry/misc/util/d/cgi/search/README" #+BEGIN_SRC text change db name to match name of db you create cv.db_selected = "spine.search.sql.db"; diff --git a/org/out_latex.org b/org/out_latex.org index 5aecfbd..326f8cd 100644 --- a/org/out_latex.org +++ b/org/out_latex.org @@ -54,25 +54,25 @@ template outputLaTeX() { <> <> <> - <> + <> <> -<> -<> + <> + <> <> <> -<> + <> <> <> -<> -<> + <> + <> <> <> -<> -<> -<> + <> + <> + <> <> <> -<> + <> <> <> <> @@ -108,7 +108,7 @@ template outputLaTeX() { <> <> <> - <> + <> <> <> <> @@ -204,166 +204,166 @@ import doc_reform.io_out; #+NAME: output_latex_shared_a_paper_type #+BEGIN_SRC d - auto paper() { - struct PaperType { - @safe auto a4() { - struct A4 { - auto portrait() { - struct V { - const uint w = 160; - const uint h = 228; - string width = format(q"┃%dmm┃", w); - string height = format(q"┃%dmm┃", h); - string font_size = "12pt"; - string name = "a4paper"; - uint img_px = 450; - bool is_portrait = true; - } - return V(); - } - auto landscape() { - struct H { - const uint w = 238; - const uint h = 160; - string width = format(q"┃%dmm┃", w); - string height = format(q"┃%dmm┃", h); - string font_size = "11pt"; - string name = "a4paper"; - uint img_px = 300; - bool is_portrait = false; - } - return H(); - } +auto paper() { + struct PaperType { + @safe auto a4() { + struct A4 { + auto portrait() { + struct V { + const uint w = 160; + const uint h = 228; + string width = format(q"┃%dmm┃", w); + string height = format(q"┃%dmm┃", h); + string font_size = "12pt"; + string name = "a4paper"; + uint img_px = 450; + bool is_portrait = true; } - return A4(); + return V(); } - @safe auto a5() { - struct A5 { - auto portrait() { - struct V { - const uint w = 112; - const uint h = 162; - string width = format(q"┃%dmm┃", w); - string height = format(q"┃%dmm┃", h); - string font_size = "0pt"; - string name = "a5paper"; - uint img_px = 280; - bool is_portrait = true; - } - return V(); - } - auto landscape() { - struct H { - const uint w = 152; - const uint h = 100; - string width = format(q"┃%dmm┃", w); - string height = format(q"┃%dmm┃", h); - string font_size = "0pt"; - string name = "a5paper"; - uint img_px = 190; - bool is_portrait = false; - } - return H(); - } + auto landscape() { + struct H { + const uint w = 238; + const uint h = 160; + string width = format(q"┃%dmm┃", w); + string height = format(q"┃%dmm┃", h); + string font_size = "11pt"; + string name = "a4paper"; + uint img_px = 300; + bool is_portrait = false; } - return A5(); + return H(); } - @safe auto b4() { - struct B4 { - auto portrait() { - struct V { - const uint w = 140; - const uint h = 204; - string width = format(q"┃%dmm┃", w); - string height = format(q"┃%dmm┃", h); - string font_size = "0pt"; - string name = "b4paper"; - uint img_px = 356; - bool is_portrait = true; - } - return V(); - } - auto landscape() { - struct H { - const uint w = 200; - const uint h = 130; - string width = format(q"┃%dmm┃", w); - string height = format(q"┃%dmm┃", h); - string font_size = "0pt"; - string name = "b4paper"; - uint img_px = 260; - bool is_portrait = false; - } - return H(); - } + } + return A4(); + } + @safe auto a5() { + struct A5 { + auto portrait() { + struct V { + const uint w = 112; + const uint h = 162; + string width = format(q"┃%dmm┃", w); + string height = format(q"┃%dmm┃", h); + string font_size = "0pt"; + string name = "a5paper"; + uint img_px = 280; + bool is_portrait = true; + } + return V(); + } + auto landscape() { + struct H { + const uint w = 152; + const uint h = 100; + string width = format(q"┃%dmm┃", w); + string height = format(q"┃%dmm┃", h); + string font_size = "0pt"; + string name = "a5paper"; + uint img_px = 190; + bool is_portrait = false; + } + return H(); + } + } + return A5(); + } + @safe auto b4() { + struct B4 { + auto portrait() { + struct V { + const uint w = 140; + const uint h = 204; + string width = format(q"┃%dmm┃", w); + string height = format(q"┃%dmm┃", h); + string font_size = "0pt"; + string name = "b4paper"; + uint img_px = 356; + bool is_portrait = true; + } + return V(); + } + auto landscape() { + struct H { + const uint w = 200; + const uint h = 130; + string width = format(q"┃%dmm┃", w); + string height = format(q"┃%dmm┃", h); + string font_size = "0pt"; + string name = "b4paper"; + uint img_px = 260; + bool is_portrait = false; } - return B4(); + return H(); } - @safe auto letter() { - struct Letter { - auto portrait() { - struct V { - const uint w = 166; - const uint h = 212; - string width = format(q"┃%dmm┃", w); - string height = format(q"┃%dmm┃", h); - string font_size = "0pt"; - string name = "letterpaper"; - uint img_px = 468; - bool is_portrait = true; - } - return V(); - } - auto landscape() { - struct H { - const uint w = 226; - const uint h = 166; - string width = format(q"┃%dmm┃", w); - string height = format(q"┃%dmm┃", h); - string font_size = "0pt"; - string name = "letterpaper"; - uint img_px = 290; - bool is_portrait = false; - } - return H(); - } + } + return B4(); + } + @safe auto letter() { + struct Letter { + auto portrait() { + struct V { + const uint w = 166; + const uint h = 212; + string width = format(q"┃%dmm┃", w); + string height = format(q"┃%dmm┃", h); + string font_size = "0pt"; + string name = "letterpaper"; + uint img_px = 468; + bool is_portrait = true; + } + return V(); + } + auto landscape() { + struct H { + const uint w = 226; + const uint h = 166; + string width = format(q"┃%dmm┃", w); + string height = format(q"┃%dmm┃", h); + string font_size = "0pt"; + string name = "letterpaper"; + uint img_px = 290; + bool is_portrait = false; + } + return H(); + } + } + return Letter(); + } + @safe auto legal() { + struct Legal { + auto portrait() { + struct V { + const uint w = 168; + const uint h = 286; + string width = format(q"┃%dmm┃", w); + string height = format(q"┃%dmm┃", h); + string font_size = "0pt"; + string name = "legalpaper"; + uint img_px = 474; + bool is_portrait = true; } - return Letter(); + return V(); } - @safe auto legal() { - struct Legal { - auto portrait() { - struct V { - const uint w = 168; - const uint h = 286; - string width = format(q"┃%dmm┃", w); - string height = format(q"┃%dmm┃", h); - string font_size = "0pt"; - string name = "legalpaper"; - uint img_px = 474; - bool is_portrait = true; - } - return V(); - } - auto landscape() { - struct H { - const uint w = 296; - const uint h = 166; - string width = format(q"┃%dmm┃", w); - string height = format(q"┃%dmm┃", h); - string font_size = "0pt"; - string name = "legalpaper"; - uint img_px = 420; - bool is_portrait = false; - } - return H(); - } + auto landscape() { + struct H { + const uint w = 296; + const uint h = 166; + string width = format(q"┃%dmm┃", w); + string height = format(q"┃%dmm┃", h); + string font_size = "0pt"; + string name = "legalpaper"; + uint img_px = 420; + bool is_portrait = false; } - return Legal(); + return H(); } } - return PaperType(); + return Legal(); } + } + return PaperType(); +} #+END_SRC *** latex \escape special characters @@ -1091,19 +1091,19 @@ string latex_head(M)( #+NAME: output_latex_head_papertype #+BEGIN_SRC d - struct paperTypeLatex { - string a4_portrait; - string a4_landscape; - string a5_portrait; - string a5_landscape; - string b4_portrait; - string b4_landscape; - string us_letter_portrait; - string us_letter_landscape; - string us_legal_portrait; - string us_legal_landscape; - } - auto paper_type_latex = paperTypeLatex(); +struct paperTypeLatex { + string a4_portrait; + string a4_landscape; + string a5_portrait; + string a5_landscape; + string b4_portrait; + string b4_landscape; + string us_letter_portrait; + string us_letter_landscape; + string us_legal_portrait; + string us_legal_landscape; +} +auto paper_type_latex = paperTypeLatex(); #+END_SRC ****** footer @@ -1145,18 +1145,18 @@ string latex_head(M)( #+NAME: output_latex_head_b_tex_papermargins #+BEGIN_SRC d - struct paperMargins { - string portrait; - string landscape; - } - auto margins = paperMargins(); +struct paperMargins { + string portrait; + string landscape; +} +auto margins = paperMargins(); #+END_SRC ****** portrait #+NAME: output_latex_head_b_tex_papermargins_portrait #+BEGIN_SRC d - margins.portrait = format(q"┃ +margins.portrait = format(q"┃ #+END_SRC #+NAME: output_latex_head_b_tex_papermargins_portrait_set @@ -1176,7 +1176,7 @@ string latex_head(M)( #+NAME: output_latex_head_b_tex_papermargins_landscape #+BEGIN_SRC d - margins.landscape = format(q"┃ +margins.landscape = format(q"┃ #+END_SRC #+NAME: output_latex_head_b_tex_papermargins_landscape_set @@ -1197,18 +1197,18 @@ string latex_head(M)( #+NAME: output_latex_head_b_tex_columns_multi #+BEGIN_SRC d - struct columnsMulti { - string portrait; - string landscape; - } - auto multicol = columnsMulti(); +struct columnsMulti { + string portrait; + string landscape; +} +auto multicol = columnsMulti(); #+END_SRC ****** portrait #+NAME: output_latex_head_b_tex_columns_multi_portrait #+BEGIN_SRC d - multicol.portrait = format(q"┃ +multicol.portrait = format(q"┃ #+END_SRC #+NAME: output_latex_head_b_tex_columns_multi_portrait_set @@ -1226,7 +1226,7 @@ string latex_head(M)( #+NAME: output_latex_head_b_tex_columns_multi_landscape #+BEGIN_SRC d - multicol.landscape = ""; +multicol.landscape = ""; #+END_SRC ***** color links @@ -1234,18 +1234,18 @@ string latex_head(M)( #+NAME: output_latex_head_b_tex_colorlinks #+BEGIN_SRC d - struct colorLinks { - string mono; - string color; - } - auto links = colorLinks(); +struct colorLinks { + string mono; + string color; +} +auto links = colorLinks(); #+END_SRC ****** mono #+NAME: output_latex_head_b_tex_colorlinks_mono #+BEGIN_SRC d - links.mono = format(q"┃ +links.mono = format(q"┃ #+END_SRC #+NAME: output_latex_head_b_tex_colorlinks_mono_set @@ -1267,7 +1267,7 @@ string latex_head(M)( #+NAME: output_latex_head_b_tex_colorlinks_color #+BEGIN_SRC d - links.color = format(q"┃ +links.color = format(q"┃ #+END_SRC #+NAME: output_latex_head_b_tex_colorlinks_color_set @@ -1900,25 +1900,25 @@ case "backmatter": #+NAME: output_latex_body_for_doc_default #+BEGIN_SRC d - case "comment": - break; - default: - { /+ debug +/ - if (doc_matters.opt.action.debug_do - && doc_matters.opt.action.verbose) { - writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_part); - writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); - writeln(__FILE__, ":", __LINE__, ": ", obj.text); - } + case "comment": + break; + default: + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_part); + writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); + writeln(__FILE__, ":", __LINE__, ": ", obj.text); } - break; } + break; } } - if (_multicolumns) { - _multicolumns = false; - _latex_body ~= "\n\\end{multicols}\n"; - } +} +if (_multicolumns) { + _multicolumns = false; + _latex_body ~= "\n\\end{multicols}\n"; +} #+END_SRC **** latex body return @@ -1982,7 +1982,9 @@ string _latex_tail = format(q"┃ #+HEADER: :tangle-mode (identity #o755) #+HEADER: :shebang #!/usr/bin/env ruby #+BEGIN_SRC ruby -# <> +=begin +<> +=end require 'fileutils' pwd = Dir.pwd argv,texfiles_with_path,flags=[],[],[] diff --git a/org/out_sqlite.org b/org/out_sqlite.org index 1cb9b40..a0f5290 100644 --- a/org/out_sqlite.org +++ b/org/out_sqlite.org @@ -266,13 +266,13 @@ template SQLiteInsertMetadata() { M doc_matters, ) { <> - <> - <> + <> + <> <> <> <> - <> - <> + <> + <> <> <> return _insert_metadata; @@ -293,8 +293,8 @@ template SQLiteInsertDocObjectsLoop() { 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; } @@ -1762,67 +1762,67 @@ string _insert_metadata = format(q"┃ #+NAME: sqlite_formatted_insertions_doc_matters_metadata_1 #+BEGIN_SRC sql - INSERT INTO metadata_and_text ( - uid, - src_filename_base, - src_filename_suffix, - src_composite_id_per_txt, - src_composite_id_per_pod, - title, - title_main, - title_sub, - title_short, - title_edition, - title_language, - creator_author, - creator_author_last_first, - creator_author_email, - creator_illustrator, - creator_translator, - language_document, - language_document_char, - date_added_to_site, - date_available, - date_created, - date_issued, - date_modified, - date_published, - date_valid, - rights_copyright, - rights_copyright_audio, - rights_copyright_cover, - rights_copyright_illustrations, - rights_copyright_photographs, - rights_copyright_text, - rights_copyright_translation, - rights_copyright_video, - rights_license, - identifier_oclc, - identifier_isbn, - classify_dewey, - classify_keywords, - classify_loc, - classify_subject, - classify_topic_register, - original_title, - original_publisher, - original_language, - original_language_char, - original_source, - notes_abstract, - notes_description, - publisher, - site_url_doc_root - ) +INSERT INTO metadata_and_text ( + uid, + src_filename_base, + src_filename_suffix, + src_composite_id_per_txt, + src_composite_id_per_pod, + title, + title_main, + title_sub, + title_short, + title_edition, + title_language, + creator_author, + creator_author_last_first, + creator_author_email, + creator_illustrator, + creator_translator, + language_document, + language_document_char, + date_added_to_site, + date_available, + date_created, + date_issued, + date_modified, + date_published, + date_valid, + rights_copyright, + rights_copyright_audio, + rights_copyright_cover, + rights_copyright_illustrations, + rights_copyright_photographs, + rights_copyright_text, + rights_copyright_translation, + rights_copyright_video, + rights_license, + identifier_oclc, + identifier_isbn, + classify_dewey, + classify_keywords, + classify_loc, + classify_subject, + classify_topic_register, + original_title, + original_publisher, + original_language, + original_language_char, + original_source, + notes_abstract, + notes_description, + publisher, + site_url_doc_root +) #+END_SRC ***** VALUES #+NAME: sqlite_formatted_insertions_doc_matters_metadata_2 #+BEGIN_SRC sql - 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' - ); +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' +); #+END_SRC ***** dlang values for formatting @@ -1908,23 +1908,23 @@ _insert_topics ~= format(q"┃ #+NAME: sqlite_formatted_insertions_topic_register_2 #+BEGIN_SRC sql - INSERT INTO topic_register ( - uid_metadata_and_text, - topic_register_lv0, - topic_register_lv1, - topic_register_lv2, - topic_register_lv3, - topic_register_lv4 - ) +INSERT INTO topic_register ( + uid_metadata_and_text, + topic_register_lv0, + topic_register_lv1, + topic_register_lv2, + topic_register_lv3, + topic_register_lv4 +) #+END_SRC ***** VALUES #+NAME: sqlite_formatted_insertions_topic_register_3 #+BEGIN_SRC sql - VALUES ( - '%s', '%s', '%s', '%s', '%s', '%s' - ); +VALUES ( + '%s', '%s', '%s', '%s', '%s', '%s' +); #+END_SRC ***** dlang values for formatting @@ -1969,26 +1969,26 @@ string _insert_doc_objects_row = format(q"┃ #+NAME: sqlite_formatted_insertions_doc_objects_1 #+BEGIN_SRC sql - INSERT INTO doc_objects ( - uid_metadata_and_text, - ocn, - obj_id, - clean, - body, - lev, - is_of_type, - is_a, - seg_name - ) +INSERT INTO doc_objects ( + uid_metadata_and_text, + ocn, + obj_id, + clean, + body, + lev, + is_of_type, + is_a, + seg_name +) #+END_SRC ***** VALUES #+NAME: sqlite_formatted_insertions_doc_objects_2 #+BEGIN_SRC sql - VALUES ( - '%s', %s, '%s', '%s', '%s', %s, '%s', '%s', '%s' - ); +VALUES ( + '%s', %s, '%s', '%s', '%s', %s, '%s', '%s', '%s' +); #+END_SRC ***** dlang values for formatting diff --git a/org/out_src_pod.org b/org/out_src_pod.org index f1c6ff1..daa2f04 100644 --- a/org/out_src_pod.org +++ b/org/out_src_pod.org @@ -449,6 +449,13 @@ if (exists(fn_pod)) { } #+END_SRC +** source pod zip + +#+NAME: source_pod_zip +#+BEGIN_SRC d +// source pod zip +#+END_SRC + * document header including copyright & license #+NAME: doc_header_including_copyright_and_license diff --git a/org/out_xmls.org b/org/out_xmls.org index df0d724..864e86e 100644 --- a/org/out_xmls.org +++ b/org/out_xmls.org @@ -2208,7 +2208,6 @@ default: M doc_matters, ) { { /+ (copy html images) +/ - auto pth_html = spinePathsHTML!()(doc_matters.output_path, doc_matters.src.language); if (!exists(pth_html.image)) { pth_html.image.mkdirRecurse; @@ -2267,7 +2266,7 @@ template outputEPub3() { <> <> <> - <> + <> <> <> <> @@ -2687,9 +2686,9 @@ xmlns="urn:oasis:names:tc:opendocument:xmlns:container"> #+NAME: output_epub3_xhtml_seg_output_loop #+BEGIN_SRC d - foreach (part; doc_matters.has.keys_seq.seg) { - foreach (obj; doc_abstraction[part]) { - string _txt = xhtml_format.special_characters(obj); +foreach (part; doc_matters.has.keys_seq.seg) { + foreach (obj; doc_abstraction[part]) { + string _txt = xhtml_format.special_characters(obj); #+END_SRC ***** all headings diff --git a/org/spine.org b/org/spine.org index fa246b9..61ed8cc 100644 --- a/org/spine.org +++ b/org/spine.org @@ -1351,11 +1351,11 @@ template spineAbstraction() { <> <> <> - <> - <> - <> - <> - <> + <> + <> + <> + <> + <> <> <> auto t = tuple(doc_abstraction, doc_matters); @@ -1518,167 +1518,167 @@ struct DocumentMatters { #+NAME: spine_each_file_do_document_matters_1_detail_program_time #+BEGIN_SRC d - @safe auto generator_program() { - struct Prog_ { - @safe string project_name() { - return "spine"; - } - @safe string name() { - return program_info.name; - } - @safe string ver() { - return program_info.ver; - } - @trusted string name_and_version() { - return format("%s-%s", - name, - ver, - ); - } - @safe string url_home() { - return "https://sisudoc.org"; - } - @safe string url_git() { - return "https://git.sisudoc.org/software/sisu"; - } - @safe auto compiler() { - return program_info.compiler; - } - @safe auto stime() { - return Clock.currTime(UTC()).toSimpleString(); - } +@safe auto generator_program() { + struct Prog_ { + @safe string project_name() { + return "spine"; + } + @safe string name() { + return program_info.name; + } + @safe string ver() { + return program_info.ver; + } + @trusted string name_and_version() { + return format("%s-%s", + name, + ver, + ); + } + @safe string url_home() { + return "https://sisudoc.org"; + } + @safe string url_git() { + return "https://git.sisudoc.org/software/sisu"; + } + @safe auto compiler() { + return program_info.compiler; + } + @safe auto stime() { + return Clock.currTime(UTC()).toSimpleString(); } - return Prog_(); - } - @safe auto generated_time() { - auto _st = Clock.currTime(UTC()); - auto _time = _st.year.to!string - ~ "-" ~ _st.month.to!int.to!string // prefer as month number - ~ "-" ~ _st.day.to!string - ~ " [" ~ _st.isoWeek.to!string ~ "/" ~ _st.dayOfWeek.to!int.to!string ~ "]" - ~ " " ~ _st.hour.to!string - ~ ":" ~ _st.minute.to!string - ~ ":" ~ _st.second.to!string; - return _time; } + return Prog_(); +} +@safe auto generated_time() { + auto _st = Clock.currTime(UTC()); + auto _time = _st.year.to!string + ~ "-" ~ _st.month.to!int.to!string // prefer as month number + ~ "-" ~ _st.day.to!string + ~ " [" ~ _st.isoWeek.to!string ~ "/" ~ _st.dayOfWeek.to!int.to!string ~ "]" + ~ " " ~ _st.hour.to!string + ~ ":" ~ _st.minute.to!string + ~ ":" ~ _st.second.to!string; + return _time; +} #+END_SRC **** config make & meta #+NAME: spine_each_file_do_document_matters_2_meta #+BEGIN_SRC d - @safe auto conf_make_meta() { - return _make_and_meta_struct; - } - @safe auto has() { - return _doc_has_struct; - } +@safe auto conf_make_meta() { + return _make_and_meta_struct; +} +@safe auto has() { + return _doc_has_struct; +} #+END_SRC **** env related #+NAME: spine_each_file_do_document_matters_3_env #+BEGIN_SRC d - @safe auto env() { - struct Env_ { - @safe auto pwd() { - return _manifest.env.pwd; - } - @safe auto home() { - return _manifest.env.home; - } +@safe auto env() { + struct Env_ { + @safe auto pwd() { + return _manifest.env.pwd; + } + @safe auto home() { + return _manifest.env.home; } - return Env_(); } + return Env_(); +} #+END_SRC **** opt #+NAME: spine_each_file_do_document_matters_4_opt #+BEGIN_SRC d - @safe auto opt() { - struct Opt_ { - @safe auto action() { - /+ getopt options, commandline instructions, raw - - processing instructions --epub --html etc. - - command line config instructions --output - +/ - return _opt_action; - } +@safe auto opt() { + struct Opt_ { + @safe auto action() { + /+ getopt options, commandline instructions, raw + - processing instructions --epub --html etc. + - command line config instructions --output + +/ + return _opt_action; } - return Opt_(); } + return Opt_(); +} #+END_SRC **** output related #+NAME: spine_each_file_do_document_matters_5_doc #+BEGIN_SRC d - @safe auto src() { - return _manifest.src; - } - @safe auto src_path_info() { - return spinePathsSRC!()(_manifest.env.pwd, _manifest.src.file_with_absolute_path); // would like (to have and use) relative path - } - @safe auto pod() { - return _manifest.pod; - } - @safe auto sqlite() { - struct SQLite_ { - @safe string filename() { - string _fn = ""; - string _pth = ""; - if (_opt_action.sqliteDB_filename.length > 0) { - _fn = _opt_action.sqliteDB_filename; - } else if (_make_and_meta_struct.conf.w_srv_db_sqlite_filename.length > 0) { - _fn = _make_and_meta_struct.conf.w_srv_db_sqlite_filename; - } - return _fn; +@safe auto src() { + return _manifest.src; +} +@safe auto src_path_info() { + return spinePathsSRC!()(_manifest.env.pwd, _manifest.src.file_with_absolute_path); // would like (to have and use) relative path +} +@safe auto pod() { + return _manifest.pod; +} +@safe auto sqlite() { + struct SQLite_ { + @safe string filename() { + string _fn = ""; + string _pth = ""; + if (_opt_action.sqliteDB_filename.length > 0) { + _fn = _opt_action.sqliteDB_filename; + } else if (_make_and_meta_struct.conf.w_srv_db_sqlite_filename.length > 0) { + _fn = _make_and_meta_struct.conf.w_srv_db_sqlite_filename; } - @safe string path() { - string _pth = ""; - if (_opt_action.sqliteDB_path.length > 0) { - _pth = _opt_action.sqliteDB_path; - } else if (_make_and_meta_struct.conf.w_srv_db_sqlite_path.length > 0) { - _pth = _make_and_meta_struct.conf.w_srv_db_sqlite_path; - } - return _pth; + return _fn; + } + @safe string path() { + string _pth = ""; + if (_opt_action.sqliteDB_path.length > 0) { + _pth = _opt_action.sqliteDB_path; + } else if (_make_and_meta_struct.conf.w_srv_db_sqlite_path.length > 0) { + _pth = _make_and_meta_struct.conf.w_srv_db_sqlite_path; } - @safe string cgi_filename() { - string _fn = ""; - if (_opt_action.cgi_sqlite_search_filename.length > 0) { - _fn = _opt_action.cgi_sqlite_search_filename; - } else if (_make_and_meta_struct.conf.w_srv_cgi_search_script.length > 0) { - _fn = _make_and_meta_struct.conf.w_srv_cgi_search_script; - } - return _fn; + return _pth; + } + @safe string cgi_filename() { + string _fn = ""; + if (_opt_action.cgi_sqlite_search_filename.length > 0) { + _fn = _opt_action.cgi_sqlite_search_filename; + } else if (_make_and_meta_struct.conf.w_srv_cgi_search_script.length > 0) { + _fn = _make_and_meta_struct.conf.w_srv_cgi_search_script; } - @safe string cgi_filename_d() { - string _fn = ""; - if (_opt_action.cgi_sqlite_search_filename_d.length > 0) { - _fn = _opt_action.cgi_sqlite_search_filename_d; - } else if (_make_and_meta_struct.conf.w_srv_cgi_search_script_raw_fn_d.length > 0) { - _fn = _make_and_meta_struct.conf.w_srv_cgi_search_script_raw_fn_d; - } - return _fn; + return _fn; + } + @safe string cgi_filename_d() { + string _fn = ""; + if (_opt_action.cgi_sqlite_search_filename_d.length > 0) { + _fn = _opt_action.cgi_sqlite_search_filename_d; + } else if (_make_and_meta_struct.conf.w_srv_cgi_search_script_raw_fn_d.length > 0) { + _fn = _make_and_meta_struct.conf.w_srv_cgi_search_script_raw_fn_d; } + return _fn; } - return SQLite_(); - } - @safe auto output_path() { - return _make_and_meta_struct.conf.output_path; } - @safe auto srcs() { - struct SRC_ { - auto file_insert_list() { - return _header_body_insertfilelist_imagelist[headBody.insert_file_list]; - } - auto image_list() { - return _doc_has_struct.imagelist; - } + return SQLite_(); +} +@safe auto output_path() { + return _make_and_meta_struct.conf.output_path; +} +@safe auto srcs() { + struct SRC_ { + auto file_insert_list() { + return _header_body_insertfilelist_imagelist[headBody.insert_file_list]; + } + auto image_list() { + return _doc_has_struct.imagelist; } - return SRC_(); } + return SRC_(); +} #+END_SRC **** } close diff --git a/org/spine_info.org b/org/spine_info.org index a23f110..1f55127 100644 --- a/org/spine_info.org +++ b/org/spine_info.org @@ -21,21 +21,64 @@ * README :readme: ** tangle +*** org + +#+HEADER: :tangle "../README" +#+BEGIN_SRC text +<> + +<> + +<> + +<> + +<> + +<> +#+END_SRC + +*** md #+HEADER: :tangle "../README.md" #+BEGIN_SRC text <> -<> -<> -<> -<> -<> + +<> + +<> + +<> + +<> +#+END_SRC + +** org header + +#+NAME: sisu_spine_readme_org_header +#+BEGIN_SRC text +-*- mode: org -*- +#+TITLE: spine (doc_reform) (project) README +#+DESCRIPTION: README for spine +#+FILETAGS: :spine:build:tools: +#+AUTHOR: Ralph Amissah +#+EMAIL: [[mailto:ralph.amissah@gmail.com][ralph.amissah@gmail.com]] +#+COPYRIGHT: Copyright (C) 2015 - 2021 Ralph Amissah +#+LANGUAGE: en +#+STARTUP: content hideblocks hidestars noindent entitiespretty +#+OPTIONS: H:3 num:nil toc:t \n:nil @:t ::t |:t ^:nil _:nil -:t f:t *:t <:t +#+PROPERTY: header-args :exports code +#+PROPERTY: header-args+ :noweb yes +#+PROPERTY: header-args+ :eval no +#+PROPERTY: header-args+ :results no +#+PROPERTY: header-args+ :cache no +#+PROPERTY: header-args+ :padline no #+END_SRC ** project name #+NAME: sisu_spine_readme_info -#+BEGIN_SRC markdown +#+BEGIN_SRC yaml project_name: Spine, Doc Reform description: [ @@ -60,18 +103,42 @@ project_name: Spine, Doc Reform ] #+END_SRC -** short description +** short description (currently UNUSED) #+NAME: sisu_spine_readme_description #+BEGIN_SRC text #+END_SRC ** installation +*** org + +#+NAME: sisu_spine_readme_install_org +#+BEGIN_SRC text +,* <> -#+NAME: sisu_spine_readme_install +<> +#+END_SRC + +*** md + +#+NAME: sisu_spine_readme_install_md #+BEGIN_SRC markdown -# Installation, Compilation +# <> +<> +#+END_SRC + +*** heading + +#+NAME: sisu_spine_readme_install_heading +#+BEGIN_SRC text +Installation, Compilation +#+END_SRC + +*** text body + +#+NAME: sisu_spine_readme_install_body +#+BEGIN_SRC markdown SiSU spine is written in the programming language D for which there are 3 compilers: - dmd @@ -105,15 +172,38 @@ https://mesonbuild.com/ make meson dub --force --compiler=ldc2 && sudo cp -v cgi-bin/spine-search /usr/lib/cgi-bin/. - #+END_SRC ** configuration +*** org + +#+NAME: sisu_spine_readme_configuration_org +#+BEGIN_SRC text +,* <> -#+NAME: sisu_spine_readme_configuration +<> +#+END_SRC + +*** md + +#+NAME: sisu_spine_readme_configuration_md #+BEGIN_SRC markdown -# Configuration +# <> + +<> +#+END_SRC + +*** heading +#+NAME: sisu_spine_readme_configuration_heading +#+BEGIN_SRC text +Configuration +#+END_SRC + +*** text body + +#+NAME: sisu_spine_readme_configuration_body +#+BEGIN_SRC markdown Configuration files are yaml files The following paths are searched: @@ -171,15 +261,38 @@ webserv: db_sqlite: "spine.search.db" db_pg_table: "" db_pg_user: "" - #+END_SRC ** commands help +*** org + +#+NAME: sisu_spine_readme_commands_org +#+BEGIN_SRC text +,* <> + +<> +#+END_SRC + +*** md -#+NAME: sisu_spine_readme_commands +#+NAME: sisu_spine_readme_commands_md #+BEGIN_SRC markdown -# Commands +# <> + +<> +#+END_SRC +*** heading + +#+NAME: sisu_spine_readme_commands_heading +#+BEGIN_SRC text +Commands +#+END_SRC + +*** text body + +#+NAME: sisu_spine_readme_commands_body +#+BEGIN_SRC markdown for a list of commands from the program type: spine -h @@ -252,36 +365,91 @@ at the time of writing this provides the following output: --workon (reserved for some matters under development & testing) --xhtml xhtml output -h --help This help information. - #+END_SRC ** command examples +*** text body org -#+NAME: sisu_spine_readme_examples +#+NAME: sisu_spine_readme_examples_org #+BEGIN_SRC markdown -# Examples +,* Examples -if configuartion has been set specify just -- the desired output and -- the markup document/pod(s) to process +,** curate - spine -v --html ~spineMarkupSamples/markup/pod/sisu-manual +<> -if configuartion has not been set or to overide the set configration specify -- the output path as well as -- the desired output and -- the markup document/pod(s) to process +,** sqlite -note: ~webDocRoot should be the path to web doc root, provide a suitable output path. +<> - spine -v --html --html-link-search --html-link-curate --output=`echo ~webDocRoot` ~spineMarkupSamples/pod/* +,*** create db - spine -v --html --html-link-search --html-link-curate --epub --output=`echo ~webDocRoot` ~spineMarkupSamples/pod/* +<> - spine -v --html --epub --latex --odt --curate --output=`echo ~webDocRoot` ~spineMarkupSamples/pod/* +,*** populate db + +<> + +,*** generate a cgi search form in d + + <> + +,**** compile the cgi search form + +<> + +,*** create db & search form + + <> + +,*** html with links to search form + + <> +#+END_SRC + +*** text body md + +#+NAME: sisu_spine_readme_examples_md +#+BEGIN_SRC markdown +# Examples ## curate +<> + +## sqlite + +<> + +### create db + +<> + +### populate db + +<> + +### generate a cgi search form in d + + <> + +#### compile the cgi search form + +<> + +### create db & search form + + <> + +### html with links to search form + + <> +#+END_SRC + +*** text body content + +#+NAME: sisu_spine_readme_examples_curate_text +#+BEGIN_SRC text if you have a document collection with documents that have metadata headers a summary of the collection can be made using the curate command @@ -292,11 +460,32 @@ summary of the collection can be made using the curate command spine -v --html --html-link-search --html-link-curate --curate --output=`echo ~webDocRoot` ~spineMarkupSamples/pod/* spine -v --html --html-link-search --html-link-curate --curate ~spineMarkupSamples/pod/* +#+END_SRC -## sqlite +#+NAME: sisu_spine_readme_examples_sqlite_text +#+BEGIN_SRC text +if configuartion has been set specify just +- the desired output and +- the markup document/pod(s) to process -### create db + spine -v --html ~spineMarkupSamples/markup/pod/sisu-manual + +if configuartion has not been set or to overide the set configration specify +- the output path as well as +- the desired output and +- the markup document/pod(s) to process +note: ~webDocRoot should be the path to web doc root, provide a suitable output path. + + spine -v --html --html-link-search --html-link-curate --output=`echo ~webDocRoot` ~spineMarkupSamples/pod/* + + spine -v --html --html-link-search --html-link-curate --epub --output=`echo ~webDocRoot` ~spineMarkupSamples/pod/* + + spine -v --html --epub --latex --odt --curate --output=`echo ~webDocRoot` ~spineMarkupSamples/pod/* +#+END_SRC + +#+NAME: sisu_spine_readme_examples_create_db_text +#+BEGIN_SRC text if there is no sqlite db you first need to create one, to do so - the name of the db and - the root path for document output @@ -313,9 +502,10 @@ if you have a configration file providing this information that is to be used for a document collection you can point to the document collection: spine -v --sqlite-db-create ~spineMarkupSamples/pod +#+END_SRC -### populate db - +#+NAME: sisu_spine_readme_examples_populate_db_text +#+BEGIN_SRC text must specify: - the name of the db and - the root path for document output @@ -331,29 +521,31 @@ if you have a configration file providing this information that is to be used for a document collection you can point to the document collection: spine -v --sqlite-update ~spineMarkupSamples/pod/* +#+END_SRC -### generate a cgi search form in d - - spine -v --cgi-search-form-codegen \ - --output=/var/www/html \ - ~spineMarkupSamples/pod +#+NAME: sisu_spine_readme_examples_search_db_cgi_text +#+BEGIN_SRC text +spine -v --cgi-search-form-codegen \ + --output=/var/www/html \ + ~spineMarkupSamples/pod - spine -v --cgi-search-form-codegen --config=~spineMarkupSamples/pod +spine -v --cgi-search-form-codegen --config=~spineMarkupSamples/pod - spine -v --cgi-search-form-codegen --config=~spineMarkupSamples/pod/.dr/config_local_site +spine -v --cgi-search-form-codegen --config=~spineMarkupSamples/pod/.dr/config_local_site - spine --cgi-search-form-codegen --output=`echo ~webDocRoot` ~spineMarkupSamples/pod +spine --cgi-search-form-codegen --output=`echo ~webDocRoot` ~spineMarkupSamples/pod - spine --cgi-search-form-codegen --cgi-sqlite-search-filename="spine_search" --output=`echo ~webDocRoot` +spine --cgi-search-form-codegen --cgi-sqlite-search-filename="spine_search" --output=`echo ~webDocRoot` - spine -v --cgi-search-form-codegen \ - --sqlite-db-filename="spine.search.db" \ - --cgi-sqlite-search-filename="spine-search" \ - --output=/var/www/html \ - ~spineMarkupSamples/pod - -#### compile the cgi search form +spine -v --cgi-search-form-codegen \ + --sqlite-db-filename="spine.search.db" \ + --cgi-sqlite-search-filename="spine-search" \ + --output=/var/www/html \ + ~spineMarkupSamples/pod +#+END_SRC +#+NAME: sisu_spine_readme_examples_compile_search_db_cgi_text +#+BEGIN_SRC text cd /var/www/html/cgi # /var/www/html (default document root) cd ~webDocRoot/cgi @@ -376,49 +568,23 @@ cgi-bin directory spine -v --html --html-link-search --output=`echo ~webDocRoot` ~spineMarkupSamples/pod/* spine -v --html --html-link-search --cgi-sqlite-search-filename="spine-search" --html-link-curate --curate --output=`echo ~webDocRoot` ~spineMarkupSamples/pod/* - -### create db & search form - - spine -v \ - --sqlite-db-create --sqlite-db-filename="spine.search.db" \ - --cgi-search-form-codegen --cgi-sqlite-search-filename="spine-search" \ - --output=/var/www/html \ - ~spineMarkupSamples/pod/* - -### html with links to search form - - spine -v --html \ - --html-link-search \ - --output=`echo ~webDocRoot` \ - ~spineMarkupSamples/pod/* - #+END_SRC -* +README+ - -#+HEADER: :NO-tangle "../README" -#+BEGIN_SRC txt -project_name: Spine, Doc Reform - description: [ - "documents, structuring, processing, publishing", - search, - object numbering, - static content generator, - sisu markup - ] - - author: - name: Ralph Amissah - email: ralph.amissah@gmail.com - - copyright: "(C) 2015 - 2021 Ralph Amissah, All Rights Reserved." - - license: "AGPL 3 or later" +#+NAME: sisu_spine_readme_examples_create_db_and_search_form_text +#+BEGIN_SRC text +spine -v \ + --sqlite-db-create --sqlite-db-filename="spine.search.db" \ + --cgi-search-form-codegen --cgi-sqlite-search-filename="spine-search" \ + --output=/var/www/html \ + ~spineMarkupSamples/pod/* +#+END_SRC - homepage: [ - "https://www.doc_reform.org", - "https://www.sisudoc.org" - ] +#+NAME: sisu_spine_readme_examples_html_with_links_to_search_form_text +#+BEGIN_SRC text +spine -v --html \ + --html-link-search \ + --output=`echo ~webDocRoot` \ + ~spineMarkupSamples/pod/* #+END_SRC * manpage :manpage: @@ -4550,10 +4716,15 @@ matches are found. #+HEADER: :tangle "../COPYRIGHT" #+BEGIN_SRC txt -<> -<> -<> +- Name: spine - SiSU Spine, Doc Reform + <> + + <> + + <> + <> + <> #+END_SRC @@ -4561,10 +4732,15 @@ matches are found. #+HEADER: :tangle "../src/COPYRIGHT" #+BEGIN_SRC txt -<> -<> -<> +- Name: spine - SiSU Spine, Doc Reform + <> + + <> + + <> + <> + <> #+END_SRC @@ -4572,10 +4748,15 @@ matches are found. #+HEADER: :tangle "../src/doc_reform/COPYRIGHT" #+BEGIN_SRC txt -<> -<> -<> +- Name: spine - SiSU Spine, Doc Reform + <> + + <> + + <> + <> + <> #+END_SRC @@ -4589,8 +4770,11 @@ matches are found. #+HEADER: :tangle "./COPYRIGHT" #+BEGIN_SRC txt -<> -<> +- Name: spine - SiSU Spine, Doc Reform + <> + + <> + <> #+END_SRC @@ -4606,15 +4790,13 @@ matches are found. #+NAME: sisu_spine_copyright #+BEGIN_SRC txt -- Name: spine - SiSU Spine, Doc Reform - - Description: documents, structuring, processing, publishing, search - - static content generator +- Description: documents, structuring, processing, publishing, search + - static content generator - - Author: Ralph Amissah - [ralph.amissah@gmail.com] - - - Copyright: (C) 2015 - 2021 Ralph Amissah +- Author: Ralph Amissah + [ralph.amissah@gmail.com] +- Copyright: (C) 2015 - 2021 Ralph Amissah #+END_SRC *** license @@ -4622,48 +4804,46 @@ matches are found. #+NAME: sisu_spine_license_agpl3 #+BEGIN_SRC txt - - code under src/* src/doc_reform/* - - License: AGPL 3 or later: - - Spine, Doc Reform (SiSU), a framework for document structuring, publishing and - search +- code under src/* src/doc_reform/* + - License: AGPL 3 or later: - Copyright (C) Ralph Amissah + Spine, Doc Reform (SiSU), a framework for document structuring, publishing and + search - This program is free software: you can redistribute it and/or modify it - under the terms of the GNU AFERO General Public License as published by - the Free Software Foundation, either version 3 of the License, or (at your - option) any later version. + Copyright (C) Ralph Amissah - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU AFERO General Public License as published by + the Free Software Foundation, either version 3 of the License, or (at your + option) any later version. - You should have received a copy of the GNU General Public License along - with this program. If not, see [https://www.gnu.org/licenses/]. + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. - If you have Internet connection, the latest version of the AGPL should be - available at these locations: - [https://www.fsf.org/licensing/licenses/agpl.html] - [https://www.gnu.org/licenses/agpl.html] + You should have received a copy of the GNU General Public License along + with this program. If not, see [https://www.gnu.org/licenses/]. + If you have Internet connection, the latest version of the AGPL should be + available at these locations: + [https://www.fsf.org/licensing/licenses/agpl.html] + [https://www.gnu.org/licenses/agpl.html] #+END_SRC *** spine_summary #+NAME: sisu_spine_summary #+BEGIN_SRC txt - - Spine, Doc Reform (related to SiSU) uses standard: - - docReform markup syntax (based on SiSU markup) - - standard SiSU markup syntax with modified headers and minor - modifications - - docReform object numbering (based on SiSU object citation numbering) - - standard SiSU document object numbering - - - Homepages: - [https://www.sisudoc.org] - +- Spine, Doc Reform (related to SiSU) uses standard: + - docReform markup syntax (based on SiSU markup) + - standard SiSU markup syntax with modified headers and minor + modifications + - docReform object numbering (based on SiSU object citation numbering) + - standard SiSU document object numbering + +- Homepages: + [https://www.sisudoc.org] #+END_SRC #+BEGIN_SRC txt @@ -4682,7 +4862,6 @@ matches are found. - Spine, Doc Reform (SiSU) markup samples Individual document content Copyright (Author) [as stated in document header] Individual document content License (Author) [as stated in document header] - #+END_SRC *** dependencies @@ -4710,6 +4889,9 @@ matches are found. [https://github.com/dlang-community/d2sqlite3] [https://code.dlang.org/packages/d2sqlite3] + - src/ext_depends/d2sqlite3 + - sundry/spine_search_cgi/src/ext_depends_cgi/d2sqlite3 + - Name: dyaml - Description: D:YAML is an open source YAML parser and emitter library for the D programming language. @@ -4728,6 +4910,8 @@ matches are found. [https://github.com/dlang-community/D-YAML] [https://code.dlang.org/packages/dyaml] + - src/ext_depends/D-YAML + - Name: imageformats - Description: @@ -4745,6 +4929,8 @@ matches are found. [https://github.com/lgvz/imageformats] [https://code.dlang.org/packages/imageformats] + - src/ext_depends/imageformats + - Name: tinyendian (dyaml dependency) - Description: TinyEndian is a minimal endianness library for the D programming language. @@ -4763,6 +4949,8 @@ matches are found. [https://github.com/dlang-community/tinyendian] [https://code.dlang.org/packages/tinyendian] + - src/ext_depends/tinyendian + - Name: cgi.d - Description: @@ -4771,7 +4959,7 @@ matches are found. - Copyright: (C) 2008 - 2021 Adam D. Ruppe - - code: cgi.d (copy in ./sundry/spine_search_cgi/src/ext_depends_cgi/arsd) + - code: cgi.d aria2c https://raw.githubusercontent.com/adamdruppe/arsd/master/cgi.d - License: BSL-1.0 @@ -4782,6 +4970,7 @@ matches are found. - Homepages: [https://github.com/adamdruppe/arsd] + - sundry/spine_search_cgi/src/ext_depends_cgi/arsd - Name: dub2nix - Description: @@ -4796,7 +4985,6 @@ matches are found. - Homepages: [https://github.com/lionello/dub2nix] - #+END_SRC * CHANGELOG :changelog: diff --git a/org/util_cgi_d_sqlite_search.org b/org/util_cgi_d_sqlite_search.org index 84d1b1e..88efe5b 100644 --- a/org/util_cgi_d_sqlite_search.org +++ b/org/util_cgi_d_sqlite_search.org @@ -35,26 +35,26 @@ void cgi_function_intro(Cgi cgi) { <> <> <> - <> - <> - <> - <> + <> + <> + <> + <> <> <> <> <> <> -<> -<> + <> + <> <> <> -<> -<> + <> + <> <> <> <> <> -<> + <> <> <> } @@ -231,79 +231,79 @@ auto text_fields() { #+NAME: cgi_sqlite_initialize_4 #+BEGIN_SRC d - 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"); - } +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"); +} #+END_SRC ***** searchfields #+NAME: cgi_sqlite_initialize_5 #+BEGIN_SRC d - 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(); +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(); #+END_SRC ***** env @@ -311,264 +311,264 @@ auto text_fields() { #+NAME: cgi_sqlite_initialize_6 #+BEGIN_SRC d - 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)) { +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"]; - } 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 (auto m = got.search_text_area.matchFirst(rgx.author)) { + got.author = m["matched"]; + got.canned_query ~= "&au=" ~ m["matched"]; } - if ("rt" in cgi.post) { - got.results_type = cgi.post["rt"]; - got.canned_query ~= "&rt=" ~ cgi.post["rt"]; + if (auto m = got.search_text_area.matchFirst(rgx.title)) { + got.title = m["matched"]; + got.canned_query ~= "&ti=" ~ m["matched"]; } - if ("sts" in cgi.post) { - got.stats = cgi.post["sts"]; - got.canned_query ~= "&sts=" ~ cgi.post["sts"]; + if (auto m = got.search_text_area.matchFirst(rgx.uid)) { + got.uid = m["matched"]; + got.canned_query ~= "&uid=" ~ m["matched"]; } - if ("ec" in cgi.post) { - got.echo = cgi.post["ec"]; - got.canned_query ~= "&ec=" ~ cgi.post["ec"]; + if (auto m = got.search_text_area.matchFirst(rgx.fn)) { + got.fn = m["matched"]; + got.canned_query ~= "&fn=" ~ m["matched"]; } - if ("url" in cgi.post) { - got.url = cgi.post["url"]; - got.canned_query ~= "&url=" ~ cgi.post["url"]; + if (auto m = got.search_text_area.matchFirst(rgx.keywords)) { + got.keywords = m["matched"]; + got.canned_query ~= "&kw=" ~ m["matched"]; } - if ("se" in cgi.post) { - got.searched = cgi.post["se"]; - got.canned_query ~= "&se=" ~ cgi.post["se"]; + if (auto m = got.search_text_area.matchFirst(rgx.topic_register)) { + got.topic_register = m["matched"]; + got.canned_query ~= "&tr=" ~ m["matched"]; } - if ("sql" in cgi.post) { - got.sql = cgi.post["sql"]; - got.canned_query ~= "&sql=" ~ cgi.post["sql"]; + if (auto m = got.search_text_area.matchFirst(rgx.subject)) { + got.subject = m["matched"]; + got.canned_query ~= "&su=" ~ m["matched"]; } - if ("sml" in cgi.post) { - got.sql_match_limit = cgi.post["sml"]; - got.canned_query ~= "&sml=" ~ cgi.post["sml"]; + if (auto m = got.search_text_area.matchFirst(rgx.description)) { + got.description = m["matched"]; + got.canned_query ~= "&de=" ~ m["matched"]; } - if ("smo" in cgi.post) { - got.sql_match_offset = "0"; // cgi.post["smo"]; - got.canned_query ~= "&smo=0"; // ~ cgi.post["smo"]; + if (auto m = got.search_text_area.matchFirst(rgx.publisher)) { + got.publisher = m["matched"]; + got.canned_query ~= "&pb=" ~ m["matched"]; } - got.canned_query = got.canned_query.strip.split(" ").join("%20"); - conf.query_string = got.canned_query; - // cgi.write("f.canned_query: " ~ got.canned_query ~ "
"); -#+END_SRC - -****** GET - -#+NAME: cgi_sqlite_initialize_7 -#+BEGIN_SRC d - } 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 (auto m = got.search_text_area.matchFirst(rgx.editor)) { + got.editor = m["matched"]; + got.canned_query ~= "&ed=" ~ m["matched"]; } - 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 (auto m = got.search_text_area.matchFirst(rgx.contributor)) { + got.contributor = m["matched"]; + got.canned_query ~= "&ct=" ~ m["matched"]; } - 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 (auto m = got.search_text_area.matchFirst(rgx.date)) { + got.date = m["matched"]; + got.canned_query ~= "&dt=" ~ m["matched"]; } - 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 (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 ("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 (auto m = got.search_text_area.matchFirst(rgx.identifier)) { + got.identifier = m["matched"]; + got.canned_query ~= "&id=" ~ m["matched"]; } - 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 (auto m = got.search_text_area.matchFirst(rgx.source)) { + got.source = m["matched"]; + got.canned_query ~= "&src=" ~ m["matched"]; } - 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 (auto m = got.search_text_area.matchFirst(rgx.language)) { + got.language = m["matched"]; + got.canned_query ~= "&lng=" ~ m["matched"]; } - 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 (auto m = got.search_text_area.matchFirst(rgx.relation)) { + got.relation = m["matched"]; + got.canned_query ~= "&rl=" ~ m["matched"]; } - 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 (auto m = got.search_text_area.matchFirst(rgx.coverage)) { + got.coverage = m["matched"]; + got.canned_query ~= "&cv=" ~ m["matched"]; } - 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 (auto m = got.search_text_area.matchFirst(rgx.rights)) { + got.rights = m["matched"]; + got.canned_query ~= "&rgt=" ~ m["matched"]; } - 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 (auto m = got.search_text_area.matchFirst(rgx.comment)) { + got.comment = m["matched"]; + got.canned_query ~= "&cmt=" ~ m["matched"]; } - // if ("abstract" in canned_query && !(canned_query["abstract"]).empty) { - // got.abstract = canned_query["abstract"]; + // if (auto m = search_text_area.matchFirst(rgx.abstract)) { + // got.abstract = m["matched"]; // } - 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 (auto m = got.search_text_area.matchFirst(rgx.src_filename_base)) { + got.src_filename_base = m["matched"]; + got.canned_query ~= "&bfn=" ~ m["matched"]; } - 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; + 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 ~ "
"); +#+END_SRC + +****** GET + +#+NAME: cgi_sqlite_initialize_7 +#+BEGIN_SRC d +} 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; #+END_SRC ***** tail @@ -738,24 +738,24 @@ string previous_next () { #+BEGIN_SRC d { table = format(q"┃ - - - -
- - -
-
- SiSU - -
- git - -
-
- + + + +
+ +
+
+ SiSU + +
+ git +
- ┃"); +
+ +
+┃"); } #+END_SRC @@ -763,81 +763,81 @@ string previous_next () { #+NAME: cgi_sqlite_form_0 #+BEGIN_SRC d - { - 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 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; + } #+END_SRC **** canned search #+NAME: cgi_sqlite_form_1 #+BEGIN_SRC d - 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 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; +} #+END_SRC **** provide tip @@ -926,65 +926,65 @@ string previous_next () { #+NAME: cgi_sqlite_form_4 #+BEGIN_SRC d - "spine-search", - (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"), - ); + "spine-search", + (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"), +); #+END_SRC **** set value (debug) #+NAME: cgi_sqlite_form_5 #+BEGIN_SRC d - { - 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", "test"); // remove test - 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; + { + 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", "test"); // remove test + 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; } +} #+END_SRC *** cgi write @@ -1122,68 +1122,66 @@ LIMIT %s OFFSET %s #+NAME: cgi_sqlite_select_statement_2 #+BEGIN_SRC d - (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"); + (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 + ~ ", " + ); } } - sql_search_query; + cgi.write( previous_next); + } else { // offset_not_beyond_limit = false; + cgi.write("select_query_results empty

\n"); } +} #+END_SRC ****** text found @@ -1192,6 +1190,8 @@ LIMIT %s OFFSET %s #+NAME: cgi_sqlite_db_close #+BEGIN_SRC d + sql_search_query; +} { db.close; } diff --git a/org/util_cgi_rb_fcgi_sqlite_search.org b/org/util_cgi_rb_fcgi_sqlite_search.org index a11c9dc..7cb16f1 100644 --- a/org/util_cgi_rb_fcgi_sqlite_search.org +++ b/org/util_cgi_rb_fcgi_sqlite_search.org @@ -32,12 +32,36 @@ document home currently at /var/www/html (better placed at /var/www or srv/proje #+END_SRC *** sqlite cgi search TODO -**** head +**** tangle -#+HEADER: :tangle "../sundry/util/rb/cgi/spine.search.cgi" +#+HEADER: :tangle "../sundry/misc/util/rb/cgi/spine.search.cgi" #+HEADER: :tangle-mode (identity #o755) #+HEADER: :shebang #!/usr/bin/env ruby #+BEGIN_SRC ruby +<> +<> +<> + <> +end +<> + <> +end +<> +<> + <> +<> +<> +<> + <> + <> + <> +<> +#+END_SRC + +**** head + +#+NAME: license +#+BEGIN_SRC ruby =begin * Name: SiSU information Structuring Universe * Author: Ralph Amissah @@ -95,7 +119,7 @@ document home currently at /var/www/html (better placed at /var/www or srv/proje **** initialize -#+HEADER: :tangle "../sundry/util/rb/cgi/spine.search.cgi" +#+NAME: cgi_init #+BEGIN_SRC ruby begin require 'cgi' @@ -122,7 +146,7 @@ end **** form ***** initialize form -#+HEADER: :tangle "../sundry/util/rb/cgi/spine.search.cgi" +#+NAME: form_init #+BEGIN_SRC ruby class Form def initialize(base,search_field,selected_db,result_type,checked_sql_limit,checked_tip,checked_stats,checked_searched,checked_url,checked_case,checked_echo,checked_sql,checked_all,checked_none,checked_selected,checked_default,search_note,the_can='') @@ -139,93 +163,92 @@ class Form ***** submission form -#+HEADER: :tangle "../sundry/util/rb/cgi/spine.search.cgi" +#+NAME: form_submission #+BEGIN_SRC ruby - def submission_form - search_form =<<-WOK - - - - - <meta charset="utf-8"> - <meta name="sourcefile" content="SiSU._sst" /> - SiSU search form (sample): SiSU information Structuring Universe - - - - - - - -
- - -
-
- SiSU - -
- git - -
+def submission_form + search_form =<<-WOK + + + + + <meta charset="utf-8"> + <meta name="sourcefile" content="SiSU._sst" /> + SiSU search form (sample): SiSU information Structuring Universe + + + + + + + + + +
+ + +
+
+ SiSU + +
+ git + +
+
+ +
+
+ + -
+ - + + #{@tip} + #{@search_note} + #{@the_can} +
+
+ + + + 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 +
+ checks: + default + selected + all + none +
- - - -
- - - #{@tip} - #{@search_note} - #{@the_can} -
-

- - - - 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 -
- checks: - default - selected - all - none -
-
- - WOK - end + + WOK end #+END_SRC **** search request ***** initialize request -#+HEADER: :tangle "../sundry/util/rb/cgi/spine.search.cgi" +#+NAME: form_search_request_init #+BEGIN_SRC ruby class SearchRequest #% search_for attr_accessor :text1,:fulltext,:keywords,:title,:author,:topic_register,:subject,:description,:publisher,:editor,:contributor,:date,:type,:format,:identifier,:source,:language,:relation,:coverage,:rights,:comment,:abstract,:owner,:date_created,:date_issued,:date_modified,:date_available,:date_valid,:src_filename_base @@ -301,33 +324,32 @@ class SearchRequest #% sea ***** text to match -#+HEADER: :tangle "../sundry/util/rb/cgi/spine.search.cgi" +#+NAME: form_match_text #+BEGIN_SRC ruby - def text_to_match(identifier='') - m={ - string: /#{identifier}\s*(.+?)/, - string: /#{identifier}\s*(.+?)(?:;|\n|\r|$)/, - word: /#{identifier}[\s(]*(\S+)/ - } - search_string=if @search_field =~m[:word] - search_string=if @search_field =~m[:braces] then m[:braces].match(@search_field)[1] - elsif @search_field =~m[:string] then m[:string].match(@search_field)[1] - else - str=m[:word].match(@search_field)[1] - str=str.gsub(/[()]/,'') - str - end - search_string=search_string.strip.gsub(/\s+/,'+') - #else - # "__" +def text_to_match(identifier='') + m={ + string: /#{identifier}\s*(.+?)/, + string: /#{identifier}\s*(.+?)(?:;|\n|\r|$)/, + word: /#{identifier}[\s(]*(\S+)/ + } + search_string=if @search_field =~m[:word] + search_string=if @search_field =~m[:braces] then m[:braces].match(@search_field)[1] + elsif @search_field =~m[:string] then m[:string].match(@search_field)[1] + else + str=m[:word].match(@search_field)[1] + str=str.gsub(/[()]/,'') + str end + search_string=search_string.strip.gsub(/\s+/,'+') + #else + # "__" end end #+END_SRC **** search string -#+HEADER: :tangle "../sundry/util/rb/cgi/spine.search.cgi" +#+NAME: form_search_string #+BEGIN_SRC ruby class DBI_SearchString def initialize(l,t,q,cse=false) @@ -356,7 +378,7 @@ end **** search statement ***** init -#+HEADER: :tangle "../sundry/util/rb/cgi/spine.search.cgi" +#+NAME: form_search_statement #+BEGIN_SRC ruby class DBI_SearchStatement attr_reader :text_search_flag,:sql_select_body_format,:sql_offset,:sql_limit @@ -464,95 +486,95 @@ class DBI_SearchStatement ***** misc -#+HEADER: :tangle "../sundry/util/rb/cgi/spine.search.cgi" +#+NAME: form_misc #+BEGIN_SRC ruby - def sql_offset - @@offset +def sql_offset + @@offset +end +def sql_match_limit + @@limit +end +def sql_canned_search + @offset_next=sql_offset.to_i + sql_match_limit.to_i + @offset_previous=sql_offset.to_i - sql_match_limit.to_i + def current + @@canned_search_url.to_s + '<d=' + sql_match_limit.to_s + '&off=' + sql_offset.to_s end - def sql_match_limit - @@limit + def next + @@canned_search_url.to_s + '<d=' + sql_match_limit.to_s + '&off=' + @offset_next.to_s end - def sql_canned_search - @offset_next=sql_offset.to_i + sql_match_limit.to_i - @offset_previous=sql_offset.to_i - sql_match_limit.to_i - def current - @@canned_search_url.to_s + '<d=' + sql_match_limit.to_s + '&off=' + sql_offset.to_s - end - def next - @@canned_search_url.to_s + '<d=' + sql_match_limit.to_s + '&off=' + @offset_next.to_s - end - def previous - @offset_previous >= 0 \ - ? (@@canned_search_url.to_s + '<d=' + sql_match_limit.to_s + '&off=' + @offset_previous.to_s) - : '' - end - def start - @@canned_search_url.to_s + '<d=' + sql_match_limit.to_s + '&off=' + 0.to_s - end - self + def previous + @offset_previous >= 0 \ + ? (@@canned_search_url.to_s + '<d=' + sql_match_limit.to_s + '&off=' + @offset_previous.to_s) + : '' end - def pre_next(beyond_limit,img) - can=sql_canned_search - page=(sql_offset.to_i + sql_match_limit.to_i)/sql_match_limit.to_i - if beyond_limit - if page.to_s =~ /^1$/ - %{
- pg. #{page.to_s} - -  >> - -
} - elsif page.to_s =~ /^2$/ - %{
- - <<  - - pg. #{page.to_s} - -  >> - -
} - else - %{
- - |<  - - - <<  - - pg. #{page.to_s} - -  >> - -
} - end + def start + @@canned_search_url.to_s + '<d=' + sql_match_limit.to_s + '&off=' + 0.to_s + end + self +end +def pre_next(beyond_limit,img) + can=sql_canned_search + page=(sql_offset.to_i + sql_match_limit.to_i)/sql_match_limit.to_i + if beyond_limit + if page.to_s =~ /^1$/ + %{
+ pg. #{page.to_s} + +  >> + +
} + elsif page.to_s =~ /^2$/ + %{
+ + <<  + + pg. #{page.to_s} + +  >> + +
} else - if page.to_s =~ /^1$/ then '' - elsif page.to_s =~ /^2$/ - %{
- - <<  - - pg. #{page.to_s} -
} - else - %{
- - |<  - - - <<  - - pg. #{page.to_s} -
} - end + %{
+ + |<  + + + <<  + + pg. #{page.to_s} + +  >> + +
} + end + else + if page.to_s =~ /^1$/ then '' + elsif page.to_s =~ /^2$/ + %{
+ + <<  + + pg. #{page.to_s} +
} + else + %{
+ + |<  + + + <<  + + pg. #{page.to_s} +
} end end +end #+END_SRC ***** select statement -#+HEADER: :tangle "../sundry/util/rb/cgi/spine.search.cgi" +#+NAME: form_select_statement #+BEGIN_SRC ruby def sql_select_body limit ||= @@limit @@ -578,7 +600,7 @@ end **** tail -#+HEADER: :tangle "../sundry/util/rb/cgi/spine.search.cgi" +#+NAME: form_tail #+BEGIN_SRC ruby def tail <<-'WOK' @@ -683,7 +705,7 @@ end **** fcgi each ***** init & start loop -#+HEADER: :tangle "../sundry/util/rb/cgi/spine.search.cgi" +#+NAME: form_loop #+BEGIN_SRC ruby @tail=tail @counter_txt_doc,@counter_txt_ocn,@counter_endn_doc,@counter_endn_ocn=0,0,0,0 @@ -759,302 +781,302 @@ FCGI.each_cgi do |cgi| ***** canned search -#+HEADER: :tangle "../sundry/util/rb/cgi/spine.search.cgi" +#+NAME: form_search_canned #+BEGIN_SRC ruby - #Canned_search.new(@base,@search_for.text1,cgi) - if @search_for.text1=~/\S+/ or @search_for.fulltext=~/\S+/ or @search_for.author=~/\S+/ or @search_for.topic_register=~/\S+/ #and search_field =~/\S/ - s1 = 's1=' + CGI.escape(@search_for.text1) if @search_for.text1 =~ /\S/ - ft = '&ft=' + CGI.escape(@search_for.fulltext) if @search_for.fulltext =~ /\S/ - key = 'key=' + CGI.escape(@search_for.keywords) if @search_for.keywords =~ /\S/ - ti = '&ti=' + CGI.escape(@search_for.title) if @search_for.title =~ /\S/ - au = '&au=' + CGI.escape(@search_for.author) if @search_for.author =~ /\S/ - tr = '&tr=' + CGI.escape(@search_for.topic_register) if @search_for.topic_register =~ /\S/ - sj = '&sj=' + CGI.escape(@search_for.subject) if @search_for.subject =~ /\S/ - dsc = '&dsc=' + CGI.escape(@search_for.description) if @search_for.description =~ /\S/ - pb = '&pb=' + CGI.escape(@search_for.publisher) if @search_for.publisher =~ /\S/ - edt = '&edt=' + CGI.escape(@search_for.editor) if @search_for.editor =~ /\S/ - cntr = '&cntr=' + CGI.escape(@search_for.contributor) if @search_for.contributor =~ /\S/ - dt = '&dt=' + CGI.escape(@search_for.date) if @search_for.date =~ /\S/ - ty = '&ty=' + CGI.escape(@search_for.type) if @search_for.type =~ /\S/ - id = '&id=' + CGI.escape(@search_for.identifier) if @search_for.identifier =~ /\S/ - src = '&src=' + CGI.escape(@search_for.source) if @search_for.source =~ /\S/ - lang = '&lang=' + CGI.escape(@search_for.language) if @search_for.language =~ /\S/ - rel = '&rel=' + CGI.escape(@search_for.relation) if @search_for.relation =~ /\S/ - cov = '&cov=' + CGI.escape(@search_for.coverage) if @search_for.coverage =~ /\S/ - cr = '&cr=' + CGI.escape(@search_for.rights) if @search_for.rights =~ /\S/ - co = '&co=' + CGI.escape(@search_for.comment) if @search_for.comment =~ /\S/ - ab = '&ab=' + CGI.escape(@search_for.abstract) if @search_for.abstract =~ /\S/ - dtc = '&dtc=' + CGI.escape(@search_for.date_created) if @search_for.date_created =~ /\S/ - dti = '&dti=' + CGI.escape(@search_for.date_issued) if @search_for.date_issued =~ /\S/ - dtm = '&dtm=' + CGI.escape(@search_for.date_modified) if @search_for.date_modified =~ /\S/ - dta = '&dta=' + CGI.escape(@search_for.date_available) if @search_for.date_available =~ /\S/ - dtv = '&dtv=' + CGI.escape(@search_for.date_valid) if @search_for.date_valid =~ /\S/ - fns = '&fns=' + CGI.escape(@search_for.src_filename_base) if @search_for.src_filename_base =~ /\S/ - @@canned_search_url=(checked_all =~/checked/) \ - ? "#{@base}?#{s1}#{ft}#{key}#{ti}#{au}#{tr}#{sj}#{dsc}#{pb}#{edt}#{cntr}#{dt}#{ty}#{id}#{src}#{lang}#{rel}#{cov}#{cr}#{co}#{ab}#{dtc}#{dti}#{dtm}#{dta}#{dtv}#{fns}&db=#{cgi['db']}&view=#{cgi['view']}&a=1" - : "#{@base}?#{s1}#{ft}#{key}#{ti}#{au}#{tr}#{sj}#{dsc}#{pb}#{edt}#{cntr}#{dt}#{ty}#{id}#{src}#{lang}#{rel}#{cov}#{cr}#{co}#{ab}#{dtc}#{dti}#{dtm}#{dta}#{dtv}#{fns}&db=#{cgi['db']}&view=#{cgi['view']}" - mod=ft=~/\S+/ ? (ft.gsub(/ft/,'s1')) : s1 - @canned_base_url="#{@base}?#{mod}&db=#{cgi['db']}" - if checked_case=~/\S/ - @search[:text][1]=%{doc_objects.clean~'#{@search_for.text1}'} #s1 - else - @search[:text][1]=%{doc_objects.clean~*'#{@search_for.text1}'} #s1 - end - canned_note='search url:' - else - @@canned_search_url="#{@base}?db=#{@db}&view=index" - canned_note='search url example:' - end - if search_field =~/\S+/ - analyze_format=search_field.gsub(/\s*\n/,'; ') - elsif checked_all =~/checked/ or checked_url =~/checked/ - canned_search=@@canned_search_url.scan(/(?:s1|ft|au|ti|fns|tr)=[^&]+/) - af=canned_search.join('; ') - af=af.gsub(/s1=/,'text: '). - gsub(/ft=/,'fulltxt: '). - gsub(/au=/,'author: '). - gsub(/ti=/,'title: '). - gsub(/fns=/,'src_filename_base: '). - gsub(/tr=/,'topic_register: '). - gsub(/%2B/,' ') - analyze_format=af - st=af.split(/\s*;\s*/) - search_field=st.join("\n") - end - green=%{} - canned_search_url_txt=CGI.escapeHTML(@@canned_search_url) - the_can=%{#{canned_note} #{canned_search_url_txt}
} - p_text=p_fulltext=p_keywords=p_title=p_author=p_topic_register=p_subject=p_description=p_publisher=p_editor=p_contributor=p_date=p_type=p_format=p_identifier=p_source=p_language=p_relation=p_coverage=p_rights=p_comment=p_abstract=p_filename='' - p_filename = %{src_filename_base: #{green}#{@search_for.src_filename_base}

} if @search_for.src_filename_base =~ /\S+/ - p_text = %{text: #{green}#{@search_for.text1}
} if @search_for.text1 =~ /\S+/ - p_fulltext = %{fulltxt: #{green}#{@search_for.fulltext}
} if @search_for.fulltext =~ /\S+/ - p_title = %{title: #{green}#{@search_for.title}
} if @search_for.title =~ /\S+/ - p_author = %{author: #{green}#{@search_for.author}
} if @search_for.author =~ /\S+/ - p_editor = %{editor: #{green}#{@search_for.editor}
} if @search_for.editor =~ /\S+/ - p_contributor = %{contributor: #{green}#{@search_for.contributor}
} if @search_for.contributor =~ /\S+/ - p_date = %{date: #{green}#{@search_for.date}
} if @search_for.date =~ /\S+/ - p_rights = %{rights: #{green}#{@search_for.rights}
} if @search_for.rights =~ /\S+/ - p_topic_register = %{topic_register: #{green}#{@search_for.topic_register}
} if @search_for.topic_register =~ /\S+/ - p_subject = %{subject: #{green}#{@search_for.subject}
} if @search_for.subject =~ /\S+/ - p_keywords = %{keywords: #{green}#{@search_for.keywords}
} if @search_for.keywords =~ /\S+/ - p_identifier = %{identifier: #{green}#{@search_for.identifier}
} if @search_for.identifier =~ /\S+/ - p_type = %{type: #{green}#{@search_for.type}
} if @search_for.type =~ /\S+/ - p_format = %{format: #{green}#{@search_for.format}
} if @search_for.format =~ /\S+/ - p_relation = %{relation: #{green}#{@search_for.relation}
} if @search_for.relation =~ /\S+/ - p_coverage = %{coverage: #{green}#{@search_for.coverage}
} if @search_for.coverage =~ /\S+/ - p_description = %{description: #{green}#{@search_for.description}
} if @search_for.description =~ /\S+/ - p_abstract = %{abstract: #{green}#{@search_for.abstract}
} if @search_for.abstract =~ /\S+/ - p_comment = %{comment: #{green}#{@search_for.comment}
} if @search_for.comment =~ /\S+/ - p_publisher = %{publisher: #{green}#{@search_for.publisher}
} if @search_for.publisher =~ /\S+/ - p_source = %{source: #{green}#{@search_for.source}
} if @search_for.source =~ /\S+/ - p_language = %{language: #{green}#{@search_for.language}
} if @search_for.language =~ /\S+/ - search_note=<<-WOK - - database: #{green}#{@db}; selected view: #{green}#{cgi['view']} - search string: "#{green}#{analyze_format}"
- #{p_text} #{p_fulltext} #{p_keywords} #{p_title} #{p_author} #{p_topic_register} #{p_subject} #{p_description} #{p_publisher} #{p_editor} #{p_contributor} #{p_date} #{p_type} #{p_format} #{p_identifier} #{p_source} #{p_language} #{p_relation} #{p_coverage} #{p_rights} #{p_comment} #{p_abstract} #{p_filename} - - WOK - #eg = %{canned search e.g.:
#{url}
find: #{analyze}
database: #{database}} - #% dbi_canning +#Canned_search.new(@base,@search_for.text1,cgi) +if @search_for.text1=~/\S+/ or @search_for.fulltext=~/\S+/ or @search_for.author=~/\S+/ or @search_for.topic_register=~/\S+/ #and search_field =~/\S/ + s1 = 's1=' + CGI.escape(@search_for.text1) if @search_for.text1 =~ /\S/ + ft = '&ft=' + CGI.escape(@search_for.fulltext) if @search_for.fulltext =~ /\S/ + key = 'key=' + CGI.escape(@search_for.keywords) if @search_for.keywords =~ /\S/ + ti = '&ti=' + CGI.escape(@search_for.title) if @search_for.title =~ /\S/ + au = '&au=' + CGI.escape(@search_for.author) if @search_for.author =~ /\S/ + tr = '&tr=' + CGI.escape(@search_for.topic_register) if @search_for.topic_register =~ /\S/ + sj = '&sj=' + CGI.escape(@search_for.subject) if @search_for.subject =~ /\S/ + dsc = '&dsc=' + CGI.escape(@search_for.description) if @search_for.description =~ /\S/ + pb = '&pb=' + CGI.escape(@search_for.publisher) if @search_for.publisher =~ /\S/ + edt = '&edt=' + CGI.escape(@search_for.editor) if @search_for.editor =~ /\S/ + cntr = '&cntr=' + CGI.escape(@search_for.contributor) if @search_for.contributor =~ /\S/ + dt = '&dt=' + CGI.escape(@search_for.date) if @search_for.date =~ /\S/ + ty = '&ty=' + CGI.escape(@search_for.type) if @search_for.type =~ /\S/ + id = '&id=' + CGI.escape(@search_for.identifier) if @search_for.identifier =~ /\S/ + src = '&src=' + CGI.escape(@search_for.source) if @search_for.source =~ /\S/ + lang = '&lang=' + CGI.escape(@search_for.language) if @search_for.language =~ /\S/ + rel = '&rel=' + CGI.escape(@search_for.relation) if @search_for.relation =~ /\S/ + cov = '&cov=' + CGI.escape(@search_for.coverage) if @search_for.coverage =~ /\S/ + cr = '&cr=' + CGI.escape(@search_for.rights) if @search_for.rights =~ /\S/ + co = '&co=' + CGI.escape(@search_for.comment) if @search_for.comment =~ /\S/ + ab = '&ab=' + CGI.escape(@search_for.abstract) if @search_for.abstract =~ /\S/ + dtc = '&dtc=' + CGI.escape(@search_for.date_created) if @search_for.date_created =~ /\S/ + dti = '&dti=' + CGI.escape(@search_for.date_issued) if @search_for.date_issued =~ /\S/ + dtm = '&dtm=' + CGI.escape(@search_for.date_modified) if @search_for.date_modified =~ /\S/ + dta = '&dta=' + CGI.escape(@search_for.date_available) if @search_for.date_available =~ /\S/ + dtv = '&dtv=' + CGI.escape(@search_for.date_valid) if @search_for.date_valid =~ /\S/ + fns = '&fns=' + CGI.escape(@search_for.src_filename_base) if @search_for.src_filename_base =~ /\S/ + @@canned_search_url=(checked_all =~/checked/) \ + ? "#{@base}?#{s1}#{ft}#{key}#{ti}#{au}#{tr}#{sj}#{dsc}#{pb}#{edt}#{cntr}#{dt}#{ty}#{id}#{src}#{lang}#{rel}#{cov}#{cr}#{co}#{ab}#{dtc}#{dti}#{dtm}#{dta}#{dtv}#{fns}&db=#{cgi['db']}&view=#{cgi['view']}&a=1" + : "#{@base}?#{s1}#{ft}#{key}#{ti}#{au}#{tr}#{sj}#{dsc}#{pb}#{edt}#{cntr}#{dt}#{ty}#{id}#{src}#{lang}#{rel}#{cov}#{cr}#{co}#{ab}#{dtc}#{dti}#{dtm}#{dta}#{dtv}#{fns}&db=#{cgi['db']}&view=#{cgi['view']}" + mod=ft=~/\S+/ ? (ft.gsub(/ft/,'s1')) : s1 + @canned_base_url="#{@base}?#{mod}&db=#{cgi['db']}" + if checked_case=~/\S/ + @search[:text][1]=%{doc_objects.clean~'#{@search_for.text1}'} #s1 + else + @search[:text][1]=%{doc_objects.clean~*'#{@search_for.text1}'} #s1 + end + canned_note='search url:' +else + @@canned_search_url="#{@base}?db=#{@db}&view=index" + canned_note='search url example:' +end +if search_field =~/\S+/ + analyze_format=search_field.gsub(/\s*\n/,'; ') +elsif checked_all =~/checked/ or checked_url =~/checked/ + canned_search=@@canned_search_url.scan(/(?:s1|ft|au|ti|fns|tr)=[^&]+/) + af=canned_search.join('; ') + af=af.gsub(/s1=/,'text: '). + gsub(/ft=/,'fulltxt: '). + gsub(/au=/,'author: '). + gsub(/ti=/,'title: '). + gsub(/fns=/,'src_filename_base: '). + gsub(/tr=/,'topic_register: '). + gsub(/%2B/,' ') + analyze_format=af + st=af.split(/\s*;\s*/) + search_field=st.join("\n") +end +green=%{} +canned_search_url_txt=CGI.escapeHTML(@@canned_search_url) +the_can=%{#{canned_note} #{canned_search_url_txt}
} +p_text=p_fulltext=p_keywords=p_title=p_author=p_topic_register=p_subject=p_description=p_publisher=p_editor=p_contributor=p_date=p_type=p_format=p_identifier=p_source=p_language=p_relation=p_coverage=p_rights=p_comment=p_abstract=p_filename='' +p_filename = %{src_filename_base: #{green}#{@search_for.src_filename_base}

} if @search_for.src_filename_base =~ /\S+/ +p_text = %{text: #{green}#{@search_for.text1}
} if @search_for.text1 =~ /\S+/ +p_fulltext = %{fulltxt: #{green}#{@search_for.fulltext}
} if @search_for.fulltext =~ /\S+/ +p_title = %{title: #{green}#{@search_for.title}
} if @search_for.title =~ /\S+/ +p_author = %{author: #{green}#{@search_for.author}
} if @search_for.author =~ /\S+/ +p_editor = %{editor: #{green}#{@search_for.editor}
} if @search_for.editor =~ /\S+/ +p_contributor = %{contributor: #{green}#{@search_for.contributor}
} if @search_for.contributor =~ /\S+/ +p_date = %{date: #{green}#{@search_for.date}
} if @search_for.date =~ /\S+/ +p_rights = %{rights: #{green}#{@search_for.rights}
} if @search_for.rights =~ /\S+/ +p_topic_register = %{topic_register: #{green}#{@search_for.topic_register}
} if @search_for.topic_register =~ /\S+/ +p_subject = %{subject: #{green}#{@search_for.subject}
} if @search_for.subject =~ /\S+/ +p_keywords = %{keywords: #{green}#{@search_for.keywords}
} if @search_for.keywords =~ /\S+/ +p_identifier = %{identifier: #{green}#{@search_for.identifier}
} if @search_for.identifier =~ /\S+/ +p_type = %{type: #{green}#{@search_for.type}
} if @search_for.type =~ /\S+/ +p_format = %{format: #{green}#{@search_for.format}
} if @search_for.format =~ /\S+/ +p_relation = %{relation: #{green}#{@search_for.relation}
} if @search_for.relation =~ /\S+/ +p_coverage = %{coverage: #{green}#{@search_for.coverage}
} if @search_for.coverage =~ /\S+/ +p_description = %{description: #{green}#{@search_for.description}
} if @search_for.description =~ /\S+/ +p_abstract = %{abstract: #{green}#{@search_for.abstract}
} if @search_for.abstract =~ /\S+/ +p_comment = %{comment: #{green}#{@search_for.comment}
} if @search_for.comment =~ /\S+/ +p_publisher = %{publisher: #{green}#{@search_for.publisher}
} if @search_for.publisher =~ /\S+/ +p_source = %{source: #{green}#{@search_for.source}
} if @search_for.source =~ /\S+/ +p_language = %{language: #{green}#{@search_for.language}
} if @search_for.language =~ /\S+/ +search_note=<<-WOK + + database: #{green}#{@db}; selected view: #{green}#{cgi['view']} + search string: "#{green}#{analyze_format}"
+ #{p_text} #{p_fulltext} #{p_keywords} #{p_title} #{p_author} #{p_topic_register} #{p_subject} #{p_description} #{p_publisher} #{p_editor} #{p_contributor} #{p_date} #{p_type} #{p_format} #{p_identifier} #{p_source} #{p_language} #{p_relation} #{p_coverage} #{p_rights} #{p_comment} #{p_abstract} #{p_filename} + +WOK +#eg = %{canned search e.g.:
#{url}
find: #{analyze}
database: #{database}} +#% dbi_canning #+END_SRC ***** submission form -#+HEADER: :tangle "../sundry/util/rb/cgi/spine.search.cgi" +#+NAME: form_submit #+BEGIN_SRC ruby - @header = Form.new(@base,search_field,selected_db,result_type,checked_sql_limit,checked_tip,checked_stats,checked_searched,checked_url,checked_case,checked_echo,checked_sql,checked_all,checked_none,checked_selected,checked_default,search_note,the_can).submission_form #% form - unless q['s1'] =~/\S/ or q['au'] =~/\S/ or @search[:text][1] =~/\S/ - print "Content-type: text/html\n\n" - puts (@header+@tail) - else #% searches - s1=(@search_for.text1 =~/\S/) \ - ? @search_for.text1 - : 'Unavailable' - if checked_case=~/\S/ - @search[:text]<<%{doc_objects.clean~'#{CGI.unescape(s1)}'} - else - @search[:text]<<%{doc_objects.clean~*'#{CGI.unescape(s1)}'} +@header = Form.new(@base,search_field,selected_db,result_type,checked_sql_limit,checked_tip,checked_stats,checked_searched,checked_url,checked_case,checked_echo,checked_sql,checked_all,checked_none,checked_selected,checked_default,search_note,the_can).submission_form #% form +unless q['s1'] =~/\S/ or q['au'] =~/\S/ or @search[:text][1] =~/\S/ + print "Content-type: text/html\n\n" + puts (@header+@tail) +else #% searches + s1=(@search_for.text1 =~/\S/) \ + ? @search_for.text1 + : 'Unavailable' + if checked_case=~/\S/ + @search[:text]<<%{doc_objects.clean~'#{CGI.unescape(s1)}'} + else + @search[:text]<<%{doc_objects.clean~*'#{CGI.unescape(s1)}'} + end + #% dbi_request + dbi_statement=DBI_SearchStatement.new(@conn,@search_for,q,checked_case) + @text_search_flag=false + @text_search_flag=dbi_statement.text_search_flag + s_contents=dbi_statement.contents + @body_main='' + @search_regx=nil + olduid="" + if @text_search_flag + if checked_sql =~/\S/ + sql_select_body=dbi_statement.sql_select_body_format + else sql_select_body='' end - #% dbi_request - dbi_statement=DBI_SearchStatement.new(@conn,@search_for,q,checked_case) - @text_search_flag=false - @text_search_flag=dbi_statement.text_search_flag - s_contents=dbi_statement.contents - @body_main='' - @search_regx=nil - olduid="" - if @text_search_flag - if checked_sql =~/\S/ - sql_select_body=dbi_statement.sql_select_body_format - else sql_select_body='' - end - @body_main << sql_select_body - #@body_main << '



Main Text:
' << sql_select_body + @body_main << sql_select_body + #@body_main << '



Main Text:
' << sql_select_body + else + end + @hostpath = "#{@hosturl_files}" + #@hostpath="#{@hosturl_files}/#{@stub}" + def path_manifest(fn,ln=nil) + case @output_dir_structure_by + when 'filename' + @lingual =='mono' \ + ? "#{@hostpath}/#{fn}/sisu_manifest.html" + : "#{@hostpath}/#{fn}/sisu_manifest.#{ln}.html" + when 'filetype' + @lingual =='mono' \ + ? "#{@hostpath}/manifest/#{fn}.html" + : "#{@hostpath}/manifest/#{fn}.#{ln}.html" else + "#{@hostpath}/#{ln}/manifest/#{fn}.html" end - @hostpath = "#{@hosturl_files}" - #@hostpath="#{@hosturl_files}/#{@stub}" - def path_manifest(fn,ln=nil) - case @output_dir_structure_by - when 'filename' - @lingual =='mono' \ - ? "#{@hostpath}/#{fn}/sisu_manifest.html" - : "#{@hostpath}/#{fn}/sisu_manifest.#{ln}.html" - when 'filetype' - @lingual =='mono' \ - ? "#{@hostpath}/manifest/#{fn}.html" - : "#{@hostpath}/manifest/#{fn}.#{ln}.html" - else - "#{@hostpath}/#{ln}/manifest/#{fn}.html" - end - end - def path_html_seg(fn,ln=nil) - case @output_dir_structure_by - when 'filename' - "#{@hostpath}/#{fn}" - when 'filetype' - "#{@hostpath}/html/#{fn}" - else - "#{@hostpath}/#{ln}/html/#{fn}" - end + end + def path_html_seg(fn,ln=nil) + case @output_dir_structure_by + when 'filename' + "#{@hostpath}/#{fn}" + when 'filetype' + "#{@hostpath}/html/#{fn}" + else + "#{@hostpath}/#{ln}/html/#{fn}" end - def path_toc(fn,ln=nil) - if @output_dir_structure_by =='filename' \ - or @output_dir_structure_by =='filetype' - @lingual =='mono' \ - ? "#{path_html_seg(fn,ln)}/toc.html" - : "#{path_html_seg(fn,ln)}/toc.#{ln}.html" - else - "#{path_html_seg(fn,ln)}/toc.html" - end + end + def path_toc(fn,ln=nil) + if @output_dir_structure_by =='filename' \ + or @output_dir_structure_by =='filetype' + @lingual =='mono' \ + ? "#{path_html_seg(fn,ln)}/toc.html" + : "#{path_html_seg(fn,ln)}/toc.#{ln}.html" + else + "#{path_html_seg(fn,ln)}/toc.html" end - def path_filename(fn,seg_name,ln=nil) - if @output_dir_structure_by =='filename' \ - or @output_dir_structure_by =='filetype' - @lingual =='mono' \ - ? "#{path_html_seg(fn,ln)}/#{seg_name}.html" - : "#{path_html_seg(fn,ln)}/#{seg_name}.#{ln}.html" - else - "#{path_html_seg(fn,ln)}/#{seg_name}.html" - end + end + def path_filename(fn,seg_name,ln=nil) + if @output_dir_structure_by =='filename' \ + or @output_dir_structure_by =='filetype' + @lingual =='mono' \ + ? "#{path_html_seg(fn,ln)}/#{seg_name}.html" + : "#{path_html_seg(fn,ln)}/#{seg_name}.#{ln}.html" + else + "#{path_html_seg(fn,ln)}/#{seg_name}.html" end - def path_html_doc(fn,ln=nil) - case @output_dir_structure_by - when 'filename' - @lingual =='mono' \ - ? "#{path_html_seg(fn,ln)}/scroll.html" - : "#{path_html_seg(fn,ln)}/scroll.#{ln}.html" - when 'filetype' - @lingual =='mono' \ - ? "#{@hostpath}/html/#{fn}.html" - : "#{@hostpath}/html/#{fn}.#{ln}.html" - else - "#{@hostpath}/#{ln}/html/#{fn}.html" - end + end + def path_html_doc(fn,ln=nil) + case @output_dir_structure_by + when 'filename' + @lingual =='mono' \ + ? "#{path_html_seg(fn,ln)}/scroll.html" + : "#{path_html_seg(fn,ln)}/scroll.#{ln}.html" + when 'filetype' + @lingual =='mono' \ + ? "#{@hostpath}/html/#{fn}.html" + : "#{@hostpath}/html/#{fn}.#{ln}.html" + else + "#{@hostpath}/#{ln}/html/#{fn}.html" end + end #+END_SRC ***** contents each, text body -#+HEADER: :tangle "../sundry/util/rb/cgi/spine.search.cgi" +#+NAME: form_contents_each_text #+BEGIN_SRC ruby - #% text_objects_body - s_contents.each do |c| #% text body - location=c['src_filename_base'][/(.+?)\.(?:ssm\.sst|sst)$/,1] - file_suffix=c['src_filename_base'][/.+?\.(ssm\.sst|sst)$/,1] - lang=if location =~ /\S+?~(\S\S\S?)$/ - l=location[/\S+?~(\S\S\S?)$/,1] - location=location.gsub(/(\S+?)~\S\S\S?/,'\1') - l=".#{l}" - else '' - end - #% metadata_found_body - if c['uid'] != olduid - ti=c['title'] - can_txt_srch=(cgi['view']=~/index/) \ - ? %{search } - : %{search } - title = %{ #{ti} [#{c['language_document_char']}] by #{c['creator_author']} #{can_txt_srch}
} - title=@text_search_flag \ - ? '

'+title - : '
'+title - @counter_txt_doc+=1 - olduid=c['uid'] - else title='' - end - if @text_search_flag - if cgi['view']=~/text/ \ - or (cgi['view']!~/index/ and cgi['search'] !~/search db/) #% txt body - text=if c['suffix'] !~/1/ #seg - if @search_for.text1 =~/\S+/ \ - or q['s1'] =~/\S+/ #% only this branch is working !! - unescaped_search=if @search_for.text1 =~/\S+/ - CGI.unescape(@search_for.text1) - elsif q['s1'] =~/\S+/ - CGI.unescape(q['s1']) - else nil - end - @search_regx=if unescaped_search #check - search_regex=[] - build=unescaped_search.scan(/\S+/).each do |g| - (g.to_s =~/(AND|OR)/) \ - ? (search_regex << '|') - : (search_regex << %{#{g.to_s}}) - end - search_regex=search_regex.join(' ') - search_regex=search_regex.gsub(/\s*\|\s*/,'|') - Regexp.new(search_regex, Regexp::IGNORECASE) - else nil - end - else nil - end - matched_para=(@search_regx.to_s.class==String && @search_regx.to_s=~/\S\S+/) \ - ? (c['body'].gsub(/(<\s]+#{@search_regx}[^>]+?>|#{@search_regx})/mi,%{\\1})) - : c['body'] - %{

ocn #{c['ocn']}:

#{matched_para}} - elsif c['suffix'] =~/1/ #doc - %{#{title}

ocn #{c['ocn']}:#{c['body']}} - end - @counter_txt_ocn+=1 - output=title+text - else #elsif cgi['view']=~/index/ #% idx body - if c['suffix'] !~/1/ #seg - index=%{#{c['ocn']}, } if @text_search_flag - elsif c['suffix'] =~/1/ #doc #FIX - index=%{#{c['ocn']}, } + #% text_objects_body +s_contents.each do |c| #% text body + location=c['src_filename_base'][/(.+?)\.(?:ssm\.sst|sst)$/,1] + file_suffix=c['src_filename_base'][/.+?\.(ssm\.sst|sst)$/,1] + lang=if location =~ /\S+?~(\S\S\S?)$/ + l=location[/\S+?~(\S\S\S?)$/,1] + location=location.gsub(/(\S+?)~\S\S\S?/,'\1') + l=".#{l}" + else '' + end +#% metadata_found_body + if c['uid'] != olduid + ti=c['title'] + can_txt_srch=(cgi['view']=~/index/) \ + ? %{search } + : %{search } + title = %{ #{ti} [#{c['language_document_char']}] by #{c['creator_author']} #{can_txt_srch}
} + title=@text_search_flag \ + ? '


'+title + : '
'+title + @counter_txt_doc+=1 + olduid=c['uid'] + else title='' + end + if @text_search_flag + if cgi['view']=~/text/ \ + or (cgi['view']!~/index/ and cgi['search'] !~/search db/) #% txt body + text=if c['suffix'] !~/1/ #seg + if @search_for.text1 =~/\S+/ \ + or q['s1'] =~/\S+/ #% only this branch is working !! + unescaped_search=if @search_for.text1 =~/\S+/ + CGI.unescape(@search_for.text1) + elsif q['s1'] =~/\S+/ + CGI.unescape(q['s1']) + else nil end - if c['seg_name'] =~/\S+/ - if @text_search_flag - @counter_txt_ocn+=1 - output=title+index + @search_regx=if unescaped_search #check + search_regex=[] + build=unescaped_search.scan(/\S+/).each do |g| + (g.to_s =~/(AND|OR)/) \ + ? (search_regex << '|') + : (search_regex << %{#{g.to_s}}) end - else - @counter_txt_ocn+=1 - output=c['suffix'] !~/1/ \ - ? title+index - : %{#{title}#{c['ocn'].sort}, } + search_regex=search_regex.join(' ') + search_regex=search_regex.gsub(/\s*\|\s*/,'|') + Regexp.new(search_regex, Regexp::IGNORECASE) + else nil end + else nil end - else output=title + matched_para=(@search_regx.to_s.class==String && @search_regx.to_s=~/\S\S+/) \ + ? (c['body'].gsub(/(<\s]+#{@search_regx}[^>]+?>|#{@search_regx})/mi,%{\\1})) + : c['body'] + %{

ocn #{c['ocn']}:

#{matched_para}} + elsif c['suffix'] =~/1/ #doc + %{#{title}

ocn #{c['ocn']}:#{c['body']}} end - @counters_txt=if @counter_txt_doc > 0 - if checked_stats =~/\S/ - @@lt_t=(@counter_txt_ocn==dbi_statement.sql_match_limit.to_i) ? true : false - start=(@@offset.to_i+1).to_s - range=(@@offset.to_i+@counter_txt_ocn.to_i).to_s - %{


Found #{@counter_txt_ocn} times in the main body of #{@counter_txt_doc} documents [ matches #{start} to #{range} ]
} - else '' + @counter_txt_ocn+=1 + output=title+text + else #elsif cgi['view']=~/index/ #% idx body + if c['suffix'] !~/1/ #seg + index=%{#{c['ocn']}, } if @text_search_flag + elsif c['suffix'] =~/1/ #doc #FIX + index=%{#{c['ocn']}, } + end + if c['seg_name'] =~/\S+/ + if @text_search_flag + @counter_txt_ocn+=1 + output=title+index end - else '' + else + @counter_txt_ocn+=1 + output=c['suffix'] !~/1/ \ + ? title+index + : %{#{title}#{c['ocn'].sort}, } end - @body_main << output #+ details end + else output=title + end + @counters_txt=if @counter_txt_doc > 0 + if checked_stats =~/\S/ + @@lt_t=(@counter_txt_ocn==dbi_statement.sql_match_limit.to_i) ? true : false + start=(@@offset.to_i+1).to_s + range=(@@offset.to_i+@counter_txt_ocn.to_i).to_s + %{
Found #{@counter_txt_ocn} times in the main body of #{@counter_txt_doc} documents [ matches #{start} to #{range} ]
} + else '' + end + else '' + end + @body_main << output #+ details +end #+END_SRC ***** after -#+HEADER: :tangle "../sundry/util/rb/cgi/spine.search.cgi" +#+NAME: form_contents_after #+BEGIN_SRC ruby olduid = "" offset=dbi_statement.sql_offset.to_s diff --git a/org/util_spine_markup_conversion_from_sisu.org b/org/util_spine_markup_conversion_from_sisu.org index 4b7a997..bc7fea2 100644 --- a/org/util_spine_markup_conversion_from_sisu.org +++ b/org/util_spine_markup_conversion_from_sisu.org @@ -20,14 +20,14 @@ ** README -#+HEADER: :tangle "../sundry/util/d/tools/markup_conversion/README" +#+HEADER: :tangle "../sundry/misc/util/d/tools/markup_conversion/README" #+BEGIN_SRC text #+END_SRC ** endnotes, inline from binary *** tangle -#+HEADER: :tangle "../sundry/util/d/tools/markup_conversion/endnotes_inline_from_binary.d" +#+HEADER: :tangle "../sundry/misc/util/d/tools/markup_conversion/endnotes_inline_from_binary.d" #+HEADER: :tangle-mode (identity #o755) #+HEADER: :shebang #!/usr/bin/env rdmd #+BEGIN_SRC d @@ -207,7 +207,7 @@ if (endnotes.length == endnote_ref_count) { ** conversion from sisu (sisu bespoke headers) any binary to inline notes TODO *** tangle -#+HEADER: :tangle "../sundry/util/d/tools/markup_conversion/markup_conversion_from_sisu_ruby_to_sisu_spine.d" +#+HEADER: :tangle "../sundry/misc/util/d/tools/markup_conversion/markup_conversion_from_sisu_ruby_to_sisu_spine.d" #+HEADER: :tangle-mode (identity #o755) #+HEADER: :shebang #!/usr/bin/env rdmd #+BEGIN_SRC d @@ -668,7 +668,7 @@ foreach (paragraph; paragraphs) { ** conversion from sisu and multiple headers (sisu bespoke, sdlang, toml) incomplete *** tangle -#+HEADER: :tangle "../sundry/util/d/tools/markup_conversion/markup_changes_header_and_content.d" +#+HEADER: :tangle "../sundry/misc/util/d/tools/markup_conversion/markup_changes_header_and_content.d" #+HEADER: :tangle-mode (identity #o755) #+HEADER: :shebang #!/usr/bin/env rdmd #+BEGIN_SRC d diff --git a/org/util_spine_syntax_highlighting_emacs.org b/org/util_spine_syntax_highlighting_emacs.org index bce3fe2..50ad9b5 100644 --- a/org/util_spine_syntax_highlighting_emacs.org +++ b/org/util_spine_syntax_highlighting_emacs.org @@ -20,7 +20,7 @@ ** README -#+HEADER: :tangle "../sundry/editor-syntax-etc/emacs/README" +#+HEADER: :tangle "../sundry/misc/editor-syntax-etc/emacs/README" #+BEGIN_SRC elisp ; put this into your .emacs file, then use the mode file: @@ -30,7 +30,7 @@ ** autoload sisuspine-mode-autoloads.el -#+HEADER: :tangle "../sundry/editor-syntax-etc/emacs/sisu-spine-mode-autoloads.el" +#+HEADER: :tangle "../sundry/misc/editor-syntax-etc/emacs/sisu-spine-mode-autoloads.el" #+BEGIN_SRC elisp (add-to-list 'load-path (or (file-name-directory #$) (car load-path))) (autoload 'sisu-spine-mode "sisu-spine-mode" "\ @@ -46,7 +46,7 @@ and search. ** mode sisu-spine-mode.el -#+HEADER: :tangle "../sundry/editor-syntax-etc/emacs/sisu-spine-mode.el" +#+HEADER: :tangle "../sundry/misc/editor-syntax-etc/emacs/sisu-spine-mode.el" #+BEGIN_SRC elisp ;;; sisu-spine-mode.el --- Major mode for SiSU (spine parser) markup text diff --git a/org/util_spine_syntax_highlighting_vim.org b/org/util_spine_syntax_highlighting_vim.org index b8f2c14..7ccd42b 100644 --- a/org/util_spine_syntax_highlighting_vim.org +++ b/org/util_spine_syntax_highlighting_vim.org @@ -19,7 +19,7 @@ * Vim Syntax highlighting ** filetype -#+HEADER: :tangle "../sundry/editor-syntax-etc/vim/filetype.vim" +#+HEADER: :tangle "../sundry/misc/editor-syntax-etc/vim/filetype.vim" #+BEGIN_SRC text " SiSU filetype file if exists("did_load_filetypes") @@ -33,7 +33,7 @@ augroup END ** debian vim addon manager -#+HEADER: :tangle "../sundry/editor-syntax-etc/vim/vim-sisu.yaml" +#+HEADER: :tangle "../sundry/misc/editor-syntax-etc/vim/vim-sisu.yaml" #+BEGIN_SRC text #vim-addons: debian vim-addon-manager addon: sisu @@ -47,7 +47,7 @@ files: ** color files *** def.vim -#+HEADER: :tangle "../sundry/editor-syntax-etc/vim/colors/def.vim" +#+HEADER: :tangle "../sundry/misc/editor-syntax-etc/vim/colors/def.vim" #+BEGIN_SRC text " Vim color file " Name: def @@ -276,7 +276,7 @@ endif *** slate.vim -#+HEADER: :tangle "../sundry/editor-syntax-etc/vim/colors/slate.vim" +#+HEADER: :tangle "../sundry/misc/editor-syntax-etc/vim/colors/slate.vim" #+BEGIN_SRC text "%% SiSU Vim color file " Name: Slate @@ -357,7 +357,7 @@ endif *** def-sisu.vim -#+HEADER: :tangle "../sundry/editor-syntax-etc/vim/colors/def-sisu.vim" +#+HEADER: :tangle "../sundry/misc/editor-syntax-etc/vim/colors/def-sisu.vim" #+BEGIN_SRC text " Vim color file " Name: def-sisu @@ -586,7 +586,7 @@ endif *** frugal-cterm.vim -#+HEADER: :tangle "../sundry/editor-syntax-etc/vim/colors/frugal-cterm-sisu.vim" +#+HEADER: :tangle "../sundry/misc/editor-syntax-etc/vim/colors/frugal-cterm-sisu.vim" #+BEGIN_SRC text " Vim color file " Name: frugal-cterm-sisu @@ -658,7 +658,7 @@ endif ** ftplugin sisu.vim -#+HEADER: :tangle "../sundry/editor-syntax-etc/vim/ftplugin/sisu.vim" +#+HEADER: :tangle "../sundry/misc/editor-syntax-etc/vim/ftplugin/sisu.vim" #+BEGIN_SRC text "%% SiSU Vim ftplugin " SiSU Maintainer: Ralph Amissah @@ -889,7 +889,7 @@ endif ** templates *** sst.tpl -#+HEADER: :tangle "../sundry/editor-syntax-etc/vim/templates/sst.tpl" +#+HEADER: :tangle "../sundry/misc/editor-syntax-etc/vim/templates/sst.tpl" #+BEGIN_SRC text # SiSU 8.0 @@ -925,7 +925,7 @@ make: *** ssm.tpl -#+HEADER: :tangle "../sundry/editor-syntax-etc/vim/templates/ssm.tpl" +#+HEADER: :tangle "../sundry/misc/editor-syntax-etc/vim/templates/ssm.tpl" #+BEGIN_SRC text # SiSU 8.0 master @@ -961,7 +961,7 @@ make: *** ssm.tpl -#+HEADER: :tangle "../sundry/editor-syntax-etc/vim/templates/ssi.tpl" +#+HEADER: :tangle "../sundry/misc/editor-syntax-etc/vim/templates/ssi.tpl" #+BEGIN_SRC text # SiSU 8.0 insert -- cgit v1.2.3