From 29af0a143fd2304ab8fa228ac6487c314db80072 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Tue, 21 Apr 2020 21:06:01 -0400 Subject: cgi output, adjust appearance --- org/out_cgi_search_sqlite.org | 185 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 162 insertions(+), 23 deletions(-) (limited to 'org/out_cgi_search_sqlite.org') diff --git a/org/out_cgi_search_sqlite.org b/org/out_cgi_search_sqlite.org index 32e11ea..9b0c092 100644 --- a/org/out_cgi_search_sqlite.org +++ b/org/out_cgi_search_sqlite.org @@ -812,10 +812,18 @@ string show_matched_objects (string fn) { ** cgi *** cgi html header +**** format + #+NAME: cgi_sqlite_header #+BEGIN_SRC d { header = format(q"┃ +#+END_SRC + +**** html + +#+NAME: cgi_sqlite_header +#+BEGIN_SRC html @@ -827,6 +835,12 @@ string show_matched_objects (string fn) { @@ -1310,7 +1445,7 @@ string show_matched_objects (string fn) { *** cgi html table #+NAME: cgi_sqlite_table -#+BEGIN_SRC d +#+BEGIN_SRC html { table = format(q"┃ @@ -1449,7 +1584,7 @@ string show_matched_objects (string fn) { ***** form html #+NAME: cgi_sqlite_form -#+BEGIN_SRC d +#+BEGIN_SRC html form = format(q"┃
@@ -1583,7 +1718,7 @@ string show_matched_objects (string fn) { auto db = Database(conf.db_path ~ cv.db_selected); #+END_SRC -*** db select statement +*** db sql SELECT statement **** select where #+NAME: cgi_sqlite_select_statement_0 @@ -1669,11 +1804,10 @@ auto db = Database(conf.db_path ~ cv.db_selected); fields_str ~= fields.join(" AND "); #+END_SRC -**** db select statement -***** the body +**** db SELECT statement, the body #+NAME: cgi_sqlite_select_statement_0 -#+BEGIN_SRC d +#+BEGIN_SRC sql sql_select.the_body ~= format(q"┃ SELECT metadata_and_text.uid, @@ -1712,8 +1846,8 @@ LIMIT %%s OFFSET %%s ); #+END_SRC -***** html write selected -****** head +**** html write selected +***** head #+NAME: cgi_sqlite_select_statement_0 #+BEGIN_SRC d @@ -1729,15 +1863,20 @@ LIMIT %%s OFFSET %%s string _old_uid = ""; if (!select_query_results.empty) { string _date_published = "0000"; - foreach (row; select_query_results) { + string _close_para = ""; + string _matched_ocn_open = ""; + foreach (idx, row; select_query_results) { if (row["uid"].as!string != _old_uid) { + _close_para = (idx == 1) ? "" : "

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

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


\n" + ~ "

" ); } #+END_SRC -****** text found +***** text found #+NAME: cgi_sqlite_select_statement_0 #+BEGIN_SRC d if (cv.results_type == "txt") { if (row["ocn"].as!string != "0") { cgi.write( - "

" ~ row["ocn"].as!string - ~ "" - ~ "
" + ~ ":

" ~ highlight_text_matched(row["body"].as!string, tf.text) ); } else { cgi.write( - "

" ~ row["ocn"].as!string - ~ "" - ~ "
" + ~ ":

" ~ highlight_text_matched(row["body"].as!string, tf.text) ); } #+END_SRC -****** ocn index +***** ocn index #+NAME: cgi_sqlite_select_statement_0 #+BEGIN_SRC d } else { if (row["ocn"].as!string != "0") { cgi.write( - ", " ); } + _matched_ocn_open = ""; } #+END_SRC -****** tail +***** tail #+NAME: cgi_sqlite_select_statement_0 #+BEGIN_SRC d @@ -1912,4 +2052,3 @@ dub --force --compiler=ldc2 && sudo cp -v cgi-bin/spine-search /usr/lib/cgi-bin/ http://localhost/cgi-bin/spine-search? #+END_SRC - -- cgit v1.2.3