diff options
author | Ralph Amissah <ralph.amissah@gmail.com> | 2022-12-19 21:27:17 -0500 |
---|---|---|
committer | Ralph Amissah <ralph.amissah@gmail.com> | 2022-12-31 21:55:43 -0500 |
commit | da6f5d079e01906fb5dc558390659557a869df8f (patch) | |
tree | 35b99248cf1ba78b52474bea960f92984ff721c7 /org | |
parent | sort how you want this to be (diff) |
nix flake, things nix
Diffstat (limited to 'org')
-rw-r--r-- | org/cgi_spine_search.org | 2243 | ||||
-rw-r--r-- | org/config_d_cfte.org | 300 | ||||
-rw-r--r-- | org/config_dub.org | 286 | ||||
-rw-r--r-- | org/config_git.org | 91 | ||||
-rw-r--r-- | org/config_make.org | 748 | ||||
-rw-r--r-- | org/config_nix.org | 1262 |
6 files changed, 4930 insertions, 0 deletions
diff --git a/org/cgi_spine_search.org b/org/cgi_spine_search.org new file mode 100644 index 0000000..4e091bb --- /dev/null +++ b/org/cgi_spine_search.org @@ -0,0 +1,2243 @@ +-*- mode: org -*- +#+TITLE: spine search cgi (doc_reform) hub +#+DESCRIPTION: documents - structuring, various output representations & search +#+FILETAGS: :spine:hub: +#+AUTHOR: Ralph Amissah +#+EMAIL: [[mailto:ralph.amissah@gmail.com][ralph.amissah@gmail.com]] +#+COPYRIGHT: Copyright (C) 2015 - 2022 Ralph Amissah +#+LANGUAGE: en +#+STARTUP: content hideblocks hidestars noindent entitiespretty +#+PROPERTY: header-args :exports code +#+PROPERTY: header-args+ :noweb yes +#+PROPERTY: header-args+ :results no +#+PROPERTY: header-args+ :cache no +#+PROPERTY: header-args+ :padline no +#+PROPERTY: header-args+ :mkdirp yes +#+OPTIONS: H:3 num:nil toc:t \n:t ::t |:t ^:nil -:t f:t *:t + +- [[./doc-reform.org][doc-reform.org]] [[./][org/]] +- [[./spine_build_scaffold.org][make/build]] VERSION + +#+NAME: year +#+BEGIN_SRC text +2022 +#+END_SRC + +* 0. version.txt configuration.txt (set version & configuration) + +** program version struct + +#+NAME: spine_version_struct +#+BEGIN_SRC d +/+ obt - org-mode generated file +/ +struct Version { + int major; + int minor; + int patch; +} +#+END_SRC + +** set program version VERSION :version:set:project: + +#+NAME: spine_version_set +#+BEGIN_SRC d +enum _ver = Version(0, 12, 0); +#+END_SRC + +** compilation restrictions (supported compilers) +- set compilation restrictions + +https://dlang.org/spec/version.html#predefined-versions + +#+NAME: spine_compiler_restrictions +#+BEGIN_SRC d +version (Posix) { + version (DigitalMars) { + } else version (LDC) { + } else version (GNU) { + } else { + static assert (0, "Unsupported D compiler"); + } +} else { + static assert (0, "Unsupported D compiler"); +} +#+END_SRC + +* 1. spine search cgi :spine_search: +** notes +- provide + +** spine_search src/spine_search.d :template: + +#+HEADER: :tangle "../src/spine_search.d_" +#+HEADER: :shebang "#!/usr/bin/env rdmd" +#+HEADER: :noweb yes +#+BEGIN_SRC d +<<doc_header_including_copyright_and_license>> +/+ dub.sdl + name "spine search" + description "spine cgi search" + /+ obt - org-mode generated file +/ ++/ +<<spine_search_imports>> +void cgi_function_intro(Cgi cgi) { + mixin(import("configuration.txt")); + <<spine_search_init_1>> + <<spine_search_config_struct_init>> + <<spine_search_config_struct_set>> + <<spine_search_cgi_val>> + cv.db_selected = _cfg.db_sqlite_filename; + auto text_fields() { + string canned_query_str = environment.get("QUERY_STRING", ""); + if ("query_string" in cgi.post) { + canned_query_str = environment.get("QUERY_STRING", ""); + } + string[string] canned_query; + if (conf.request_method == "POST") { + } else if (conf.request_method == "GET") { + foreach (pair_str; canned_query_str.split("&")) { + // cgi.write(pair_str ~ "<br>"); + string[] pair = pair_str.split("="); + canned_query[pair[0]] = pair[1]; + } + // foreach (field, content; canned_query) { + // cgi.write(field ~ ": " ~ content ~ "<br>"); + // } + } + <<spine_search_rgx>> + <<spine_search_searchfields>> + <<spine_search_post>> + return got; + } + auto tf = text_fields; // + struct SQL_select { + string the_body = ""; + string the_range = ""; + } + auto sql_select = SQL_select(); + string canned_url () { + string _url = ""; + if (environment.get("REQUEST_METHOD", "POST") == "POST") { + _url = conf.query_base_url ~ tf.canned_query; + } else if (environment.get("REQUEST_METHOD", "POST") == "GET") { + _url = conf.query_base_url ~ environment.get("QUERY_STRING", ""); + } + return _url; + } + auto regex_canned_search () { + static struct RgxCS { + static track_offset = ctRegex!(`(?P<offset_key>[&]smo=)(?P<offset_val>[0-9]+)`); + static results_type = ctRegex!(`[&]rt=(?P<results_type>idx|txt)`); + static results_type_index = ctRegex!(`[&]rt=idx`); + static results_type_text = ctRegex!(`[&]rt=txt`); + static fn = ctRegex!(`[&]fn=(?P<fn>[^&]+)`); + } + return RgxCS(); + } + string show_matched_objects (string fn) { + <<spine_search_show_matched_objects>> + } + <<spine_search_init_2>> + string previous_next () { + <<spine_search_previous_next>> + } + { +<<spine_search_format_html_header>> + } + { + <<spine_search_format_html_table>> + } + { + string post_value(string field_name, string type="box", string set="on") { + <<spine_search_post_value>> + } + string the_can(string fv) { + <<spine_search_the_can>> + } + string provide_tip() { + <<spine_search_provide_tip>> + } +<<spine_search_form>> + { + string set_value(string field_name, string default_val) { + <<spine_search_set_value>> + } + bool set_bool(string field_name) { + <<spine_search_set_bool>> + } + <<spine_search_set_selections>> + } + } + { + cgi.write(header); + cgi.write(table); + cgi.write(form); + // cgi.write(previous_next); + { // debug environment + // foreach (k, d; environment.toAA) { + // cgi.write(k ~ ": " ~ d ~ "<br>"); + // } + } + { // debug cgi info: + // <<spine_search_debug_info>> + } + } + auto db = Database(conf.db_path ~ "/" ~ cv.db_selected); + { + uint sql_match_offset_counter(T)(T cv) { + sql_match_offset_count += cv.sql_match_limit.to!uint; + return sql_match_offset_count; + } + void sql_search_query() { + string highlight_text_matched(string _txt, string search_field) { + <<spine_search_query_highlight_text_matched>> + } + string select_field_like(string db_field, string search_field) { + <<spine_search_query_select_field_like>> + } + <<spine_search_query_fields>> +<<spine_search_query_format_sql_select_the_body>> + <<spine_search_cgi_writes>> +<<spine_search_cgi_write_tail>> + } + sql_search_query; + } + { + db.close; + } + { + string tail = format(q"┃ +</body> +┃"); + cgi.write(tail); + } +} +mixin GenericMain!cgi_function_intro; +#+END_SRC + +** settings spine_search.d +*** spine search parts +**** imports + +#+NAME: spine_search_imports +#+BEGIN_SRC d +import std.format; +import std.range; +import std.regex; +import arsd.cgi; +import d2sqlite3; +import std.process : environment; +#+END_SRC + +**** inits + +#+NAME: spine_search_init_1 +#+BEGIN_SRC d +string header; +string table; +string form; +#+END_SRC + +#+NAME: spine_search_init_2 +#+BEGIN_SRC d +string base; // = ""; +string tip; // = ""; +string search_note; // = ""; +uint sql_match_offset_count = 0; +#+END_SRC + +**** config struct + +see: cfte_configuation.org + +***** init config struct + +#+NAME: spine_search_config_struct_init +#+BEGIN_SRC d +struct Config { + string http_request_type; + string http_host; + // string server_name; + string doc_collection_subroot; + string cgi_script_name; + string cgi_search_form_title; + string cgi_search_form_html_title; + string data_path_html; + string http_url; + string query_base_url; + string query_string; + string request_method; + string db_path; +} +#+END_SRC + +***** SET config struct + +#+NAME: spine_search_config_struct_set +#+BEGIN_SRC d +auto conf = Config(); +conf.http_request_type = environment.get("REQUEST_SCHEME", _cfg.http_request_type); +conf.http_host = environment.get("SERVER_NAME", _cfg.http_host); +// conf.http_host = environment.get("HTTP_HOST", _cfg.http_host); +conf.doc_collection_subroot = _cfg.www_url_doc_subroot; +conf.cgi_script_name = environment.get("SCRIPT_NAME", _cfg.cgi_filename); +conf.cgi_search_form_title = _cfg.cgi_search_form_title; // ≅ SiSU spine search form +conf.cgi_search_form_html_title = "<a href=\"" + ~ conf.http_request_type ~ "://" + ~ conf.http_host + ~ "\">" + ~ _cfg.cgi_search_form_title + ~ "</a>"; +conf.query_base_url = conf.http_request_type ~ "://" ~ conf.http_host ~ conf.cgi_script_name ~ "?"; +conf.query_string = environment.get("QUERY_STRING", ""); +conf.http_url = environment.get("HTTP_REFERER", conf.query_base_url ~ conf.query_string); +conf.request_method = environment.get("REQUEST_METHOD", "POST"); +conf.db_path = _cfg.db_sqlite_path; +#+END_SRC + +**** cgi val + +#+NAME: spine_search_cgi_val +#+BEGIN_SRC d +struct CGI_val { + string db_selected = ""; + string sql_match_limit = ""; // radio: ( 1000 | 2500 ) + string sql_match_offset = ""; + string search_text = ""; + string results_type = ""; // index + bool checked_echo = false; + bool checked_stats = false; + bool checked_url = false; + bool checked_searched = false; + bool checked_tip = false; + bool checked_sql = false; +} +auto cv = CGI_val(); +#+END_SRC + +**** rgx + +#+NAME: spine_search_rgx +#+BEGIN_SRC d +static struct Rgx { + // static canned_query = ctRegex!(`\A(?P<matched>.+)\Z`, "m"); + static search_text_area = ctRegex!(`\A(?P<matched>.+)\Z`, "m"); + // static fulltext = ctRegex!(`\A(?P<matched>.+)\Z`, "m"); + static line = ctRegex!(`^(?P<matched>.+?)(?: ~|$)`, "m"); + static text = ctRegex!(`(?:^|\s~\s*)text:\s+(?P<matched>.+?)(?: ~|$)`, "m"); + static author = ctRegex!(`(?:^|\s~\s*)author:\s+(?P<matched>.+)$`, "m"); + static title = ctRegex!(`(?:^|\s~\s*)title:\s+(?P<matched>.+)$`, "m"); + static uid = ctRegex!(`(?:^|\s~\s*)uid:\s+(?P<matched>.+)$`, "m"); + static fn = ctRegex!(`(?:^|\s~\s*)fn:\s+(?P<matched>.+)$`, "m"); + static keywords = ctRegex!(`(?:^|\s~\s*)keywords:\s+(?P<matched>.+)$`, "m"); + static topic_register = ctRegex!(`(?:^|\s~\s*)topic_register:\s+(?P<matched>.+)$`, "m"); + static subject = ctRegex!(`(?:^|\s~\s*)subject:\s+(?P<matched>.+)$`, "m"); + static description = ctRegex!(`(?:^|\s~\s*)description:\s+(?P<matched>.+)$`, "m"); + static publisher = ctRegex!(`(?:^|\s~\s*)publisher:\s+(?P<matched>.+)$`, "m"); + static editor = ctRegex!(`(?:^|\s~\s*)editor:\s+(?P<matched>.+)$`, "m"); + static contributor = ctRegex!(`(?:^|\s~\s*)contributor:\s+(?P<matched>.+)$`, "m"); + static date = ctRegex!(`(?:^|\s~\s*)date:\s+(?P<matched>.+)$`, "m"); + static results_type = ctRegex!(`(?:^|\s~\s*)type:\s+(?P<matched>.+)$`, "m"); + static format = ctRegex!(`(?:^|\s~\s*)format:\s+(?P<matched>.+)$`, "m"); + static source = ctRegex!(`(?:^|\s~\s*)source:\s+(?P<matched>.+)$`, "m"); + static language = ctRegex!(`(?:^|\s~\s*)language:\s+(?P<matched>.+)$`, "m"); + static relation = ctRegex!(`(?:^|\s~\s*)relation:\s+(?P<matched>.+)$`, "m"); + static coverage = ctRegex!(`(?:^|\s~\s*)coverage:\s+(?P<matched>.+)$`, "m"); + static rights = ctRegex!(`(?:^|\s~\s*)rights:\s+(?P<matched>.+)$`, "m"); + static comment = ctRegex!(`(?:^|\s~\s*)comment:\s+(?P<matched>.+)$`, "m"); + // static abstract_ = ctRegex!(`(?:^|\s~\s*)abstract:\s+(?P<matched>.+)$`, "m"); + static src_filename_base = ctRegex!(`^src_filename_base:\s+(?P<matched>.+)$`, "m"); +} +auto rgx = Rgx(); +#+END_SRC + +**** search fields + +#+NAME: spine_search_searchfields +#+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 got = searchFields(); +#+END_SRC + +**** post + +#+NAME: spine_search_post +#+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)) { + 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 ("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 ~ "<br>"); +} else if (environment.get("REQUEST_METHOD", "POST") == "GET") { + got.canned_query = environment.get("QUERY_STRING", ""); + // cgi.write("f.canned_query: " ~ got.canned_query ~ "<br>"); + 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 ~ "<br>"); +} +#+END_SRC + +**** show_matched_objects (string fn) {} + +#+NAME: spine_search_show_matched_objects +#+BEGIN_SRC d +auto rgx = regex_canned_search; +string _matched_objects_text = ""; +string _url = canned_url; +string _url_new = ""; +string _matches_show_text = "&rt=txt"; +string _matches_show_index = "&rt=idx"; +string _fn = "&fn=" ~ fn; +_url_new = _url; +if (_url_new.match(rgx.results_type_index)) { + _url_new = _url_new.replace(rgx.results_type_index, _matches_show_text); +} else if (_url.match(rgx.results_type_text)) { + _url_new = _url_new.replace(rgx.results_type_text, _matches_show_index); +} else { + if (!(_url.match(rgx.results_type))) { + _url_new = _url ~ _matches_show_text; + } +} +if (!(_url_new.match(rgx.fn))) { + _url_new = _url_new ~ _fn; +} +_matched_objects_text = + "<font-size=\"2rem\" color=\"#666666\">" + ~ "<a href=\"" + ~ _url_new + ~ "\">" + ~ "※" + ~ "</a></font>"; +return _matched_objects_text; +#+END_SRC + +**** previous_next () {} + +#+NAME: spine_search_previous_next +#+BEGIN_SRC d +auto rgx = regex_canned_search; +string _previous_next = ""; +int _current_offset_value = 0; +string _set_offset_next = ""; +string _set_offset_previous = ""; +string _url = canned_url; +string _url_previous = ""; +string _url_next = ""; +string arrow_previous = ""; +string arrow_next = ""; +if (auto m = _url.matchFirst(rgx.track_offset)) { + _current_offset_value = m.captures["offset_val"].to!int; + _set_offset_next = m.captures["offset_key"] ~ ((m.captures["offset_val"]).to!int + cv.sql_match_limit.to!int).to!string; + _url_next = _url.replace(rgx.track_offset, _set_offset_next); + if (_current_offset_value < cv.sql_match_limit.to!int) { + _url_previous = ""; + } else { + _url_previous = ""; + _set_offset_previous = m.captures["offset_key"] ~ ((m.captures["offset_val"]).to!int - cv.sql_match_limit.to!int).to!string; + _url_previous = _url.replace(rgx.track_offset, _set_offset_previous); + } +} else { // _current_offset_value = 0; + _url_next = _url ~= "&smo=" ~ cv.sql_match_limit.to!string; +} +if (_url_previous.empty) { + arrow_previous = ""; +} else { + arrow_previous = + "<font-size=\"1.8rem\" color=\"#666666\">" + ~ "<a href=\"" + ~ _url_previous + ~ "\">" + ~ "<< prev" + ~ "</a> || </font>"; +} +arrow_next = + "<font-size=\"1.8rem\" color=\"#666666\">" + ~ "<a href=\"" + ~ _url_next + ~ "\">" + ~ "next >>" + ~ "</a></font>"; +_previous_next = "<hr>" ~ arrow_previous ~ arrow_next; +return _previous_next; +#+END_SRC + +**** format html header + +#+NAME: spine_search_format_html_header +#+HEADER: :noweb yes +#+BEGIN_SRC d + header = format(q"┃ +<!DOCTYPE html> +<html> +<head> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> + <title> + %s + </title> + <meta name="sourcefile" content="SiSU.sst"> + <link rel="generator" href="sisudoc.org"> + <link rel="shortcut icon" href="%s://%s/image_sys/spine.ico"> + <style media = "all"> + <<spine_search_css>> + </style> +</head> +<body lang="en" xml:lang="en"> +┃", + conf.cgi_search_form_title, + conf.http_request_type, + conf.http_host, + ); +#+END_SRC + +**** format html table + +#+NAME: spine_search_format_html_table +#+BEGIN_SRC d + table = format(q"┃ +<table summary="band" border="0" cellpadding="2" cellspacing="0"> +<tr><td width="20%%"> + <table summary="home button / home information" border="0" cellpadding="2" cellspacing="0"> + <tr><td align="left"> + %s + </td></tr> + </table> +</td> +<td> +</td></tr> +</table> + ┃", + conf.cgi_search_form_html_title, + ); +#+END_SRC + +**** post_value(string field_name, string type="box", string set="on") {} + +#+NAME: spine_search_post_value +#+BEGIN_SRC d +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 + +**** string the_can(string fv) {} + +#+NAME: spine_search_the_can +#+BEGIN_SRC d +string show_the_can = post_value("url"); +string _the_can = ""; +if (show_the_can == "checked") { + tf = text_fields; + string method_get_url = conf.query_base_url ~ environment.get("QUERY_STRING", ""); + string method_post_url_construct = conf.query_base_url ~ tf.canned_query; + // assert(method_get_url == environment.get("HTTP_REFERER", conf.query_base_url ~ conf.query_string)); + if (conf.request_method == "POST") { + _the_can = + "<font-size=\"1rem\" color=\"#666666\">" + ~ "POST: " + ~ "<a href=\"" + ~ method_post_url_construct + ~ "\">" + ~ method_post_url_construct + ~ "</a></font>" + ~ "<br>"; + } else if (conf.request_method == "GET") { + _the_can = + "<font-size=\"1rem\" color=\"#666666\">" + ~ "GET: " + ~ "<a href=\"" + ~ method_get_url + ~ "\">" + ~ method_get_url + ~ "</a></font>"; + } + conf.http_url = conf.http_request_type ~ "://" ~ conf.http_host ~ conf.cgi_script_name ~ tf.canned_query; +} +return _the_can; +#+END_SRC + +**** string provide_tip() {} + +#+NAME: spine_search_provide_tip +#+BEGIN_SRC d +string searched_tip = post_value("se"); +string tip = ""; +if (searched_tip == "checked") { + string search_field = post_value("sf", "field"); + tf = text_fields; + tip = format(q"┃ +<font-size="1rem" color="#666666"> +<b>database:</b> <font-size="1rem" color="#004000">%s</font>; <b>selected view:</b> <font-size="2" color="#004000">index</font> +<b>search string:</b> %s %s %s %s %s %s<br> +%s %s %s %s %s %s +</font> +┃", + cv.db_selected, + (tf.text.empty ? "" : "\"text: <font-size=\"1rem\" color=\"#004000\">" ~ tf.text ~ "</font>; "), + (tf.title.empty ? "" : "\"title: <font-size=\"1rem\" color=\"#004000\">" ~ tf.title ~ "</font>; "), + (tf.author.empty ? "" : "\"author: <font-size=\"1rem\" color=\"#004000\">" ~ tf.author ~ "</font>; "), + (tf.date.empty ? "" : "\"date <font-size=\"1rem\" color=\"#004000\">" ~ tf.date ~ "</font>; "), + (tf.uid.empty ? "" : "\"uid: <font-size=\"1rem\" color=\"#004000\">" ~ tf.uid ~ "</font>; "), + (tf.fn.empty ? "" : "\"fn: <font-size=\"1rem\" color=\"#004000\">" ~ tf.fn ~ "</font>; "), + (tf.text.empty ? "" : "text: <font-size=\"1rem\" color=\"#004000\">" ~ tf.text ~ "</font><br>"), + (tf.title.empty ? "" : "title: <font-size=\"1rem\" color=\"#004000\">" ~ tf.title ~ "</font><br>"), + (tf.author.empty ? "" : "author: <font-size=\"1rem\" color=\"#004000\">" ~ tf.author ~ "</font><br>"), + (tf.date.empty ? "" : "date: <font-size=\"1rem\" color=\"#004000\">" ~ tf.date ~ "</font><br>"), + (tf.uid.empty ? "" : "\"uid: <font-size=\"1rem\" color=\"#004000\">" ~ tf.uid ~ "</font>; "), + (tf.fn.empty ? "" : "\"fn: <font-size=\"1rem\" color=\"#004000\">" ~ tf.fn ~ "</font>; "), + ); +} +return tip; +#+END_SRC + +**** form + +#+NAME: spine_search_form +#+HEADER: :noweb yes +#+BEGIN_SRC d + form = format(q"┃ +<<spine_search_form_html>> +┃", + _cfg.cgi_filename, + (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 + +#+NAME: spine_search_form_html +#+BEGIN_SRC html +<form action="%s" id="SubmitForm" method="post" accept-charset="UTF-8"> + <table cellpadding="2"> + <tr><td valign=\"top\"> + <textarea id="find" name="sf" type="text" rows="6" cols="40" maxlength="256" wrap="virtual">%s</textarea> + </td> + <td valign=\"top\"> + %s + %s + %s + </td></tr></table> + <td valign=\"top\"><tr><td> + <font-size="1rem" color="#222222"> + <input type="hidden" name="db" value="%s"> + <input type="submit" value="※ SiSU search"> + <input type="radio" name="rt" id="results_type_index" value="idx" %s> index + <input type="radio" name="rt" id="results_type_text" value="txt" %s> text / grep; + match limit: + <input type="radio" name="sml" id="sql_match_limit_1000" value="1000" %s> 1,000 + <input type="radio" name="sml" id="sql_match_limit_2500" value="2500" %s> 2,500 + <br> + <input type="checkbox" name="ec" %s> echo query + <input type="checkbox" name="url" %s> search url + <input type="checkbox" name="se" %s> searched + <input type="checkbox" name="sql" %s> sql statement + <input type="hidden" name="smo" value="0"> + <br> + </font> + </td></tr> + </table> +</form> +#+END_SRC + +**** set_value(string field_name, string default_val) {} + +#+NAME: spine_search_set_value +#+BEGIN_SRC d +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; +#+END_SRC + +**** set_bool(string field_name) {} + +#+NAME: spine_search_set_bool +#+BEGIN_SRC d +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; +#+END_SRC + +**** set selections + +#+NAME: spine_search_set_selections +#+BEGIN_SRC d +cv.db_selected = set_value("selected_db", _cfg.db_sqlite_filename); // 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 + +**** string highlight_text_matched(string _txt, string search_field) {} + +#+NAME: spine_search_query_highlight_text_matched +#+BEGIN_SRC d +string _mark_open = "┤"; +string _mark_close = "├"; +string _span_match = "<span class=\"match\">"; +string _span_close = "</span>"; +string _sf_str = search_field.strip.split("%20").join(" ").strip; +string[] _sf_arr = _sf_str.split(regex(r"\s+AND\s+|\s+OR\s+")); +auto rgx_url = regex(r"<a href=[^>]+?>"); +foreach (_sf; _sf_arr) { + auto rgx_matched_text = regex(_sf, "i"); + auto rgx_marked_pair = regex(r"┤(?P<keep>" ~ _sf ~ ")├", "i"); + if (auto m = _txt.matchFirst(rgx_url)) { + _txt = replaceAll!(m => + _mark_open + ~ m.captures[0] + ~ _mark_close + )(_txt, rgx_matched_text); + _txt = replaceAll!(m => + replaceAll!(u => + u["keep"] + )(m.hit, rgx_marked_pair) + )(_txt, rgx_url); + _txt = replaceAll!(m => + _span_match + ~ m["keep"] + ~ _span_close + )(_txt, rgx_marked_pair); + } else { + _txt = replaceAll!(m => + _span_match + ~ m.captures[0] + ~ _span_close + )(_txt, rgx_matched_text); + } +} +return _txt; +#+END_SRC + +**** string select_field_like(string db_field, string search_field) {} + +#+NAME: spine_search_query_select_field_like +#+BEGIN_SRC d +string where_ = ""; +if (!(search_field.empty)) { + string _sf = search_field.strip.split("%20").join(" "); + if (_sf.match(r" OR ")) { + _sf = _sf.split(" OR ").join("%' OR " ~ db_field ~ " LIKE '%"); + } + if (_sf.match(r" AND ")) { + _sf = _sf.split(" AND ").join("%' AND " ~ db_field ~ " LIKE '%"); + } + _sf = "( " ~ db_field ~ " LIKE\n '%" ~ _sf ~ "%' )"; + where_ ~= format(q"┃ + %s +┃", + _sf + ); +} +return where_; +#+END_SRC + +**** query fields + +#+NAME: spine_search_query_fields +#+BEGIN_SRC d +string[] _fields; +_fields ~= select_field_like("doc_objects.clean", tf.text); +_fields ~= select_field_like("metadata_and_text.title", tf.title); +_fields ~= select_field_like("metadata_and_text.creator_author", tf.author); +_fields ~= select_field_like("metadata_and_text.uid", tf.uid); +_fields ~= select_field_like("metadata_and_text.src_filename_base", tf.fn); +_fields ~= select_field_like("metadata_and_text.src_filename_base", tf.src_filename_base); +_fields ~= select_field_like("metadata_and_text.language_document_char", tf.language); +_fields ~= select_field_like("metadata_and_text.date_published", tf.date); +_fields ~= select_field_like("metadata_and_text.classify_keywords", tf.keywords); +_fields ~= select_field_like("metadata_and_text.classify_topic_register", tf.topic_register); +string[] fields; +foreach (f; _fields) { + if (!(f.empty)) { fields ~= f; } +} +string fields_str = ""; +fields_str ~= fields.join(" AND "); +#+END_SRC + +**** the body format sql select + +#+NAME: spine_search_query_format_sql_select_the_body +#+BEGIN_SRC d + sql_select.the_body ~= format(q"┃ +SELECT + metadata_and_text.uid, + metadata_and_text.title, + metadata_and_text.creator_author_last_first, + metadata_and_text.creator_author, + metadata_and_text.src_filename_base, + metadata_and_text.language_document_char, + metadata_and_text.date_published, + metadata_and_text.classify_keywords, + metadata_and_text.classify_topic_register, + doc_objects.body, + doc_objects.seg_name, + doc_objects.ocn, + doc_objects.lev, + doc_objects.is_a, + metadata_and_text.uid +FROM + doc_objects, + metadata_and_text +WHERE ( + %s + ) +AND + doc_objects.uid_metadata_and_text = metadata_and_text.uid +ORDER BY + metadata_and_text.creator_author_last_first, + metadata_and_text.date_published DESC, + metadata_and_text.title, + metadata_and_text.language_document_char, + metadata_and_text.src_filename_base, + doc_objects.ocn +LIMIT %s OFFSET %s +;┃", + fields_str, + cv.sql_match_limit, + cv.sql_match_offset, + ); +#+END_SRC + +**** cgi writes + +#+NAME: spine_search_cgi_writes +#+BEGIN_SRC d +(cv.checked_sql) +? cgi.write(previous_next + ~ "<hr><font-size=\"1rem\" color=\"#666666\">" + ~ sql_select.the_body.strip.split("\n ").join(" ").split("\n").join("<br>") + ~ "</font>\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) ? "" : "</p>"; + _matched_ocn_open = (idx == 1) ? "" : "<p class=\"matched_ocn\">"; + _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 + ~ "<hr><div class=\"publication\">" + ~ "<p class=\"publication\"><a href=\"" + ~ conf.http_request_type ~ "://" + ~ conf.http_host ~ conf.doc_collection_subroot ~ "/" + ~ row["language_document_char"].as!string ~ "/html/" + ~ row["src_filename_base"].as!string ~ "/" + ~ "toc.html" + ~ "\">\"" + ~ row["title"].as!string ~ "\"" + ~ "</a> " + ~ _date + ~ "[" ~ row["language_document_char"].as!string ~ "] " + ~ row["creator_author_last_first"].as!string + ~ " " + ~ show_matched_objects(row["src_filename_base"].as!string) + ~ "</p>" + ~ "</div>" + ); + } + if (cv.results_type == "txt") { + string _sfn, _id; + if ((row["lev"].as!int < 4) + || (row["ocn"].as!string == "0")) { + if (row["is_a"].as!string == "bookindex") { + _sfn = "bookindex"; + _id = "idx"; + } else if (row["is_a"].as!string == "blurb") { + _sfn = "blurb"; + _id = "bm"; + } else { + _sfn = "toc"; + _id = row["ocn"].as!string; + } + cgi.write( + "<div class=\"flex-container\">" + ~ "<div class=\"textview_ocn\" style=\"flex: 0 0 1.2em\">" + ~ "<p class=\"ocn_is\"><a href=\"" + ~ conf.http_request_type ~ "://" + ~ conf.http_host ~ conf.doc_collection_subroot ~ "/" + ~ row["language_document_char"].as!string ~ "/html/" + ~ row["src_filename_base"].as!string ~ "/" + ~ _sfn ~ ".html" + ~ "\">" + ~ _id + ~ "</a>:</p>" + ~ "</div>" + ~ "<div class=\"textview_found\">" + ~ highlight_text_matched(row["body"].as!string, tf.text) + ~ "</div>" + ~ "</div>" + ); + } else { + if (row["is_a"].as!string == "bibliography") { + _id = row["ocn"].as!string ~ "b"; + _sfn = "bibliography"; + } else if (row["is_a"].as!string == "glossary") { + _id = row["ocn"].as!string ~ "g"; + _sfn = "glossary"; + } else { + _id = row["ocn"].as!string; + _sfn = row["seg_name"].as!string; + } + cgi.write( + "<div class=\"flex-container\">" + ~ "<div class=\"textview_ocn\" style=\"flex: 0 0 1.2em\">" + ~ "<p class=\"ocn_is\"><a href=\"" + ~ conf.http_request_type ~ "://" + ~ conf.http_host ~ conf.doc_collection_subroot ~ "/" + ~ row["language_document_char"].as!string ~ "/html/" + ~ row["src_filename_base"].as!string ~ "/" + ~ _sfn ~ ".html#" ~ row["ocn"].as!string + ~ "\">" + ~ _id + ~ "</a>:</p>" + ~ "</div>" + ~ "<div class=\"textview_found\">" + ~ highlight_text_matched(row["body"].as!string, tf.text) + ~ "</div>" + ~ "</div>" + ); + } + } else { + string _sfn, _id; + if ((row["lev"].as!int < 4) + || (row["ocn"].as!string == "0")) { + if (row["is_a"].as!string == "bookindex") { + _sfn = "bookindex"; + _id = "i"; + } else if (row["is_a"].as!string == "blurb") { + _sfn = "blurb"; + _id = "bm"; + } else { + _sfn = "toc"; + _id = row["ocn"].as!string; + } + cgi.write( + _matched_ocn_open + ~ "<a href=\"" + ~ conf.http_request_type ~ "://" + ~ conf.http_host ~ conf.doc_collection_subroot ~ "/" + ~ row["language_document_char"].as!string ~ "/html/" + ~ row["src_filename_base"].as!string ~ "/" + ~ _sfn ~ ".html" + ~ "\">" + ~ _id + ~ "</a>, " + ); + } else { + if (row["is_a"].as!string == "bibliography") { + _id = row["ocn"].as!string ~ "b"; + _sfn = "bibliography"; + } else if (row["is_a"].as!string == "glossary") { + _id = row["ocn"].as!string ~ "g"; + _sfn = "glossary"; + } else { + _id = row["ocn"].as!string; + _sfn = row["seg_name"].as!string; + } + cgi.write( + _matched_ocn_open + ~ "<a href=\"" + ~ conf.http_request_type ~ "://" + ~ conf.http_host ~ conf.doc_collection_subroot ~ "/" + ~ row["language_document_char"].as!string ~ "/html/" + ~ row["src_filename_base"].as!string ~ "/" + ~ _sfn ~ ".html#" ~ row["ocn"].as!string + ~ "\">" + ~ _id + ~ "</a>, " + ); + } + _matched_ocn_open = ""; + } + } + cgi.write( previous_next); +} else { // offset_not_beyond_limit = false; + cgi.write("select_query_results empty<p>\n"); +} +#+END_SRC + +**** cgi write tail + +#+NAME: spine_search_cgi_write_tail +#+BEGIN_SRC d + cgi.write("<br><p class=\"center\"> +<label for=\"find\"> +<a href=\"https://sisudoc.org/\" target=\"_top\"><b>≅ SiSU Spine</b></a> +</label> +<label for=\"find\">(object numbering & object search) 2022</label> +<br><a href=\"https://git.sisudoc.org/\" target=\"_top\">git</a> +</p> +"); +#+END_SRC + +**** debug info + +#+NAME: spine_search_debug_info +#+BEGIN_SRC d +cgi.write("db with path: " ~ conf.db_path ~ "/" ~ cv.db_selected ~ "<br>\n"); +cgi.write("http url: " ~ conf.http_url ~ "<br>\n"); +cgi.write("query base url: " ~ conf.query_base_url ~ "<br>\n"); +cgi.write("db_selected: " ~ cv.db_selected ~ "<br>\n"); +cgi.write("search_text: " ~ cv.search_text ~ "<br>\n"); +cgi.write("sql_match_limit: " ~ cv.sql_match_limit ~ ";\n"); +cgi.write("sql_match_offset: " ~ cv.sql_match_offset ~ ";\n"); +cgi.write("results_type: " ~ cv.results_type ~ "<br>\n"); +cgi.write("cv.checked_echo: " ~ (cv.checked_echo ? "checked" : "off") ~ "; \n"); +cgi.write("cv.checked_stats: " ~ (cv.checked_stats ? "checked" : "off") ~ "; \n"); +cgi.write("cv.checked_url: " ~ (cv.checked_url ? "checked" : "off") ~ "; \n"); +cgi.write("cv.checked_searched: " ~ (cv.checked_searched ? "checked" : "off") ~ ";<br>\n"); +cgi.write("cv.checked_tip: " ~ (cv.checked_tip ? "checked" : "off") ~ "; \n"); +cgi.write("cv.checked_sql: " ~ (cv.checked_sql ? "checked" : "off") ~ "<br>\n"); +#+END_SRC + +**** css + +- if base size is 16px, 62.5% is 10px + 1rem == 10px + 1.6rem == 16px + +#+NAME: spine_search_css +#+BEGIN_SRC css +html { + font-size : 62.5%%; +} +,*{ + padding : 0px; + margin : 2px; +} +body { + height : 100vh; + font-size : 1.6rem; + color : #000000; + background : #FFFFFF; + background-color : #FFFFFF; +} +a:link { + color : #003399; + text-decoration : none; +} +a:visited { + color : #003399; + text-decoration : none; +} +a:hover { + color : #000000; + background-color : #F9F9AA; +} +a.matched_ocn:link { + color : #003399; + text-decoration : none; +} +a.matched_ocn:visited { + color : #003399; + text-decoration : none; +} +a.matched_ocn:hover { + color : #000000; + background-color : #F9F9AA; + font-size : 1.6rem; +} +a.lnkocn:link { + color : #777777; + text-decoration : none; +} +a.lnkocn:visited { + color : #32CD32; + text-decoration : none; +} +a.lnkocn:hover { + color : #777777; + font-size : 1.6rem; +} +a:hover img { + background-color : #FFFFFF; +} +a:active { + color : #003399; + text-decoration : underline; +} +.flex-container { + display : flex; +} +div.publication { + margin-top : 2px; + margin-bottom : 4px; + margin-left : 0%%; + margin-right : 0%%; +} +div.textview_ocn { + margin-left : 0%%; + margin-right : 1%%; +} +div.textview_found { + margin-left : 1%%; + margin-right : 1%%; +} +textarea { + color : #000000; + background-color : #FFFFFF; +} +span.match { + color : #000000; + background-color : #FFFF48; +} +input, select, textarea { + font-size : 2rem; +} +input[type="text"] { + font-size : 2rem; + line-height : 150%%; +} +button[type="submit"] { + font-size : 2rem; + line-height : 150%%; +} +p.norm { } +p.center { text-align : center; } +p.i1 { padding-left : 1em; } +p.i2 { padding-left : 2em; } +p.i3 { padding-left : 3em; } +p.i4 { padding-left : 4em; } +p.i5 { padding-left : 5em; } +p.i6 { padding-left : 6em; } +p.i7 { padding-left : 7em; } +p.i8 { padding-left : 8em; } +p.i9 { padding-left : 9em; } +/* hanging indent */ +p[indent="h0i0"] { + padding-left : 0em; + text-indent : 0em; +} +p.publication { + font-size : 1.6rem; + margin-left : 0em; + margin-top : 0px; + margin-bottom : 0px; + margin-right : 6px; + text-align : left; +} +p.ocn_is { + font-size : 1.6rem; + display : inline-block; +} +p.matched_ocn { + font-size : 1.5rem; + margin-left : 2em; + margin-top : 0px; + margin-bottom : 0px; + margin-right : 6px; + text-align : left; +} +p[indent="h0i1"] { + padding-left : 1em; + text-indent : -1em; +} +p[indent="h0i2"] { + padding-left : 2em; + text-indent : -2em; +} +p[indent="h0i3"] { + padding-left : 3em; + text-indent : -3em; +} +p[indent="h0i4"] { + padding-left : 4em; + text-indent : -4em; +} +p[indent="h0i5"] { + padding-left : 5em; + text-indent : -5em; +} +p[indent="h0i6"] { + padding-left : 6em; + text-indent : -6em; +} +p[indent="h0i7"] { + padding-left : 7em; + text-indent : -7em; +} +p[indent="h0i8"] { + padding-left : 8em; + text-indent : -8em; +} +p[indent="h0i9"] { + padding-left : 9em; + text-indent : -9em; +} +p[indent="h1i0"] { + padding-left : 0em; + text-indent : 1em; +} +p[indent="h1i1"] { + padding-left : 1em; + text-indent : 0em; +} +p[indent="h1i2"] { + padding-left : 2em; + text-indent : -1em; +} +p[indent="h1i3"] { + padding-left : 3em; + text-indent : -2em; +} +p[indent="h1i4"] { + padding-left : 4em; + text-indent : -3em; +} +p[indent="h1i5"] { + padding-left : 5em; + text-indent : -4em; +} +p[indent="h1i6"] { + padding-left : 6em; + text-indent : -5em; +} +p[indent="h1i7"] { + padding-left : 7em; + text-indent : -6em; +} +p[indent="h1i8"] { + padding-left : 8em; + text-indent : -7em; +} +p[indent="h1i9"] { + padding-left : 9em; + text-indent : -8em; +} +p[indent="h2i0"] { + padding-left : 0em; + text-indent : 2em; +} +p[indent="h2i1"] { + padding-left : 1em; + text-indent : 1em; +} +p[indent="h2i2"] { + padding-left : 2em; + text-indent : 0em; +} +p[indent="h2i3"] { + padding-left : 3em; + text-indent : -1em; +} +p[indent="h2i4"] { + padding-left : 4em; + text-indent : -2em; +} +p[indent="h2i5"] { + padding-left : 5em; + text-indent : -3em; +} +p[indent="h2i6"] { + padding-left : 6em; + text-indent : -4em; +} +p[indent="h2i7"] { + padding-left : 7em; + text-indent : -5em; +} +p[indent="h2i8"] { + padding-left : 8em; + text-indent : -6em; +} +p[indent="h2i9"] { + padding-left : 9em; + text-indent : -7em; +} +p[indent="h3i0"] { + padding-left : 0em; + text-indent : 3em; +} +p[indent="h3i1"] { + padding-left : 1em; + text-indent : 2em; +} +p[indent="h3i2"] { + padding-left : 2em; + text-indent : 1em; +} +p[indent="h3i3"] { + padding-left : 3em; + text-indent : 0em; +} +p[indent="h3i4"] { + padding-left : 4em; + text-indent : -1em; +} +p[indent="h3i5"] { + padding-left : 5em; + text-indent : -2em; +} +p[indent="h3i6"] { + padding-left : 6em; + text-indent : -3em; +} +p[indent="h3i7"] { + padding-left : 7em; + text-indent : -4em; +} +p[indent="h3i8"] { + padding-left : 8em; + text-indent : -5em; +} +p[indent="h3i9"] { + padding-left : 9em; + text-indent : -6em; +} +p[indent="h4i0"] { + padding-left : 0em; + text-indent : 4em; +} +p[indent="h4i1"] { + padding-left : 1em; + text-indent : 3em; +} +p[indent="h4i2"] { + padding-left : 2em; + text-indent : 2em; +} +p[indent="h4i3"] { + padding-left : 3em; + text-indent : 1em; +} +p[indent="h4i4"] { + padding-left : 4em; + text-indent : 0em; +} +p[indent="h4i5"] { + padding-left : 5em; + text-indent : -1em; +} +p[indent="h4i6"] { + padding-left : 6em; + text-indent : -2em; +} +p[indent="h4i7"] { + padding-left : 7em; + text-indent : -3em; +} +p[indent="h4i8"] { + padding-left : 8em; + text-indent : -4em; +} +p[indent="h4i9"] { + padding-left : 9em; + text-indent : -5em; +} +p[indent="h5i0"] { + padding-left : 0em; + text-indent : 5em; +} +p[indent="h5i1"] { + padding-left : 1em; + text-indent : 4em; +} +p[indent="h5i2"] { + padding-left : 2em; + text-indent : 3em; +} +p[indent="h5i3"] { + padding-left : 3em; + text-indent : 2em; +} +p[indent="h5i4"] { + padding-left : 4em; + text-indent : 1em; +} +p[indent="h5i5"] { + padding-left : 5em; + text-indent : 0em; +} +p[indent="h5i6"] { + padding-left : 6em; + text-indent : -1em; +} +p[indent="h5i7"] { + padding-left : 7em; + text-indent : -2em; +} +p[indent="h5i8"] { + padding-left : 8em; + text-indent : -3em; +} +p[indent="h5i9"] { + padding-left : 9em; + text-indent : -4em; +} +p[indent="h6i0"] { + padding-left : 0em; + text-indent : 6em; +} +p[indent="h6i1"] { + padding-left : 1em; + text-indent : 5em; +} +p[indent="h6i2"] { + padding-left : 2em; + text-indent : 4em; +} +p[indent="h6i3"] { + padding-left : 3em; + text-indent : 3em; +} +p[indent="h6i4"] { + padding-left : 4em; + text-indent : 2em; +} +p[indent="h6i5"] { + padding-left : 5em; + text-indent : 1em; +} +p[indent="h6i6"] { + padding-left : 6em; + text-indent : 0em; +} +p[indent="h6i7"] { + padding-left : 7em; + text-indent : -1em; +} +p[indent="h6i8"] { + padding-left : 8em; + text-indent : -2em; +} +p[indent="h6i9"] { + padding-left : 9em; + text-indent : -3em; +} +p[indent="h7i0"] { + padding-left : 0em; + text-indent : 7em; +} +p[indent="h7i1"] { + padding-left : 1em; + text-indent : 6em; +} +p[indent="h7i2"] { + padding-left : 2em; + text-indent : 5em; +} +p[indent="h7i3"] { + padding-left : 3em; + text-indent : 4em; +} +p[indent="h7i4"] { + padding-left : 4em; + text-indent : 3em; +} +p[indent="h7i5"] { + padding-left : 5em; + text-indent : 2em; +} +p[indent="h7i6"] { + padding-left : 6em; + text-indent : 1em; +} +p[indent="h7i7"] { + padding-left : 7em; + text-indent : 0em; +} +p[indent="h7i8"] { + padding-left : 8em; + text-indent : -1em; +} +p[indent="h7i9"] { + padding-left : 9em; + text-indent : -2em; +} +p[indent="h8i0"] { + padding-left : 0em; + text-indent : 8em; +} +p[indent="h8i1"] { + padding-left : 1em; + text-indent : 7em; +} +p[indent="h8i2"] { + padding-left : 2em; + text-indent : 6em; +} +p[indent="h8i3"] { + padding-left : 3em; + text-indent : 5em; +} +p[indent="h8i4"] { + padding-left : 4em; + text-indent : 4em; +} +p[indent="h8i5"] { + padding-left : 5em; + text-indent : 3em; +} +p[indent="h8i6"] { + padding-left : 6em; + text-indent : 2em; +} +p[indent="h8i7"] { + padding-left : 7em; + text-indent : 1em; +} +p[indent="h8i8"] { + padding-left : 8em; + text-indent : 0em; +} +p[indent="h8i9"] { + padding-left : 9em; + text-indent : -1em; +} +p[indent="h9i0"] { + padding-left : 0em; + text-indent : 9em; +} +p[indent="h9i1"] { + padding-left : 1em; + text-indent : 8em; +} +p[indent="h9i2"] { + padding-left : 2em; + text-indent : 7em; +} +p[indent="h9i3"] { + padding-left : 3em; + text-indent : 6em; +} +p[indent="h9i4"] { + padding-left : 4em; + text-indent : 5em; +} +p[indent="h9i5"] { + padding-left : 5em; + text-indent : 4em; +} +p[indent="h9i6"] { + padding-left : 6em; + text-indent : 3em; +} +p[indent="h9i7"] { + padding-left : 7em; + text-indent : 2em; +} +p[indent="h9i8"] { + padding-left : 8em; + text-indent : 1em; +} +p[indent="h9i9"] { + padding-left : 9em; + text-indent : 0em; +} +p.spaced { white-space : pre; } +p.block { + white-space : pre; +} +p.group { } +p.alt { } +p.verse { + white-space : pre; + margin-bottom : 6px; +} +p.caption { + text-align : left; + font-size : 80%%; + display : inline; +} +p.endnote { + font-size : 1.5rem; + line-height : 120%%; + text-align : left; + margin-right : 15mm; + padding-left : 1em; + text-indent : -1em; +} +p.center { + text-align : center; +} +p.bold { + font-weight : bold; +} +p.bold_left { + font-weight : bold; + text-align : left; +} +p.centerbold { + text-align : center; + font-weight : bold; +} +p.em { + font-weight : bold; + font-style : normal; + background : #FFF3B6; +} +p.small { + font-size : 1.4rem; + margin-top : 0px; + margin-bottom : 0px; + margin-right : 6px; + text-align : left; +} +.tiny, .tiny_left, .tiny_right, .tiny_center { + font-size : 1.3rem; + margin-top : 0px; + margin-bottom : 0px; + color : #EEEEEE; + margin-right : 6px; + text-align : left; +} +p.tiny { } +p.tiny_left { + margin-left : 0px; + margin-right : 0px; + text-align : left; +} +p.tiny_right { + margin-right : 1em; + text-align : right; +} +p.tiny_center { + margin-left : 0px; + margin-right : 0px; + text-align : center; +} +p.book_index_lev1 { + line-height : 100%%; + margin-top : 4px; + margin-bottom : 1px; +} +p.book_index_lev2 { + line-height : 100%%; + text-align : left; + margin-left : 3em; + margin-top : 1px; + margin-bottom : 3px; +} +tt { + font-family : inconsolata, "liberation mono", "bitstream vera mono", "dejavu mono", monaco, consolas, "andale mono", "courier new", "courier 10 pitch", courier, monospace; + background-color : #555555; + color : #DDDDDD; +} +pre { + width : auto; + display : block; + clear : both; + color : #555555; +} +pre.codeline { + display : table; + clear : both; + table-layout : fixed; + margin-left : 5%%; + margin-right : 5%%; + width : 90%%; + white-space : pre-wrap; + border-style : none; + border-radius : 5px 5px 5px 5px; + box-shadow : 0 2px 5px #AAAAAA inset; + margin-bottom : 1em; + padding : 0.5em 1em; + page-break-inside : avoid; + word-wrap : break-word; + font-family : inconsolata, "liberation mono", "bitstream vera mono", "dejavu mono", monaco, consolas, "andale mono", "courier new", "courier 10 pitch", courier, monospace; + white-space : pre; + white-space : pre-wrap; + white-space : -moz-pre-wrap; + white-space : -o-pre-wrap; + background-color : #555555; + color : #DDDDDD; + font-size : 1.8rem; + line-height : 120%%; +} +pre.codeline::before { + counter-reset : linenum; +} +pre.codeline span.tr { + display : table-row; + counter-increment : linenum; +} +pre.codeline span.th { + display : table-cell; + user-select : none; + -moz-user-select : none; + -webkit-user-select : none; + padding : 0.5em 0.5em; +} +pre.codeline span.th::before { + content : counter(linenum) "."; + color : #999999; + text-align : right; + display : block; +} +pre.codeline span.th { + width : 4em; +} +pre.codeline code { + display : table-cell; +} +p.code { + border-style : none; +} +note { white-space : pre; } +em { + font-weight : bold; + font-style : italic; +} +p.left,th.left,td.left { + text-align : left; +} +p.small_left,th.small_left,td.small_left { + text-align : left; + font-size : 1.4rem; +} +p.right,th.right,td.right { + text-align : right; +} +ul, li { + list-style-type : none; + list-style : none; + padding-left : 20px; + font-weight : normal; + line-height : 150%%; + text-align : left; + text-indent : 0mm; + margin-left : 1em; + margin-right : 2em; + margin-top : 3px; + margin-bottom : 3px; +} +li { + background : (../image_sys/bullet_09.png) no-repeat 0px 6px; +} +ul { } +h0, h1, h2, h3, h4, h5, h6, h7 { + font-weight : bold; + line-height : 120%%; + text-align : left; + margin-top : 20px; + margin-bottom : 10px; +} +h4.norm, h5.norm, h6.norm, h7.norm { + margin-top : 10px; + margin-bottom : 0px; +} +h0 { font-size : 2rem; } +h1 { font-size : 1.9rem; } +h2 { font-size : 1.8rem; } +h3 { font-size : 1.7rem; } +h4 { font-size : 1.6rem; } +h5 { font-size : 1.6rem; } +h6 { font-size : 1.6rem; } +h7 { font-size : 1.6rem; } +h0, h1, h2, h3, h4, h5, h6, h7 { + text-shadow : .2em .2em .3em #999999; +} +h1.i { margin-left : 2em; } +h2.i { margin-left : 3em; } +h3.i { margin-left : 4em; } +h4.i { margin-left : 5em; } +h5.i { margin-left : 6em; } +h6.i { margin-left : 7em; } +h7.i { margin-left : 8em; } +h8.i { margin-left : 9em; } +h9.i { margin-left : 10em; } +.toc { + font-weight : normal; + margin-top : 6px; + margin-bottom : 6px; +} +h0.toc { + margin-left : 1em; + font-size : 2rem; + line-height : 150%%; +} +h1.toc { + margin-left : 1em; + font-size : 1.9rem; + line-height : 150%%; +} +h2.toc { + margin-left : 2em; + font-size : 1.8rem; + line-height : 140%%; +} +h3.toc { + margin-left : 3em; + font-size : 1.7rem; + line-height : 120%%; +} +h4.toc { + margin-left : 4em; + font-size : 1.6rem; + line-height : 120%%; +} +h5.toc { + margin-left : 5em; + font-size : 1.5rem; + line-height : 110%%; +} +h6.toc { + margin-left : 6em; + font-size : 1.4rem; + line-height : 110%%; +} +h7.toc { + margin-left : 7em; + font-size : 1.3rem; + line-height : 100%%; +} +.subtoc { + margin-right : 34%%; + font-weight : normal; +} +h5.subtoc { + margin-left : 2em; + font-size : 1.5rem; + margin-top : 2px; + margin-bottom : 2px; +} +h6.subtoc { + margin-left : 3em; + font-size : 1.4rem; + margin-top : 0px; + margin-bottom : 0px; +} +h7.subtoc { + margin-left : 4em; + font-size : 1.3rem; + margin-top : 0px; + margin-bottom : 0px; +} +hr { + display : block; + height : 1px; + width : 100%%; + border : 0; + border-top : 1px solid #AAAAAA; + border-color : #AAAAAA + background-color : #AAAAAA + margin-left : 0%%; + margin-right : 0em; + margin-top : 0.5em; + margin-bottom : 0.5em; + padding : 0; +} +#+END_SRC + +*** settings for spine search SET + +#+NAME: url_doc_root +#+BEGIN_SRC text +/srv/www +#+END_SRC + +#+NAME: doc_root_path +#+BEGIN_SRC text +_cfg.doc_root_www +#+END_SRC +#+BEGIN_SRC text +/var/www/html +#+END_SRC + +#+NAME: doc_subroot_path +#+BEGIN_SRC text +/spine +#+END_SRC + +#+NAME: db_root_path +#+BEGIN_SRC text +_cfg.doc_root_db +#+END_SRC +#+BEGIN_SRC text +/var/www/sqlite/ +#+END_SRC + +*** spine_search configuration.txt + +see configuration_cfte.org + +*** document header including copyright & license + +#+NAME: doc_header_including_copyright_and_license +#+BEGIN_SRC txt +/+ +- Name: Spine, Doc Reform + - Description: documents, structuring, processing, publishing, search + - static content generator + + - Author: Ralph Amissah + [ralph.amissah@gmail.com] + + - Copyright: (C) 2015 - 2022 Ralph Amissah, All Rights + Reserved. + + - License: AGPL 3 or later: + + Spine (SiSU), a framework for document structuring, publishing and + search + + Copyright (C) Ralph Amissah + + 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. + + 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. + + 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] + + - Spine (by Doc Reform, related to SiSU) uses standard: + - docReform markup syntax + - standard SiSU markup syntax with modified headers and minor modifications + - docReform object numbering + - standard SiSU object citation numbering & system + + - Homepages: + [https://www.doc_reform.org] + [https://www.sisudoc.org] + + - Git + [https://git.sisudoc.org/projects/?p=software/spine.git;a=summary] + ++/ +#+END_SRC diff --git a/org/config_d_cfte.org b/org/config_d_cfte.org new file mode 100644 index 0000000..9bc1bd3 --- /dev/null +++ b/org/config_d_cfte.org @@ -0,0 +1,300 @@ +-*- mode: org -*- +#+TITLE: configuration d cfte +#+DESCRIPTION: documents - structuring, various output representations & search +#+FILETAGS: :spine:hub: +#+AUTHOR: Ralph Amissah +#+EMAIL: [[mailto:ralph.amissah@gmail.com][ralph.amissah@gmail.com]] +#+COPYRIGHT: Copyright (C) 2015 - 2022 Ralph Amissah +#+LANGUAGE: en +#+STARTUP: content hideblocks hidestars noindent entitiespretty +#+PROPERTY: header-args :exports code +#+PROPERTY: header-args+ :noweb yes +#+PROPERTY: header-args+ :results no +#+PROPERTY: header-args+ :cache no +#+PROPERTY: header-args+ :padline no +#+PROPERTY: header-args+ :mkdirp yes +#+OPTIONS: H:3 num:nil toc:t \n:t ::t |:t ^:nil -:t f:t *:t + +- [[./doc-reform.org][doc-reform.org]] [[../org/][org/]] + +* cfte views version.txt configuration.txt (set version & configuration) SET + +** program version: version.txt + +*** set program version SET VERSION :version:set:project: + +- comma separated numbers: major, minor, patch + +#+NAME: spine_version_set +#+BEGIN_SRC d +0, 12, 0 +#+END_SRC + +*** set program version tangle :version: + +#+HEADER: :tangle "../views/version.txt" +#+HEADER: :noweb yes +#+BEGIN_SRC txt +/+ obt - org-mode generated file +/ +struct Version { + int major; + int minor; + int patch; +} +enum _ver = Version(<<spine_version_set>>); +<<spine_compiler_restrictions>> +#+END_SRC + +*** compilation restrictions (supported compilers) +- set compilation restrictions + +https://dlang.org/spec/version.html#predefined-versions + +#+NAME: spine_compiler_restrictions +#+HEADER: :noweb yes +#+BEGIN_SRC d +version (Posix) { + version (DigitalMars) { + } else version (LDC) { + } else version (GNU) { + } else { + static assert (0, "Unsupported D compiler"); + } +} else { + static assert (0, "Unsupported D compiler"); +} +#+END_SRC + +** set configuration SET :configuration: + +SEE NOTES on configuration hierarchy in spine.org + +*** spine: configuration.txt SET +**** example + +#+HEADER: :tangle "../views/configuration_example.txt" +#+HEADER: :noweb yes +#+BEGIN_SRC d +/+ obt - org-mode generated file +/ +struct Cfg { + string http_request_type = "http"; + string http_host = "localhost"; + string www_url_doc_subroot = "/spine"; + string cgi_filename = "spine_search"; + string cgi_search_form_title = "≅ SiSU Spine search"; + string db_sqlite_path = "/var/www/sqlite"; + string db_sqlite_filename = "spine.search.db"; +} +enum _cfg = Cfg(); +#+END_SRC + +#+BEGIN_SRC d +/+ obt - org-mode generated file +/ +struct Cfg { + string http_request_type = "<<http_request_type>>"; + string http_host = "<<http_host>>"; + string www_url_doc_root = "<<www_url_doc_root>>"; + string www_url_doc_subroot = "<<www_url_doc_subroot>>"; + string processing_path_doc_root = "<<processing_path_doc_root>>"; + string cgi_bin_root = "<<cgi_bin_root>>"; + string cgi_bin_subpath = "<<cgi_bin_subpath>>"; + string cgi_filename = "<<cgi_filename>>"; + string cgi_url_root = "<<http_request_type>>://<<http_host>><<cgi_bin_subpath>>"; + string cgi_port = ""; + string cgi_user = ""; + string cgi_url_action = "<<http_request_type>>://<<http_host>><<cgi_bin_subpath>>/<<cgi_filename>>"; + string cgi_search_form_title = "<<cgi_search_form_title>>"; + string db_sqlite_path = "<<db_sqlite_path>>"; + string db_sqlite_filename = "<<db_sqlite_filename>>"; + string default_language = "en"; + string default_papersize = "a4,letter.portrait"; + string default_text_wrap = "80"; + string default_hash_digest = "sha256"; +} +enum _cfg = Cfg(); +#+END_SRC + +**** configure + +#+HEADER: :tangle ../views/configuration.txt_ +#+HEADER: :noweb yes +#+BEGIN_SRC d +<<config_localhost>> +#+END_SRC + +**** configure remote host (sisudoc.org) + +#+NAME: config_remotehost +#+HEADER: :tangle ../views/configuration.txt_remotehost_ +#+BEGIN_SRC d +struct Cfg { + string http_request_type = "https"; + string http_host = "sisudoc.org"; + string www_url_doc_subroot = "/spine"; + string cgi_filename = "spine_search"; + string cgi_search_form_title = "≅ SiSU Spine search"; + string db_sqlite_path = "/var/www/sqlite"; + string db_sqlite_filename = "spine.search.db"; +} +enum _cfg = Cfg(); +#+END_SRC + +#+BEGIN_SRC d +struct Cfg { + string http_request_type = "https"; + string http_host = "sisudoc.org"; + string www_url_doc_root = "https://sisudoc.org"; + string www_url_doc_subroot = "/spine"; + string processing_path_doc_root = "/srv/www/spine"; + string cgi_bin_root = "/var/www/cgi/cgi-bin"; + string cgi_bin_subpath = ""; + string cgi_filename = "spine_search"; + string cgi_url_root = "https://sisudoc.org"; + string cgi_port = ""; + string cgi_user = ""; + string cgi_url_action = "https://sisudoc.org/spine_search"; + string cgi_search_form_title = "≅ SiSU Spine search"; + string db_sqlite_path = "/var/www/sqlite"; + string db_sqlite_filename = "spine.search.db"; + string default_language = "en"; + string default_papersize = "a4"; + string default_text_wrap = "80"; + string default_hash_digest = "sha256"; +} +enum _cfg = Cfg(); +#+END_SRC + +**** configure localhost + +#+NAME: config_localhost +#+HEADER: :tangle ../views/configuration.txt_localhost_ +#+BEGIN_SRC d +struct Cfg { + string http_request_type = "http"; + string http_host = "localhost"; + string www_url_doc_subroot = "/spine"; + string cgi_filename = "spine_search"; + string cgi_search_form_title = "≅ SiSU Spine search"; + string db_sqlite_path = "/var/www/sqlite"; + string db_sqlite_filename = "spine.search.db"; +} +enum _cfg = Cfg(); +#+END_SRC + +#+BEGIN_SRC d +struct Cfg { + string http_request_type = "http"; + string http_host = "localhost"; + string www_url_doc_root = "http://localhost"; + string www_url_doc_subroot = "/spine"; + string processing_path_doc_root = "/srv/www/spine"; + string cgi_bin_root = "/var/www/cgi/cgi-bin"; + string cgi_bin_subpath = "/cgi-bin"; + string cgi_filename = "spine_search"; + string cgi_url_root = "http://localhost/cgi-bin"; + string cgi_port = ""; + string cgi_user = ""; + string cgi_url_action = "http://localhost/cgi-bin/spine_search"; + string cgi_search_form_title = "≅ SiSU Spine search"; + string db_sqlite_path = "/var/www/sqlite"; + string db_sqlite_filename = "spine.search.db"; + string default_language = "en"; + string default_papersize = "a4,letter.portrait"; + string default_text_wrap = "80"; + string default_hash_digest = "sha256"; +} +enum _cfg = Cfg(); +#+END_SRC + +*** spine_search: configuration.txt SET + +#+HEADER: :tangle "../doc-reform-code-software-search-cgi/views/configuration_example.txt" +#+HEADER: :noweb yes +#+BEGIN_SRC d +/+ obt - org-mode generated file +/ +struct Cfg { + string http_request_type = "<<http_request_type>>"; + string http_host = "<<http_host>>"; + string www_url_doc_subroot = "<<www_doc_subroot>>"; + string cgi_filename = "<<cgi_filename>>"; + string cgi_search_form_title = "<<cgi_search_form_title>>"; + string db_sqlite_path = "<<db_sqlite_path>>"; + string db_sqlite_filename = "<<db_sqlite_filename>>"; +} +enum _cfg = Cfg(); +#+END_SRC + +#+BEGIN_SRC d +struct Cfg { + string http_request_type = "https"; + string http_host = "sisudoc.org"; + string www_url_doc_subroot = "/spine"; + string cgi_filename = "spine_search"; + string cgi_search_form_title = "≅ SiSU Spine search"; + string db_sqlite_path = "/var/www/sqlite"; + string db_sqlite_filename = "spine.search.db"; +} +enum _cfg = Cfg(); +#+END_SRC + +*** shared settings SET defaults + +#+NAME: http_request_type +#+BEGIN_SRC sh +http +#+END_SRC + +#+NAME: http_host +#+BEGIN_SRC sh +localhost +#+END_SRC + +#+NAME: www_url_doc_root +#+BEGIN_SRC sh +http://localhost +#+END_SRC + +#+NAME: www_url_doc_subroot +#+BEGIN_SRC sh +/spine +#+END_SRC + +#+NAME: processing_path_doc_root +#+BEGIN_SRC sh +/srv/www/spine +#+END_SRC + +#+NAME: www_doc_subroot +#+BEGIN_SRC sh +/spine +#+END_SRC + +#+NAME: cgi_bin_root +#+BEGIN_SRC sh +/var/www/cgi/cgi-bin +#+END_SRC + +#+NAME: db_sqlite_path +#+BEGIN_SRC sh +/var/www/sqlite +#+END_SRC + +#+NAME: cgi_filename +#+BEGIN_SRC sh +spine_search +#+END_SRC + +#+NAME: cgi_bin_subpath +#+BEGIN_SRC sh +/cgi-bin +#+END_SRC + +#+NAME: cgi_search_form_title +#+BEGIN_SRC sh +≅ SiSU Spine search +#+END_SRC + +#+NAME: db_sqlite_filename +#+BEGIN_SRC sh +spine.search.db +#+END_SRC diff --git a/org/config_dub.org b/org/config_dub.org new file mode 100644 index 0000000..65b0843 --- /dev/null +++ b/org/config_dub.org @@ -0,0 +1,286 @@ +-*- mode: org -*- +#+TITLE: configuration dub +#+DESCRIPTION: documents - structuring, various output representations & search +#+FILETAGS: :spine:hub: +#+AUTHOR: Ralph Amissah +#+EMAIL: [[mailto:ralph.amissah@gmail.com][ralph.amissah@gmail.com]] +#+COPYRIGHT: Copyright (C) 2015 - 2022 Ralph Amissah +#+LANGUAGE: en +#+STARTUP: content hideblocks hidestars noindent entitiespretty +#+PROPERTY: header-args :exports code +#+PROPERTY: header-args+ :noweb yes +#+PROPERTY: header-args+ :results no +#+PROPERTY: header-args+ :cache no +#+PROPERTY: header-args+ :padline no +#+PROPERTY: header-args+ :mkdirp yes +#+OPTIONS: H:3 num:nil toc:t \n:t ::t |:t ^:nil -:t f:t *:t + +- [[./doc-reform.org][doc-reform.org]] [[./][org/]] + +** spine version SET VERSION :version:set:project: + +#+NAME: spine_version_set +#+BEGIN_SRC sh +0.12.0 +#+END_SRC + +*** dub.json :dub:config:json: +**** dub.json +***** file-system download external dependencies + +- d2sqlite3 +- dyaml + - tinyendian +- imageformats + +#+HEADER: :tangle "../dub.json" +#+HEADER: :noweb yes +#+BEGIN_SRC json +{ + "authors": [ + "Ralph Amissah" + ], + "copyright": "Copyright © 2015 - 2022 Ralph Amissah", + "name": "spine_search", + "version": "0.12.0", + "description": "cgi search for spine, a sisu like document parser", + "homepage": "https://sisudoc.org", + "license": "AGPL-3.0+", + "targetPath": "./cgi-bin", + "sourcePaths": [ "./src" ], + "stringImportPaths": [ "./views" ], + "buildRequirements": [ "allowWarnings" ], + "targetType": "executable", + "platforms": [ "posix" ], + "buildTypes": { + "dmd": { + "dflags": [ "-J=views", "-I=src" ], + "buildOptions": [ "inline", "verbose" ], + "buildRequirements": [ "allowWarnings" ] + }, + "ldc2": { + "dflags": [ "-O2", "-J=views", "-I=src" ], + "buildOptions": [ "optimize", "inline", "verbose" ], + "buildRequirements": [ "allowWarnings" ] + }, + "ldmd2": { + "dflags": [ "-O2", "-boundscheck=on", "-J=views", "-I=src", "-color=on" ], + "buildOptions": [ "optimize", "inline", "verbose" ], + "buildRequirements": [ "allowWarnings" ] + }, + "gdc": { + "dflags": [ "-O2", "-J=views", "-I=src" ], + "buildOptions": [ "optimize", "inline" ], + "buildRequirements": [ "allowWarnings" ] + }, + "gdmd": { + "dflags": [ "-O2", "-J=views", "-I=src" ], + "buildOptions": [ "optimize", "inline" ], + "buildRequirements": [ "allowWarnings" ] + } + }, + "dependencies": { + "spine_search:arsd.cgi": "*", + "spine_search:d2sqlite3": "*" + }, + "subPackages": [ + { + "name": "d2sqlite3", + "description": "A thin wrapper around SQLite 3", + "homepage": "https://github.com/dlang-community/d2sqlite3", + "authors": [ "Nicolas Sicard", "Other contributors: see Github repo" ], + "copyright": "Copyright 2011-18 Nicolas Sicard", + "license": "BSL-1.0", + "sourcePaths": [ "./src/ext_depends/d2sqlite3/source" ], + "importPaths": [ "./src/ext_depends/d2sqlite3/source" ], + "configurations": [ + { + "name": "d2sqlite3", + "d2sqlite3": "with-lib", + "targetType": "library", + "systemDependencies": "SQLite version >= 3.8.7", + "libs": [ "sqlite3" ], + "excludedSourceFiles": [ "source/tests.d" ] + } + ] + }, + { + "name": "arsd.cgi", + "description": "cgi", + "homepage": "https://code.dlang.org/packages/arsd-official", + "authors": [ "Adam Ruppee" ], + "copyright": "Copyright 2011-18 Adam Ruppee", + "license": "BSL-1.0", + "sourcePaths": [ "./src/ext_depends/arsd" ], + "importPaths": [ "./src/ext_depends/arsd" ], + "configurations": [ + { + "name": "cgi", + "cgi": "with-lib", + "targetType": "library", + "systemDependencies": "Arsd version >= 0.8.7" + } + ] + } + ], + "configurations": [ + { + "name": "default", + "targetName": "spine_search" + }, + { + "name": "ldc2", + "targetName": "spine-search-ldc.cgi" + }, + { + "name": "ldmd2", + "targetName": "spine-search-ldc.cgi" + }, + { + "name": "dmd", + "targetName": "spine-search-dmd.cgi" + }, + { + "name": "gdc", + "targetName": "spine-search-gdc.cgi" + } + ] +} +#+END_SRC + +***** generic :generic: +****** build (sdp) :release: + +#+BEGIN_SRC sh +configuration "build" { + name "build" + targetType "executable" + platforms "posix" + targetName "bin/spine" + dflags "-J=views" "-I=src/doc_reform" + buildOptions "verbose" "releaseMode" "optimize" "inline" + postGenerateCommands "notify-send -t 0 'D release executable ready' 'spine'" +} +#+END_SRC + +** dub :dub: + +https://github.com/dlang/dub/ +https://code.dlang.org/getting_started +https://code.dlang.org/docs/commandline + +*** setup +**** dub json or sdlang + +Every DUB package should contain a [[https://code.dlang.org/package-format?lang=json][dub.json]] or [[https://code.dlang.org/package-format?lang=sdl][dub.sdl]] +https://code.dlang.org/package-format?lang=sdl +https://code.dlang.org/packages/sdlang-d +https://github.com/Abscissa/SDLang-D/blob/master/HOWTO.md + +https://code.dlang.org/docs/commandline + +**** dub dependencies + +dub list +dub upgrade +dub fetch taggedalgebraic +dub fetch libinputvisitor +dub fetch unit-threaded ? + +sdp ~master: /home/ralph/grotto/repo/git.repo/utils/spine-x/ +/home/ralph/.dub/packages/* + +*** build +**** debug flags + +#+BEGIN_SRC sh +biblio +biblio_sorted +bibliosorted +block +bookindex +bookindexmatch +bookindexraw +check +checkdoc +code +comment +dumpdoc write out document contents, with object type and ocn +endnotes +endnotes_build +footnotes +footnotesdone +group +header +header_and_content +header1 +headerjson +headermakejson +headermetadatajson +heading +headings +headingsfound +insert +io +munge +node +objectrelated1 +objectrelated2 +objects +ocnoff +para +parabullet +parabulletindent +paraindent +paraindenthang +parent +poem +quote +raw +source +srclines +structattrib +summary +table +toc +#+END_SRC + +** dub REFERENCE +*** SET version + +#+NAME: dub_version_set +#+HEADER: :noweb yes +#+BEGIN_SRC nix +<<dub_version_next>> +#+END_SRC + +#+NAME: nix_sha_dub +#+HEADER: :noweb yes +#+BEGIN_SRC nix +<<nix_sha_dub_next>> +#+END_SRC + +*** SELECT version +**** dub 1.24.0 + +#+NAME: dub_version_next +#+BEGIN_SRC nix +1.24.0 +#+END_SRC + +#+NAME: nix_sha_dub_next +#+BEGIN_SRC nix +0wirm6msz8kw2a7v2ax9ab6i48cmfv6qjwpfrl9vrr4k4xdg3vn6 +#+END_SRC + +**** dub 1.23.0 + +#+NAME: dub_version_current +#+BEGIN_SRC nix +1.23.0 +#+END_SRC + +#+NAME: nix_sha_dub_current +#+BEGIN_SRC nix +06a4whsl1m600k096nwif83n7za3vr7pj1xwapncy5fcad1gmady +#+END_SRC diff --git a/org/config_git.org b/org/config_git.org new file mode 100644 index 0000000..069341e --- /dev/null +++ b/org/config_git.org @@ -0,0 +1,91 @@ +-*- mode: org -*- +#+TITLE: configuration git +#+DESCRIPTION: documents - structuring, various output representations & search +#+FILETAGS: :spine:hub: +#+AUTHOR: Ralph Amissah +#+EMAIL: [[mailto:ralph.amissah@gmail.com][ralph.amissah@gmail.com]] +#+COPYRIGHT: Copyright (C) 2015 - 2022 Ralph Amissah +#+LANGUAGE: en +#+STARTUP: content hideblocks hidestars noindent entitiespretty +#+PROPERTY: header-args :exports code +#+PROPERTY: header-args+ :noweb yes +#+PROPERTY: header-args+ :results no +#+PROPERTY: header-args+ :cache no +#+PROPERTY: header-args+ :padline no +#+PROPERTY: header-args+ :mkdirp yes +#+OPTIONS: H:3 num:nil toc:t \n:t ::t |:t ^:nil -:t f:t *:t + +* spine +** .gitignore :gitignore: + +#+HEADER: :tangle "../.gitignore" +#+BEGIN_SRC sh +# git ls-files --others --exclude-from=.git/info/exclude +# git check-ignore -v flake.lock +# git clean -ix +# find . -name "*_" | xargs rm -rf +# find . -name "*.o" | xargs rm -rf +* +!.gitignore +!.gitattributes +!nix/** +!*.nix +!flake.lock +!.envrc +!README.md +!README +!COPYRIGHT +!CHANGELOG +!makefile +!version.txt +!configuration.txt +!*.json +!*.sdl +!meson.build +!tangle +!*.org +!org +!org/*.org +!*.d +!*.rb +!*.txt +!src +!src/** +!*.sst +!*.ssm +!**/*.sst +!**/*.ssm +!config_local_site +!views +.dub/** +**/.dub/** +**/cgi-bin/** +tmp/** +*_.org +*_.nix +*_.d +*_.txt +*_ +*.swp +*~ +\#* +*.\#* +!.envrc-local_ +!src/spine_search.d_ +#!*/ +#\#* +#*.\#* +#.reggae/** +#+END_SRC + +** .gitattributes :gitattributes: + +#+HEADER: :tangle "../.gitattributes" +#+BEGIN_SRC sh +/org export-ignore +.gitattributes export-ignore +#.gitignore export-ignore +tangle export-ignore +#flake.lock export-ignore +/build export-ignore +#+END_SRC diff --git a/org/config_make.org b/org/config_make.org new file mode 100644 index 0000000..f2ea5af --- /dev/null +++ b/org/config_make.org @@ -0,0 +1,748 @@ +-*- mode: org -*- +#+TITLE: spine (doc_reform) (project) makefile +#+DESCRIPTION: makefile for spine +#+FILETAGS: :spine:build:tools: +#+AUTHOR: Ralph Amissah +#+EMAIL: [[mailto:ralph.amissah@gmail.com][ralph.amissah@gmail.com]] +#+COPYRIGHT: Copyright (C) 2015 - 2022 Ralph Amissah +#+LANGUAGE: en +#+STARTUP: content hideblocks hidestars noindent entitiespretty +#+PROPERTY: header-args :exports code +#+PROPERTY: header-args+ :noweb yes +#+PROPERTY: header-args+ :results no +#+PROPERTY: header-args+ :cache no +#+PROPERTY: header-args+ :padline no +#+PROPERTY: header-args+ :mkdirp yes + +- [[./doc-reform.org][doc-reform.org]] [[../org/][org/]] + +* project +** version info SET VERSION :version:set:project: +*** project SET VERSION + +#+NAME: spine_version_set +#+BEGIN_SRC sh +0.12.0 +#+END_SRC + +*** build tools if specified + +- meson + +#+NAME: meson_version_set +#+BEGIN_SRC sh +0.46 +#+END_SRC + +- soversion + +#+NAME: soversion_version_set +#+BEGIN_SRC sh +0 +#+END_SRC + +* spine +** spine makefile :makefile: +*** tangle + +#+HEADER: :noweb yes +#+BEGIN_SRC makefile +SpineBIN := "${SpineBIN}" # 'result/bin' +SpineOUT := "${SpineOUT}" # '/srv/www/spine' +SpinePOD := "${SpinePOD}" # '~/grotto/repo/git.repo/projects/project-spine/doc-reform-markup/spine-markup-samples/markup/pod' +SpineSearchAction := 'https://sisudoc.org/spine_search' +SpineCGIform := 'spine_search' +SpineSQLdb := 'spine.search.db' + +# nix build +build: + nix-build + +# cp cgi search form +cp-cgi: + sudo cp -vi /var/www/cgi/cgi-bin/spine_search /var/www/cgi/cgi-bin/spine_search_old && \ + sudo cp -vi result/share/cgi-bin/spine_search /var/www/cgi/cgi-bin/spine_search + +get_depends: + hwd=$$(echo `pwd`) && \ + gwd="$${hwd}/src/ext_depends" && \ + dirs=$$(echo `ls -gx $${gwd}`) && \ + license_bsl="Boost Software License 1.0 (BSL-1.0)" && \ + echo $${hwd} && \ + echo $${gwd} && \ + echo $${deps} && \ + dub upgrade; \ + cd $${gwd} && \ + for dir in $${deps}; do \ + if [ -d $${dir} ]; then \ + echo $${dir} && \ + if [[ "arsd" == $${dir} ]]; then \ + echo $${dir} && \ + rm -rf $${dir} && \ + mkdir $${dir} && \ + aria2c -o "$${dir}/cgi.d" "https://raw.githubusercontent.com/adamdruppe/arsd/master/cgi.d" && \ + cd $${gwd}; \ + elif [[ "d2sqlite3" == $${dir} ]]; then \ + echo $${dir} && \ + rm -rf $${dir} && \ + git clone --depth=1 https://github.com/dlang-community/$${dir} && \ + cd $${dir} && \ + echo "$${dir} `git rev-parse HEAD | cut -c 1-8`" > ../$${dir}.meta && \ + echo "https://github.com/dlang-community/$${dir}" >> ../$${dir}.meta && \ + echo "$${license_bsl}" >> ../$${dir}.meta && \ + cd $${gwd} && \ + rm -rf $${dir}/.git; \ + fi; \ + fi; \ + done; \ + cd $${hwd} + +set_depends: get_depends + dub describe | sed 's~$(shell echo `pwd | sed 's_/_\\/_g'`)~.~g' > dub_describe.json +#+END_SRC + +<<make_git_snapshot>> +<<make_phony>> + +*** settings [+2] :settings: + +*** make archive + +#+NAME: make_project_zip_archive +#+BEGIN_SRC makefile +gitZip: + git archive -v --format=tar --prefix=`echo spine-$(PROG_VER_DECLARED)-tag-$(PROG_VER_GIT)`/ HEAD | gzip > ./tarballGitHEAD/spine-$(PROG_VER_DECLARED)-tag-$(PROG_VER_GIT).tar.gz && \ + echo "to unzip: tar -xzf spine-$(PROG_VER_DECLARED)-tag-$(PROG_VER_GIT).tar.gz" + +# git archive project, produce current state .tar.gz +gitArchive: + git archive -v --format=tar --prefix=spine-$(PROG_VER_DECLARED)-tag-$(PROG_VER_GIT)/ HEAD | gzip > ./tarballGitHEAD/spine-$(PROG_VER_DECLARED)-tag-$(PROG_VER_GIT).tar.gz && \ + echo "to unzip: tar -xzf spine-$(PROG_VER_DECLARED)-tag-$(PROG_VER_GIT).tar.gz" + +# git archive project, produce current state .tar.gz +# gitArchive: +# git archive -v --format=tar --prefix="spine-{{PROG_VER_DECLARED}}-tag-{{PROG_VER_GIT}}/" HEAD | gzip > ./tarballGitHEAD/spine-{{PROG_VER_DECLARED}}-tag-{{PROG_VER_GIT}}.tar.gz && \ +# echo "to unzip: tar -xzf spine-{{PROG_VER_DECLARED}}-tag-{{PROG_VER_GIT}}.tar.gz" + +#+END_SRC + +*** nixGitHEADtarball + +#+NAME: nixGitHEADtarball +#+HEADER: :noweb yes +#+BEGIN_SRC makefile +# remove test tarball dir +nixGitHEADtarballClean: + if [ -d "./tarballGitHEAD" ]; then \ + rm -rv ./tarballGitHEAD; \ + fi; + +# create test tarball +nixGitHEADtarballTar: + if [ ! -d "./tarballGitHEAD" ]; then \ + mkdir ./tarballGitHEAD; \ + fi; \ + git archive -v --format=tar --prefix="spine-${PROG_VER_DECLARED}/" HEAD | \ + gzip > ./tarballGitHEAD/spine-${PROG_VER_DECLARED}-tag-${PROG_VER_GIT}.tar.gz && \ + cp -v ./tarballGitHEAD/spine-${PROG_VER_DECLARED}-tag-${PROG_VER_GIT}.tar.gz ./tarballGitHEAD/spine-${PROG_VER_DECLARED}.tar.gz && \ + echo "to unzip: tar -xzf spine-${PROG_VER_DECLARED}-tag-${PROG_VER_GIT}.tar.gz"; \ + echo "to unzip: tar -xzf spine-${PROG_VER_DECLARED}.tar.gz" + +# check test tarball +nixGitHEADtarballCheck: + nix flake check <<nixGitUrl>>/spine-${PROG_VER_DECLARED}.tar.gz; \ + nix flake lock <<nixGitUrl>>/spine-${PROG_VER_DECLARED}.tar.gz; \ + nix flake show <<nixGitUrl>>/spine-${PROG_VER_DECLARED}.tar.gz; + +# build test tarball +nixGitHEADtarballBuild: + echo "nix build <<nixGitUrl>>/spine-${PROG_VER_DECLARED}.tar.gz#spine --print-build-logs" + nix build <<nixGitUrl>>/spine-${PROG_VER_DECLARED}.tar.gz#spine --print-build-logs + #nix build "./tarballGitHEAD/spine-${PROG_VER_DECLARED}.tar.gz#spine" --print-build-logs + +# clean create check & build test tarball +nixGitHEADtarball: nixGitHEADtarballClean nixGitHEADtarballTar nixGitHEADtarballCheck nixGitHEADtarballBuild + +#+END_SRC + +**** Url nixGitHEADtarball + +#+NAME: nixGitUrl +#+BEGIN_SRC makefile +file://${hwd}/tarballGitHEAD +#+END_SRC + +*** _make_ commands [+2] :make:commands: + +- build commands + - build + - debug + - release +- init, clean, distclean etc. + - init + - clean + - expunge + - distclean + - distclean_and_init +- org babel tangle + - tangle +- git snapshot + - gitsnapshot + +**** version tag, stamp + +#+NAME: make_version_tag +#+HEADER: :noweb yes +#+BEGIN_SRC makefile +version_tag: + echo "DRV=<<spine_version_set>>; git tag -f doc-reform_v$$\{DRV} -m\"doc-reform $$\{DRV}\" HEAD" && \ + echo "git tag -f doc-reform_v<<spine_version_set>> -m\"doc-reform spine-<<spine_version_set>>\" HEAD" + +#+END_SRC + +**** changelog + +#+NAME: make_changelog +#+BEGIN_SRC makefile +changelog_: + git log --pretty=format:'---%+s %+as %ae%+h%d%+b' --no-merges | sed "/^\\s*$$/d" | sed "s/^---$$//" | sed "s/^\(\*\)\+/-/" | sed "s/ \+$$//" > CHANGELOG_ + +# git changelog for project +changelog: + git log --pretty=format:'---%+s %+as %ae%+h%d%+b' --no-merges | sed "/^\\s*$$/d" | sed "s/^---$$//" | sed "s/^\(\*\)\+/-/" | sed "s/ \+$$//" | sed "s/ \+$//" > CHANGELOG_ + +#+END_SRC + +**** build commands [+1] :build:compile: +***** _dub_ build rebuild :dub: +****** all compiler builds :all:dmd:gdc:ldc: +******* all builds +******** default + +#+NAME: make_dub_upgrade +#+BEGIN_SRC makefile +dub_upgrade: + $(DUB) upgrade + +#+END_SRC + +#+NAME: make_compile_compiler_default +#+BEGIN_SRC makefile +default: ldc + +#+END_SRC + +******** quick :quick: +********* default :default: + +#+NAME: make_compile_compiler_all +#+BEGIN_SRC makefile +all: dmd ldc gdc + +all_ver: dmd_ver ldc_ver gdc_ver + +all_debug: dmd_debug gdc_debug ldc_debug + +#+END_SRC +******** clean & tangle :clean:tangle: +********* default :default: + +#+NAME: make_clean_tangle_compile_all_clean +#+BEGIN_SRC makefile +all_clean: clean tangle dmd ldc gdc + +all_ver_clean: clean tangle dmd_ver ldc_ver gdc_ver + +all_debug_ver: dmd_debug_ver gdc_debug_ver ldc_debug_ver + +all_debug_clean_ver: clean tangle dmd_debug_ver gdc_debug_ver ldc_debug_ver + +#+END_SRC + +****** individual compiler builds :each: +******* dmd :dmd: +******** quick builds :quick: + +#+NAME: make_dub_compile_dmd_default +#+BEGIN_SRC makefile +dmd: dub_upgrade + $(DUB) --compiler=dmd --config=dmd --build=release-nobounds + notify-send -t 0 'D dmd compiled test release executable ready' 'spine-dmd' + +dmd_debug: + $(DUB) --compiler=dmd --config=dmd --build=debug + +# assumes git tags with program version +dmd_ver: dub_upgrade + $(DUB) --compiler=dmd --config=dmd-version + mv bin/spine-dmd-ver bin-archive/spine-$(PROG_VER_DECLARED)-tag-$(PROG_VER_GIT)-dmd + notify-send -t 0 'D dmd compiled test release executable ready' 'spine-$(PROG_VER_DECLARED)-tag-$(PROG_VER_GIT)-dmd' + +#+END_SRC + +******** clean & tangle :clean:tangle: + +#+NAME: make_dub_compile_dmd_release +#+BEGIN_SRC makefile +dmd_clean_ver: clean tangle dmd_ver + +dmd_rel: expunge skel tangle + $(DUB) --compiler=dmd --config=spine-release + +dmd_rel_tangle: tangle + $(DUB) --compiler=dmd --config=spine-dmd + +dmd_rel_expunge_tangle: expunge skel tangle dmd_rel_tangle + +dmd_debug_tangle: tangle + $(DUB) --compiler=dmd --config=spine-dmd-debug + +#+END_SRC + +******* gdc :gdc: +******** quick builds :quick: + +#+NAME: make_dub_compile_gdc_default +#+BEGIN_SRC makefile +gdc: dub_upgrade + $(DUB) --compiler=gdc --config=gdc + notify-send -t 0 'D gdc compiled test release executable ready' 'spine-gdc' + +gdc_debug: + $(DUB) --compiler=gdc --config=gdc --build=debug + +# assumes git tags with program version +gdc_ver: dub_upgrade + $(DUB) --compiler=gdc --config=gdc-version + mv bin/spine-gdc-ver bin-archive/spine-$(PROG_VER_DECLARED)-tag-$(PROG_VER_GIT)-gdc + notify-send -t 0 'D gdc compiled test release executable ready' 'spine-$(PROG_VER_DECLARED)-tag-$(PROG_VER_GIT)-gdc' + +#+END_SRC + +******** clean & tangle :clean:tangle: + +#+NAME: make_dub_compile_gdc_release +#+BEGIN_SRC makefile +gdc_clean_ver: clean tangle gdc_ver + +gdc_rel: expunge skel tangle + $(DUB) --compiler=gdc --config=spine-release + +gdc_rel_tangle: tangle + $(DUB) --compiler=gdc --config=spine-gdc + +gdc_rel_expunge_tangle: expunge skel tangle gdc_rel_tangle + +gdc_debug_tangle: tangle + $(DUB) --compiler=gdc --config=spine-gdc-debug + +#+END_SRC + +******* ldc :ldc: +******** quick builds :quick: + +#+NAME: make_dub_compile_ldc_default +#+BEGIN_SRC makefile +ldc: dub_upgrade + $(DUB) --compiler=ldc2 --config=ldc --build=release + notify-send -t 0 'D ldc compiled test release executable ready' 'spine-ldc' + +ldc_debug: + $(DUB) --compiler=ldc2 --config=ldc --build=debug + +# assumes git tags with program version +ldc_ver: dub_upgrade + $(DUB) --compiler=ldc2 --config=ldc-version + mv bin/spine-ldc-ver bin-archive/spine-$(PROG_VER_DECLARED)-tag-$(PROG_VER_GIT)-ldc + notify-send -t 0 'D ldc2 compiled test release executable ready' 'spine-$(PROG_VER_DECLARED)-tag-$(PROG_VER_GIT)-ldc' + +ldc_clean_ver: clean tangle ldc_ver + +#+END_SRC + +******** clean & tangle :clean:tangle: + +#+NAME: make_dub_compile_ldc_release +#+BEGIN_SRC makefile +ldc_rel: expunge skel tangle + $(DUB) --compiler=ldc2 --config=spine-release + +ldc_rel_tangle: tangle + $(DUB) --compiler=ldc2 --config=spine-ldc + +ldc_rel_expunge_tangle: expunge skel tangle ldc_rel_tangle + +ldc_debug_tangle: tangle + $(DUB) --compiler=ldc2 --config=spine-ldc-debug + +#+END_SRC + +****** generic +******* init clean distclean etc. :clean: + +#+NAME: make_initialization_operations_parts +#+BEGIN_SRC makefile +reinit: clean skel tangle + +skel: + mkdir -p $(PRG_BINDIR); \ + mkdir -p $(PRG_BINDIR)-archive; \ + mkdir -p build; \ + mkdir -p views; \ + mkdir -p data; \ + 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; \ + mkdir -p $(PRG_SRCDIR)/$(PRG_NAME_DIR)/meta; \ + mkdir -p $(PRG_SRCDIR)/$(PRG_NAME_DIR)/share; \ + mkdir -p $(PRG_SRCDIR)/$(PRG_NAME_DIR); \ + mkdir -p $(PRG_BINDIR); + +init: skel + +clean: + rm -rf build; \ + rm -rf $(PRG_SRCDIR); \ + rm -rf $(PRG_DOCDIR); + +clean_bin: + rm $(PRG_BINDIR)/* + +clean_src: + rm -rf $(PRG_SRCDIR); + +clean_docs: + rm -rf $(PRG_DOCDIR) + +expunge: + rm -f dub.selections.json; \ + rm -rf build; \ + rm -rf $(PRG_SRCDIR); \ + rm -rf $(PRG_BINDIR); \ + rm -rf $(PRG_DOCDIR); + +distclean: expunge + +distclean_and_init: expunge + mkdir -p views; \ + 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 + +******* version :version: + +#+NAME: make_initialization_operations_git_version +#+BEGIN_SRC makefile +ver: + echo spine-$(PROG_VER_DECLARED)-tag-$(PROG_VER_GIT) + +#+END_SRC + +******* tangle build rebuild :clean:tangle:build: + +#+NAME: make_initialization_operations_assemble +#+BEGIN_SRC makefile +clean_tangle_build: clean tangle build + +tangle_build: tangle build + +build: $(PRG_SRCDIR)/$(PRG_SRC) + $(DC) $(DC_FLAGS) \ + $(DC_FLAG_BINOF)$(PRG_BINDIR)/$(PRG_BIN) \ + $(PRG_SRCDIR)/$(PRG_SRC) + +rebuild: $(PRG_SRCDIR)/$(PRG_SRC) $(PRG_BINDIR)/$(PRG_BIN).o clean build + +makefile_new: + make -k tangle_maker + +restart: clean tangle + +#+END_SRC + +**** get project dependencies + +#+NAME: make_get_project_dependencies_github +#+BEGIN_SRC makefile +get_depends: + hwd=$$(echo `pwd`) && \ + gwd="$${hwd}/src/ext_depends" && \ + dirs=$$(echo `ls -gx $${gwd}`) && \ + license_bsl="Boost Software License 1.0 (BSL-1.0)" && \ + echo $${hwd} && \ + echo $${gwd} && \ + echo $${deps} && \ + dub upgrade; \ + cd $${gwd} && \ + for dir in $${deps}; do \ + if [ -d $${dir} ]; then \ + echo $${dir} && \ + if [ "imageformats" == $${dir} ]; then \ + echo $${dir} && \ + rm -rf $${dir} && \ + git clone --depth=1 https://github.com/tjhann/$${dir} && \ + cd $${dir} && \ + echo $$PWD && \ + echo "$${dir} `git rev-parse HEAD | cut -c 1-8`" > ../$${dir}.meta && \ + echo "https://github.com/tjhann/$${dir}" >> ../$${dir}.meta && \ + echo "$${license_bsl}" >> ../$${dir}.meta && \ + cd $${gwd} && \ + rm -rf $${dir}/.git; \ + elif [[ "d2sqlite3" == $${dir} ]]; then \ + echo $${dir} && \ + rm -rf $${dir} && \ + git clone --depth=1 https://github.com/dlang-community/$${dir} && \ + cd $${dir} && \ + echo "$${dir} `git rev-parse HEAD | cut -c 1-8`" > ../$${dir}.meta && \ + echo "https://github.com/dlang-community/$${dir}" >> ../$${dir}.meta && \ + echo "$${license_bsl}" >> ../$${dir}.meta && \ + cd $${gwd} && \ + rm -rf $${dir}/.git; \ + fi; \ + fi; \ + done; \ + cd $${hwd} + +set_depends: get_depends + dub describe | sed 's~$(shell echo `pwd | sed 's_/_\\/_g'`)~.~g' > dub_describe.json + +rm_flakelock: + git reset HEAD flake.lock && \ + touch flake.lock \ + git rm -f flake.lock + +flake_update: + git add .; \ + nix flake lock && \ + git reset HEAD flake.lock; \ + cp flake.lock flake.lock_ + +flake_update_move_lock: flake_update + touch flake.lock \ + git rm -f flake.lock + +set_latest: set_depends flake_update rm_flakelock + +#+END_SRC + +gitDir=dub2nix; git clone --depth=1 https://github.com/lionello/${gitDir} | rm -rf ${gitDir}/.git + +**** _meson_ build :meson: + +meson using dub +- works & looks pretty clean +- but subprojects built externally & not suitable for debian packaging + +#+NAME: make_meson_build +#+BEGIN_SRC makefile +meson_clean_build_dir: + rm -r build; mkdir build + +meson_build: meson_clean_build_dir + meson --buildtype=debugoptimized build + ninja -C build + notify-send -t 0 'D meson build ldc compiled test release executable ready' 'spine' + +meson_redo: meson_clean_build_dir meson_build + +meson_project_build_clean: clean skel tangle dub_upgrade meson_build + +meson: meson_clean_build_dir dub_upgrade meson_build + +#+END_SRC + +**** testrun (program against document markup) :markup:sample: +***** pods :pod: +******* find files + +#+NAME: make_project_testrun_0_find_pods +#+BEGIN_SRC makefile +find_pods: + $(SiSU_MARKUP_SAMPLES_FIND_PODS) + +#+END_SRC + +**** org babel tangle batch process command :tangle: +***** tangle: org babel tangle *.org + +#+NAME: make_tangle_0 +#+BEGIN_SRC makefile +tangle: skel + for f in $(ORGFILELIST); do \ + ORGFILES="$$ORGFILES \"$$f\""; \ + done; \ + emacs --batch -Q -q \ + --eval "(progn \ + (add-to-list 'load-path \ + (expand-file-name \"$(EMACSLISP)\")) \ + (add-to-list 'load-path \ + (expand-file-name \"$(EMACSLISP_ORG)\" t)) \ + (add-to-list 'load-path \ + (expand-file-name \"$(EMACSLISP_ORG_CONTRIB)\" t)) \ + (require 'org)(require 'ob)(require 'ob-tangle) \ + (mapc (lambda (file) \ + (find-file (expand-file-name file \"$(ORGDIR)\")) \ + (setq-local org-src-preserve-indentation t) \ + (org-babel-tangle) \ + (kill-buffer)) '($$ORGFILES)))" 2>&1 + +#+END_SRC + +***** tangle maker: org babel tangle makefile new + +#+NAME: make_tangle_1 +#+BEGIN_SRC makefile +tangle_maker: + for f in $(ORGFILELIST); do \ + ORGFILES="\"org/dr_build_scaffold.org\""; \ + done; \ + emacs --batch -Q -q \ + --eval "(progn \ + (add-to-list 'load-path \ + (expand-file-name \"$(EMACSLISP)\")) \ + (add-to-list 'load-path \ + (expand-file-name \"$(EMACSLISP_ORG)\" t)) \ + (add-to-list 'load-path \ + (expand-file-name \"$(EMACSLISP_ORG_CONTRIB)\" t)) \ + (require 'org)(require 'ob)(require 'ob-tangle) \ + (mapc (lambda (file) \ + (find-file (expand-file-name file \".\")) \ + (setq-local org-src-preserve-indentation t) \ + (org-babel-tangle) \ + (kill-buffer)) '($$ORGFILES)))" 2>&1 + +#+END_SRC + +**** git snapshot + +#+NAME: make_git_snapshot +#+BEGIN_SRC makefile +gitsnapshot: distclean tangle + git commit -a + +#+END_SRC + +*** phony :phony: + +#+NAME: make_phony +#+BEGIN_SRC makefile +.PHONY : all build rebuild debug release \ + distclean init \ + tangle gitsnapshot + +#+END_SRC + +* dr spine_search +** spine_search makefile :makefile +*** tangle + +#+HEADER: :tangle ../makefile +#+HEADER: :noweb yes +#+BEGIN_SRC makefile +<<make_cgi_search_makefile>> +<<make_get_project_cgi_search_dependencies_github>> +#+END_SRC + +*** make + +#+NAME: make_cgi_search_makefile +#+BEGIN_SRC makefile +SpineBIN := "${SpineBIN}" # 'result/bin' +SpineOUT := "${SpineOUT}" # '/srv/www/spine' +SpinePOD := "${SpinePOD}" # '~/grotto/repo/git.repo/projects/project-spine/doc-reform-markup/spine-markup-samples/markup/pod' +SpineSearchAction := 'https://sisudoc.org/spine_search' +SpineCGIform := 'spine_search' +SpineSQLdb := 'spine.search.db' + +# nix build +build: + nix-build + +# cp cgi search form +cp-cgi: + sudo cp -vi /var/www/cgi/cgi-bin/spine_search /var/www/cgi/cgi-bin/spine_search_old && \ + sudo cp -vi result/share/cgi-bin/spine_search /var/www/cgi/cgi-bin/spine_search + +#+END_SRC + +*** get project dependencies + +#+NAME: make_get_project_cgi_search_dependencies_github +#+BEGIN_SRC makefile +get_depends: + hwd=$$(echo `pwd`) && \ + gwd="$${hwd}/src/ext_depends" && \ + dirs=$$(echo `ls -gx $${gwd}`) && \ + license_bsl="Boost Software License 1.0 (BSL-1.0)" && \ + echo $${hwd} && \ + echo $${gwd} && \ + echo $${deps} && \ + dub upgrade; \ + cd $${gwd} && \ + for dir in $${deps}; do \ + if [ -d $${dir} ]; then \ + echo $${dir} && \ + if [[ "arsd" == $${dir} ]]; then \ + echo $${dir} && \ + rm -rf $${dir} && \ + mkdir $${dir} && \ + aria2c -o "$${dir}/cgi.d" "https://raw.githubusercontent.com/adamdruppe/arsd/master/cgi.d" && \ + cd $${gwd}; \ + elif [[ "d2sqlite3" == $${dir} ]]; then \ + echo $${dir} && \ + rm -rf $${dir} && \ + git clone --depth=1 https://github.com/dlang-community/$${dir} && \ + cd $${dir} && \ + echo "$${dir} `git rev-parse HEAD | cut -c 1-8`" > ../$${dir}.meta && \ + echo "https://github.com/dlang-community/$${dir}" >> ../$${dir}.meta && \ + echo "$${license_bsl}" >> ../$${dir}.meta && \ + cd $${gwd} && \ + rm -rf $${dir}/.git; \ + fi; \ + fi; \ + done; \ + cd $${hwd} + +set_depends: get_depends + dub describe | sed 's~$(shell echo `pwd | sed 's_/_\\/_g'`)~.~g' > dub_describe.json + +#+END_SRC + +** .env/local + +#+HEADER: :NO-tangle ../sundry/spine_search_cgi/.env/local +#+BEGIN_SRC nix +export NIX_PATH=/nix/var/nix/profiles/per-user/root/channels/nixos +#+END_SRC + +* www dr spine latex + +- /srv/www/spine/latex + +** make + +** notes + +- vim {the_wealth_of_networks.yochai_benkler,two_bits.christopher_kelty,viral_spiral.david_bollier}.en.a4.portrait.tex +- emacs {the_wealth_of_networks.yochai_benkler,two_bits.christopher_kelty,viral_spiral.david_bollier}.en.a4.portrait.tex + +- evince the_wealth_of_networks.yochai_benkler.en.a4.portrait.pdf +- evince two_bits.christopher_kelty.en.a4.portrait.pdf +- evince viral_spiral.david_bollier.en.a4.portrait.pdf diff --git a/org/config_nix.org b/org/config_nix.org new file mode 100644 index 0000000..4081957 --- /dev/null +++ b/org/config_nix.org @@ -0,0 +1,1262 @@ +-*- mode: org -*- +#+TITLE: configuration nix +#+DESCRIPTION: makefile for spine +#+FILETAGS: :spine:build:tools: +#+AUTHOR: Ralph Amissah +#+EMAIL: [[mailto:ralph.amissah@gmail.com][ralph.amissah@gmail.com]] +#+COPYRIGHT: Copyright (C) 2015 - 2022 Ralph Amissah +#+LANGUAGE: en +#+STARTUP: content hideblocks hidestars noindent entitiespretty +#+PROPERTY: header-args :exports code +#+PROPERTY: header-args+ :noweb yes +#+PROPERTY: header-args+ :results no +#+PROPERTY: header-args+ :cache no +#+PROPERTY: header-args+ :padline no +#+PROPERTY: header-args+ :mkdirp yes +#+OPTIONS: H:3 num:nil toc:t \n:t ::t |:t ^:nil -:t f:t *:t + +* nix :nix: + +#+NAME: nixpkgs_local +#+BEGIN_SRC sh +/srv/nix/nixpkgs +#+END_SRC + +** NOTES +*** nix-shell + +- default.nix + +#+BEGIN_SRC sh +nix-shell +nix-build +#+END_SRC + +- project.nix + +#+BEGIN_SRC sh +nix-shell +nix-build project.nix +#+END_SRC + +*** nix-shell --pure + +- default.nix + +#+HEADER: :noweb yes +#+BEGIN_SRC sh +nix-shell --pure +nix-build -I nixpkgs=<<nixpkgs_local>> +nix-build -I .envrc +#+END_SRC + +#+BEGIN_SRC sh +nix build -f default.nix --print-build-logs +nix build -f derivation.nix --print-build-logs +nix shell -f default.nix --print-build-logs +# nix build -f project.nix +# nix build -f spine.nix +nix develop --build -f derivation.nix -I .envrc --print-build-logs +#+END_SRC + +*** derivation .drv + +#+BEGIN_SRC sh +nix show-derivation /nix/store/q7n14bm8j5vzm62qaraczdb4bpyf59vv-spine-0.11.1.drv +#+END_SRC + +** spine + +- default.nix +- shell.nix + +*** envrc :envrc: +**** .envrc + +- https://github.com/nix-community/nix-direnv + - source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/${NixDirEnvVersion}/direnvrc" "sha256-0000000000000000000000000000000000000000000=" + +#+HEADER: :tangle ../.envrc +#+BEGIN_SRC sh +use flake . +NIX_ENFORCE_PURITY=1 +NixDirEnvVersion="2.2.0" +if ! has nix_direnv_version || ! nix_direnv_version ${NixDirEnvVersion}; then +# - https://github.com/nix-community/nix-direnv +# source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/${NixDirEnvVersion}/direnvrc" "sha256-0000000000000000000000000000000000000000000=" + source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/${NixDirEnvVersion}/direnvrc" "sha256-5EwyKnkJNQeXrRkYbwwRBcXbibosCJqyIUuz9Xq+LRc=" +fi +if [ -f .envrc-local ]; then + source_env_if_exists .envrc-local || source .envrc-local +fi +#+END_SRC + +**** .envrc-local CHECK MODIFY + +- bespoke modify appropriately and generate if needed + +#+HEADER: :tangle ../.envrc-local_ +#+HEADER: :noweb yes +#+BEGIN_SRC sh +# reload when these files change +watch_file flake.lock +watch_file flake.nix +nix flake update; nix flake check; nix flake show +#use flake .#default +export NIX_PATH=/nix/var/nix/profiles/per-user/root/channels/nixos +#export NIX_PATH=nixpkgs=/srv/nix/nixpkgs +export DFLAGS="-O2 -inline -boundscheck=on -color=on" +## load the flake devShell +# eval "$(nix print-dev-env)" +# echo $NIX_BUILD_TOP +export Date=`date "+%Y%m%d"` +export SpineVER=$(git describe --long --tags | sed 's/^[ a-z_-]\+\([0-9.]\+\)/\1/;s/\([^-]*-g\)/r\1/;s/-/./g') +export SpinePROJ=~/grotto/repo/git.repo/projects/doc-reform/code/software/spine-search +export SpineSRC=$SpinePROJ/src +#export SpineBIN=$SpinePROJ/result/bin +export SpineDOC=~/grotto/repo/git.repo/projects/project-spine/doc-reform-markup/spine-markup-samples +export SpinePOD=$SpineDOC/markup/pod +#export SpineOUTversioned=/srv/www/spine/$SpineVER +export SpineOUT=/srv/www/spine +export SpineDBpath=/var/www/sqlite +export SpineCgiBIN=/var/www/cgi/cgi-bin +#+END_SRC + +*** makefile + +#+HEADER: :tangle ../makefile_ +#+BEGIN_SRC make +buildPhase: + HOME=$${PWD}; \ + for DC_ in dmd ldmd2 gdmd; do \ + echo "- check for D compiler $${DC_}"; \ + DC=$$(type -P $${DC_} || echo ""); \ + if [ ! "$${DC}" == "" ]; then \ + break; \ + fi; \ + done; \ + echo "D compiler = $${DC}"; \ + if [ "$${DC}" == "" ]; then \ + echo "Error: could not find D compiler"; \ + exit 1; \ + fi; \ + echo "$${DC_} used as D compiler to build $${pname}"; \ + export DFLAGS="-O2 -inline"; \ + dub build --compiler=$${DC} --build=release --combined --skip-registry=all; +checkPhase: + runHook preCheck; \ + HOME=$${PWD}; \ + dub test --combined --skip-registry=all; \ + runHook postCheck +installPhase: + runHook preInstall; \ + mkdir -p $${out}/bin; \ + install -m755 ./bin/spine $${out}/bin/spine; \ + runHook postInstall + #cp -r bin/spine $out/bin/. +postInstall: + echo "$${out}/share/cgi-bin"; \ + echo `ls -la $${out}/bin/spine` +#+END_SRC + +*** flake :flake: +**** flake static :flake:static: +***** flake.nix + +#+HEADER: :tangle ../flake.nix +#+HEADER: :noweb yes +#+BEGIN_SRC nix +{ + description = "a sisu like document parser search form"; + inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; # "github:nixos/nixpkgs"; "github:NixOS/nixpkgs/nixpkgs-unstable"; "nixpkgs/nixos-unstable"; "nixpkgs/nixos-21.11"; + inputs.flake-utils.url = "github:numtide/flake-utils"; + outputs = { self, nixpkgs, flake-utils }: + let + version = "<<spine_version_set>>"; + supportedSystems = [ "x86_64-linux" ]; # [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ]; + forAllSystems = nixpkgs.lib.genAttrs supportedSystems; + nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; }); # nixpkgs instantiated for supported system types. + in { + packages = forAllSystems (system: + let pkgs = nixpkgsFor.${system}; + in with pkgs; { + default = stdenv.mkDerivation { + pname = "spine_search"; + inherit version; + executable = true; + src = self; + shell = ./default.nix; + devEnv = ./devenv.nix; + buildInputs = [ sqlite ]; + nativeBuildInputs = [ dub ldc ]; # [ dub dmd ]; [ dub ldc ]; [ dub gdc ]; + <<flake_phases>> + }; + #vendorSha256 = "sha256-0Q00000000000000000000000000000000000000000="; + }); + devShells = forAllSystems (system: + let pkgs = nixpkgsFor.${system}; + in with pkgs; { + devShell = mkShell { buildInputs = [ git dub dmd ldc gdc sqlite ]; }; + }); + }; +} +#+END_SRC + +**** flakes +***** flake single system + +#+NAME: flake_single_sytem +#+HEADER: :noweb yes +#+BEGIN_SRC nix +{ + description = "a sisu like document parser search form"; + inputs.<<flake_inputs_nix>> + outputs = { <<flake_outputs>> }: { + packages.x86_64-linux.spine_search = + let + pkgs = import nixpkgs { + system = "x86_64-linux"; + }; + #targetOf = package: "${package.targetPath or "."}/${package.targetName or package.name}"; + in pkgs.stdenv.mkDerivation { + <<flake_metadata>> + inherit self; + src = self; + #shell = ./shell.nix; + shell = ./default.nix; + devEnv = ./devenv.nix; + <<flake_phases>> + buildInputs = [ sqlite ]; + nativeBuildInputs = with pkgs; [ dub ldc ]; + }; + packages.x86_64-linux.default = self.packages.x86_64-linux.spine_search; + }; +} +#+END_SRC + +***** flake (multi-system) + +#+NAME: flake_multi_system_possible +#+HEADER: :noweb yes +#+BEGIN_SRC nix +{ + description = "a sisu like document parser search form"; + inputs.<<flake_inputs_nix>> + outputs = { <<flake_outputs>> }: + let + version = "<<spine_version_set>>"; + supportedSystems = [ "x86_64-linux" ]; # [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ]; + # helper function to generate an attrset '{ x86_64-linux = f "x86_64-linux"; ... }'. + forAllSystems = nixpkgs.lib.genAttrs supportedSystems; + nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; }); # nixpkgs instantiated for supported system types. + <<flake_devshells>> + in { + packages = forAllSystems (system: + let + pkgs = nixpkgsFor.${system}; + in { + default = pkgs.stdenv.mkDerivation { + pname = "spine_search"; + inherit version; + src = self; + shell = ./default.nix; + devEnv = ./devenv.nix; + buildInputs = [ sqlite ]; + nativeBuildInputs = with pkgs; [ dub ldc ]; # [ dub dmd ]; [ dub ldc ]; [ dub gdc ]; + <<flake_phases>> + }; + #vendorSha256 = "sha256-0Q00000000000000000000000000000000000000000="; + }); + }; +} +#+END_SRC + +*** flake :flake: +**** notes? + +- flake.nix + /srv/nix/nixpkgs + ./shell.nix + - shell.nix + ./pkgs/shell-pkgs.nix + - pkgs/shell-pkgs.nix + - default.nix + ./nix/dub.selections.nix # + - dub.selections.nix + +- nix develop + +- nix flake update + +- nix shell -f default.nix --print-build-logs +- nix shell -c default.nix + +- nix build `nix-instantiate` +- nix build -f default.nix --print-build-logs +- nix shell -f default.nix --print-build-logs +- nix develop --build -f derivation.nix -I .envrc --print-build-logs +- nix develop --profile .#default --print-build-logs --command spine -v + +- nix search --json 2>/dev/null |jq +- nix flake show +- nix show-derivation + +# nix-instantiate | nix-build + +#nix flake update +#nix flake check +#nix flake show +#nix develop +#nix build .#default --print-build-logs + + +#+BEGIN_SRC nix +src = fetchTarball { + url = "file:///[path]/$(pname)-$(version).tar.gz"; + sha256 = "sha256:0000000000000000000000000000000000000000000000000000"; +}; +#+END_SRC + +**** flake parts +***** flake metadata + +#+NAME: flake_metadata +#+HEADER: :noweb yes +#+BEGIN_SRC nix +pname = "spine_search"; +version = "<<spine_version_set>>"; +description = "a sisu like document parser search form"; +#+END_SRC + +***** flake inputs +****** flake inputs static + +#+NAME: flake_inputs_nix +#+HEADER: :noweb yes +#+BEGIN_SRC nix +nixpkgs.url = "github:nixos/nixpkgs"; +flake-utils.url = "github:numtide/flake-utils"; +#+END_SRC + +***** flake outputs +****** flake outputs static + +#+NAME: flake_outputs +#+HEADER: :noweb yes +#+BEGIN_SRC nix +self, nixpkgs, flake-utils +#+END_SRC + +***** flake devshells + +#+NAME: flake_devshells +#+HEADER: :noweb yes +#+BEGIN_SRC nix +devShells = forAllSystems (system: + let pkgs = nixpkgsFor.${system}; + in { + default = pkgs.mkShell { + buildInputs = with pkgs; [ git dub dmd ldc sqlite ]; + }; +}); +#+END_SRC + +***** flake phases + +#+NAME: flake_phases +#+HEADER: :noweb yes +#+BEGIN_SRC nix +buildPhase = '' + runHook preBuild + HOME="$PWD" + for DC_ in dmd ldmd2 ldc2 gdc gdmd; do + echo "- check for D compiler $DC_" + DC=$(type -P $DC_ || echo "") + if [ ! "$DC" == "" ]; then break; fi + done + if [ "$DC" == "" ]; then exit "Error: could not find D compiler"; fi + echo "$DC_ used as D compiler to build $pname" + dub build --compiler=$DC --build=$DC_ --combined --skip-registry=all + runHook postBuild +''; +checkPhase = '' + runHook preCheck + HOME="$PWD" + dub test --combined --skip-registry=all + runHook postCheck +''; +installPhase = '' + runHook preInstall + mkdir -p $out/share/cgi-bin + install -m755 -D ./cgi-bin/spine_search $out/share/cgi-bin/spine_search + runHook postInstall +''; +postInstall = '' + echo `ls -la $out/share/cgi-bin/spine_search` + echo " + nix build or nix develop? (suggestions): + - nix build + nix build .#default --print-build-logs + nix flake update; nix build .#default --print-build-logs + nix build --print-build-logs + - nix run + nix run .#default --print-build-logs + nix run default.nix --print-build-logs + - nix shell + nix shell .#default --print-build-logs --command spine -v + - nix develop + nix develop --profile .#default --print-build-logs --command spine -v + nix develop ; eval \"$buildPhase\" + nix develop --build -f derivation.nix -I .envrc --print-build-logs + - nix profile install . --print-build-logs + nix-instantiate | nix show-derivation | jq + " +''; +#+END_SRC + +*** shell.nix :shell: +**** tangle + +#+HEADER: :tangle ../shell.nix +#+HEADER: :tangle-mode (identity #o755) +#+HEADER: :shebang "#!/usr/bin/env -S nix-shell --pure\n#!nix-shell -i bash" +#+HEADER: :noweb yes +#+BEGIN_SRC nix +{ pkgs ? import <nixpkgs> {} }: +with pkgs; +mkShell { + buildInputs = [ + direnv + nixVersions.unstable #nixFlakes + nix-prefetch-git + validatePkgConfig + nix-tree jq nix-output-monitor + git + ps + ### d_build_related + dub + ## compiler + ldc + rund + ## linker + #lld + #mold + ## builder + #ninja + #meson + ### sqlite search related + sqlite + ### tools + #aria #wget #curl + ### candy + #starship + ]; + shellHook = '' + #if [[ -f ".envrc" ]]; then + # source .envrc + #fi + nix flake update + echo "" + echo "nix flake metadata:" + nix flake metadata + echo "" + echo "nix flake check:" + nix flake check + echo "" + echo "nix flake show:" + nix flake show + echo " + nix flake update + nix flake metadata + nix flake check + nix flake show + + nix build or nix develop? (suggestions): + + - nix build + nix build .#default --print-build-logs + nix build --print-build-logs + nix build .#default --print-build-logs |& nom + + - nix run + nix run .#default --print-build-logs + nix run default.nix --print-build-logs + + - nix shell + nix shell --print-build-logs + + - nix develop + nix develop --build .#default --print-build-logs + nix develop --build -f derivation.nix -I .envrc --print-build-logs + nix develop ; eval \$buildPhase + + nix-build |& nom + + nix-instantiate | nix show-derivation | jq + nix-build . --no-out-link | xargs -o nix-tree + nix-tree --derivation .#spine_search + + dub build --compiler=ldmd --build=release --combined --skip-registry=all + " + ''; +} +#+END_SRC + +echo "ldc `${pkgs.ldc}/bin/ldc2 -v`" + +**** Notes + +#+BEGIN_SRC text +#% Notes + +# - shell.nix -I .envrc +# - shell.nix -I .envrc --pure + +# [ nix-shell ] + + # - nix-shell -I nixpkgs=/srv/nix/nixpkgs --pure + # - nix-shell -p "with import /srv/nix/nixpkgs {}; ldc" --pure + # - nix-shell -p "with import /srv/nix/nixpkgs {}; [dub ldc]" --pure + + # - nix-shell -p nixVersions.unstable #nixFlakes + # - nix-shell -p nixFlakes --pure + # - nix-shell -p nixFlakes --pure -p "with import /srv/nix/nixpkgs {}; [nix dub ldc git ps]" + # - nix-shell shell.nix direnv: export +IN_NIX_SHELL + # - nix-shell shell.nix + +# [ nix-build ] + + # - nix-build -I nixpkgs=/srv/nix/nixpkgs # --pure + # - nix-build -I .envrc --pure + # - nix-build default.nix -I .envrc && result/bin/spine -v + +# [ nix-instantiate ] + + # - nix-instantiate | nix show-derivation | jq + # - nix-instantiate -I .envrc | nix show-derivation -f derivation.nix -I .envrc | jq + # - nix-instantiate | nix show-derivation --recursive | jq + # - nix-instantiate -I .envrc | nix show-derivation -f derivation.nix --recursive -I .envrc | jq + # - nix-instantiate | nix-build + # - nix-instantiate -I .envrc | nix-build -I .envrc + +# [ nix shell ] + + # - nix shell -c default.nix + # - nix shell -f default.nix --print-build-logs + +# [ nix build ] + + # - nix build -I .envrc --print-build-logs + # - nix build -f default.nix --print-build-logs + # - nix build -f derivation.nix --print-build-logs + + # - nix build `nix-instantiate` + # - nix build `nix-instantiate -I .envrc` + + # - nix build -f default.nix && ./result/bin/spine -v && noti -t "spine build" -m "see ./result/bin/spine" + # - nix build .#spine + +# [ nix run ] + + # - nix run default.nix --print-build-logs + # - nix run -I .envrc default.nix --print-build-logs + # - nix run .#spine + +# - nix-shell -I .envrc --pure +# - nix develop --build -f derivation.nix -I .envrc --print-build-logs + +# - nix-shell -p nixFlakes --pure -p "with import /srv/nix/nixpkgs {}; [nix dub ldc git ps]" +# - nix-build +# - nix build `nix-instantiate -I .envrc` + +# - nix develop --build -f default.nix -I .envrc + +# - nix-shell -I .envrc --pure +# - nix-build default.nix -I .envrc && result/bin/spine -v + +# - nix shell -f default.nix --print-build-logs +# - nix-instantiate -I .envrc | nix-build -I .envrc +#+END_SRC + +#+BEGIN_SRC text +#% Notes +- nix-shell + +- shell.nix --pure +- shell.nix --pure -I .envrc + +- nix-shell --pure -I nixpkgs=<<nixpkgs_local>> +- nix-shell --pure -p "with import <<nixpkgs_local>> {}; ldc" +- nix-shell --pure -p "with import /srv/nix/nixpkgs {}; [dub ldc]" + +- shell.nix direnv: export +IN_NIX_SHELL + +- nix-shell -p nixFlakes +- nix-shell -p nixFlakes --pure +- nix-shell -p nixFlakes --pure -p "with import /srv/nix/nixpkgs {}; [dub ldc]" + +- shell.nix -I .envrc +- nix-shell -I nixpkgs=<provide local nix path> +- nix-shell -I nixpkgs=<provide local nix path> --pure +- shell.nix +- nix-shell shell.nix --pure + +- nix shell -c default.nix + +- nix run default.nix --print-build-logs +- nix run -I .envrc default.nix --print-build-logs + +- nix develop + +- nix-build -I nixpkgs=<provide local nix path> +- nix-build -I .envrc + +- nix build -f default.nix --print-build-logs +- nix build -f derivation.nix --print-build-logs +- nix build -I .envrc --print-build-logs +- nix shell -f default.nix --print-build-logs +- nix develop --build -f derivation.nix -I .envrc --print-build-logs + +- buildPhase + +- nix build -f default.nix && noti +- nix build -f default.nix && ./result/bin/spine -v && noti -t "spine build" -m "see ./result/bin/spine" +- nix develop --build -f derivation.nix -I .envrc --print-build-logs + + ./result/bin/spine +#+END_SRC + +**** shell parts (packages) +***** packages nix related + +#+NAME: shell_packages_nix_related +#+BEGIN_SRC nix +### nix_related +direnv +nixVersions.unstable #nixFlakes +nix-prefetch-git +validatePkgConfig +jq +git +ps +#+END_SRC + +***** packages d build related + +#+NAME: shell_packages_d_build_related +#+BEGIN_SRC nix +### d_build_related +## package manager +dub +## compiler +ldc +rund +## linker +#lld +#mold +## builder +#ninja +#meson +#+END_SRC + +***** packages tools + +#+NAME: shell_packages_tool_download +#+BEGIN_SRC nix +### tools +#curl +#wget +aria +#+END_SRC + +***** packages candy + +#+NAME: shell_packages_candy +#+BEGIN_SRC nix +### candy +starship +#+END_SRC + +***** packages search sqlite related + +#+NAME: shell_packages_search_related_sqlite +#+BEGIN_SRC nix +### sqlite search related +sqlite +#+END_SRC + +***** packages pdf latex related + +#+NAME: shell_packages_pdf_latex_related +#+BEGIN_SRC nix +### pdf_latex_related +source-sans-pro +source-serif-pro +source-code-pro +texlive.combined.scheme-full +#+END_SRC + +***** packages xml epub related + +#+NAME: shell_packages_xml_and_epub_related +#+BEGIN_SRC nix +### xml_and_epub_related +libxml2 +html-tidy +xmlstarlet +epubcheck +ebook_tools +epr +sigil +calibre #(suite includes: ebook-viewer) +foliate +#+END_SRC + +***** packages i18n_translation related + +#+NAME: shell_packages_i18n_translation +#+BEGIN_SRC nix +### i18n translation related +perl534Packages.Po4a +#+END_SRC + +*** default.nix :default: + +- default.nix -I nixpkgs=<provide local nix path> + e.g. default.nix -I nixpkgs=/srv/nix/nixpkgs + +- nix-build -I nixpkgs=<provide local nix path> + e.g. nix-build -I nixpkgs=<<nixpkgs_local>> + +#+HEADER: :noweb yes +#+BEGIN_SRC sh +nix-build -I nixpkgs=<<nixpkgs_local>> +nix-build -I .envrc-local +nix-build -I .envrc +default.nix -I .envrc +default.nix + +nix build -f default.nix --print-build-logs +nix build -f derivation.nix --print-build-logs +nix shell -f default.nix --print-build-logs +nix develop --build -f derivation.nix -I .envrc --print-build-logs + +# nix build -f project.nix +# nix build -f spine.nix +#+END_SRC + +#+HEADER: :tangle ../default.nix +#+HEADER: :tangle-mode (identity #o755) +#+HEADER: :shebang "#!/usr/bin/env -S nix-build" +#+BEGIN_SRC nix +{ pkgs ? import <nixpkgs> {} }: +pkgs.callPackage ./devenv.nix {} +#+END_SRC + +#+HEADER: :tangle-mode (identity #o755) +#+HEADER: :shebang "#!/usr/bin/env -S nix-build" +#+BEGIN_SRC nix +{ pkgs ? import <nixpkgs> {} }: +pkgs.callPackage ./derivation.nix {} +#+END_SRC + +*** devenv.nix :default:devenv: + +#+HEADER: :tangle ../devenv.nix +#+HEADER: :tangle-mode (identity #o755) +#+BEGIN_SRC nix +{ pkgs ? import <nixpkgs> { }, name ? "user-env" }: with pkgs; +buildEnv { + inherit name; + extraOutputsToInstall = [ "out" "man" "lib" ]; # to get all needed symlinks + paths = [ + #nix # if not on NixOS, this is needed + direnv + nixVersions.unstable #nixFlakes + nix-prefetch-git + validatePkgConfig + nix-tree jq nix-output-monitor + git + ps + ### d_build_related + dub + ## compiler + dmd + ldc + #gdc + #rund + ## linker + #lld + #mold + ## builder + #ninja + #meson + ### sqlite search related + sqlite + # this will create a script that will rebuild and upgrade your setup; using shell script syntax + (writeScriptBin "nix-rebuild" '' + #!${stdenv.shell} + cd <path-to-flake> || exit 1 + nix flake update + nix profile upgrade '.*' + '') + # puts in your root the nixpkgs version + (writeTextFile { + name = "nixpkgs-version"; + destination = "/nixpkgs-version"; + text = lib.version; + }) + ]; +} +#+END_SRC + +*** derivation.nix :default: + +#+HEADER: :tangle ../derivation.nix +#+HEADER: :tangle-mode (identity #o644) +#+HEADER: :noweb yes +#+BEGIN_SRC nix +{ pkgs ? import <nixpkgs> {}, + stdenv ? pkgs.stdenv, + lib ? pkgs.lib, + ldc ? null, + dcompiler ? pkgs.ldc, + dub ? pkgs.dub +}: +assert dcompiler != null; +with ( + with lib; + let + filterDub = name: type: let baseName = baseNameOf (toString name); in ! ( # filter function to remove the .dub package folder from src + type == "directory" && baseName == ".dub" + ); + targetOf = package: "${package.targetPath or "."}/${package.targetName or package.name}"; + # remove reference to build tools and library sources + disallowedReferences = deps: [ dcompiler dub ]; + removeExpr = refs: ''remove-references-to ${lib.concatMapStrings (ref: " -t ${ref}") refs}''; + in { + mkDubDerivation = lib.makeOverridable ({ + src, + nativeBuildInputs ? [], + dubJSON ? src + "/dub.json", + passthru ? {}, + package ? lib.importJSON dubJSON, + ... + } @ attrs: stdenv.mkDerivation (attrs // { + pname = package.name; + nativeBuildInputs = [ dcompiler dub pkgs.removeReferencesTo ] ++ nativeBuildInputs; + disallowedReferences = disallowedReferences deps; + passthru = passthru // { + inherit dub dcompiler pkgs; + }; + src = lib.cleanSourceWith { + filter = filterDub; + src = lib.cleanSource src; + }; + preFixup = '' + find $out/share/cgi-bin -type f -exec ${removeExpr (disallowedReferences deps)} '{}' + || true + ''; + buildPhase = '' + runHook preBuild + HOME="$PWD" + DFLAGS="-O2 -inline" + for DC_ in dmd ldmd2 gdmd; do + echo "- check for D compiler $DC_" + DC=$(type -P $DC_ || echo "") + if [ ! "$DC" == "" ]; then + break + fi + done + if [ "$DC" == "" ]; then + exit "Error: could not find D compiler" + fi + echo "$DC_ used as D compiler to build $pname" + dub build --compiler=$DC --build=release --combined --skip-registry=all + runHook postBuild + ''; + checkPhase = '' + runHook preCheck + HOME="$PWD" + dub test --combined --skip-registry=all + runHook postCheck + ''; + installPhase = '' + runHook preInstall + mkdir -p $out/share/cgi-bin + cp -r "${targetOf package}" $out/share/cgi-bin + install -m755 -D $out/share/cgi-bin/spine_search spine_search + runHook postInstall + ''; + postInstall = '' + echo "HERE ${targetOf package} $out/share/cgi-bin" + echo `ls -la $out/share/cgi-bin/spine_search` + ''; + meta = lib.optionalAttrs (package ? description) { + description = package.description; + } // attrs.meta or {}; + } // lib.optionalAttrs (!(attrs ? version)) { + name = package.name; # use name from dub.json, unless pname and version are specified + })); + } +); +mkDubDerivation rec { + name = "spine-search-${version}"; + #version = "<<spine_version_set>>"; + src = ./.; + buildInputs = [ + pkgs.sqlite ( + with pkgs; [ + nixVersions.unstable #nixFlakes + ## package manager + dub + ## compiler + ldc + rund + ## linker + #lld + #mold + ## builder + #ninja + sqlite + ] + ) + ]; + meta = with pkgs.lib; { + pname = "spine-search"; + version = "<<spine_version_set>>"; + homepage = "https://sisudoc.org"; + description = "cgi sqlite search form for document object search"; + longDescription = '' + a sisu like parser and document generator + ''; + homepage = "https://sisudoc.org"; + license = licenses.agpl3Plus; + platforms = platforms.linux; + maintainers = [ "RalphAmissah" ]; + }; +} +#+END_SRC + +- unused + - installPhase + +#+BEGIN_SRC txt +installPhase = '' + mkdir -p $out/bin + cp spine $out/bin + chmod +x $out/bin/spine +''; +#+END_SRC + +*** project meta + +#+NAME: nix_project_meta +#+HEADER: :noweb yes +#+BEGIN_SRC nix +meta = with pkgs.lib; { + pname = "spine"; + version = "<<spine_version_set>>"; + description = "a sisu like document parser"; + longDescription = '' + A sisu like parser and document generator + ''; + homepage = "https://sisudoc.org"; + license = licenses.agpl3Plus; + platforms = platforms.linux; + maintainers = [ "RalphAmissah" ]; +}; +#+END_SRC + +*** dub.selections.json + +#+HEADER: :NO-tangle ../dub.selections.json +#+BEGIN_SRC nix +{ + "fileVersion": 1, + "versions": { + "d2sqlite3": "0.19.1", + "dyaml": "0.8.3", + "imageformats": "7.0.2", + "tinyendian": "0.2.0" + } +} +#+END_SRC + +*** dub.selections.nix + +#+HEADER: :NO-tangle ../nix/dub.selections.nix +#+BEGIN_SRC nix +# This file was generated by https://github.com/lionello/dub2nix v0.2.3 +[ { + fetch = { + type = "git"; + url = "https://github.com/dlang-community/d2sqlite3.git"; + rev = "v0.19.1"; + sha256 = "0rnsgla6xyr8r34knf7v6dwhacra96q1b5rhxcz9246inwhvrk5k"; + fetchSubmodules = false; + date = "2020-07-21T12:32:51+02:00"; + deepClone = false; + leaveDotGit = false; + path = "/nix/store/hsi8xvl15w6fwlqvs042m1z5i88yc72i-d2sqlite3"; + }; +} { + fetch = { + type = "git"; + url = "https://github.com/kiith-sa/tinyendian.git"; + rev = "v0.2.0"; + sha256 = "086gf5aga52wr5rj2paq54daj8lafn980x77b706vvvqaz2mlis8"; + fetchSubmodules = false; + date = "2018-06-10T11:04:28+02:00"; + deepClone = false; + leaveDotGit = false; + path = "/nix/store/9c7fsmi5am84j6dq2mp3va306x3ay291-tinyendian"; + }; +} { + fetch = { + type = "git"; + url = "https://github.com/kiith-sa/D-YAML.git"; + rev = "v0.8.3"; + sha256 = "13wy304xjbwkpgg7ilql1lkxkm83s87jm59ffnrg26slp7cx149q"; + fetchSubmodules = false; + date = "2020-09-19T23:46:57+02:00"; + deepClone = false; + leaveDotGit = false; + path = "/nix/store/3i8i56lkmw2xq3lxr5h66v909waq2mqg-D-YAML"; + }; +} { + fetch = { + type = "git"; + url = "https://github.com/lgvz/imageformats.git"; + rev = "v7.0.2"; + sha256 = "1mfbsmi4fs1xny4zqs6jyr04d5f4h03r9f6jadvkdqj5kd1k0ws7"; + fetchSubmodules = false; + date = "2019-10-10T07:54:45+03:00"; + deepClone = false; + leaveDotGit = false; + path = "/nix/store/wn554pn21nzmpvw2hs7hvv9v9y0sgarg-imageformats"; + }; +} ] +#+END_SRC + +*** dub2nix & shared pkgs SHARED +**** dub2nix with pkgs shared + +#+NAME: nix_with_pkgs +#+HEADER: :noweb yes +#+BEGIN_SRC nix +with pkgs; [ + <<nix_shell_with_pkgs_list>> +] +#+END_SRC + +**** with pkgs list + +#+NAME: nix_shell_with_pkgs_list +#+BEGIN_SRC nix +nixVersions.unstable #nixFlakes +rund +dub +ldc +sqlite +nix-prefetch-git +validatePkgConfig +jq +git +#+END_SRC + +** variables +*** spine version SET VERSION :version:set:project: + +#+NAME: spine_version_set +#+BEGIN_SRC sh +0.12.0 +#+END_SRC + +*** set names SET + +#+NAME: spine_search_db +#+BEGIN_SRC sh +spine.search.db +#+END_SRC + +#+NAME: spine_search_cgi +#+BEGIN_SRC sh +spine_search +#+END_SRC + +*** nixpkgs_path SETUP +**** nixpkgs select path SELECT + +#+NAME: nixpkgs_path +#+HEADER: :noweb yes +#+BEGIN_SRC nix +<<nixpkgs_path_local>> +#+END_SRC + +**** nixpkgs path options + +- <nixpkgs> + +#+NAME: nixpkgs_path_default +#+HEADER: :noweb yes +#+BEGIN_SRC nix +<nixpkgs> +#+END_SRC + +#+NAME: nix_path_directory +#+HEADER: :noweb yes +#+BEGIN_SRC nix +nixpkgs=<<nixpkgs_path_local>> +#+END_SRC + +#+NAME: project_path_local_project +#+HEADER: :noweb yes +#+BEGIN_SRC nix +~/grotto/repo/git.repo/projects/project-spine/doc-reform +#+END_SRC + +#+NAME: project_path_local_src +#+HEADER: :noweb yes +#+BEGIN_SRC nix +<<project_path_local_project>>/src +#+END_SRC + +#+NAME: project_path_local_bin +#+HEADER: :noweb yes +#+BEGIN_SRC nix +<<project_path_local_project>>/result/bin +#+END_SRC + +#+NAME: project_path_cgi_bin +#+BEGIN_SRC nix +/var/www/cgi/cgi-bin +#+END_SRC + +#+NAME: project_path_local_doc +#+BEGIN_SRC nix +~/grotto/repo/git.repo/projects/project-spine/doc-reform-markup/spine-markup-samples +#+END_SRC + +#+NAME: project_path_local_out +#+BEGIN_SRC nix +/srv/www/spine/$SpineVER +#+END_SRC + +#+NAME: project_path_local_out_ +#+HEADER: :noweb yes +#+BEGIN_SRC nix +/tmp/spine/$SpineVER/www +#+END_SRC + +#+NAME: project_path_local_out_static +#+HEADER: :noweb yes +#+BEGIN_SRC nix +/srv/www/spine +#+END_SRC + +#+NAME: project_path_local_out_static_ +#+BEGIN_SRC nix +/var/www +#+END_SRC + +#+NAME: project_path_sqlite +#+BEGIN_SRC nix +/var/www/sqlite +#+END_SRC + +#+NAME: nixpkgs_url +#+BEGIN_SRC nix +github:nixos/nixpkgs +#+END_SRC + +#+HEADER: :noweb yes +#+BEGIN_SRC nix +<<nixpkgs_path_local>> +#+END_SRC + +- local path SET WARN + +#+NAME: nixpkgs_path_local +#+BEGIN_SRC nix +/srv/nix/nixpkgs +#+END_SRC + +**** project path options + +- local path SET WARN + +#+NAME: nix_path_channel +#+BEGIN_SRC nix +/nix/var/nix/profiles/per-user/root/channels/nixos +#+END_SRC + +** texlive xetex xelatex shell.nix +*** shell.nix :shell: + +#+BEGIN_SRC nix +#!/usr/bin/env -S nix-shell --pure +{ pkgs ? import <nixpkgs> {} }: +pkgs.mkShell { + buildInputs = with pkgs; [ + nixVersions.unstable #nixFlakes + nix-prefetch-git + validatePkgConfig + jq + git + fontconfig + source-sans-pro + source-serif-pro + source-code-pro + #(texlive.combine { + # inherit (texlive) scheme-tetex xetex fontspec footmisc multirow titlesec listings anysize float graphics helvetic times courier; + #}) + texlive.combined.scheme-full + dejavu_fonts dejavu_fontsEnv + liberation_ttf + evince + zathura + apvlv + ]; + #FONTCONFIG_FILE = makeFontsConf { fontDirectories = [ + # liberation_ttf + #]; + shellHook = '' + if [[ -f ".envrc" ]]; then + source .envrc + fi + #for texfile in *.tex; do xelatex -interaction=nonstopmode $texfile; done + #for texfile in *.tex; do xelatex -interaction=batchmode $texfile; done + ''; +} +#+END_SRC + +*** notes + +#+BEGIN_SRC sh +nix-shell --run 'which xetex' +echo 'for texfile in *.tex; do echo "* --> " ~ $texfile && xelatex -interaction=batchmode $texfile; rm *.aux *.log *.toc *.out; done' + +$SpineBIN/spine --latex --serial --output="$SpineOUT" $SpinePOD/* && for texfile in $SpineOUT/latex/*.tex; do xelatex -interaction=nonstopmode $texfile; done 2>&1 | tee _err.xelatex_.org; ls $SpineOUT/latex/*.{tex,pdf} + +/run/current-system/sw/share/X11/fonts/ + +kpsewhich pdftexconfig.tex +/nix/store/2r4qa8rbll085nmpx56jg1rbmbir1zkp-texlive-combined-2021/share/texmf/tex/generic/tex-ini-files/pdftexconfig.tex +/nix/store/2r4qa8rbll085nmpx56jg1rbmbir1zkp-texlive-combined-2021/share/texmf/fonts/opentype/public/ + +find: texclive-fonts.conf +fc-cache && mkfontscale && mkfontdir + +fc-match LiberationSans + +cd /nix/var/nix/profiles/system/sw/share/X11/fonts +fc-query LiberationSans-Regular.ttf | grep '^\s\+family:' | cut -d'"' -f2 +Liberation Sans +fc-query LiberationMono-Regular.ttf | grep '^\s\+family:' | cut -d'"' -f2 +Liberation Mono + +fc-query DejaVuSans.ttf | grep '^\s\+family:' | cut -d'"' -f2 + +$XDG_DATA_HOME/fonts +~/.local/share/fonts +#+END_SRC |