aboutsummaryrefslogtreecommitdiffhomepage
path: root/sundry
diff options
context:
space:
mode:
authorRalph Amissah <ralph.amissah@gmail.com>2021-10-05 12:39:53 -0400
committerRalph Amissah <ralph.amissah@gmail.com>2021-11-27 19:40:42 -0500
commit02718313824caa0e87eb0f1448684ff8d2dbe4d1 (patch)
treecb916873c46c57d18643d26fb6731f5258824a0f /sundry
parentnix related config, direnv else minor (diff)
primarily org related
Diffstat (limited to 'sundry')
-rw-r--r--sundry/editor-syntax-etc/emacs/README4
-rw-r--r--sundry/editor-syntax-etc/emacs/sisu-spine-mode-autoloads.el10
-rw-r--r--sundry/editor-syntax-etc/emacs/sisu-spine-mode.el493
-rw-r--r--sundry/editor-syntax-etc/vim/colors/def-sisu.vim223
-rw-r--r--sundry/editor-syntax-etc/vim/colors/def.vim223
-rw-r--r--sundry/editor-syntax-etc/vim/colors/frugal-cterm-sisu.vim66
-rw-r--r--sundry/editor-syntax-etc/vim/colors/slate.vim75
-rw-r--r--sundry/editor-syntax-etc/vim/filetype.vim8
-rw-r--r--sundry/editor-syntax-etc/vim/ftplugin/sisu.vim224
-rw-r--r--sundry/editor-syntax-etc/vim/templates/ssi.tpl30
-rw-r--r--sundry/editor-syntax-etc/vim/templates/ssm.tpl30
-rw-r--r--sundry/editor-syntax-etc/vim/templates/sst.tpl30
-rw-r--r--sundry/editor-syntax-etc/vim/vim-sisu.yaml7
-rw-r--r--sundry/misc/util/d/cgi/search/src/spine_cgi_sqlite_search.d976
-rwxr-xr-xsundry/misc/util/rb/tex/dr_tex.rb28
-rwxr-xr-xsundry/spine_search_cgi/src/spine_search.d_34
-rw-r--r--sundry/util/d/tools/markup_conversion/README1
-rwxr-xr-xsundry/util/d/tools/markup_conversion/endnotes_inline_from_binary.d123
-rwxr-xr-xsundry/util/d/tools/markup_conversion/markup_changes_header_and_content.d244
-rwxr-xr-xsundry/util/d/tools/markup_conversion/markup_conversion_from_sisu_ruby_to_sisu_spine.d367
-rwxr-xr-xsundry/util/rb/cgi/spine.search.cgi952
21 files changed, 3629 insertions, 519 deletions
diff --git a/sundry/editor-syntax-etc/emacs/README b/sundry/editor-syntax-etc/emacs/README
new file mode 100644
index 0000000..6dabf72
--- /dev/null
+++ b/sundry/editor-syntax-etc/emacs/README
@@ -0,0 +1,4 @@
+; put this into your .emacs file, then use the mode file:
+
+(load-file "~/emacs/el/sisu-spine-mode.el")
+(add-to-list 'auto-mode-alist '("\\.sst$" . sisu-spine-mode))
diff --git a/sundry/editor-syntax-etc/emacs/sisu-spine-mode-autoloads.el b/sundry/editor-syntax-etc/emacs/sisu-spine-mode-autoloads.el
new file mode 100644
index 0000000..4cc6332
--- /dev/null
+++ b/sundry/editor-syntax-etc/emacs/sisu-spine-mode-autoloads.el
@@ -0,0 +1,10 @@
+(add-to-list 'load-path (or (file-name-directory #$) (car load-path)))
+(autoload 'sisu-spine-mode "sisu-spine-mode" "\
+Major mode for editing SiSU (spine) markup files.
+SiSU (https://www.sisudoc.org/) document structuring, publishing
+and search.
+
+\(fn)" t nil)
+(add-to-list 'auto-mode-alist '("\\.sst\\'" . sisu-spine-mode))
+(add-to-list 'auto-mode-alist '("\\.ssm\\'" . sisu-spine-mode))
+(add-to-list 'auto-mode-alist '("\\.ssi\\'" . sisu-spine-mode))
diff --git a/sundry/editor-syntax-etc/emacs/sisu-spine-mode.el b/sundry/editor-syntax-etc/emacs/sisu-spine-mode.el
new file mode 100644
index 0000000..773fa5c
--- /dev/null
+++ b/sundry/editor-syntax-etc/emacs/sisu-spine-mode.el
@@ -0,0 +1,493 @@
+;;; sisu-spine-mode.el --- Major mode for SiSU (spine parser) markup text
+
+;; Copyright (C) 2011, 2021 Free Software Foundation, Inc.
+
+;; Author: Ralph Amissah & Ambrose Kofi Laing
+;; Maintainer: Ralph Amissah <ralph.amissah@gmail.com>
+;; Keywords: text, syntax, processes, tools
+;; Version: 8.0.0
+;; URL: https://www.sisudoc.org/
+;; originally looked at (based on) doc-mode, with kind permission of the author
+;; Author: SUN, Tong <suntong001@users.sf.net>, (c)2001-6, all right reserved
+;; Version: $Date: 2006/01/19 03:13:41 $ $Revision: 1.14 $
+;; Home URL: https://xpt.sourceforge.net/
+;; with contributions from Kevin Ryde and Stefan Monnier
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 3, 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/>.
+
+;; Viva Software Libre!
+;; Support the free software movement!
+;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+;;; Commentary:
+
+;; SiSU (https://www.sisudoc.org/) is a document structuring and
+;; publishing framework. This package provides an Emacs major mode
+;; for SiSU markup, as used by the spine parser (in D) which has a different
+;; header (based on yaml) from the original sisu parser (in Ruby) which has
+;; bespoke headers.
+
+;; When this package is installed, files ending in ".sst" are automatically
+;; associated with sisu-spine-mode. If a file doesn't have a
+;; .sst extension, add a first line:
+;; # -*- sisuSpine -*-
+
+;; The documentation for the "Structure Of The Hierarchy Text" can be
+;; found in the sisustring for the sisu-spine-mode function.
+
+;;; Code:
+
+;; Variables:
+
+(defgroup sisu-faces nil
+ "AsciiSisu highlighting"
+ :group 'sisus)
+
+;; == Colors
+; color n is more prominent than color n+1
+
+(defface sisu-title-1-face
+ `((((class color)
+ (background dark))
+ (:foreground "brown3" :bold t :height 1.2 :inherit variable-pitch))
+ (((class color)
+ (background light))
+ (:foreground "brown3" :bold t :height 1.2 :inherit variable-pitch))
+ (t (:weight bold :inherit variable-pitch)))
+ "Face for AsciiSisu titles at level 1."
+ :group 'sisu-faces)
+
+(defface sisu-title-2-face
+ `((((class color)
+ (background dark))
+ (:foreground "yellow4" :bold t :height 1.1 :inherit variable-pitch))
+ (((class color)
+ (background light))
+ (:foreground "yellow4" :bold t :height 1.1 :inherit variable-pitch))
+ (t (:weight bold :inherit variable-pitch)))
+ "Face for AsciiSisu titles at level 2."
+ :group 'sisu-faces)
+
+(defface sisu-title-3-face
+ `((((class color)
+ (background dark))
+ (:foreground "sienna3" :bold t))
+ (((class color)
+ (background light))
+ (:foreground "sienna3" :bold t))
+ (t (:weight bold)))
+ "Face for AsciiSisu titles at level 3."
+ :group 'sisu-faces)
+
+(defface sisu-title-4-face
+ `((((class color)
+ (background dark))
+ (:foreground "burlywood3"))
+ (((class color)
+ (background light))
+ (:foreground "burlywood3"))
+ (t ()))
+ "Face for AsciiSisu titles at level 4."
+ :group 'sisu-faces)
+
+(defface info-node
+ '((((class color) (background light)) (:foreground "brown" :bold t :italic t))
+ (((class color) (background dark)) (:foreground "white" :bold t :italic t))
+ (t (:bold t :italic t)))
+ "Face for Info node names."
+ :group 'sisu-faces)
+
+(defvar sisu-title-1 'sisu-title-1-face)
+(defvar sisu-title-2 'sisu-title-2-face)
+(defvar sisu-title-3 'sisu-title-3-face)
+(defvar sisu-title-4 'sisu-title-4-face)
+
+(defvar sisu-general-font-lock-red1 font-lock-warning-face)
+(defvar sisu-general-font-lock-red2 font-lock-comment-face)
+(defvar sisu-general-font-lock-red3 font-lock-string-face)
+
+(defvar sisu-general-font-lock-green1 font-lock-type-face)
+(defvar sisu-general-font-lock-green2 font-lock-constant-face)
+
+(defvar sisu-general-font-lock-blue1 font-lock-keyword-face)
+(defvar sisu-general-font-lock-blue2 font-lock-function-name-face)
+(defvar sisu-general-font-lock-blue3 font-lock-builtin-face)
+
+(defvar sisu-general-font-lock-yellow1 font-lock-variable-name-face)
+(defvar sisu-general-font-lock-yellow2 font-lock-comment-face)
+
+;; == sisu-spine-mode settings
+
+(defvar sisu-spine-mode-hook nil
+ "Normal hook run when entering Sisu Text mode.")
+
+(defvar sisu-spine-mode-abbrev-table nil
+ "Abbrev table in use in Sisu-spine-mode buffers.")
+(define-abbrev-table 'sisu-spine-mode-abbrev-table ())
+
+(defconst sisu-font-lock-keywords
+ (eval-when-compile
+ (list
+ ;;grouped text ---------
+ ;(cons "^```[ ]code\\(.\\|\n\\)+?\n```\n" 'sisu-general-font-lock-red2)
+ (cons "^```[ ]+code.*?$\\|^```$" 'sisu-general-font-lock-red2)
+ (cons "^```[ ]+table.*?$\\|^```$" 'sisu-general-font-lock-red2)
+ (cons "^```[ ]+group$\\|^```$" 'sisu-general-font-lock-red2)
+ (cons "^```[ ]+block$\\|^```$" 'sisu-general-font-lock-red2)
+ (cons "^```[ ]+poem$\\|^```$" 'sisu-general-font-lock-red2)
+ (cons "^```[ ]+alt$\\|^```$" 'sisu-general-font-lock-red2)
+ ;;grouped text ---------
+ (cons "^group{\\|^}group" 'sisu-general-font-lock-red2)
+ (cons "^block{\\|^}block" 'sisu-general-font-lock-red2)
+ (cons "^code{\\|^}code" 'sisu-general-font-lock-red2)
+ (cons "^poem{\\|^}poem" 'sisu-general-font-lock-red2)
+ (cons "^alt{\\|^}alt" 'sisu-general-font-lock-red2)
+ (cons "^table{.+\\|^}table" 'sisu-general-font-lock-red2)
+ (cons "^{table[^}]+}" 'sisu-general-font-lock-red2)
+
+ (list
+ (concat
+ "^\`\\{3\\}[ ]+code.*?$"
+ "\\(.\\|\n\\)+?"
+ "\`\\{3\\}$"
+ )
+ '(1 sisu-general-font-lock-red2 t)
+ '(2 nil t)
+ '(3 sisu-general-font-lock-red2 t)
+ )
+ (list
+ (concat
+ "^\`\\{3\\}[ ]+table.*?$"
+ "\\(.\\|\n\\)+?"
+ "\`\\{3\\}$"
+ )
+ '(1 sisu-general-font-lock-red2 t)
+ '(2 nil t)
+ '(3 sisu-general-font-lock-red2 t)
+ )
+ (list
+ (concat
+ "^\`\\{3\\}[ ]+\\(group\\|block\\|alt\\|poem\\)$"
+ "\\(.\\|\n\\)+?"
+ "^\`\\{3\\}$"
+ )
+ '(1 sisu-general-font-lock-red2 t)
+ '(2 nil t)
+ '(3 sisu-general-font-lock-red2 t)
+ )
+
+ ;; footnote/endnote ----
+ ;(cons "\~{.+?}\~" 'sisu-general-font-lock-green1)
+ (cons "\~{\\*\\*\\|\~{\\*\\|\~{\\|}\~" 'sisu-general-font-lock-red2)
+ (cons "\~\\[\\+\\|\~\\[\\*\\|\~\\[\\|\\]\~" 'sisu-general-font-lock-red2)
+ (cons "\~\\^ \\|^\\^\~ " 'sisu-general-font-lock-red2)
+ (list
+ (concat
+ "\\(\*\~\\)"
+ "\\([^ \r\t\n]+\\)"
+ )
+ '(1 sisu-general-font-lock-red1 t)
+ '(2 sisu-general-font-lock-blue2 t)
+ )
+
+ ;; emphasis (can be program configured to be bold italics or underscore)
+ (list
+ (concat
+ "\\([*]{\\)"
+ "\\([^}]+\\)"
+ "\\(}[*]\\)"
+ )
+ '(1 sisu-general-font-lock-red1 t)
+ '(2 sisu-general-font-lock-red1 t)
+ '(3 sisu-general-font-lock-red1 t)
+ )
+
+ ;; bold ----------------
+ (list
+ (concat
+ "\\([!]{\\)"
+ "\\([^}]+\\)"
+ "\\(}[!]\\)"
+ )
+ '(1 sisu-general-font-lock-red1 t)
+ '(2 sisu-general-font-lock-red1 t)
+ '(3 sisu-general-font-lock-red1 t)
+ )
+ (cons "\\*[^ ]+\\*" 'sisu-general-font-lock-red1)
+ (cons "^!_ .+" 'sisu-general-font-lock-red1)
+
+ ;; italics -------------
+ (list
+ (concat
+ "\\([/]{\\)"
+ "\\([^}]+\\)"
+ "\\(}[/]\\)"
+ )
+ '(1 sisu-general-font-lock-red1 t)
+ '(2 sisu-general-font-lock-blue1 t)
+ '(3 sisu-general-font-lock-red1 t)
+ )
+
+ ;; underscore ----------
+ (list
+ (concat
+ "\\([_]{\\)"
+ "\\([^}]+\\)"
+ "\\(\}[_]\\)"
+ )
+ '(1 sisu-general-font-lock-red1 t)
+ '(2 sisu-general-font-lock-red1 t)
+ '(3 sisu-general-font-lock-red1 t)
+ )
+
+ ;; monospace -----------
+ (list
+ (concat
+ "\\([#]{\\)"
+ "\\([^}]+\\)"
+ "\\(}[#]\\)"
+ )
+ '(1 sisu-general-font-lock-red1 t)
+ '(2 sisu-general-font-lock-red1 t)
+ '(3 sisu-general-font-lock-red1 t)
+ )
+
+ ;; citation ------------
+ (list
+ (concat
+ "\\([\"]{\\)"
+ "\\([^}]+\\)"
+ "\\(}[\"]\\)"
+ )
+ '(1 sisu-general-font-lock-red1 t)
+ '(2 sisu-general-font-lock-red1 t)
+ '(3 sisu-general-font-lock-red1 t)
+ )
+
+ ;; inserted text -------
+ (list
+ (concat
+ "\\([\+]{\\)"
+ "\\([^}]+\\)"
+ "\\(}[\+]\\)"
+ )
+ '(1 sisu-general-font-lock-red1 t)
+ '(2 sisu-general-font-lock-red1 t)
+ '(3 sisu-general-font-lock-red1 t)
+ )
+
+ ;; strike through ------
+ (list
+ (concat
+ "\\(\\-{\\)"
+ "\\([^}]+\\)"
+ "\\(}\\-\\)"
+ )
+ '(1 sisu-general-font-lock-red1 t)
+ '(2 sisu-general-font-lock-red1 t)
+ '(3 sisu-general-font-lock-red1 t)
+ )
+
+ ;; superscript ---------
+ (list
+ (concat
+ "\\(\\^{\\)"
+ "\\([^}]+\\)"
+ "\\(}\\^\\)"
+ )
+ '(1 sisu-general-font-lock-red1 t)
+ '(2 sisu-general-font-lock-red1 t)
+ '(3 sisu-general-font-lock-red1 t)
+ )
+
+ ;; subscript -----------
+ (list
+ (concat
+ "\\([,]{\\)"
+ "\\([^}]+\\)"
+ "\\(}[,]\\)"
+ )
+ '(1 sisu-general-font-lock-red1 t)
+ '(2 sisu-general-font-lock-red1 t)
+ '(3 sisu-general-font-lock-red1 t)
+ )
+
+ ;; numbered list
+ (cons "^# \\|^_# " 'sisu-general-font-lock-red1)
+
+ ;; bullet text
+ (cons "^_\\*[1-9] \\|^_\\* " 'sisu-general-font-lock-red1)
+
+ ;; indented text
+ (cons "^_[1-9] " 'sisu-general-font-lock-red1)
+ (cons "^_[1-9]! " 'sisu-general-font-lock-red1)
+
+ ;; hanging indented text [proposed enable when implemented]
+ (cons "^__[1-9] " 'sisu-general-font-lock-red1)
+ (cons "^_[0-9]_[0-9] " 'sisu-general-font-lock-red1)
+ (cons "^__[1-9]! " 'sisu-general-font-lock-red1)
+ (cons "^_[0-9]_[0-9]! " 'sisu-general-font-lock-red1)
+
+ ;; url
+ (cons "\\(^\\|[ ]\\)https?:[/][/][^ \t\n\r<]+" 'sisu-general-font-lock-blue2)
+
+ ;; Comment Lines
+ (cons "^% .*" 'sisu-general-font-lock-blue1)
+
+ ;; page break
+ (cons "^\\(-\\\\\\\\-\\|=\\\\\\\\=\\|-\\.\\.-\\)" 'sisu-general-font-lock-red2)
+
+ ;; line break
+ (cons " \\\\\\\\ " 'sisu-general-font-lock-red1)
+
+ ;; line break (depreciated)
+ (cons "<br>" 'sisu-general-font-lock-red1)
+
+ ;; Section titles
+ (list "^\\(\\([1-4]\\|:?[A-D]\\)\\~\\)\\(.*\\)"
+ '(1 sisu-title-1 t)
+ '(3 sisu-title-2 t)
+ )
+
+ ;; hyper-links
+ (list
+ (concat
+ "\\({~^\\|{\\)"
+ "\\([^}{]+\\)"
+ "\\(}https?:[/][/][^ \r\n\t<]+\\)"
+ )
+ '(1 sisu-general-font-lock-blue2 t)
+ '(2 sisu-general-font-lock-red1 t)
+ '(3 sisu-general-font-lock-blue2 t)
+ )
+
+ ;; book index
+ (list
+ (concat
+ "^\\(\={\\)"
+ "\\([^}{]+\\)"
+ "\\(}\\)$"
+ )
+ '(1 sisu-general-font-lock-green1 t)
+ '(2 nil t)
+ '(3 sisu-general-font-lock-green1 t)
+ )
+
+ ;(cons "^\={.+}" 'sisu-general-font-lock-green1)
+
+ ;; numbers
+ (cons "\\<[.0-9]+\\>" 'sisu-general-font-lock-green2)
+
+ ;; bullets sisu_normal (nearly copied regexp)
+ (cons "^_\\([1-9*]\\|[1-9]\\*\\) " 'sisu-general-font-lock-blue2)
+
+ ;; image links
+ (list
+ (concat
+ "\\({\\)"
+ "\\([^}{]+\\)"
+ "\\(}image\\)"
+ )
+ '(1 sisu-general-font-lock-blue2 t)
+ '(2 sisu-general-font-lock-red1 t)
+ '(3 sisu-general-font-lock-blue2 t)
+ )
+
+ ;; insert file links
+ (list
+ (concat
+ "\\(<< \\)"
+ "\\([^ \r\t\n]+\\.ss\\)"
+ "\\(i\\|t\\)"
+ )
+ '(1 sisu-general-font-lock-blue2 t)
+ '(2 sisu-general-font-lock-blue2 t)
+ '(3 sisu-general-font-lock-blue2 t)
+ )
+
+ ;; raw keywords
+ (list
+ (concat
+ "^\\(\\("
+ "creator\\|"
+ "title\\|"
+ "date\\|"
+ "rights\\|"
+ "publisher\\|"
+ "classify\\|"
+ "identifier\\|"
+ "original\\|"
+ "notes\\|"
+ "links\\|"
+ "make\\|"
+ "\\):\\)\\(.*\\)"
+ )
+ '(1 sisu-title-2 keep)
+ '(3 sisu-title-3 keep)
+ )
+ )
+ )
+ "Default expressions to highlight in AsciiSisu mode."
+)
+
+;; outline mode evil "folding" if available
+;; (define-key evil-normal-state-map ",0" 'show-all)
+;; (define-key evil-normal-state-map ",-" 'hide-body)
+;; (define-key evil-normal-state-map ",+" 'show-subtree)
+;; (define-key evil-normal-state-map ",=" 'show-subtree)
+
+;;
+
+;; Sisu & Autoload:
+
+;;;###autoload
+(define-derived-mode sisu-spine-mode text-mode "SiSU"
+ "Major mode for editing SiSU files.
+SiSU document structuring, publishing in multiple formats and search.
+URL `https://www.sisudoc.org/'"
+ (modify-syntax-entry ?\' ".")
+ ;;(flyspell-mode nil)
+
+ (make-local-variable 'paragraph-start)
+ (setq paragraph-start (concat "$\\|>" page-delimiter))
+ (make-local-variable 'paragraph-separate)
+ (setq paragraph-separate paragraph-start)
+ (make-local-variable 'paragraph-ignore-fill-prefix)
+ (setq paragraph-ignore-fill-prefix t)
+
+ (set (make-local-variable 'outline-regexp)
+ "^\\(\\([1-4]\\|:?[A-D]\\)\\~\\|\\@[a-z]+:\\( \\|$\\)\\)")
+
+ (make-local-variable 'require-final-newline)
+ (setq require-final-newline t)
+
+ (make-local-variable 'font-lock-defaults)
+ (setq font-lock-defaults
+ '(sisu-font-lock-keywords
+ nil ; KEYWORDS-ONLY: no
+ nil ; CASE-FOLD: no
+ ((?_ . "w")) ; SYNTAX-ALIST
+ ))
+ ;; Enable outlining.
+ ;; TODO with outlining make sure linum (line numbering) is off,
+ ;; else performance penalty, sucks bigtime
+ (outline-minor-mode 1))
+
+;;;###autoload (add-to-list 'auto-mode-alist '("\\.ss[imt]\\'" . sisu-spine-mode))
+
+(provide 'sisu-spine-mode)
+
+;;
+
+;;; sisu-spine-mode.el ends here
diff --git a/sundry/editor-syntax-etc/vim/colors/def-sisu.vim b/sundry/editor-syntax-etc/vim/colors/def-sisu.vim
new file mode 100644
index 0000000..ac3e0c3
--- /dev/null
+++ b/sundry/editor-syntax-etc/vim/colors/def-sisu.vim
@@ -0,0 +1,223 @@
+" Vim color file
+" Name: def-sisu
+" Maintainer: Ralph Amissah <ralph@amissah.com>
+" Last Change: 2013-02-14
+" URL: <https://git.sisudoc.org/projects/?p=software/spine.git;a=blob;f=data/sisu/conf/editor-syntax-etc/vim/colors/def-sisu.vim;hb=HEAD>
+" Note: primarily 16 color cterm improved by tweaking of .Xdefaults
+" (with occasional other colors selected from 256 color palate)
+" .Xdefaults tweaking to make identical to def (256) provided,
+" along with an alternative possibility using colors beyond
+" 256 color palate
+:hi clear
+if exists("syntax_on")
+ syntax reset
+endif
+:set t_Co=256
+:set background=dark
+:let colors_name = "def-sisu"
+" -------
+" terminal def
+" -------
+:hi Normal ctermbg=0 ctermfg=7
+":hi Cursor ctermbg=5 ctermfg=0
+:hi lCursor cterm=reverse
+:hi StatusLine cterm=bold,reverse
+:hi StatusLineNC cterm=reverse
+:hi Search cterm=none ctermbg=57 ctermfg=0
+:hi IncSearch cterm=none ctermbg=154 ctermfg=0
+:hi SpecialKey ctermfg=4
+:hi Visual cterm=reverse
+:hi VisualNOS cterm=bold,underline
+:hi MoreMsg ctermfg=2
+:hi ModeMsg cterm=bold
+:hi Question ctermfg=2
+:hi Title cterm=bold ctermfg=3
+:hi NonText cterm=bold ctermfg=4
+:hi LineNr cterm=bold ctermbg=0 ctermfg=0*
+:hi CursorLineNr cterm=bold ctermbg=166 ctermfg=0
+:hi Directory ctermfg=4
+:hi WildMenu ctermbg=3 ctermfg=0
+:hi VertSplit cterm=reverse
+:hi Folded cterm=none ctermbg=0 ctermfg=8
+:hi FoldColumn ctermbg=7 ctermfg=4
+:hi DiffAdd cterm=none ctermbg=2 ctermfg=0
+:hi DiffChange cterm=none ctermbg=7 ctermfg=0
+:hi DiffDelete cterm=none ctermbg=7 ctermfg=0
+:hi DiffText cterm=none ctermbg=6 ctermfg=0
+:hi String cterm=none ctermfg=3
+:hi Comment cterm=none ctermbg=0 ctermfg=4
+:hi Constant ctermfg=1
+:hi Special ctermfg=6
+:hi Identifier ctermfg=6
+:hi Statement ctermfg=6
+:hi Operator ctermfg=1
+:hi PreProc ctermbg=7 ctermfg=1
+:hi Type ctermfg=2
+:hi Delimiter cterm=none ctermfg=1
+:hi Ignore cterm=bold ctermfg=7
+:hi Todo ctermbg=3 ctermfg=0
+:hi Underlined cterm=underline
+:hi Include ctermfg=1
+:hi Define ctermfg=3
+:hi Function ctermfg=6
+:hi Structure ctermfg=2
+:hi MatchParen cterm=bold ctermbg=4 ctermfg=7
+:hi CursorLine cterm=bold
+:hi CursorColumn ctermbg=17
+:hi ColorColumn ctermbg=17
+:hi SpellBad cterm=underline ctermbg=0 ctermfg=5
+:hi SpellCap cterm=underline ctermbg=0 ctermfg=5
+:hi SpellLocal cterm=underline ctermbg=0 ctermfg=5
+:hi SpellRare cterm=underline ctermbg=0 ctermfg=5
+:hi TrailingWhitespace ctermbg=1
+:hi ExtraWhitespace ctermbg=1
+:hi WarningMsg ctermfg=1
+:hi ErrorMsg cterm=bold ctermbg=1 ctermfg=7
+:hi Error cterm=bold ctermbg=1 ctermfg=7
+" -------
+" gui def
+" -------
+:hi Normal guibg=#000000 guifg=#D3D3D3
+:hi Cursor guibg=#CC9966 guifg=#000000
+:hi lCursor gui=reverse
+:hi StatusLine gui=bold,reverse
+:hi StatusLineNC gui=reverse
+:hi Search gui=none guibg=#5F00FF guifg=#000000
+:hi IncSearch gui=none guibg=#AFFF00 guifg=#000000
+:hi SpecialKey guifg=#5971AD
+:hi Visual gui=reverse
+:hi VisualNOS gui=bold,underline
+:hi MoreMsg guifg=#4E9A06
+:hi ModeMsg gui=bold
+:hi Question guifg=#4E9A06
+:hi Title gui=bold guifg=#C4A000
+:hi NonText gui=bold guifg=#5971AD
+:hi LineNr gui=bold guibg=#000000 guifg=#808080
+:hi CursorLineNr gui=bold guibg=#D75F00 guifg=#000000
+:hi Directory guifg=#5971AD
+:hi WildMenu guibg=#C4A000 guifg=#000000
+:hi VertSplit gui=reverse
+:hi Folded gui=none guibg=#000000 guifg=#808080
+:hi FoldColumn guibg=#D3D3D3 guifg=#5971AD
+:hi DiffAdd gui=none guibg=#4E9A06 guifg=#000000
+:hi DiffChange gui=none guibg=#D3D3D3 guifg=#000000
+:hi DiffDelete gui=none guibg=#D3D3D3 guifg=#000000
+:hi DiffText gui=none guibg=#06989A guifg=#000000
+:hi String gui=none guifg=#C4A000
+:hi Comment gui=none guibg=#000000 guifg=#5971AD
+:hi Constant guifg=#CC0000
+:hi Special guifg=#06989A
+:hi Identifier guifg=#06989A
+:hi Statement guifg=#06989A
+:hi Operator guifg=#CC0000
+:hi PreProc guibg=#D3D3D3 guifg=#CC0000
+:hi Type guifg=#4E9A06
+:hi Delimiter gui=none guifg=#CC0000
+:hi Ignore gui=bold guifg=#D3D3D3
+:hi Todo guibg=#C4A000 guifg=#000000
+:hi Underlined gui=underline
+:hi Include guifg=#CC0000
+:hi Define guifg=#C4A000
+:hi Function guifg=#06989A
+:hi Structure guifg=#4E9A06
+:hi MatchParen gui=bold guibg=#5971AD guifg=#D3D3D3
+:hi CursorLine gui=bold
+:hi CursorColumn guibg=#00005F
+:hi ColorColumn guibg=#00005F
+:hi SpellBad gui=underline guibg=#000000 guifg=#75507B
+:hi SpellCap gui=underline guibg=#000000 guifg=#75507B
+:hi SpellLocal gui=underline guibg=#000000 guifg=#75507B
+:hi SpellRare gui=underline guibg=#000000 guifg=#75507B
+:hi TrailingWhitespace guibg=#080000
+:hi ExtraWhitespace guibg=#CC0000
+:hi WarningMsg guifg=#CC0000
+:hi ErrorMsg gui=bold guibg=#CC0000 guifg=#D3D3D3
+:hi Error gui=bold guibg=#CC0000 guifg=#D3D3D3
+" -------
+"256 color .Xdefaults vim: cterm giu
+"<https://vim.wikia.com/wiki/Xterm256_color_names_for_console_Vim>
+"<https://guns.github.com/xterm-color-table.vim/images/xterm-color-table-with-visible-rgb.png>
+" -------
+" 256 color .Xdefaults vim: cterm giu def
+" -------
+" 16 color standard altered 256 altered beyond 256
+" black/dark grey
+" 0 [ 0:#000000] #000000
+" 8 [ 8:#808080] [59:#5F5F5F] #555555
+" red
+" 1 [ 1:#800000] 160:#DF0000 #CC0000
+" 9 [ 9:#FF0000] #EF2929
+" green
+" 2 [ 2:#008000] 112:#87DF00 #4E9A06
+" 10 [10:#00FF00] 154:#AFFF00 #8AE234
+" yellow/orange
+" 3 [ 3:#808000] 178:#DFAF00 #C4A000
+" 11 [11:#FFFF00] 184:#DFDF00 #FC9E4F
+" blue
+" 4 [ 4:#000080] 24:#005F87 #5971AD
+" 12 [12:#0000FF] 73:#5FAFAF #729FCF
+" magenta
+" 5 [ 5:#800080] 90:#870087 #75507B
+" 13 [13:#FF00FF] 126:#AF0087 #AD7FA8
+" cyan
+" 6 [ 6:#008080] 37:#00AFAF #06989A
+" 14 [14:#00FFFF] 87:#5FFFFF #34E2E2
+" white
+" 7 [ 7:#C0C0C0] #D3D3D3
+" 15 [15:#FFFFFF] #EEEEEE
+" --------
+" .Xdefaults (rxvt urxvt setting beyond 256 colors, vim colorscheme "def" gui settings)
+" (vim colorscheme "def" cterm matches "def" gui if .Xdefaults set thus)
+" --------
+" ! black
+" Rxvt.color0 : #000000
+" Rxvt.color8 : #555555
+" ! red
+" Rxvt.color1 : #CC0000
+" Rxvt.color9 : #EF2929
+" ! green
+" Rxvt.color2 : #4E9A06
+" Rxvt.color10 : #8AE234
+" ! yellow
+" Rxvt.color3 : #C4A000
+" Rxvt.color11 : #FCE94F
+" ! blue
+" Rxvt.color4 : #5971AD
+" Rxvt.color12 : #729FCF
+" ! magenta
+" Rxvt.color5 : #75507B
+" Rxvt.color13 : #AD7FA8
+" ! cyan
+" Rxvt.color6 : #06989A
+" Rxvt.color14 : #34E2E2
+" ! white
+" Rxvt.color7 : #D3D7CF
+" Rxvt.color15 : #EEEEEE
+" --------
+" .Xdefaults 256 (rxvt urxvt setting, vim colorscheme "def256" cterm & gui settings)
+" (vim colorscheme "def" cterm matches "def256" if .Xdefaults set thus)
+" --------
+" ! black
+" Rxvt.color0 : #000000
+" Rxvt.color8 : #808080
+" ! red
+" Rxvt.color1 : #DF0000
+" Rxvt.color9 : #FF0000
+" ! green
+" Rxvt.color2 : #87DF00
+" Rxvt.color10 : #AFFF00
+" ! yellow
+" Rxvt.color3 : #DFAF00
+" Rxvt.color11 : #FFFF00
+" ! blue
+" Rxvt.color4 : #5F87DF
+" Rxvt.color12 : #87DFFF
+" ! magenta
+" Rxvt.color5 : #8700DF
+" Rxvt.color13 : #87DFFF
+" ! cyan
+" Rxvt.color6 : #00DFDF
+" Rxvt.color14 : #5F5FDF
+" ! white
+" Rxvt.color7 : #C0C0C0
+" Rxvt.color15 : #FFFFFF
diff --git a/sundry/editor-syntax-etc/vim/colors/def.vim b/sundry/editor-syntax-etc/vim/colors/def.vim
new file mode 100644
index 0000000..aca1975
--- /dev/null
+++ b/sundry/editor-syntax-etc/vim/colors/def.vim
@@ -0,0 +1,223 @@
+" Vim color file
+" Name: def
+" Maintainer: Ralph Amissah <ralph@amissah.com>
+" Last Change: 2013-02-14
+" URL: <https://git.sisudoc.org/projects/?p=software/spine.git;a=blob;f=data/sisu/conf/editor-syntax-etc/vim/colors/def.vim;hb=HEAD>
+" Note: primarily 16 color cterm improved by tweaking of .Xdefaults
+" (with occasional other colors selected from 256 color palate)
+" .Xdefaults tweaking to make identical to def (256) provided,
+" along with an alternative possibility using colors beyond
+" 256 color palate
+:hi clear
+if exists("syntax_on")
+ syntax reset
+endif
+:set t_Co=256
+:set background=dark
+:let colors_name = "def"
+" -------
+" terminal def
+" -------
+:hi Normal ctermbg=0 ctermfg=7
+":hi Cursor ctermbg=5 ctermfg=0
+:hi lCursor cterm=reverse
+:hi StatusLine cterm=bold,reverse
+:hi StatusLineNC cterm=reverse
+:hi Search cterm=none ctermbg=57 ctermfg=0
+:hi IncSearch cterm=none ctermbg=154 ctermfg=0
+:hi SpecialKey ctermfg=4
+:hi Visual cterm=reverse
+:hi VisualNOS cterm=bold,underline
+:hi MoreMsg ctermfg=2
+:hi ModeMsg cterm=bold
+:hi Question ctermfg=2
+:hi Title cterm=bold ctermfg=3
+:hi NonText cterm=bold ctermfg=4
+:hi LineNr cterm=bold ctermbg=0 ctermfg=0*
+:hi CursorLineNr cterm=bold ctermbg=166 ctermfg=0
+:hi Directory ctermfg=4
+:hi WildMenu ctermbg=3 ctermfg=0
+:hi VertSplit cterm=reverse
+:hi Folded cterm=none ctermbg=0 ctermfg=8
+:hi FoldColumn ctermbg=7 ctermfg=4
+:hi DiffAdd cterm=none ctermbg=2 ctermfg=0
+:hi DiffChange cterm=none ctermbg=7 ctermfg=0
+:hi DiffDelete cterm=none ctermbg=7 ctermfg=0
+:hi DiffText cterm=none ctermbg=6 ctermfg=0
+:hi String cterm=none ctermfg=3
+:hi Comment cterm=none ctermbg=0 ctermfg=4
+:hi Constant ctermfg=1
+:hi Special ctermfg=6
+:hi Identifier ctermfg=6
+:hi Statement ctermfg=2
+:hi Operator ctermfg=2
+:hi PreProc ctermfg=1
+:hi Type cterm=bold ctermfg=3
+:hi Delimiter cterm=none ctermfg=2
+:hi Ignore cterm=bold ctermfg=7
+:hi Todo ctermbg=3 ctermfg=0
+:hi Underlined cterm=underline
+:hi Include ctermfg=1
+:hi Define ctermfg=3
+:hi Function ctermfg=6
+:hi Structure ctermfg=2
+:hi MatchParen cterm=bold ctermbg=4 ctermfg=7
+:hi CursorLine cterm=bold
+:hi CursorColumn ctermbg=17
+:hi ColorColumn ctermbg=17
+:hi SpellBad cterm=underline ctermbg=0 ctermfg=5
+:hi SpellCap cterm=underline ctermbg=0 ctermfg=5
+:hi SpellLocal cterm=underline ctermbg=0 ctermfg=5
+:hi SpellRare cterm=underline ctermbg=0 ctermfg=5
+:hi TrailingWhitespace ctermbg=1
+:hi ExtraWhitespace ctermbg=1
+:hi WarningMsg ctermfg=1
+:hi ErrorMsg cterm=bold ctermbg=1 ctermfg=7
+:hi Error cterm=bold ctermbg=1 ctermfg=7
+" -------
+" gui def
+" -------
+:hi Normal guibg=#000000 guifg=#D3D3D3
+:hi Cursor guibg=#CC9966 guifg=#000000
+:hi lCursor gui=reverse
+:hi StatusLine gui=bold,reverse
+:hi StatusLineNC gui=reverse
+:hi Search gui=none guibg=#5F00FF guifg=#000000
+:hi IncSearch gui=none guibg=#AFFF00 guifg=#000000
+:hi SpecialKey guifg=#5971AD
+:hi Visual gui=reverse
+:hi VisualNOS gui=bold,underline
+:hi MoreMsg guifg=#4E9A06
+:hi ModeMsg gui=bold
+:hi Question guifg=#4E9A06
+:hi Title gui=bold guifg=#C4A000
+:hi NonText gui=bold guifg=#5971AD
+:hi LineNr gui=bold guibg=#000000 guifg=#808080
+:hi CursorLineNr gui=bold guibg=#D75F00 guifg=#000000
+:hi Directory guifg=#5971AD
+:hi WildMenu guibg=#C4A000 guifg=#000000
+:hi VertSplit gui=reverse
+:hi Folded gui=none guibg=#000000 guifg=#808080
+:hi FoldColumn guibg=#D3D3D3 guifg=#5971AD
+:hi DiffAdd gui=none guibg=#4E9A06 guifg=#000000
+:hi DiffChange gui=none guibg=#D3D3D3 guifg=#000000
+:hi DiffDelete gui=none guibg=#D3D3D3 guifg=#000000
+:hi DiffText gui=none guibg=#06989A guifg=#000000
+:hi String gui=none guifg=#C4A000
+:hi Comment gui=none guibg=#000000 guifg=#5971AD
+:hi Constant guifg=#CC0000
+:hi Special guifg=#06989A
+:hi Identifier guifg=#06989A
+:hi Statement guifg=#4E9A06
+:hi Operator guifg=#4E9A06
+:hi PreProc guifg=#CC0000
+:hi Type gui=bold guifg=#C4A000
+:hi Delimiter gui=none guifg=#4E9A06
+:hi Ignore gui=bold guifg=#D3D3D3
+:hi Todo guibg=#C4A000 guifg=#000000
+:hi Underlined gui=underline
+:hi Include guifg=#CC0000
+:hi Define guifg=#C4A000
+:hi Function guifg=#06989A
+:hi Structure guifg=#4E9A06
+:hi MatchParen gui=bold guibg=#5971AD guifg=#D3D3D3
+:hi CursorLine gui=bold
+:hi CursorColumn guibg=#00005F
+:hi ColorColumn guibg=#00005F
+:hi SpellBad gui=underline guibg=#000000 guifg=#75507B
+:hi SpellCap gui=underline guibg=#000000 guifg=#75507B
+:hi SpellLocal gui=underline guibg=#000000 guifg=#75507B
+:hi SpellRare gui=underline guibg=#000000 guifg=#75507B
+:hi TrailingWhitespace guibg=#080000
+:hi ExtraWhitespace guibg=#CC0000
+:hi WarningMsg guifg=#CC0000
+:hi ErrorMsg gui=bold guibg=#CC0000 guifg=#D3D3D3
+:hi Error gui=bold guibg=#CC0000 guifg=#D3D3D3
+" -------
+"256 color .Xdefaults vim: cterm giu
+"<https://vim.wikia.com/wiki/Xterm256_color_names_for_console_Vim>
+"<https://guns.github.com/xterm-color-table.vim/images/xterm-color-table-with-visible-rgb.png>
+" -------
+" 256 color .Xdefaults vim: cterm giu def
+" -------
+" 16 color standard altered 256 altered beyond 256
+" black/dark grey
+" 0 [ 0:#000000] #000000
+" 8 [ 8:#808080] [59:#5F5F5F] #555555
+" red
+" 1 [ 1:#800000] 160:#DF0000 #CC0000
+" 9 [ 9:#FF0000] #EF2929
+" green
+" 2 [ 2:#008000] 112:#87DF00 #4E9A06
+" 10 [10:#00FF00] 154:#AFFF00 #8AE234
+" yellow/orange
+" 3 [ 3:#808000] 178:#DFAF00 #C4A000
+" 11 [11:#FFFF00] 184:#DFDF00 #FC9E4F
+" blue
+" 4 [ 4:#000080] 24:#005F87 #5971AD
+" 12 [12:#0000FF] 73:#5FAFAF #729FCF
+" magenta
+" 5 [ 5:#800080] 90:#870087 #75507B
+" 13 [13:#FF00FF] 126:#AF0087 #AD7FA8
+" cyan
+" 6 [ 6:#008080] 37:#00AFAF #06989A
+" 14 [14:#00FFFF] 87:#5FFFFF #34E2E2
+" white
+" 7 [ 7:#C0C0C0] #D3D3D3
+" 15 [15:#FFFFFF] #EEEEEE
+" --------
+" .Xdefaults (rxvt urxvt setting beyond 256 colors, vim colorscheme "def" gui settings)
+" (vim colorscheme "def" cterm matches "def" gui if .Xdefaults set thus)
+" --------
+" ! black
+" Rxvt.color0 : #000000
+" Rxvt.color8 : #555555
+" ! red
+" Rxvt.color1 : #CC0000
+" Rxvt.color9 : #EF2929
+" ! green
+" Rxvt.color2 : #4E9A06
+" Rxvt.color10 : #8AE234
+" ! yellow
+" Rxvt.color3 : #C4A000
+" Rxvt.color11 : #FCE94F
+" ! blue
+" Rxvt.color4 : #5971AD
+" Rxvt.color12 : #729FCF
+" ! magenta
+" Rxvt.color5 : #75507B
+" Rxvt.color13 : #AD7FA8
+" ! cyan
+" Rxvt.color6 : #06989A
+" Rxvt.color14 : #34E2E2
+" ! white
+" Rxvt.color7 : #D3D7CF
+" Rxvt.color15 : #EEEEEE
+" --------
+" .Xdefaults 256 (rxvt urxvt setting, vim colorscheme "def256" cterm & gui settings)
+" (vim colorscheme "def" cterm matches "def256" if .Xdefaults set thus)
+" --------
+" ! black
+" Rxvt.color0 : #000000
+" Rxvt.color8 : #808080
+" ! red
+" Rxvt.color1 : #DF0000
+" Rxvt.color9 : #FF0000
+" ! green
+" Rxvt.color2 : #87DF00
+" Rxvt.color10 : #AFFF00
+" ! yellow
+" Rxvt.color3 : #DFAF00
+" Rxvt.color11 : #FFFF00
+" ! blue
+" Rxvt.color4 : #5F87DF
+" Rxvt.color12 : #87DFFF
+" ! magenta
+" Rxvt.color5 : #8700DF
+" Rxvt.color13 : #87DFFF
+" ! cyan
+" Rxvt.color6 : #00DFDF
+" Rxvt.color14 : #5F5FDF
+" ! white
+" Rxvt.color7 : #C0C0C0
+" Rxvt.color15 : #FFFFFF
diff --git a/sundry/editor-syntax-etc/vim/colors/frugal-cterm-sisu.vim b/sundry/editor-syntax-etc/vim/colors/frugal-cterm-sisu.vim
new file mode 100644
index 0000000..aae822d
--- /dev/null
+++ b/sundry/editor-syntax-etc/vim/colors/frugal-cterm-sisu.vim
@@ -0,0 +1,66 @@
+" Vim color file
+" Name: frugal-cterm-sisu
+" Maintainer: Ralph Amissah <ralph@amissah.com>
+" Last Change: 2013-02-09
+" URL: <https://git.sisudoc.org/projects/?p=software/spine.git;a=blob;f=data/sisu/conf/editor-syntax-etc/vim/colors/frugal-cterm-sisu.vim;hb=HEAD>
+" Note: 8 color cterm, related colorschemes 8 & sparse
+:set background=dark
+:hi clear
+if exists("syntax_on")
+ syntax reset
+endif
+:let colors_name = "frugal-cterm-sisu"
+" 0 = black, 1 = red, 2 = green, 3 = yellow/orange, 4 = blue, 5 = magenta, 6 = cyan, 7 = white
+:hi Normal ctermbg=0 ctermfg=7
+:hi Cursor cterm=reverse
+:hi lCursor cterm=reverse
+:hi StatusLine cterm=bold,reverse
+:hi StatusLineNC cterm=reverse
+:hi Search cterm=none ctermbg=2 ctermfg=0
+:hi IncSearch cterm=bold ctermbg=2 ctermfg=7
+:hi SpecialKey ctermfg=4
+:hi Visual cterm=reverse
+:hi VisualNOS cterm=bold,underline
+:hi MoreMsg ctermfg=2
+:hi ModeMsg cterm=bold
+:hi Question ctermfg=2
+:hi Title cterm=bold ctermfg=3
+:hi NonText cterm=bold ctermfg=4
+:hi LineNr cterm=bold ctermbg=0 ctermfg=0*
+:hi Directory ctermfg=4
+:hi WildMenu ctermbg=3 ctermfg=0
+:hi VertSplit cterm=reverse
+:hi Folded cterm=none ctermbg=0 ctermfg=7
+:hi FoldColumn ctermbg=7 ctermfg=4
+:hi DiffChange cterm=none ctermbg=7 ctermfg=0
+:hi DiffText cterm=none ctermbg=6 ctermfg=0
+:hi DiffAdd cterm=none ctermbg=2 ctermfg=0
+:hi DiffDelete cterm=none ctermbg=7 ctermfg=0
+:hi String cterm=none ctermfg=3
+:hi Comment cterm=none ctermbg=0 ctermfg=7
+:hi Constant ctermfg=1
+:hi Special ctermfg=6
+:hi Identifier ctermfg=6
+:hi Statement ctermfg=6
+:hi Operator ctermfg=1
+:hi PreProc ctermbg=7 ctermfg=1
+:hi Type ctermfg=2
+:hi Delimiter cterm=none ctermfg=1
+:hi Ignore cterm=bold ctermfg=7
+:hi Todo ctermbg=3 ctermfg=0
+:hi Underlined cterm=underline
+:hi Include ctermfg=1
+:hi Define ctermfg=3
+:hi Function ctermfg=6
+:hi Structure ctermfg=2
+:hi MatchParen cterm=bold ctermbg=4 ctermfg=7
+:hi CursorLine cterm=bold,underline
+:hi CursorColumn cterm=bold
+:hi ColorColumn ctermbg=8
+:hi SpellBad cterm=none ctermbg=7 ctermfg=0
+:hi SpellCap cterm=none ctermbg=7 ctermfg=0
+:hi SpellLocal cterm=none ctermbg=7 ctermfg=0
+:hi SpellRare cterm=none ctermbg=7 ctermfg=0
+:hi WarningMsg ctermfg=1
+:hi ErrorMsg cterm=bold ctermbg=1 ctermfg=7
+:hi Error cterm=bold ctermbg=1 ctermfg=7
diff --git a/sundry/editor-syntax-etc/vim/colors/slate.vim b/sundry/editor-syntax-etc/vim/colors/slate.vim
new file mode 100644
index 0000000..4d741e8
--- /dev/null
+++ b/sundry/editor-syntax-etc/vim/colors/slate.vim
@@ -0,0 +1,75 @@
+"%% SiSU Vim color file
+" Name: Slate
+" Maintainer: Ralph Amissah <ralph@amissah.com>
+" Last Change: 2013-02-09
+" URL: <https://git.sisudoc.org/projects/?p=software/spine.git;a=blob;f=data/sisu/conf/editor-syntax-etc/vim/colors/slate.vim;hb=HEAD>
+" Notes: cterm now uses frugal-sisu 8 colors for term
+" (for gui originally looked at desert Hans Fugal <hans@fugal.net>
+" <https://hans.fugal.net/vim/colors/desert.vim> (April/May 2003))
+:set background=dark
+:hi clear
+if exists("syntax_on")
+ syntax reset
+endif
+:let colors_name = "slate"
+" 0 = black, 1 = red, 2 = green, 3 = yellow/orange, 4 = blue, 5 = magenta, 6 = cyan, 7 = white
+:hi Normal ctermbg=0 ctermfg=7 guibg=grey15 guifg=white
+:hi Cursor term=reverse cterm=reverse guibg=khaki guifg=slategrey
+:hi lCursor term=reverse cterm=reverse
+:hi StatusLine term=reverse cterm=bold,reverse gui=none guibg=#c2bfa5 guifg=black
+:hi StatusLineNC term=reverse cterm=reverse gui=none guibg=#c2bfa5 guifg=grey40
+:hi Search term=reverse cterm=none ctermbg=2 ctermfg=0 guibg=peru guifg=wheat
+:hi IncSearch term=reverse cterm=bold ctermbg=2 ctermfg=7 guibg=black guifg=green
+:hi SpecialKey term=bold ctermfg=4 guifg=yellowgreen
+:hi Visual term=reverse cterm=reverse gui=none guibg=olivedrab guifg=khaki
+:hi VisualNOS term=bold,underline cterm=bold,underline
+:hi MoreMsg term=bold ctermfg=2 guifg=SeaGreen
+:hi ModeMsg term=bold cterm=bold guifg=goldenrod
+:hi Question term=standout ctermfg=2 guifg=springgreen
+:hi Title term=bold cterm=bold ctermfg=3 gui=bold guifg=gold
+:hi NonText term=bold cterm=bold ctermfg=4 guibg=grey15 guifg=RoyalBlue
+:hi LineNr term=underline cterm=bold ctermbg=0 ctermfg=0* guifg=grey50
+:hi Directory term=bold ctermfg=4
+:hi WildMenu term=standout ctermbg=3 ctermfg=0 guibg=darkyellow guifg=black
+:hi VertSplit term=reverse cterm=reverse gui=none guibg=#c2bfa5 guifg=grey40
+:hi Folded term=standout cterm=none ctermbg=0 ctermfg=7 guibg=black guifg=grey40
+:hi FoldColumn term=standout ctermbg=7 ctermfg=4 guibg=black guifg=grey20
+:hi DiffChange cterm=none ctermbg=7 ctermfg=0 guibg=darkgrey guifg=white
+:hi DiffText cterm=none ctermbg=6 ctermfg=0 guibg=darkcyan guifg=white
+:hi DiffAdd cterm=none ctermbg=2 ctermfg=0 guibg=darkgreen guifg=white
+:hi DiffDelete cterm=none ctermbg=7 ctermfg=0 guibg=darkgrey guifg=black
+:hi String cterm=none ctermfg=3 guifg=SkyBlue
+:hi Comment term=bold cterm=none ctermbg=0 ctermfg=7 guifg=grey40
+:hi Constant term=underline ctermfg=1 guifg=#ffa0a0
+:hi Special term=bold ctermfg=6 guifg=darkkhaki
+:hi Identifier term=underline ctermfg=6 guifg=salmon
+:hi Statement term=bold ctermfg=6 guifg=CornflowerBlue
+:hi Operator term=bold ctermfg=1 guifg=red
+:hi PreProc term=underline ctermbg=7 ctermfg=1 guibg=white guifg=red
+:hi Type term=underline ctermfg=2 guifg=CornflowerBlue
+:hi Delimiter term=none cterm=none ctermfg=1
+:hi Ignore cterm=bold ctermfg=7 guifg=grey40
+:hi Todo term=standout ctermbg=3 ctermfg=0 guibg=yellow2 guifg=orangered
+:hi Underlined term=underline cterm=underline
+:hi Include ctermfg=1 guifg=red
+:hi Define ctermfg=3 gui=bold guifg=gold
+:hi Function ctermfg=6 guifg=navajowhite
+:hi Structure ctermfg=2 guifg=green
+:hi MatchParen cterm=bold ctermbg=4 ctermfg=7
+:hi CursorLine cterm=bold,underline guibg=black
+:hi CursorColumn cterm=bold guibg=black
+:hi SpellBad term=underline,standout cterm=none ctermbg=7 ctermfg=0 guibg=darkmagenta guifg=white
+:hi SpellCap term=underline,standout cterm=none ctermbg=7 ctermfg=0
+:hi SpellLocal term=underline,standout cterm=none ctermbg=7 ctermfg=0 guibg=darkmagenta guifg=white
+:hi SpellRare term=underline,standout cterm=none ctermbg=7 ctermfg=0
+:hi WarningMsg term=standout ctermfg=1 guibg=darkmagenta guifg=salmon
+:hi ErrorMsg term=standout cterm=bold ctermbg=1 ctermfg=7 guibg=darkmagenta guifg=white
+:hi Error term=reverse cterm=bold ctermbg=1 ctermfg=7 guibg=darkmagenta guifg=white
+:hi Black ctermbg=grey ctermfg=black guibg=grey guifg=black
+:hi Red ctermbg=black ctermfg=red guibg=black guifg=red
+:hi Magenta ctermbg=black ctermfg=magenta guibg=black guifg=magenta
+:hi Blue ctermbg=black ctermfg=blue guibg=black guifg=blue
+:hi Cyan ctermbg=black ctermfg=cyan guibg=black guifg=cyan
+:hi Green ctermbg=black ctermfg=green guibg=black guifg=green
+:hi Yellow ctermbg=black ctermfg=yellow guibg=black guifg=yellow
+:hi White ctermbg=black ctermfg=white guibg=black guifg=white
diff --git a/sundry/editor-syntax-etc/vim/filetype.vim b/sundry/editor-syntax-etc/vim/filetype.vim
new file mode 100644
index 0000000..917c3e0
--- /dev/null
+++ b/sundry/editor-syntax-etc/vim/filetype.vim
@@ -0,0 +1,8 @@
+" SiSU filetype file
+if exists("did_load_filetypes")
+ finish
+endif
+augroup filetypedetect
+ au! BufNewFile,BufRead *.sst,*.ssm,*.ssi,*.-sst setf sisu
+ au! BufNewFile,BufRead *._sst,*.sst.meta,*.-sst.meta,*._sst.meta setf sisu
+augroup END
diff --git a/sundry/editor-syntax-etc/vim/ftplugin/sisu.vim b/sundry/editor-syntax-etc/vim/ftplugin/sisu.vim
new file mode 100644
index 0000000..43c7e53
--- /dev/null
+++ b/sundry/editor-syntax-etc/vim/ftplugin/sisu.vim
@@ -0,0 +1,224 @@
+"%% SiSU Vim ftplugin
+" SiSU Maintainer: Ralph Amissah <ralph@amissah.com>
+" SiSU Markup: SiSU (sisu-3.3) 2012-08-18
+" an ftplugin setting defaults for editing sisu markup files
+:syntax on
+:filetype off
+":filetype on
+:filetype indent on
+:autocmd FileType sisu :set nonumber
+:set encoding=utf-8 fileencodings=
+:set ff=unix
+:set autowrite " Automatically save before commands like :next and :make
+:set nocompatible
+:set tabstop=2
+:set expandtab
+:set shiftwidth=2
+:set autoindent
+:set showcmd " Show (partial) command in status line.
+:set showmatch " Show matching brackets.
+:set ignorecase " Do case insensitive matching
+:set smartcase
+:set incsearch
+:set hlsearch
+:set gdefault
+:set guioptions=agr " add 'm' for menu
+:map <silent> <C-m> :if &guioptions =~# 'm' <Bar>
+ \set guioptions-=m <Bar>
+ \set guioptions-=T <Bar>
+ \else <Bar>
+ \set guioptions+=m <Bar>
+ \set guioptions-=T <Bar>
+ \endif<CR>
+:set paste
+""% statusline
+"set statusline= "
+"set fillchars=stl:―,stlnc:—,vert:│,fold:۰,diff:·
+"" [ buffer number ]
+"set statusline +=%#Normal#[ "
+"set statusline +=%#Identifier#%n " buffer number
+"set statusline +=%#PreProc#%M " modified flag
+"set statusline +=%#Normal#] "
+"" [ file name (& modified?) ]
+"set statusline +=%#Normal#\ [ "
+"set statusline +=%#Statement#%<%F%* " full path
+""set statusline +=%#Statement#%<%t " full path
+"set statusline +=%#PreProc#%M " modified flag
+"set statusline +=%#Normal#] "
+"" [ column : line number / number of lines in file, percentage of file ] [%v:%l/%L\ %p%%]
+"set statusline +=%#Normal#\ [ "
+"set statusline +=%#Identifier#%v " column & line
+"set statusline +=%#Normal#: "
+"set statusline +=%#Identifier#%l " column & line
+"set statusline +=%#SpecialKey#/%L\ " total lines
+"set statusline +=%#Identifier#%p " percentage of file
+"set statusline +=%#SpecialKey#%% "
+"set statusline +=%#Normal#] " "
+"" [ file format : file type ]
+"set statusline +=%#Normal#\ [ "
+"set statusline +=%#SpecialKey#%{&fenc} " file format
+"set statusline +=%#Normal#: "
+"set statusline +=%#SpecialKey#%{&ff} " file format
+"set statusline +=%#Normal#: "
+"set statusline +=%#SpecialKey#%y " file type
+"set statusline +=%#Normal#] "
+"" [ character under cursor ]
+"set statusline +=%#Normal#\ [ "
+"set statusline +=%#String#0x%04B " character under cursor
+"set statusline +=%#Normal#]\ "
+"" [ syntastic ]
+"set statusline +=%#warningmsg#
+"set statusline +=%{SyntasticStatuslineFlag()}\ "
+""set statusline+=%*
+"" Status line background
+"set statusline +=%#Folded#\ "
+"" misc
+"set laststatus=2 " status line always on
+"% textwrap
+:set whichwrap=<,>,h,l,[,]
+:set nolinebreak " only affects display not buffer
+:set wrap
+:set wrapmargin=0
+"% map
+":let mapleader = "," " consider
+:map <leader>paste :set invpaste<cr>
+"% wrap/formatting paragraph according to the current 'textwidth' with ^\ (control-\):
+:imap <C-\> <C-O>gqap
+:nmap <C-\> gqap
+:vmap <C-\> gq
+"% save file, go to next file in buffer
+:map <leader>nf :w <enter> :n <enter>
+"% vimdiff q exits
+:if &diff
+: cmap q qa
+:endif
+"% directory files, placed in vertical split window
+:map <leader>ls :vs<cr> :Explore<cr>
+:map <leader>dir :vs<cr> :Explore<cr>
+"% remapping lines make cursor jump a line at a time within wrapped text
+:nnoremap j gj
+:nnoremap k gk
+:vnoremap j gj
+:vnoremap k gk
+:nnoremap <Down> gj
+:nnoremap <Up> gk
+:vnoremap <Down> gj
+:vnoremap <Up> gk
+:inoremap <Down> <C-o>gj
+:inoremap <Up> <C-o>gk
+"% search and replace
+:map <leader>rd :.,$s///c "search and replace down
+:map <leader>rg :%s///c "search and replace whole file
+:map <leader>rr :rubyd gsub!(//,"")
+"% pwd t64 working directory set to that of the file you're editing
+"changes pwd to directory of file in current buffer
+:function! CHANGE_CURR_DIR()
+: let _dir = expand("%:p:h")
+: exec "cd " . _dir
+: unlet _dir
+:endfunction
+"% Change to the directory the file in your current buffer is in
+:if has("autocmd")
+ autocmd BufEnter * :lcd %:p:h
+:endif
+"% autocompletefilenames To search for files in the current directory
+:set path=,,
+"auto-completion for file to edit in current dir, used in normal mode
+:map <leader>e :e <c-r>=expand("%:p:h") . "/" <cr>
+:map <leader>pwd :exe 'cd ' . expand ("%:p:h")<cr>
+"% searchhighlight t93: Toggle search highlight <C-n>
+:function! ToggleHLSearched()
+: if &hls
+: set nohls
+: else
+: set hls
+: endif
+:endfun
+:nmap <silent> <C-n> :silent call ToggleHLSearched()<cr>
+"%% SiSU vim folds
+"% foldsearchx FoldSearch (opens result of search all else closed) t77
+:map <leader>fs :set foldmethod=expr foldcolumn=2 foldlevel=0 <cr>
+:map <leader>ff :F<cr>
+:map <leader>fe :F<cr> zE
+"% foldtoggle Fold Toggle mapped to <space>
+:fun! ToggleFold()
+: if foldlevel('.') == 0
+: normal! l
+: else
+: if foldclosed('.') < 0
+: foldclose
+: else
+: foldopen
+: endif
+: endif
+" Clear status line
+: echo
+:endfun
+" Map this function to Space key.
+:noremap <space> :call ToggleFold()<cr>
+"% foldtype Fold? set foldtext
+:set foldtext=v:folddashes.substitute(getline(v:foldstart),'\\=','','g',)
+:set foldexpr=getline(v:lnum-1)!~@/&&getline(v:lnum)!~@/&&getline(v:lnum+1)!~@/
+"% foldsearch t77: Fold on search result
+:function! FoldMake(search)
+: set fdm=manual
+: normal zE
+: normal G$
+: let folded = 0 "flag to set when a fold is found
+: let flags = "w" "allow wrapping in the search
+: let line1 = 0 "set marker for beginning of fold
+: while search(a:search, flags) > 0
+: let line2 = line(".")
+: if (line2 -1 > line1)
+: "echo line1 . ":" . (line2-1)
+: "echo "a fold goes here."
+: execute ":" . line1 . "," . (line2-1) . "fold"
+: let folded = 1 "at least one fold has been found
+: endif
+: let line1 = line2 "update marker
+: let flags = "W" "turn off wrapping
+: endwhile
+" create the last fold which goes to the end of the file.
+: normal $G
+: let line2 = line(".")
+: if (line2 > line1 && folded == 1)
+: execute ":". line1 . "," . line2 . "fold"
+: endif
+: normal 1G
+:endfunction
+"% folds Fold Patterns
+:command! -nargs=+ -complete=command FMake call FoldMake(<q-args>)
+: if ( &filetype == "ruby" )
+: command! F FMake ^# ==\?\|^\s*\(\(def\|class\|module\)\s\|\(public\|protected\|private\|__END__\)\s*$\)\|\(^\s*\|\s\+\)#%\s
+: command! Fa FMake \(^# ==\?\|^\s*\(\(\(def\|class\|module\)\s\)\|\(\(public\|protected\|private\|__END__\)\(\s*$\)\)\)\)\|^[0-9]\~\|\([#%]\|^["]\)\{1,4\}\s*%\|{\({\|!!\)
+: command! FD FMake \(^# ==\?\|^\s*\(\(def\|class\|module\)\s\)\)\|^\s*\([#%"0-9]\{0,4\}\~\(%\+\s\|!!\)\|#\s\+=\+\s\+\)
+: else
+"% folds :F Fold Patterns SiSU Markup :F
+: command! F FMake ^\([1-8]\|:\?[A-C]\)\~\|\(^%\|\(^\|\s\+\)[#"]\)%\{1,2\}\(\s\|$\)\|^<<\s*|
+: command! Fa FMake ^\([1-8]\|:\?[A-C]\)\~\|\(^%\|\(^\|\s\+\)[#"]\)%\{1,2\}\(\s\|$\)\|^<<\s*|\|^\(Book\|Part\|Chapter\|Section\|Article\|BOOK\|PART\|CHAPTER\|SECTION\|ARTICLE\)\s
+: command! F0 FMake ^\(\s*0\~\|@\S\+:[+-]\?\s\+\)
+: command! FA FMake ^:\?A\~
+: command! FB FMake ^:\?[AB]\~
+: command! FC FMake ^:\?[A-C]\~
+: command! F1 FMake ^\(:\?[A-C]\|1\)\~
+: command! F2 FMake ^\(:\?[A-C]\|[12]\)\~
+: command! F3 FMake ^\(:\?[A-C]\|[1-3]\)\~
+: command! F4 FMake ^[1-4]\~
+: command! F5 FMake ^[4-5]\~
+: command! F6 FMake ^[4-6]\~
+: command! Fc FMake ^[%]\+\s\+
+: endif
+"% folds Fold Patterns misc
+":command! Fp FMake ^\s*[A-Za-z0-9#]
+:command! Fp FMake ^\s*\S
+:command! Fo FMake ^[%\"]\s*[{>]
+"% linenumbering, on, relative, off
+:map <Leader>nn :set <c-r>={'00':'','01':'r','10':'nor'}[&rnu.&nu]<CR>nu<CR>
+"% cursorline
+:map <leader>cu :if &cursorcolumn <Bar>
+ \set nocursorline nocursorcolumn <Bar>
+ \else <Bar>
+ \set cursorline cursorcolumn <Bar>
+ \endif<cr>
+:map <leader>cu- :set nocursorline nocursorcolumn<cr>
+:map <leader>cu+ :set cursorline cursorcolumn<cr>
diff --git a/sundry/editor-syntax-etc/vim/templates/ssi.tpl b/sundry/editor-syntax-etc/vim/templates/ssi.tpl
new file mode 100644
index 0000000..28e8101
--- /dev/null
+++ b/sundry/editor-syntax-etc/vim/templates/ssi.tpl
@@ -0,0 +1,30 @@
+# SiSU 8.0 insert
+
+title:
+ main: "#___#"
+ sub: "#___#"
+ language: "#___#"
+
+creator:
+ author: "#___#"
+
+date:
+ :published: "YYYY-MM-DD"
+
+rights:
+ copyright: "#___#"
+ license: "#___#"
+
+classify:
+ topic_register: "#___#"
+
+make:
+ breaks: "new=:B; break=1"
+# home_button_text: "#___#"
+# footer: "#___#"
+
+#% -- body ---
+
+:A~ @title @author
+
+1~ #___#
diff --git a/sundry/editor-syntax-etc/vim/templates/ssm.tpl b/sundry/editor-syntax-etc/vim/templates/ssm.tpl
new file mode 100644
index 0000000..579375f
--- /dev/null
+++ b/sundry/editor-syntax-etc/vim/templates/ssm.tpl
@@ -0,0 +1,30 @@
+# SiSU 8.0 master
+
+title:
+ main: "#___#"
+ sub: "#___#"
+ language: "#___#"
+
+creator:
+ author: "#___#"
+
+date:
+ :published: "YYYY-MM-DD"
+
+rights:
+ copyright: "#___#"
+ license: "#___#"
+
+classify:
+ topic_register: "#___#"
+
+make:
+ breaks: "new=:B; break=1"
+# home_button_text: "#___#"
+# footer: "#___#"
+
+#% -- body ---
+
+:A~ @title @author
+
+1~ #___#
diff --git a/sundry/editor-syntax-etc/vim/templates/sst.tpl b/sundry/editor-syntax-etc/vim/templates/sst.tpl
new file mode 100644
index 0000000..069d498
--- /dev/null
+++ b/sundry/editor-syntax-etc/vim/templates/sst.tpl
@@ -0,0 +1,30 @@
+# SiSU 8.0
+
+title:
+ main: "#___#"
+ sub: "#___#"
+ language: "#___#"
+
+creator:
+ author: "#___#"
+
+date:
+ :published: "YYYY-MM-DD"
+
+rights:
+ copyright: "#___#"
+ license: "#___#"
+
+classify:
+ topic_register: "#___#"
+
+make:
+ breaks: "new=:B; break=1"
+# home_button_text: "#___#"
+# footer: "#___#"
+
+#% -- body ---
+
+:A~ @title @author
+
+1~ #___#
diff --git a/sundry/editor-syntax-etc/vim/vim-sisu.yaml b/sundry/editor-syntax-etc/vim/vim-sisu.yaml
new file mode 100644
index 0000000..ca665bc
--- /dev/null
+++ b/sundry/editor-syntax-etc/vim/vim-sisu.yaml
@@ -0,0 +1,7 @@
+#vim-addons: debian vim-addon-manager
+addon: sisu
+description: SiSU documents - structuring, publishing in multiple formats and search
+basedir: /usr/share/vim-scripts/
+files:
+ - ftplugin/sisu.vim
+ - syntax/sisu.vim
diff --git a/sundry/misc/util/d/cgi/search/src/spine_cgi_sqlite_search.d b/sundry/misc/util/d/cgi/search/src/spine_cgi_sqlite_search.d
index 987c319..aa073c0 100644
--- a/sundry/misc/util/d/cgi/search/src/spine_cgi_sqlite_search.d
+++ b/sundry/misc/util/d/cgi/search/src/spine_cgi_sqlite_search.d
@@ -40,7 +40,7 @@
- docReform object numbering
- standard SiSU object citation numbering & system
- - Hompages:
+ - Homepages:
[https://www.doc_reform.org]
[https://www.sisudoc.org]
@@ -118,325 +118,325 @@ void cgi_function_intro(Cgi cgi) {
// cgi.write(field ~ ": " ~ content ~ "<br>");
// }
}
- 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 identifier = ctRegex!(`(?:^|\s~\s*)identifier:\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");
- }
- struct searchFields {
- string canned_query = ""; // GET canned_query == cq
- string search_text_area = ""; // POST search_text_area == tsa
- string text = ""; // text == txt
- string author = ""; // author == au
- string title = ""; // title == ti
- string uid = ""; // uid == uid
- string fn = ""; // fn == fn
- string keywords = ""; // keywords == kw
- string topic_register = ""; // topic_register == tr
- string subject = ""; // subject == su
- string description = ""; // description == de
- string publisher = ""; // publisher == pb
- string editor = ""; // editor == ed
- string contributor = ""; // contributor == ct
- string date = ""; // date == dt
- string format = ""; // format == fmt
- string identifier = ""; // identifier == id
- string source = ""; // source == src sfn
- string language = ""; // language == lng
- string relation = ""; // relation == rl
- string coverage = ""; // coverage == cv
- string rights = ""; // rights == rgt
- string comment = ""; // comment == cmt
- // string abstract = "";
- string src_filename_base = ""; // src_filename_base == bfn
- string results_type = ""; // results_type == rt radio
- string sql_match_limit = ""; // sql_match_limit == sml radio
- string sql_match_offset = ""; // sql_match_offset == smo
- string stats = ""; // stats == sts checked
- string echo = ""; // echo == ec checked
- string url = ""; // url == url checked
- string searched = ""; // searched == se checked
- string sql = ""; // sql == sql checked
- }
- auto rgx = Rgx();
- auto got = searchFields();
- if (environment.get("REQUEST_METHOD", "POST") == "POST") {
- if ("sf" in cgi.post) {
- got.search_text_area = cgi.post["sf"];
- if (auto m = got.search_text_area.matchFirst(rgx.text)) {
+ 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 identifier = ctRegex!(`(?:^|\s~\s*)identifier:\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");
+ }
+ struct searchFields {
+ string canned_query = ""; // GET canned_query == cq
+ string search_text_area = ""; // POST search_text_area == tsa
+ string text = ""; // text == txt
+ string author = ""; // author == au
+ string title = ""; // title == ti
+ string uid = ""; // uid == uid
+ string fn = ""; // fn == fn
+ string keywords = ""; // keywords == kw
+ string topic_register = ""; // topic_register == tr
+ string subject = ""; // subject == su
+ string description = ""; // description == de
+ string publisher = ""; // publisher == pb
+ string editor = ""; // editor == ed
+ string contributor = ""; // contributor == ct
+ string date = ""; // date == dt
+ string format = ""; // format == fmt
+ string identifier = ""; // identifier == id
+ string source = ""; // source == src sfn
+ string language = ""; // language == lng
+ string relation = ""; // relation == rl
+ string coverage = ""; // coverage == cv
+ string rights = ""; // rights == rgt
+ string comment = ""; // comment == cmt
+ // string abstract = "";
+ string src_filename_base = ""; // src_filename_base == bfn
+ string results_type = ""; // results_type == rt radio
+ string sql_match_limit = ""; // sql_match_limit == sml radio
+ string sql_match_offset = ""; // sql_match_offset == smo
+ string stats = ""; // stats == sts checked
+ string echo = ""; // echo == ec checked
+ string url = ""; // url == url checked
+ string searched = ""; // searched == se checked
+ string sql = ""; // sql == sql checked
+ }
+ auto rgx = Rgx();
+ auto got = searchFields();
+ if (environment.get("REQUEST_METHOD", "POST") == "POST") {
+ if ("sf" in cgi.post) {
+ got.search_text_area = cgi.post["sf"];
+ if (auto m = got.search_text_area.matchFirst(rgx.text)) {
+ got.text = m["matched"];
+ got.canned_query ~= "sf=" ~ m["matched"];
+ } else if (auto m = got.search_text_area.matchFirst(rgx.line)) {
+ if (
+ !(m["matched"].matchFirst(rgx.author))
+ && !(m["matched"].matchFirst(rgx.title))
+ ) {
got.text = m["matched"];
got.canned_query ~= "sf=" ~ m["matched"];
- } else if (auto m = got.search_text_area.matchFirst(rgx.line)) {
- if (
- !(m["matched"].matchFirst(rgx.author))
- && !(m["matched"].matchFirst(rgx.title))
- ) {
- got.text = m["matched"];
- got.canned_query ~= "sf=" ~ m["matched"];
- }
- }
- if (auto m = got.search_text_area.matchFirst(rgx.author)) {
- got.author = m["matched"];
- got.canned_query ~= "&au=" ~ m["matched"];
- }
- if (auto m = got.search_text_area.matchFirst(rgx.title)) {
- got.title = m["matched"];
- got.canned_query ~= "&ti=" ~ m["matched"];
- }
- if (auto m = got.search_text_area.matchFirst(rgx.uid)) {
- got.uid = m["matched"];
- got.canned_query ~= "&uid=" ~ m["matched"];
- }
- if (auto m = got.search_text_area.matchFirst(rgx.fn)) {
- got.fn = m["matched"];
- got.canned_query ~= "&fn=" ~ m["matched"];
- }
- if (auto m = got.search_text_area.matchFirst(rgx.keywords)) {
- got.keywords = m["matched"];
- got.canned_query ~= "&kw=" ~ m["matched"];
- }
- if (auto m = got.search_text_area.matchFirst(rgx.topic_register)) {
- got.topic_register = m["matched"];
- got.canned_query ~= "&tr=" ~ m["matched"];
- }
- if (auto m = got.search_text_area.matchFirst(rgx.subject)) {
- got.subject = m["matched"];
- got.canned_query ~= "&su=" ~ m["matched"];
- }
- if (auto m = got.search_text_area.matchFirst(rgx.description)) {
- got.description = m["matched"];
- got.canned_query ~= "&de=" ~ m["matched"];
- }
- if (auto m = got.search_text_area.matchFirst(rgx.publisher)) {
- got.publisher = m["matched"];
- got.canned_query ~= "&pb=" ~ m["matched"];
- }
- if (auto m = got.search_text_area.matchFirst(rgx.editor)) {
- got.editor = m["matched"];
- got.canned_query ~= "&ed=" ~ m["matched"];
- }
- if (auto m = got.search_text_area.matchFirst(rgx.contributor)) {
- got.contributor = m["matched"];
- got.canned_query ~= "&ct=" ~ m["matched"];
- }
- if (auto m = got.search_text_area.matchFirst(rgx.date)) {
- got.date = m["matched"];
- got.canned_query ~= "&dt=" ~ m["matched"];
- }
- // if (auto m = got.search_text_area.matchFirst(rgx.results_type)) {
- // got.results_type = m["matched"];
- // got.canned_query ~= "&rt=" ~ m["matched"];
- // }
- if (auto m = got.search_text_area.matchFirst(rgx.format)) {
- got.format = m["matched"];
- got.canned_query ~= "&fmt=" ~ m["matched"];
- }
- if (auto m = got.search_text_area.matchFirst(rgx.identifier)) {
- got.identifier = m["matched"];
- got.canned_query ~= "&id=" ~ m["matched"];
- }
- if (auto m = got.search_text_area.matchFirst(rgx.source)) {
- got.source = m["matched"];
- got.canned_query ~= "&src=" ~ m["matched"];
- }
- if (auto m = got.search_text_area.matchFirst(rgx.language)) {
- got.language = m["matched"];
- got.canned_query ~= "&lng=" ~ m["matched"];
- }
- if (auto m = got.search_text_area.matchFirst(rgx.relation)) {
- got.relation = m["matched"];
- got.canned_query ~= "&rl=" ~ m["matched"];
- }
- if (auto m = got.search_text_area.matchFirst(rgx.coverage)) {
- got.coverage = m["matched"];
- got.canned_query ~= "&cv=" ~ m["matched"];
- }
- if (auto m = got.search_text_area.matchFirst(rgx.rights)) {
- got.rights = m["matched"];
- got.canned_query ~= "&rgt=" ~ m["matched"];
- }
- if (auto m = got.search_text_area.matchFirst(rgx.comment)) {
- got.comment = m["matched"];
- got.canned_query ~= "&cmt=" ~ m["matched"];
- }
- // if (auto m = search_text_area.matchFirst(rgx.abstract)) {
- // got.abstract = m["matched"];
- // }
- if (auto m = got.search_text_area.matchFirst(rgx.src_filename_base)) {
- got.src_filename_base = m["matched"];
- got.canned_query ~= "&bfn=" ~ m["matched"];
}
}
- if ("fn" in cgi.post) {
- got.fn = cgi.post["fn"];
- got.canned_query ~= "&fn=" ~ cgi.post["fn"];
+ if (auto m = got.search_text_area.matchFirst(rgx.author)) {
+ got.author = m["matched"];
+ got.canned_query ~= "&au=" ~ m["matched"];
}
- if ("rt" in cgi.post) {
- got.results_type = cgi.post["rt"];
- got.canned_query ~= "&rt=" ~ cgi.post["rt"];
+ if (auto m = got.search_text_area.matchFirst(rgx.title)) {
+ got.title = m["matched"];
+ got.canned_query ~= "&ti=" ~ m["matched"];
}
- if ("sts" in cgi.post) {
- got.stats = cgi.post["sts"];
- got.canned_query ~= "&sts=" ~ cgi.post["sts"];
+ if (auto m = got.search_text_area.matchFirst(rgx.uid)) {
+ got.uid = m["matched"];
+ got.canned_query ~= "&uid=" ~ m["matched"];
}
- if ("ec" in cgi.post) {
- got.echo = cgi.post["ec"];
- got.canned_query ~= "&ec=" ~ cgi.post["ec"];
+ if (auto m = got.search_text_area.matchFirst(rgx.fn)) {
+ got.fn = m["matched"];
+ got.canned_query ~= "&fn=" ~ m["matched"];
}
- if ("url" in cgi.post) {
- got.url = cgi.post["url"];
- got.canned_query ~= "&url=" ~ cgi.post["url"];
+ if (auto m = got.search_text_area.matchFirst(rgx.keywords)) {
+ got.keywords = m["matched"];
+ got.canned_query ~= "&kw=" ~ m["matched"];
}
- if ("se" in cgi.post) {
- got.searched = cgi.post["se"];
- got.canned_query ~= "&se=" ~ cgi.post["se"];
+ if (auto m = got.search_text_area.matchFirst(rgx.topic_register)) {
+ got.topic_register = m["matched"];
+ got.canned_query ~= "&tr=" ~ m["matched"];
}
- if ("sql" in cgi.post) {
- got.sql = cgi.post["sql"];
- got.canned_query ~= "&sql=" ~ cgi.post["sql"];
+ if (auto m = got.search_text_area.matchFirst(rgx.subject)) {
+ got.subject = m["matched"];
+ got.canned_query ~= "&su=" ~ m["matched"];
}
- if ("sml" in cgi.post) {
- got.sql_match_limit = cgi.post["sml"];
- got.canned_query ~= "&sml=" ~ cgi.post["sml"];
- }
- if ("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 (auto m = got.search_text_area.matchFirst(rgx.description)) {
+ got.description = m["matched"];
+ got.canned_query ~= "&de=" ~ m["matched"];
}
- 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 (auto m = got.search_text_area.matchFirst(rgx.publisher)) {
+ got.publisher = m["matched"];
+ got.canned_query ~= "&pb=" ~ m["matched"];
}
- 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 (auto m = got.search_text_area.matchFirst(rgx.editor)) {
+ got.editor = m["matched"];
+ got.canned_query ~= "&ed=" ~ m["matched"];
}
- 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 (auto m = got.search_text_area.matchFirst(rgx.contributor)) {
+ got.contributor = m["matched"];
+ got.canned_query ~= "&ct=" ~ m["matched"];
}
- 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 (auto m = got.search_text_area.matchFirst(rgx.date)) {
+ got.date = m["matched"];
+ got.canned_query ~= "&dt=" ~ m["matched"];
}
- 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 (auto m = got.search_text_area.matchFirst(rgx.results_type)) {
+ // got.results_type = m["matched"];
+ // got.canned_query ~= "&rt=" ~ m["matched"];
+ // }
+ if (auto m = got.search_text_area.matchFirst(rgx.format)) {
+ got.format = m["matched"];
+ got.canned_query ~= "&fmt=" ~ m["matched"];
}
- if ("id" in canned_query && !(canned_query["id"]).empty) {
- got.identifier = canned_query["id"].split("%20").join(" ");
- got.search_text_area ~= "identifier: " ~ got.identifier ~ "\n";
+ if (auto m = got.search_text_area.matchFirst(rgx.identifier)) {
+ got.identifier = m["matched"];
+ got.canned_query ~= "&id=" ~ m["matched"];
}
- if ("src" in canned_query && !(canned_query["src"]).empty) {
- got.source = canned_query["src"].split("%20").join(" ");
- got.search_text_area ~= "source: " ~ got.source ~ "\n";
+ if (auto m = got.search_text_area.matchFirst(rgx.source)) {
+ got.source = m["matched"];
+ got.canned_query ~= "&src=" ~ m["matched"];
}
- if ("lng" in canned_query && !(canned_query["lng"]).empty) {
- got.language = canned_query["lng"].split("%20").join(" ");
- got.search_text_area ~= "language: " ~ got.language ~ "\n";
+ if (auto m = got.search_text_area.matchFirst(rgx.language)) {
+ got.language = m["matched"];
+ got.canned_query ~= "&lng=" ~ m["matched"];
}
- if ("rl" in canned_query && !(canned_query["rl"]).empty) {
- got.relation = canned_query["rl"].split("%20").join(" ");
- got.search_text_area ~= "relation: " ~ got.relation ~ "\n";
+ if (auto m = got.search_text_area.matchFirst(rgx.relation)) {
+ got.relation = m["matched"];
+ got.canned_query ~= "&rl=" ~ m["matched"];
}
- if ("cv" in canned_query && !(canned_query["cv"]).empty) {
- got.coverage = canned_query["cv"].split("%20").join(" ");
- got.search_text_area ~= "coverage: " ~ got.coverage ~ "\n";
+ if (auto m = got.search_text_area.matchFirst(rgx.coverage)) {
+ got.coverage = m["matched"];
+ got.canned_query ~= "&cv=" ~ m["matched"];
}
- if ("rgt" in canned_query && !(canned_query["rgt"]).empty) {
- got.rights = canned_query["rgt"].split("%20").join(" ");
- got.search_text_area ~= "rights: " ~ got.rights ~ "\n";
+ if (auto m = got.search_text_area.matchFirst(rgx.rights)) {
+ got.rights = m["matched"];
+ got.canned_query ~= "&rgt=" ~ m["matched"];
}
- if ("cmt" in canned_query && !(canned_query["cmt"]).empty) {
- got.comment = canned_query["cmt"].split("%20").join(" ");
- got.search_text_area ~= "comment: " ~ got.comment ~ "\n";
+ if (auto m = got.search_text_area.matchFirst(rgx.comment)) {
+ got.comment = m["matched"];
+ got.canned_query ~= "&cmt=" ~ m["matched"];
}
- // if ("abstract" in canned_query && !(canned_query["abstract"]).empty) {
- // got.abstract = canned_query["abstract"];
+ // if (auto m = search_text_area.matchFirst(rgx.abstract)) {
+ // got.abstract = m["matched"];
// }
- if ("bfn" in canned_query && !(canned_query["bfn"]).empty) { // search_field
- got.src_filename_base = canned_query["bfn"].split("%20").join(" ");
- got.search_text_area ~= "src_filename_base: " ~ got.src_filename_base ~ "\n";
- }
- if ("sml" in canned_query && !(canned_query["sml"]).empty) {
- got.sql_match_limit = canned_query["sml"].split("%20").join(" ");
- // got.search_text_area ~= "sql_match_limit: " ~ got.sql_match_limit ~ "\n";
+ if (auto m = got.search_text_area.matchFirst(rgx.src_filename_base)) {
+ got.src_filename_base = m["matched"];
+ got.canned_query ~= "&bfn=" ~ m["matched"];
}
- // cgi.write("f.search_text_area: " ~ got.search_text_area ~ "<br>");
}
- return got;
+ if ("fn" in cgi.post) {
+ got.fn = cgi.post["fn"];
+ got.canned_query ~= "&fn=" ~ cgi.post["fn"];
+ }
+ if ("rt" in cgi.post) {
+ got.results_type = cgi.post["rt"];
+ got.canned_query ~= "&rt=" ~ cgi.post["rt"];
+ }
+ if ("sts" in cgi.post) {
+ got.stats = cgi.post["sts"];
+ got.canned_query ~= "&sts=" ~ cgi.post["sts"];
+ }
+ if ("ec" in cgi.post) {
+ got.echo = cgi.post["ec"];
+ got.canned_query ~= "&ec=" ~ cgi.post["ec"];
+ }
+ if ("url" in cgi.post) {
+ got.url = cgi.post["url"];
+ got.canned_query ~= "&url=" ~ cgi.post["url"];
+ }
+ if ("se" in cgi.post) {
+ got.searched = cgi.post["se"];
+ got.canned_query ~= "&se=" ~ cgi.post["se"];
+ }
+ if ("sql" in cgi.post) {
+ got.sql = cgi.post["sql"];
+ got.canned_query ~= "&sql=" ~ cgi.post["sql"];
+ }
+ if ("sml" in cgi.post) {
+ got.sql_match_limit = cgi.post["sml"];
+ got.canned_query ~= "&sml=" ~ cgi.post["sml"];
+ }
+ if ("smo" in cgi.post) {
+ got.sql_match_offset = "0"; // cgi.post["smo"];
+ got.canned_query ~= "&smo=0"; // ~ cgi.post["smo"];
+ }
+ got.canned_query = got.canned_query.strip.split(" ").join("%20");
+ conf.query_string = got.canned_query;
+ // cgi.write("f.canned_query: " ~ got.canned_query ~ "<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 ("id" in canned_query && !(canned_query["id"]).empty) {
+ got.identifier = canned_query["id"].split("%20").join(" ");
+ got.search_text_area ~= "identifier: " ~ got.identifier ~ "\n";
+ }
+ if ("src" in canned_query && !(canned_query["src"]).empty) {
+ got.source = canned_query["src"].split("%20").join(" ");
+ got.search_text_area ~= "source: " ~ got.source ~ "\n";
+ }
+ if ("lng" in canned_query && !(canned_query["lng"]).empty) {
+ got.language = canned_query["lng"].split("%20").join(" ");
+ got.search_text_area ~= "language: " ~ got.language ~ "\n";
+ }
+ if ("rl" in canned_query && !(canned_query["rl"]).empty) {
+ got.relation = canned_query["rl"].split("%20").join(" ");
+ got.search_text_area ~= "relation: " ~ got.relation ~ "\n";
+ }
+ if ("cv" in canned_query && !(canned_query["cv"]).empty) {
+ got.coverage = canned_query["cv"].split("%20").join(" ");
+ got.search_text_area ~= "coverage: " ~ got.coverage ~ "\n";
+ }
+ if ("rgt" in canned_query && !(canned_query["rgt"]).empty) {
+ got.rights = canned_query["rgt"].split("%20").join(" ");
+ got.search_text_area ~= "rights: " ~ got.rights ~ "\n";
+ }
+ if ("cmt" in canned_query && !(canned_query["cmt"]).empty) {
+ got.comment = canned_query["cmt"].split("%20").join(" ");
+ got.search_text_area ~= "comment: " ~ got.comment ~ "\n";
+ }
+ // if ("abstract" in canned_query && !(canned_query["abstract"]).empty) {
+ // got.abstract = canned_query["abstract"];
+ // }
+ if ("bfn" in canned_query && !(canned_query["bfn"]).empty) { // search_field
+ got.src_filename_base = canned_query["bfn"].split("%20").join(" ");
+ got.search_text_area ~= "src_filename_base: " ~ got.src_filename_base ~ "\n";
+ }
+ if ("sml" in canned_query && !(canned_query["sml"]).empty) {
+ got.sql_match_limit = canned_query["sml"].split("%20").join(" ");
+ // got.search_text_area ~= "sql_match_limit: " ~ got.sql_match_limit ~ "\n";
+ }
+ // cgi.write("f.search_text_area: " ~ got.search_text_area ~ "<br>");
+ }
+ return got;
}
auto tf = text_fields; //
struct SQL_select {
@@ -573,96 +573,96 @@ void cgi_function_intro(Cgi cgi) {
conf.http_host,
);
}
- {
- 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">
- <br /><a href="https://sisudoc.org/" target="_top">
- <b>SiSU</b>
- </a>
- <br /><a href="https://git.sisudoc.org/" target="_top">
- git
- </a>
- </td></tr>
- </table>
- </td>
- <td>
- <label for="find"><b>SiSU spine (generated) search form</b></label>
+ {
+ 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">
+ <br /><a href="https://sisudoc.org/" target="_top">
+ <b>SiSU</b>
+ </a>
+ <br /><a href="https://git.sisudoc.org/" target="_top">
+ git
+ </a>
</td></tr>
</table>
- ┃");
- }
- {
- string post_value(string field_name, string type="box", string set="on") {
- string val = "";
- switch (type) {
- case "field":
- val = ((field_name in cgi.post && !(cgi.post[field_name]).empty)
- ? cgi.post[field_name]
- : (field_name in cgi.get)
- ? cgi.get[field_name]
- : "");
- val = tf.search_text_area;
- break;
- case "box": // generic for checkbox or radio; checkbox set == "on" radio set == "name set"
- val = ((field_name in cgi.post && !(cgi.post[field_name]).empty)
- ? (cgi.post[field_name] == set ? "checked" : "off")
- : (field_name in cgi.get)
- ? (cgi.get[field_name] == set ? "checked" : "off")
- : "off");
- break;
- case "radio": // used generic bo
- val = ((field_name in cgi.post && !(cgi.post[field_name]).empty)
- ? (cgi.post[field_name] == set ? "checked" : "off")
- : (field_name in cgi.get)
- ? (cgi.get[field_name] == set ? "checked" : "off")
- : "checked");
- break;
- case "checkbox": // used generic bo
- val = ((field_name in cgi.post && !(cgi.post[field_name]).empty)
- ? (cgi.post[field_name] == set ? "checked" : "off")
- : (field_name in cgi.get)
- ? (cgi.get[field_name] == set ? "checked" : "off")
- : "checked");
- break;
- default:
- }
- return val;
+</td>
+<td>
+ <label for="find"><b>SiSU spine (generated) search form</b></label>
+</td></tr>
+</table>
+┃");
+ }
+{
+ string post_value(string field_name, string type="box", string set="on") {
+ string val = "";
+ switch (type) {
+ case "field":
+ val = ((field_name in cgi.post && !(cgi.post[field_name]).empty)
+ ? cgi.post[field_name]
+ : (field_name in cgi.get)
+ ? cgi.get[field_name]
+ : "");
+ val = tf.search_text_area;
+ break;
+ case "box": // generic for checkbox or radio; checkbox set == "on" radio set == "name set"
+ val = ((field_name in cgi.post && !(cgi.post[field_name]).empty)
+ ? (cgi.post[field_name] == set ? "checked" : "off")
+ : (field_name in cgi.get)
+ ? (cgi.get[field_name] == set ? "checked" : "off")
+ : "off");
+ break;
+ case "radio": // used generic bo
+ val = ((field_name in cgi.post && !(cgi.post[field_name]).empty)
+ ? (cgi.post[field_name] == set ? "checked" : "off")
+ : (field_name in cgi.get)
+ ? (cgi.get[field_name] == set ? "checked" : "off")
+ : "checked");
+ break;
+ case "checkbox": // used generic bo
+ val = ((field_name in cgi.post && !(cgi.post[field_name]).empty)
+ ? (cgi.post[field_name] == set ? "checked" : "off")
+ : (field_name in cgi.get)
+ ? (cgi.get[field_name] == set ? "checked" : "off")
+ : "checked");
+ break;
+ default:
}
- string the_can(string fv) {
- string show_the_can = post_value("url");
- string _the_can = "";
- if (show_the_can == "checked") {
- tf = text_fields;
- string method_get_url = conf.http_request_type ~ "://" ~ conf.http_host ~ conf.cgi_script ~ "?" ~ environment.get("QUERY_STRING", "");
- string method_post_url_construct = conf.http_request_type ~ "://" ~ conf.http_host ~ conf.cgi_script ~ "?" ~ tf.canned_query;
- // assert(method_get_url == environment.get("HTTP_REFERER", conf.http_request_type ~ "://" ~ conf.http_host ~ conf.cgi_script ~ "?" ~ conf.query_string));
- if (conf.request_method == "POST") {
- _the_can =
- "<font size=\"2\" color=\"#666666\">"
- ~ "POST:&nbsp;"
- ~ "<a href=\""
- ~ method_post_url_construct
- ~ "\">"
- ~ method_post_url_construct
- ~ "</a></font>"
- ~ "<br>";
- } else if (conf.request_method == "GET") {
- _the_can =
- "<font size=\"2\" color=\"#666666\">"
- ~ "GET:&nbsp;&nbsp;"
- ~ "<a href=\""
- ~ method_get_url
- ~ "\">"
- ~ method_get_url
- ~ "</a></font>";
- }
- conf.http_url = conf.http_request_type ~ "://" ~ conf.http_host ~ conf.cgi_script ~ tf.canned_query;
- }
- return _the_can;
+ return val;
+ }
+string the_can(string fv) {
+ string show_the_can = post_value("url");
+ string _the_can = "";
+ if (show_the_can == "checked") {
+ tf = text_fields;
+ string method_get_url = conf.http_request_type ~ "://" ~ conf.http_host ~ conf.cgi_script ~ "?" ~ environment.get("QUERY_STRING", "");
+ string method_post_url_construct = conf.http_request_type ~ "://" ~ conf.http_host ~ conf.cgi_script ~ "?" ~ tf.canned_query;
+ // assert(method_get_url == environment.get("HTTP_REFERER", conf.http_request_type ~ "://" ~ conf.http_host ~ conf.cgi_script ~ "?" ~ conf.query_string));
+ if (conf.request_method == "POST") {
+ _the_can =
+ "<font size=\"2\" color=\"#666666\">"
+ ~ "POST:&nbsp;"
+ ~ "<a href=\""
+ ~ method_post_url_construct
+ ~ "\">"
+ ~ method_post_url_construct
+ ~ "</a></font>"
+ ~ "<br>";
+ } else if (conf.request_method == "GET") {
+ _the_can =
+ "<font size=\"2\" color=\"#666666\">"
+ ~ "GET:&nbsp;&nbsp;"
+ ~ "<a href=\""
+ ~ method_get_url
+ ~ "\">"
+ ~ method_get_url
+ ~ "</a></font>";
}
+ conf.http_url = conf.http_request_type ~ "://" ~ conf.http_host ~ conf.cgi_script ~ tf.canned_query;
+ }
+ return _the_can;
+}
string provide_tip() {
string searched_tip = post_value("se");
string tip = "";
@@ -732,59 +732,59 @@ void cgi_function_intro(Cgi cgi) {
</table>
</form>
┃",
- "spine-search",
- (post_value("ec") == "checked") ? post_value("sf", "field") : "",
- provide_tip,
- search_note,
- the_can(post_value("sf", "field")),
- cv.db_selected,
- cv.db_selected,
- post_value("rt", "box", "idx"),
- post_value("rt", "box", "txt"),
- post_value("sml", "box", "1000"),
- post_value("sml", "box", "2500"),
- post_value("ec"),
- post_value("sts"),
- post_value("url"),
- post_value("se"),
- post_value("tip"),
- post_value("sql"),
- );
- {
- string set_value(string field_name, string default_val) {
- string val;
- if (field_name in cgi.post) {
- val = cgi.post[field_name];
- } else if (field_name in cgi.get) {
- val = cgi.get[field_name];
- } else { val = default_val; }
- return val;
- }
- bool set_bool(string field_name) {
- bool val;
- if (field_name in cgi.post
- && cgi.post[field_name] == "on") {
- val = true;
- } else if (field_name in cgi.get
- && cgi.get[field_name] == "on") {
- val = true;
- } else { val = false; }
- return val;
- }
- cv.db_selected = set_value("selected_db", "spine.search.db"); // selected_db == db
- cv.sql_match_limit = set_value("sml", "1000");
- cv.sql_match_offset = set_value("smo", "0");
- cv.search_text = set_value("sf", "test"); // remove test
- cv.results_type = set_value("rt", "idx");
- cv.checked_echo = set_bool("ec");
- cv.checked_stats = set_bool("sts");
- cv.checked_url = set_bool("url");
- cv.checked_searched = set_bool("se");
- cv.checked_tip = set_bool("tip");
- cv.checked_sql = set_bool("sql");
- tf = text_fields;
+ "spine-search",
+ (post_value("ec") == "checked") ? post_value("sf", "field") : "",
+ provide_tip,
+ search_note,
+ the_can(post_value("sf", "field")),
+ cv.db_selected,
+ cv.db_selected,
+ post_value("rt", "box", "idx"),
+ post_value("rt", "box", "txt"),
+ post_value("sml", "box", "1000"),
+ post_value("sml", "box", "2500"),
+ post_value("ec"),
+ post_value("sts"),
+ post_value("url"),
+ post_value("se"),
+ post_value("tip"),
+ post_value("sql"),
+);
+ {
+ string set_value(string field_name, string default_val) {
+ string val;
+ if (field_name in cgi.post) {
+ val = cgi.post[field_name];
+ } else if (field_name in cgi.get) {
+ val = cgi.get[field_name];
+ } else { val = default_val; }
+ return val;
+ }
+ bool set_bool(string field_name) {
+ bool val;
+ if (field_name in cgi.post
+ && cgi.post[field_name] == "on") {
+ val = true;
+ } else if (field_name in cgi.get
+ && cgi.get[field_name] == "on") {
+ val = true;
+ } else { val = false; }
+ return val;
}
+ cv.db_selected = set_value("selected_db", "spine.search.db"); // selected_db == db
+ cv.sql_match_limit = set_value("sml", "1000");
+ cv.sql_match_offset = set_value("smo", "0");
+ cv.search_text = set_value("sf", "test"); // remove test
+ cv.results_type = set_value("rt", "idx");
+ cv.checked_echo = set_bool("ec");
+ cv.checked_stats = set_bool("sts");
+ cv.checked_url = set_bool("url");
+ cv.checked_searched = set_bool("se");
+ cv.checked_tip = set_bool("tip");
+ cv.checked_sql = set_bool("sql");
+ tf = text_fields;
}
+}
{
cgi.write(header);
cgi.write(table);
@@ -888,68 +888,68 @@ LIMIT %s OFFSET %s
cv.sql_match_limit,
cv.sql_match_offset,
);
- (cv.checked_sql)
- ? cgi.write(previous_next ~ "<hr><font size=\"2\" color=\"#666666\">" ~ sql_select.the_body.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) {
- foreach (row; select_query_results) {
- if (row["uid"].as!string != _old_uid) {
- _old_uid = row["uid"].as!string;
- auto m = (row["date_published"].as!string).match(regex(r"^([0-9]{4})")); // breaks if row missing or no match?
- cgi.write(
- "<hr><a href=\""
- ~ "https://" ~ conf.http_host ~ "/"
- ~ row["language_document_char"].as!string ~ "/html/"
- ~ row["src_filename_base"].as!string ~ "/"
- ~ "toc.html"
- ~ "\">\""
- ~ row["title"].as!string ~ "\""
- ~ "</a> ("
- ~ m.hit
- ~ ") "
- ~ "["
- ~ row["language_document_char"].as!string
- ~ "] "
- ~ row["creator_author_last_first"].as!string
- ~ ":<br>\n"
- );
- }
- if (cv.results_type == "txt") {
- cgi.write(
- "<hr><a href=\""
- ~ "https://" ~ conf.http_host ~ "/"
- ~ row["language_document_char"].as!string ~ "/html/"
- ~ row["src_filename_base"].as!string ~ "/"
- ~ row["seg_name"].as!string ~ ".html#" ~ row["ocn"].as!string
- ~ "\">"
- ~ row["ocn"].as!string
- ~ "</a>"
- ~ "<br>"
- ~ row["body"].as!string
- );
- } else {
- cgi.write(
- "<a href=\""
- ~ "https://" ~ conf.http_host ~ "/"
- ~ row["language_document_char"].as!string ~ "/html/"
- ~ row["src_filename_base"].as!string ~ "/"
- ~ row["seg_name"].as!string ~ ".html#" ~ row["ocn"].as!string
- ~ "\">"
- ~ row["ocn"].as!string
- ~ "</a>, "
- );
- }
+ (cv.checked_sql)
+ ? cgi.write(previous_next ~ "<hr><font size=\"2\" color=\"#666666\">" ~ sql_select.the_body.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) {
+ foreach (row; select_query_results) {
+ if (row["uid"].as!string != _old_uid) {
+ _old_uid = row["uid"].as!string;
+ auto m = (row["date_published"].as!string).match(regex(r"^([0-9]{4})")); // breaks if row missing or no match?
+ cgi.write(
+ "<hr><a href=\""
+ ~ "https://" ~ conf.http_host ~ "/"
+ ~ row["language_document_char"].as!string ~ "/html/"
+ ~ row["src_filename_base"].as!string ~ "/"
+ ~ "toc.html"
+ ~ "\">\""
+ ~ row["title"].as!string ~ "\""
+ ~ "</a> ("
+ ~ m.hit
+ ~ ") "
+ ~ "["
+ ~ row["language_document_char"].as!string
+ ~ "] "
+ ~ row["creator_author_last_first"].as!string
+ ~ ":<br>\n"
+ );
+ }
+ if (cv.results_type == "txt") {
+ cgi.write(
+ "<hr><a href=\""
+ ~ "https://" ~ conf.http_host ~ "/"
+ ~ row["language_document_char"].as!string ~ "/html/"
+ ~ row["src_filename_base"].as!string ~ "/"
+ ~ row["seg_name"].as!string ~ ".html#" ~ row["ocn"].as!string
+ ~ "\">"
+ ~ row["ocn"].as!string
+ ~ "</a>"
+ ~ "<br>"
+ ~ row["body"].as!string
+ );
+ } else {
+ cgi.write(
+ "<a href=\""
+ ~ "https://" ~ conf.http_host ~ "/"
+ ~ row["language_document_char"].as!string ~ "/html/"
+ ~ row["src_filename_base"].as!string ~ "/"
+ ~ row["seg_name"].as!string ~ ".html#" ~ row["ocn"].as!string
+ ~ "\">"
+ ~ row["ocn"].as!string
+ ~ "</a>, "
+ );
}
- cgi.write( previous_next);
- } else { // offset_not_beyond_limit = false;
- cgi.write("select_query_results empty<p>\n");
}
+ cgi.write( previous_next);
+ } else { // offset_not_beyond_limit = false;
+ cgi.write("select_query_results empty<p>\n");
}
- sql_search_query;
}
+ sql_search_query;
+}
{
db.close;
}
diff --git a/sundry/misc/util/rb/tex/dr_tex.rb b/sundry/misc/util/rb/tex/dr_tex.rb
index b71d8c1..f310735 100755
--- a/sundry/misc/util/rb/tex/dr_tex.rb
+++ b/sundry/misc/util/rb/tex/dr_tex.rb
@@ -3,51 +3,51 @@
# - Name: Spine, Doc Reform [a part of]
# - Description: documents, structuring, processing, publishing, search
# - static content generator
-#
+#
# - Author: Ralph Amissah
# [ralph.amissah@gmail.com]
-#
+#
# - Copyright: (C) 2015 - 2021 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
-#
-# - Hompages:
+#
+# - Homepages:
# [https://www.doc_reform.org]
# [https://www.sisudoc.org]
-#
+#
# - Git
# [https://git.sisudoc.org/projects/?p=software/spine.git;a=summary]
-#
+#
# +/
require 'fileutils'
pwd = Dir.pwd
diff --git a/sundry/spine_search_cgi/src/spine_search.d_ b/sundry/spine_search_cgi/src/spine_search.d_
index b22c959..836c746 100755
--- a/sundry/spine_search_cgi/src/spine_search.d_
+++ b/sundry/spine_search_cgi/src/spine_search.d_
@@ -41,7 +41,7 @@
- docReform object numbering
- standard SiSU object citation numbering & system
- - Hompages:
+ - Homepages:
[https://www.doc_reform.org]
[https://www.sisudoc.org]
@@ -1368,21 +1368,21 @@ void cgi_function_intro(Cgi cgi) {
);
}
{
- 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,
- );
+ 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,
+ );
}
{
string post_value(string field_name, string type="box", string set="on") {
@@ -1822,7 +1822,7 @@ LIMIT %s OFFSET %s
}
}
cgi.write( previous_next);
-
+
} else { // offset_not_beyond_limit = false;
cgi.write("select_query_results empty<p>\n");
}
diff --git a/sundry/util/d/tools/markup_conversion/README b/sundry/util/d/tools/markup_conversion/README
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/sundry/util/d/tools/markup_conversion/README
@@ -0,0 +1 @@
+
diff --git a/sundry/util/d/tools/markup_conversion/endnotes_inline_from_binary.d b/sundry/util/d/tools/markup_conversion/endnotes_inline_from_binary.d
new file mode 100755
index 0000000..b084052
--- /dev/null
+++ b/sundry/util/d/tools/markup_conversion/endnotes_inline_from_binary.d
@@ -0,0 +1,123 @@
+#!/usr/bin/env rdmd
+/+
+ - read in file .sst .ssi .ssm
+ - loop twice
+ - first
+ - check for and skip code blocks
+ - use unique code marker for endnote markers in text and give an endnote
+ number ★1, increment
+ - extract all endnotes in array
+ - second
+ - check that the footnote marker number count matches the number of notes
+ in the array
+ - if they match either:
+ - substitute each endnote marker with the array footnote[number-1]
+ - substitute each endnote marker with footnote
+ as inlined footnote markup (footnote number not needed)
+ - if they do not match exit
+ - check whether changes have been made
+ - if so write file with inline footnotes in sub-directory converted_output_/
+ using the same name as the original file
+ - else, exit
++/
+import std.stdio;
+import std.file;
+import std.array : split;
+import std.exception;
+import core.stdc.errno;
+import std.regex;
+import std.format;
+import std.conv;
+void main(string[] args) {
+ static comment = ctRegex!(`^%+ `);
+ static block_tic_code_open = ctRegex!("^`{3} code(?:[.](?P<syntax>[a-z][0-9a-z#+_]+))?(?:[(](?P<attrib>[ a-zA-Z0-9;:,]*)[)])?");
+ static block_tic_close = ctRegex!("^(`{3})$","m");
+ static block_curly_code_open = ctRegex!(`^(?:code(?:[.](?P<syntax>[a-z][0-9a-z_]+))?(?:[(](?P<attrib>[ a-zA-Z0-9;:,]*)[)])?[{][ ]*$)`);
+ static block_curly_code_close = ctRegex!(`^([}]code)`);
+ auto rgx_endnote_ref = ctRegex!(`([~]\^)(?P<tail>[)\]]? |$)`, "gm");
+ auto rgx_endnote = ctRegex!(`^\^~\s+(.+|\n)`, "gm");
+ foreach(arg; args[1..$]) {
+ if (
+ !(arg.match(regex(r"--\w+")))
+ && arg.match(regex(r"\w+?\.ss[itm]"))
+ ) {
+ writeln(arg);
+ string filename = arg;
+ try {
+ string[] contents, endnotes, endnote_refs;
+ string text = filename.readText;
+ string[] paragraphs = text.split("\n\n");
+ int endnote_ref_count = 0;
+ int code_block_status = 0;
+ enum codeBlock { off, curly, tic, }
+ foreach (paragraph; paragraphs) { /+ loop to gather binary endnotes +/
+ if (code_block_status == codeBlock.off
+ && paragraph.match(rgx_endnote)
+ ) {
+ endnotes ~= replaceAll!(m => m[1])
+ (paragraph, rgx_endnote);
+ } else {
+ if ((code_block_status == codeBlock.curly
+ && paragraph.matchFirst(block_curly_code_close))
+ || ((code_block_status == codeBlock.tic
+ && paragraph.matchFirst(block_tic_close))
+ ) {
+ code_block_status = codeBlock.off;
+ } else if ( type["curly_code"] == 1 || type["tic_code"] == 1) {
+ // skip, prevent search for endnotes
+ } else if (paragraph.matchFirst(block_curly_code_open)) {
+ code_block_status = codeBlock.curly;
+ } else if (paragraph.matchFirst(block_tic_code_open)) {
+ code_block_status = codeBlock.tic;
+ } else if (auto m = paragraph.matchAll(rgx_endnote_ref)) {
+ foreach (n; m) {
+ endnote_ref_count++; // endnote_refs ~= (n.captures[1]);
+ }
+ }
+ contents ~= paragraph;
+ }
+ }
+ if (endnotes.length == endnote_ref_count) {
+ import std.outbuffer;
+ writeln("endnote ref count: ", endnote_ref_count);
+ writeln("number of binary endnotes: ", endnotes.length);
+ int endnote_count = -1;
+ auto buffer = new OutBuffer();
+ foreach (content; contents) { /+ loop to inline endnotes +/
+ content = replaceAll!(m => "~{ " ~ endnotes[++endnote_count] ~ " }~" ~ m["tail"] )
+ (content, rgx_endnote_ref);
+ buffer.write(content ~ "\n\n");
+ }
+ if (buffer) {
+ try {
+ string dir_out = "converted_output_";
+ string path_and_file_out = dir_out ~ "/" ~ filename;
+ dir_out.mkdirRecurse;
+ auto f = File(path_and_file_out, "w");
+ f.write(buffer);
+ writeln("wrote: ", path_and_file_out);
+ } catch (FileException ex) {
+ writeln("did not write file");
+ // Handle errors
+ }
+ }
+ } else {
+ writeln("ERROR binary endnote mismatch, check markup,\nmisatch in the number of endnotes & endnote references!");
+ writeln(" number of endnotes: ", endnotes.length);
+ writeln(" number of endnote refs: ", endnote_ref_count); // endnote_refs.length,
+ }
+ // assert(endnotes.length == endnote_ref_count);
+ } catch (ErrnoException ex) {
+ switch(ex.errno) {
+ case EPERM:
+ case EACCES: // Permission denied
+ break;
+ case ENOENT: // File does not exist
+ break;
+ default: // Handle other errors
+ break;
+ }
+ }
+ }
+ }
+}
diff --git a/sundry/util/d/tools/markup_conversion/markup_changes_header_and_content.d b/sundry/util/d/tools/markup_conversion/markup_changes_header_and_content.d
new file mode 100755
index 0000000..86792ff
--- /dev/null
+++ b/sundry/util/d/tools/markup_conversion/markup_changes_header_and_content.d
@@ -0,0 +1,244 @@
+#!/usr/bin/env rdmd
+/+
+ - read in file .sst .ssi .ssm
+ - loop twice
+ - first
+ - check for and skip code blocks
+ - use unique code marker for endnote markers in text and give an endnote
+ number ★1, increment
+ - extract all endnotes in array
+ - second
+ - check that the footnote marker number count matches the number of notes
+ in the array
+ - if they match either:
+ - substitute each endnote marker with the array footnote[number-1]
+ - substitute each endnote marker with footnote
+ as inlined footnote markup (footnote number not needed)
+ - if they do not match exit
+ - check whether changes have been made
+ - if so write file with inline footnotes in sub-directory converted_output_/
+ using the same name as the original file
+ - else, exit
++/
+import std.stdio;
+import std.file;
+import std.array : split;
+import std.exception;
+// import std.range;
+import core.stdc.errno;
+import std.regex;
+import std.format;
+import std.conv;
+void main(string[] args) {
+ static heading_a = ctRegex!(`^:?[A][~] `, "m");
+ static comment = ctRegex!(`^%+ `);
+ static block_tic_code_open = ctRegex!("^`{3} code(?:[.](?P<syntax>[a-z][0-9a-z#+_]+))?(?:[(](?P<attrib>[ a-zA-Z0-9;:,]*)[)])?");
+ static block_tic_close = ctRegex!("^(`{3})$","m");
+ static block_curly_code_open = ctRegex!(`^(?:code(?:[.](?P<syntax>[a-z][0-9a-z_]+))?(?:[(](?P<attrib>[ a-zA-Z0-9;:,]*)[)])?[{][ ]*$)`);
+ static block_curly_code_close = ctRegex!(`^([}]code)`);
+ auto rgx_endnote_ref = ctRegex!(`([~]\^)(?P<tail>[)\]]? |$)`, "gm");
+ auto rgx_endnote = ctRegex!(`^\^~\s+(.+|\n)`, "gm");
+ char[][] header0Content1(in string src_text) { // cast(char[])
+ /+ split string on _first_ match of "^:?A~\s" into [header, content] array/tuple +/
+ char[][] header_and_content;
+ auto m = (cast(char[]) src_text).matchFirst(heading_a);
+ header_and_content ~= m.pre;
+ header_and_content ~= m.hit ~ m.post;
+ assert(header_and_content.length == 2,
+ "document markup is broken, header body split == "
+ ~ header_and_content.length.to!string
+ ~ "; (header / body array split should == 2 (split is on level A~))"
+ );
+ return header_and_content;
+ }
+ foreach(arg; args[1..$]) {
+ if (
+ !(arg.match(regex(r"--\w+")))
+ && arg.match(regex(r"\w+?\.ss[itm]"))
+ ) {
+ writeln(arg);
+ string filename = arg;
+ try {
+ string[] munged_header, munged_contents, munged_endnotes, endnote_refs;
+ string text = filename.readText;
+ char[][] hc = header0Content1(text);
+ char[] src_header = hc[0];
+ string[] headers = src_header.to!string.split("\n\n");
+ char[] src_txt = hc[1];
+ string[] paragraphs = src_txt.to!string.split("\n\n");
+ int endnote_ref_count = 0;
+ int[string] type = [
+ "curly_code" : 0,
+ "tic_code" : 0,
+ ];
+ string _tmp_header;
+ foreach (h_; headers) { /+ loop to inline endnotes +/
+ _tmp_header = "";
+ if (h_.match(regex(r"^[@\[]?title[:\]]?"))) { // title
+ if (auto m = h_.match(regex(r"^@title:(?:\s+(?P<c>.+)|$)"))) { // sisu bespoke markup
+ if (m.captures["c"].length == 0) {
+ _tmp_header ~= "title:";
+ } else {
+ _tmp_header ~= "title:\n main: " ~ "\"" ~ m.captures["c"] ~ "\"";
+ }
+ } else if (auto m = h_.match(regex(r"^title\s*=\s*(?P<c>.+)"))) { // toml?
+ if (m.captures["c"].length == 0) {
+ _tmp_header ~= "title:";
+ } else {
+ _tmp_header ~= "title:\n main: " ~ "\"" ~ m.captures["c"] ~ "\"";
+ }
+ } else if (auto m = h_.match(regex(r"^\[title\]"))) { // toml markup
+ _tmp_header ~= "title:";
+ } else if (auto m = h_.match(regex(r"^title(?:\s+(?P<c>.+)|\s+\\$)"))) { // sdlang markup
+ if (m.captures["c"].length == 0) {
+ _tmp_header ~= "title:";
+ } else {
+ _tmp_header ~= "title:\n main: " ~ "\"" ~ m.captures["c"] ~ "\"";
+ }
+ }
+ if (h_.match(regex(r"^\s*[:]?(?:main)[:= ]?", "m"))) {
+ if (auto m = h_.match(regex(r"^\s+(?P<h>:main):(?:\s+(?P<c>.+)|$)", "m"))) { // sisu bespoke markup
+ _tmp_header ~= " main: " ~ "\"" ~ m.captures["c"] ~ "\"";
+ } else if (auto m = h_.match(regex(r"^\s*(?P<h>main)\s*=\s*(?P<c>.+)", "m"))) { // toml?
+ _tmp_header ~= " main: " ~ m.captures["c"];
+ } else if (auto m = h_.match(regex(r"^\s+(?P<h>main)(?:\s*\s*(?P<c>.+)|$)", "m"))) { // toml markup
+ _tmp_header ~= " main: " ~ "\"" ~ m.captures["c"] ~ "\"";
+ } else if (auto m = h_.match(regex(r"^\s+(?P<h>main)(?:\s+(?P<c>.+)|\s+\\$)", "m"))) { // sdlang markup
+ _tmp_header ~= " main: " ~ "\"" ~ m.captures["c"] ~ "\"";
+ }
+ }
+ if (h_.match(regex(r"^\s*[:]?(?:sub(title)?)[:= ]?", "m"))) {
+ if (auto m = h_.match(regex(r"^\s+:sub(?:title)?:(?:\s+(?P<c>.+)|$)", "m"))) { // sisu bespoke markup
+ _tmp_header ~= " subtitle: " ~ "\"" ~ m.captures["c"] ~ "\"";
+ } else if (auto m = h_.match(regex(r"^\s*sub(?:title)?\s*=\s*(?P<c>.+)$", "m"))) { // toml?
+ _tmp_header ~= " subtitle: " ~ m.captures["c"];
+ } else if (auto m = h_.match(regex(r"^\s+(?:title)?(?:\s*\s*(?P<c>.+)|$)", "m"))) { // toml markup
+ _tmp_header ~= " subtitle: " ~ "\"" ~ m.captures["c"] ~ "\"";
+ } else if (auto m = h_.match(regex(r"^\s+(?:title)?(?:\s+(?P<c>.+)|\s+\\$)", "m"))) { // sdlang markup
+ _tmp_header ~= " subtitle: " ~ "\"" ~ m.captures["c"] ~ "\"";
+ }
+ }
+ }
+ if (h_.match(regex(r"^[@\[]?rights[:\]]?"))) { // rights
+ if (auto m = h_.match(regex(r"^@rights:[ ]+(?P<c>.+)$"))) { // sisu bespoke markup
+ _tmp_header ~= "rights: \n copyright: \"" ~ m.captures["c"] ~ "\"";
+ } else if (auto m = h_.match(regex(r"^@rights:"))) { // sisu bespoke markup
+ _tmp_header ~= "rights:";
+ } else if (auto m = h_.match(regex(r"^\[rights\]", "m"))) { // toml markup
+ _tmp_header ~= "rights:";
+ } else if (auto m = h_.match(regex(r"^rights:"))) { // sdlang markup
+ _tmp_header ~= "rights:";
+ }
+ if (h_.match(regex(r"^\s*[:]?copyright[:= ]?", "m"))) {
+ if (auto m = h_.match(regex(r"^\s+:copyright:(?:\s+(?P<c>.+)|$)", "m"))) { // sisu bespoke markup
+ _tmp_header ~= " copyright: " ~ "\"" ~ m.captures["c"] ~ "\"";
+ } else if (auto m = h_.match(regex(r"^\s*copyright\s*=\s*(?P<c>.+)", "m"))) { // toml?
+ _tmp_header ~= " copyright: " ~ m.captures["c"];
+ } else if (auto m = h_.match(regex(r"^\s+<h>copyright(?:\s*\s*(?P<c>.+)|$)", "m"))) { // toml markup
+ _tmp_header ~= " copyright: " ~ "\"" ~ m.captures["c"] ~ "\"";
+ } else if (auto m = h_.match(regex(r"^\s+copyright(?:\s+(?P<c>.+)|\s+\\$)", "m"))) { // sdlang markup
+ _tmp_header ~= " copyright: " ~ "\"" ~ m.captures["c"] ~ "\"";
+ }
+ }
+ if (h_.match(regex(r"^\s*[:]?licen[cs]e[:= ]?", "m"))) {
+ if (auto m = h_.match(regex(r"^\s+:licen[cs]e:(?:\s+(?P<c>.+)|$)", "m"))) { // sisu bespoke markup
+ _tmp_header ~= " license: " ~ "\"" ~ m.captures["c"] ~ "\"";
+ } else if (auto m = h_.match(regex(r"^\s*licen[cs]e\s*=\s*(?P<c>.+)$", "m"))) { // toml?
+ _tmp_header ~= " license: " ~ m.captures["c"];
+ } else if (auto m = h_.match(regex(r"^\s+licen[cs]e(?:\s*\s*(?P<c>.+)|$)", "m"))) { // toml markup
+ _tmp_header ~= " license: " ~ "\"" ~ m.captures["c"] ~ "\"";
+ } else if (auto m = h_.match(regex(r"^\s+licen[cs]e(?:\s+(?P<c>.+)|\s+\\$)", "m"))) { // sdlang markup
+ _tmp_header ~= " license: " ~ "\"" ~ m.captures["c"] ~ "\"";
+ }
+ }
+ }
+ if (_tmp_header.length > 0) {
+ munged_header ~= _tmp_header;
+ } else {
+ munged_header ~= h_;
+ }
+ }
+ writeln(munged_header);
+ foreach (paragraph; paragraphs) { /+ loop to gather binary endnotes +/
+ if ( !( type["curly_code"] == 1 || type["tic_code"] == 1)
+ && paragraph.match(rgx_endnote)
+ ) {
+ munged_endnotes ~= replaceAll!(m => m[1])
+ (paragraph, rgx_endnote);
+ } else {
+ if ( type["curly_code"] == 1 || type["tic_code"] == 1
+ || paragraph.matchFirst(block_curly_code_open)
+ || paragraph.matchFirst(block_tic_code_open)
+ ) { /+ code blocks identified, no munging +/
+ if ( type["curly_code"] == 1
+ && paragraph.matchFirst(block_curly_code_close)
+ ) {
+ type["curly_code"] = 0;
+ } else if (type["tic_code"] == 1
+ && paragraph.matchFirst(block_tic_close)
+ ) {
+ type["tic_code"] = 0;
+ } else if (paragraph.matchFirst(block_curly_code_open)) {
+ type["curly_code"] = 1;
+ } else if (paragraph.matchFirst(block_tic_code_open)) {
+ type["tic_code"] = 1;
+ }
+ munged_contents ~= paragraph;
+ } else { /+ regular content, not a code block +/
+ if (auto m = paragraph.matchAll(rgx_endnote_ref)) {
+ foreach (n; m) {
+ endnote_ref_count++; // endnote_refs ~= (n.captures[1]);
+ }
+ }
+ paragraph = replaceAll!(m => " \\\\ " )
+ (paragraph, regex(r"\s*<(?:/\s*|:)?br>\s*")); // (paragraph, regex(r"(<br>)"));
+ munged_contents ~= paragraph;
+ }
+ }
+ }
+ {
+ import std.outbuffer;
+ auto buffer = new OutBuffer();
+ foreach (header; munged_header) { /+ loop to inline endnotes +/
+ buffer.write(header ~ "\n\n");
+ }
+ if (munged_endnotes.length == endnote_ref_count) {
+ int endnote_count = -1;
+ foreach (content; munged_contents) { /+ loop to inline endnotes +/
+ content = replaceAll!(m => "~{ " ~ munged_endnotes[++endnote_count] ~ " }~" ~ m["tail"] )
+ (content, rgx_endnote_ref); // endnote_ref cannot occur in a code block or else fail
+ buffer.write(content ~ "\n\n");
+ }
+ if (buffer) {
+ try {
+ string dir_out = "converted_output_";
+ string path_and_file_out = dir_out ~ "/" ~ filename;
+ dir_out.mkdirRecurse;
+ auto f = File(path_and_file_out, "w");
+ f.write(buffer);
+ // writeln("wrote: ", path_and_file_out);
+ } catch (FileException ex) {
+ writeln("did not write file");
+ // Handle errors
+ }
+ }
+ } else {
+ foreach (content; munged_contents) { /+ loop to inline endnotes +/
+ buffer.write(content ~ "\n\n");
+ }
+ }
+ }
+ } catch (ErrnoException ex) {
+ switch(ex.errno) {
+ case EPERM:
+ case EACCES: // Permission denied
+ break;
+ case ENOENT: // File does not exist
+ break;
+ default: // Handle other errors
+ break;
+ }
+ }
+ }
+ }
+}
diff --git a/sundry/util/d/tools/markup_conversion/markup_conversion_from_sisu_ruby_to_sisu_spine.d b/sundry/util/d/tools/markup_conversion/markup_conversion_from_sisu_ruby_to_sisu_spine.d
new file mode 100755
index 0000000..0ec541d
--- /dev/null
+++ b/sundry/util/d/tools/markup_conversion/markup_conversion_from_sisu_ruby_to_sisu_spine.d
@@ -0,0 +1,367 @@
+#!/usr/bin/env rdmd
+/+
+ - read in file .sst .ssi .ssm
+ - loop twice
+ - first
+ - check for and skip code blocks
+ - use unique code marker for endnote markers in text and give an endnote
+ number ★1, increment
+ - extract all endnotes in array
+ - second
+ - check that the footnote marker number count matches the number of notes
+ in the array
+ - if they match either:
+ - substitute each endnote marker with the array footnote[number-1]
+ - substitute each endnote marker with footnote
+ as inlined footnote markup (footnote number not needed)
+ - if they do not match exit
+ - check whether changes have been made
+ - if so write file with inline footnotes in sub-directory converted_output_/
+ using the same name as the original file
+ - else, exit
++/
+import std.stdio;
+import std.file;
+import std.array : split, join;
+import std.exception;
+// import std.range;
+import core.stdc.errno;
+import std.regex;
+import std.format;
+import std.conv;
+void main(string[] args) {
+ static heading_a = ctRegex!(`^:?[A][~] `, "m");
+ static comment = ctRegex!(`^%+ `);
+ static block_tic_code_open = ctRegex!("^`{3} code(?:[.](?P<syntax>[a-z][0-9a-z#+_]+))?(?:[(](?P<attrib>[ a-zA-Z0-9;:,]*)[)])?");
+ static block_tic_close = ctRegex!("^(`{3})$","m");
+ static block_curly_code_open = ctRegex!(`^(?:code(?:[.](?P<syntax>[a-z][0-9a-z_]+))?(?:[(](?P<attrib>[ a-zA-Z0-9;:,]*)[)])?[{][ ]*$)`);
+ static block_curly_code_close = ctRegex!(`^([}]code)`);
+ auto rgx_endnote_ref = ctRegex!(`([~]\^)(?P<tail>[)\]]? |$)`, "gm");
+ auto rgx_endnote = ctRegex!(`^\^~\s+(.+|\n)`, "gm");
+ char[][] header0Content1(in string src_text) { // cast(char[])
+ /+ split string on _first_ match of "^:?A~\s" into [header, content] array/tuple +/
+ char[][] header_and_content;
+ auto m = (cast(char[]) src_text).matchFirst(heading_a);
+ header_and_content ~= m.pre;
+ header_and_content ~= m.hit ~ m.post;
+ assert(header_and_content.length == 2,
+ "document markup is broken, header body split == "
+ ~ header_and_content.length.to!string
+ ~ "; (header / body array split should == 2 (split is on level A~))"
+ );
+ return header_and_content;
+ }
+ string format_body_string(string s) {
+ string o;
+ o = s
+ .replaceAll(regex("^<(?:/[ ]*)?br>[ ]*"), " \\\\ ")
+ .replaceAll(regex("[ ]*<(?:/[ ]*)?br>$"), " \\\\")
+ .replaceAll(regex("[ ]*<(?:/[ ]*)?br>[ ]*"), " \\\\ ");
+ return o;
+ }
+ string format_header_string(string s) {
+ string o;
+ o = s
+ .replaceAll(regex("\""), "\\\"")
+ .replaceAll(regex("[ ]*<(?:/[ ]*)?br>$"), " \\\\")
+ .replaceAll(regex("[ ]*<(?:/[ ]*)?br>[ ]*"), " \\\\ ");
+ return o;
+ }
+ string format_main_header(string hm, string hs = "", string c = "") {
+ string o;
+ if (c.length == 0) {
+ o ~= hm ~ ":\n";
+ } else {
+ o ~= hm ~ ":\n"
+ ~ " " ~ hs ~ ": "
+ ~ "\"" ~ format_header_string(c) ~ "\"\n";
+ }
+ return o;
+ }
+ string format_sub_header(string hs, string c) {
+ string o;
+ o ~= " " ~ hs ~ ": "
+ ~ "\"" ~ format_header_string(c) ~ "\"\n";
+ return o;
+ }
+ foreach(arg; args[1..$]) {
+ if (
+ !(arg.match(regex(r"--\w+")))
+ && arg.match(regex(r"\w+?\.ss[itm]"))
+ ) {
+ writeln(arg);
+ string filename = arg;
+ try {
+ string[] munged_header, munged_contents, munged_endnotes, endnote_refs;
+ char[][] hc;
+ char[] src_header;
+ string[] headers;
+ char[] src_txt;
+ string[] paragraphs;
+ enum codeBlock { off, curly, tic, }
+ string _tmp_header;
+ int endnote_ref_count = 0;
+ int code_block_status = codeBlock.off;
+ string text = filename.readText;
+ if (arg.match(regex(r"\w+?\.ss[tm]"))) {
+ hc = header0Content1(text);
+ src_header = hc[0];
+ headers = src_header.to!string.split("\n\n");
+ src_txt = hc[1];
+ paragraphs = src_txt.to!string.split("\n\n");
+ } else if (arg.match(regex(r"\w+?\.ssi"))) {
+ headers = [];
+ paragraphs = text.split("\n\n");
+ }
+ if (headers.length > 0) {
+ headers[0] = headers[0].replaceFirst(regex(r"^%\s+SiSU.+", "i"), "# SiSU 8.0 spine (auto-conversion)");
+ foreach (h_; headers) {
+ _tmp_header = "";
+ if (auto m = h_.match(regex(r"^%\s*", "m"))) {
+ h_ = h_.replaceAll(regex(r"^%\s*", "m"), "# ") ~ "\n";
+ }
+ if (h_.match(regex(r"^@title:|@subtitle"))) {
+ if (auto m = h_.match(regex(r"^@(?P<h>title):(?:[ ]+(?P<c>.+)|\n)"))) {
+ _tmp_header ~= format_main_header(m.captures["h"], "main", m.captures["c"]);
+ }
+ if (auto m = h_.match(regex(r"^@(?P<h>subtitle):(?:[ ]+(?P<c>.+)|$)"))) {
+ if (m.captures["c"].length == 0) {
+ } else {
+ _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]);
+ }
+ }
+ if (auto m = h_.match(regex(r"^\s+:(?P<h>main):(?:[ ]+(?P<c>.+)|$)", "m"))) {
+ _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]);
+ }
+ if (auto m = h_.match(regex(r"^\s+:sub(?:title)?:(?:[ ]+(?P<c>.+)|$)", "m"))) {
+ _tmp_header ~= format_sub_header("subtitle", m.captures["c"]);
+ }
+ } else if (h_.match(regex(r"^@creator:|@author:"))) {
+ if (auto m = h_.match(regex(r"^(?:@creator:|@author:)(?:[ ]+(?P<c>.+)|\n)"))) {
+ _tmp_header ~= format_main_header("creator", "author", m.captures["c"]);
+ }
+ if (auto m = h_.match(regex(r"^\s+:(?P<h>author):(?:[ ]+(?P<c>.+)|$)", "m"))) {
+ _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]);
+ }
+ } else if (h_.match(regex(r"^@rights:"))) {
+ if (auto m = h_.match(regex(r"^@(?P<h>rights):(?:[ ]+(?P<c>.+)|\n)"))) {
+ _tmp_header ~= format_main_header(m.captures["h"], "copyright", m.captures["c"]);
+ }
+ if (auto m = h_.match(regex(r"^\s+:(?P<h>copyright):(?:[ ]+(?P<c>.+)|$)", "m"))) {
+ _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]);
+ }
+ if (auto m = h_.match(regex(r"^\s+:licen[cs]e:(?:[ ]+(?P<c>.+)|$)", "m"))) {
+ _tmp_header ~= format_sub_header("license", m.captures["c"]);
+ }
+ } else if (h_.match(regex(r"^@date:|@date\."))) {
+ if (auto m = h_.match(regex(r"^@(?P<h>date):(?:[ ]+(?P<c>.+)|\n)"))) {
+ _tmp_header ~= format_main_header(m.captures["h"], "published", m.captures["c"]);
+ }
+ if (auto m = h_.match(regex(r"^\s+:(?P<h>published):(?:[ ]+(?P<c>.+)|$)", "m"))) {
+ _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]);
+ }
+ if (auto m = h_.match(regex(r"^\s+:(?P<h>available):(?:[ ]+(?P<c>.+)|$)", "m"))) {
+ _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]);
+ }
+ if (auto m = h_.match(regex(r"^\s+:(?P<h>modified):(?:[ ]+(?P<c>.+)|$)", "m"))) {
+ _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]);
+ }
+ if (auto m = h_.match(regex(r"^\s+:(?P<h>created):(?:[ ]+(?P<c>.+)|$)", "m"))) {
+ _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]);
+ }
+ if (auto m = h_.match(regex(r"^\s+:(?P<h>issued):(?:[ ]+(?P<c>.+)|$)", "m"))) {
+ _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]);
+ }
+ if (auto m = h_.match(regex(r"^\s+:(?P<h>valid):(?:[ ]+(?P<c>.+)|$)", "m"))) {
+ _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]);
+ }
+ if (auto m = h_.match(regex(r"^@date\.(?P<h>available):[ ]+(?P<c>.+)$"))) {
+ _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]);
+ }
+ if (auto m = h_.match(regex(r"^@date\.(?P<h>modified):[ ]+(?P<c>.+)$"))) {
+ _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]);
+ }
+ if (auto m = h_.match(regex(r"^@date\.(?P<h>created):[ ]+(?P<c>.+)$"))) {
+ _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]);
+ }
+ if (auto m = h_.match(regex(r"^@date\.(?P<h>issued):[ ]+(?P<c>.+)$"))) {
+ _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]);
+ }
+ if (auto m = h_.match(regex(r"^@date\.(?P<h>valid):[ ]+(?P<c>.+)$"))) {
+ _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]);
+ }
+ } else if (h_.match(regex(r"^@classify:"))) {
+ if (auto m = h_.match(regex(r"^@classify:"))) {
+ _tmp_header ~= "classify:\n";
+ }
+ if (auto m = h_.match(regex(r"^\s+:(?P<h>topic_register):(?:[ ]+(?P<c>.+)|$)", "m"))) {
+ _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]);
+ }
+ if (auto m = h_.match(regex(r"^\s+:type:(?:[ ]+(?P<c>.+)|$)", "m"))) {
+ _tmp_header ~= "# type: " ~ "\"" ~ m.captures["c"] ~ "\"\n";
+ }
+ } else if (h_.match(regex(r"^(?:@identifier:|@identify:)"))) {
+ if (auto m = h_.match(regex(r"^(?:@identifier:|@idenfify)"))) {
+ _tmp_header ~= "identify:\n";
+ }
+ if (auto m = h_.match(regex(r"^\s+:(?P<h>oclc):(?:[ ]+(?P<c>.+)|$)", "m"))) {
+ _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]);
+ }
+ if (auto m = h_.match(regex(r"^\s+:(?P<h>isbn):(?:[ ]+(?P<c>.+)|$)", "m"))) {
+ _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]);
+ }
+ if (auto m = h_.match(regex(r"^\s+:(?P<h>dewey):(?:[ ]+(?P<c>.+)|$)", "m"))) {
+ _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]);
+ }
+ } else if (h_.match(regex(r"^@publisher:"))) {
+ if (auto m = h_.match(regex(r"^@publisher:[ ]+(?P<c>.+)$"))) {
+ _tmp_header ~= "publisher: " ~ "\"" ~ m.captures["c"] ~ "\"\n";
+ }
+ } else if (h_.match(regex(r"^@make:"))) {
+ // writeln(h_);
+ if (auto m = h_.match(regex(r"^@make:"))) {
+ _tmp_header ~= "make:\n";
+ }
+ if (auto m = h_.match(regex(r"^\s+:(?P<h>breaks):(?:[ ]+(?P<c>.+)|$)", "m"))) {
+ _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]);
+ }
+ if (auto m = h_.match(regex(r"^\s+:(?P<h>num_top):(?:[ ]+(?P<c>.+)|$)", "m"))) {
+ _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]);
+ }
+ if (auto m = h_.match(regex(r"^\s+:(?P<h>headings):(?:[ ]+(?P<c>.+)|$)", "m"))) {
+ _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]);
+ }
+ if (auto m = h_.match(regex(r"^\s+:(?P<h>italics):(?:[ ]+(?P<c>.+)|$)", "m"))) {
+ _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]);
+ }
+ if (auto m = h_.match(regex(r"^\s+:(?P<h>bold):(?:[ ]+(?P<c>.+)|$)", "m"))) {
+ _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]);
+ }
+ if (auto m = h_.match(regex(r"^\s+:(?P<h>emphasis):(?:[ ]+(?P<c>.+)|$)", "m"))) {
+ _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]);
+ }
+ if (auto m = h_.match(regex(r"^\s+:(?P<h>substitute):(?:[ ]+(?P<c>.+)|$)", "m"))) {
+ _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]);
+ }
+ if (auto m = h_.match(regex(r"^\s+:(?P<h>texpdf_font):(?:[ ]+(?P<c>.+)|$)", "m"))) {
+ _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]);
+ }
+ if (auto m = h_.match(regex(r"^\s+:(?P<h>home_button_text):(?:[ ]+(?P<c>.+)|$)", "m"))) {
+ _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]);
+ }
+ if (auto m = h_.match(regex(r"^\s+:(?P<h>home_button_image):(?:[ ]+(?P<c>.+)|$)", "m"))) {
+ _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]);
+ }
+ if (auto m = h_.match(regex(r"^\s+:(?P<h>cover_image):(?:[ ]+(?P<c>.+)|$)", "m"))) {
+ _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]);
+ }
+ if (auto m = h_.match(regex(r"^\s+:(?P<h>footer):(?:[ ]+(?P<c>.+)|$)", "m"))) {
+ _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]);
+ }
+ // writeln(_tmp_header);
+ } else if (h_.match(regex(r"^@\w+:"))) {
+ _tmp_header ~= "# " ~ h_.split("\n").join("\n# ") ~ "\n";
+ } else if (h_.match(regex(r"^\s+:\w+:", "m"))) {
+ if (auto m = h_.match(regex(r"^(?P<g>\s+:\w+:.*)"))) {
+ _tmp_header ~= "# " ~ m.captures["g"] ~ "\n";
+ }
+ }
+ if (h_.match(regex(r"^#", "m"))) {
+ if (auto m = h_.match(regex(r"^(?P<g>#.*)", "m"))) {
+ _tmp_header ~= m.captures["g"] ~ "\n";
+ }
+ }
+ if (_tmp_header.length > 0) {
+ munged_header ~= _tmp_header.split("\n\n");
+ } else if (h_.length > 0) {
+ writeln("munging required: ", h_);
+ h_ = h_.replaceAll((regex(r"\n\n\n+", "m")), "\n\n");
+ munged_header ~= h_;
+ }
+ }
+ // writeln(munged_header.join("\n"));
+ }
+ foreach (paragraph; paragraphs) { /+ loop to gather binary endnotes +/
+ if (code_block_status == codeBlock.off
+ && paragraph.match(rgx_endnote)
+ ) {
+ munged_endnotes ~= replaceAll!(m => m[1])
+ (paragraph, rgx_endnote);
+ } else {
+ if ( code_block_status != codeBlock.off
+ || paragraph.matchFirst(block_curly_code_open)
+ || paragraph.matchFirst(block_tic_code_open)
+ ) { /+ code blocks identified, no munging +/
+ if ((code_block_status == codeBlock.curly
+ && paragraph.matchFirst(block_curly_code_close))
+ || (code_block_status == codeBlock.tic
+ && paragraph.matchFirst(block_tic_close))
+ ) {
+ code_block_status = codeBlock.off;
+ } else if (paragraph.matchFirst(block_curly_code_open)) {
+ code_block_status = codeBlock.curly;
+ } else if (paragraph.matchFirst(block_tic_code_open)) {
+ code_block_status = codeBlock.tic;
+ }
+ munged_contents ~= paragraph;
+ } else { /+ regular content, not a code block +/
+ if (auto m = paragraph.matchAll(rgx_endnote_ref)) {
+ foreach (n; m) {
+ endnote_ref_count++; // endnote_refs ~= (n.captures[1]);
+ }
+ }
+ paragraph = format_body_string(paragraph);
+ // paragraph = replaceAll!(m => " \\\\ " )
+ // (paragraph, regex(r"\s*<(?:/\s*|:)?br>\s*")); // (paragraph, regex(r"(<br>)"));
+ munged_contents ~= paragraph;
+ }
+ }
+ }
+ {
+ import std.outbuffer;
+ auto buffer = new OutBuffer();
+ if (munged_header.length > 0) {
+ foreach (header; munged_header) { /+ loop to inline endnotes +/
+ buffer.write(header ~ "\n");
+ }
+ }
+ if (munged_endnotes.length == endnote_ref_count) {
+ int endnote_count = -1;
+ foreach (k, content; munged_contents) { /+ loop to inline endnotes +/
+ content = replaceAll!(m => "~{ " ~ munged_endnotes[++endnote_count] ~ " }~" ~ m["tail"] )
+ (content, rgx_endnote_ref); // endnote_ref cannot occur in a code block or else fail
+ buffer.write(content ~ ((k == munged_contents.length - 1) ? "" : "\n\n"));
+ }
+ if (buffer) {
+ try {
+ string dir_out = "converted_output_";
+ string path_and_file_out = dir_out ~ "/" ~ filename;
+ dir_out.mkdirRecurse;
+ auto f = File(path_and_file_out, "w");
+ f.write(buffer);
+ // writeln("wrote: ", path_and_file_out);
+ } catch (FileException ex) {
+ writeln("did not write file");
+ // Handle errors
+ }
+ }
+ } else {
+ foreach (content; munged_contents) { /+ loop to inline endnotes +/
+ buffer.write(content ~ "\n\n");
+ }
+ }
+ }
+ } catch (ErrnoException ex) {
+ switch(ex.errno) {
+ case EPERM:
+ case EACCES: // Permission denied
+ break;
+ case ENOENT: // File does not exist
+ break;
+ default: // Handle other errors
+ break;
+ }
+ }
+ }
+ }
+}
diff --git a/sundry/util/rb/cgi/spine.search.cgi b/sundry/util/rb/cgi/spine.search.cgi
new file mode 100755
index 0000000..36f109d
--- /dev/null
+++ b/sundry/util/rb/cgi/spine.search.cgi
@@ -0,0 +1,952 @@
+#!/usr/bin/env ruby
+=begin
+ * Name: SiSU information Structuring Universe
+ * Author: Ralph Amissah
+ * https://sisudoc.org
+ * https://git.sisudoc.org
+
+ * Description: generates naive cgi search form for search of sisu database (sqlite)
+ * Name: SiSU generated sample cgi search form
+
+ * Description: generated sample cgi search form for SiSU
+ (SiSU is a framework for document structuring, publishing and search)
+
+ * Author: Ralph Amissah
+
+ * Copyright: (C) 1997 - 2014, Ralph Amissah, All Rights Reserved.
+
+ * License: GPL 3 or later:
+
+ 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 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 GPL should be
+ available at these locations:
+ <https://www.fsf.org/licenses/gpl.html>
+ <https://www.gnu.org/licenses/gpl.html>
+
+ * SiSU uses:
+ * Standard SiSU markup syntax,
+ * Standard SiSU meta-markup syntax, and the
+ * Standard SiSU object citation numbering and system
+
+ * Homepages:
+ <https://www.sisudoc.org>
+
+ * Ralph Amissah
+ <ralph@amissah.com>
+ <ralph.amissah@gmail.com>
+
+=end
+begin
+ require 'cgi'
+ require 'fcgi'
+ require 'sqlite3'
+rescue LoadError
+ puts 'cgi, fcgi or sqlite3 NOT FOUND (LoadError)'
+end
+@stub_default = 'search'
+@image_src = "https://#{ENV['HTTP_HOST']}/image_sys"
+@hosturl_cgi = "https://#{ENV['HTTP_HOST']}#{ENV['PATH_INFO']}"
+@hosturl_files = "https://#{ENV['HTTP_HOST']}"
+@output_dir_structure_by = 'language'
+@lingual = 'multi'
+@db_name_prefix = 'spine.'
+@base = "https://#{ENV['HTTP_HOST']}#{ENV['PATH_INFO']}#{ENV['SCRIPT_NAME']}"
+#Common TOP
+@@offset = 0
+@@canned_search_url = @base
+@color_heading = '#DDFFAA'
+@color_match = '#ffff48'
+class Form
+ def initialize(base,search_field,selected_db,result_type,checked_sql_limit,checked_tip,checked_stats,checked_searched,checked_url,checked_case,checked_echo,checked_sql,checked_all,checked_none,checked_selected,checked_default,search_note,the_can='')
+ search_note = '' if checked_searched !~ /\S/
+ the_can = '' if checked_url !~ /\S/
+ search_field = '' if checked_echo !~ /\S/
+ @base,@search_field,@selected_db,@result_type,@checked_sql_limit,@checked_tip,@checked_stats,@checked_searched,@checked_url,@checked_case,@checked_echo,@checked_sql,@checked_all,@checked_none,@checked_selected,@checked_default,@search_note,@the_can=base,search_field,selected_db,result_type,checked_sql_limit,checked_tip,checked_stats,checked_searched,checked_url,checked_case,checked_echo,checked_sql,checked_all,checked_none,checked_selected,checked_default,search_note,the_can
+ @tip = if checked_tip =~ /\S/
+ '<font size="2" color="#666666">text:__; fulltxt:__; keywords:__; title:__; author:__; topic_register:__; subject:__; description:__; publisher:__; editor:__; contributor:__; date:__; type:__; format:__; identifier:__; source:__; language:__; relation:__; coverage:__; rights:__; comment:__; abstract:__; src_filename_base:__;</font><br />'
+ else ''
+ end
+ end
+def submission_form
+ search_form =<<-WOK
+ <!DOCTYPE html>
+ <html>
+ <head>
+ <title>
+ <meta charset="utf-8">
+ <meta name="sourcefile" content="SiSU._sst" />
+ SiSU search form (sample): SiSU information Structuring Universe
+ </title>
+ <link rel="generator" href="https://sisudoc.org/" />
+ <link rel="shortcut icon" href="https://#{ENV['HTTP_HOST']}/_sisu/image_sys/rb7.ico" />
+ <link href="../_sisu/css/html.css" rel="stylesheet">
+ </head>
+ <body lang="en" xml:lang="en">
+ <table summary="band" border="0" cellpadding="3" cellspacing="0">
+ <tr><td width="20%">
+ <table summary="home button / home information" border="0" cellpadding="3" cellspacing="0">
+ <tr><td align="left">
+ <br /><a href="https://sisudoc.org/" target="_top">
+ <b>SiSU</b>
+ </a>
+ <br /><a href="https://git.sisudoc.org/" target="_top">
+ git
+ </a>
+ </td></tr>
+ </table>
+ </td>
+ <td>
+ <label for="find"><b>SiSU (generated sample) search form (content organised by filetype)</b></label>
+ </td></tr>
+ </table>
+ <form action="#{@base}" id="Test Form" method="post">
+ <table cellpadding="2">
+ <tr><td valign=\"top\">
+ <textarea id="find" name="find" type="text" rows="6" cols="40" maxlength="256">#{@search_field}</textarea>
+ </td>
+ <td valign=\"top\">
+ #{@tip}
+ #{@search_note}
+ #{@the_can}
+ </td></tr></table>
+ <td valign=\"top\"><tr><td>
+ <!input type="text" id="find" name="find" value="#{@search_field}" />
+ <!input type="text" id="find" name="find" value="" />
+ <font size="2" color="#222222">
+ <b>to search:</b> select which database to search (drop-down menu below); enter your search query (in the form above); and <b>click on the search button</b> (below)
+ <br />
+ <select name="db" size="1">
+ #{@selected_db}
+ <option value="spine.sqlite">spine</option>
+ </select>
+ <input type="submit" value="SiSU search" />
+ <input type="radio" name="view" value="index" #{@result_type[:index]}> index
+ <input type="radio" name="view" value="text" #{@result_type[:text]}> text / grep
+ <br />
+ match limit:
+ <input type="radio" name="sql_match_limit" value="1000" #{@checked_sql_limit[:l1000]}> 1,000
+ <input type="radio" name="sql_match_limit" value="2500" #{@checked_sql_limit[:l2500]}> 2,500
+ <br />
+ <input type="checkbox" name="echo" #{@checked_echo}> echo query
+ <input type="checkbox" name="stats" #{@checked_stats}> result stats
+ <input type="checkbox" name="url" #{@checked_url}> search url
+ <input type="checkbox" name="searched" #{@checked_searched}> searched
+ <input type="checkbox" name="tip" #{@checked_tip}> available fields
+ <input type="checkbox" name="sql" #{@checked_sql}> sql statement
+ <br />
+ checks:
+ <input type="radio" name="checks" value="check_default" #{@checked_default}> default
+ <input type="radio" name="checks" value="check_selected" #{@checked_selected}> selected
+ <input type="radio" name="checks" value="check_all" #{@checked_all}> all
+ <input type="radio" name="checks" value="check_none" #{@checked_none}> none
+ </font>
+ </td></tr>
+ </table>
+ </form>
+ WOK
+ end
+end
+class SearchRequest #% search_for
+ attr_accessor :text1,:fulltext,:keywords,:title,:author,:topic_register,:subject,:description,:publisher,:editor,:contributor,:date,:type,:format,:identifier,:source,:language,:relation,:coverage,:rights,:comment,:abstract,:owner,:date_created,:date_issued,:date_modified,:date_available,:date_valid,:src_filename_base
+ def initialize(search_field='',q='')
+ @search_field,@q=search_field,q
+ @text1=@fulltext=@keywords=@title=@author=@topic_register=@subject=@description=@publisher=@editor=@contributor=@date=@type=@format=@identifier=@source=@language=@relation=@coverage=@rights=@comment=@abstract=@owner=@date_created=@date_issued=@date_modified=@date_available=@date_valid=@filename=''
+ if @search_field=~/\S/
+ @text1 = text_to_match('text:')
+ @fulltext = text_to_match('fulltxt:')
+ @topic_register = text_to_match('topic_register:')
+ @title = text_to_match('title:') # DublinCore 1 - title
+ @author = text_to_match('(?:author|creator)s?:') # DublinCore 2 - creator/author
+ @subject = text_to_match('subj(?:ect)?:') # DublinCore 3 - subject
+ @description = text_to_match('description:') # DublinCore 4 - description
+ @publisher = text_to_match('pub(?:lisher)?:') # DublinCore 5 - publisher
+ @editor = text_to_match('editor:')
+ @contributor = text_to_match('contributor:') # DublinCore 6 - contributor
+ @date = text_to_match('date:') # DublinCore 7 - date dd-mm-yy
+ @type = text_to_match('type:') # DublinCore 8 - type
+ @format = text_to_match('format:') # DublinCore 9 - format
+ @identifier = text_to_match('identifier:') # DublinCore 10 - identifier
+ @source = text_to_match('source:') # DublinCore 11 - source
+ @language = text_to_match('language:') # DublinCore 12 - language
+ @relation = text_to_match('relation:') # DublinCore 13 - relation
+ @coverage = text_to_match('coverage:') # DublinCore 14 - coverage
+ @rights = text_to_match('rights:') # DublinCore 15 - rights
+ @keywords = text_to_match('key(?:words?)?:')
+ @comment = text_to_match('comment:')
+ @abstract = text_to_match('abs(?:tract)?:')
+ @owner = text_to_match('owner:')
+ @date_created = text_to_match('date_created:')
+ @date_issued = text_to_match('date_issued:')
+ @date_modified = text_to_match('date_modified:')
+ @date_available = text_to_match('date_available:')
+ @date_valid = text_to_match('date_valid:')
+ @filename = text_to_match('src_filename_base:')
+ @text1 = text_to_match unless @keywords or @author or @title or @text1 or @fulltext or @comment or @abstract or @rights or @subject or @publisher or @date or @filename or @topic_register
+ else
+ @text1 = q['s1'] if q['s1'] =~ /\S/
+ @fulltext = q['ft'] if q['ft'] =~ /\S/
+ @keywords = q['key'] if q['key'] =~ /\S/
+ @title = q['ti'] if q['ti'] =~ /\S/
+ @author = q['au'] if q['au'] =~ /\S/
+ @topic_register = q['tr'] if q['tr'] =~ /\S/
+ @subject = q['sj'] if q['sj'] =~ /\S/
+ @description = q['dsc'] if q['dsc'] =~ /\S/
+ @publisher = q['pb'] if q['pb'] =~ /\S/
+ @editor = q['cntr'] if q['cntr'] =~ /\S/
+ @contributor = q['cntr'] if q['cntr'] =~ /\S/
+ @date = q['dt'] if q['dt'] =~ /\S/
+ @type = q['ty'] if q['ty'] =~ /\S/
+ @identifier = q['id'] if q['id'] =~ /\S/
+ @source = q['src'] if q['src'] =~ /\S/
+ @language = q['lang'] if q['lang'] =~ /\S/
+ @relation = q['rel'] if q['rel'] =~ /\S/
+ @coverage = q['cov'] if q['cov'] =~ /\S/
+ @rights = q['cr'] if q['cr'] =~ /\S/
+ @comment = q['co'] if q['co'] =~ /\S/
+ @abstract = q['ab'] if q['ab'] =~ /\S/
+ @date_created = q['dtc'] if q['dtc'] =~ /\S/
+ @date_issued = q['dti'] if q['dti'] =~ /\S/
+ @date_modified = q['dtm'] if q['dtm'] =~ /\S/
+ @date_available = q['dta'] if q['dta'] =~ /\S/
+ @date_valid = q['dtv'] if q['dtv'] =~ /\S/
+ @filename = if q['doc'] and q['search'] !~ /search db/ then q['doc']
+ elsif q['fns'] =~ /\S/ then q['fns']
+ end
+ @@limit = q['ltd'] if q['ltd'] =~ /\d+/ # 1000
+ @@offset = q['off'] if q['off'] =~ /\d+/ # 0
+ end
+ end
+def text_to_match(identifier='')
+ m={
+ string: /#{identifier}\s*(.+?)/,
+ string: /#{identifier}\s*(.+?)(?:;|\n|\r|$)/,
+ word: /#{identifier}[\s(]*(\S+)/
+ }
+ search_string=if @search_field =~m[:word]
+ search_string=if @search_field =~m[:braces] then m[:braces].match(@search_field)[1]
+ elsif @search_field =~m[:string] then m[:string].match(@search_field)[1]
+ else
+ str=m[:word].match(@search_field)[1]
+ str=str.gsub(/[()]/,'')
+ str
+ end
+ search_string=search_string.strip.gsub(/\s+/,'+')
+ #else
+ # "__"
+ end
+ end
+end
+class DBI_SearchString
+ def initialize(l,t,q,cse=false)
+ @l,@t,@q=l,t,q
+ end
+ def string
+ search={ search: [], flag: false }
+ if @t =~/\S+/ or @q =~/\S+/
+ if @t =~/\S+/ then unescaped_search=CGI.unescape(@t)
+ elsif @q =~/\S+/ then unescaped_search=CGI.unescape(@q)
+ end
+ search_construct=[]
+ unescaped_search=unescaped_search.gsub(/\s*(AND|OR)\s*/,"%' \) \\1 #{@l} LIKE \( '%").
+ gsub(/(.+)/,"#{@l} LIKE \( '%\\1%' \)")
+ search_construct << unescaped_search
+ search_construct=search_construct.join(' ')
+ search[:search] << search_construct
+ search[:flag]=true
+ search
+ end
+ search
+ end
+end
+class DBI_SearchStatement
+ attr_reader :text_search_flag,:sql_select_body_format,:sql_offset,:sql_limit
+ def initialize(conn,search_for,q,c)
+ @conn=conn
+ @text_search_flag=false
+ @sql_statement={ body: '', endnotes: '', range: '' }
+ #@offset||=@@offset
+ #@offset+=@@limit
+ search={ text: [], endnotes: [] }
+ cse=(c =~/\S/) ? true : false
+ st=DBI_SearchString.new('doc_objects.clean',search_for.text1,q['s1'],cse).string
+ se=DBI_SearchString.new('endnotes.clean',search_for.text1,q['s1'],cse).string
+ @text_search_flag=st[:flag]
+ if st[:flag]
+ search[:text] << st[:search]
+ end
+ st = DBI_SearchString.new('metadata_and_text.fulltext',search_for.fulltext,q['ft'],cse).string
+ if st[:flag]
+ search[:text] << st[:search]
+ end
+ st = DBI_SearchString.new('metadata_and_text.title',search_for.title,q['ti'],cse).string
+ if st[:flag]
+ search[:text] << st[:search]
+ end
+ st = DBI_SearchString.new('metadata_and_text.creator_author',search_for.author,q['au'],cse).string
+ if st[:flag]
+ search[:text] << st[:search]
+ end
+ st = DBI_SearchString.new('metadata_and_text.classify_topic_register',search_for.topic_register,q['tr'],cse).string
+ if st[:flag]
+ search[:text] << st[:search]
+ end
+ st = DBI_SearchString.new('metadata_and_text.classify_subject',search_for.subject,q['sj'],cse).string
+ if st[:flag]
+ search[:text] << st[:search]
+ end
+ st = DBI_SearchString.new('metadata_and_text.classify_keywords',search_for.keywords,q['key'],cse).string
+ if st[:flag]
+ search[:text] << st[:search]
+ end
+ st = DBI_SearchString.new('metadata_and_text.notes_description',search_for.description,q['dsc'],cse).string
+ if st[:flag]
+ search[:text] << st[:search]
+ end
+ st = DBI_SearchString.new('metadata_and_text.publisher',search_for.publisher,q['pb'],cse).string
+ if st[:flag]
+ search[:text] << st[:search]
+ end
+ st = DBI_SearchString.new('metadata_and_text.creator_editor',search_for.editor,q['cntr'],cse).string
+ if st[:flag]
+ search[:text] << st[:search]
+ end
+ st = DBI_SearchString.new('metadata_and_text.creator_contributor',search_for.contributor,q['cntr'],cse).string
+ if st[:flag]
+ search[:text] << st[:search]
+ end
+ st = DBI_SearchString.new('metadata_and_text.date_published',search_for.date,q['dt'],cse).string
+ if st[:flag]
+ search[:text] << st[:search]
+ end
+ st = DBI_SearchString.new('metadata_and_text.notes_type',search_for.type,q['ty'],cse).string
+ if st[:flag]
+ search[:text] << st[:search]
+ end
+ st = DBI_SearchString.new('metadata_and_text.original_source',search_for.source,q['src'],cse).string
+ if st[:flag]
+ search[:text] << st[:search]
+ end
+ st = DBI_SearchString.new('metadata_and_text.language_document_char',search_for.language,q['lang'],cse).string
+ if st[:flag]
+ search[:text] << st[:search]
+ end
+ st = DBI_SearchString.new('metadata_and_text.notes_relation',search_for.relation,q['rel'],cse).string
+ if st[:flag]
+ search[:text] << st[:search]
+ end
+ st = DBI_SearchString.new('metadata_and_text.notes_coverage',search_for.coverage,q['cov'],cse).string
+ if st[:flag]
+ search[:text] << st[:search]
+ end
+ st = DBI_SearchString.new('metadata_and_text.rights_all',search_for.rights,q['cr'],cse).string
+ if st[:flag]
+ search[:text] << st[:search]
+ end
+ st = DBI_SearchString.new('metadata_and_text.notes_comment',search_for.comment,q['co'],cse).string
+ if st[:flag]
+ search[:text] << st[:search]
+ end
+ st = DBI_SearchString.new('metadata_and_text.notes_abstract',search_for.abstract,q['ab'],cse).string
+ if st[:flag]
+ search[:text] << st[:search]
+ end
+ st = DBI_SearchString.new('metadata_and_text.src_filename_base',search_for.src_filename_base,q['fns'],cse).string
+ if st[:flag]
+ search[:text] << st[:search]
+ end
+ @@limit=q['ltd'] if q['ltd']=~/\d+/ # 1000
+ @@offset=q['off'] if q['off']=~/\d+/ # 0
+ @search_text=''
+ @search_text=search[:text].flatten.join(' AND ')
+ @search_text=@search_text.gsub(/(doc_objects\.clean\s+LIKE\s+\(\s*'%[^']+%'\s*\)\s+(?:(?:AND|OR)\s+doc_objects\.clean\s+LIKE\s+\(\s*'%[^']+%'\s*\))+)/,'(\1)')
+ end
+def sql_offset
+ @@offset
+end
+def sql_match_limit
+ @@limit
+end
+def sql_canned_search
+ @offset_next=sql_offset.to_i + sql_match_limit.to_i
+ @offset_previous=sql_offset.to_i - sql_match_limit.to_i
+ def current
+ @@canned_search_url.to_s + '&ltd=' + sql_match_limit.to_s + '&off=' + sql_offset.to_s
+ end
+ def next
+ @@canned_search_url.to_s + '&ltd=' + sql_match_limit.to_s + '&off=' + @offset_next.to_s
+ end
+ def previous
+ @offset_previous >= 0 \
+ ? (@@canned_search_url.to_s + '&ltd=' + sql_match_limit.to_s + '&off=' + @offset_previous.to_s)
+ : ''
+ end
+ def start
+ @@canned_search_url.to_s + '&ltd=' + sql_match_limit.to_s + '&off=' + 0.to_s
+ end
+ self
+end
+def pre_next(beyond_limit,img)
+ can=sql_canned_search
+ page=(sql_offset.to_i + sql_match_limit.to_i)/sql_match_limit.to_i
+ if beyond_limit
+ if page.to_s =~ /^1$/
+ %{<br /><center>
+ pg. #{page.to_s}
+ <a href="#{can.next}">
+ <img border="0" width="22" height="22" src="#{img}/arrow_next_red.png" alt="&nbsp;&gt;&gt;" />
+ </a>
+ </center>}
+ elsif page.to_s =~ /^2$/
+ %{<br /><center>
+ <a href="#{can.previous}">
+ <img border="0" width="22" height="22" src="#{img}/arrow_prev_red.png" alt="&lt;&lt;&nbsp;" />
+ </a>
+ pg. #{page.to_s}
+ <a href="#{can.next}">
+ <img border="0" width="22" height="22" src="#{img}/arrow_next_red.png" alt="&nbsp;&gt;&gt;" />
+ </a>
+ </center>}
+ else
+ %{<br /><center>
+ <a href="#{can.start}">
+ <img border="0" width="22" height="22" src="#{img}/arrow_prev_red.png" alt="|&lt;&nbsp;" />
+ </a>
+ <a href="#{can.previous}">
+ <img border="0" width="22" height="22" src="#{img}/arrow_prev_red.png" alt="&lt;&lt;&nbsp;" />
+ </a>
+ pg. #{page.to_s}
+ <a href="#{can.next}">
+ <img border="0" width="22" height="22" src="#{img}/arrow_next_red.png" alt="&nbsp;&gt;&gt;" />
+ </a>
+ </center>}
+ end
+ else
+ if page.to_s =~ /^1$/ then ''
+ elsif page.to_s =~ /^2$/
+ %{<br /><center>
+ <a href="#{can.previous}">
+ <img border="0" width="22" height="22" src="#{img}/arrow_prev_red.png" alt="&lt;&lt;&nbsp;" />
+ </a>
+ pg. #{page.to_s}
+ </center>}
+ else
+ %{<br /><center>
+ <a href="#{can.start}">
+ <img border="0" width="22" height="22" src="#{img}/arrow_prev_red.png" alt="|&lt;&nbsp;" />
+ </a>
+ <a href="#{can.previous}">
+ <img border="0" width="22" height="22" src="#{img}/arrow_prev_red.png" alt="&lt;&lt;&nbsp;" />
+ </a>
+ pg. #{page.to_s}
+ </center>}
+ end
+ end
+end
+def sql_select_body
+ limit ||= @@limit
+ offset ||= @@offset
+ @sql_statement[:body] = %{
+ SELECT metadata_and_text.title, metadata_and_text.creator_author, metadata_and_text.src_filename_base, metadata_and_text.language_document_char, metadata_and_text.notes_suffix, doc_objects.body, doc_objects.seg_name, doc_objects.ocn, metadata_and_text.uid
+ FROM doc_objects, metadata_and_text
+ WHERE #{@search_text} AND doc_objects.uid_metadata_and_text = metadata_and_text.uid
+ ORDER BY metadata_and_text.language_document_char, metadata_and_text.title, metadata_and_text.src_filename_base, doc_objects.ocn
+ }
+ @sql_statement[:range] = %{LIMIT #{limit} OFFSET #{offset} ;}
+ select = @sql_statement[:body] + ' ' + @sql_statement[:range]
+ select
+ end
+ def sql_select_body_format
+ %{<font color="#666666" size="2">#{sql_select_body}</font>}
+ end
+ def contents
+ @conn.execute(sql_select_body)
+ end
+end
+def tail
+ <<-'WOK'
+ <br /><hr /><br />
+<table summary="SiSU summary" cellpadding="2" border="0">
+ <!-- widget sisu -->
+<tr><td valign="top" width="10%">
+ <table summary="home button / home information" border="0" cellpadding="3" cellspacing="0">
+ <tr><td align="left">
+ <br /><a href="https://sisudoc.org/" target="_top">
+ <b>SiSU</b>
+ </a>
+ <br /><a href="https://git.sisudoc.org/" target="_top">
+ git
+ </a>
+ </td></tr>
+ </table>
+</td>
+<td valign="top" width="45%">
+<!-- SiSU Rights -->
+ <p class="tiny_left"><font color="#666666" size="2">
+ Generated by
+ SiSU 6.3.1 2014-10-19 (2014w41/7)
+ <br />
+ <a href="https://www.sisudoc.org" >
+ <b>SiSU</b></a> <sup>&copy;</sup> Ralph Amissah
+ 1993, current 2014.
+ All Rights Reserved.
+ <br />
+ SiSU is software for document structuring, publishing and search,
+ <br />
+ <a href="https://www.sisudoc.org" >
+ www.sisudoc.org
+ </a>
+ sources
+ <a href="https://git.sisudoc.org" >
+ git.sisudoc.org
+ </a>
+ <br />
+ <i>w3 since October 3 1993</i>
+ <a href="mailto:ralph@amissah.com" >
+ ralph@amissah.com
+ </a>
+ <br />
+ mailing list subscription
+ <a href="https://lists.sisudoc.org/listinfo/sisu" >
+ https://lists.sisudoc.org/listinfo/sisu
+ </a>
+ <br />
+ <a href="mailto:sisu@lists.sisudoc.org" >
+ sisu@lists.sisudoc.org
+ </a>
+ </font></p>
+</td><td valign="top" width="45%">
+ <p class="tiny_left"><font color="#666666" size="2">
+ SiSU using:
+ <br />Standard SiSU markup syntax,
+ <br />Standard SiSU meta-markup syntax, and the
+ <br />Standard SiSU <u>object citation numbering</u> and system, (object/text identifying/locating system)
+ <br />
+ <sup>&copy;</sup> Ralph Amissah 1997, current 2014.
+ All Rights Reserved.
+ </font></p>
+</td></tr>
+ <!-- widget way better -->
+<tr><td valign="top" width="10%">
+ <p class="tiny_left"><font color="#666666" size="2">
+ <a href="https://www.gnu.org/licenses/gpl.html">
+ .:
+ </a>
+ </font></p>
+</td><td valign="top" width="45%">
+ <p class="tiny_left"><font color="#666666" size="2">
+ SiSU is released under
+ <a href="https://www.gnu.org/licenses/gpl.html">GPL&nbsp;v3</a>
+ or later,
+ <a href="https://www.gnu.org/licenses/gpl.html">
+ https://www.gnu.org/licenses/gpl.html
+ </a>
+ </font></p>
+</td><td valign="top" width="45%">
+ <p class="tiny_left"><font color="#666666" size="2">
+ SiSU, developed using
+ <a href="https://www.ruby-lang.org/en/">
+ Ruby
+ </a>
+ on
+ <a href="https://www.debian.org/">
+ Debian/Gnu/Linux
+ </a>
+ software infrastructure,
+ with the usual GPL (or OSS) suspects.
+ </font></p>
+</td></tr>
+</table>
+ <a name="bottom" id="bottom"></a><a name="down" id="down"></a><a name="end" id="end"></a><a name="finish" id="finish"></a><a name="stop" id="stop"></a><a name="credits" id="credits"></a>
+ </body></html>
+ WOK
+end
+@tail=tail
+@counter_txt_doc,@counter_txt_ocn,@counter_endn_doc,@counter_endn_ocn=0,0,0,0
+@counters_txt,@counters_endn,@sql_select_body='','',''
+FCGI.each_cgi do |cgi|
+ begin # all code goes in begin section
+ @search={ text: [], endnotes: [] }
+ q=CGI.new
+ @db=if cgi['db'] =~ /#{@db_name_prefix}(\S+)/
+ @stub=$1
+ cgi['db']
+ else
+ @stub=@stub_default
+ @db_name_prefix + @stub
+ end
+ checked_url,checked_stats,checked_searched,checked_tip,checked_case,checked_echo,checked_sql,checked_all,checked_none,checked_selected,checked_default,selected_db='','','','','','','','',''
+ result_type=(cgi['view']=~/text/) \
+ ? result_type={ index: '', text: 'checked'}
+ : result_type={ index: 'checked', text: ''}
+ @@limit=if cgi['sql_match_limit'].to_s=~/2500/
+ checked_sql_limit={ l1000: '', l2500: 'checked'}
+ '2500'
+ else
+ checked_sql_limit={ l1000: 'checked', l2500: ''}
+ '1000'
+ end
+ checked_echo = 'checked' if cgi['echo'] =~/\S/
+ checked_stats = 'checked' if cgi['stats'] =~/\S/
+ checked_url = 'checked' if cgi['url'] =~/\S/ or cgi['u'].to_i==1
+ checked_searched = 'checked' if cgi['searched'] =~/\S/
+ checked_tip = 'checked' if cgi['tip'] =~/\S/
+ checked_case = 'checked' if cgi['casesense'] =~/\S/
+ checked_sql = 'checked' if cgi['sql'] =~/\S/
+ if cgi['checks'] =~ /check_all/ or cgi['check_all'] =~/\S/ or cgi['a'].to_i==1
+ checked_all = 'checked'
+ checked_echo=checked_stats=checked_url=checked_searched=checked_tip=checked_sql='checked'
+ checked_none =''
+ elsif cgi['checks'] =~ /check_none/
+ checked_none = 'checked'
+ checked_all=checked_url=checked_stats=checked_searched=checked_tip=checked_echo=checked_sql=''
+ elsif cgi['checks'] =~ /check_selected/
+ checked_selected = 'checked'
+ elsif cgi['checks'] =~ /check_default/
+ checked_default = 'checked'
+ checked_echo=checked_stats=checked_url='checked'
+ checked_searched=checked_tip=checked_case=checked_sql=''
+ else
+ checked_selected='checked'
+ checked_echo=checked_stats=checked_url='checked'
+ checked_searched=checked_tip=checked_case=checked_sql=''
+ end
+ selected_db=case cgi['db']
+ when /spine.sqlite/ then '<option value="spine.sqlite">spine</option>'
+ end
+ db_name='spine.search.sql.db'
+ #db_name='spine.sqlite.db'
+ #db_name='sisu_sqlite.db'
+ db_sqlite=case cgi['db']
+ when /spine.sqlite/ then "/srv/complete.sisudoc.org/web/manual/#{db_name}"
+ else "/var/www/sqlite/#{db_name}"
+ end
+ #when /spine.sqlite/ then "/srv/complete.sisudoc.org/web/manual/#{db_name}"
+ #else "/srv/complete.sisudoc.org/web/manual/#{db_name}"
+ #end
+ #@conn=SQLite3::Database.new(db_sqlite)
+ @conn=SQLite3::Database.new("/var/www/sqlite/spine.search.sql.db")
+ #@conn=SQLite3::Database.new("/var/www/spine.sqlite.db")
+ @conn.results_as_hash=true
+ search_field=cgi['find'] if cgi['find'] # =~/\S+/
+ @search_for=SearchRequest.new(search_field,q) #.analyze #% search_for
+ #% searches
+#Canned_search.new(@base,@search_for.text1,cgi)
+ if @search_for.text1=~/\S+/ or @search_for.fulltext=~/\S+/ or @search_for.author=~/\S+/ or @search_for.topic_register=~/\S+/ #and search_field =~/\S/
+ s1 = 's1=' + CGI.escape(@search_for.text1) if @search_for.text1 =~ /\S/
+ ft = '&ft=' + CGI.escape(@search_for.fulltext) if @search_for.fulltext =~ /\S/
+ key = 'key=' + CGI.escape(@search_for.keywords) if @search_for.keywords =~ /\S/
+ ti = '&ti=' + CGI.escape(@search_for.title) if @search_for.title =~ /\S/
+ au = '&au=' + CGI.escape(@search_for.author) if @search_for.author =~ /\S/
+ tr = '&tr=' + CGI.escape(@search_for.topic_register) if @search_for.topic_register =~ /\S/
+ sj = '&sj=' + CGI.escape(@search_for.subject) if @search_for.subject =~ /\S/
+ dsc = '&dsc=' + CGI.escape(@search_for.description) if @search_for.description =~ /\S/
+ pb = '&pb=' + CGI.escape(@search_for.publisher) if @search_for.publisher =~ /\S/
+ edt = '&edt=' + CGI.escape(@search_for.editor) if @search_for.editor =~ /\S/
+ cntr = '&cntr=' + CGI.escape(@search_for.contributor) if @search_for.contributor =~ /\S/
+ dt = '&dt=' + CGI.escape(@search_for.date) if @search_for.date =~ /\S/
+ ty = '&ty=' + CGI.escape(@search_for.type) if @search_for.type =~ /\S/
+ id = '&id=' + CGI.escape(@search_for.identifier) if @search_for.identifier =~ /\S/
+ src = '&src=' + CGI.escape(@search_for.source) if @search_for.source =~ /\S/
+ lang = '&lang=' + CGI.escape(@search_for.language) if @search_for.language =~ /\S/
+ rel = '&rel=' + CGI.escape(@search_for.relation) if @search_for.relation =~ /\S/
+ cov = '&cov=' + CGI.escape(@search_for.coverage) if @search_for.coverage =~ /\S/
+ cr = '&cr=' + CGI.escape(@search_for.rights) if @search_for.rights =~ /\S/
+ co = '&co=' + CGI.escape(@search_for.comment) if @search_for.comment =~ /\S/
+ ab = '&ab=' + CGI.escape(@search_for.abstract) if @search_for.abstract =~ /\S/
+ dtc = '&dtc=' + CGI.escape(@search_for.date_created) if @search_for.date_created =~ /\S/
+ dti = '&dti=' + CGI.escape(@search_for.date_issued) if @search_for.date_issued =~ /\S/
+ dtm = '&dtm=' + CGI.escape(@search_for.date_modified) if @search_for.date_modified =~ /\S/
+ dta = '&dta=' + CGI.escape(@search_for.date_available) if @search_for.date_available =~ /\S/
+ dtv = '&dtv=' + CGI.escape(@search_for.date_valid) if @search_for.date_valid =~ /\S/
+ fns = '&fns=' + CGI.escape(@search_for.src_filename_base) if @search_for.src_filename_base =~ /\S/
+ @@canned_search_url=(checked_all =~/checked/) \
+ ? "#{@base}?#{s1}#{ft}#{key}#{ti}#{au}#{tr}#{sj}#{dsc}#{pb}#{edt}#{cntr}#{dt}#{ty}#{id}#{src}#{lang}#{rel}#{cov}#{cr}#{co}#{ab}#{dtc}#{dti}#{dtm}#{dta}#{dtv}#{fns}&db=#{cgi['db']}&view=#{cgi['view']}&a=1"
+ : "#{@base}?#{s1}#{ft}#{key}#{ti}#{au}#{tr}#{sj}#{dsc}#{pb}#{edt}#{cntr}#{dt}#{ty}#{id}#{src}#{lang}#{rel}#{cov}#{cr}#{co}#{ab}#{dtc}#{dti}#{dtm}#{dta}#{dtv}#{fns}&db=#{cgi['db']}&view=#{cgi['view']}"
+ mod=ft=~/\S+/ ? (ft.gsub(/ft/,'s1')) : s1
+ @canned_base_url="#{@base}?#{mod}&db=#{cgi['db']}"
+ if checked_case=~/\S/
+ @search[:text][1]=%{doc_objects.clean~'#{@search_for.text1}'} #s1
+ else
+ @search[:text][1]=%{doc_objects.clean~*'#{@search_for.text1}'} #s1
+ end
+ canned_note='search url:'
+ else
+ @@canned_search_url="#{@base}?db=#{@db}&view=index"
+ canned_note='search url example:'
+ end
+ if search_field =~/\S+/
+ analyze_format=search_field.gsub(/\s*\n/,'; ')
+ elsif checked_all =~/checked/ or checked_url =~/checked/
+ canned_search=@@canned_search_url.scan(/(?:s1|ft|au|ti|fns|tr)=[^&]+/)
+ af=canned_search.join('; ')
+ af=af.gsub(/s1=/,'text: ').
+ gsub(/ft=/,'fulltxt: ').
+ gsub(/au=/,'author: ').
+ gsub(/ti=/,'title: ').
+ gsub(/fns=/,'src_filename_base: ').
+ gsub(/tr=/,'topic_register: ').
+ gsub(/%2B/,' ')
+ analyze_format=af
+ st=af.split(/\s*;\s*/)
+ search_field=st.join("\n")
+ end
+ green=%{<font size="2" color="#004000">}
+ canned_search_url_txt=CGI.escapeHTML(@@canned_search_url)
+ the_can=%{<font size="2" color="#666666">#{canned_note} <a href="#{@@canned_search_url}">#{canned_search_url_txt}</a></font><br />}
+ p_text=p_fulltext=p_keywords=p_title=p_author=p_topic_register=p_subject=p_description=p_publisher=p_editor=p_contributor=p_date=p_type=p_format=p_identifier=p_source=p_language=p_relation=p_coverage=p_rights=p_comment=p_abstract=p_filename=''
+ p_filename = %{src_filename_base: #{green}#{@search_for.src_filename_base}</font><br />} if @search_for.src_filename_base =~ /\S+/
+ p_text = %{text: #{green}#{@search_for.text1}</font><br />} if @search_for.text1 =~ /\S+/
+ p_fulltext = %{fulltxt: #{green}#{@search_for.fulltext}</font><br />} if @search_for.fulltext =~ /\S+/
+ p_title = %{title: #{green}#{@search_for.title}</font><br />} if @search_for.title =~ /\S+/
+ p_author = %{author: #{green}#{@search_for.author}</font><br />} if @search_for.author =~ /\S+/
+ p_editor = %{editor: #{green}#{@search_for.editor}</font><br />} if @search_for.editor =~ /\S+/
+ p_contributor = %{contributor: #{green}#{@search_for.contributor}</font><br />} if @search_for.contributor =~ /\S+/
+ p_date = %{date: #{green}#{@search_for.date}</font><br />} if @search_for.date =~ /\S+/
+ p_rights = %{rights: #{green}#{@search_for.rights}</font><br />} if @search_for.rights =~ /\S+/
+ p_topic_register = %{topic_register: #{green}#{@search_for.topic_register}</font><br />} if @search_for.topic_register =~ /\S+/
+ p_subject = %{subject: #{green}#{@search_for.subject}</font><br />} if @search_for.subject =~ /\S+/
+ p_keywords = %{keywords: #{green}#{@search_for.keywords}</font><br />} if @search_for.keywords =~ /\S+/
+ p_identifier = %{identifier: #{green}#{@search_for.identifier}</font><br />} if @search_for.identifier =~ /\S+/
+ p_type = %{type: #{green}#{@search_for.type}</font><br />} if @search_for.type =~ /\S+/
+ p_format = %{format: #{green}#{@search_for.format}</font><br />} if @search_for.format =~ /\S+/
+ p_relation = %{relation: #{green}#{@search_for.relation}</font><br />} if @search_for.relation =~ /\S+/
+ p_coverage = %{coverage: #{green}#{@search_for.coverage}</font><br />} if @search_for.coverage =~ /\S+/
+ p_description = %{description: #{green}#{@search_for.description}</font><br />} if @search_for.description =~ /\S+/
+ p_abstract = %{abstract: #{green}#{@search_for.abstract}</font><br />} if @search_for.abstract =~ /\S+/
+ p_comment = %{comment: #{green}#{@search_for.comment}</font><br />} if @search_for.comment =~ /\S+/
+ p_publisher = %{publisher: #{green}#{@search_for.publisher}</font><br />} if @search_for.publisher =~ /\S+/
+ p_source = %{source: #{green}#{@search_for.source}</font><br />} if @search_for.source =~ /\S+/
+ p_language = %{language: #{green}#{@search_for.language}</font><br />} if @search_for.language =~ /\S+/
+ search_note=<<-WOK
+ <font size="2" color="#666666">
+ <b>database:</b> #{green}#{@db}</font>; <b>selected view:</b> #{green}#{cgi['view']}</font>
+ <b>search string:</b> "#{green}#{analyze_format}</font>"<br />
+ #{p_text} #{p_fulltext} #{p_keywords} #{p_title} #{p_author} #{p_topic_register} #{p_subject} #{p_description} #{p_publisher} #{p_editor} #{p_contributor} #{p_date} #{p_type} #{p_format} #{p_identifier} #{p_source} #{p_language} #{p_relation} #{p_coverage} #{p_rights} #{p_comment} #{p_abstract} #{p_filename}
+ </font>
+ WOK
+#eg = %{canned search e.g.:<br /> <a href="#{url}">#{url}</a><br />find: #{analyze}<br />database: #{database}}
+#% dbi_canning
+@header = Form.new(@base,search_field,selected_db,result_type,checked_sql_limit,checked_tip,checked_stats,checked_searched,checked_url,checked_case,checked_echo,checked_sql,checked_all,checked_none,checked_selected,checked_default,search_note,the_can).submission_form #% form
+unless q['s1'] =~/\S/ or q['au'] =~/\S/ or @search[:text][1] =~/\S/
+ print "Content-type: text/html\n\n"
+ puts (@header+@tail)
+else #% searches
+ s1=(@search_for.text1 =~/\S/) \
+ ? @search_for.text1
+ : 'Unavailable'
+ if checked_case=~/\S/
+ @search[:text]<<%{doc_objects.clean~'#{CGI.unescape(s1)}'}
+ else
+ @search[:text]<<%{doc_objects.clean~*'#{CGI.unescape(s1)}'}
+ end
+ #% dbi_request
+ dbi_statement=DBI_SearchStatement.new(@conn,@search_for,q,checked_case)
+ @text_search_flag=false
+ @text_search_flag=dbi_statement.text_search_flag
+ s_contents=dbi_statement.contents
+ @body_main=''
+ @search_regx=nil
+ olduid=""
+ if @text_search_flag
+ if checked_sql =~/\S/
+ sql_select_body=dbi_statement.sql_select_body_format
+ else sql_select_body=''
+ end
+ @body_main << sql_select_body
+ #@body_main << '<p><hr><br /><b>Main Text:</b><br />' << sql_select_body
+ else
+ end
+ @hostpath = "#{@hosturl_files}"
+ #@hostpath="#{@hosturl_files}/#{@stub}"
+ def path_manifest(fn,ln=nil)
+ case @output_dir_structure_by
+ when 'filename'
+ @lingual =='mono' \
+ ? "#{@hostpath}/#{fn}/sisu_manifest.html"
+ : "#{@hostpath}/#{fn}/sisu_manifest.#{ln}.html"
+ when 'filetype'
+ @lingual =='mono' \
+ ? "#{@hostpath}/manifest/#{fn}.html"
+ : "#{@hostpath}/manifest/#{fn}.#{ln}.html"
+ else
+ "#{@hostpath}/#{ln}/manifest/#{fn}.html"
+ end
+ end
+ def path_html_seg(fn,ln=nil)
+ case @output_dir_structure_by
+ when 'filename'
+ "#{@hostpath}/#{fn}"
+ when 'filetype'
+ "#{@hostpath}/html/#{fn}"
+ else
+ "#{@hostpath}/#{ln}/html/#{fn}"
+ end
+ end
+ def path_toc(fn,ln=nil)
+ if @output_dir_structure_by =='filename' \
+ or @output_dir_structure_by =='filetype'
+ @lingual =='mono' \
+ ? "#{path_html_seg(fn,ln)}/toc.html"
+ : "#{path_html_seg(fn,ln)}/toc.#{ln}.html"
+ else
+ "#{path_html_seg(fn,ln)}/toc.html"
+ end
+ end
+ def path_filename(fn,seg_name,ln=nil)
+ if @output_dir_structure_by =='filename' \
+ or @output_dir_structure_by =='filetype'
+ @lingual =='mono' \
+ ? "#{path_html_seg(fn,ln)}/#{seg_name}.html"
+ : "#{path_html_seg(fn,ln)}/#{seg_name}.#{ln}.html"
+ else
+ "#{path_html_seg(fn,ln)}/#{seg_name}.html"
+ end
+ end
+ def path_html_doc(fn,ln=nil)
+ case @output_dir_structure_by
+ when 'filename'
+ @lingual =='mono' \
+ ? "#{path_html_seg(fn,ln)}/scroll.html"
+ : "#{path_html_seg(fn,ln)}/scroll.#{ln}.html"
+ when 'filetype'
+ @lingual =='mono' \
+ ? "#{@hostpath}/html/#{fn}.html"
+ : "#{@hostpath}/html/#{fn}.#{ln}.html"
+ else
+ "#{@hostpath}/#{ln}/html/#{fn}.html"
+ end
+ end
+#% text_objects_body
+s_contents.each do |c| #% text body
+ location=c['src_filename_base'][/(.+?)\.(?:ssm\.sst|sst)$/,1]
+ file_suffix=c['src_filename_base'][/.+?\.(ssm\.sst|sst)$/,1]
+ lang=if location =~ /\S+?~(\S\S\S?)$/
+ l=location[/\S+?~(\S\S\S?)$/,1]
+ location=location.gsub(/(\S+?)~\S\S\S?/,'\1')
+ l=".#{l}"
+ else ''
+ end
+#% metadata_found_body
+ if c['uid'] != olduid
+ ti=c['title']
+ can_txt_srch=(cgi['view']=~/index/) \
+ ? %{<a href="#{@canned_base_url}&fns=#{c['src_filename_base']}&lang=#{c['language_document_char']}&view=text"><img border="0" width="24" height="16" src="#{@image_src}/b_search.png" alt="search"></a>&nbsp;}
+ : %{<a href="#{@canned_base_url}&fns=#{c['src_filename_base']}&lang=#{c['language_document_char']}&view=index"><img border="0" width="24" height="16" src="#{@image_src}/b_search.png" alt="search"></a>&nbsp;}
+ title = %{<span style="background-color: #{@color_heading}"><a href="#{path_toc(location,c['language_document_char'])}"><img border="0" width="15" height="18" src="#{@image_src}/b_toc.png" alt="">&nbsp;#{ti}</a></span> [#{c['language_document_char']}] by #{c['creator_author']} <a href="#{path_manifest(location,c['language_document_char'])}"><img border="0" width="15" height="15" src="#{@image_src}/b_info.png" alt=""></a> #{can_txt_srch}<br />}
+ title=@text_search_flag \
+ ? '<br /><hr>'+title
+ : '<br />'+title
+ @counter_txt_doc+=1
+ olduid=c['uid']
+ else title=''
+ end
+ if @text_search_flag
+ if cgi['view']=~/text/ \
+ or (cgi['view']!~/index/ and cgi['search'] !~/search db/) #% txt body
+ text=if c['suffix'] !~/1/ #seg
+ if @search_for.text1 =~/\S+/ \
+ or q['s1'] =~/\S+/ #% only this branch is working !!
+ unescaped_search=if @search_for.text1 =~/\S+/
+ CGI.unescape(@search_for.text1)
+ elsif q['s1'] =~/\S+/
+ CGI.unescape(q['s1'])
+ else nil
+ end
+ @search_regx=if unescaped_search #check
+ search_regex=[]
+ build=unescaped_search.scan(/\S+/).each do |g|
+ (g.to_s =~/(AND|OR)/) \
+ ? (search_regex << '|')
+ : (search_regex << %{#{g.to_s}})
+ end
+ search_regex=search_regex.join(' ')
+ search_regex=search_regex.gsub(/\s*\|\s*/,'|')
+ Regexp.new(search_regex, Regexp::IGNORECASE)
+ else nil
+ end
+ else nil
+ end
+ matched_para=(@search_regx.to_s.class==String && @search_regx.to_s=~/\S\S+/) \
+ ? (c['body'].gsub(/(<a\s+href="https?:\/\/[^><\s]+#{@search_regx}[^>]+?>|#{@search_regx})/mi,%{<span style="background-color: #{@color_match}">\\1</span>}))
+ : c['body']
+ %{<hr><p><font size="2">ocn <b><a href="#{path_filename(location,c['seg_name'],c['language_document_char'])}##{c['ocn']}">#{c['ocn']}</a></b>:</font></p>#{matched_para}}
+ elsif c['suffix'] =~/1/ #doc
+ %{#{title}<hr><p><font size="2">ocn #{c['ocn']}:#{c['body']}}
+ end
+ @counter_txt_ocn+=1
+ output=title+text
+ else #elsif cgi['view']=~/index/ #% idx body
+ if c['suffix'] !~/1/ #seg
+ index=%{<a href="#{path_filename(location,c['seg_name'],c['language_document_char'])}##{c['ocn']}">#{c['ocn']}</a>, } if @text_search_flag
+ elsif c['suffix'] =~/1/ #doc #FIX
+ index=%{<a href="#{path_html_doc(location,c['language_document_char'])}##{c['ocn']}">#{c['ocn']}</a>, }
+ end
+ if c['seg_name'] =~/\S+/
+ if @text_search_flag
+ @counter_txt_ocn+=1
+ output=title+index
+ end
+ else
+ @counter_txt_ocn+=1
+ output=c['suffix'] !~/1/ \
+ ? title+index
+ : %{#{title}#{c['ocn'].sort}, }
+ end
+ end
+ else output=title
+ end
+ @counters_txt=if @counter_txt_doc > 0
+ if checked_stats =~/\S/
+ @@lt_t=(@counter_txt_ocn==dbi_statement.sql_match_limit.to_i) ? true : false
+ start=(@@offset.to_i+1).to_s
+ range=(@@offset.to_i+@counter_txt_ocn.to_i).to_s
+ %{<hr /><font size="2" color="#666666">Found #{@counter_txt_ocn} times in the main body of #{@counter_txt_doc} documents [ matches #{start} to #{range} ]</font><br />}
+ else ''
+ end
+ else ''
+ end
+ @body_main << output #+ details
+end
+olduid = ""
+ offset=dbi_statement.sql_offset.to_s
+ limit=dbi_statement.sql_match_limit.to_s
+ @@lt_t ||=false; @@lt_e ||=false
+ canned=(@@lt_t or @@lt_e) \
+ ? dbi_statement.pre_next(true,@image_src).to_s
+ : dbi_statement.pre_next(false,@image_src).to_s
+ limit=dbi_statement.sql_match_limit.to_s
+ cgi.out{
+ @header.force_encoding("UTF-8") \
+ + @counters_txt.force_encoding("UTF-8") \
+ + @counters_endn.force_encoding("UTF-8") \
+ + canned.force_encoding("UTF-8") \
+ + @body_main.force_encoding("UTF-8") \
+ + canned.force_encoding("UTF-8") \
+ + @tail.force_encoding("UTF-8")
+ } #% print cgi_output_header+counters+body
+ end
+ rescue Exception => e
+ s='<pre>' + CGI::escapeHTML(e.backtrace.reverse.join("\n"))
+ s << CGI::escapeHTML(e.message) + '</pre>'
+ cgi.out{s}
+ next
+ ensure # eg. disconnect from server
+ @conn.disconnect if @conn
+ end
+end