From 75e3bf86382edf99275a25895b362647158e25c1 Mon Sep 17 00:00:00 2001
From: Ralph Amissah
Date: Tue, 10 Jan 2012 22:37:26 -0500
Subject: v3dv, add dev branch (use to make some changes to module & class
names & test)
* (intended as) short term branch, merge back into v3 once tested
* sisu --dev (to invoke)
---
lib/sisu/v3/modify.rb | 376 --
lib/sisu/v3dv/air.rb | 82 +
lib/sisu/v3dv/author_format.rb | 113 +
lib/sisu/v3dv/cgi.rb | 83 +
lib/sisu/v3dv/cgi_pgsql.rb | 230 +
lib/sisu/v3dv/cgi_sql_common.rb | 1075 +++++
lib/sisu/v3dv/cgi_sqlite.rb | 217 +
lib/sisu/v3dv/character_encoding.rb | 379 ++
lib/sisu/v3dv/composite.rb | 275 ++
lib/sisu/v3dv/concordance.rb | 356 ++
lib/sisu/v3dv/conf.rb | 247 +
lib/sisu/v3dv/constants.rb | 285 ++
lib/sisu/v3dv/css.rb | 3332 +++++++++++++
lib/sisu/v3dv/dal.rb | 506 ++
lib/sisu/v3dv/dal_character_check.rb | 103 +
lib/sisu/v3dv/dal_doc_objects.rb | 446 ++
lib/sisu/v3dv/dal_doc_str.rb | 1252 +++++
lib/sisu/v3dv/dal_endnotes.rb | 125 +
lib/sisu/v3dv/dal_expand_insertions.rb | 379 ++
lib/sisu/v3dv/dal_hash_digest.rb | 155 +
lib/sisu/v3dv/dal_idx.rb | 357 ++
lib/sisu/v3dv/dal_images.rb | 156 +
lib/sisu/v3dv/dal_metadata.rb | 79 +
lib/sisu/v3dv/dal_numbering.rb | 465 ++
lib/sisu/v3dv/dal_substitutions_and_insertions.rb | 154 +
lib/sisu/v3dv/dal_syntax.rb | 538 +++
lib/sisu/v3dv/db_columns.rb | 2108 ++++++++
lib/sisu/v3dv/db_create.rb | 614 +++
lib/sisu/v3dv/db_dbi.rb | 93 +
lib/sisu/v3dv/db_drop.rb | 187 +
lib/sisu/v3dv/db_import.rb | 666 +++
lib/sisu/v3dv/db_indexes.rb | 114 +
lib/sisu/v3dv/db_load_tuple.rb | 333 ++
lib/sisu/v3dv/db_remove.rb | 119 +
lib/sisu/v3dv/db_select.rb | 215 +
lib/sisu/v3dv/db_sqltxt.rb | 132 +
lib/sisu/v3dv/db_tests.rb | 117 +
lib/sisu/v3dv/dbi.rb | 143 +
lib/sisu/v3dv/defaults.rb | 2267 +++++++++
lib/sisu/v3dv/digests.rb | 388 ++
lib/sisu/v3dv/embedded.rb | 142 +
lib/sisu/v3dv/epub.rb | 706 +++
lib/sisu/v3dv/epub_concordance.rb | 312 ++
lib/sisu/v3dv/epub_format.rb | 2608 ++++++++++
lib/sisu/v3dv/epub_segments.rb | 551 +++
lib/sisu/v3dv/epub_tune.rb | 413 ++
lib/sisu/v3dv/errors.rb | 81 +
lib/sisu/v3dv/git.rb | 281 ++
lib/sisu/v3dv/harvest.rb | 108 +
lib/sisu/v3dv/harvest_authors.rb | 378 ++
lib/sisu/v3dv/harvest_topics.rb | 650 +++
lib/sisu/v3dv/help.rb | 1923 ++++++++
lib/sisu/v3dv/html.rb | 663 +++
lib/sisu/v3dv/html_format.rb | 1480 ++++++
lib/sisu/v3dv/html_minitoc.rb | 198 +
lib/sisu/v3dv/html_promo.rb | 434 ++
lib/sisu/v3dv/html_scroll.rb | 209 +
lib/sisu/v3dv/html_segments.rb | 558 +++
lib/sisu/v3dv/html_table.rb | 65 +
lib/sisu/v3dv/html_tune.rb | 383 ++
lib/sisu/v3dv/hub.rb | 674 +++
lib/sisu/v3dv/i18n.rb | 698 +++
lib/sisu/v3dv/manifest.rb | 863 ++++
lib/sisu/v3dv/manpage.rb | 430 ++
lib/sisu/v3dv/manpage_format.rb | 108 +
lib/sisu/v3dv/modify.rb | 376 ++
lib/sisu/v3dv/odf.rb | 779 +++
lib/sisu/v3dv/odf_format.rb | 607 +++
lib/sisu/v3dv/options.rb | 649 +++
lib/sisu/v3dv/param.rb | 1536 ++++++
lib/sisu/v3dv/param_identify_markup.rb | 168 +
lib/sisu/v3dv/particulars.rb | 210 +
lib/sisu/v3dv/plaintext.rb | 430 ++
lib/sisu/v3dv/plaintext_format.rb | 113 +
lib/sisu/v3dv/po4a.rb | 982 ++++
lib/sisu/v3dv/po4a_set.rb | 300 ++
lib/sisu/v3dv/prog_text_translation.rb | 1704 +++++++
lib/sisu/v3dv/qrcode.rb | 738 +++
lib/sisu/v3dv/relaxng.rb | 1161 +++++
lib/sisu/v3dv/remote.rb | 212 +
lib/sisu/v3dv/response.rb | 75 +
lib/sisu/v3dv/rexml.rb | 121 +
lib/sisu/v3dv/screen_text_color.rb | 487 ++
lib/sisu/v3dv/share_src.rb | 95 +
lib/sisu/v3dv/share_src_kdissert.rb | 88 +
lib/sisu/v3dv/shared_html.rb | 65 +
lib/sisu/v3dv/shared_html_lite.rb | 321 ++
lib/sisu/v3dv/shared_markup_alt.rb | 318 ++
lib/sisu/v3dv/shared_metadata.rb | 1361 ++++++
lib/sisu/v3dv/shared_sem.rb | 156 +
lib/sisu/v3dv/shared_txt.rb | 232 +
lib/sisu/v3dv/shared_xhtml.rb | 65 +
lib/sisu/v3dv/shared_xml.rb | 713 +++
lib/sisu/v3dv/sisupod_make.rb | 369 ++
lib/sisu/v3dv/sitemaps.rb | 215 +
lib/sisu/v3dv/spell.rb | 101 +
lib/sisu/v3dv/sst_convert_markup.rb | 312 ++
lib/sisu/v3dv/sst_do_inline_footnotes.rb | 472 ++
lib/sisu/v3dv/sst_from_xml.rb | 169 +
lib/sisu/v3dv/sst_identify_markup.rb | 474 ++
lib/sisu/v3dv/sst_to_s_xml_sax.rb | 453 ++
lib/sisu/v3dv/sysenv.rb | 5291 +++++++++++++++++++++
lib/sisu/v3dv/termsheet.rb | 166 +
lib/sisu/v3dv/texinfo.rb | 398 ++
lib/sisu/v3dv/texinfo_format.rb | 587 +++
lib/sisu/v3dv/texpdf.rb | 960 ++++
lib/sisu/v3dv/texpdf_format.rb | 1620 +++++++
lib/sisu/v3dv/update.rb | 130 +
lib/sisu/v3dv/urls.rb | 427 ++
lib/sisu/v3dv/webrick.rb | 174 +
lib/sisu/v3dv/wikispeak.rb | 373 ++
lib/sisu/v3dv/xhtml.rb | 431 ++
lib/sisu/v3dv/xhtml_table.rb | 99 +
lib/sisu/v3dv/xml.rb | 467 ++
lib/sisu/v3dv/xml_dom.rb | 542 +++
lib/sisu/v3dv/xml_fictionbook.rb | 300 ++
lib/sisu/v3dv/xml_format.rb | 1644 +++++++
lib/sisu/v3dv/xml_md_oai_pmh_dc.rb | 230 +
lib/sisu/v3dv/xml_scaffold.rb | 199 +
lib/sisu/v3dv/xml_tables.rb | 203 +
lib/sisu/v3dv/zap.rb | 83 +
121 files changed, 64752 insertions(+), 376 deletions(-)
delete mode 100644 lib/sisu/v3/modify.rb
create mode 100644 lib/sisu/v3dv/air.rb
create mode 100644 lib/sisu/v3dv/author_format.rb
create mode 100644 lib/sisu/v3dv/cgi.rb
create mode 100644 lib/sisu/v3dv/cgi_pgsql.rb
create mode 100644 lib/sisu/v3dv/cgi_sql_common.rb
create mode 100644 lib/sisu/v3dv/cgi_sqlite.rb
create mode 100644 lib/sisu/v3dv/character_encoding.rb
create mode 100644 lib/sisu/v3dv/composite.rb
create mode 100644 lib/sisu/v3dv/concordance.rb
create mode 100644 lib/sisu/v3dv/conf.rb
create mode 100644 lib/sisu/v3dv/constants.rb
create mode 100644 lib/sisu/v3dv/css.rb
create mode 100644 lib/sisu/v3dv/dal.rb
create mode 100644 lib/sisu/v3dv/dal_character_check.rb
create mode 100644 lib/sisu/v3dv/dal_doc_objects.rb
create mode 100644 lib/sisu/v3dv/dal_doc_str.rb
create mode 100644 lib/sisu/v3dv/dal_endnotes.rb
create mode 100644 lib/sisu/v3dv/dal_expand_insertions.rb
create mode 100644 lib/sisu/v3dv/dal_hash_digest.rb
create mode 100644 lib/sisu/v3dv/dal_idx.rb
create mode 100644 lib/sisu/v3dv/dal_images.rb
create mode 100644 lib/sisu/v3dv/dal_metadata.rb
create mode 100644 lib/sisu/v3dv/dal_numbering.rb
create mode 100644 lib/sisu/v3dv/dal_substitutions_and_insertions.rb
create mode 100644 lib/sisu/v3dv/dal_syntax.rb
create mode 100644 lib/sisu/v3dv/db_columns.rb
create mode 100644 lib/sisu/v3dv/db_create.rb
create mode 100644 lib/sisu/v3dv/db_dbi.rb
create mode 100644 lib/sisu/v3dv/db_drop.rb
create mode 100644 lib/sisu/v3dv/db_import.rb
create mode 100644 lib/sisu/v3dv/db_indexes.rb
create mode 100644 lib/sisu/v3dv/db_load_tuple.rb
create mode 100644 lib/sisu/v3dv/db_remove.rb
create mode 100644 lib/sisu/v3dv/db_select.rb
create mode 100644 lib/sisu/v3dv/db_sqltxt.rb
create mode 100644 lib/sisu/v3dv/db_tests.rb
create mode 100644 lib/sisu/v3dv/dbi.rb
create mode 100644 lib/sisu/v3dv/defaults.rb
create mode 100644 lib/sisu/v3dv/digests.rb
create mode 100644 lib/sisu/v3dv/embedded.rb
create mode 100644 lib/sisu/v3dv/epub.rb
create mode 100644 lib/sisu/v3dv/epub_concordance.rb
create mode 100644 lib/sisu/v3dv/epub_format.rb
create mode 100644 lib/sisu/v3dv/epub_segments.rb
create mode 100644 lib/sisu/v3dv/epub_tune.rb
create mode 100644 lib/sisu/v3dv/errors.rb
create mode 100644 lib/sisu/v3dv/git.rb
create mode 100644 lib/sisu/v3dv/harvest.rb
create mode 100644 lib/sisu/v3dv/harvest_authors.rb
create mode 100644 lib/sisu/v3dv/harvest_topics.rb
create mode 100644 lib/sisu/v3dv/help.rb
create mode 100644 lib/sisu/v3dv/html.rb
create mode 100644 lib/sisu/v3dv/html_format.rb
create mode 100644 lib/sisu/v3dv/html_minitoc.rb
create mode 100644 lib/sisu/v3dv/html_promo.rb
create mode 100644 lib/sisu/v3dv/html_scroll.rb
create mode 100644 lib/sisu/v3dv/html_segments.rb
create mode 100644 lib/sisu/v3dv/html_table.rb
create mode 100644 lib/sisu/v3dv/html_tune.rb
create mode 100644 lib/sisu/v3dv/hub.rb
create mode 100644 lib/sisu/v3dv/i18n.rb
create mode 100644 lib/sisu/v3dv/manifest.rb
create mode 100644 lib/sisu/v3dv/manpage.rb
create mode 100644 lib/sisu/v3dv/manpage_format.rb
create mode 100644 lib/sisu/v3dv/modify.rb
create mode 100644 lib/sisu/v3dv/odf.rb
create mode 100644 lib/sisu/v3dv/odf_format.rb
create mode 100644 lib/sisu/v3dv/options.rb
create mode 100644 lib/sisu/v3dv/param.rb
create mode 100644 lib/sisu/v3dv/param_identify_markup.rb
create mode 100644 lib/sisu/v3dv/particulars.rb
create mode 100644 lib/sisu/v3dv/plaintext.rb
create mode 100644 lib/sisu/v3dv/plaintext_format.rb
create mode 100644 lib/sisu/v3dv/po4a.rb
create mode 100644 lib/sisu/v3dv/po4a_set.rb
create mode 100644 lib/sisu/v3dv/prog_text_translation.rb
create mode 100644 lib/sisu/v3dv/qrcode.rb
create mode 100644 lib/sisu/v3dv/relaxng.rb
create mode 100644 lib/sisu/v3dv/remote.rb
create mode 100644 lib/sisu/v3dv/response.rb
create mode 100644 lib/sisu/v3dv/rexml.rb
create mode 100644 lib/sisu/v3dv/screen_text_color.rb
create mode 100644 lib/sisu/v3dv/share_src.rb
create mode 100644 lib/sisu/v3dv/share_src_kdissert.rb
create mode 100644 lib/sisu/v3dv/shared_html.rb
create mode 100644 lib/sisu/v3dv/shared_html_lite.rb
create mode 100644 lib/sisu/v3dv/shared_markup_alt.rb
create mode 100644 lib/sisu/v3dv/shared_metadata.rb
create mode 100644 lib/sisu/v3dv/shared_sem.rb
create mode 100644 lib/sisu/v3dv/shared_txt.rb
create mode 100644 lib/sisu/v3dv/shared_xhtml.rb
create mode 100644 lib/sisu/v3dv/shared_xml.rb
create mode 100644 lib/sisu/v3dv/sisupod_make.rb
create mode 100644 lib/sisu/v3dv/sitemaps.rb
create mode 100644 lib/sisu/v3dv/spell.rb
create mode 100644 lib/sisu/v3dv/sst_convert_markup.rb
create mode 100644 lib/sisu/v3dv/sst_do_inline_footnotes.rb
create mode 100644 lib/sisu/v3dv/sst_from_xml.rb
create mode 100644 lib/sisu/v3dv/sst_identify_markup.rb
create mode 100644 lib/sisu/v3dv/sst_to_s_xml_sax.rb
create mode 100644 lib/sisu/v3dv/sysenv.rb
create mode 100644 lib/sisu/v3dv/termsheet.rb
create mode 100644 lib/sisu/v3dv/texinfo.rb
create mode 100644 lib/sisu/v3dv/texinfo_format.rb
create mode 100644 lib/sisu/v3dv/texpdf.rb
create mode 100644 lib/sisu/v3dv/texpdf_format.rb
create mode 100644 lib/sisu/v3dv/update.rb
create mode 100644 lib/sisu/v3dv/urls.rb
create mode 100644 lib/sisu/v3dv/webrick.rb
create mode 100644 lib/sisu/v3dv/wikispeak.rb
create mode 100644 lib/sisu/v3dv/xhtml.rb
create mode 100644 lib/sisu/v3dv/xhtml_table.rb
create mode 100644 lib/sisu/v3dv/xml.rb
create mode 100644 lib/sisu/v3dv/xml_dom.rb
create mode 100644 lib/sisu/v3dv/xml_fictionbook.rb
create mode 100644 lib/sisu/v3dv/xml_format.rb
create mode 100644 lib/sisu/v3dv/xml_md_oai_pmh_dc.rb
create mode 100644 lib/sisu/v3dv/xml_scaffold.rb
create mode 100644 lib/sisu/v3dv/xml_tables.rb
create mode 100644 lib/sisu/v3dv/zap.rb
(limited to 'lib')
diff --git a/lib/sisu/v3/modify.rb b/lib/sisu/v3/modify.rb
deleted file mode 100644
index 7a1c0441..00000000
--- a/lib/sisu/v3/modify.rb
+++ /dev/null
@@ -1,376 +0,0 @@
-#!/usr/bin/env ruby
-# encoding: utf-8
-=begin
-
- * Name: modify.rb
-
- * Description: A conversion script for canned substitutions,
- a fairly generic simple tool that can be used to store other canned conversions,
- (used here for altering SiSU markup or the SiSU program)
-
- * Author: Ralph Amissah
-
- * Copyright: (C) 1997 - 2012, Ralph Amissah, All Rights Reserved.
-
- * License: GPL 3 or later:
-
- * Packaged with: SiSU a framework for document structuring, publishing & 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 .
-
- If you have Internet connection, the latest version of the GPL should be
- available at these locations:
-
-
-
-
-
-
-
- * Hompages:
-
-
-
- * Download:
-
-
- * Ralph Amissah
-
-
-
-=end
-module SiSU_Modify
- class Operations
- def initialize(cf,files)
- @cf,@files=cf,files
- @description="This is a script that contains canned text conversions for reuse"
- pwd=Dir.pwd
- @mod_inst='modify_instructions.rb'
- @modify_instructions_script="#{pwd}/#{@mod_inst}"
- if FileTest.file?(@modify_instructions_script) ==true
- puts <<-WOK
- autoload script: "#{@modify_instructions_script}"
- used by "ruby #{__FILE__} --convert" if
- "Extracted.new.modify.modules_and_classes" is used
- (see "matches_and_replaces")
- EDIT this file manually
- [to rebuild run: "ruby #{__FILE__} --build-gsub"]
-
- WOK
- else
- puts <<-WOK
- autoload script does not exist: "#{@modify_instructions_script}"
- needed for "ruby #{__FILE__} --convert" if
- "Extracted.new.modify.modules_and_classes" is used
- (see "matches_and_replaces")
- try run: "ruby #{__FILE__} --build-gsub"
-
- WOK
- end
- autoload :Extracted, "./#{@mod_inst}"
- end
- def matches_and_replaces #edit manually
- [
- #Extracted.new.modify.modules_and_classes,
- #Extracted.new.modify.modules,
- #Extracted.new.modify.classes,
- modify.dates,
- #modify.modules,
- #modify.classes,
- #modify.misc,
- ]
- end
- def message(text)
- response=''
- while response !~/yes/
- print %{
- #{text}
- To continue type "yes" [to exit type "no" or "quit"]: }
- response=File.new('/dev/tty').gets.strip
- exit if response =~/^(?:quit|no)$/
- end
- end
- def help
- print < 0
- @files.each do |i|
- @new,@matched,@empty1,@empty2=true,false,false,false
- file=File.open(i,'r')
- cont=file.readlines
- file.close
- @file=File.new(i,'w')
- cont.each do |t|
- matches_and_replaces.each do |match_and_replace|
- match_and_replace.each do |m,r|
- if t =~m
- p m.to_s + ' -> ' + r
- puts "in: #{t}"
- t.gsub!(m,r) if m and r
- puts "out: #{t}"
- end
- end
- end
- if t=~/^\s*$/; @empty1=true
- else @empty1=false
- end
- @file.puts t unless (@empty1==true and @empty2==true)
- if t=~/^\s*$/; @empty2=true
- else @empty2=false
- end
- end
- @file.close
- end
- end
- end
- def report_modules_and_classes
- @f=nil
- @structure={}
- @arr={mod: [], cl: []}
- @files.each do |f|
- @new,@matched,@empty1,@empty2=true,false,false,false
- file=File.open(f,'r')
- cont=file.readlines
- file.close
- cont.each do |t|
- if f != @f
- @f=f
- @mod=nil
- #puts "---\n#{@f}"
- @structure[@f]={}
- end
- if t =~/^\s*module\s+\S+/
- @mod=t.match(/^\s*module\s+(\S+)/)[1]
- #puts ' ' + @mod
- @arr[:mod] << @mod
- @structure[@f].store(@mod,[])
- #@structure[@f] = {@mod => []}
- end
- if t =~/^\s*class\s+\S+/
- cl=t.match(/^\s*class\s+(\S+)/)[1]
- #puts ' ' + cl
- @arr[:cl] << cl
- @structure[@f][@mod] << cl
- end
- end
- end
- @structure.sort.each do |fl,modules|
- puts "---\n" + fl
- modules.sort.each do |mod,classes|
- puts ' ' + mod
- classes.sort.each do |cl|
- puts ' ' + cl
- end
- end
- end
- puts '---'
- puts 'number of modules: ' + @arr[:mod].length.to_s + ', unique: ' + @arr[:mod].uniq.length.to_s
- puts 'number of classes: ' + @arr[:cl].length.to_s + ', unique: ' + @arr[:cl].uniq.length.to_s
- end
- def build_search_and_replace_method_for_modules_and_classes
- @f=nil
- @structure={}
- @arr={mod: [], cl: []}
- @files.each do |f|
- @new,@matched,@empty1,@empty2=true,false,false,false
- file=File.open(f,'r')
- cont=file.readlines
- file.close
- cont.each do |t|
- if f != @f
- @f=f
- @mod=nil
- #puts "---\n#{@f}"
- @structure[@f]={}
- end
- if t =~/^\s*module\s+\S+/
- @mod=t.match(/^\s*module\s+(\S+)/)[1]
- #puts ' ' + @mod
- @arr[:mod] << @mod
- @structure[@f].store(@mod,[])
- #@structure[@f] = {@mod => []}
- end
- if t =~/^\s*class\s+\S+/
- cl=t.match(/^\s*class\s+(\S+)/)[1]
- #puts ' ' + cl
- @arr[:cl] << cl
- @structure[@f][@mod] << cl
- end
- end
- end
- puts 'number of modules: ' + @arr[:mod].length.to_s + ', unique: ' + @arr[:mod].uniq.length.to_s
- puts 'number of classes: ' + @arr[:cl].length.to_s + ', unique: ' + @arr[:cl].uniq.length.to_s
- method_modules_and_classes=[]
- method_modules_and_classes <<<<-WOK
-#module SiSU_MC
- class Extracted
- def modify
- WOK
- #% modules_and_classes
- method_modules_and_classes <<<<-WOK
- def modules_and_classes
- [
- WOK
- @structure.sort.each do |fl,modules|
- method_modules_and_classes << ' '*8 + "##% -- " + fl
- modules.sort.each do |mod,classes|
- method_modules_and_classes << ' '*8 + '# ' + "[/#{mod}/," + ' '*(67 - mod.length) + "'#{mod}'],"
- classes.uniq.sort.each do |cl|
- method_modules_and_classes << ' '*8 + '# ' + "[/#{cl}/," + ' '*(65 - cl.length) + "'#{cl}'],"
- end
- end
- end
- method_modules_and_classes <<<<-WOK
- ]
- end
- WOK
- #% modules
- method_modules_and_classes <<<<-WOK
- def modules
- [
- WOK
- method_modules_and_classes << ' '*8 + '# ' + 'number of modules: ' + @arr[:mod].length.to_s +
- ', unique: ' + @arr[:mod].uniq.length.to_s
- @arr[:mod].uniq.sort.each do |mod|
- method_modules_and_classes << ' '*8 + '# ' + "[/#{mod}/," + ' '*(67 - mod.length) + "'#{mod}'],"
- end
- method_modules_and_classes <<<<-WOK
- ]
- end
- WOK
- #% classes
- method_modules_and_classes <<<<-WOK
- def classes
- [
- WOK
- method_modules_and_classes << ' '*8 + '# ' + 'number of classes: ' + @arr[:cl].length.to_s +
- ', unique: ' + @arr[:cl].uniq.length.to_s
- @arr[:cl].uniq.sort.each do |cl|
- method_modules_and_classes << ' '*8 + '# ' + "[/#{cl}/," + ' '*(67 - cl.length) + "'#{cl}'],"
- end
- method_modules_and_classes <<<<-WOK
- ]
- end
- WOK
- method_modules_and_classes <<<<-WOK
- self
- end
- end
-#end
- WOK
- #method_modules_and_classes.each{|x| puts x}
- if FileTest.file?(@modify_instructions_script) ==true
- message("WARNING << #{@mod_inst} >> exists (and may have been edited). The existing << #{@mod_inst} >> will be overwritten if you proceed.")
- end
- instructs=File.new(@modify_instructions_script,'w')
- method_modules_and_classes.each do |x|
- puts x
- instructs.puts x
- end
- instructs.close
- end
- def action
- if @files and @files.length > 0
- p @files
- mr=nil
- #%% changes to make m match, r replace -------------------------->
- if @cf =~/--help/; help
- else
- case @cf
- when /--convert/; convert
- when /--report/; report_modules_and_classes
- when /--build-gsub/; build_search_and_replace_method_for_modules_and_classes
- else help
- end
- #act
- end
- else puts "this routine makes permanent changes to the contents of the files matched, as instructed within [no matches]"
- end
- end
- end
-end
-#% files to match for this conversion set ------------------------->
-f=$* #; p $*
-cf=f[0].to_s
-f.shift
-match_and_replace=Array.new
-unless f.length > 0
- f=if cf == '--report' \
- or cf == '--build-gsub'
- Dir.glob("[a-zA-Z]*.rb") #restrict to ruby files
- else
- Dir.glob("[a-zA-Z]*")
- end
- f=f.sort.delete_if { |x| x == __FILE__ or x == 'modify_instructions.rb' }
-end
-SiSU_Modify::Operations.new(cf,f).action
-__END__
-#f=Dir.glob("{bin,conf,data,lib}/**/*.rb") #sisu development
-#f=Dir.glob("[^_]/**/*") #all files subdirectories beneath pwd except those starting with _
diff --git a/lib/sisu/v3dv/air.rb b/lib/sisu/v3dv/air.rb
new file mode 100644
index 00000000..f5bf3286
--- /dev/null
+++ b/lib/sisu/v3dv/air.rb
@@ -0,0 +1,82 @@
+# encoding: utf-8
+=begin
+
+ * Name: SiSU
+
+ * Description: a framework for document structuring, publishing and search
+
+ * Author: Ralph Amissah
+
+ * Copyright: (C) 1997 - 2012, 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 .
+
+ If you have Internet connection, the latest version of the GPL should be
+ available at these locations:
+
+
+
+
+
+
+
+ * SiSU uses:
+ * Standard SiSU markup syntax,
+ * Standard SiSU meta-markup syntax, and the
+ * Standard SiSU object citation numbering and system
+
+ * Hompages:
+
+
+
+ * Download:
+
+
+ * Ralph Amissah
+
+
+
+ ** Description: system environment, resource control and configuration details
+
+=end
+module SiSU_Air
+ require_relative 'particulars' # particulars.rb
+ class Source
+ @@dal_array=[]
+ @@fns=nil
+ def initialize(opt)
+ @opt=opt
+ @@fns||@opt.fns
+ @particulars=SiSU_Particulars::Combined.new(opt)
+ #@env=@particulars.env
+ #@md=@particulars.md
+ #@dal_array=@particulars.dal_array
+ end
+ def read
+ end
+ protected
+ def print
+ puts @particulars.md.inspect
+ puts @particulars.env.inspect
+ puts @particulars.dal_array
+ end
+ end
+end
+__END__
diff --git a/lib/sisu/v3dv/author_format.rb b/lib/sisu/v3dv/author_format.rb
new file mode 100644
index 00000000..481674d0
--- /dev/null
+++ b/lib/sisu/v3dv/author_format.rb
@@ -0,0 +1,113 @@
+# encoding: utf-8
+=begin
+
+ * Name: SiSU
+
+ * Description: a framework for document structuring, publishing and search
+
+ * Author: Ralph Amissah
+
+ * Copyright: (C) 1997 - 2012, 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 .
+
+ If you have Internet connection, the latest version of the GPL should be
+ available at these locations:
+
+
+
+
+
+
+
+ * SiSU uses:
+ * Standard SiSU markup syntax,
+ * Standard SiSU meta-markup syntax, and the
+ * Standard SiSU object citation numbering and system
+
+ * Hompages:
+
+
+
+ * Download:
+
+
+ * Ralph Amissah
+
+
+
+ ** Description: system environment, resource control and configuration details
+
+=end
+module FORMAT
+ class Author
+ def initialize(author_param)
+ @author_param=author_param
+ end
+ def author_details
+ @authors,@author_array=[],[]
+ authors=@author_param.scan(/[^;]+/)
+ authors.each do |a|
+ a.strip!
+ if a =~/"(.+?)"/
+ @authors << { the: $1 }
+ @author_array << $1.upcase
+ else #if a =~/,/
+ x=a.scan(/[^,]+/)
+ x[0].strip!
+ x[1].strip! if x[1]
+ if x.length==1
+ @authors << { the: x[0] }
+ @author_array << x[0].upcase
+ elsif x.length==2
+ @authors << { the: x[0], others: x[1] }
+ @author_array << "#{x[0].upcase}, #{x[1]}"
+ else #p x.length
+ end
+ end
+ end
+ l = @authors.length
+ authors_string=''
+ @authors.each_with_index do |a,i|
+ authors_string += if a[:others]
+ if (l - i) > 1
+ "#{a[:others]} #{a[:the]}, "
+ else
+ "#{a[:others]} #{a[:the]}"
+ end
+ else
+ if (l - i) > 2
+ "#{a[:the]}, "
+ else
+ "#{a[:the]}"
+ end
+ end
+ end
+ {
+ last_first_a: authors,
+ last_first_format_a: @author_array,
+ authors_h: @authors,
+ authors_s: authors_string,
+ authors_param: @author_param
+ }
+ end
+ end
+end
+__END__
diff --git a/lib/sisu/v3dv/cgi.rb b/lib/sisu/v3dv/cgi.rb
new file mode 100644
index 00000000..779ee35a
--- /dev/null
+++ b/lib/sisu/v3dv/cgi.rb
@@ -0,0 +1,83 @@
+# encoding: utf-8
+=begin
+
+ * Name: SiSU
+
+ * Description: a framework for document structuring, publishing and search
+
+ * Author: Ralph Amissah
+
+ * Copyright: (C) 1997 - 2012, 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 .
+
+ If you have Internet connection, the latest version of the GPL should be
+ available at these locations:
+
+
+
+
+
+
+
+ * SiSU uses:
+ * Standard SiSU markup syntax,
+ * Standard SiSU meta-markup syntax, and the
+ * Standard SiSU object citation numbering and system
+
+ * Hompages:
+
+
+
+ * Download:
+
+
+ * Ralph Amissah
+
+
+
+ ** Description: generates naive cgi search form for search of sisu database
+ (pgsql sqlite)
+
+=end
+module SiSU_CGI #% database building documents
+ require_relative 'sysenv' # sysenv.rb
+ require_relative 'cgi_pgsql' # cgi_pgsql.rb
+ require_relative 'cgi_sqlite' # cgi_sqlite.rb
+ class SiSU_search
+ def initialize(opt)
+ @opt=opt
+ @webserv=@opt.files[0].to_s.strip
+ end
+ def search_info
+ a=%{
+ For help on sisu search, type:
+ sisu --help search
+ }
+ SiSU_Screen::Ansi.new(@opt.cmd,a).print_grey
+ end
+ def read
+ SiSU_CGI_sqlite::SiSU_search_sqlite.new(@opt,@webserv).sqlite
+ SiSU_CGI_pgsql::SiSU_search_pgsql.new(@opt,@webserv).pgsql
+ search_info unless @opt.cmd =~/q/
+ end
+ end
+end
+__END__
diff --git a/lib/sisu/v3dv/cgi_pgsql.rb b/lib/sisu/v3dv/cgi_pgsql.rb
new file mode 100644
index 00000000..6fb35714
--- /dev/null
+++ b/lib/sisu/v3dv/cgi_pgsql.rb
@@ -0,0 +1,230 @@
+# encoding: utf-8
+=begin
+
+ * Name: SiSU
+
+ * Description: a framework for document structuring, publishing and search
+
+ * Author: Ralph Amissah
+
+ * Copyright: (C) 1997 - 2012, 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 .
+
+ If you have Internet connection, the latest version of the GPL should be
+ available at these locations:
+
+
+
+
+
+
+
+ * SiSU uses:
+ * Standard SiSU markup syntax,
+ * Standard SiSU meta-markup syntax, and the
+ * Standard SiSU object citation numbering and system
+
+ * Hompages:
+
+
+
+ * Download:
+
+
+ * Ralph Amissah
+
+
+
+ ** Description: generates naive cgi search form for search of sisu database (pgsql sqlite)
+
+=end
+module SiSU_CGI_pgsql #% database building documents
+ require_relative 'sysenv' # sysenv.rb
+ require_relative 'cgi_sql_common' # cgi_sql_common.rb
+ include SiSU_CGI_sql
+ class SiSU_search_pgsql < SiSU_CGI_common
+ def initialize(opt,webserv)
+ @opt,@webserv=opt,webserv
+ @env=SiSU_Env::Info_env.new('',opt)
+ @sys=SiSU_Env::System_call.new
+ @image_src="#{@env.url.webserv_cgi}/_sisu/image_sys"
+ @common=SiSU_CGI_sql::SiSU_CGI_common.new(@webserv,@opt,@image_src,@env)
+ @db=SiSU_Env::Info_db.new
+ @cgi_file_name="#{Db[:name_prefix_db]}by_#{opt.dir_structure_by}_pgsql.cgi"
+ end
+ def pgsql
+ serve=[]
+ if @sys.psql
+ available_db_table=`psql --list` # system call requires psql
+ available_db=available_db_table.scan(/(#{Db[:name_prefix]}\S+)/) if not available_db_table.nil?
+ if available_db \
+ and available_db.class==Array
+ available_db.flatten.each do |x|
+ serve << x.gsub(/#{Db[:name_prefix]}(\S+)/,'\1')
+ end
+ else put "WARNING: no postgresql database available, (have you created one?)"
+ end
+ serve.sort!
+ f1,f2,f3='','',''
+ serve.each do |x|
+ f1 << %{ \n} unless x =~/apache|sisu\/image/ #check
+ end
+ f2 << %{ selected_db=case cgi['db']\n}
+ serve.each do |x|
+ f2 << %{ when /#{Db[:name_prefix]}#{x}/; ''\n} unless x =~/apache|sisu\/image/ #check
+ end
+ end
+ f2 << " end\n"
+ if FileTest.writable?('.')
+ output=File.open(@cgi_file_name,'w')
+ output << header0 << header1 << header_desc << header2 << f1 << buttons1 << buttons1_pgsql << buttons2 << search_request << search_statement << search_statement_common << search_query1 << @common.pages << search_query2 << @common.tail << @common.main1 << f2 << dbi_connect << @common.main2 << @common.dir_structure << @common.main3
+ a=%{ generated sisu_pgsql.cgi,
+ BASED ON ALREADY EXISTING directories that could potentially be used to populate postgresql db, (-D)
+ }
+ SiSU_Screen::Ansi.new(@opt.cmd,a).print_grey
+ c=case @webserv
+ when /pwd/; ''
+ else "if necessary make the directory /usr/lib/cgi-bin :
+ sudo cp -vi #{Dir.pwd}/#{@cgi_file_name} /usr/lib/cgi-bin/.
+ sudo chmod -v 755 /usr/lib/cgi-bin/#{@cgi_file_name}
+ sudo ln -s /usr/lib/cgi-bin/#{@cgi_file_name} /usr/lib/cgi-bin/sisu_pgsql.cgi
+ (copy #{@cgi_file_name} to your cgi directory) set file permissions to 755, and make symbolic link to sisu_pgsql.cgi"
+ end
+ a=%{#{c}
+ #{@env.webserv_base_cgi}/cgi-bin/sisu_pgsql.cgi
+ }
+ SiSU_Screen::Ansi.new(@opt.cmd,a).warn
+ a="postgresql db used for present directory: #{@db.psql.db}"
+ b="\n\t(to create and populate postgresql database see 'man sisu' and in particular the -D flag)\n\t[the database to be used for this directory (#{@db.psql.db}) will have to be created manually if it does not exist,\n\tsee 'sisu --help sql'\n\tif you have permission to create databases:\n\t'sisu -d --createdb'\n\tor using postgresql tools directly:\n\t'createdb #{@db.psql.db}'\n\tfor a list of existing databases try 'psql --list']"
+ SiSU_Screen::Ansi.new(@opt.cmd,a,b).txt_cyan
+ else puts 'failed in attempt to write #{@cgi_file_name} to present directory, is directory writable?'
+ end
+ end
+ def header0
+ <<-WOK_SQL
+#!/usr/bin/env ruby
+=begin
+#{about}
+ * Description: generates naive cgi search form for search of sisu database (pgsql)
+#{gpl}
+=end
+ require 'cgi'
+ require 'fcgi'
+ require 'dbi'
+ @version='sisu_pgsql'
+ @image_src="#{@env.url.webserv_cgi}/_sisu/image_sys"
+ @hosturl_db="#{@env.url.webserv_base_cgi}"
+ @hosturl_files="#{@env.url.webserv_files_from_db}"
+ @port="#{@db.psql.port}"
+ @db_name_prefix="#{Db[:name_prefix]}"
+ user='#{@env.user}' # check user name for access to pg database: '#{@env.user}'
+ WOK_SQL
+ end
+ def search_statement
+ <<-'WOK_SQL'
+ class Dbi_search_string
+ def initialize(l,t,q,cse=false)
+ @l,@t,@q,@c=l,t,q,cse
+ end
+ def string
+ search={ :search => [], :flag => false }
+ if @t =~/\S+/ or @q =~/\S+/
+ if @t =~/\S+/; unescaped_search=CGI.unescape(@t)
+ elsif @q =~/\S+/; unescaped_search=CGI.unescape(@q)
+ end
+ search_construct=[]
+ if @c
+ unescaped_search.gsub!(/\s*(AND|OR)\s*/,"' \) \\1 #{@l}~\( '")
+ unescaped_search.gsub!(/(.+)/,"#{@l}~\( '\\1' \)")
+ else
+ unescaped_search.gsub!(/\s*(AND|OR)\s*/,"' \) \\1 #{@l}~*\( '")
+ unescaped_search.gsub!(/(.+)/,"#{@l}~*\( '\\1' \)")
+ end
+ search_construct << unescaped_search
+ search_construct=search_construct.join(' ')
+ search[:search] << search_construct
+ search[:flag]=true
+ search
+ end
+ search
+ end
+ end
+ WOK_SQL
+ end
+ def search_query1
+ <<-'WOK_SQL'
+ @search_text,@search_endnotes='',''
+ search[:text].flatten.each {|x| @search_text << "#{x} AND " }
+ @search_text=@search_text.gsub!(/AND\s+$/m,'') #watch
+ @search_text.gsub!(/(doc_objects\.clean~[*]?\(\s*'[^']+'\s*\)\s+(?:(?:AND|OR)\s+doc_objects\.clean~[*]?\(\s*'[^']+'\s*\))+)/,'(\1)')
+ search[:endnotes].flatten.each {|x| @search_endnotes << "#{x} AND " }
+ @search_endnotes=@search_endnotes.gsub!(/AND\s+$/m,'') #watch
+ @search_endnotes.gsub!(/(endnotes\.clean~\(\s*'[^']+'\s*\)\s+(?:(?:AND|OR)\s+endnotes\.clean~\(\s*'[^']+'\s*\))+)/,'(\1)')
+ end
+ WOK_SQL
+ end
+ def search_query2
+ <<-'WOK_SQL'
+ 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, metadata_and_text.language_document_char, metadata_and_text.notes_suffix, doc_objects.body, doc_objects.seg, doc_objects.ocn, metadata_and_text.tid FROM doc_objects, metadata_and_text WHERE (#{@search_text}) AND doc_objects.metadata_tid = metadata_and_text.tid ORDER BY metadata_and_text.language_document_char, metadata_and_text.title, metadata_and_text.src_filename, doc_objects.ocn}
+ @sql_statement[:range]=%{LIMIT #{limit} OFFSET #{offset} ;}
+ select=@sql_statement[:body] + ' ' + @sql_statement[:range]
+ select
+ end
+ def sql_select_endnotes
+ limit ||=@@limit
+ offset ||=@@offset
+ @sql_statement[:endnotes]=%{SELECT metadata_and_text.title, metadata_and_text.creator_author, metadata_and_text.src_filename, metadata_and_text.language_document_char, endnotes.body, endnotes.nr, endnotes.ocn, endnotes.metadata_tid FROM metadata_and_text, endnotes WHERE (#{@search_endnotes}) AND metadata_and_text.tid = endnotes.metadata_tid ORDER BY metadata_and_text.language_document_char, metadata_and_text.title, metadata_and_text.src_filename, endnotes.nr}
+ @sql_statement[:range]=%{LIMIT #{limit} OFFSET #{offset} ;}
+ select=@sql_statement[:endnotes] + ' ' + @sql_statement[:range]
+ select
+ end
+ def sql_select_body_format
+ %{#{sql_select_body}}
+ end
+ def sql_select_endnotes_format
+ %{#{sql_select_endnotes}}
+ end
+ def contents
+ @conn.select_all(sql_select_body)
+ end
+ def endnotes
+ @conn.select_all(sql_select_endnotes)
+ end
+ end
+ WOK_SQL
+ end
+ def buttons1_pgsql
+ <<-'WOK_SQL'
+ case sensitive
+ WOK_SQL
+ end
+ def dbi_connect
+ <<-'WOK_SQL'
+ dbi="dbi:Pg:database=#{@db};port=#{@port}"
+ @conn=DBI.connect(dbi,user)
+ WOK_SQL
+ end
+ end
+end
+__END__
diff --git a/lib/sisu/v3dv/cgi_sql_common.rb b/lib/sisu/v3dv/cgi_sql_common.rb
new file mode 100644
index 00000000..9f4dd457
--- /dev/null
+++ b/lib/sisu/v3dv/cgi_sql_common.rb
@@ -0,0 +1,1075 @@
+# encoding: utf-8
+=begin
+
+ * Name: SiSU
+
+ * Description: a framework for document structuring, publishing and search
+
+ * Author: Ralph Amissah
+
+ * Copyright: (C) 1997 - 2012, 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 .
+
+ If you have Internet connection, the latest version of the GPL should be
+ available at these locations:
+
+
+
+
+
+
+
+ * SiSU uses:
+ * Standard SiSU markup syntax,
+ * Standard SiSU meta-markup syntax, and the
+ * Standard SiSU object citation numbering and system
+
+ * Hompages:
+
+
+
+ * Download:
+
+
+ * Ralph Amissah
+
+
+
+ ** Description: generates naive cgi search form for search of sisu database (pgsql sqlite)
+
+=end
+module SiSU_CGI_sql
+ class SiSU_CGI_common
+ def initialize(webserv,opt,image_src,dir)
+ @webserv,@opt,@image_src,@env=webserv,opt,image_src,dir
+ @cmd=opt.cmd
+ end
+ def about
+ <<-'WOK_SQL'
+ * Name: SiSU information Structuring Universe
+ * Author: Ralph Amissah
+ * http://www.jus.uio.no/sisu
+ * http://www.jus.uio.no/sisu/SiSU/download
+ WOK_SQL
+ end
+ def gpl
+ <<-'WOK_SQL'
+ * 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 - 2012, 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 .
+
+ If you have Internet connection, the latest version of the GPL should be
+ available at these locations:
+
+
+
+
+ * SiSU uses:
+ * Standard SiSU markup syntax,
+ * Standard SiSU meta-markup syntax, and the
+ * Standard SiSU object citation numbering and system
+
+ * Hompages:
+
+
+
+ * Download:
+
+
+ * Ralph Amissah
+
+
+ WOK_SQL
+ end
+ def header1
+ <<-'WOK_SQL'
+#Common TOP
+ @@offset=0
+ @base="#{@hosturl_db}/cgi-bin/#{@version}.cgi"
+ @@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/
+ 'text:__; fulltxt:__; keywords:__; title:__; author:__; topic_register:__; subject:__; description:__; publisher:__; editor:__; contributor:__; date:__; type:__; format:__; identifier:__; source:__; language:__; relation:__; coverage:__; rights:__; comment:__; abstract:__; filename:__; '
+ else ''
+ end
+ end
+ def submission_form
+ search_form=<<-WOK
+ WOK_SQL
+ end
+ def header_desc
+ <<-WOK_SQL
+
+
+
+
+ SiSU search form (sample): SiSU information Structuring Universe
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ WOK_SQL
+ end
+ def header2
+ <<-'WOK_SQL'
+
+ WOK
+ end
+ end
+ WOK_SQL
+ end
+ def search_request
+ <<-'WOK_SQL'
+ class Search_request #% 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,:filename
+ 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('filename:')
+ @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/; q['doc']
+ elsif q['fns']=~/\S/; 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]; m[:braces].match(@search_field)[1]
+ elsif @search_field =~m[:string]; m[:string].match(@search_field)[1]
+ else
+ str=m[:word].match(@search_field)[1]
+ str.gsub!(/[()]/,'')
+ str
+ end
+ search_string.strip!
+ search_string.gsub!(/\s+/,'+')
+ search_string
+ #else
+ # "__"
+ end
+ end
+ end
+ WOK_SQL
+ end
+ def search_statement_common
+ <<-'WOK_SQL'
+ class Dbi_search_statement
+ attr_reader :text_search_flag,:sql_select_body_format,:sql_select_endnotes_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_search_string.new('doc_objects.clean',search_for.text1,q['s1'],cse).string
+ se=Dbi_search_string.new('endnotes.clean',search_for.text1,q['s1'],cse).string
+ @text_search_flag=st[:flag]
+ if st[:flag]
+ search[:text] << st[:search]
+ search[:endnotes] << se[:search]
+ end
+ st=Dbi_search_string.new('metadata_and_text.fulltext',search_for.fulltext,q['ft'],cse).string
+ if st[:flag]
+ search[:text] << st[:search]
+ search[:endnotes] << st[:search]
+ end
+ st=Dbi_search_string.new('metadata_and_text.classify_keywords',search_for.keywords,q['key'],cse).string
+ if st[:flag]
+ search[:text] << st[:search]
+ search[:endnotes] << st[:search]
+ end
+ st=Dbi_search_string.new('metadata_and_text.title',search_for.title,q['ti'],cse).string
+ if st[:flag]
+ search[:text] << st[:search]
+ search[:endnotes] << st[:search]
+ end
+ st=Dbi_search_string.new('metadata_and_text.creator_author',search_for.author,q['au'],cse).string
+ if st[:flag]
+ search[:text] << st[:search]
+ search[:endnotes] << st[:search]
+ end
+ st=Dbi_search_string.new('metadata_and_text.classify_topic_register',search_for.topic_register,q['tr'],cse).string
+ if st[:flag]
+ search[:text] << st[:search]
+ search[:endnotes] << st[:search]
+ end
+ st=Dbi_search_string.new('metadata_and_text.classify_subject',search_for.subject,q['sj'],cse).string
+ if st[:flag]
+ search[:text] << st[:search]
+ search[:endnotes] << st[:search]
+ end
+ st=Dbi_search_string.new('metadata_and_text.notes_description',search_for.description,q['dsc'],cse).string
+ if st[:flag]
+ search[:text] << st[:search]
+ search[:endnotes] << st[:search]
+ end
+ st=Dbi_search_string.new('metadata_and_text.publisher',search_for.publisher,q['pb'],cse).string
+ if st[:flag]
+ search[:text] << st[:search]
+ search[:endnotes] << st[:search]
+ end
+ st=Dbi_search_string.new('metadata_and_text.creator_editor',search_for.editor,q['cntr'],cse).string
+ if st[:flag]
+ search[:text] << st[:search]
+ search[:endnotes] << st[:search]
+ end
+ st=Dbi_search_string.new('metadata_and_text.creator_contributor',search_for.contributor,q['cntr'],cse).string
+ if st[:flag]
+ search[:text] << st[:search]
+ search[:endnotes] << st[:search]
+ end
+ st=Dbi_search_string.new('metadata_and_text.date_published',search_for.date,q['dt'],cse).string
+ if st[:flag]
+ search[:text] << st[:search]
+ search[:endnotes] << st[:search]
+ end
+ st=Dbi_search_string.new('metadata_and_text.classify_type',search_for.type,q['ty'],cse).string
+ if st[:flag]
+ search[:text] << st[:search]
+ search[:endnotes] << st[:search]
+ end
+ st=Dbi_search_string.new('metadata_and_text.classify_identifier',search_for.identifier,q['id'],cse).string
+ if st[:flag]
+ search[:text] << st[:search]
+ search[:endnotes] << st[:search]
+ end
+ st=Dbi_search_string.new('metadata_and_text.original_source',search_for.source,q['src'],cse).string
+ if st[:flag]
+ search[:text] << st[:search]
+ search[:endnotes] << st[:search]
+ end
+ st=Dbi_search_string.new('metadata_and_text.language_document_char',search_for.language,q['lang'],cse).string
+ if st[:flag]
+ search[:text] << st[:search]
+ search[:endnotes] << st[:search]
+ end
+ st=Dbi_search_string.new('metadata_and_text.classify_relation',search_for.relation,q['rel'],cse).string
+ if st[:flag]
+ search[:text] << st[:search]
+ search[:endnotes] << st[:search]
+ end
+ st=Dbi_search_string.new('metadata_and_text.classify_coverage',search_for.coverage,q['cov'],cse).string
+ if st[:flag]
+ search[:text] << st[:search]
+ search[:endnotes] << st[:search]
+ end
+ st=Dbi_search_string.new('metadata_and_text.rights_all',search_for.rights,q['cr'],cse).string
+ if st[:flag]
+ search[:text] << st[:search]
+ search[:endnotes] << st[:search]
+ end
+ st=Dbi_search_string.new('metadata_and_text.notes_comment',search_for.comment,q['co'],cse).string
+ if st[:flag]
+ search[:text] << st[:search]
+ search[:endnotes] << st[:search]
+ end
+ st=Dbi_search_string.new('metadata_and_text.notes_abstract',search_for.abstract,q['ab'],cse).string
+ if st[:flag]
+ search[:text] << st[:search]
+ search[:endnotes] << st[:search]
+ end
+ st=Dbi_search_string.new('metadata_and_text.src_filename',search_for.filename,q['fns'],cse).string
+ if st[:flag]
+ search[:text] << st[:search]
+ search[:endnotes] << st[:search]
+ end
+ @@limit=q['ltd'] if q['ltd']=~/\d+/ # 1000
+ @@offset=q['off'] if q['off']=~/\d+/ # 0
+ WOK_SQL
+ end
+ def pages
+ <<-'WOK_SQL'
+ def sql_offset
+ @@offset
+ end
+ def sql_match_limit
+ @@limit
+ end
+ def sql_canned_search
+ @offset_next=sql_offset.to_i + sql_match_limit.to_i
+ @offset_previous=sql_offset.to_i - sql_match_limit.to_i
+ def current
+ @@canned_search_url.to_s + '<d=' + sql_match_limit.to_s + '&off=' + sql_offset.to_s
+ end
+ def next
+ @@canned_search_url.to_s + '<d=' + sql_match_limit.to_s + '&off=' + @offset_next.to_s
+ end
+ def previous
+ @offset_previous >= 0 \
+ ? (@@canned_search_url.to_s + '<d=' + sql_match_limit.to_s + '&off=' + @offset_previous.to_s)
+ : ''
+ end
+ def start
+ @@canned_search_url.to_s + '<d=' + sql_match_limit.to_s + '&off=' + 0.to_s
+ end
+ self
+ 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$/
+ %{
+ #{v[:project]}, developed using
+
+ Ruby
+
+ on
+
+ Debian/Gnu/Linux
+
+ software infrastructure,
+ with the usual GPL (or OSS) suspects.
+
+ Better - "performance, reliability, scalability, security & total cost of ownership"
+ [not to mention flexibility & choice] use of and adherence to open standards (where practical and fair) and it is software libré.
+
+ Get With the Future
+
+ Way Better!
+
+
+
+
+
+
+ WOK
+ end
+ WOK_SQL
+ end
+ def main1
+ <<-'WOK_SQL'
+ @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,@sql_select_endnotes='','','',''
+ FCGI.each_cgi do |cgi|
+ begin # all code goes in begin section
+ @search={ :text => [], :endnotes => [] }
+ q=CGI.new
+ @db=if cgi['db'] =~/\S+/;
+ @stub=/#{@db_name_prefix}(\S+)/.match(cgi['db'])[1]
+ cgi['db']
+ else
+ @stub='sisu'
+ "#{@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
+ WOK_SQL
+ end
+ def main2
+ <<-'WOK_SQL'
+ search_field=cgi['find'] if cgi['find'] # =~/\S+/
+ @search_for=Search_request.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.filename) if @search_for.filename=~/\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
+ @search[:endnotes][1]=%{endnotes.clean~'#{@search_for.text1}'} #s1
+ else
+ @search[:text][1]=%{doc_objects.clean~*'#{@search_for.text1}'} #s1
+ @search[:endnotes][1]=%{endnotes.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.gsub!(/s1=/,'text: ')
+ af.gsub!(/ft=/,'fulltxt: ')
+ af.gsub!(/au=/,'author: ')
+ af.gsub!(/ti=/,'title: ')
+ af.gsub!(/fns=/,'filename: ')
+ af.gsub!(/tr=/,'topic_register: ')
+ af.gsub!(/%2B/,' ')
+ analyze_format=af
+ st=af.split(/\s*;\s*/)
+ search_field=st.join("\n")
+ end
+ green=%{}
+ canned_search_url_txt=CGI.escapeHTML(@@canned_search_url)
+ the_can=%{#{canned_note} #{canned_search_url_txt} }
+ p_text=p_fulltext=p_keywords=p_title=p_author=p_topic_register=p_subject=p_description=p_publisher=p_editor=p_contributor=p_date=p_type=p_format=p_identifier=p_source=p_language=p_relation=p_coverage=p_rights=p_comment=p_abstract=p_filename=''
+ p_filename=%{filename: #{green}#{@search_for.filename} } if @search_for.filename =~/\S+/
+ p_text=%{text: #{green}#{@search_for.text1} } if @search_for.text1 =~/\S+/
+ p_fulltext=%{fulltxt: #{green}#{@search_for.fulltext} } if @search_for.fulltext =~/\S+/
+ p_title=%{title: #{green}#{@search_for.title} } if @search_for.title =~/\S+/
+ p_author=%{author: #{green}#{@search_for.author} } if @search_for.author =~/\S+/
+ p_editor=%{editor: #{green}#{@search_for.editor} } if @search_for.editor=~/\S+/
+ p_contributor=%{contributor: #{green}#{@search_for.contributor} } if @search_for.contributor =~/\S+/
+ p_date=%{date: #{green}#{@search_for.date} } if @search_for.date =~/\S+/
+ p_rights=%{rights: #{green}#{@search_for.rights} } if @search_for.rights =~/\S+/
+ p_topic_register=%{topic_register: #{green}#{@search_for.topic_register} } if @search_for.topic_register =~/\S+/
+ p_subject=%{subject: #{green}#{@search_for.subject} } if @search_for.subject =~/\S+/
+ p_keywords=%{keywords: #{green}#{@search_for.keywords} } if @search_for.keywords =~/\S+/
+ p_identifier=%{identifier: #{green}#{@search_for.identifier} } if @search_for.identifier =~/\S+/
+ p_type=%{type: #{green}#{@search_for.type} } if @search_for.type =~/\S+/
+ p_format=%{format: #{green}#{@search_for.format} } if @search_for.format =~/\S+/
+ p_relation=%{relation: #{green}#{@search_for.relation} } if @search_for.relation =~/\S+/
+ p_coverage=%{coverage: #{green}#{@search_for.coverage} } if @search_for.coverage =~/\S+/
+ p_description=%{description: #{green}#{@search_for.description} } if @search_for.description =~/\S+/
+ p_abstract=%{abstract: #{green}#{@search_for.abstract} } if @search_for.abstract =~/\S+/
+ p_comment=%{comment: #{green}#{@search_for.comment} } if @search_for.comment =~/\S+/
+ p_publisher=%{publisher: #{green}#{@search_for.publisher} } if @search_for.publisher =~/\S+/
+ p_source=%{source: #{green}#{@search_for.source} } if @search_for.source =~/\S+/
+ p_language=%{language: #{green}#{@search_for.language} } if @search_for.language =~/\S+/
+ search_note=<<-WOK
+
+ database: #{green}#{@db}; selected view: #{green}#{cgi['view']}
+ search string: "#{green}#{analyze_format}"
+ #{p_text} #{p_fulltext} #{p_keywords} #{p_title} #{p_author} #{p_topic_register} #{p_subject} #{p_description} #{p_publisher} #{p_editor} #{p_contributor} #{p_date} #{p_type} #{p_format} #{p_identifier} #{p_source} #{p_language} #{p_relation} #{p_coverage} #{p_rights} #{p_comment} #{p_abstract} #{p_filename}
+
+ WOK
+ #eg = %{canned search e.g.: #{url} find: #{analyze} database: #{database}}
+ #% dbi_canning
+ @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)}'}
+ @search[:endnotes]<<%{endnotes.clean~'#{CGI.unescape(s1)}'}
+ else
+ @search[:text]<<%{doc_objects.clean~*'#{CGI.unescape(s1)}'}
+ @search[:endnotes]<<%{endnotes.clean~*'#{CGI.unescape(s1)}'}
+ end
+ #% dbi_request
+ dbi_statement=Dbi_search_statement.new(@conn,@search_for,q,checked_case)
+ @text_search_flag=false
+ @text_search_flag=dbi_statement.text_search_flag
+ s_contents=dbi_statement.contents
+ s_endnotes=dbi_statement.endnotes
+ @body_main,@endnotes='',''
+ @search_regx=nil
+ oldtid=0
+ if @text_search_flag
+ if checked_sql =~/\S/
+ sql_select_body=dbi_statement.sql_select_body_format
+ sql_select_endnotes=dbi_statement.sql_select_endnotes_format
+ else sql_select_body,sql_select_endnotes='',''
+ end
+ @body_main << ' Main Text: ' << sql_select_body
+ @endnotes << ' Endnotes: ' << sql_select_endnotes
+ else
+ end
+ @hostpath="#{@hosturl_files}/#{@stub}"
+ @ln='en'
+ WOK_SQL
+ end
+ def dir_structure
+ case @opt.dir_structure_by
+ when /language/
+ <<-'WOK_SQL'
+ def path_manifest(fn,ln=nil)
+ "#{@hostpath}/#{ln}/manifest/#{fn}.html"
+ end
+ def path_html_seg(fn,ln=nil)
+ "#{@hostpath}/#{ln}/html/#{fn}"
+ end
+ def path_toc(fn,ln=nil)
+ "#{path_html_seg(fn,ln)}/toc.html"
+ end
+ def path_filename(fn,seg,ln=nil)
+ "#{path_html_seg(fn,ln)}/#{seg}.html"
+ end
+ def path_endnotes(fn,ln=nil)
+ "#{path_html_seg(fn,ln)}/endnotes.html"
+ end
+ def path_html_doc(fn,ln=nil)
+ "#{@hostpath}/#{ln}/html/#{fn}.html"
+ end
+ WOK_SQL
+ when /filetype/
+ <<-'WOK_SQL'
+ def path_manifest(fn,ln=nil)
+ "#{@hostpath}/manifest/#{fn}.#{ln}.html"
+ end
+ def path_html_seg(fn,ln=nil)
+ "#{@hostpath}/html/#{fn}"
+ end
+ def path_toc(fn,ln=nil)
+ "#{path_html_seg(fn,ln)}/toc.#{ln}.html"
+ end
+ def path_filename(fn,seg,ln=nil)
+ "#{path_html_seg(fn,ln)}/#{seg}.#{ln}.html"
+ end
+ def path_endnotes(fn,ln=nil)
+ "#{path_html_seg(fn,ln)}/endnotes.#{ln}.html"
+ end
+ def path_html_doc(fn,ln=nil)
+ "#{@hostpath}/html/#{fn}.#{ln}.html"
+ end
+ WOK_SQL
+ else
+ <<-'WOK_SQL'
+ def path_manifest(fn,ln=nil)
+ "#{@hostpath}/#{fn}/sisu_manifest.#{ln}.html"
+ end
+ def path_html_seg(fn,ln=nil)
+ "#{@hostpath}/#{fn}"
+ end
+ def path_toc(fn,ln=nil)
+ "#{path_html_seg(fn,ln)}/toc.#{ln}.html"
+ end
+ def path_filename(fn,seg,ln=nil)
+ "#{path_html_seg(fn,ln)}/#{seg}.#{ln}.html"
+ end
+ def path_endnotes(fn,ln=nil)
+ "#{path_html_seg(fn,ln)}/endnotes.#{ln}.html"
+ end
+ def path_html_doc(fn,ln=nil)
+ "#{path_html_seg(fn,ln)}/scroll.#{ln}.html"
+ end
+ WOK_SQL
+ end
+ end
+ def main3
+ <<-'WOK_SQL'
+ #% text_objects_body
+ s_contents.each do |c| #% text body
+ location=c['src_filename'][/(.+?)\.(?:ssm\.sst|sst)$/,1]
+ file_suffix=c['src_filename'][/.+?\.(_?sst|ssm)$/,1]
+ lang=if location =~ /\S+?~(\S\S\S?)$/
+ l=location[/\S+?~(\S\S\S?)$/,1]
+ location.gsub!(/(\S+?)~\S\S\S?/,'\1')
+ l=".#{l}"
+ else ''
+ end
+ #% metadata_found_body
+ if c['tid'].to_i != oldtid.to_i
+ ti=c['title']
+ can_txt_srch=(cgi['view']=~/index/) \
+ ? %{ }
+ : %{ }
+ title=%{ #{ti} [#{c['language_document_char']}] by #{c['creator_author']} #{can_txt_srch} } if file_suffix=~/s/ #hmm watch file_suffix
+ title=@text_search_flag \
+ ? ' '+title
+ : ' '+title
+ @counter_txt_doc+=1
+ oldtid=c['tid'].to_i
+ else title=''
+ end
+ if @text_search_flag
+ if cgi['view']=~/text/ \
+ or (cgi['view']!~/index/ and cgi['search'] !~/search db/) #% txt body
+ text=if c['suffix'] !~/1/ #seg
+ if @search_for.text1 =~/\S+/ \
+ or q['s1'] =~/\S+/ #% only this branch is working !!
+ unescaped_search=if @search_for.text1 =~/\S+/
+ CGI.unescape(@search_for.text1)
+ elsif q['s1'] =~/\S+/
+ CGI.unescape(q['s1'])
+ else nil
+ end
+ @search_regx=if unescaped_search #check
+ search_regex=[]
+ build=unescaped_search.scan(/\S+/).each do |g|
+ (g.to_s =~/(AND|OR)/) \
+ ? (search_regex << '|')
+ : (search_regex << %{#{g.to_s}})
+ end
+ search_regex=search_regex.join(' ')
+ search_regex=search_regex.gsub(/\s*\|\s*/,'|')
+ Regexp.new(search_regex, Regexp::IGNORECASE)
+ else nil
+ end
+ else nil
+ end
+ matched_para=(@search_regx.to_s.class==String && @search_regx.to_s=~/\S\S+/) \
+ ? (c['body'].gsub(/(<\s]+#{@search_regx}[^>]+?>|#{@search_regx})/mi,%{\\1}))
+ : c['body']
+ %{
Word index links are to html versions of the text the segmented version followed by the scroll (single document) version. [For segmented text references [T1], [T2] or [T3] appearing without a link, indicates that the word appears in a title (or subtitle) of the text (that is identifiable by the appended object citation number).]
+
(The word listing/index is Case sensitive: Capitalized words appear before lower case)
+
+ word (number of occurences) linked references to word within document
+ [if number of occurences exceed number of references - word occurs more than once in at least one reference. Footnote/endnotes are either assigned to the paragraph from which they are referenced or ignored, so it is relevant to check the footnotes referenced from within a paragraph as well.]
+
+
+ (After the page is fully loaded) you can jump directly to a word by appending a hash (#) and the word to the url for this text, (do not forget that words are case sensitive, and may be listed twice (starting with and without an upper case letter)), #your_word # [ http://[web host]/#{@fnb}/concordance.html#your_word ]
+
+WOK
+ end
+ end
+ class Word
+ @@word_previous=''
+ def initialize(word,freq)
+ @word,@freq=word,freq
+ end
+ def html
+ w=if @word.capitalize==@@word_previous
+ %{\n
#{@word}
(#{@freq})
\n\t
}
+ else n=@word.strip.gsub(/\s+/,'_') #also need to convert extended character set to html
+ %{\n
}
+ for word in @freq.keys.sort! {|a,b| a.downcase<=>b.downcase}
+ f=/^(\S)/.match(word)[1]
+ if letter < f.upcase
+ while letter < f.upcase
+ if alph.length > 0
+ letter=alph.shift
+ @file_concordance << %{\n
}
+ the_idx.each do |i|
+ i.each do |x|
+ if x.class==String
+ f=/^(\S)/.match(x)[1]
+ if letter < f
+ while letter < f
+ if alph.length > 0
+ letter=alph.shift
+ idx[:html] << %{\n
'
+ idx[:xhtml][@r]=idx[:xhtml][@r] + ''
+ end
+ end
+ end
+ idx
+ @x +=1
+ end
+ end
+ end
+ print "\n" if @md.opt.cmd =~/V/
+ idx
+ end
+ def screen_print(the_idx)
+ the_idx.each do |i|
+ i.each do |x|
+ if x.class==String
+ print "\n" + x + ', '
+ elsif x.class==Array
+ p 'array error? -->'
+ print x
+ elsif x.class==Hash
+ if x['term_node_lev1'].class==Array
+ x['term_node_lev1'].each do |a|
+ if a[:range]
+ print a[:range] + ', '
+ elsif a[:ocn]
+ print a[:ocn] + ', '
+ else p 'error'
+ end
+ end
+ end
+ if x['term_node_lev2']
+ m=x['term_node_lev2']
+ m=m.sort
+ m.each do |k,y|
+ if k !~/term_node_lev1/
+ print "\n\t" + k + ', '
+ y.each do |z|
+ if z[:range]
+ print z[:range] + ', '
+ elsif z[:ocn]
+ print z[:ocn] + ', '
+ else p 'error'
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+ def output_idx(idx)
+ if @md.book_idx
+ path="#{@env.path.output}/#{@md.fnb}"
+ Dir.mkdir(path) unless FileTest.directory?(path)
+ puts "#{path}/#{@md.fn[:book_idx_html]} #{__FILE__}::#{__LINE__}"
+ html_index_file=File.new("#{path}/#{@md.fn[:book_idx_html]}",'w')
+ idx[:html].each {|x| html_index_file << x }
+ html_index_file.close
+ end
+ end
+ def clean_and_insert_index(data,sisu_markup_idx)
+ tuned_file=[]
+ data.each do |dob|
+ tuned_file << dob
+ if dob.obj =~/#{Mx[:br_endnotes]}/ \
+ and sisu_markup_idx
+ sisu_markup_idx.each do |idx|
+ tuned_file << idx
+ end
+ end
+ end
+ tuned_file
+ end
+ def clean_index(data) #check on use of dob
+ tuned_file=[]
+ data.each do |para|
+ para.gsub!(/\n*#{@rgx_idx}/m,'')
+ tuned_file << para
+ end
+ tuned_file
+ end
+ end
+end
+__END__
diff --git a/lib/sisu/v3dv/dal_images.rb b/lib/sisu/v3dv/dal_images.rb
new file mode 100644
index 00000000..34157f74
--- /dev/null
+++ b/lib/sisu/v3dv/dal_images.rb
@@ -0,0 +1,156 @@
+# encoding: utf-8
+=begin
+
+ * Name: SiSU
+
+ * Description: a framework for document structuring, publishing and search
+
+ * Author: Ralph Amissah
+
+ * Copyright: (C) 1997 - 2012, 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 .
+
+ If you have Internet connection, the latest version of the GPL should be
+ available at these locations:
+
+
+
+
+
+
+
+ * SiSU uses:
+ * Standard SiSU markup syntax,
+ * Standard SiSU meta-markup syntax, and the
+ * Standard SiSU object citation numbering and system
+
+ * Hompages:
+
+
+
+ * Download:
+
+
+ * Ralph Amissah
+
+
+
+ ** Description: system environment, resource control and configuration details
+
+=end
+module SiSU_images
+ class Images
+ #require 'RMagick'
+ #include Magick
+ def initialize(md,data)
+ @md,@data=md,data
+ end
+ def images
+ data=@data
+ tuned_file=[]
+ @rmgk=false
+ imagemagick_=true #imagemagick_=SiSU_Env::Info_settings.new.program?('rmagick')
+ if imagemagick_
+ begin
+ @rmgk=SiSU_Env::Load.new('RMagick').prog
+ rescue
+ @rmgk=false
+ end
+ else
+ if @md.opt.cmd =~/[vVM]/
+ SiSU_Screen::Ansi.new(@md.opt.cmd,'use of RMagick is not enabled in sisurc.yml').warn
+ end
+ end
+ data.each do |dob|
+ unless dob.is =~/^table/
+ dob.obj.strip!
+ if dob.obj =~/#{Mx[:lnk_o]}\s*\S+\.(?:png|jpg|gif)(?:\s*|\s+.+)?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)/
+ if dob.obj !~/#{Mx[:lnk_o]}\s*\S+\.(?:png|jpg|gif)\s+\d+x\d+/
+ m=/#{Mx[:lnk_o]}\s*(\S+\.(?:png|jpg|gif))/
+ if imagemagick_
+ imgs=dob.obj.scan(m).flatten
+ img_col=img_row=nil
+ images=imgs.each do |image|
+ dir=SiSU_Env::Info_env.new(@md.fns)
+ path_image=[dir.path.image_source_include_local,dir.path.image_source_include_remote,dir.path.image_source_include]
+ image_path=nil
+ path_image.each do |img_pth|
+ image_path=img_pth
+ break if FileTest.exist?("#{img_pth}/#{image}")
+ end
+ if FileTest.exist?("#{image_path}/#{image}")
+ if @rmgk
+ img=Magick::ImageList.new("#{image_path}/#{image}")
+ img_col,img_row=img.columns,img.rows
+ else
+ if @md.opt.cmd =~/[vVM]/
+ SiSU_Screen::Ansi.new(@md.opt.cmd,'RMagick not present, will attempt to use imagemagick (identify) directly').warn
+ end
+ imgk=SiSU_Env::System_call.new.imagemagick
+ gmgk=SiSU_Env::System_call.new.graphicksmagick
+ if imgk or gmgk
+ if imgk
+ imgsys=`identify #{image_path}/#{image}`.strip #system call
+ elsif gmgk
+ imgsys=`gm identify #{image_path}/#{image}`.strip #system call
+ end
+ img_col,img_row=/(\d+)x(\d+)/m.match(imgsys)[1,2]
+ img_col,img_row=img_col.to_i,img_row.to_i
+ end
+ end
+ row=((img && defined? img.rows) ? img.rows : img_row)
+ col=((img && defined? img.columns) ? img.columns : img_col)
+ if img_col > img_row #landscape
+ if img_col> 640
+ img_col=640
+ img_row=((1.00*img_col/col)*row).round
+ end
+ else #portrait
+ if img_col> 640
+ img_col=640
+ img_row=((1.00*img_col/col)*row).round
+ end
+ if img_row > 640
+ img_row=640
+ img_col=((1.00*img_row/row)*col).round
+ end
+ end
+ dob.obj.gsub!(/(#{image})/,"#{image} #{img_col}x#{img_row}")
+ else dob.obj.gsub!(/#{Mx[:lnk_o]}\s*(\S+)\.(png|jpg|gif).+?#{Mx[:lnk_c]}(#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)/,'[ \1 (\2 missing) ]')
+ end
+ end
+ else
+ images=dob.obj.scan(m) do |image|
+ SiSU_Screen::Ansi.new(@md.opt.cmd,'where image dimensions have not been provided RMagick or imagemagick is required',image).warn #unless @opt.cmd =~/q/
+ end
+ end
+ end
+ end
+ dob.obj.gsub!(/(#{Mx[:lnk_o]})\s*(\S+\.(?:png|jpg|gif))\s+/i,'\1\2 ') if dob.obj =~/#{Mx[:lnk_o]}\s*\S+\.(?:png|jpg|gif).+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)/
+ end
+ tuned_file << dob unless dob.nil?
+ end
+ tuned_file
+ end
+ end
+end
+__END__
+imgsys=`identify #{image_path}/#{image}`.strip
diff --git a/lib/sisu/v3dv/dal_metadata.rb b/lib/sisu/v3dv/dal_metadata.rb
new file mode 100644
index 00000000..8647a075
--- /dev/null
+++ b/lib/sisu/v3dv/dal_metadata.rb
@@ -0,0 +1,79 @@
+# encoding: utf-8
+=begin
+
+ * Name: SiSU
+
+ * Description: a framework for document structuring, publishing and search
+
+ * Author: Ralph Amissah
+
+ * Copyright: (C) 1997 - 2012, 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 .
+
+ If you have Internet connection, the latest version of the GPL should be
+ available at these locations:
+
+
+
+
+
+
+
+ * SiSU uses:
+ * Standard SiSU markup syntax,
+ * Standard SiSU meta-markup syntax, and the
+ * Standard SiSU object citation numbering and system
+
+ * Hompages:
+
+
+
+ * Download:
+
+
+ * Ralph Amissah
+
+
+
+ ** Description: system environment, resource control and configuration details
+
+=end
+module SiSU_metadata
+ class Metadata
+ def initialize(md,metad)
+ @md,@metadata=md,metad
+ l=SiSU_Env::Standardise_language.new(@md.opt.lng).language
+ language=l[:n]
+ @tr=SiSU_Translate::Source.new(md,language)
+ end
+ def make_para(obj,ocn)
+ h={ obj: obj, ocn: 0 }
+ SiSU_document_structure::Object_para.new.paragraph(h)
+ end
+ def make_heading(obj,ocn,name,lv,ln)
+ h={ lv: lv, ln: ln, name: name, obj: obj, ocn: 0 }
+ SiSU_document_structure::Object_heading.new.heading(h)
+ end
+ def metadata
+ end
+ end
+end
+__END__
diff --git a/lib/sisu/v3dv/dal_numbering.rb b/lib/sisu/v3dv/dal_numbering.rb
new file mode 100644
index 00000000..4b12793f
--- /dev/null
+++ b/lib/sisu/v3dv/dal_numbering.rb
@@ -0,0 +1,465 @@
+# encoding: utf-8
+=begin
+
+ * Name: SiSU
+
+ * Description: a framework for document structuring, publishing and search
+
+ * Author: Ralph Amissah
+
+ * Copyright: (C) 1997 - 2012, 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 .
+
+ If you have Internet connection, the latest version of the GPL should be
+ available at these locations:
+
+
+
+
+
+
+
+ * SiSU uses:
+ * Standard SiSU markup syntax,
+ * Standard SiSU meta-markup syntax, and the
+ * Standard SiSU object citation numbering and system
+
+ * Hompages:
+
+
+
+ * Download:
+
+
+ * Ralph Amissah
+
+
+
+ ** Description: system environment, resource control and configuration details
+
+=end
+module SiSU_numbering
+ class Numbering
+ attr_accessor :obj,:osp,:ocn,:lv,:name,:index,:comment
+ def initialize(md,data)
+ @md,@data=md,data
+ @obj=@type=@ocn=@lv=@name=@index=@comment=nil
+ end
+ def numbering_song
+ data=@data
+ data=number_plaintext_para(data)
+ data=auto_number_heading_ie_title(data.compact) #tr issue
+ data=ocn(data.compact) #watch
+ data=xml(data.compact)
+ data=minor_numbering(data.compact)
+ data,tags_map,ocn_html_seg_map=name_para_seg_filename(data)
+ data=set_heading_top(data) unless @md.set_heading_top
+ [data,tags_map,ocn_html_seg_map]
+ end
+ def number_plaintext_para(data)
+ @tuned_file=[]
+ data.each do |dob|
+ if dob.of !~/(?:block|comment|layout)/ and dob.ocn_ #and dob.obj !~ /#{Mx[:gr_o]}Th|#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}/ #FIX
+ dob.obj.gsub!(/(.+)\n/,'\1 ') #messy, but idea is that tables should retain breaks
+ end
+ unless dob.obj.class==Array
+ dob.obj.gsub!(/^\s+/,'')
+ dob.obj.gsub!(/\s$/,"\n")
+ end
+ @tuned_file << dob
+ end
+ @tuned_file=@tuned_file.flatten
+ end
+ def number_sub_heading(dob,num,title_no)
+ unless dob.obj =~/\d+\.|(?:chapter|article|section|clause)\s+\d+/i #name selection arbitrary, fix
+ case dob.name
+ when /-/; dob.obj.gsub!(/^/,"#{title_no} ")
+ when /^#/; dob.obj.gsub!(/^/,"#{title_no} ")
+ when /^[a-z_\.]+/
+ dob.obj.gsub!(/^/,"#{title_no} ")
+ else
+ dob.name=title_no if dob.name=~/^$/ #where title contains title number
+ dob.obj.gsub!(/^/,"#{title_no} ") if title_no =~/\d+/ #main, where title number is to be provided #watch changed placement
+ end
+ if @md.toc_lev_limit \
+ and @md.toc_lev_limit < num
+ dob.obj.gsub!(/^/,'!_ ') #bold line, watch
+ end
+ end
+ dob
+ end
+ def heading_tag_clean(heading_tag)
+ heading_tag.gsub!(/[ ]+/,'_')
+ heading_tag.gsub!(/["']/,'')
+ heading_tag.gsub!(/[\/]/,'-')
+ heading_tag.gsub!(/#{Mx[:fa_bold_o]}|#{Mx[:fa_bold_c]}/,'')
+ heading_tag.gsub!(/#{Mx[:fa_italics_o]}|#{Mx[:fa_italics_c]}/,'')
+ heading_tag.gsub!(/#{Mx[:fa_underscore_o]}|#{Mx[:fa_underscore_c]}/,'')
+ heading_tag.gsub!(/#{Mx[:fa_cite_o]}|#{Mx[:fa_cite_c]}/,'')
+ heading_tag.gsub!(/#{Mx[:fa_insert_o]}|#{Mx[:fa_insert_c]}/,'')
+ heading_tag.gsub!(/#{Mx[:fa_strike_o]}|#{Mx[:fa_strike_c]}/,'')
+ heading_tag.gsub!(/#{Mx[:fa_superscript_o]}|#{Mx[:fa_superscript_c]}/,'')
+ heading_tag.gsub!(/#{Mx[:fa_subscript_o]}|#{Mx[:fa_subscript_c]}/,'')
+ heading_tag.gsub!(/#{Mx[:fa_hilite_o]}|#{Mx[:fa_hilite_c]}/,'')
+ heading_tag.gsub!(/#{Mx[:gl_bullet]}/,'')
+ heading_tag
+ end
+ def auto_number_heading_ie_title(data) #also does some segment naming
+ @tuned_file=[]
+ if defined? @md.make.num_top \
+ and @md.make.num_top \
+ and @md.make.num_top !~/^$/
+ input||=@md.make.num_top
+ end
+ num_top=(input ? input.to_i : nil)
+ t_no1=t_no2=t_no3=t_no4=0
+ if num_top
+ no1=num_top; no2=(num_top + 1); no3=(num_top + 2); no4=(num_top + 3)
+ end
+ t_not=0
+ data.compact!
+ chapter_number_counter=0
+ data.each do |dob| #@md.seg_names << [additions to segment names]
+ title_no=nil
+ dob=SiSU_document_structure_extract::Structure.new(@md,dob).structure_markup #must happen earlier, node info etc. require
+ if dob.is =='heading' \
+ and dob.autonum_ \
+ and defined? @md.make.num_top \
+ and @md.make.num_top !~/^$/
+ if dob.lv=='1' \
+ and dob.obj =~/^#\s|\s#(?:\s|$)/
+ chapter_number_counter +=1
+ dob.obj.gsub!(/^#\s/,"#{chapter_number_counter} ")
+ dob.obj.gsub!(/#([:,]?\s|[.]?$)/,"#{chapter_number_counter}\\1")
+ end
+ if dob.ln==no1
+ @subnumber=1
+ @subnumber=0 if dob.ln==no1
+ end
+ if dob.ln.to_s =~/^[1-6]/ \
+ and not dob.toc_ \
+ and dob.obj !~/#{Mx[:fa_o]}(?:~#|-#)#{Mx[:fa_c]}/ # <-- fix
+ if dob.ln==no1
+ t_no1+=1; t_no2=0; t_no3=0
+ title_no="#{t_no1}"
+ if not @md.seg_names.nil? \
+ and not @md.seg_names.include?(title_no)
+ if dob.ln==no1
+ dob.name="#{title_no}" if not dob.name
+ dob.tags=[title_no,dob.tags].flatten if title_no !~/^\d+$/ #check whether will work across file types with stop signs
+ tag=dob.obj.gsub(/(Article|Clause|Section|Chapter)\s+/,"\\1_#{title_no}").downcase
+ tag=heading_tag_clean(tag)
+ dob.tags=[tag,dob.tags].flatten if tag !~/^\d+$/ #check whether will work across file types with stop signs
+ (dob.obj =~/(Article|Clause|Section)\s+/) \
+ ? (dob.obj.gsub!(/(Article|Clause|Section)\s+/,"\\1 #{title_no} "))
+ : (dob.obj.gsub!(/^/,"#{title_no}. ")) #fix stop later
+ end
+ if dob.ln !=no1 \
+ and dob.obj =~/^[\d.]+\s/ #fix -> if the title starts with a numbering scheme, do not auto-number, review
+ dob.name ="#{title_no}" if not dob.name
+ dob.tags=[title_no,dob.tags].flatten if title_no !~/^\d+$/ #check whether will work across file types with stop signs
+ dob.obj.gsub!(/^/,"#{title_no}. ")
+ end
+ @md.seg_names << title_no
+ end
+ if dob.ln!=no1 \
+ and dob.name!~/^[a-z_\.]+$/ \
+ and dob.obj !~/[A-Z]\.?\s/ #bug -> tmp fix, excludes A. B. C. lettering, but not roman numerals, is arbitrary, review required # not fixed, work on
+ dob.tags=[title_no,dob.tags].flatten if title_no !~/^\d+$/ #check whether will work across file types with stop signs
+ dob.obj.gsub!(/^/i,"#{title_no}. ")
+ end
+ end
+ if dob.ln==no1 #watch because here you change dob.name
+ dob.tags=["h#{title_no}",dob.tags].flatten #check whether will work across file types with stop signs
+ end
+ if dob.ln==no2 #watch because here you change dob.name
+ t_no2+=1; t_no3=0
+ title_no="#{t_no1}.#{t_no2}"
+ dob.tags=["h#{title_no}",dob.tags].flatten #check whether will work across file types with stop signs
+ dob=number_sub_heading(dob,no2,title_no)
+ end
+ if dob.ln==no3 #watch because here you change dob.name
+ t_no3+=1
+ title_no="#{t_no1}.#{t_no2}.#{t_no3}"
+ dob.tags=["h#{title_no}",dob.tags].flatten #check whether will work across file types with stop signs
+ dob=number_sub_heading(dob,no3,title_no)
+ end
+ elsif dob.ln.to_s =~/^[1-6]/ \
+ and dob.name =~ /^[\w-]+-/ # endnotes, watch2005# endnotes, watch2005
+ dob.tags=[dob.name,dob.tags].flatten if dob.name !~/^\d+$/ #check whether will work across file types with stop signs
+ dob.name.gsub(/^([a-z_\.]+)-$/,'\1')
+ end
+ elsif dob.is =='heading' \
+ and dob.autonum_ \
+ and @md.markup =~/num_extract/ #AS DANGEROUS force enable with document, note already does this type of numbering for cisg, locate and coordinate logic, is currently misplaced in code, chengwei inspired 2004w23/4
+ #here lies a bug, as is nil when run from -Dv --update, FIX
+ if (dob.name.nil? or dob.name.empty?) \
+ and dob.ln.to_s =~/^[1-9]/ \
+ and dob.obj =~ /^([\d\.]+)/ #risky (must be unique) consider output to 4~~\d instead of 4~\d
+ dob.name=$1
+ dob.tags=[dob.name,dob.tags].flatten if dob.name !~/^\d+$/ #check whether will work across file types with stop signs
+ end
+ if @md.toc_lev_limit
+ end
+ elsif defined? dob.name \
+ and dob.name
+ dob.tags=[dob.name,dob.tags].flatten if dob.name !~/^\d+$/ #check whether will work across file types with stop signs
+ end
+ dob.tags=dob.tags.uniq if defined? dob.tags
+ @tuned_file << dob
+ end
+ @tuned_file=@tuned_file.flatten
+ end
+ def ocn(data) #and auto segment numbering increment
+ @tuned_file=SiSU_document_structure_extract::OCN.new(@md,data).ocn
+ @tuned_file
+ end
+ def xml(data)
+ @tuned_file=SiSU_document_structure_extract::XML.new(@md,data).dom
+ @tuned_file
+ end
+ def minor_numbering(data) #and auto segment numbering increment
+ @tuned_file=[]
+ number_small,letter_small=0,0
+ letter=%w( a b c d e f g h i j k l m n o p q r s t u v w x y z )
+ data.each do |dob|
+ if dob.of =~/heading|para|block/
+ if dob.is =='heading' \
+ and dob.ln.to_s=~/^[1-9]/ #% sub-number system, (baby numbering) reset with any change of major number (more obviously should be placed in number titles, but that is conditionally executed, check and move later)
+ number_small,letter_small=0,0
+ elsif dob.is =~/para/
+ if dob.obj =~/^#[ 1]/ \
+ and dob.obj !~/^#\s+(?:~#)?$/
+ letter_small=0
+ number_small=0 if dob.obj =~ /^#1/
+ number_small+=1
+ dob.obj.gsub!(/^#[ 1]/,"#{number_small}. ") #change 2004
+ end
+ if dob.obj =~/^_# /
+ dob.obj.gsub!(/^_# /,"#{letter[letter_small]}. ") #change 2004
+ dob.indent='1'
+ letter_small+=1
+ end
+ end
+ end
+ @tuned_file << dob
+ end
+ @tuned_file=@tuned_file.flatten
+ end
+ def name_para_seg_filename(data) #segment naming, remaining
+ # paragraph name/numbering rules
+ # manual naming overrides, manual naming may be
+ # alpha-numeric characters mixed,
+ # numeric only (a number), if
+ # all segments have been named,
+ # the numbers used are over 1000 or
+ # it is not minded that auto-numbering uses a funny scheme for naming segments (not yet implemented)
+ # [for now a warning is printed for such documents on use of maintenance or very-verbose flag]
+ # auto-naming takes the form of giving numbers to segments
+ # the rules for which are as follows
+ # if the title/heading text starts with a numeric, then that is used (1 3.1 3rd etc.)
+ # otherwise the level 4 segment number from the embedded document structure info is used
+ # if there is none a sequential number is designated, preceded by an underscore
+ @tuned_file,@unique_auto_name=[],[]
+ tags={}
+ art_filename_auto=1
+ @counter=1
+ if not @md.seg_autoname_safe and @md.opt.cmd =~/[MV]/
+ puts 'manual segment names, numbers used as names, risk warning (segmented html)'
+ end
+ ocn_html_seg=[]
+ data.each do |dob|
+ if dob.is=='heading' \
+ and dob.ln \
+ and dob.ln.to_s =~/^[456]/
+ if dob.ln==4 \
+ and not dob.name \
+ and not @md.set_heading_seg
+ @md.set_heading_seg=true
+ end
+ if dob.name !~/^\S+/ \
+ and dob.obj =~/^\s*(?:\S+\s+)?([\d.,:-]+)/m #heading starts with a recognised numeric or word followed by a recognised numerical construct, use that as name
+ possible_seg_name=$1
+ possible_seg_name.gsub!(/(?:[:,-]|\W)/,'.')
+ possible_seg_name.gsub!(/\.$/,'')
+ if not @md.seg_names.nil? \
+ and not @md.seg_names.include?(possible_seg_name)
+ dob.name=possible_seg_name
+ dob.tags=[dob.name,dob.tags].flatten if dob.name !~/^\d+$/
+ @md.seg_names << possible_seg_name
+ else puts 'warn, there may be a conflicting numbering scheme' if @md.opt.cmd =~/[VM]/
+ end
+ end
+ if dob.ln==4 \
+ and dob.name #extract segment name from embedded document structure info
+ if not @md.seg_names.nil? \
+ and not @md.seg_names.include?(dob.name)
+ dob.tags=[dob.name,dob.tags].flatten if dob.name !~/^\d+$/
+ @md.seg_names << dob.name
+ end
+ end
+ if dob.ln==4 \
+ and not dob.name #if still no segment name, provide a numerical one
+ pf='_' #pg='' #may use e.g. '' or '~' or '_'
+ segn_auto="#{pf}#{art_filename_auto.to_s}"
+ if not @md.seg_names.nil? \
+ and not @md.seg_names.include?(segn_auto)
+ dob.name=segn_auto
+ dob.tags=[dob.name,dob.tags].flatten if dob.name !~/^\d+$/ #check whether will work across file types with stop signs
+ @md.seg_names << segn_auto
+ else puts 'segment name (numbering) error'
+ end
+ art_filename_auto+=1
+ end
+ if dob.ln==4 \
+ and not dob.name #should not occur
+ puts "e r r o r -\t#{__FILE__}::#{__LINE__}\n#{dob.inspect}"
+ end
+ end
+ if dob.is =~/heading/ \
+ and dob.ln==4
+ @seg=dob.name
+ end
+ @tuned_file << if dob.is=='heading' \
+ and (@md.pagenew or @md.pagebreak)
+ m=dob.ln.to_s
+ dob_tmp=[]
+ if @md.pagenew.inspect =~/#{m}/
+ dob_tmp << SiSU_document_structure::Object_layout.new.break(Hx[:br_page_new]) << dob
+ elsif @md.pagebreak.inspect =~/#{m}/
+ dob_tmp << SiSU_document_structure::Object_layout.new.break(Hx[:br_page]) << dob
+ end
+ para_result=unless dob_tmp.length > 0; dob
+ else dob_tmp
+ end
+ else dob
+ end
+ if defined? dob.ocn \
+ and dob.ocn
+ @segname=((dob.is=='heading'|| dob.is=='heading_insert') && dob.ln==4 && (defined? dob.name)) \
+ ? (dob.name)
+ : @segname
+ tags["#{dob.ocn}"]={ segname: @segname }
+ ocn_html_seg[dob.ocn]=if dob.is =~/heading/
+ x=if dob.ln =~/[1-3]/
+ { seg: nil, level: dob.ln }
+ else #elsif dob.ln =~/[4-6]/
+ { seg: @seg, level: dob.ln }
+ end
+ else
+ { seg: @seg, level: nil }
+ end
+ end
+ dob.tags=dob.tags.uniq if defined? dob.tags
+ if defined? dob.tags \
+ and dob.tags.length > 0
+ #@segname=((dob.is=='heading'|| dob.is=='heading_insert') && dob.ln==4 && (defined? dob.name)) \
+ #? (dob.name) \
+ #: @segname
+ dob.tags.each do |x|
+ tags[x]={ ocn: dob.ocn.to_s, segname: @segname }
+ end
+ end
+ dob
+ end
+ ocn_html_seg.each_with_index do |ocn,i|
+ if ocn \
+ and ocn[:level].to_s=~/[1-3]/
+ ocn_seg=nil
+ (1..4).each do |x|
+ if ocn_html_seg[i+x] and ocn_html_seg[i+x][:level]==4
+ ocn[:seg]=ocn_html_seg[i+x][:seg]
+ end
+ end
+ end
+ end
+ if @md.seg_names.length > 0
+ @md.set_heading_seg=true
+ end
+ tuned_file=@tuned_file.flatten
+ [tuned_file,tags,ocn_html_seg]
+ end
+ def set_heading_top(data) #% make sure no false positives
+ unless @md.set_heading_top
+ puts "\tdocument contains no top level heading, (will have to manufacture one)" if @md.opt.cmd =~/[MV]/
+ @tuned_file=[]
+ data.each do |t_o|
+ unless @md.set_heading_top
+ if t_o !~/^(?:#{Rx[:meta]}|@\S+:)\s/m \
+ and t_o !~/\A\s*\Z/m
+ @md.set_heading_top=true
+ if defined? @md.title \
+ and @md.title \
+ and defined? @md.title.full \
+ and defined? @md.creator \
+ and @md.creator
+ head=@md.title.main ? ([@lv='1',@obj=@md.title.main]) : ([@lv='1',@obj='[no title provided]'])
+ @tuned_file << head
+ end
+ end
+ end
+ @tuned_file << t_o
+ end
+ @tuned_file=@tuned_file.flatten
+ end
+ end
+ def set_heading_seg(data) #% make sure no false positives
+ unless @md.set_heading_seg
+ puts "\tdocument contains no segment level, (will have to manufacture one)" if @md.opt.cmd =~/[MV]/
+ @tuned_file=[]
+ data.each do |dob|
+ unless @md.set_heading_seg
+ if defined? dob.ln and dob.ln.to_s !~/^[123]/m \
+ and dob.obj !~/\A\s*\Z/m \
+ and dob.is !='layout'
+ @md.set_heading_seg=true
+ head=if @md.title.main ; dob.ln,dob.name,dob.obj=4,'seg',@md.title.main
+ else dob.ln,dob.name,dob.obj=4,'seg','[segment]'
+ end
+ @tuned_file << head
+ end
+ end
+ @tuned_file << dob
+ end
+ @tuned_file=@tuned_file.flatten
+ end
+ end
+ def set_header_title(data) #% make sure no false positives
+ unless @md.set_header_title
+ puts "\t no document title provided, (will have to manufacture one)" if @md.opt.cmd =~/[MV]/
+ @tuned_file=[]
+ data.each do |t_o|
+ unless @md.set_header_title
+ if t_o !~/^%{1,2}\s/m \
+ and t_o !~/\A\s*\Z/m
+ @tuned_file << "#{Mx[:meta_o]}title#{Mx[:meta_c]} #{@md.heading_seg_first}"
+ @md.title.main=@md.heading_seg_first
+ @md.set_header_title=true
+ end
+ end
+ @tuned_file << t_o
+ end
+ @tuned_file=@tuned_file.flatten
+ end
+ end
+ end
+end
+__END__
diff --git a/lib/sisu/v3dv/dal_substitutions_and_insertions.rb b/lib/sisu/v3dv/dal_substitutions_and_insertions.rb
new file mode 100644
index 00000000..5844071f
--- /dev/null
+++ b/lib/sisu/v3dv/dal_substitutions_and_insertions.rb
@@ -0,0 +1,154 @@
+# encoding: utf-8
+=begin
+
+ * Name: SiSU
+
+ * Description: a framework for document structuring, publishing and search
+
+ * Author: Ralph Amissah
+
+ * Copyright: (C) 1997 - 2012, 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 .
+
+ If you have Internet connection, the latest version of the GPL should be
+ available at these locations:
+
+
+
+
+
+
+
+ * SiSU uses:
+ * Standard SiSU markup syntax,
+ * Standard SiSU meta-markup syntax, and the
+ * Standard SiSU object citation numbering and system
+
+ * Hompages:
+
+
+
+ * Download:
+
+
+ * Ralph Amissah
+
+
+
+ ** Description: system environment, resource control and configuration details
+
+=end
+module SiSU_substitute_and_insert
+ class SI
+ def initialize(md,data)
+ @md,@data=md,data
+ @skin=SiSU_Env::Info_skin.new(@md)
+ end
+ def substitutions_and_insertions?
+ data=@data
+ data_expand=[]
+ if data[0] =~ /^#!\s*(?:\/usr\/bin\/env sisu|\/usr\/bin\/sisu)/ # remove bang from top #! (however file is stripped, so will be removed provided no content precedes it)
+ data[0].gsub!(/^#!\s*\/usr\/bin\/sisu/,'')
+ data[0].gsub!(/^#!\s*\/usr\/bin\/env sisu/,'')
+ end
+ if data[0] =~ /^(SiSU\s+[\d.]*|sisu-[\d.]+)$/ # SiSU identifier
+ data[0].gsub!(/^(SiSU\s*[\d.]*)$/,'% \1')
+ data[0].gsub!(/^(sisu-[\d.]+)$/,'% \1')
+ end
+ data.each do |para|
+ if para =~/<:(insert\d+)!?>/ \
+ and para !~/^%\s+/
+ @skin.select
+ ins=SiSU_Viz::Inserts.new
+ case para
+ when /^\s*<:(insert1)>\s*$/
+ i=$1
+ if defined? ins.insert1
+ para=[]
+ ins.insert1.split(/\n\n/).each {|x| para << x }
+ else p "skin #{i} not found in #{@skin.select}"
+ end
+ when /^\s*<:(insert2)>\s*$/
+ i=$1
+ if defined? ins.insert2
+ para=[]
+ ins.insert2.split(/\n\n/).each {|x| para << x }
+ else p "skin #{i} not found in #{@skin.select}"
+ end
+ when /^\s*<:(insert3)>\s*$/
+ i=$1
+ if defined? ins.insert3
+ para=[]
+ ins.insert3.split(/\n\n/).each {|x| para << x << "\n"}
+ else p "skin #{i} not found in #{@skin.select}"
+ end
+ when /^\s*<:(insert4)>\s*$/
+ i=$1
+ if defined? ins.insert4
+ para=[]
+ ins.insert4.split(/\n\n/).each {|x| para << x << "\n"}
+ else p "skin #{i} not found in #{@skin.select}"
+ end
+ when /^\s*<:(insert5)>\s*$/
+ i=$1
+ if defined? ins.insert5
+ para=[]
+ ins.insert5.split(/\n\n/).each {|x| para << x << "\n"}
+ else p "skin #{i} not found in #{@skin.select}"
+ end
+ when /^\s*<:(insert6)>\s*$/
+ i=$1
+ if defined? ins.insert6
+ para=[]
+ ins.insert6.split(/\n\n/).each {|x| para << x << "\n"}
+ else p "skin #{i} not found in #{@skin.select}"
+ end
+ when /^\s*<:(insert7)>\s*$/
+ i=$1
+ if defined? ins.insert7
+ para=[]
+ ins.insert7.split(/\n\n/).each {|x| para << x << "\n"}
+ else p "skin #{i} not found in #{@skin.select}"
+ end
+ end
+ para.each {|x| data_expand << x }
+ else data_expand << para
+ end
+ data_expand.flatten!
+ data_expand.compact!
+ end
+ data_expand.each do |para|
+ para=if @md.markup_version.determined >= 0.38
+ SiSU_document_structure_extract::Structure.new(@md,para).structure_markup_normalize
+ else
+ SiSU_document_structure_extract::Structure.new(@md,para).structure_marks
+ end
+ para.gsub!(/^(:?A~)\s*$/,'\1~ @title @author') #conditional header
+ para.gsub!(/^((?:[1-9]|:?[A-C])~\S*)\s*$/,'\1~ [Note: heading marker::required title missing]~#') #conditional header for incorporated document 2004w12
+ if para =~/^@\S+?:/
+ para.gsub!(/^@(\S+?):(\s+|$)/,"#{Mx[:meta_o]}\\1#{Mx[:meta_c]}\\2")
+ para.gsub!(/^@(\S+?):([+-])(\s+|$)/,"#{Mx[:meta_o]}\\1\\2#{Mx[:meta_c]}\\3")
+ end
+ end
+ end
+ end
+end
+__END__
diff --git a/lib/sisu/v3dv/dal_syntax.rb b/lib/sisu/v3dv/dal_syntax.rb
new file mode 100644
index 00000000..2d2a8430
--- /dev/null
+++ b/lib/sisu/v3dv/dal_syntax.rb
@@ -0,0 +1,538 @@
+# encoding: utf-8
+=begin
+
+ * Name: SiSU
+
+ * Description: a framework for document structuring, publishing and search
+
+ * Author: Ralph Amissah
+
+ * Copyright: (C) 1997 - 2012, 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 .
+
+ If you have Internet connection, the latest version of the GPL should be
+ available at these locations:
+
+
+
+
+
+
+
+ * SiSU uses:
+ * Standard SiSU markup syntax,
+ * Standard SiSU meta-markup syntax, and the
+ * Standard SiSU object citation numbering and system
+
+ * Hompages:
+
+
+
+ * Download:
+
+
+ * Ralph Amissah
+
+
+
+ ** Description: Syntax for markup, input markup syntaxes, determined here
+
+=end
+module SiSU_Syntax
+ class Words
+ def initialize(line,md,mkp)
+ @line,@md,@mkp=line,md,mkp
+ end
+ end
+ class Markup
+ def initialize(md='',data='')
+ @data,@md=data,md
+ @vz=SiSU_Env::Get_init.instance.skin
+ @data_new=[]
+ url_and_stub=SiSU_Env::Info_env.new.url
+ @output_url="#{url_and_stub.remote}"
+ @env=SiSU_Env::Info_env.new
+ emph_set=if defined? @md.make.emphasis \
+ and not @md.make.emphasis.nil?
+ @md.make.emphasis
+ else @env.markup_emphasis
+ end
+ @emph=case emph_set
+ when /bold/
+ emph_italics=false
+ { o: Mx[:fa_bold_o], c: Mx[:fa_bold_c] }
+ when /italics/
+ emph_italics=true
+ { o: Mx[:fa_italics_o], c: Mx[:fa_italics_c] }
+ when /underscore/
+ emph_italics=false
+ { o: Mx[:fa_underscore_o], c: Mx[:fa_underscore_c] }
+ else p __LINE__.to_s + '::' + __FILE__
+ end
+ @http_m=%r{\{.+?\}https?://\S+|https?:\S+|:\S+|\.\.\/\S+|#\S+|\S+?\.png\b|[*]~\S+|^#{Mx[:meta_o]}.+|#{Mx[:gr_o]}(?:code|block|group|alt|verse)(?:-end)?#{Mx[:gr_c]}|#{Mx[:fa_o]}:br#{Mx[:fa_c]}}
+ @manmkp_ital=emph_italics \
+ ? '[i/*]\\{.+?\\}[i/*]'
+ : '[i/]\\{.+?\\}[i/]'
+ tail_m_ital=%q{(?:\s|[.,;:?!'")]|~\^|~\\\{\s|$)}
+ tail_m_bold=%{(?:(?:#{Mx[:fa_italics_c]})?(?:\s|[.,;:?!'")]|~\^|~\\\{\s|$))?}
+ bold_line=%{^!_\s.+?(?:#{Mx[:br_line]}|\n|$)}
+ ital_line=%{^/_\s.+?(?:#{Mx[:br_line]}|\n|$)}
+ @line_scan_ital=if defined? @md.make.italics[:str] \
+ and defined? @vz.markup_make_italic[:str]
+ /#{@http_m}|#{bold_line}|#{@manmkp_ital}#{tail_m_ital}|(?:#{@md.make.italics[:str]}|#{@vz.markup_make_italic[:str]})#{tail_m_ital}|\S+|\n/i
+ elsif defined? @md.make.italics[:str]
+ /#{@http_m}|#{bold_line}|#{@manmkp_ital}#{tail_m_ital}|#{@md.make.italics[:str]}#{tail_m_ital}|\S+|\n/i
+ elsif defined? @vz.markup_make_italic[:str]
+ /#{@http_m}|#{bold_line}|#{@manmkp_ital}#{tail_m_ital}|#{@vz.markup_make_italic[:str]}#{tail_m_ital}|\S+|\n/i
+ end
+ @manmkp_bold=emph_italics \
+ ? '^!_\s.+?(?:\n|$)|[!b]\\{.+?\\}[*!b]|[*!][a-zA-Z0-9\-_]+[!]'
+ : '^!_\s.+?(?:\n|$)|[*!b]\\{.+?\\}[*!b]|[*!][a-zA-Z0-9\-_]+[*!]'
+ @line_scan_bold=if (defined? @md.make.bold[:str] \
+ and @md.make.bold[:str]) \
+ and (defined? @vz.markup_make_bold[:str] \
+ and @vz.markup_make_bold[:str])
+ /#{@http_m}|#{bold_line}|(?:#{@manmkp_bold}|#{@md.make.bold[:str]}|#{@vz.markup_make_bold[:str]})#{tail_m_bold}|\S+|\n/i
+ elsif defined? @md.make.bold[:str] \
+ and @md.make.bold[:str]
+ /#{@http_m}|#{bold_line}|(?:#{@manmkp_bold}|#{@md.make.bold[:str]})#{tail_m_bold}|\S+|\n/i
+ elsif defined? @vz.markup_make_bold[:str] \
+ and @vz.markup_make_bold[:str]
+ /#{@http_m}|#{bold_line}|(?:#{@manmkp_bold}|#{@vz.markup_make_bold[:str]})#{tail_m_bold}|\S+|\n/i
+ end
+ end
+ def songsheet
+ @data.compact!
+ @data.each do |dob|
+ dob=breaks(dob)
+ dob=if @md.sem_tag then sem(dob) else dob end #revisit
+ dob=wordlist_italics(dob)
+ dob=wordlist_bold(dob)
+ dob=bodymarkup(dob)
+ @data_new << dob unless dob.nil?
+ end
+ @data_new
+ end
+ def sem(dob) #revisit
+ dob=SiSU_sem::Tags.new(dob,@md).rm.all
+ end
+ def breaks(dob)
+ if dob.is !~/^(?:meta|comment|code|table)/
+ dob.obj.gsub!(/ \\\\(?: |$)/,"#{Mx[:br_line]}")
+ dob.obj.gsub!(/(?:<:?br>| )/,"#{Mx[:br_line]}") # depreciated
+ end
+ dob
+ end
+ def wordlist_italics(dob)
+ dob=dob.dup
+ if (defined? @md.make.italics[:str] \
+ and @md.make.italics[:str]) \
+ or (defined? @vz.markup_make_italic[:str] \
+ and @vz.markup_make_italic[:str])
+ dob.obj=if dob.is !~/^(?:meta|heading|code|comment)/
+ word=dob.obj.scan(@line_scan_ital)
+ word.flatten!
+ word.compact! #reinstated
+ line_array=[]
+ word.each do |w|
+ unless /#{@manmkp_ital}|#{@http_m}/.match(w)
+ if defined? @md.make.italics[:regx] \
+ and @md.make.italics[:regx]
+ w.gsub!(@md.make.italics[:regx],
+ "#{Mx[:fa_italics_o]}\\1#{Mx[:fa_italics_c]}")
+ elsif defined? @vz.markup_make_italic \
+ and @vz.markup_make_italic
+ w.gsub!(@vz.markup_make_italic,
+ "#{Mx[:fa_italics_o]}\\1#{Mx[:fa_italics_c]}")
+ else w
+ end
+ end
+ line_array << w
+ end
+ line_array.join(' ')
+ else dob.obj
+ end
+ end
+ dob
+ end
+ def embolden(given)
+ given.gsub!(/^!_\s+((?:\{|#{Mx[:lnk_o]})(?:~^ )?.+?(?:\}|#{Mx[:lnk_o]})https?:\/\/\S+.*?)([#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}])/,
+ "#{Mx[:fa_bold_o]} \\1 #{Mx[:fa_bold_c]}\\2")
+ given.gsub!(/^!_\s+((?:\{|#{Mx[:lnk_o]})(?:~^ )?.+?(?:\}|#{Mx[:lnk_o]})https?:\/\/\S+.*)/,
+ "#{Mx[:fa_bold_o]} \\1 #{Mx[:fa_bold_c]}")
+ given.gsub!(/(?:^!_|^#{Mx[:lv_o]}[7-9]:\S*?#{Mx[:lv_c]})\s*(.+?)([#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}])/,
+ "#{Mx[:fa_bold_o]}\\1#{Mx[:fa_bold_c]}\\2")
+ given.gsub!(/(?:^!_|^#{Mx[:lv_o]}[7-9]:\S*?#{Mx[:lv_c]})\s*(.+?)\s+((?:[*]~\S+\s*)+)/,
+ "#{Mx[:fa_bold_o]}\\1#{Mx[:fa_bold_c]}\\2")
+ given.gsub!(/(?:^!_|^#{Mx[:lv_o]}[7-9]:\S*?#{Mx[:lv_c]})\s*(.+?)\s*([~-]#)$/,
+ "#{Mx[:fa_bold_o]}\\1#{Mx[:fa_bold_c]}\\2")
+ given.gsub!(/(?:^!_\s+|^#{Mx[:lv_o]}[7-9]:\S*?#{Mx[:lv_c]}\s*)(.*)?\s*$/,
+ "#{Mx[:fa_bold_o]}\\1#{Mx[:fa_bold_c]}")
+ end
+ def italicise(given)
+ given.gsub!(/^\/_\s*(.+?)([#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}])/,
+ "#{Mx[:fa_italics_o]}\\1#{Mx[:fa_italics_c]}\\2")
+ given.gsub!(/^\/_\s*(.+?)\s+((?:[*]~\S+\s*)+)/,
+ "#{Mx[:fa_italics_o]}\\1#{Mx[:fa_italics_c]}\\2")
+ given.gsub!(/^\/_\s*(.+?)\s*([~-]#)$/,
+ "#{Mx[:fa_italics_o]}\\1#{Mx[:fa_italics_c]}\\2")
+ given.gsub!(/^\/_\s+(.*)?\s*$/,
+ "#{Mx[:fa_italics_o]}\\1#{Mx[:fa_italics_c]}")
+ end
+ def wordlist_bold(dob)
+ dob=dob.dup
+ if (defined? @md.make.bold[:str] \
+ and @md.make.bold[:str]) \
+ or (defined? @vz.markup_make_bold[:str] \
+ and @vz.markup_make_bold[:str])
+ dob.obj=if dob.is !~/^(?:meta|heading|code|comment|table)/
+ line_array=[]
+ word=dob.obj.scan(@line_scan_bold)
+ word.flatten!
+ word.compact!
+ word.each do |w|
+ unless /#{@manmkp_bold}|#{@http_m}/.match(w)
+ if defined? @md.make.bold[:regx] \
+ and @md.make.bold[:regx] #document header: @bold: [bold word list]
+ w.gsub!(@md.make.bold[:regx],"#{Mx[:fa_bold_o]}\\1#{Mx[:fa_bold_c]}")
+ elsif defined? @vz.markup_make_bold \
+ and @vz.markup_make_bold #defaults and skin adjusted bold word list
+ w.gsub!(@vz.markup_make_bold,"#{Mx[:fa_bold_o]}\\1#{Mx[:fa_bold_c]}")
+ end
+ else
+ if w =~ /(?:^!_|^#{Mx[:lv_o]}[7-9]:\S*?#{Mx[:lv_c]})\s+/; embolden(w) #bold paragraph/emphasize #may wish to remove think about 7{ 8{ conversion not satisfactory, as information is lost!
+ elsif w =~/^\/_\s+/; italicise(w)
+ else w
+ end
+ end
+ line_array << w
+ end
+ line_array.join(' ')
+ else dob.obj
+ end
+ else
+ if dob.is !~/^(?:heading|comment|meta)/ \
+ and dob.obj =~ /^!_\s+/
+ embolden(dob.obj)
+ elsif dob.is=='heading' \
+ and dob.ln.to_s =~/[7-9]/
+ embolden(dob.obj)
+ end
+ if dob.obj =~ /\/_\s+/
+ italicise(dob.obj)
+ end
+ end
+ dob
+ end
+ def fontface(dob)
+ dob.obj.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|#{Mx[:lnk_o]}|#{Mx[:br_line]}|#{Mx[:br_paragraph]}|[\(\[\{]|\>)\*\{(.+?)\}\*/m,
+ "\\1#{@emph[:o]}\\2#{@emph[:c]}") #emphasis
+ dob.obj.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|#{Mx[:lnk_o]}|#{Mx[:br_line]}|#{Mx[:br_paragraph]}|[\(\[\{]|\>)!\{(.+?)\}!/m,
+ "\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}") #bold
+ dob.obj.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|#{Mx[:lnk_o]}|#{Mx[:br_line]}|#{Mx[:br_paragraph]}|[\(\[\{]|\(|\>)\/\{(.+?)\}\//m,
+ "\\1#{Mx[:fa_italics_o]}\\2#{Mx[:fa_italics_c]}") #italics
+ dob.obj.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|#{Mx[:lnk_o]}|#{Mx[:br_line]}|#{Mx[:br_paragraph]}|[\(\[\{]|\>)_\{(.+?)\}_/m,
+ "\\1#{Mx[:fa_underscore_o]}\\2#{Mx[:fa_underscore_c]}") #underscore
+ dob.obj.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|#{Mx[:lnk_o]}|#{Mx[:br_line]}|#{Mx[:br_paragraph]}|[\(\[\{]|\>)#\{(.+?)\}#/m,
+ "\\1#{Mx[:fa_monospace_o]}\\2#{Mx[:fa_monospace_c]}") #monospace
+ dob.obj.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\"\{(.+?)\}\"/m,
+ "\\1#{Mx[:fa_cite_o]}\\2#{Mx[:fa_c_o]}cite#{Mx[:fa_c]}") #cite /blockquote?
+ dob.obj.gsub!(/(^|[^\\])\^\{(.+?)\}\^/m,
+ "\\1#{Mx[:fa_superscript_o]}\\2#{Mx[:fa_superscript_c]}") #superscript
+ dob.obj.gsub!(/(^|[^\\]),\{(.+?)\},/m,
+ "\\1#{Mx[:fa_subscript_o]}\\2#{Mx[:fa_subscript_c]}") #subscript
+ dob.obj.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\+\{(.+?)\}\+/m,
+ "\\1#{Mx[:fa_insert_o]}\\2#{Mx[:fa_insert_c]}") #inserted text
+ dob.obj.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)-\{(.+?)\}-/m,
+ "\\1#{Mx[:fa_strike_o]}\\2#{Mx[:fa_strike_c]}") #strikethrough - deleted text
+ dob.obj.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>|\d+)\^(\S+?)\^/,
+ "\\1#{Mx[:fa_superscript_o]}\\2#{Mx[:fa_superscript_c]}") #superscript single word, watch digit added
+ dob
+ end
+ def bodymarkup(dob)
+ # << http://www.jus.uio.no/sisu/sisu_markup_table/markup >>
+ # See: data/sisu/sample/document_samples_sisu_markup/
+ ## fontface
+ # *{emphasis}* e{emphasis}e emphasis
+ # !{bold text}! b{bold}b bold text
+ # _{underline}_ u{underline}u underline
+ # /{italics}/ i{italics}i italics
+ # "{citation}" c{citation}c citation #blockquote?
+ # ^{superscript}^ superscript
+ # ,{subscript}, subscript
+ # +{inserted text}+ inserted text
+ # -{deleted text}- deleted text
+ # #{monospace text}#
+ #
+ # {url address}:url
+ # {image.png}imageurl
+ # {image.png}png
+ # ~{endnote}~
+ # !_ #bold/emphasise paragraph
+ # _" #blockquote paragraph
+ # _1 <:i1> #indent paragraph 1 step
+ # _2 <:i2> #indent paragraph 2 steps
+ # _3 <:i3> #indent paragraph 3 steps
+ # _4 <:i4> #indent paragraph 4 steps
+ # _* #bullet (list) ●
+ # _1* #bullet (list) indented
+ # _1* #bullet (list) indented
+ # # #numbered (list) level 1
+ # _# #numbered (list) level 2
+ dob=dob.dup
+ if dob.is !~/^(?:meta|comment|code|table)/
+ line_array=[]
+ word=dob.obj.scan(/\S+|\n/) #unless line =~/^(?:#{Mx[:meta_o]}|%+\s)/ #visit
+ if word
+ word.each do |w| # _ - / # | : ! ^ ~
+ unless w =~/~\{|\}~|~\[|\]~|^\^~|~\^|\*~\S+|~#|\{t?~|\{table|https?:\/\/\S+/ # do something earlier about table!!
+ w.gsub!(/\\?~/,"#{Mx[:gl_o]}#126#{Mx[:gl_c]}") #escaped special character
+ end
+ w.gsub!(/^\<$/,"#{Mx[:gl_o]}#lt#{Mx[:gl_c]}") #escaped special character
+ w.gsub!(/^\>$/,"#{Mx[:gl_o]}#gt#{Mx[:gl_c]}") #escaped special character
+ line_array << w
+ end
+ dob.obj=line_array.join(' ')
+ dob.obj=dob.obj.strip
+ end
+ dob.obj.gsub!(/^([*#-.]{1,12})$/,'\1 ~#') #ocn off for these paragraph separators
+ dob.obj.gsub!(/~\{(.+?)\}~/m,Mx[:en_a_o] + '\1' + Mx[:en_a_c])
+ dob.obj.gsub!(/~\[([^*+].+?)\]~/m,Mx[:en_b_o] + '* \1' + Mx[:en_b_c]) #default if markup does not specify
+ dob.obj.gsub!(/~\[(.+?)\]~/m,Mx[:en_b_o] + '\1' + Mx[:en_b_c])
+ if dob.is =='heading' \
+ and dob.ln ==1
+ dob.obj.gsub!(/\s*@title\b/," #{@md.title.full}")
+ if defined? @md.creator.author \
+ and @md.creator.author
+ dob.obj.gsub!(/\s+(?:@creator|@author)/,",#{Mx[:br_line]}#{@md.creator.author}")
+ else dob.obj.gsub!(/\s+(?:@creator|@author)/,'')
+ end
+ end
+ if defined? @md.title \
+ and @md.title \
+ and defined? @md.title.full \
+ and defined? @md.creator \
+ and @md.creator
+ if dob.is =='heading'
+ dob.obj.gsub!(/^\s*@title\s*$/,@md.title.full) if dob.lv =~/1/
+ if dob.lv =~/[23]/ \
+ and defined? @md.creator.author \
+ and @md.creator.author
+ dob.obj.gsub!(/^\s*(?:(by\s+)?(?:@creator|@author))\s*$/,"\\1#{@md.creator.author}")
+ else dob.obj.gsub!(/^\s*(?:(by\s+)?(?:@creator|@author))\s*$/,'\1')
+ end
+ end
+ end
+ dob.obj.gsub!(/<(https?:\/\/\S+?)>/,'< \1 >') #catch problem markup
+ dob.obj.gsub!(/<:=(\S+?)>/,'{ c_\1.png 14x14 }image')
+ dob.obj.gsub!(//,'<:\1>') #escaped special character
+ dob.obj.gsub!(/ /,"#{Mx[:nbsp]}") #escaped special character
+ dob.obj.gsub!(/\\~/,"#{Mx[:gl_o]}#126#{Mx[:gl_c]}") #escaped special character
+ dob.obj.gsub!(/\\\{/,"#{Mx[:gl_o]}#123#{Mx[:gl_c]}") #escaped special character
+ dob.obj.gsub!(/\\\}/,"#{Mx[:gl_o]}#125#{Mx[:gl_c]}") #escaped special character
+ dob.obj.gsub!(/\\\<,"#{Mx[:gl_o]}#lt#{Mx[:gl_c]}#{Mx[:gl_o]}#lt#{Mx[:gl_c]}") #escaped special character
+ dob.obj.gsub!(/\\\>>/,"#{Mx[:gl_o]}#gt#{Mx[:gl_c]}#{Mx[:gl_o]}#gt#{Mx[:gl_c]}") #escaped special character
+ dob.obj.gsub!(/\\\,"#{Mx[:gl_o]}#lt#{Mx[:gl_c]}") #escaped special character
+ dob.obj.gsub!(/\\\>/,"#{Mx[:gl_o]}#gt#{Mx[:gl_c]}") #escaped special character
+ dob.obj.gsub!(/\\\_/,"#{Mx[:gl_o]}#095#{Mx[:gl_c]}") #escaped special character
+ dob.obj.gsub!(/\\\-/,"#{Mx[:gl_o]}#045#{Mx[:gl_c]}") #escaped special character
+ dob.obj.gsub!(/\\\+/,"#{Mx[:gl_o]}#043#{Mx[:gl_c]}") #escaped special character
+ dob.obj.gsub!(/\\\//,"#{Mx[:gl_o]}#047#{Mx[:gl_c]}") #escaped special character
+ dob.obj.gsub!(/\\\#/,"#{Mx[:gl_o]}#035#{Mx[:gl_c]}") #escaped special character
+ dob.obj.gsub!(/\\\&/,"#{Mx[:gl_o]}#038#{Mx[:gl_c]}") #& #escaped special character
+ dob.obj.gsub!(/\\\|/,"#{Mx[:gl_o]}#124#{Mx[:gl_c]}") #not really a sisu special character but made available as possibility
+ dob.obj.gsub!(/\\\:/,"#{Mx[:gl_o]}#058#{Mx[:gl_c]}") #not really a sisu special character but made available as possibility
+ dob.obj.gsub!(/\\\!/,"#{Mx[:gl_o]}#033#{Mx[:gl_c]}") #not really a sisu special character but made available as possibility
+ dob.obj.gsub!(/\\\^/,"#{Mx[:gl_o]}#094#{Mx[:gl_c]}") #not really a sisu special character but made available as possibility
+ dob.obj.gsub!(/\\\,/,"#{Mx[:gl_o]}#044#{Mx[:gl_c]}") #not really a sisu special character but made available as possibility
+ dob.obj.gsub!(/\\\\/,"#{Mx[:gl_o]}#092#{Mx[:gl_c]}") #escaped special character
+ dob.obj.gsub!(/\\\*/,"#{Mx[:gl_o]}#042#{Mx[:gl_c]}") #escaped special character
+ dob.obj.gsub!(/\\\!/,"#{Mx[:gl_o]}#033#{Mx[:gl_c]}") #escaped special character
+ if dob.obj=~/(?:https?:|ftp:|\{([^{}]+?)\}(?:#|:|[.]{1,2}\/))\S+/m
+ if dob.obj=~/(?:^|[#{Mx[:gl_c]}#{Mx[:nbsp]} ])\{~\^ (?:.+?)\s*\}(?:(?:https?:|ftp:|:|[.]{1,2}\/)\S+?)\s*#{Mx[:en_a_o]}(.+?)#{Mx[:en_a_c]}/m
+ dob.obj.gsub!(/(^|[#{Mx[:gl_c]}#{Mx[:nbsp]} ])\{~\^ ([^}]+?)\s*\}((?:https?:|ftp:|:|[.]{1,2}\/)\S+?)\s*#{Mx[:en_a_o]}(.+?)#{Mx[:en_a_c]}/m,
+ "\\1#{Mx[:lnk_o]}\\2#{Mx[:lnk_c]}\\3 #{Mx[:en_a_o]}\\3 \\4#{Mx[:en_a_c]}") # watch
+ end
+ if dob.obj=~/(?:^|[#{Mx[:gl_c]}#{Mx[:nbsp]} ])\{~\^ (?:.+?)\s*\}(?:(?:https?:|ftp:|:|[.]{1,2}\/)\S+?)([;,.]?)(?=\s|[#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}]|$)/m
+ dob.obj.gsub!(/(^|[#{Mx[:gl_c]}#{Mx[:nbsp]} ])\{~\^ (.+?)\s*\}((?:https?:|ftp:|:|[.]{1,2}\/)\S+?)([;,.]?)(?=\s|[#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}]|$)/m,
+ "\\1#{Mx[:lnk_o]}\\2#{Mx[:lnk_c]}\\3\\4 #{Mx[:en_a_o]}\\3#{Mx[:en_a_c]} ")
+ end
+ dob.obj.gsub!(/(^|[^#])\{\s*([^{}]+?)\s*\}((?:https?:|:|[.]{2}\/|#)\S+?)(?=\s|[#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}#{Mx[:en_a_o]}#{Mx[:en_b_o]}]|$)/,
+ "\\1#{Mx[:lnk_o]}\\2#{Mx[:lnk_c]}\\3") #linked (text or image, however text cannot include modified face, e.g. bold, ital, underline)
+ dob.obj.gsub!(/(^|[#{Mx[:gl_c]}#{Mx[:lnk_c]}#{Mx[:en_a_o]}#{Mx[:en_b_o]}(\s])((?:https?|ftp):\/\/\S+?\.[^>< ]+?)([,.;'"]?)(?=[\s#{Mx[:en_a_c]}#{Mx[:en_b_c]}#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}]|$)/m,
+ %{\\1#{Mx[:url_o]}\\2#{Mx[:url_c]}\\3})
+ dob.obj.gsub!(/#{Mx[:lnk_c]}#(\S+?[^>< ]+?)([()\[\]]*[,.;:!?'"]{0,2})(?=[\s#{Mx[:en_a_c]}#{Mx[:en_b_c]}#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}]|$)/m,
+ %{#{Mx[:lnk_c]}#{Mx[:rel_o]}\\1#{Mx[:rel_c]}\\2})
+ dob.obj.gsub!(/#{Mx[:lnk_c]}:(\S+?[^>< ]+?)([()\[\]]*[,.;:!?'"]{0,2})(?=[\s#{Mx[:en_a_c]}#{Mx[:en_b_c]}#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}]|$)/m,
+ %{#{Mx[:lnk_c]}#{Mx[:rel_o]}:\\1#{Mx[:rel_c]}\\2})
+ dob.obj.gsub!(/#{Mx[:lnk_c]}[.]{2}\/(\S+?[^>< ]+?)([()\[\]]*[,.;:!?'"]{0,2})(?=[\s#{Mx[:en_a_c]}#{Mx[:en_b_c]}#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}]|$)/m,
+ %{#{Mx[:lnk_c]}#{Mx[:rel_o]}:\\1#{Mx[:rel_c]}\\2})
+ end
+ if dob.obj=~/_(?:https?|ftp):\S+/m # _http://url #CHECK
+ dob.obj.gsub!(/(^|[#{Mx[:gl_c]}#{Mx[:lnk_c]}#{Mx[:en_a_o]}#{Mx[:en_b_o]}(\s])(_(?:https?|ftp):\/\/\S+?\.[^>< ]+?)([,.;'"]?)(?=[\s#{Mx[:en_a_c]}#{Mx[:en_b_c]}#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}]|$)/m,
+ %{\\1#{Mx[:url_o]}\\2#{Mx[:url_c]}\\3})
+ end
+ dob=fontface(dob)
+ dob.obj.gsub!(/<[:e]\s+(.+?)!?>/,
+ "#{Mx[:en_a_o]}\\1#{Mx[:en_a_c]}") #not tested
+ dob.obj.gsub!(/^\s*_\*\s*/,
+ "#{Mx[:gl_bullet]}") #bullets, shortcut
+ dob.obj.gsub!(/=\{(.+?)\}/,
+ "#{Mx[:idx_o]}\\1#{Mx[:idx_c]}")
+ dob.obj.gsub!(/^\s*_([1-9])\*\s*/,
+ "#{Mx[:pa_o]}:i\\1:\\1#{Mx[:pa_c]}#{Mx[:gl_bullet]}") #bullets, shortcut
+ dob.obj.gsub!(/^\s*_([1-9])\s+/,
+ "#{Mx[:pa_o]}:i\\1:\\1#{Mx[:pa_c]}") #indent
+ dob.obj.gsub!(/^\s*_([1-9])!\s+(.+?)\s*$/,
+ "#{Mx[:pa_o]}:i\\1:\\1#{Mx[:pa_c]}#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]} ") #indent bold
+ dob.obj.gsub!(/^\s*__([1-9])\s+/,
+ "#{Mx[:pa_o]}:i0:\\1#{Mx[:pa_c]}") #hang
+ dob.obj.gsub!(/^\s*__([1-9])!\s+(.+?)\s*$/,
+ "#{Mx[:pa_o]}:i0:\\1#{Mx[:pa_c]}#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]} ") #hangdef
+ dob.obj.gsub!(/^\s*_([0-9])_([0-9])\s+/,
+ "#{Mx[:pa_o]}:i\\1:\\2#{Mx[:pa_c]}") #hang
+ dob.obj.gsub!(/^\s*_([0-9])_([0-9])!\s+(.+?)\s*$/,
+ "#{Mx[:pa_o]}:i\\1:\\2#{Mx[:pa_c]}#{Mx[:fa_bold_o]}\\3#{Mx[:fa_bold_c]} ") #hangdef
+ dob.obj.gsub!(/<:hi>/,"#{Mx[:fa_hilite_o]}") #'') # bright yellow rgb(255,255,0) pale yellow rgb(255,255,200)
+ dob.obj.gsub!(/<:\/hi>/,"#{Mx[:fa_hilite_c]}") #'')
+ dob.obj.gsub!(/(#{Mx[:gr_o]}verse#{Mx[:gr_c]}.+)/m,"\\1\n")
+ dob.obj.gsub!(/[ ]+($)/,'\1')
+ dob.obj.gsub!(/\{\s*(.+?)\s*\}(https?:\S+?)([;,.]?)(?=\s|[#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}#{Mx[:en_a_o]}#{Mx[:en_b_o]}]|$)/,
+ "#{Mx[:lnk_o]}\\1#{Mx[:lnk_c]}#{Mx[:url_o]}\\2#{Mx[:url_c]}\\3") #any remaining linked text or image
+ dob.obj.gsub!(/\{\s*(.+?)\s*\}(#{Mx[:url_o]}\S+?#{Mx[:url_c]})/,
+ "#{Mx[:lnk_o]}\\1#{Mx[:lnk_c]}\\2") #any remaining linked text or image
+ dob.obj.gsub!(/(^|\s)([a-zA-Z0-9._-]+\@\S+?\.[a-zA-Z0-9._-]+)/,"\\1#{Mx[:url_o]}\\2#{Mx[:url_c]}")
+ dob.obj.gsub!(/(^|[ ])\{\s*(.+?)\s*\}(\S+?)([;,.]?)(?=\s|[#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}#{Mx[:en_a_o]}#{Mx[:en_b_o]}]|$)/,
+ "\\1#{Mx[:lnk_o]}\\2#{Mx[:lnk_c]}\\3\\4") #any remaining linked text or image
+ dob.obj.gsub!(/\{\s*(.+?)\s*\}#([a-zA-Z0-9][a-zA-Z0-9_-]*)([;,.]?)(?=\s|[#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}#{Mx[:en_a_o]}#{Mx[:en_b_o]}]|$)/,
+ "#{Mx[:lnk_o]}\\1#{Mx[:lnk_c]}#{Mx[:rel_o]}\\2#{Mx[:rel_c]}\\3") #any remaining linked text or image, check need
+ dob.obj.gsub!(/\{\s*(.+?)\s*\}(#{Mx[:rel_o]}\S+?#{Mx[:rel_c]})/,
+ "#{Mx[:lnk_o]}\\1#{Mx[:lnk_c]}\\2") #any remaining linked text or image, check need
+ dob.obj.gsub!(/\{\s*(.+?)\s*\}(image)/,
+ "#{Mx[:lnk_o]}\\1#{Mx[:lnk_c]}\\2") #linked image
+ elsif dob.is=='table'
+ dob=fontface(dob)
+ elsif dob.is =='code'
+ dob.obj.gsub!(/#{Mx[:meta_o]}(\S+?)#{Mx[:meta_c]}\s*/,'@\1: ')
+ dob.obj.gsub!(/(^|#{Mx[:gl_c]}|\s)<(br(?: \/)?)>([\s,.]|$)/,'\1<\2>\3') #convert
back, clumsy
+ if dob.number_
+ codeline=[]
+ ln=1
+ dob.obj.split(/#{Mx[:gr_o]}codeline#{Mx[:gr_c]}| |\n/).each_with_index do |cl,i|
+ unless i == 0
+ cl.gsub!(Mx[:br_nl],'')
+ w=3-ln.to_s.length
+ cl = "#{ln}#{Mx[:nbsp]*w}#{Mx[:vline]}#{cl}#{Mx[:br_nl]}"
+ ln +=1
+ end
+ codeline << cl
+ end
+ codeline= codeline.join("")
+ dob.obj=codeline
+ else
+ dob.obj.gsub!(/#{Mx[:gr_o]}codeline#{Mx[:gr_c]}/,"\n")
+ end
+ dob
+ else # @\S+?:
+ end
+ dob
+ end
+ def tech #script markup planned to be more strict for technical documents
+ # *{emphasis}* e{emphasis}e emphasis
+ # !{bold text}! b{bold}b bold text
+ # _{underline}_ u{underline}u underline
+ # /{italics}/ i{italics}i italics
+ # "{citation}" c{citation}c citation
+ # ^{superscript}^ superscript
+ # ,{subscript}, subscript
+ # +{inserted text}+ inserted text
+ # -{deleted text}- deleted text
+ # #{monospace text}#
+ # {url address}:url
+ # {image.png}imageurl
+ # {image.png}png
+ # ~{endnote}~
+ # +1
+ # +2
+ puts 'tech'
+ @data.each do |line|
+ line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\>)e\{(.+?)\}e/,
+ "\\1#{@emph[:o]}\\2#{@emph[:c]}") #emphasis
+ line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\>)b\{(.+?)\}b/,
+ "\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}") #bold
+ line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\>)u\{(.+?)\}u/,
+ "\\1#{Mx[:fa_underscore_o]}\\2#{Mx[:fa_underscore_c]}") #underscore
+ line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\>)c\{(.+?)\}c/,
+ "\\1#{Mx[:fa_cite_o]}\\2#{Mx[:fa_c_o]}cite#{Mx[:fa_c]}") #cite
+ line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\>)i\{(.+?)\}i/,
+ "\\1#{Mx[:fa_italics_o]}\\2#{Mx[:fa_italics_c]}") #italics
+ line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\>)!\{(.+?)\}!/,
+ "\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}") #bold
+ line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\>)\*\{(.+?)\}\*/,
+ "\\1#{@emph[:o]}\\2#{@emph[:c]}") #emphasis
+ line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\>)_\{(.+?)\}_/,
+ "\\1#{Mx[:fa_underscore_o]}\\2#{Mx[:fa_underscore_c]}") #underscore
+ line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\(|\>)\/\{(.+?)\}\//,
+ "\\1#{Mx[:fa_italics_o]}\\2#{Mx[:fa_italics_c]}") #italics
+ line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\"\{(.+?)\}\"/,
+ "\\1#{Mx[:fa_cite_o]}\\2#{Mx[:fa_c_o]}cite#{Mx[:fa_c]}")
+ line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\^\{(.+?)\}\^/,
+ "\\1#{Mx[:fa_superscript_o]}\\2#{Mx[:fa_superscript_c]}")
+ line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)9\{(.+?)\}9/,
+ "\\1#{Mx[:fa_superscript_o]}\\2#{Mx[:fa_superscript_c]}")
+ line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>),\{(.+?)\},/,
+ "\\1#{Mx[:fa_subscript_o]}\\2#{Mx[:fa_subscript_c]}")
+ line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)6\{(.+?)\}6/,
+ "\\1#{Mx[:fa_subscript_o]}\\2#{Mx[:fa_subscript_c]}")
+ line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\+\{(.+?)\}\+/,
+ "\\1#{Mx[:fa_insert_o]}\\2#{Mx[:fa_insert_c]}")
+ line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)v\{(.+?)\}v/,
+ "\\1#{Mx[:fa_insert_o]}\\2#{Mx[:fa_insert_c]}")
+ line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)-\{(.+?)\}-/,
+ "\\1#{Mx[:fa_strike_o]}\\2#{Mx[:fa_strike_c]}")
+ line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)x\{(.+?)\}x/,
+ "\\1#{Mx[:fa_strike_o]}\\2#{Mx[:fa_strike_c]}")
+ line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\*(\S+?)\*/,
+ "\\1#{@emph[:o]}\\2#{@emph[:c]}") #emphasise single word, watch
+ line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\!(\S+?)\!/,
+ "\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}") #bold single word, watch
+ line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\/([\(\)a-zA-Z0-9']+?)\/([ ,.;:'"~$]|[^a-zA-Z0-9])/,
+ "\\1#{Mx[:fa_italics_o]}\\2#{Mx[:fa_italics_c]}\\3") #italics single word, watch
+ line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)_(\S+?)_/,
+ "\\1#{Mx[:fa_underscore_o]}\\2#{Mx[:fa_underscore_c]}") #underscore single word, watch
+ line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\^(\S+?)\^/,
+ "\\1#{Mx[:fa_superscript_o]}\\2#{Mx[:fa_superscript_c]}") #check #superscript single word, watch digit added
+ line.gsub!(/^\s*_\([1-9]\)\(\*\+\)\s*/,
+ "#{Mx[:pa_o]}:i\\1#{Mx[:pa_c]}#{Mx[:fa_o]}\\2#{Mx[:fa_c_o]}") #bullets, shortcut
+ line.gsub!(/^\s*_\([1-9]\)\s+/,
+ "#{Mx[:pa_o]}:i\\1#{Mx[:pa_c]}") #watch
+ line.gsub!(/^\s*__\([1-9]\)\s+/,
+ "#{Mx[:pa_o]}:h\\1#{Mx[:pa_c]}") #watch
+ #line.gsub!(/^\s*__\([1-9]\)!\s+/,
+ # "#{Mx[:pa_o]}:hd\\1#{Mx[:pa_c]}") #watch
+ line.gsub!(/#{Mx[:br_line]}\s*_[12]\s+/,
+ "#{Mx[:br_line]} ") #indent used in endnotes, not implemented, replace when ready with: line.gsub!(/(?: | )\s*_([12])\s+/,' <:i\1> ')
+ end
+ @data
+ end
+ end
+end
+__END__
diff --git a/lib/sisu/v3dv/db_columns.rb b/lib/sisu/v3dv/db_columns.rb
new file mode 100644
index 00000000..10b9635f
--- /dev/null
+++ b/lib/sisu/v3dv/db_columns.rb
@@ -0,0 +1,2108 @@
+# encoding: utf-8
+=begin
+
+ * Name: SiSU
+
+ * Description: a framework for document structuring, publishing and search
+
+ * Author: Ralph Amissah
+
+ * Copyright: (C) 1997 - 2012, 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 .
+
+ If you have Internet connection, the latest version of the GPL should be
+ available at these locations:
+
+
+
+
+
+
+
+ * SiSU uses:
+ * Standard SiSU markup syntax,
+ * Standard SiSU meta-markup syntax, and the
+ * Standard SiSU object citation numbering and system
+
+ * Hompages:
+
+
+
+ * Download:
+
+
+ * Ralph Amissah
+
+
+
+ ** Description: modules shared by the different db types, dbi, postgresql,
+ sqlite
+
+=end
+module SiSU_DB_columns
+ require_relative 'sysenv' # sysenv.rb
+ require_relative 'db_sqltxt' # db_sqltxt.rb
+ class Columns < SiSU_DB_text::Prepare
+ def initialize(md=nil)
+ @md=md
+ @db=SiSU_Env::Info_db.new #watch
+ @lang ||=SiSU_i18n::Languages.new
+ if defined? md.opt.mod \
+ and md.opt.mod.inspect=~/import|update/ \
+ and FileTest.exist?(md.fns)
+ txt_arr=IO.readlines(md.fns,'')
+ src=txt_arr.join("\n")
+ if @db.share_source?
+ @sisutxt=special_character_escape(src)
+ else @sisutxt=''
+ end
+ @fulltext=clean_searchable_text(txt_arr)
+ else @sisutxt,@fulltext='',''
+ end
+ end
+#% structures
+ #def column_define
+ # def varchar(name,size)
+ # "#{name} VARCHAR(#{size}) NULL,"
+ # end
+ #end
+=begin
+#% title
+@title:
+ :subtitle:
+ :short:
+ :edition:
+ :language:
+ :note:
+=end
+ def column
+ def title # DublinCore 1 - title
+ def name
+ 'title'
+ end
+ def create_column
+ "#{name} VARCHAR(#{Db[:col_title]}) NOT NULL,"
+ end
+ def column_comment
+ %{COMMENT ON COLUMN metadata_and_text.#{name}
+ IS 'metadata full document title [DC1]';}
+ end
+ def tuple
+ t=if defined? @md.title.full \
+ and @md.title.full=~/\S+/
+ txt=@md.title.full
+ special_character_escape(txt)
+ ["#{name}, ","'#{txt}', "]
+ else ['','']
+ end
+ end
+ self
+ end
+ def title_main
+ def name
+ 'title_main'
+ end
+ def create_column
+ "#{name} VARCHAR(#{Db[:col_title_part]}) NOT NULL,"
+ end
+ def column_comment
+ %{COMMENT ON COLUMN metadata_and_text.#{name}
+ IS 'metadata main document title';}
+ end
+ def tuple
+ t=if defined? @md.title.main \
+ and @md.title.main=~/\S+/
+ txt=@md.title.main
+ special_character_escape(txt)
+ ["#{name}, ","'#{txt}', "]
+ else ['','']
+ end
+ end
+ self
+ end
+ def title_sub
+ def name
+ 'title_sub'
+ end
+ def create_column
+ "#{name} VARCHAR(#{Db[:col_title_part]}) NULL,"
+ end
+ def column_comment
+ %{COMMENT ON COLUMN metadata_and_text.#{name}
+ IS 'metadata document subtitle';}
+ end
+ def tuple
+ t=if defined? @md.title.sub \
+ and @md.title.sub=~/\S+/
+ txt=@md.title.sub
+ special_character_escape(txt)
+ ["#{name}, ","'#{txt}', "]
+ else ['','']
+ end
+ end
+ self
+ end
+ def title_short
+ def name
+ 'title_short'
+ end
+ def create_column
+ "#{name} VARCHAR(#{Db[:col_title_part]}) NULL,"
+ end
+ def column_comment
+ %{COMMENT ON COLUMN metadata_and_text.#{name}
+ IS 'metadata document short title if any';}
+ end
+ def tuple
+ t=if defined? @md.title.short \
+ and @md.title.short=~/\S+/
+ txt=@md.title.short
+ special_character_escape(txt)
+ ["#{name}, ","'#{txt}', "]
+ else ['','']
+ end
+ end
+ self
+ end
+ def title_edition
+ def name
+ 'title_edition'
+ end
+ def create_column
+ "#{name} VARCHAR(#{Db[:col_title_edition]}) NULL,"
+ end
+ def column_comment
+ %{COMMENT ON COLUMN metadata_and_text.#{name}
+ IS 'metadata document edition (version)';}
+ end
+ def tuple
+ t=if defined? @md.title.edition \
+ and @md.title.edition=~/\S+/
+ txt=@md.title.edition
+ special_character_escape(txt)
+ ["#{name}, ","'#{txt}', "]
+ else ['','']
+ end
+ end
+ self
+ end
+ def title_note
+ def name
+ 'title_note'
+ end
+ def create_column
+ "#{name} VARCHAR(#{Db[:col_info_note]}) NULL,"
+ end
+ def column_comment
+ %{COMMENT ON COLUMN metadata_and_text.#{name}
+ IS 'metadata document notes associated with title';}
+ end
+ def tuple
+ t=if defined? @md.title.note \
+ and @md.title.note=~/\S+/
+ txt=@md.title.note
+ special_character_escape(txt)
+ ["#{name}, ","'#{txt}', "]
+ else ['','']
+ end
+ end
+ self
+ end
+ def title_language
+ def name
+ 'title_language'
+ end
+ def create_column
+ "#{name} VARCHAR(#{Db[:col_language]}) NULL,"
+ end
+ def column_comment
+ %{COMMENT ON COLUMN metadata_and_text.#{name}
+ IS 'metadata document language [DC12]';}
+ end
+ def tuple
+ t=if @lang.list[@md.opt.lng][:n]
+ txt=@lang.list[@md.opt.lng][:n]
+ special_character_escape(txt)
+ ["#{name}, ","'#{txt}', "]
+ else ['','']
+ end
+ end
+ self
+ end
+ def title_language_char # consider
+ def name
+ 'title_language_char'
+ end
+ def create_column
+ "#{name} VARCHAR(#{Db[:col_language_char]}) NULL,"
+ end
+ def column_comment
+ %{COMMENT ON COLUMN metadata_and_text.#{name}
+ IS 'metadata document language iso code';}
+ end
+ def tuple
+ t=if defined? @md.opt.lng \
+ and @md.opt.lng=~/\S+/
+ txt=@md.opt.lng
+ special_character_escape(txt)
+ ["#{name}, ","'#{txt}', "]
+ else ['','']
+ end
+ end
+ self
+ end
+=begin
+#% creator
+@creator:
+ :author:
+ :editor:
+ :contributor:
+ :illustrator:
+ :photographer:
+ :translator:
+ :prepared_by:
+ :digitized_by:
+ :audio:
+ :video:
+=end
+ def creator_author # DublinCore 2 - creator/author (author)
+ def name
+ 'creator_author'
+ end
+ def create_column
+ "#{name} VARCHAR(#{Db[:col_name]}) NULL,"
+ end
+ def column_comment
+ %{COMMENT ON COLUMN metadata_and_text.#{name}
+ IS 'metadata document author (creator) [DC2]';}
+ end
+ def tuple
+ t=if defined? @md.creator.author_detail \
+ and @md.creator.author_detail.class==Array \
+ and @md.creator.author_detail.length > 0
+ txt=''
+ @md.creator.author_detail.each do |h|
+ txt=txt + %{#{h[:the]}, #{h[:others]}; }
+ end
+ txt.gsub!(/[;, ]+\s*$/,'')
+ special_character_escape(txt)
+ ["#{name}, ","'#{txt}', "]
+ else ['','']
+ end
+ end
+ self
+ end
+ def creator_author_honorific # consider
+ def name
+ 'creator_author_hon'
+ end
+ def create_column
+ "#{name} VARCHAR(#{Db[:col_creator_misc_short]}) NULL,"
+ end
+ def column_comment
+ %{COMMENT ON COLUMN metadata_and_text.#{name}
+ IS 'metadata document author honorific (title e.g, Ms. Dr. Prof.)';}
+ end
+ def tuple
+ t=if defined? @md.creator.author_hon \
+ and @md.creator.author_hon=~/\S+/
+ txt=@md.creator.author_hon
+ special_character_escape(txt)
+ ["#{name}, ","'#{txt}', "]
+ else ['','']
+ end
+ end
+ self
+ end
+ def creator_author_nationality # consider
+ def name
+ 'creator_author_nationality'
+ end
+ def create_column
+ "#{name} VARCHAR(#{Db[:col_creator_misc_short]}) NULL,"
+ end
+ def column_comment
+ %{COMMENT ON COLUMN metadata_and_text.#{name}
+ IS 'metadata nationality of document author (creator)';}
+ end
+ def tuple
+ t=if defined? @md.creator.author_nationality_detail \
+ and @md.creator.author_nationality=~/\S+/
+ txt=@md.creator.author_nationality_detail
+ special_character_escape(txt)
+ ["#{name}, ","'#{txt}', "]
+ else ['','']
+ end
+ end
+ self
+ end
+ def creator_editor
+ def name
+ 'creator_editor'
+ end
+ def create_column
+ "#{name} VARCHAR(#{Db[:col_name]}) NULL,"
+ end
+ def column_comment
+ %{COMMENT ON COLUMN metadata_and_text.#{name}
+ IS 'metadata document editor name(s)';}
+ end
+ def tuple
+ t=if defined? @md.creator.editor_detail \
+ and @md.creator.editor_detail.class==Array \
+ and @md.creator.editor_detail.length > 0
+ txt=@md.creator.editor_detail #dc
+ txt=''
+ @md.creator.editor_detail.each do |h|
+ txt=txt + %{#{h[:the]}, #{h[:others]}; }
+ end
+ txt.gsub!(/[;, ]+\s*$/,'')
+ special_character_escape(txt)
+ ["#{name}, ","'#{txt}', "]
+ else ['','']
+ end
+ end
+ self
+ end
+ def creator_contributor # DublinCore 6 - contributor
+ def name
+ 'creator_contributor'
+ end
+ def create_column
+ "#{name} VARCHAR(#{Db[:col_name]}) NULL,"
+ end
+ def column_comment
+ %{COMMENT ON COLUMN metadata_and_text.#{name}
+ IS 'metadata document contributor name(s) [DC6]';}
+ end
+ def tuple
+ t=if defined? @md.creator.contributor_detail \
+ and @md.creator.contributor_detail.class==Array \
+ and @md.creator.contributor_detail.length > 0
+ txt=@md.creator.contributor_detail #dc
+ txt=''
+ @md.creator.contributor_detail.each do |h|
+ txt=txt + %{#{h[:the]}, #{h[:others]}; }
+ end
+ txt.gsub!(/[;, ]+\s*$/,'')
+ special_character_escape(txt)
+ ["#{name}, ","'#{txt}', "]
+ else ['','']
+ end
+ end
+ self
+ end
+ def creator_illustrator
+ def name
+ 'creator_illustrator'
+ end
+ def create_column
+ "#{name} VARCHAR(#{Db[:col_name]}) NULL,"
+ end
+ def column_comment
+ %{COMMENT ON COLUMN metadata_and_text.#{name}
+ IS 'metadata document illustrator name(s)';}
+ end
+ def tuple
+ t=if defined? @md.creator.illustrator_detail \
+ and @md.creator.illustrator_detail.class==Array \
+ and @md.creator.illustrator_detail.length > 0
+ txt=@md.creator.illustrator_detail
+ txt=''
+ @md.creator.illustrator_detail.each do |h|
+ txt=txt + %{#{h[:the]}, #{h[:others]}; }
+ end
+ txt.gsub!(/[;, ]+\s*$/,'')
+ special_character_escape(txt)
+ ["#{name}, ","'#{txt}', "]
+ else ['','']
+ end
+ end
+ self
+ end
+ def creator_photographer
+ def name
+ 'creator_photographer'
+ end
+ def create_column
+ "#{name} VARCHAR(#{Db[:col_name]}) NULL,"
+ end
+ def column_comment
+ %{COMMENT ON COLUMN metadata_and_text.#{name}
+ IS 'metadata document photographer name(s)';}
+ end
+ def tuple
+ t=if defined? @md.creator.photographer_detail \
+ and @md.creator.photographer_detail.class==Array \
+ and @md.creator.photographer_detail.length > 0
+ txt=@md.creator.photographer_detail
+ txt=''
+ @md.creator.photographer_detail.each do |h|
+ txt=txt + %{#{h[:the]}, #{h[:others]}; }
+ end
+ txt.gsub!(/[;, ]+\s*$/,'')
+ special_character_escape(txt)
+ ["#{name}, ","'#{txt}', "]
+ else ['','']
+ end
+ end
+ self
+ end
+ def creator_translator
+ def name
+ 'creator_translator'
+ end
+ def create_column
+ "#{name} VARCHAR(#{Db[:col_name]}) NULL,"
+ end
+ def column_comment
+ %{COMMENT ON COLUMN metadata_and_text.#{name}
+ IS 'metadata document translator name(s)';}
+ end
+ def tuple
+ t=if defined? @md.creator.translator_detail \
+ and @md.creator.translator_detail.class==Array \
+ and @md.creator.translator_detail.length > 0
+ txt=''
+ @md.creator.translator_detail.each do |h|
+ txt=txt + %{#{h[:the]}, #{h[:others]}; }
+ end
+ txt.gsub!(/[;, ]+\s*$/,'')
+ special_character_escape(txt)
+ ["#{name}, ","'#{txt}', "]
+ else ['','']
+ end
+ end
+ self
+ end
+ def creator_prepared_by
+ def name
+ 'creator_prepared_by'
+ end
+ def create_column
+ "#{name} VARCHAR(#{Db[:col_name]}) NULL,"
+ end
+ def column_comment
+ %{COMMENT ON COLUMN metadata_and_text.#{name}
+ IS 'metadata document prepared by name(s)';}
+ end
+ def tuple
+ t=if defined? @md.creator.prepared_by_detail \
+ and @md.creator.prepared_by_detail.class==Array \
+ and @md.creator.prepared_by_detail.length > 0
+ txt=@md.creator.prepared_by_detail
+ txt=''
+ @md.creator.prepared_by_detail.each do |h|
+ txt=txt + %{#{h[:the]}, #{h[:others]}; }
+ end
+ txt.gsub!(/[;, ]+\s*$/,'')
+ special_character_escape(txt)
+ ["#{name}, ","'#{txt}', "]
+ else ['','']
+ end
+ end
+ self
+ end
+ def creator_digitized_by
+ def name
+ 'creator_digitized_by'
+ end
+ def create_column
+ "#{name} VARCHAR(#{Db[:col_name]}) NULL,"
+ end
+ def column_comment
+ %{COMMENT ON COLUMN metadata_and_text.#{name}
+ IS 'metadata document digitized by name(s)';}
+ end
+ def tuple
+ t=if defined? @md.creator.digitized_by_detail \
+ and @md.creator.digitized_by_detail.class==Array \
+ and @md.creator.digitized_by_detail.length > 0
+ txt=@md.creator.digitized_by_detail
+ txt=''
+ @md.creator.digitized_by_detail.each do |h|
+ txt=txt + %{#{h[:the]}, #{h[:others]}; }
+ end
+ txt.gsub!(/[;, ]+\s*$/,'')
+ special_character_escape(txt)
+ ["#{name}, ","'#{txt}', "]
+ else ['','']
+ end
+ end
+ self
+ end
+ def creator_audio
+ def name
+ 'creator_audio'
+ end
+ def create_column
+ "#{name} VARCHAR(#{Db[:col_name]}) NULL,"
+ end
+ def column_comment
+ %{COMMENT ON COLUMN metadata_and_text.#{name}
+ IS 'metadata document audio by name(s)';}
+ end
+ def tuple
+ t=if defined? @md.creator.audio_detail \
+ and @md.creator.audio_detail.class==Array \
+ and @md.creator.audio_detail.length > 0
+ txt=@md.creator.audio_detail
+ txt=''
+ @md.creator.audio_detail.each do |h|
+ txt=txt + %{#{h[:the]}, #{h[:others]}; }
+ end
+ txt.gsub!(/[;, ]+\s*$/,'')
+ special_character_escape(txt)
+ ["#{name}, ","'#{txt}', "]
+ else ['','']
+ end
+ end
+ self
+ end
+ def creator_video
+ def name
+ 'creator_video'
+ end
+ def create_column
+ "#{name} VARCHAR(#{Db[:col_name]}) NULL,"
+ end
+ def column_comment
+ %{COMMENT ON COLUMN metadata_and_text.#{name}
+ IS 'metadata document video by name(s)';}
+ end
+ def tuple
+ t=if defined? @md.creator.video_detail \
+ and @md.creator.video_detail.class==Array \
+ and @md.creator.video_detail.length > 0
+ txt=''
+ @md.creator.video_detail.each do |h|
+ txt=txt + %{#{h[:the]}, #{h[:others]}; }
+ end
+ txt.gsub!(/[;, ]+\s*$/,'')
+ special_character_escape(txt)
+ ["#{name}, ","'#{txt}', "]
+ else ['','']
+ end
+ end
+ self
+ end
+=begin
+#% language
+#taken from other fields
+@title:
+ :language:
+@original:
+ :language:
+#not available -->
+#@language:
+# :document:
+# :original:
+=end
+ def language_document
+ def name
+ 'language_document'
+ end
+ def create_column
+ "#{name} VARCHAR(#{Db[:col_language]}) NULL,"
+ end
+ def column_comment
+ %{COMMENT ON COLUMN metadata_and_text.#{name}
+ IS 'metadata document language';}
+ end
+ def tuple
+ t=if @lang.list[@md.opt.lng][:n]
+ txt=@lang.list[@md.opt.lng][:n]
+ special_character_escape(txt)
+ ["#{name}, ","'#{txt}', "]
+ else ['','']
+ end
+ end
+ self
+ end
+ def language_document_char
+ def name
+ 'language_document_char'
+ end
+ def create_column
+ "#{name} VARCHAR(#{Db[:col_language_char]}) NOT NULL,"
+ end
+ def column_comment
+ %{COMMENT ON COLUMN metadata_and_text.#{name}
+ IS 'metadata document language';}
+ end
+ def tuple
+ #modify check, is now required, SiSUv3d_
+ t=if defined? @md.opt.lng \
+ and @md.opt.lng=~/\S+/
+ txt=@md.opt.lng
+ special_character_escape(txt)
+ ["#{name}, ","'#{txt}', "]
+ else ['','']
+ end
+ end
+ self
+ end
+ def language_original
+ def name
+ 'language_original'
+ end
+ def create_column
+ "#{name} VARCHAR(#{Db[:col_language]}) NULL,"
+ end
+ def column_comment
+ %{COMMENT ON COLUMN metadata_and_text.#{name}
+ IS 'metadata original document/text language';}
+ end
+ def tuple
+ t=if defined? @md.language.original \
+ and @md.language.original=~/\S+/
+ txt=@md.language.original
+ special_character_escape(txt)
+ ["#{name}, ","'#{txt}', "]
+ else ['','']
+ end
+ end
+ self
+ end
+ def language_original_char
+ def name
+ 'language_original_char'
+ end
+ def create_column
+ "#{name} VARCHAR(#{Db[:col_language_char]}) NULL,"
+ end
+ def column_comment
+ %{COMMENT ON COLUMN metadata_and_text.#{name}
+ IS 'metadata document language';}
+ end
+ def tuple
+ t=if defined? @md.language.original_char \
+ and @md.language.original_char=~/\S+/
+ txt=@md.language.original_char
+ special_character_escape(txt)
+ ["#{name}, ","'#{txt}', "]
+ else ['','']
+ end
+ end
+ self
+ end
+=begin
+#% date
+@date:
+ :added_to_site:
+ :available:
+ :created:
+ :issued:
+ :modified:
+ :published:
+ :valid:
+ :translated:
+ :original_publication:
+=end
+ def date_added_to_site
+ def name
+ 'date_added_to_site'
+ end
+ def create_column
+ "#{name} VARCHAR(#{Db[:col_date_text]}) NULL,"
+ #"#{name} DATE,"
+ end
+ def column_comment
+ %{COMMENT ON COLUMN metadata_and_text.#{name}
+ IS 'metadata date added to site';}
+ end
+ def tuple
+ t=if defined? @md.date.added_to_site \
+ and @md.date.added_to_site=~/\S+/
+ txt=@md.date.added_to_site
+ special_character_escape(txt)
+ ["#{name}, ","'#{txt}', "]
+ else ['','']
+ end
+ end
+ self
+ end
+ def date_available
+ def name
+ 'date_available'
+ end
+ def create_column
+ "#{name} VARCHAR(#{Db[:col_date_text]}) NULL,"
+ end
+ def column_comment
+ %{COMMENT ON COLUMN metadata_and_text.#{name}
+ IS 'metadata date added to site [DC]';}
+ end
+ def tuple
+ t=if defined? @md.date.available \
+ and @md.date.available=~/\S+/
+ txt=@md.date.available
+ special_character_escape(txt)
+ ["#{name}, ","'#{txt}', "]
+ else ['','']
+ end
+ end
+ self
+ end
+ def date_created
+ def name
+ 'date_created'
+ end
+ def create_column
+ "#{name} VARCHAR(#{Db[:col_date_text]}) NULL,"
+ end
+ def column_comment
+ %{COMMENT ON COLUMN metadata_and_text.#{name}
+ IS 'metadata date created [DC]';}
+ end
+ def tuple
+ t=if defined? @md.date.created \
+ and @md.date.created=~/\S+/
+ txt=@md.date.created
+ special_character_escape(txt)
+ ["#{name}, ","'#{txt}', "]
+ else ['','']
+ end
+ end
+ self
+ end
+ def date_issued
+ def name
+ 'date_issued'
+ end
+ def create_column
+ "#{name} VARCHAR(#{Db[:col_date_text]}) NULL,"
+ end
+ def column_comment
+ %{COMMENT ON COLUMN metadata_and_text.#{name}
+ IS 'metadata date issued [DC]';}
+ end
+ def tuple
+ t=if defined? @md.date.issued \
+ and @md.date.issued=~/\S+/
+ txt=@md.date.issued
+ special_character_escape(txt)
+ ["#{name}, ","'#{txt}', "]
+ else ['','']
+ end
+ end
+ self
+ end
+ def date_modified
+ def name
+ 'date_modified'
+ end
+ def create_column
+ "#{name} VARCHAR(#{Db[:col_date_text]}) NULL,"
+ end
+ def column_comment
+ %{COMMENT ON COLUMN metadata_and_text.#{name}
+ IS 'metadata date modified [DC]';}
+ end
+ def tuple
+ t=if defined? @md.date.modified \
+ and @md.date.modified=~/\S+/
+ txt=@md.date.modified
+ special_character_escape(txt)
+ ["#{name}, ","'#{txt}', "]
+ else ['','']
+ end
+ end
+ self
+ end
+ def date_published
+ def name
+ 'date_published'
+ end
+ def create_column
+ "#{name} VARCHAR(#{Db[:col_date_text]}) NULL,"
+ end
+ def column_comment
+ %{COMMENT ON COLUMN metadata_and_text.#{name}
+ IS 'metadata date published [DC7]';}
+ end
+ def tuple
+ t=if defined? @md.date.published \
+ and @md.date.published=~/\S+/
+ txt=@md.date.published
+ special_character_escape(txt)
+ ["#{name}, ","'#{txt}', "]
+ else ['','']
+ end
+ end
+ self
+ end
+ def date_valid
+ def name
+ 'date_valid'
+ end
+ def create_column
+ "#{name} VARCHAR(#{Db[:col_date_text]}) NULL,"
+ end
+ def column_comment
+ %{COMMENT ON COLUMN metadata_and_text.#{name}
+ IS 'metadata date valid [DC]';}
+ end
+ def tuple
+ t=if defined? @md.date.valid \
+ and @md.date.valid=~/\S+/
+ txt=@md.date.valid
+ special_character_escape(txt)
+ ["#{name}, ","'#{txt}', "]
+ else ['','']
+ end
+ end
+ self
+ end
+ def date_translated
+ def name
+ 'date_translated'
+ end
+ def create_column
+ "#{name} VARCHAR(#{Db[:col_date_text]}) NULL,"
+ end
+ def column_comment
+ %{COMMENT ON COLUMN metadata_and_text.#{name}
+ IS 'metadata date translated';}
+ end
+ def tuple
+ t=if defined? @md.date.translated \
+ and @md.date.translated=~/\S+/
+ txt=@md.date.translated
+ special_character_escape(txt)
+ ["#{name}, ","'#{txt}', "]
+ else ['','']
+ end
+ end
+ self
+ end
+ def date_original_publication
+ def name
+ 'date_original_publication'
+ end
+ def create_column
+ "#{name} VARCHAR(#{Db[:col_date_text]}) NULL,"
+ end
+ def column_comment
+ %{COMMENT ON COLUMN metadata_and_text.#{name}
+ IS 'metadata date of original publication';}
+ end
+ def tuple
+ t=if defined? @md.date.original_publication \
+ and @md.date.original_publication=~/\S+/
+ txt=@md.date.original_publication
+ special_character_escape(txt)
+ ["#{name}, ","'#{txt}', "]
+ else ['','']
+ end
+ end
+ self
+ end
+ def date_generated
+ def name
+ 'date_generated'
+ end
+ def create_column #choose other representation of time
+ "#{name} VARCHAR(30) NULL,"
+ #"#{name} VARCHAR(10) NULL,"
+ end
+ def column_comment
+ %{COMMENT ON COLUMN metadata_and_text.#{name}
+ IS 'metadata date of sisu generation of document, automatically populated';}
+ end
+ def tuple #choose other representation of time
+ t=if defined? @md.generated \
+ and @md.generated.to_s=~/\S+/
+ txt=@md.generated.to_s
+ special_character_escape(txt)
+ ["#{name}, ","'#{txt}', "]
+ else ['','']
+ end
+ end
+ self
+ end
+=begin
+#% publisher
+@publisher:
+=end
+ def publisher
+ def name
+ 'publisher'
+ end
+ def create_column
+ "#{name} VARCHAR(#{Db[:col_name]}) NULL,"
+ end
+ def column_comment
+ %{COMMENT ON COLUMN metadata_and_text.#{name}
+ IS 'metadata document publisher [DC5]';}
+ end
+ def tuple
+ t=if defined? @md.publisher \
+ and @md.publisher=~/\S+/
+ txt=@md.publisher
+ special_character_escape(txt)
+ ["#{name}, ","'#{txt}', "]
+ else ['','']
+ end
+ end
+ self
+ end
+##% current
+# def current_publisher
+# def name
+# 'current_publisher'
+# end
+# def size
+# 10
+# end
+# def create_column
+# "#{name} VARCHAR(#{current_publisher.size}) NULL,"
+# end
+# def tuple
+# t=if defined? @md.current.publisher \
+# and @md.current.publisher=~/\S+/
+# txt=@md.current.publisher
+# special_character_escape(txt)
+# "'#{txt}', "
+# end
+# end
+# self
+# end
+=begin
+#% original
+@original:
+ :publisher:
+ #:date: #repeated under date
+ :language:
+ :institution:
+ :nationality:
+ :source:
+=end
+ def original_publisher
+ def name
+ 'original_publisher'
+ end
+ def create_column
+ "#{name} VARCHAR(#{Db[:col_name]}) NULL,"
+ end
+ def column_comment
+ %{COMMENT ON COLUMN metadata_and_text.#{name}
+ IS 'metadata document original publisher [DC5]';}
+ end
+ def tuple
+ t=if defined? @md.original.publisher \
+ and @md.original.publisher=~/\S+/
+ txt=@md.original.publisher
+ special_character_escape(txt)
+ ["#{name}, ","'#{txt}', "]
+ else ['','']
+ end
+ end
+ self
+ end
+ def original_language
+ def name
+ 'original_language'
+ end
+ def create_column
+ "#{name} VARCHAR(#{Db[:col_language]}) NULL,"
+ end
+ def column_comment
+ %{COMMENT ON COLUMN metadata_and_text.#{name}
+ IS 'metadata document original language';}
+ end
+ def tuple
+ t=if defined? @md.original.language \
+ and @md.original.language=~/\S+/
+ txt=@md.original.language
+ special_character_escape(txt)
+ ["#{name}, ","'#{txt}', "]
+ else ['','']
+ end
+ end
+ self
+ end
+ def original_language_char # consider
+ def name
+ 'original_language_char'
+ end
+ def create_column
+ "#{name} VARCHAR(#{Db[:col_language_char]}) NULL,"
+ end
+ def column_comment
+ %{COMMENT ON COLUMN metadata_and_text.#{name}
+ IS 'metadata document original language iso character';}
+ end
+ def tuple
+ t=if defined? @md.original.language_char \
+ and @md.original.language_char=~/\S+/
+ txt=@md.original.language_char
+ special_character_escape(txt)
+ ["#{name}, ","'#{txt}', "]
+ else ['','']
+ end
+ end
+ self
+ end
+ def original_source
+ def name
+ 'original_source'
+ end
+ def create_column
+ "#{name} VARCHAR(#{Db[:col_name]}) NULL,"
+ end
+ def column_comment
+ %{COMMENT ON COLUMN metadata_and_text.#{name}
+ IS 'metadata document original source [DC11]';}
+ end
+ def tuple
+ t=if defined? @md.original.source \
+ and @md.original.source=~/\S+/
+ txt=@md.original.source
+ special_character_escape(txt)
+ ["#{name}, ","'#{txt}', "]
+ else ['','']
+ end
+ end
+ self
+ end
+ def original_institution
+ def name
+ 'original_institution'
+ end
+ def create_column
+ "#{name} VARCHAR(#{Db[:col_name]}) NULL,"
+ end
+ def column_comment
+ %{COMMENT ON COLUMN metadata_and_text.#{name}
+ IS 'metadata document original institution';}
+ end
+ def tuple
+ t=if defined? @md.original.institution \
+ and @md.original.institution=~/\S+/
+ txt=@md.original.institution
+ special_character_escape(txt)
+ ["#{name}, ","'#{txt}', "]
+ else ['','']
+ end
+ end
+ self
+ end
+ def original_nationality
+ def name
+ 'original_nationality'
+ end
+ def create_column
+ "#{name} VARCHAR(#{Db[:col_language]}) NULL,"
+ end
+ def column_comment
+ %{COMMENT ON COLUMN metadata_and_text.#{name}
+ IS 'metadata document original nationality';}
+ end
+ def tuple
+ t=if defined? @md.original.nationality \
+ and @md.original.nationality=~/\S+/
+ txt=@md.original.nationality
+ special_character_escape(txt)
+ ["#{name}, ","'#{txt}', "]
+ else ['','']
+ end
+ end
+ self
+ end
+=begin
+#% rights
+@rights:
+ #:copyright: #mapped to :text: used where no other copyrights and included in :all:
+ :text:
+ :translation:
+ :illustrations:
+ :photographs:
+ :preparation:
+ :digitization:
+ :audio:
+ :video:
+ :license:
+ :all:
+=end
+ def rights_all
+ def name
+ 'rights'
+ end
+ def create_column
+ "#{name} VARCHAR(#{Db[:col_info_note]}) NULL,"
+ end
+ def column_comment
+ %{COMMENT ON COLUMN metadata_and_text.#{name}
+ IS 'metadata rights associated with document (composite) [DC15]';}
+ end
+ def tuple
+ t=if defined? @md.rights.all \
+ and @md.rights.all=~/\S+/
+ txt=@md.rights.all
+ special_character_escape(txt)
+ ["#{name}, ","'#{txt}', "]
+ else ['','']
+ end
+ end
+ self
+ end
+ def rights_copyright_text
+ def name
+ 'rights_copyright_text'
+ end
+ def create_column
+ "#{name} VARCHAR(#{Db[:col_info_note]}) NULL,"
+ end
+ def column_comment
+ %{COMMENT ON COLUMN metadata_and_text.#{name}
+ IS 'metadata copyright associated for document text';}
+ end
+ def tuple
+ t=if defined? @md.rights.copyright_text \
+ and @md.rights.copyright_text=~/\S+/
+ txt=@md.rights.copyright_text
+ special_character_escape(txt)
+ ["#{name}, ","'#{txt}', "]
+ else ['','']
+ end
+ end
+ self
+ end
+ def rights_copyright_translation
+ def name
+ 'rights_copyright_translation'
+ end
+ def create_column
+ "#{name} VARCHAR(#{Db[:col_info_note]}) NULL,"
+ end
+ def column_comment
+ %{COMMENT ON COLUMN metadata_and_text.#{name}
+ IS 'metadata copyright associated for document text translation (if any)';}
+ end
+ def tuple
+ t=if defined? @md.rights.copyright_translation \
+ and @md.rights.copyright_translation=~/\S+/
+ txt=@md.rights.copyright_translation
+ special_character_escape(txt)
+ ["#{name}, ","'#{txt}', "]
+ else ['','']
+ end
+ end
+ self
+ end
+ def rights_copyright_illustrations
+ def name
+ 'rights_copyright_illustrations'
+ end
+ def create_column
+ "#{name} VARCHAR(#{Db[:col_info_note]}) NULL,"
+ end
+ def column_comment
+ %{COMMENT ON COLUMN metadata_and_text.#{name}
+ IS 'metadata copyright associated for document text illustrations (if any)';}
+ end
+ def tuple
+ t=if defined? @md.rights.copyright_illustrations \
+ and @md.rights.copyright_illustrations=~/\S+/
+ txt=@md.rights.copyright_illustrations
+ special_character_escape(txt)
+ ["#{name}, ","'#{txt}', "]
+ else ['','']
+ end
+ end
+ self
+ end
+ def rights_copyright_photographs
+ def name
+ 'rights_copyright_photographs'
+ end
+ def create_column
+ "#{name} VARCHAR(#{Db[:col_info_note]}) NULL,"
+ end
+ def column_comment
+ %{COMMENT ON COLUMN metadata_and_text.#{name}
+ IS 'metadata copyright associated for document text photographs (if any)';}
+ end
+ def tuple
+ t=if defined? @md.rights.copyright_photographs \
+ and @md.rights.copyright_photographs=~/\S+/
+ txt=@md.rights.copyright_photographs
+ special_character_escape(txt)
+ ["#{name}, ","'#{txt}', "]
+ else ['','']
+ end
+ end
+ self
+ end
+ def rights_copyright_preparation
+ def name
+ 'rights_copyright_preparation'
+ end
+ def create_column
+ "#{name} VARCHAR(#{Db[:col_info_note]}) NULL,"
+ end
+ def column_comment
+ %{COMMENT ON COLUMN metadata_and_text.#{name}
+ IS 'metadata copyright associated for document text preparation (if any)';}
+ end
+ def tuple
+ t=if defined? @md.rights.copyright_preparation \
+ and @md.rights.copyright_preparation=~/\S+/
+ txt=@md.rights.copyright_preparation
+ special_character_escape(txt)
+ ["#{name}, ","'#{txt}', "]
+ else ['','']
+ end
+ end
+ self
+ end
+ def rights_copyright_digitization
+ def name
+ 'rights_copyright_digitization'
+ end
+ def create_column
+ "#{name} VARCHAR(#{Db[:col_info_note]}) NULL,"
+ end
+ def column_comment
+ %{COMMENT ON COLUMN metadata_and_text.#{name}
+ IS 'metadata copyright associated for document text digitization (if any)';}
+ end
+ def tuple
+ t=if defined? @md.rights.copyright_digitization \
+ and @md.rights.copyright_digitization=~/\S+/
+ txt=@md.rights.copyright_digitization
+ special_character_escape(txt)
+ ["#{name}, ","'#{txt}', "]
+ else ['','']
+ end
+ end
+ self
+ end
+ def rights_copyright_audio
+ def name
+ 'rights_copyright_audio'
+ end
+ def create_column
+ "#{name} VARCHAR(#{Db[:col_info_note]}) NULL,"
+ end
+ def column_comment
+ %{COMMENT ON COLUMN metadata_and_text.#{name}
+ IS 'metadata copyright associated for document text audio (if any)';}
+ end
+ def tuple
+ t=if defined? @md.rights.copyright_audio \
+ and @md.rights.copyright_audio=~/\S+/
+ txt=@md.rights.copyright_audio
+ special_character_escape(txt)
+ ["#{name}, ","'#{txt}', "]
+ else ['','']
+ end
+ end
+ self
+ end
+ def rights_copyright_video
+ def name
+ 'rights_copyright_video'
+ end
+ def create_column
+ "#{name} VARCHAR(#{Db[:col_info_note]}) NULL,"
+ end
+ def column_comment
+ %{COMMENT ON COLUMN metadata_and_text.#{name}
+ IS 'metadata copyright associated for document text video (if any)';}
+ end
+ def tuple
+ t=if defined? @md.rights.copyright_video \
+ and @md.rights.copyright_video=~/\S+/
+ txt=@md.rights.copyright_video
+ special_character_escape(txt)
+ ["#{name}, ","'#{txt}', "]
+ else ['','']
+ end
+ end
+ self
+ end
+ def rights_license
+ def name
+ 'rights_license'
+ end
+ def create_column
+ "#{name} VARCHAR(#{Db[:col_info_note]}) NULL,"
+ end
+ def column_comment
+ %{COMMENT ON COLUMN metadata_and_text.#{name}
+ IS 'metadata license granted for use of document if any)';}
+ end
+ def tuple
+ t=if defined? @md.rights.license \
+ and @md.rights.license=~/\S+/
+ txt=@md.rights.license
+ special_character_escape(txt)
+ ["#{name}, ","'#{txt}', "]
+ else ['','']
+ end
+ end
+ self
+ end
+=begin
+#% classify
+@classify:
+ :topic_register:
+ :coverage:
+ :format:
+ :identifier:
+ :keywords:
+ :relation:
+ :subject:
+ :type:
+ :loc:
+ :dewey:
+ :pg:
+ :isbn:
+=end
+ def classify_topic_register
+ def name
+ 'classify_topic_register'
+ end
+ def create_column
+ "#{name} VARCHAR(#{Db[:col_info_note]}) NULL,"
+ end
+ def column_comment
+ %{COMMENT ON COLUMN metadata_and_text.#{name}
+ IS 'metadata classify document topic register (semi-structured document subject information)';}
+ end
+ def tuple
+ t=if defined? @md.classify.topic_register \
+ and @md.classify.topic_register=~/\S+/
+ txt=@md.classify.topic_register
+ special_character_escape(txt)
+ ["#{name}, ","'#{txt}', "]
+ else ['','']
+ end
+ end
+ self
+ end
+ def classify_subject
+ def name
+ 'classify_subject'
+ end
+ def create_column
+ "#{name} VARCHAR(#{Db[:col_classify_txt_short]}) NULL,"
+ end
+ def column_comment
+ %{COMMENT ON COLUMN metadata_and_text.#{name}
+ IS 'metadata classify document subject matter [DC3]';}
+ end
+ def tuple
+ t=if defined? @md.classify.subject \
+ and @md.classify.subject=~/\S+/
+ txt=@md.classify.subject
+ special_character_escape(txt)
+ ["#{name}, ","'#{txt}', "]
+ else ['','']
+ end
+ end
+ self
+ end
+ def classify_type #check
+ def name
+ 'classify_type'
+ end
+ def create_column
+ "#{name} VARCHAR(#{Db[:col_classify_txt_short]}) NULL,"
+ end
+ def column_comment
+ %{COMMENT ON COLUMN metadata_and_text.#{name}
+ IS 'metadata classify document type [DC8]';}
+ end
+ def tuple
+ t=if defined? @md.classify.type \
+ and @md.classify.type=~/\S+/
+ txt=@md.classify.type
+ special_character_escape(txt)
+ ["#{name}, ","'#{txt}', "]
+ else ['','']
+ end
+ end
+ self
+ end
+ def classify_loc
+ def name
+ 'classify_loc'
+ end
+ def create_column
+ "#{name} VARCHAR(#{Db[:col_classify_library]}) NULL,"
+ end
+ def column_comment
+ %{COMMENT ON COLUMN metadata_and_text.#{name}
+ IS 'metadata classify document Library of Congress';}
+ end
+ def tuple
+ t=if defined? @md.classify.loc \
+ and @md.classify.loc=~/\S+/
+ txt=@md.classify.loc
+ special_character_escape(txt)
+ ["#{name}, ","'#{txt}', "]
+ else ['','']
+ end
+ end
+ self
+ end
+ def classify_dewey
+ def name
+ 'classify_dewey'
+ end
+ def create_column
+ "#{name} VARCHAR(#{Db[:col_classify_library]}) NULL,"
+ end
+ def column_comment
+ %{COMMENT ON COLUMN metadata_and_text.#{name}
+ IS 'metadata classify document Dewey';}
+ end
+ def tuple
+ t=if defined? @md.classify.dewey \
+ and @md.classify.dewey=~/\S+/
+ txt=@md.classify.dewey
+ special_character_escape(txt)
+ ["#{name}, ","'#{txt}', "]
+ else ['','']
+ end
+ end
+ self
+ end
+ def classify_oclc
+ def name
+ 'classify_oclc'
+ end
+ def create_column
+ "#{name} VARCHAR(#{Db[:col_classify_library]}) NULL,"
+ end
+ def column_comment
+ %{COMMENT ON COLUMN metadata_and_text.#{name}
+ IS 'metadata classify document Online Computer Library Center number';}
+ end
+ def tuple
+ t=if defined? @md.classify.oclc \
+ and @md.classify.oclc=~/\S+/
+ txt=@md.classify.oclc
+ special_character_escape(txt)
+ ["#{name}, ","'#{txt}', "]
+ else ['','']
+ end
+ end
+ self
+ end
+ def classify_pg
+ def name
+ 'classify_pg'
+ end
+ def create_column
+ "#{name} VARCHAR(#{Db[:col_classify_small]}) NULL,"
+ end
+ def column_comment
+ %{COMMENT ON COLUMN metadata_and_text.#{name}
+ IS 'metadata classify document project gutenberg (if any)';}
+ end
+ def tuple
+ t=if defined? @md.classify.pg \
+ and @md.classify.pg=~/\S+/
+ txt=@md.classify.pg
+ special_character_escape(txt)
+ ["#{name}, ","'#{txt}', "]
+ else ['','']
+ end
+ end
+ self
+ end
+ def classify_isbn
+ def name
+ 'classify_isbn'
+ end
+ def create_column
+ "#{name} VARCHAR(#{Db[:col_classify_small]}) NULL,"
+ end
+ def column_comment
+ %{COMMENT ON COLUMN metadata_and_text.#{name}
+ IS 'metadata classify document isbn (if any)';}
+ end
+ def tuple
+ t=if defined? @md.classify.isbn \
+ and @md.classify.isbn=~/\S+/
+ txt=@md.classify.isbn
+ special_character_escape(txt)
+ ["#{name}, ","'#{txt}', "]
+ else ['','']
+ end
+ end
+ self
+ end
+ def classify_format
+ def name
+ 'classify_format'
+ end
+ def create_column
+ "#{name} VARCHAR(#{Db[:col_classify_txt_short]}) NULL,"
+ end
+ def column_comment
+ %{COMMENT ON COLUMN metadata_and_text.#{name}
+ IS 'metadata classify document format [DC9]';}
+ end
+ def tuple
+ t=if defined? @md.classify.format \
+ and @md.classify.format=~/\S+/
+ txt=@md.classify.format
+ special_character_escape(txt)
+ ["#{name}, ","'#{txt}', "]
+ else ['','']
+ end
+ end
+ self
+ end
+ def classify_identifier
+ def name
+ 'classify_identifier'
+ end
+ def create_column
+ "#{name} VARCHAR(#{Db[:col_classify_identify]}) NULL,"
+ end
+ def column_comment
+ %{COMMENT ON COLUMN metadata_and_text.#{name}
+ IS 'metadata classify document identifier [DC10]';}
+ end
+ def tuple
+ t=if defined? @md.classify.identifier \
+ and @md.classify.identifier=~/\S+/
+ txt=@md.classify.identifier
+ special_character_escape(txt)
+ ["#{name}, ","'#{txt}', "]
+ else ['','']
+ end
+ end
+ self
+ end
+ def classify_relation
+ def name
+ 'classify_relation'
+ end
+ def create_column
+ "#{name} VARCHAR(#{Db[:col_classify_short]}) NULL,"
+ end
+ def column_comment
+ %{COMMENT ON COLUMN metadata_and_text.#{name}
+ IS 'metadata classify document relation [DC13]';}
+ end
+ def tuple
+ t=if defined? @md.classify.relation \
+ and @md.classify.relation=~/\S+/
+ txt=@md.classify.relation
+ special_character_escape(txt)
+ ["#{name}, ","'#{txt}', "]
+ else ['','']
+ end
+ end
+ self
+ end
+ def classify_coverage
+ def name
+ 'classify_coverage'
+ end
+ def create_column
+ "#{name} VARCHAR(#{Db[:col_classify_short]}) NULL,"
+ end
+ def column_comment
+ %{COMMENT ON COLUMN metadata_and_text.#{name}
+ IS 'metadata classify document coverage [DC14]';}
+ end
+ def tuple
+ t=if defined? @md.classify.coverage \
+ and @md.classify.coverage=~/\S+/
+ txt=@md.classify.coverage
+ special_character_escape(txt)
+ ["#{name}, ","'#{txt}', "]
+ else ['','']
+ end
+ end
+ self
+ end
+ def classify_keywords
+ def name
+ 'classify_keywords'
+ end
+ def create_column
+ "#{name} VARCHAR(#{Db[:col_classify_txt_short]}) NULL,"
+ end
+ def column_comment
+ %{COMMENT ON COLUMN metadata_and_text.#{name}
+ IS 'metadata classify document keywords';}
+ end
+ def tuple
+ t=if defined? @md.classify.keywords \
+ and @md.classify.keywords=~/\S+/
+ txt=@md.classify.keywords
+ special_character_escape(txt)
+ ["#{name}, ","'#{txt}', "]
+ else ['','']
+ end
+ end
+ self
+ end
+=begin
+#% notes
+@notes:
+ :abstract:
+ :comment:
+ :description:
+ :history:
+ :prefix:
+ :prefix_a:
+ :prefix_b:
+ :suffix:
+=end
+ def notes_abstract
+ def name
+ 'notes_abstract'
+ end
+ def create_column
+ "#{name} TEXT NULL,"
+ end
+ def column_comment
+ %{COMMENT ON COLUMN metadata_and_text.#{name}
+ IS 'metadata document notes abstract';}
+ end
+ def tuple
+ t=if defined? @md.notes.abstract \
+ and @md.notes.abstract=~/\S+/
+ txt=@md.notes.abstract
+ special_character_escape(txt)
+ ["#{name}, ","'#{txt}', "]
+ else ['','']
+ end
+ end
+ self
+ end
+ def notes_comment
+ def name
+ 'notes_comment'
+ end
+ def create_column
+ "#{name} TEXT NULL,"
+ end
+ def column_comment
+ %{COMMENT ON COLUMN metadata_and_text.#{name}
+ IS 'metadata document notes comment';}
+ end
+ def tuple
+ t=if defined? @md.notes.comment \
+ and @md.notes.comment=~/\S+/
+ txt=@md.notes.comment
+ special_character_escape(txt)
+ ["#{name}, ","'#{txt}', "]
+ else ['','']
+ end
+ end
+ self
+ end
+ def notes_description
+ def name
+ 'notes_description'
+ end
+ def create_column
+ "#{name} TEXT NULL,"
+ end
+ def column_comment
+ %{COMMENT ON COLUMN metadata_and_text.#{name}
+ IS 'metadata document notes description [DC4]';}
+ end
+ def tuple
+ t=if defined? @md.notes.description \
+ and @md.notes.description=~/\S+/
+ txt=@md.notes.description
+ special_character_escape(txt)
+ ["#{name}, ","'#{txt}', "]
+ else ['','']
+ end
+ end
+ self
+ end
+ def notes_history #check, consider removal
+ def name
+ 'notes_history'
+ end
+ def create_column
+ "#{name} VARCHAR(#{Db[:col_classify_txt_short]}) NULL,"
+ end
+ def column_comment
+ %{COMMENT ON COLUMN metadata_and_text.#{name}
+ IS 'metadata document notes history';}
+ end
+ def tuple
+ t=if defined? @md.notes.history \
+ and @md.notes.history=~/\S+/
+ txt=@md.notes.history
+ special_character_escape(txt)
+ ["#{name}, ","'#{txt}', "]
+ else ['','']
+ end
+ end
+ self
+ end
+ def notes_prefix
+ def name
+ 'notes_prefix'
+ end
+ def create_column
+ "#{name} TEXT NULL,"
+ end
+ def column_comment
+ %{COMMENT ON COLUMN metadata_and_text.#{name}
+ IS 'metadata document notes prefix';}
+ end
+ def tuple
+ t=if defined? @md.notes.prefix \
+ and @md.notes.prefix=~/\S+/
+ txt=@md.notes.prefix
+ special_character_escape(txt)
+ ["#{name}, ","'#{txt}', "]
+ else ['','']
+ end
+ end
+ self
+ end
+ def notes_prefix_a
+ def name
+ 'notes_prefix_a'
+ end
+ def create_column
+ "#{name} TEXT NULL,"
+ end
+ def column_comment
+ %{COMMENT ON COLUMN metadata_and_text.#{name}
+ IS 'metadata document notes prefix_a';}
+ end
+ def tuple
+ t=if defined? @md.notes.prefix_a \
+ and @md.notes.prefix_a=~/\S+/
+ txt=@md.notes.prefix_a
+ special_character_escape(txt)
+ ["#{name}, ","'#{txt}', "]
+ else ['','']
+ end
+ end
+ self
+ end
+ def notes_prefix_b
+ def name
+ 'notes_prefix_b'
+ end
+ def create_column
+ "#{name} TEXT NULL,"
+ end
+ def column_comment
+ %{COMMENT ON COLUMN metadata_and_text.#{name}
+ IS 'metadata document notes prefix_b';}
+ end
+ def tuple
+ t=if defined? @md.notes.prefix_b \
+ and @md.notes.prefix_b=~/\S+/
+ txt=@md.notes.prefix_b
+ special_character_escape(txt)
+ ["#{name}, ","'#{txt}', "]
+ else ['','']
+ end
+ end
+ self
+ end
+ def notes_suffix
+ def name
+ 'notes_suffix'
+ end
+ def create_column # keep text
+ "#{name} TEXT NULL,"
+ end
+ def column_comment
+ %{COMMENT ON COLUMN metadata_and_text.#{name}
+ IS 'metadata document notes suffix';}
+ end
+ def tuple
+ t=if defined? @md.notes.suffix \
+ and @md.notes.suffix=~/\S+/
+ txt=@md.notes.suffix
+ special_character_escape(txt)
+ ["#{name}, ","'#{txt}', "]
+ else ['','']
+ end
+ end
+ self
+ end
+=begin
+#% src
+=end
+ def src_filename
+ def name
+ 'src_filename'
+ end
+ def create_column
+ "#{name} VARCHAR(#{Db[:col_filename]}) NOT NULL,"
+ end
+ def column_comment
+ %{COMMENT ON COLUMN metadata_and_text.#{name}
+ IS 'sisu markup source text filename';}
+ end
+ def tuple
+ t=if defined? @md.fns \
+ and @md.fns=~/\S+/
+ txt=@md.fns
+ special_character_escape(txt)
+ ["#{name}, ","'#{txt}', "]
+ else ['','']
+ end
+ end
+ self
+ end
+ def src_fingerprint
+ def name
+ 'src_fingerprint' #hash/digest, sha256 or md5
+ end
+ def create_column
+ "#{name} VARCHAR(#{Db[:col_digest]}) NULL,"
+ #"#{name} TEXT NULL,"
+ end
+ def column_comment
+ %{COMMENT ON COLUMN metadata_and_text.#{name}
+ IS 'sisu markup source text fingerprint, hash digest sha256 (or md5)';}
+ end
+ def tuple
+ t=if defined? @md.dgst \
+ and @md.dgst.class==Array \
+ and @md.dgst[1]=~/\S+/
+ txt=@md.dgst[1]
+ ["#{name}, ","'#{txt}', "]
+ else ['','']
+ end
+ end
+ self
+ end
+ def src_filesize
+ def name
+ 'src_filesize'
+ end
+ def create_column
+ "#{name} VARCHAR(#{Db[:col_filesize]}) NULL,"
+ end
+ def column_comment
+ %{COMMENT ON COLUMN metadata_and_text.#{name}
+ IS 'sisu markup source text file size';}
+ end
+ def tuple
+ t=if defined? @md.filesize \
+ and @md.filesize=~/\S+/
+ txt=@md.filesize
+ special_character_escape(txt)
+ ["#{name}, ","'#{txt}', "]
+ else ['','']
+ end
+ end
+ self
+ end
+ def src_word_count
+ def name
+ 'src_word_count'
+ end
+ def create_column
+ "#{name} TEXT NULL,"
+ end
+ def column_comment
+ %{COMMENT ON COLUMN metadata_and_text.#{name}
+ IS 'sisu markup source text word count';}
+ end
+ def tuple
+ t=if defined? @md.wc_words \
+ and @md.wc_words=~/\S+/
+ txt=@md.wc_words
+ special_character_escape(txt)
+ ["#{name}, ","'#{txt}', "]
+ else ['','']
+ end
+ end
+ self
+ end
+ def src_txt # consider naming sisusrc
+ def name
+ 'src_text'
+ end
+ def create_column
+ "#{name} TEXT NULL,"
+ end
+ def column_comment
+ %{COMMENT ON COLUMN metadata_and_text.#{name}
+ IS 'sisu markup source text (if shared)';}
+ end
+ def tuple
+ t=if @md.opt.mod.inspect=~/import|update/ \
+ and FileTest.exist?(@md.fns)
+ ["#{name}, ","'#{@sisutxt}', "]
+ else ['','']
+ end
+ end
+ self
+ end
+=begin
+#% misc
+@make:
+ :skin:
+@links:
+=end
+ def fulltext
+ def name
+ 'fulltext'
+ end
+ def create_column
+ "#{name} TEXT NULL,"
+ end
+ def column_comment
+ %{COMMENT ON COLUMN metadata_and_text.#{name}
+ IS 'document full text clean, searchable';}
+ end
+ def tuple
+ t=if @md.opt.mod.inspect=~/import|update/ \
+ and FileTest.exist?(@md.fns)
+ ["#{name}, ","'#{@fulltext}', "]
+ else ['','']
+ end
+ end
+ self
+ end
+ def skin_name #check
+ def name
+ 'skin_name'
+ end
+ def create_column
+ "#{name} VARCHAR(#{Db[:col_filename]}) NULL,"
+ end
+ def column_comment
+ %{COMMENT ON COLUMN metadata_and_text.#{name}
+ IS 'source text skin name';}
+ end
+ def tuple
+ t=if defined? @md.skin_name \
+ and @md.skin_name=~/\S+/
+ txt=@md.skin_name
+ special_character_escape(txt)
+ ["#{name}, ","'#{txt}', "]
+ else ['','']
+ end
+ end
+ self
+ end
+ def skin_fingerprint #check
+ def name
+ 'skin_fingerprint'
+ end
+ def create_column
+ "#{name} VARCHAR(#{Db[:col_digest]}) NULL,"
+ end
+ def column_comment
+ %{COMMENT ON COLUMN metadata_and_text.#{name}
+ IS 'source text skin fingerprint';}
+ end
+ def tuple
+ t=if defined? @md.dgst_skin \
+ and @md.dgst_skin.class==Array \
+ and @md.dgst_skin[1]=~/\S+/
+ txt=@md.dgst_skin[1]
+ special_character_escape(txt)
+ ["#{name}, ","'#{txt}', "]
+ else ['','']
+ end
+ end
+ self
+ end
+ def skin # you likely want a separate table for skins
+ def name
+ 'skin'
+ end
+ def create_column
+ "#{name} TEXT NULL,"
+ end
+ def column_comment
+ %{COMMENT ON COLUMN metadata_and_text.#{name}
+ IS 'source text skin';}
+ end
+ def tuple
+ t=if defined? @md.skin \
+ and @md.skin=~/\S+/
+ txt=@md.skin
+ special_character_escape(txt)
+ ["#{name}, ","'#{txt}', "]
+ else ['','']
+ end
+ end
+ self
+ end
+ def links
+ def name
+ 'links'
+ end
+ def create_column
+ "#{name} TEXT NULL,"
+ #"#{name} VARCHAR(#{links.size}) NULL,"
+ end
+ def column_comment
+ %{COMMENT ON COLUMN metadata_and_text.#{name}
+ IS 'metadata document links';}
+ end
+ def tuple
+ t=if defined? @md.links \
+ and @md.links=~/\S+/
+ txt=@md.links
+ special_character_escape(txt)
+ ["#{name}, ","'#{txt}', "]
+ else ['','']
+ end
+ end
+ self
+ end
+ self
+ end
+ end
+ class Column_size
+ def document_clean # restriction not necessary
+ 60000
+ end
+ def document_body
+ 16000
+ end
+ def document_seg
+ 120
+ end
+ def document_seg_full
+ 120
+ end
+ def endnote_clean # restriction not necessary
+ 60000
+ end
+ def endnote_body
+ 16000
+ end
+ end
+end
+__END__
diff --git a/lib/sisu/v3dv/db_create.rb b/lib/sisu/v3dv/db_create.rb
new file mode 100644
index 00000000..71d0ce09
--- /dev/null
+++ b/lib/sisu/v3dv/db_create.rb
@@ -0,0 +1,614 @@
+# encoding: utf-8
+=begin
+
+ * Name: SiSU
+
+ * Description: a framework for document structuring, publishing and search
+
+ * Author: Ralph Amissah
+
+ * Copyright: (C) 1997 - 2012, 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 .
+
+ If you have Internet connection, the latest version of the GPL should be
+ available at these locations:
+
+
+
+
+
+
+
+ * SiSU uses:
+ * Standard SiSU markup syntax,
+ * Standard SiSU meta-markup syntax, and the
+ * Standard SiSU object citation numbering and system
+
+ * Hompages:
+
+
+
+ * Download:
+
+
+ * Ralph Amissah
+
+
+
+ ** Description: modules shared by the different db types, dbi, postgresql,
+ sqlite
+
+=end
+module SiSU_DB_create
+ require_relative 'db_columns' # db_columns.rb
+ class Create < SiSU_DB_columns::Columns
+ require_relative 'sysenv' # sysenv.rb
+ @@dl=nil
+ def initialize(opt,conn,file,sql_type='pg')
+ @opt,@conn,@file,@sql_type=opt,conn,file,sql_type
+ @cX=SiSU_Screen::Ansi.new(@opt.cmd).cX
+ @comment=(@sql_type=='pg') \
+ ? (Comment.new(@conn,@sql_type))
+ : nil
+ @@dl ||=SiSU_Env::Info_env.new.digest.length
+ end
+ def available
+ DBI.available_drivers.each do |driver|
+ puts "Driver: #{driver}"
+ DBI.data_sources(driver).each do |dsn|
+ puts "\tDatasource: #{dsn}"
+ end
+ end
+ end
+ def create_db
+ @env=SiSU_Env::Info_env.new(@opt.fns)
+ tell=(@sql_type=='sqlite') \
+ ? SiSU_Screen::Ansi.new(@opt.cmd,'invert','Create Sqlite db tables in:',%{"#{@env.path.output}/sisu_sqlite.db"})
+ : SiSU_Screen::Ansi.new(@opt.cmd,'invert','Create PG db tables in:',%{"#{Db[:name_prefix]}#{@env.path.stub_pwd}"})
+ tell.colorize if @opt.cmd =~/vVM/
+ SiSU_Env::System_call.new.create_pg_db(@env.path.stub_pwd) if @sql_type=='pg' #watch use of path.stub_pwd instead of stub
+ end
+ def output_dir?
+ dir=SiSU_Env::Info_env.new('')
+ if @opt.cmd =~/d/
+ dir.path.webserv_stub_ensure
+ end
+ end
+ def create_table
+ def metadata_and_text
+ print %{
+ currently using sisu dbi module
+ to be populated from document files
+ create tables metadata_and_text
+ data import through ruby transfer
+ } unless @opt.cmd =~/q/
+ @conn.execute(%{
+ CREATE TABLE metadata_and_text (
+ tid BIGINT PRIMARY KEY,
+ /* title */
+ #{column.title.create_column}
+ #{column.title_main.create_column}
+ #{column.title_sub.create_column}
+ #{column.title_short.create_column}
+ #{column.title_edition.create_column}
+ #{column.title_note.create_column}
+ #{column.title_language.create_column}
+ #{column.title_language_char.create_column}
+ /* creator */
+ #{column.creator_author.create_column}
+ #{column.creator_author_honorific.create_column}
+ #{column.creator_author_nationality.create_column}
+ #{column.creator_editor.create_column}
+ #{column.creator_contributor.create_column}
+ #{column.creator_illustrator.create_column}
+ #{column.creator_photographer.create_column}
+ #{column.creator_translator.create_column}
+ #{column.creator_prepared_by.create_column}
+ #{column.creator_digitized_by.create_column}
+ #{column.creator_audio.create_column}
+ #{column.creator_video.create_column}
+ /* language */
+ #{column.language_document.create_column}
+ #{column.language_document_char.create_column}
+ #{column.language_original.create_column}
+ #{column.language_original_char.create_column}
+ /* date */
+ #{column.date_added_to_site.create_column}
+ #{column.date_available.create_column}
+ #{column.date_created.create_column}
+ #{column.date_issued.create_column}
+ #{column.date_modified.create_column}
+ #{column.date_published.create_column}
+ #{column.date_valid.create_column}
+ #{column.date_translated.create_column}
+ #{column.date_original_publication.create_column}
+ #{column.date_generated.create_column}
+ /* publisher */
+ #{column.publisher.create_column}
+ /* original */
+ #{column.original_publisher.create_column}
+ #{column.original_language.create_column}
+ #{column.original_language_char.create_column}
+ #{column.original_source.create_column}
+ #{column.original_institution.create_column}
+ #{column.original_nationality.create_column}
+ /* rights */
+ #{column.rights_all.create_column}
+ #{column.rights_copyright_text.create_column}
+ #{column.rights_copyright_translation.create_column}
+ #{column.rights_copyright_illustrations.create_column}
+ #{column.rights_copyright_photographs.create_column}
+ #{column.rights_copyright_preparation.create_column}
+ #{column.rights_copyright_digitization.create_column}
+ #{column.rights_copyright_audio.create_column}
+ #{column.rights_copyright_video.create_column}
+ #{column.rights_license.create_column}
+ /* classify */
+ #{column.classify_topic_register.create_column}
+ #{column.classify_subject.create_column}
+ #{column.classify_type.create_column}
+ #{column.classify_loc.create_column}
+ #{column.classify_dewey.create_column}
+ #{column.classify_oclc.create_column}
+ #{column.classify_pg.create_column}
+ #{column.classify_isbn.create_column}
+ #{column.classify_format.create_column}
+ #{column.classify_identifier.create_column}
+ #{column.classify_relation.create_column}
+ #{column.classify_coverage.create_column}
+ #{column.classify_keywords.create_column}
+ /* notes */
+ #{column.notes_abstract.create_column}
+ #{column.notes_comment.create_column}
+ #{column.notes_description.create_column}
+ #{column.notes_history.create_column}
+ #{column.notes_prefix.create_column}
+ #{column.notes_prefix_a.create_column}
+ #{column.notes_prefix_b.create_column}
+ #{column.notes_suffix.create_column}
+ /* src */
+ #{column.src_filename.create_column}
+ #{column.src_fingerprint.create_column}
+ #{column.src_filesize.create_column}
+ #{column.src_word_count.create_column}
+ #{column.src_txt.create_column}
+ /* misc */
+ #{column.fulltext.create_column}
+ #{column.skin_name.create_column}
+ #{column.skin_fingerprint.create_column}
+ #{column.skin.create_column}
+ #{column.links.create_column.gsub(/,$/,'')}
+/* subj VARCHAR(64) NULL, */
+/* contact VARCHAR(100) NULL, */
+/* information VARCHAR(100) NULL, */
+/* types CHAR(1) NULL, */
+/* writing_focus_nationality VARCHAR(100) NULL, */
+ );
+ })
+ @comment.psql.metadata_and_text if @comment
+ end
+ def doc_objects # create doc_objects base
+ print %{
+ to be populated from documents files
+ create tables doc_objects
+ data import through ruby transfer
+ } unless @opt.cmd =~/q/
+ @conn.execute(%{
+ CREATE TABLE doc_objects (
+ lid BIGINT PRIMARY KEY,
+ metadata_tid BIGINT REFERENCES metadata_and_text,
+ ocn SMALLINT,
+ ocnd VARCHAR(6),
+ ocns VARCHAR(6),
+ clean TEXT NULL,
+ body TEXT NULL,
+ seg VARCHAR(256) NULL,
+ lev_an VARCHAR(1),
+ lev SMALLINT NULL,
+ lev1 SMALLINT,
+ lev2 SMALLINT,
+ lev3 SMALLINT,
+ lev4 SMALLINT,
+ lev5 SMALLINT,
+ lev6 SMALLINT,
+ en_a SMALLINT NULL,
+ en_z SMALLINT NULL,
+ en_a_asterisk SMALLINT NULL,
+ en_z_asterisk SMALLINT NULL,
+ en_a_plus SMALLINT NULL,
+ en_z_plus SMALLINT NULL,
+ t_of VARCHAR(16),
+ t_is VARCHAR(16),
+ node VARCHAR(16) NULL,
+ parent VARCHAR(16) NULL,
+ digest_clean CHAR(#{@@dl}),
+ digest_all CHAR(#{@@dl}),
+ types CHAR(1) NULL
+ );
+ })
+ @comment.psql.doc_objects if @comment
+ end
+ def endnotes
+ print %{
+ to be populated from document files
+ create tables endnotes
+ data import through ruby transfer
+ } unless @opt.cmd =~/q/
+ @conn.execute(%{
+ CREATE TABLE endnotes (
+ nid BIGINT PRIMARY KEY,
+ document_lid BIGINT REFERENCES doc_objects,
+ nr SMALLINT,
+ clean TEXT NULL,
+ body TEXT NULL,
+ ocn SMALLINT,
+ ocnd VARCHAR(6),
+ ocns VARCHAR(6),
+ digest_clean CHAR(#{@@dl}),
+ metadata_tid BIGINT REFERENCES metadata_and_text
+ );
+ })
+ @comment.psql.endnotes if @comment
+ end
+ def endnotes_asterisk
+ print %{
+ to be populated from document files
+ create tables endnotes_asterisk
+ data import through ruby transfer
+ } unless @opt.cmd =~/q/
+ @conn.execute(%{
+ CREATE TABLE endnotes_asterisk (
+ nid BIGINT PRIMARY KEY,
+ document_lid BIGINT REFERENCES doc_objects,
+ nr SMALLINT,
+ clean TEXT NULL,
+ body TEXT NULL,
+ ocn SMALLINT,
+ ocnd VARCHAR(6),
+ ocns VARCHAR(6),
+ digest_clean CHAR(#{@@dl}),
+ metadata_tid BIGINT REFERENCES metadata_and_text
+ );
+ })
+ @comment.psql.endnotes_asterisk if @comment
+ end
+ def endnotes_plus
+ print %{
+ to be populated from document files
+ create tables endnotes_plus
+ data import through ruby transfer
+ } unless @opt.cmd =~/q/
+ @conn.execute(%{
+ CREATE TABLE endnotes_plus (
+ nid BIGINT PRIMARY KEY,
+ document_lid BIGINT REFERENCES doc_objects,
+ nr SMALLINT,
+ clean TEXT NULL,
+ body TEXT NULL,
+ ocn SMALLINT,
+ ocnd VARCHAR(6),
+ ocns VARCHAR(6),
+ digest_clean CHAR(#{@@dl}),
+ metadata_tid BIGINT REFERENCES metadata_and_text
+ );
+ })
+ @comment.psql.endnotes_plus if @comment
+ end
+ def urls # create doc_objects file links mapping
+ print %{
+ currently using sisu dbi module
+ to be populated from doc_objects files
+ create tables urls
+ data import through ruby transfer
+ } unless @opt.cmd =~/q/
+ @conn.execute(%{
+ CREATE TABLE urls (
+ metadata_tid BIGINT REFERENCES metadata_and_text,
+ plaintext varchar(512),
+ html_toc varchar(512),
+ html_doc varchar(512),
+ xhtml varchar(512),
+ xml_sax varchar(512),
+ xml_dom varchar(512),
+ odf varchar(512),
+ pdf_p varchar(512),
+ pdf_l varchar(512),
+ concordance varchar(512),
+ latex_p varchar(512),
+ latex_l varchar(512),
+ digest varchar(512),
+ manifest varchar(512),
+ markup varchar(512),
+ sisupod varchar(512)
+ );
+ })
+ @comment.psql.urls if @comment
+ end
+ self
+ end
+ end
+ class Comment < SiSU_DB_columns::Columns
+ def initialize(conn,sql_type='pg')
+ @conn=conn
+ if sql_type =~ /pg/; psql
+ end
+ end
+ def psql
+ def conn_execute_array(sql_arr)
+ @conn.transaction do |conn|
+ sql_arr.each do |sql|
+ conn.execute(sql)
+ end
+ end
+ end
+ def metadata_and_text
+ sql_arr=[
+ %{COMMENT ON Table metadata_and_text
+ IS 'contains SiSU metadata and fulltext for search (including source .sst if shared)';},
+ %{COMMENT ON COLUMN metadata_and_text.tid
+ IS 'unique';},
+ %{#{column.title.column_comment}},
+ %{#{column.title_main.column_comment}},
+ %{#{column.title_sub.column_comment}},
+ %{#{column.title_short.column_comment}},
+ %{#{column.title_edition.column_comment}},
+ %{#{column.title_note.column_comment}},
+ %{#{column.title_language.column_comment}},
+ %{#{column.title_language_char.column_comment}},
+ %{#{column.creator_author.column_comment}},
+ %{#{column.creator_author_honorific.column_comment}},
+ %{#{column.creator_author_nationality.column_comment}},
+ %{#{column.creator_editor.column_comment}},
+ %{#{column.creator_contributor.column_comment}},
+ %{#{column.creator_illustrator.column_comment}},
+ %{#{column.creator_photographer.column_comment}},
+ %{#{column.creator_translator.column_comment}},
+ %{#{column.creator_prepared_by.column_comment}},
+ %{#{column.creator_digitized_by.column_comment}},
+ %{#{column.creator_audio.column_comment}},
+ %{#{column.creator_video.column_comment}},
+ %{#{column.language_document.column_comment}},
+ %{#{column.language_document_char.column_comment}},
+ %{#{column.language_original.column_comment}},
+ %{#{column.language_original_char.column_comment}},
+ %{#{column.date_added_to_site.column_comment}},
+ %{#{column.date_available.column_comment}},
+ %{#{column.date_created.column_comment}},
+ %{#{column.date_issued.column_comment}},
+ %{#{column.date_modified.column_comment}},
+ %{#{column.date_published.column_comment}},
+ %{#{column.date_valid.column_comment}},
+ %{#{column.date_translated.column_comment}},
+ %{#{column.date_original_publication.column_comment}},
+ %{#{column.date_generated.column_comment}},
+ %{#{column.publisher.column_comment}},
+ %{#{column.original_publisher.column_comment}},
+ %{#{column.original_language.column_comment}},
+ %{#{column.original_language_char.column_comment}},
+ %{#{column.original_source.column_comment}},
+ %{#{column.original_institution.column_comment}},
+ %{#{column.original_nationality.column_comment}},
+ %{#{column.rights_all.column_comment}},
+ %{#{column.rights_copyright_text.column_comment}},
+ %{#{column.rights_copyright_translation.column_comment}},
+ %{#{column.rights_copyright_illustrations.column_comment}},
+ %{#{column.rights_copyright_photographs.column_comment}},
+ %{#{column.rights_copyright_preparation.column_comment}},
+ %{#{column.rights_copyright_digitization.column_comment}},
+ %{#{column.rights_copyright_audio.column_comment}},
+ %{#{column.rights_copyright_video.column_comment}},
+ %{#{column.rights_license.column_comment}},
+ %{#{column.classify_topic_register.column_comment}},
+ %{#{column.classify_subject.column_comment}},
+ %{#{column.classify_type.column_comment}},
+ %{#{column.classify_loc.column_comment}},
+ %{#{column.classify_dewey.column_comment}},
+ %{#{column.classify_oclc.column_comment}},
+ %{#{column.classify_pg.column_comment}},
+ %{#{column.classify_isbn.column_comment}},
+ %{#{column.classify_format.column_comment}},
+ %{#{column.classify_identifier.column_comment}},
+ %{#{column.classify_relation.column_comment}},
+ %{#{column.classify_coverage.column_comment}},
+ %{#{column.classify_keywords.column_comment}},
+ %{#{column.notes_abstract.column_comment}},
+ %{#{column.notes_comment.column_comment}},
+ %{#{column.notes_description.column_comment}},
+ %{#{column.notes_history.column_comment}},
+ %{#{column.notes_prefix.column_comment}},
+ %{#{column.notes_prefix_a.column_comment}},
+ %{#{column.notes_prefix_b.column_comment}},
+ %{#{column.notes_suffix.column_comment}},
+ %{#{column.src_filename.column_comment}},
+ %{#{column.src_fingerprint.column_comment}},
+ %{#{column.src_filesize.column_comment}},
+ %{#{column.src_word_count.column_comment}},
+ %{#{column.src_txt.column_comment}},
+ %{#{column.fulltext.column_comment}},
+ %{#{column.skin_name.column_comment}},
+ %{#{column.skin_fingerprint.column_comment}},
+ %{#{column.skin.column_comment}},
+ %{#{column.links.column_comment}},
+ ]
+ conn_execute_array(sql_arr)
+ end
+ def doc_objects
+ sql_arr=[
+ %{COMMENT ON Table doc_objects
+ IS 'contains searchable text of SiSU document objects';},
+ %{COMMENT ON COLUMN doc_objects.lid
+ IS 'unique';},
+ %{COMMENT ON COLUMN doc_objects.metadata_tid
+ IS 'tie to title in metadata_and_text';},
+ %{COMMENT ON COLUMN doc_objects.lev_an
+ IS 'doc level A-C 1-6';},
+ %{COMMENT ON COLUMN doc_objects.lev
+ IS 'doc level 1-6 \d\~';},
+ %{COMMENT ON COLUMN doc_objects.seg
+ IS 'segment name from level number 4 (lv 1)';},
+ %{COMMENT ON COLUMN doc_objects.ocn
+ IS 'object citation number';},
+ %{COMMENT ON COLUMN doc_objects.en_a
+ IS 'first endnote number in text object (eg. NULL or 34) (used with en_z to create range)';},
+ %{COMMENT ON COLUMN doc_objects.en_z
+ IS 'last endnote number within text object (eg. NULL, 34 or say 47) (used with en_a to create range)';},
+ %{COMMENT ON COLUMN doc_objects.en_a_asterisk
+ IS 'first endnote number in text object (eg. NULL or 34) (used with en_z_asterisk to create range)';},
+ %{COMMENT ON COLUMN doc_objects.en_z_asterisk
+ IS 'last endnote number within text object (eg. NULL, 34 or say 47) (used with en_a_asterisk to create range)';},
+ %{COMMENT ON COLUMN doc_objects.en_a_plus
+ IS 'first endnote number in text object (eg. NULL or 34) (used with en_z_plus to create range)';},
+ %{COMMENT ON COLUMN doc_objects.en_z_plus
+ IS 'last endnote number within text object (eg. NULL, 34 or say 47) (used with en_a_plus to create range)';},
+ %{COMMENT ON COLUMN doc_objects.types
+ IS 'document types seg scroll';},
+ %{COMMENT ON COLUMN doc_objects.clean
+ IS 'text object - substantive text: clean, stripped of markup';},
+ %{COMMENT ON COLUMN doc_objects.body
+ IS 'text object - substantive text: light html markup';},
+ %{COMMENT ON COLUMN doc_objects.lev1
+ IS 'document structure, level number 1';},
+ %{COMMENT ON COLUMN doc_objects.lev2
+ IS 'document structure, level number 2';},
+ %{COMMENT ON COLUMN doc_objects.lev3
+ IS 'document structure, level number 3';},
+ %{COMMENT ON COLUMN doc_objects.lev4
+ IS 'document structure, level number 4';},
+ %{COMMENT ON COLUMN doc_objects.lev5
+ IS 'document structure, level number 5';},
+ %{COMMENT ON COLUMN doc_objects.lev6
+ IS 'document structure, level number 6';},
+ %{COMMENT ON COLUMN doc_objects.t_of
+ IS 'document structure, type of object (object is of)';},
+ %{COMMENT ON COLUMN doc_objects.t_is
+ IS 'document structure, object is';},
+ %{COMMENT ON COLUMN doc_objects.node
+ IS 'document structure, object node if heading';},
+ %{COMMENT ON COLUMN doc_objects.parent
+ IS 'document structure, object parent (is a heading)';}
+ ]
+ conn_execute_array(sql_arr)
+ end
+ def endnotes
+ sql_arr=[
+ %{COMMENT ON Table endnotes
+ IS 'contains searchable text of SiSU documents endnotes';},
+ %{COMMENT ON COLUMN endnotes.nid
+ IS 'unique';},
+ %{COMMENT ON COLUMN endnotes.document_lid
+ IS 'ties to text block from which referenced';},
+ %{COMMENT ON COLUMN endnotes.nr
+ IS 'endnote number ';},
+ %{COMMENT ON COLUMN endnotes.clean
+ IS 'endnote substantive content, stripped of markup';},
+ %{COMMENT ON COLUMN endnotes.body
+ IS 'endnote substantive content';},
+ %{COMMENT ON COLUMN endnotes.ocn
+ IS 'object citation no# <\~(\d+)> from which endnote is referenced';},
+ %{COMMENT ON COLUMN doc_objects.metadata_tid
+ IS 'tie to title in metadata_and_text - unique for each document';}
+ ]
+ conn_execute_array(sql_arr)
+ end
+ def endnotes_asterisk
+ sql_arr=[
+ %{COMMENT ON Table endnotes_asterisk
+ IS 'contains searchable text of SiSU documents endnotes marked with asterisk';},
+ %{COMMENT ON COLUMN endnotes_asterisk.nid
+ IS 'unique';},
+ %{COMMENT ON COLUMN endnotes_asterisk.document_lid
+ IS 'ties to text block from which referenced';},
+ %{COMMENT ON COLUMN endnotes_asterisk.nr
+ IS 'endnote number ';},
+ %{COMMENT ON COLUMN endnotes_asterisk.clean
+ IS 'endnote substantive content, stripped of markup';},
+ %{COMMENT ON COLUMN endnotes_asterisk.body
+ IS 'endnote substantive content';},
+ %{COMMENT ON COLUMN endnotes_asterisk.ocn
+ IS 'object citation no# <\~(\d+)> from which endnote is referenced';},
+ %{COMMENT ON COLUMN doc_objects.metadata_tid
+ IS 'tie to title in metadata_and_text - unique for each document';}
+ ]
+ conn_execute_array(sql_arr)
+ end
+ def endnotes_plus
+ sql_arr=[
+ %{COMMENT ON Table endnotes_plus
+ IS 'contains searchable text of SiSU documents endnotes marked with plus';},
+ %{COMMENT ON COLUMN endnotes_plus.nid
+ IS 'unique';},
+ %{COMMENT ON COLUMN endnotes_plus.document_lid
+ IS 'ties to text block from which referenced';},
+ %{COMMENT ON COLUMN endnotes_plus.nr
+ IS 'endnote number ';},
+ %{COMMENT ON COLUMN endnotes_plus.clean
+ IS 'endnote substantive content, stripped of markup';},
+ %{COMMENT ON COLUMN endnotes_plus.body
+ IS 'endnote substantive content';},
+ %{COMMENT ON COLUMN endnotes_plus.ocn
+ IS 'object citation no# <\~(\d+)> from which endnote is referenced';},
+ %{COMMENT ON COLUMN doc_objects.metadata_tid
+ IS 'tie to title in metadata_and_text - unique for each document';},
+ ]
+ conn_execute_array(sql_arr)
+ end
+ def urls
+ sql_arr=[
+ %{COMMENT ON Table urls
+ IS 'contains base url links to different SiSU output';},
+ %{COMMENT ON COLUMN doc_objects.metadata_tid
+ IS 'tie to title in metadata_and_text - unique for each document, the mapping of rows is one to one';},
+ %{COMMENT ON COLUMN urls.plaintext
+ IS 'plaintext utf-8';},
+ %{COMMENT ON COLUMN urls.html_toc
+ IS 'table of contents for segmented html document';},
+ %{COMMENT ON COLUMN urls.html_doc
+ IS 'html document (scroll)';},
+ %{COMMENT ON COLUMN urls.xhtml
+ IS 'xhtml document (scroll)';},
+ %{COMMENT ON COLUMN urls.xml_sax
+ IS 'xml sax oriented document (scroll)';},
+ %{COMMENT ON COLUMN urls.xml_dom
+ IS 'xml dom oriented document (scroll)';},
+ %{COMMENT ON COLUMN urls.odf
+ IS 'opendocument format text';},
+ %{COMMENT ON COLUMN urls.pdf_p
+ IS 'pdf portrait';},
+ %{COMMENT ON COLUMN urls.pdf_l
+ IS 'pdf landscape';},
+ %{COMMENT ON COLUMN urls.concordance
+ IS 'rudimentary document index linked to html';},
+ %{COMMENT ON COLUMN urls.latex_p
+ IS 'latex portrait';},
+ %{COMMENT ON COLUMN urls.latex_l
+ IS 'latex_landscape';},
+ %{COMMENT ON COLUMN urls.markup
+ IS 'markup';},
+ %{COMMENT ON COLUMN urls.sisupod
+ IS 'SiSU document format .tgz (all SiSU information on document)';},
+ ]
+ conn_execute_array(sql_arr)
+ end
+ self
+ end
+ end
+end
+__END__
diff --git a/lib/sisu/v3dv/db_dbi.rb b/lib/sisu/v3dv/db_dbi.rb
new file mode 100644
index 00000000..c290c9e3
--- /dev/null
+++ b/lib/sisu/v3dv/db_dbi.rb
@@ -0,0 +1,93 @@
+# encoding: utf-8
+=begin
+
+ * Name: SiSU
+
+ * Description: a framework for document structuring, publishing and search
+
+ * Author: Ralph Amissah
+
+ * Copyright: (C) 1997 - 2012, 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 .
+
+ If you have Internet connection, the latest version of the GPL should be
+ available at these locations:
+
+
+
+
+
+
+
+ * SiSU uses:
+ * Standard SiSU markup syntax,
+ * Standard SiSU meta-markup syntax, and the
+ * Standard SiSU object citation numbering and system
+
+ * Hompages:
+
+
+
+ * Download:
+
+
+ * Ralph Amissah
+
+
+
+ ** Description: modules shared by the different db types, dbi, postgresql,
+ sqlite
+
+=end
+module SiSU_DB_DBI
+ require_relative 'db_columns' # db_columns.rb
+ require_relative 'db_tests' # db_tests.rb
+ require_relative 'db_create' # db_create.rb
+ require_relative 'db_select' # db_select.rb
+ require_relative 'db_indexes' # db_indexes.rb
+ require_relative 'db_drop' # db_drop.rb
+ require_relative 'db_remove' # db_remove.rb
+ require_relative 'db_load_tuple' # db_load_tuple.rb
+ require_relative 'db_import' # db_import.rb
+ class Column_size < SiSU_DB_columns::Column_size # db_columns.rb
+ end
+ class Test < SiSU_DB_tests::Test # db_tests.rb
+ end
+ class Create .
+
+ If you have Internet connection, the latest version of the GPL should be
+ available at these locations:
+
+
+
+
+
+
+
+ * SiSU uses:
+ * Standard SiSU markup syntax,
+ * Standard SiSU meta-markup syntax, and the
+ * Standard SiSU object citation numbering and system
+
+ * Hompages:
+
+
+
+ * Download:
+
+
+ * Ralph Amissah
+
+
+
+ ** Description: modules shared by the different db types, dbi, postgresql,
+ sqlite
+
+=end
+module SiSU_DB_drop
+ class Drop
+ require_relative 'response' # response.rb
+ def initialize(opt,conn,db_info,sql_type='')
+ @opt,@conn,@db_info,@sql_type=opt,conn,db_info,sql_type
+ @ans=SiSU_Response::Response.new
+ case @sql_type
+ when /sqlite/
+ cascade=''
+ else
+ cascade='CASCADE'
+ end
+ @drop_table=[
+ "DROP TABLE metadata_and_text #{cascade};",
+ "DROP TABLE doc_objects #{cascade};",
+ "DROP TABLE urls #{cascade};",
+ "DROP TABLE endnotes #{cascade};",
+ "DROP TABLE endnotes_asterisk #{cascade};",
+ "DROP TABLE endnotes_plus #{cascade};",
+ ]
+ end
+ def drop
+ def tables #% drop all tables
+ begin
+ msg_sqlite="as not all disk space is recovered after dropping the database << #{@db_info.sqlite.db} >>, you may be better off deleting the file, and recreating it as necessary"
+ case @sql_type
+ when /sqlite/
+ puts msg_sqlite
+ ans=@ans.response?('remove sql database?')
+ if ans \
+ and File.exist?(@db_info.sqlite.db)
+ @conn.close
+ File.unlink(@db_info.sqlite.db)
+ db=SiSU_Env::Info_db.new
+ conn=db.sqlite.conn_sqlite3
+ sdb=SiSU_DB_DBI::Create.new(@opt,conn,@db_info,@sql_type)
+ sdb_index=SiSU_DB_DBI::Index.new(@opt,conn,@db_info,@sql_type)
+ sdb.output_dir?
+ begin
+ sdb.create_db
+ sdb.create_table.metadata_and_text
+ sdb.create_table.doc_objects
+ sdb.create_table.endnotes
+ sdb.create_table.endnotes_asterisk
+ sdb.create_table.endnotes_plus
+ sdb.create_table.urls
+ sdb_index.create_indexes
+ rescue; SiSU_Errors::Info_error.new($!,$@,'-D').error; @sdb.output_dir?
+ end
+ exit
+ else
+ @conn.transaction
+ @drop_table.each do |d|
+ @conn.execute(d)
+ end
+ @conn.commit
+ end
+ else
+ @drop_table.each do |d|
+ @conn.execute(d)
+ end
+ end
+ rescue
+ case @sql_type
+ when /sqlite/
+ ans=@ans.response?('remove sql database?')
+ if ans and File.exist?(@db_info.sqlite.db); File.unlink(@db_info.sqlite.db)
+ end
+ else
+ @drop_table.each do |d|
+ @conn.execute(d)
+ end
+ end
+ ensure
+ end
+ end
+ def indexes
+ def conn_execute_array(sql_arr)
+ @conn.transaction do |conn|
+ sql_arr.each do |sql|
+ conn.execute(sql)
+ end
+ end
+ end
+ def base #% drop base indexes
+ print "\n drop documents common indexes\n" unless @opt.cmd =~/q/
+ sql_arr=[
+ %{DROP INDEX idx_title;},
+ %{DROP INDEX idx_author;},
+ %{DROP INDEX idx_filename;},
+ %{DROP INDEX idx_topics;},
+ %{DROP INDEX idx_ocn;},
+ %{DROP INDEX idx_digest_clean;},
+ %{DROP INDEX idx_digest_all;},
+ %{DROP INDEX idx_lev1;},
+ %{DROP INDEX idx_lev2;},
+ %{DROP INDEX idx_lev3;},
+ %{DROP INDEX idx_lev4;},
+ %{DROP INDEX idx_lev5;},
+ %{DROP INDEX idx_lev6;},
+ %{DROP INDEX idx_endnote_nr;},
+ %{DROP INDEX idx_digest_en;},
+ %{DROP INDEX idx_endnote_nr_asterisk;},
+ %{DROP INDEX idx_endnote_asterisk;},
+ %{DROP INDEX idx_digest_en_asterisk;},
+ %{DROP INDEX idx_endnote_nr_plus;},
+ %{DROP INDEX idx_endnote_plus;},
+ %{DROP INDEX idx_digest_en_plus},
+ ]
+ conn_execute_array(sql_arr)
+ end
+ def text #% drop TEXT indexes, sqlite
+ print "\n drop documents TEXT indexes\n" unless @opt.cmd =~/q/
+ sql_arr=[
+ %{DROP INDEX idx_clean;},
+ %{DROP INDEX idx_endnote},
+ ]
+ conn_execute_array(sql_arr)
+ end
+ self
+ end
+ indexes.base
+ @opt.cmd=~/D/ || ((@opt.mod=~/psql/) ? '' : indexes.text)
+ self
+ end
+ end
+end
+__END__
diff --git a/lib/sisu/v3dv/db_import.rb b/lib/sisu/v3dv/db_import.rb
new file mode 100644
index 00000000..a78a0656
--- /dev/null
+++ b/lib/sisu/v3dv/db_import.rb
@@ -0,0 +1,666 @@
+# encoding: utf-8
+=begin
+
+ * Name: SiSU
+
+ * Description: a framework for document structuring, publishing and search
+
+ * Author: Ralph Amissah
+
+ * Copyright: (C) 1997 - 2012, 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 .
+
+ If you have Internet connection, the latest version of the GPL should be
+ available at these locations:
+
+
+
+
+
+
+
+ * SiSU uses:
+ * Standard SiSU markup syntax,
+ * Standard SiSU meta-markup syntax, and the
+ * Standard SiSU object citation numbering and system
+
+ * Hompages:
+
+
+
+ * Download:
+
+
+ * Ralph Amissah
+
+
+
+ ** Description: modules shared by the different db types, dbi, postgresql,
+ sqlite
+
+=end
+module SiSU_DB_import
+ require_relative 'db_columns' # db_columns.rb
+ require_relative 'db_load_tuple' # db_load_tuple.rb
+ require_relative 'db_sqltxt' # db_sqltxt.rb
+ require_relative 'shared_html_lite' # shared_html_lite.rb
+ require 'sqlite3'
+ class Import < SiSU_DB_text::Prepare
+ include SiSU_Param
+ include SiSU_Screen
+ @@dl=nil
+ @@hname=nil
+ attr_accessor :tp
+ def initialize(opt,conn,file,sql_type='pg')
+ @opt,@conn,@file,@sql_type=opt,conn,file,sql_type
+ @cX=SiSU_Screen::Ansi.new(@opt.cmd).cX
+ @env=SiSU_Env::Info_env.new(@opt.fns)
+ @dal="#{@env.processing_path.dal}"
+ if @opt.fns.empty? or @opt.cmd.empty?; @fnb=''
+ else
+ @md=SiSU_Param::Parameters.new(@opt).get
+ @fnb=@md.fnb
+ end
+ @suffix=@opt.fns[/(?:.+?)(?:\.ssm\.sst|\.-?sst)/,1]
+ @fnc="#{@dal}/#{@opt.fns}.content.rbm"
+ @@seg,@@seg_full='','' #create? consider placing field just before clean text as opposed to seg which contains seg(.html) name info seg_full would contain seg info for levels 5 & 6 where available eg seg_full may be 7.3 (level 5) and 7.3.1 (level 6) where seg is 7
+ @col=Hash.new('')
+ @col[:ocn]=''
+ @counter={}
+ @db=SiSU_Env::Info_db.new
+ if @sql_type=='sqlite'
+ @driver_sqlite3=(@conn.inspect.match(/^(.{10})/)[1]==@db.sqlite.conn_sqlite3.inspect.match(/^(.{10})/)[1]) \
+ ? true
+ : false
+ end
+ sql='SELECT MAX(lid) FROM doc_objects'
+ begin
+ @col[:lid] ||=0
+ @col[:lid]=@driver_sqlite3 \
+ ? @conn.execute( sql ).join.to_i
+ : @conn.execute( sql ) { |x| x.fetch_all.flatten[0] }
+ rescue
+ puts "#{__FILE__}:#{__LINE__}" if @opt.cmd =~/M/
+ end
+ @col[:lid]=0 if @col[:lid].nil? or @col[:lid].to_s.empty?
+ sql='SELECT MAX(nid) FROM endnotes'
+ begin
+ @id_n=@driver_sqlite3 \
+ ? @conn.execute( sql ).join.to_i
+ : @id_n=@conn.execute( sql ) { |x| x.fetch_all.flatten[0] }
+ @id_n ||=0
+ rescue
+ puts "#{__FILE__}:#{__LINE__}" if @opt.cmd =~/M/
+ end
+ @id_n =0 if @col[:lid].nil? or @col[:lid].to_s.empty?
+ @col[:lv1]=@col[:lv2]=@col[:lv3]=@col[:lv4]=@col[:lv5]=@col[:lv6]=0
+ @db=SiSU_Env::Info_db.new
+ @@dl ||=SiSU_Env::Info_env.new.digest.length
+ end
+ def marshal_load
+ require_relative 'dal' # dal.rb
+ @dal_array=SiSU_DAL::Source.new(@opt).get # dal file drawn here
+ SiSU_Screen::Ansi.new(@opt.cmd,"#{@db.psql.db}::#{@opt.fns}").puts_blue if @opt.cmd =~/vVM/
+ SiSU_Screen::Ansi.new(@opt.cmd,'Marshal Load',@fnc).puts_grey if @opt.cmd =~/v/
+#%
+ select_first_match=%{
+ SELECT metadata_and_text.tid
+ FROM metadata_and_text
+ WHERE metadata_and_text.src_filename = '#{@opt.fns}'
+ AND metadata_and_text.language_document_char = '#{@opt.lng}'
+ ;}
+ file_exist=@sql_type=~/sqlite/ \
+ ? @conn.get_first_value(select_first_match)
+ : @conn.select_one(select_first_match)
+ if not file_exist
+ t_d=[] # transaction_data
+ t_d << db_import_metadata
+ t_d << db_import_documents(@dal_array)
+ t_d << db_import_urls(@dal_array,@fnc) #import OID on/off
+ t_d=t_d.flatten
+ if @opt.cmd =~/[MV]/
+ puts @conn.class if defined? @conn.class
+ puts @conn.driver_name if defined? @conn.driver_name
+ puts @conn.driver if defined? @conn.driver
+ end
+ begin
+ sql=''
+ if @sql_type=~/sqlite/
+ @conn.transaction do |conn|
+ t_d.each do |sql|
+ conn.execute(sql)
+ end
+ end
+ #also 'execute' works for sqlite
+ #@conn.execute("BEGIN")
+ # t_d.each do |sql|
+ # @conn.execute(sql)
+ # end
+ #@conn.execute("COMMIT")
+ else
+ #'do' works for postgresql
+ @conn.do("BEGIN")
+ t_d.each do |sql|
+ @conn.do(sql)
+ end
+ @conn.do("COMMIT")
+ end
+ rescue DBI::DatabaseError => e
+ puts "Error code: #{e.err}"
+ puts "Error message: #{e.errstr}"
+ puts "Error SQLSTATE: #{e.state}"
+ SiSU_Errors::Info_error.new($!,$@,@opt.cmd,@opt.fns).error
+ sqlfn="#{@env.processing_path.sql}/#{@md.fnb}.sql"
+ sql=File.new(sqlfn,'w')
+ t_d.each {|i| sql.puts i}
+ p sqlfn
+ if @opt.cmd =~/M/
+ puts sql
+ p @conn.methods.sort
+ puts "#{__FILE__}:#{__LINE__}"
+ end
+ rescue
+ SiSU_Errors::Info_error.new($!,$@,@opt.cmd,@opt.fns).error
+ sqlfn="#{@env.processing_path.sql}/#{@md.fnb}.sql"
+ sql=File.new(sqlfn,'w')
+ t_d.each {|i| sql.puts i}
+ p sqlfn
+ if @opt.cmd =~/M/
+ puts sql
+ p @conn.methods.sort
+ puts "#{__FILE__}:#{__LINE__}"
+ end
+ ensure
+ end
+ else
+ if file_exist
+ @db=SiSU_Env::Info_db.new
+ puts "\n#{@cX.grey}file #{@cX.off} #{@cX.blue}#{@opt.fns}#{@cX.off} in language code #{cX.blue}#{@opt.lng}#{cX.off} #{@cX.grey}already exists in database#{@cX.off} #{@cX.blue}#{@db.psql.db}#{@cX.off} #{@cX.brown}update instead?#{@cX.off}"
+ end
+ end
+ end
+ def pf_db_import_transaction_open
+ end
+ def pf_db_import_transaction_close
+ end
+ def db_import_metadata #% import documents - populate database
+ print %{ #{@cX.grey}import documents dbi_unit #{@cX.off} } if @opt.cmd =~/vVM/
+ @tp={}
+ @md=SiSU_Param::Parameters.new(@opt).get
+#% sisutxt & fulltxt
+ if FileTest.exist?(@md.fns)
+ txt_arr=IO.readlines(@md.fns,'')
+ src=txt_arr.join("\n")
+ src=special_character_escape(src)
+ @tp[:sisutxt_f],@tp[:sisutxt_i]='sisutxt, ',"'#{src}', "
+ txt=clean_searchable_text(txt_arr)
+ #special_character_escape(txt)
+ @tp[:fulltxt_f],@tp[:fulltxt_i]='fulltxt, ',"'#{txt}', "
+ end
+#% title
+ if defined? @md.title.full \
+ and @md.title.full=~/\S+/ # DublinCore 1 - title
+ #@tp[:title]=@md.title.full
+ #special_character_escape(@tp[:title])
+ #@tp[:title_f],@tp[:title_i]='title, ',"'#{@tp[:title]}', "
+ sql='SELECT MAX(tid) FROM metadata_and_text;'
+ begin
+ @@id_t ||=0
+ id_t=if @driver_sqlite3
+ @conn.execute( sql ).join.to_i # { |x| id_t=x.join.to_i }
+ else
+ @conn.execute( sql ) { |x| x.fetch_all.flatten[0] }
+ end
+ @@id_t=id_t if id_t
+ rescue
+ puts "#{__FILE__} #{__LINE__}" if @opt.cmd =~/M/
+ end
+ @@id_t+=1 #bug related, needs to be performed once at start of file, but consider moving, as, placed here it means program will fail if document header lacks @title:
+ puts %{\n#{@cX.grey}Processing file number#{@cX.off}: #{@cX.green}#{@@id_t}#{@@cX.off}} if @opt.cmd =~/vVM/
+ end
+ ################ CLEAR ##############
+ SiSU_DB_DBI::Test.new(self,@opt).verify #% import title names, filenames (tuple)
+ t=SiSU_DB_tuple::Load_metadata.new(@conn,@@id_t,@md,@file)
+ tuple=t.tuple
+ tuple
+ end
+ def db_import_documents(dal_array) #% import documents - populate main database table, import into substantive database tables (tuple)
+ begin
+ @col[:tid]=@@id_t
+ @en,@en_ast,@en_pls,@tuple_array=[],[],[],[]
+ @col[:en_a],@col[:en_z]=nil,nil
+ dal_array.each do |data|
+ data.obj.gsub!(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'\1')
+ data.obj.gsub!(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'\1')
+ data.obj.gsub!(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'\1')
+ data.obj.gsub!(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,'\1')
+ data.obj.gsub!(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,'\1')
+ data.obj.gsub!(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'\1')
+ data.obj.gsub!(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,'\1')
+ data.obj.gsub!(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,'\1')
+ data.obj.gsub!(/#{Mx[:fa_monospace_o]}(.+?)#{Mx[:fa_monospace_c]}/,'\1')
+ data.obj.gsub!(/#{Mx[:gl_o]}(●)#{Mx[:gl_c]}\s*/,'\1 ')
+ data.obj.gsub!(/#{Mx[:tag_o]}\S+?#{Mx[:tag_c]}/,'') #check
+ @col[:seg]=@@seg
+ if data.of =~/para|heading|block|group/ # regular text what of code-blocks grouped text etc.
+ notedata=data.obj.dup
+ if data.is=='heading' \
+ and data.ln.inspect=~/[123]/
+ @col[:lev],txt,@col[:ocn],@col[:lev_an],@col[:ocnd],@col[:ocns],@col[:t_of],@col[:t_is],@col[:node],@col[:parent],@col[:digest_clean],@col[:digest_all]=data.ln,data.obj,data.ocn,data.lv,data.odv,data.osp,data.of,data.is,data.node,data.parent,'',''
+ @col[:lid]+=1
+ txt=endnotes(txt).extract_any
+ @col[:body]=SiSU_Format_Shared::CSS_Format.new(@md,data).lev4_minus
+ special_character_escape(@col[:body])
+ @col[:plaintext]=@col[:body].dup
+ @col[:plaintext]=strip_markup(@col[:plaintext])
+ @col[:plaintext]=clean_searchable_text(@col[:plaintext])
+ if @en[0]; @en_a,@en_z=@en[0].first,@en[0].last
+ end
+ if @en_ast[0]; @en_a_asterisk,@en_z_asterisk=@en_ast[0].first,@en_ast[0].last
+ end
+ if @en_pls[0]; @en_a_plus,@en_z_plus=@en_pls[0].first,@en_pls[0].last
+ end
+ t=SiSU_DB_tuple::Load_documents.new(@conn,@col,@opt,@file)
+ @tuple_array << t.tuple
+ case @col[:lev]
+ when /1/; @col[:lv1]+=1
+ when /2/; @col[:lv2]+=1
+ when /3/; @col[:lv3]+=1
+ end
+ @col[:lev]=@col[:plaintext]=@col[:body]=''
+ elsif data.is=='heading' \
+ and data.ln==4
+ @@seg,txt,@col[:ocn],@col[:lev_an],@col[:ocnd],@col[:ocns],@col[:t_of],@col[:t_is],@col[:node],@col[:parent],@col[:digest_clean],@col[:digest_all]=data.name,data.obj,data.ocn,data.lv,data.odv,data.osp,data.of,data.is,data.node,data.parent,'',''
+ @col[:seg]=@@seg
+ @col[:lv4]+=1
+ @col[:lid]+=1
+ @col[:lev]=4
+ @hname=if @col[:seg] \
+ and not @col[:seg].to_s.empty?
+ @@hname=@col[:seg].to_s
+ else @@hname
+ end
+ @env=SiSU_Env::Info_env.new(@md.fns)
+ @base_url="#{@env.url.root}/#{@md.fnb}/#{@hname}.html"
+ txt=endnotes(txt).extract_any
+ @col[:body]=SiSU_Format_Shared::CSS_Format.new(@md,data).lev4_plus
+ special_character_escape(@col[:body])
+ @col[:plaintext]=@col[:body].dup
+ @col[:plaintext]=strip_markup(@col[:plaintext])
+ @col[:plaintext]=clean_searchable_text(@col[:plaintext])
+ @en_a,@en_z=@en[0].first,@en[0].last if @en[0]
+ @en_a_asterisk,@en_z_asterisk=@en_ast[0].first,@en_ast[0].last if @en_ast[0]
+ @en_a_plus,@en_z_plus=@en_pls[0].first,@en_pls[0].last if @en_pls[0]
+ t=SiSU_DB_tuple::Load_documents.new(@conn,@col,@opt,@file)
+ @tuple_array << t.tuple
+ @col[:lev]=@col[:plaintext]=@col[:body]=''
+ elsif data.is=='heading' and data.ln==5
+ txt,@col[:ocn],@col[:lev_an],@col[:ocnd],@col[:ocns],@col[:t_of],@col[:t_is],@col[:node],@col[:parent],@col[:digest_clean],@col[:digest_all]=data.obj,data.ocn,data.lv,data.odv,data.osp,data.of,data.is,data.node,data.parent,'',''
+ @@seg_full=data.name if data.is=='heading' and data.ln==5 and data.name #check data.name
+ @@seg ||='' #nil # watch
+ @col[:seg]=@@seg
+ @col[:lv5]+=1
+ @col[:lid]+=1
+ @col[:lev]=5
+ @hname=if @col[:seg] \
+ and not @col[:seg].to_s.empty?
+ @@hname=@col[:seg].to_s
+ else @@hname
+ end
+ @env=SiSU_Env::Info_env.new(@md.fns)
+ @base_url="#{@env.url.root}/#{@md.fnb}/#{@hname}.html"
+ txt=endnotes(txt).extract_any
+ @col[:body]=SiSU_Format_Shared::CSS_Format.new(@md,data).lev4_plus
+ special_character_escape(@col[:body])
+ @col[:plaintext]=@col[:body].dup
+ @col[:plaintext]=strip_markup(@col[:plaintext])
+ @col[:plaintext]=clean_searchable_text(@col[:plaintext])
+ @en_a,@en_z=@en[0].first,@en[0].last if @en[0]
+ @en_a_asterisk,@en_z_asterisk=@en_ast[0].first,@en_ast[0].last if @en_ast[0]
+ @en_a_plus,@en_z_plus=@en_pls[0].first,@en_pls[0].last if @en_pls[0]
+ t=SiSU_DB_tuple::Load_documents.new(@conn,@col,@opt,@file)
+ @tuple_array << t.tuple
+ @col[:lev]=@col[:plaintext]=@col[:body]=''
+ elsif data.is=='heading' and data.ln==6
+ txt,@col[:ocn],@col[:lev_an],@col[:ocnd],@col[:ocns],@col[:t_of],@col[:t_is],@col[:node],@col[:parent],@col[:digest_clean],@col[:digest_all]=data.obj,data.ocn,data.lv,data.odv,data.osp,data.of,data.is,data.node,data.parent,'',''
+ @@seg_full=data.name if data.is=='heading' and data.ln==6 and data.name #check data.name
+ @@seg ||='' #nil # watch
+ @col[:seg]=@@seg
+ @col[:lv6]+=1
+ @col[:lid]+=1
+ @col[:lev]=6
+ @hname=if @col[:seg] \
+ and not @col[:seg].to_s.empty?
+ @@hname=@col[:seg].to_s
+ else @@hname
+ end
+ @env=SiSU_Env::Info_env.new(@md.fns)
+ @base_url="#{@env.url.root}/#{@md.fnb}/#{@hname}.html"
+ txt=endnotes(txt).extract_any
+ @col[:body]=SiSU_Format_Shared::CSS_Format.new(@md,data).lev4_plus
+ special_character_escape(@col[:body])
+ @col[:plaintext]=@col[:body].dup
+ @col[:plaintext]=strip_markup(@col[:plaintext])
+ @col[:plaintext]=clean_searchable_text(@col[:plaintext])
+ @en_a,@en_z=@en[0].first,@en[0].last if @en[0]
+ @en_a_asterisk,@en_z_asterisk=@en_ast[0].first,@en_ast[0].last if @en_ast[0]
+ @en_a_plus,@en_z_plus=@en_pls[0].first,@en_pls[0].last if @en_pls[0]
+ t=SiSU_DB_tuple::Load_documents.new(@conn,@col,@opt,@file)
+ @tuple_array << t.tuple
+ @col[:lev]=@col[:plaintext]=@col[:body]=''
+ else #% regular text
+ @col[:lid]+=1
+ txt=''
+ txt,@col[:ocn],@col[:ocnd],@col[:ocns],@col[:t_of],@col[:t_is],@col[:node],@col[:parent],@col[:digest_clean],@col[:digest_all]=data.obj,data.ocn,data.odv,data.osp,data.of,data.is,'',data.parent,'',''
+ @hname=if @col[:seg] \
+ and not @col[:seg].to_s.empty?
+ @@hname=@col[:seg].to_s
+ else @@hname
+ end
+ @env=SiSU_Env::Info_env.new(@md.fns)
+ @base_url="#{@env.url.root}/#{@md.fnb}/#{@hname}.html"
+ txt=endnotes(txt).extract_any
+ if @sql_type=~/pg/ \
+ and txt.size > (SiSU_DB_columns::Column_size.new.document_clean - 1) #% examine pg build & remove limitation
+ puts "\n\nTOO LARGE (TXT - see error log)\n\n"
+ open("#{Dir.pwd}/pg_documents_error_log",'a') do |error|
+ error.puts("\n#{@opt.fns}\nTEXT BODY\n#{@col[:body].size} object #{@col[:ocn]} -> #{@col[:body].slice(0..500)}")
+ end
+ txt=%{\n\nLARGE TEXT BLOCK OMITTED\n\n}
+ end
+ @en_a,@en_z=@en[0].first,@en[0].last if @en[0]
+ @en_a_asterisk,@en_z_asterisk=@en_ast[0].first,@en_ast[0].last if @en_ast[0]
+ @en_a_plus,@en_z_plus=@en_pls[0].first,@en_pls[0].last if @en_pls[0]
+ @col[:body]=if data.is=='table'
+ SiSU_Format_Shared::CSS_Format.new(@md,data).html_table
+ elsif data.is=='code'
+ SiSU_Format_Shared::CSS_Format.new(@md,data).code
+ elsif defined? data.indent \
+ and defined? data.hang \
+ and data.indent =~/[1-9]/ \
+ and data.indent == data.hang
+ SiSU_Format_Shared::CSS_Format.new(@md,data).indent(data.indent)
+ elsif defined? data.indent \
+ and defined? data.hang \
+ and data.hang =~/[0-9]/ \
+ and data.indent != data.hang
+ SiSU_Format_Shared::CSS_Format.new(@md,data).hang_indent(data.hang,data.indent)
+ else
+ SiSU_Format_Shared::CSS_Format.new(@md,data).norm
+ end
+ special_character_escape(@col[:body])
+ @col[:plaintext]=@col[:body].dup
+ @col[:plaintext]=strip_markup(@col[:plaintext])
+ @col[:plaintext]=clean_searchable_text(@col[:plaintext])
+ t=SiSU_DB_tuple::Load_documents.new(@conn,@col,@opt,@file)
+ @tuple_array << t.tuple
+ @en,@en_ast,@en_pls=[],[],[]
+ @col[:en_a]=@col[:en_z]=nil
+ @col[:lev]=@col[:plaintext]=@col[:body]=@col[:words]=''
+ end
+ if notedata =~/#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}/ #% import into database endnotes tables
+ endnote_array=notedata.scan(/#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}/)
+ endnote_array.each do |inf|
+ if inf[/#{Mx[:en_a_o]}\d+.+?#{Mx[:en_a_c]}/]
+ if inf[/#{Mx[:en_a_o]}(\d+)(.+?)#{Mx[:en_a_c]}/]
+ nr,txt,digest_clean=$1,$2.strip,0
+ end
+ @id_n+=1
+ special_character_escape(txt)
+ body=SiSU_Format_Shared::CSS_Format.new(@md,data).endnote(nr,txt)
+ strip_markup(txt)
+ if txt.size > (SiSU_DB_columns::Column_size.new.endnote_clean - 1)
+ puts "\n\nTOO LARGE (ENDNOTE - see error log)\n\n"
+ open("#{Dir.pwd}/pg_documents_error_log",'a') do |error|
+ error.puts("\n#{@opt.fns}\nENDNOTE\n#{txt.size} object #{@col[:ocn]},#{@col[:ocnd]},#{@col[:ocns]} -> #{txt.slice(0..500)}")
+ end
+ txt=%{\n\nLARGE TEXT BLOCK OMITTED\n\n}
+ end
+ if txt
+ en={
+ type: 'endnotes',
+ id: @id_n,
+ lid: @col[:lid],
+ nr: nr,
+ txt: txt,
+ body: body,
+ ocn: @col[:ocn],
+ ocnd: @col[:ocnd],
+ ocns: @col[:ocns],
+ id_t: @@id_t,
+ hash: digest_clean
+ }
+ t=SiSU_DB_tuple::Load_endnotes.new(@conn,en,@opt,@file)
+ @tuple_array << t.tuple
+ end
+ end
+ end
+ word_mode=notedata.scan(/\S+/)
+ end
+ if notedata =~/#{Mx[:en_b_o]}\*.+?#{Mx[:en_b_c]}/ #% import into database endnotes tables
+ endnote_array=notedata.scan(/#{Mx[:en_b_o]}\*.+?#{Mx[:en_b_c]}/)
+ endnote_array.each do |inf|
+ if inf[/#{Mx[:en_b_o]}\*\d+.+?#{Mx[:en_b_c]}/] # dal new endnotes 2003w31/1
+ if inf[/#{Mx[:en_b_o]}[*](\d+)(.+?)#{Mx[:en_b_c]}/] # dal new endnotes 2003w31/1
+ nr,txt,digest_clean=$1,$2.strip,0
+ end
+ @id_n+=1
+ special_character_escape(txt)
+ body=SiSU_Format_Shared::CSS_Format.new(@md,data).endnote(nr,txt)
+ strip_markup(txt)
+ if txt.size > (SiSU_DB_columns::Column_size.new.endnote_clean - 1)
+ puts "\n\nTOO LARGE (ENDNOTE - see error log)\n\n"
+ open("#{Dir.pwd}/pg_documents_error_log",'a') do |error|
+ error.puts("\n#{@opt.fns}\nENDNOTE\n#{txt.size} object #{@col[:ocn]},#{@col[:ocnd]},#{@col[:ocns]} -> #{txt.slice(0..500)}")
+ end
+ txt=%{\n\nLARGE TEXT BLOCK OMITTED\n\n}
+ end
+ if txt
+ en={
+ type: 'endnotes_asterisk',
+ id: @id_n,
+ lid: @col[:lid],
+ nr: nr,
+ txt: txt,
+ body: body,
+ ocn: @col[:ocn],
+ ocnd: @col[:ocnd],
+ ocns: @col[:ocns],
+ id_t: @@id_t,
+ hash: digest_clean
+ }
+ t=SiSU_DB_tuple::Load_endnotes.new(@conn,en,@opt,@file)
+ @tuple_array << t.tuple
+ end
+ end
+ end
+ word_mode=notedata.scan(/\S+/)
+ end
+ if notedata =~/#{Mx[:en_b_o]}\+.+?#{Mx[:en_b_c]}/ #% import into database endnotes tables
+ endnote_array=notedata.scan(/#{Mx[:en_b_o]}\+.+?#{Mx[:en_b_c]}/)
+ endnote_array.each do |inf|
+ if inf[/#{Mx[:en_b_o]}\+\d+.+?#{Mx[:en_b_c]}/] # dal new endnotes 2003w31/1
+ if inf[/#{Mx[:en_b_o]}[+](\d+)(.+?)#{Mx[:en_b_c]}/] # dal new endnotes 2003w31/1
+ nr,txt,digest_clean=$1,$2.strip,0
+ end
+ @id_n+=1
+ special_character_escape(txt)
+ body=SiSU_Format_Shared::CSS_Format.new(@md,data).endnote(nr,txt)
+ strip_markup(txt)
+ if txt.size > (SiSU_DB_columns::Column_size.new.endnote_clean - 1)
+ puts "\n\nTOO LARGE (ENDNOTE - see error log)\n\n"
+ open("#{Dir.pwd}/pg_documents_error_log",'a') do |error|
+ error.puts("\n#{@opt.fns}\nENDNOTE\n#{txt.size} object #{@col[:ocn]},#{@col[:ocnd]},#{@col[:ocns]} -> #{txt.slice(0..500)}")
+ end
+ txt=%{\n\nLARGE TEXT BLOCK OMITTED\n\n}
+ end
+ if txt
+ en={
+ type: 'endnotes_plus',
+ id: @id_n,
+ lid: @col[:lid],
+ nr: nr,
+ txt: txt,
+ body: body,
+ ocn: @col[:ocn],
+ ocnd: @col[:ocnd],
+ ocns: @col[:ocns],
+ id_t: @@id_t,
+ hash: digest_clean
+ }
+ t=SiSU_DB_tuple::Load_endnotes.new(@conn,en,@opt,@file)
+ @tuple_array << t.tuple
+ end
+ end
+ end
+ word_mode=notedata.scan(/\S+/)
+ end
+ end
+ end
+ rescue; SiSU_Errors::Info_error.new($!,$@,@opt.cmd,@opt.fns).error
+ ensure
+ end
+ @tuple_array
+ end
+ def endnotes(txt)
+ @txt=txt
+ def extract_any
+ if @txt =~/(?:#{Mx[:en_a_o]}|#{Mx[:en_b_o]})[*+]?(\d+)\s+.+?(?:#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/
+ endnotes(@txt).range
+ @en << endnotes(@txt).standard if @txt =~/#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}/
+ @en_ast << endnotes(@txt).asterisk if @txt =~/#{Mx[:en_b_o]}\*.+?#{Mx[:en_b_c]}/
+ @en_pls << endnotes(@txt).plus if @txt =~/#{Mx[:en_b_o]}\+.+?#{Mx[:en_b_c]}/
+ @txt=endnotes(@txt).clean_text
+ end
+ @txt
+ end
+ def standard
+ x=(@txt =~/#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}/) \
+ ? @txt.scan(/#{Mx[:en_a_o]}(\d+).+?#{Mx[:en_a_c]}/)
+ : nil
+ end
+ def asterisk
+ x=(@txt =~/#{Mx[:en_b_o]}\*.+?#{Mx[:en_b_c]}/) \
+ ? @txt.scan(/#{Mx[:en_b_o]}[*](\d+).+?#{Mx[:en_b_c]}/)
+ : nil
+ end
+ def plus
+ x=(@txt =~/#{Mx[:en_b_o]}\+.+?#{Mx[:en_b_c]}/) \
+ ? @txt.scan(/#{Mx[:en_b_o]}[+](\d+).+?#{Mx[:en_b_c]}/)
+ : nil
+ end
+ def clean_text(base_url=nil)
+ if base_url
+ @txt.gsub!(/#{Mx[:en_a_o]}(\d+).+?#{Mx[:en_a_c]}/,%{\\1})
+ @txt.gsub!(/#{Mx[:en_b_o]}([*]\d+).+?#{Mx[:en_b_c]}/,%{\\1})
+ @txt.gsub!(/#{Mx[:en_b_o]}([+]\d+).+?#{Mx[:en_b_c]}/,%{\\1})
+ else
+ @txt.gsub!(/#{Mx[:en_a_o]}(\d+).+?#{Mx[:en_a_c]}/,'\1')
+ @txt.gsub!(/#{Mx[:en_b_o]}([*]\d+).+?#{Mx[:en_b_c]}/,'\1')
+ @txt.gsub!(/#{Mx[:en_b_o]}([+]\d+).+?#{Mx[:en_b_c]}/,'\1')
+ end
+ @txt
+ end
+ def range
+ @col[:en_a]=@col[:en_z]=nil
+ if @txt =~/#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}([*]\d+).+?#{Mx[:en_b_c]}|#{Mx[:en_b_o]}([+]\d+).+?#{Mx[:en_b_c]}/
+ word_array=@txt.scan(/\S+/)
+ word_array.each do |w|
+ if w[/(?:#{Mx[:en_a_o]}|#{Mx[:en_b_o]})[*+]?(\d+)\s+.+?(?:#{Mx[:en_a_c]}|#{Mx[:en_b_c]})(?:#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/] # not tested since change 2003w31
+ @col[:en_a]=$1 unless @col[:en_a]
+ @col[:en_z]=@col[:en_a].dup unless @col[:en_a]
+ @col[:en_z]=$1 if @col[:en_a]
+ end
+ end
+ end
+ @col
+ end
+ self
+ end
+ def db_import_urls(dbi_unit,content) #% import documents OID - populate database
+ begin
+ @fnc=content
+ @env=SiSU_Env::Info_env.new(@opt.fns)
+ base=@env.url.root
+ out=@env.path.output
+ f,u={},{}
+ if @fnb.empty? \
+ or @fnb.nil?
+ p 'file output path error' #remove
+ end
+ if FileTest.file?("#{out}/#{@fnb}/#{@md.fn[:plain]}")==true
+ f[:txt],u[:txt]='plaintext,', "'#{base}/#{@fnb}/#{@md.fn[:plain]}',"
+ end
+ if FileTest.file?("#{out}/#{@fnb}/#{@md.fn[:toc]}")==true
+ f[:html_toc],u[:html_toc]='html_toc,', "'#{base}/#{@fnb}/#{@md.fn[:toc]}',"
+ end
+ if FileTest.file?("#{out}/#{@fnb}/#{@md.fn[:doc]}")==true
+ f[:html_doc],u[:html_doc]='html_doc,', "'#{base}/#{@fnb}/#{@md.fn[:doc]}',"
+ end
+ if FileTest.file?("#{out}/#{@fnb}/#{@md.fn[:xhtml]}")==true
+ f[:xhtml],u[:xhtml]='xhtml,', "'#{base}/#{@fnb}/#{@md.fn[:xhtml]}',"
+ end
+ if FileTest.file?("#{out}/#{@fnb}/#{@md.fn[:sax]}")==true
+ f[:xml_sax],u[:xml_sax]='xml_sax,', "'#{base}/#{@fnb}/#{@md.fn[:sax]}',"
+ end
+ if FileTest.file?("#{out}/#{@fnb}/#{@md.fn[:dom]}")==true
+ f[:xml_dom],u[:xml_dom]='xml_dom,', "'#{base}/#{@fnb}/#{@md.fn[:dom]}',"
+ end
+ if FileTest.file?("#{out}/#{@fnb}/#{@md.fn[:odf]}")==true
+ f[:odf],u[:odf]='odf,', "'#{base}/#{@fnb}/#{@md.fn[:odf]}',"
+ end
+ if FileTest.file?("#{out}/#{@fnb}/#{@md.fn[:pdf_p]}")==true
+ f[:pdf_p],u[:pdf_p]='pdf_p,', "'#{base}/#{@fnb}/#{@md.fn[:pdf_p]}',"
+ end
+ if FileTest.file?("#{out}/#{@fnb}/#{@md.fn[:pdf_l]}")==true
+ f[:pdf_l],u[:pdf_l]='pdf_l,', "'#{base}/#{@fnb}/#{@md.fn[:pdf_l]}',"
+ end
+ if FileTest.file?("#{out}/#{@fnb}/#{@md.fn[:concordance]}")==true
+ f[:concordance],u[:concordance]='concordance,', "'#{base}/#{@fnb}/#{@md.fn[:concordance]}',"
+ end
+ if FileTest.file?("#{out}/#{@fnb}/#{@opt.fns}.tex")==true
+ f[:latex_p],u[:latex_p]='latex_p,', "'#{base}/#{@fnb}/#{@opt.fns}.tex',"
+ end
+ if FileTest.file?("#{out}/#{@fnb}/#{@opt.fns}.landscape.tex")==true
+ f[:latex_l],u[:latex_l]='latex_l,', "'#{base}/#{@fnb}/#{@opt}.fns}.landscape.tex',"
+ end
+ if FileTest.file?("#{out}/#{@fnb}/#{@md.fn[:digest]}")==true
+ f[:digest],u[:digest]='digest,', "'#{base}/#{@fnb}/#{@md.fn[:digest]}',"
+ end
+ if FileTest.file?("#{out}/#{@fnb}/#{@md.fn[:manifest]}")==true #revisit, was to be text, this is html
+ f[:manifest],u[:manifest]='manifest,', "'#{base}/#{@fnb}/#{@md.fn[:manifest]}',"
+ end
+ if FileTest.file?("#{out}/#{@fnb}/#{@opt.fns}.meta")==true
+ f[:markup],u[:markup]='markup,', "'#{base}/#{@fnb}/#{@opt.fns}.meta',"
+ end
+ if FileTest.file?("#{out}/#{@fnb}/#{@opt.fns}.tgz")==true
+ f[:sisupod],u[:sisupod]='sisupod,', "'#{base}/#{@fnb}/#{@opt.fns}.tgz',"
+ end
+ t=SiSU_DB_tuple::Load_urls.new(@conn,f,u,@@id_t,@opt,@file)
+ tuple=t.tuple
+ rescue; SiSU_Errors::Info_error.new($!,$@,@opt.cmd,@opt.fns).error
+ ensure
+ end
+ tuple
+ end
+ end
+end
+__END__
diff --git a/lib/sisu/v3dv/db_indexes.rb b/lib/sisu/v3dv/db_indexes.rb
new file mode 100644
index 00000000..5e387e27
--- /dev/null
+++ b/lib/sisu/v3dv/db_indexes.rb
@@ -0,0 +1,114 @@
+# encoding: utf-8
+=begin
+
+ * Name: SiSU
+
+ * Description: a framework for document structuring, publishing and search
+
+ * Author: Ralph Amissah
+
+ * Copyright: (C) 1997 - 2012, 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 .
+
+ If you have Internet connection, the latest version of the GPL should be
+ available at these locations:
+
+
+
+
+
+
+
+ * SiSU uses:
+ * Standard SiSU markup syntax,
+ * Standard SiSU meta-markup syntax, and the
+ * Standard SiSU object citation numbering and system
+
+ * Hompages:
+
+
+
+ * Download:
+
+
+ * Ralph Amissah
+
+
+
+ ** Description: modules shared by the different db types, dbi, postgresql,
+ sqlite
+
+=end
+module SiSU_DB_index
+ class Index # create documents Indexes def initialize(opt,conn='',sql_type='')
+ def initialize(opt,conn,file,sql_type='')
+ @opt,@conn,@file,@sql_type=opt,conn,file,sql_type
+ end
+ def create_indexes # check added from pg not tested
+ def conn_execute_array(sql_arr)
+ @conn.transaction do |conn|
+ sql_arr.each do |sql|
+ conn.execute(sql)
+ end
+ end
+ end
+ def base
+ print "\n create documents common indexes\n" unless @opt.cmd =~/q/
+ sql_arr=[
+ %{CREATE INDEX idx_ocn ON doc_objects(ocn);},
+ %{CREATE INDEX idx_digest_clean ON doc_objects(digest_clean);},
+ %{CREATE INDEX idx_digest_all ON doc_objects(digest_all);},
+ %{CREATE INDEX idx_lev1 ON doc_objects(lev1);},
+ %{CREATE INDEX idx_lev2 ON doc_objects(lev2);},
+ %{CREATE INDEX idx_lev3 ON doc_objects(lev3);},
+ %{CREATE INDEX idx_lev4 ON doc_objects(lev4);},
+ %{CREATE INDEX idx_lev5 ON doc_objects(lev5);},
+ %{CREATE INDEX idx_lev6 ON doc_objects(lev6);},
+ %{CREATE INDEX idx_endnote_nr ON endnotes(nr);},
+ %{CREATE INDEX idx_digest_en ON endnotes(digest_clean);},
+ %{CREATE INDEX idx_endnote_nr_asterisk ON endnotes_asterisk(nr);},
+ %{CREATE INDEX idx_endnote_asterisk ON endnotes_asterisk(clean);},
+ %{CREATE INDEX idx_digest_en_asterisk ON endnotes_asterisk(digest_clean);},
+ %{CREATE INDEX idx_endnote_nr_plus ON endnotes_plus(nr);},
+ %{CREATE INDEX idx_endnote_plus ON endnotes_plus(clean);},
+ %{CREATE INDEX idx_digest_en_plus ON endnotes_plus(digest_clean);},
+ %{CREATE INDEX idx_title ON metadata_and_text(title);},
+ %{CREATE INDEX idx_author ON metadata_and_text(creator_author);},
+ %{CREATE INDEX idx_filename ON metadata_and_text(src_filename);},
+ %{CREATE INDEX idx_language ON metadata_and_text(language_document_char);},
+ %{CREATE INDEX idx_topics ON metadata_and_text(classify_topic_register)},
+ ]
+ conn_execute_array(sql_arr)
+ end
+ def text
+ print "\n create documents TEXT indexes\n" unless @opt.cmd =~/q/
+ sql_arr=[
+ %{CREATE INDEX idx_clean ON doc_objects(clean);},
+ %{CREATE INDEX idx_endnote ON endnotes(clean);}
+ ]
+ conn_execute_array(sql_arr)
+ end
+ base
+ @opt.cmd=~/D/ || ((@opt.mod=~/psql/) ? '' : text)
+ end
+ end
+end
+__END__
diff --git a/lib/sisu/v3dv/db_load_tuple.rb b/lib/sisu/v3dv/db_load_tuple.rb
new file mode 100644
index 00000000..812e8e5a
--- /dev/null
+++ b/lib/sisu/v3dv/db_load_tuple.rb
@@ -0,0 +1,333 @@
+# encoding: utf-8
+=begin
+
+ * Name: SiSU
+
+ * Description: a framework for document structuring, publishing and search
+
+ * Author: Ralph Amissah
+
+ * Copyright: (C) 1997 - 2012, 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 .
+
+ If you have Internet connection, the latest version of the GPL should be
+ available at these locations:
+
+
+
+
+
+
+
+ * SiSU uses:
+ * Standard SiSU markup syntax,
+ * Standard SiSU meta-markup syntax, and the
+ * Standard SiSU object citation numbering and system
+
+ * Hompages:
+
+
+
+ * Download:
+
+
+ * Ralph Amissah
+
+
+
+ ** Description: modules shared by the different db types, dbi, postgresql,
+ sqlite
+
+=end
+module SiSU_DB_tuple
+ require_relative 'db_columns' # db_columns.rb
+ class Load_documents
+ require_relative 'param' # param.rb
+ include SiSU_Param
+ def initialize(conn,col,opt,file)
+ @conn,@col,@opt,@file=conn,col,opt,file
+ @col[:lev]=@col[:lev].to_i
+ unless @col[:lev]=~/^[1-6]/ \
+ or @col[:lev]==1 \
+ or @col[:lev]==2 \
+ or @col[:lev]==3 \
+ or @col[:lev]==4 \
+ or @col[:lev]==5 \
+ or @col[:lev]==6 #changed from \d+ ??
+ @col[:lev]=0
+ end
+ @col[:ocn]=0 unless @col[:ocn].inspect=~/\d+/
+ @cX=SiSU_Screen::Ansi.new(@opt.cmd).cX
+ end
+ def tuple #% import line
+ sql_entry=if @col[:en_a]
+ "INSERT INTO doc_objects (lid, metadata_tid, lev, lev_an, clean, body, ocn, ocnd, ocns, seg, lev1, lev2, lev3, lev4, lev5, lev6, en_a, en_z, t_of, t_is, node, parent, digest_clean, digest_all) " +
+ "VALUES (#{@col[:lid]}, #{@col[:tid]}, #{@col[:lev]}, '#{@col[:lev_an]}', '#{@col[:plaintext]}', '#{@col[:body]}', '#{@col[:ocn]}', '#{@col[:ocnd]}', '#{@col[:ocns]}', '#{@col[:seg]}', '#{@col[:lv1]}', '#{@col[:lv2]}', '#{@col[:lv3]}', '#{@col[:lv4]}', '#{@col[:lv5]}', '#{@col[:lv6]}', '#{@col[:en_a]}', '#{@col[:en_z]}', '#{@col[:t_of]}', '#{@col[:t_is]}', '#{@col[:node]}', '#{@col[:parent]}', '#{@col[:digest_clean]}', '#{@col[:digest_all]}');"
+ else
+ "INSERT INTO doc_objects (lid, metadata_tid, lev, lev_an, clean, body, ocn, ocnd, ocns, seg, lev1, lev2, lev3, lev4, lev5, lev6, t_of, t_is, node, parent, digest_clean, digest_all) " +
+ "VALUES (#{@col[:lid]}, #{@col[:tid]}, #{@col[:lev]}, '#{@col[:lev_an]}', '#{@col[:plaintext]}', '#{@col[:body]}', '#{@col[:ocn]}', '#{@col[:ocnd]}', '#{@col[:ocns]}', '#{@col[:seg]}', '#{@col[:lv1]}', '#{@col[:lv2]}', '#{@col[:lv3]}', '#{@col[:lv4]}', '#{@col[:lv5]}', '#{@col[:lv6]}', '#{@col[:t_of]}', '#{@col[:t_is]}', '#{@col[:node]}', '#{@col[:parent]}', '#{@col[:digest_clean]}', '#{@col[:digest_all]}');"
+ end
+ if @opt.cmd =~/M/
+ if @opt.cmd =~/V/
+ puts @file.inspect
+ puts sql_entry
+ end
+ @file.puts sql_entry
+ else
+ if @opt.cmd =~/V/
+ puts sql_entry
+ @file.puts sql_entry
+ end
+ end
+ if @opt.cmd =~/v/
+ if @col[:lev].inspect =~/[12356789]/
+ lev=case @col[:lev].inspect
+ when /1/; ':A'
+ when /2/; ':B'
+ when /3/; ':C'
+ when /5/; ' 2'
+ when /6/; ' 3'
+ end
+ puts %{#{lev}>\t#{@col[:lv1]}\t#{@col[:lv2]}\t#{@col[:lv3]}\t#{@col[:lv4]}\t#{@col[:lv5]}\t#{@col[:lv6]}\t#{@col[:ocn]}\t#{@col[:node]}\t#{@col[:ocns]}}
+ elsif @col[:lev].inspect =~/[4]/
+ puts %{ #{@cX.green}1>#{@cX.off}\t#{@col[:lv1]}\t#{@col[:lv2]}\t#{@col[:lv3]}\t#{@col[:lv4]}\t#{@col[:lv5]}\t#{@col[:lv6]}\t#{@col[:ocn]}\t#{@col[:node]}\t#{@col[:ocns]}\t#{@col[:seg]}}
+ end
+ end
+ sql_entry
+ end
+ end
+ class Load_metadata #< SiSU_DB_columns::Columns
+ def initialize(conn,id,md,file)
+ @conn,@id,@md,@file=conn,id,md,file
+ @tp=SiSU_DB_columns::Columns.new(md)
+ end
+ def tuple
+ sql_entry="INSERT INTO metadata_and_text (
+#{@tp.column.title.tuple[0]}
+#{@tp.column.title_main.tuple[0]}
+#{@tp.column.title_sub.tuple[0]}
+#{@tp.column.title_short.tuple[0]}
+#{@tp.column.title_edition.tuple[0]}
+#{@tp.column.title_note.tuple[0]}
+#{@tp.column.title_language.tuple[0]}
+#{@tp.column.title_language_char.tuple[0]}
+#{@tp.column.creator_author.tuple[0]}
+#{@tp.column.creator_author_honorific.tuple[0]}
+#{@tp.column.creator_author_nationality.tuple[0]}
+#{@tp.column.creator_editor.tuple[0]}
+#{@tp.column.creator_contributor.tuple[0]}
+#{@tp.column.creator_illustrator.tuple[0]}
+#{@tp.column.creator_photographer.tuple[0]}
+#{@tp.column.creator_translator.tuple[0]}
+#{@tp.column.creator_prepared_by.tuple[0]}
+#{@tp.column.creator_digitized_by.tuple[0]}
+#{@tp.column.creator_audio.tuple[0]}
+#{@tp.column.creator_video.tuple[0]}
+#{@tp.column.language_document.tuple[0]}
+#{@tp.column.language_document_char.tuple[0]}
+#{@tp.column.language_original.tuple[0]}
+#{@tp.column.language_original_char.tuple[0]}
+#{@tp.column.date_added_to_site.tuple[0]}
+#{@tp.column.date_available.tuple[0]}
+#{@tp.column.date_created.tuple[0]}
+#{@tp.column.date_issued.tuple[0]}
+#{@tp.column.date_modified.tuple[0]}
+#{@tp.column.date_published.tuple[0]}
+#{@tp.column.date_valid.tuple[0]}
+#{@tp.column.date_translated.tuple[0]}
+#{@tp.column.date_original_publication.tuple[0]}
+#{@tp.column.date_generated.tuple[0]}
+#{@tp.column.publisher.tuple[0]}
+#{@tp.column.original_publisher.tuple[0]}
+#{@tp.column.original_language.tuple[0]}
+#{@tp.column.original_language_char.tuple[0]}
+#{@tp.column.original_source.tuple[0]}
+#{@tp.column.original_institution.tuple[0]}
+#{@tp.column.original_nationality.tuple[0]}
+#{@tp.column.rights_all.tuple[0]}
+#{@tp.column.rights_copyright_text.tuple[0]}
+#{@tp.column.rights_copyright_translation.tuple[0]}
+#{@tp.column.rights_copyright_illustrations.tuple[0]}
+#{@tp.column.rights_copyright_photographs.tuple[0]}
+#{@tp.column.rights_copyright_preparation.tuple[0]}
+#{@tp.column.rights_copyright_digitization.tuple[0]}
+#{@tp.column.rights_copyright_audio.tuple[0]}
+#{@tp.column.rights_copyright_video.tuple[0]}
+#{@tp.column.rights_license.tuple[0]}
+#{@tp.column.classify_topic_register.tuple[0]}
+#{@tp.column.classify_subject.tuple[0]}
+#{@tp.column.classify_type.tuple[0]}
+#{@tp.column.classify_loc.tuple[0]}
+#{@tp.column.classify_dewey.tuple[0]}
+#{@tp.column.classify_oclc.tuple[0]}
+#{@tp.column.classify_pg.tuple[0]}
+#{@tp.column.classify_isbn.tuple[0]}
+#{@tp.column.classify_format.tuple[0]}
+#{@tp.column.classify_identifier.tuple[0]}
+#{@tp.column.classify_relation.tuple[0]}
+#{@tp.column.classify_coverage.tuple[0]}
+#{@tp.column.classify_keywords.tuple[0]}
+#{@tp.column.notes_abstract.tuple[0]}
+#{@tp.column.notes_comment.tuple[0]}
+#{@tp.column.notes_description.tuple[0]}
+#{@tp.column.notes_history.tuple[0]}
+#{@tp.column.notes_prefix.tuple[0]}
+#{@tp.column.notes_prefix_a.tuple[0]}
+#{@tp.column.notes_prefix_b.tuple[0]}
+#{@tp.column.notes_suffix.tuple[0]}
+#{@tp.column.src_filename.tuple[0]}
+#{@tp.column.src_fingerprint.tuple[0]}
+#{@tp.column.src_filesize.tuple[0]}
+#{@tp.column.src_word_count.tuple[0]}
+#{@tp.column.src_txt.tuple[0]}
+#{@tp.column.fulltext.tuple[0]}
+#{@tp.column.skin_name.tuple[0]}
+#{@tp.column.skin_fingerprint.tuple[0]}
+#{@tp.column.skin.tuple[0]}
+#{@tp.column.links.tuple[0]}
+tid)
+" +
+ "VALUES (
+#{@tp.column.title.tuple[1]}
+#{@tp.column.title_main.tuple[1]}
+#{@tp.column.title_sub.tuple[1]}
+#{@tp.column.title_short.tuple[1]}
+#{@tp.column.title_edition.tuple[1]}
+#{@tp.column.title_note.tuple[1]}
+#{@tp.column.title_language.tuple[1]}
+#{@tp.column.title_language_char.tuple[1]}
+#{@tp.column.creator_author.tuple[1]}
+#{@tp.column.creator_author_honorific.tuple[1]}
+#{@tp.column.creator_author_nationality.tuple[1]}
+#{@tp.column.creator_editor.tuple[1]}
+#{@tp.column.creator_contributor.tuple[1]}
+#{@tp.column.creator_illustrator.tuple[1]}
+#{@tp.column.creator_photographer.tuple[1]}
+#{@tp.column.creator_translator.tuple[1]}
+#{@tp.column.creator_prepared_by.tuple[1]}
+#{@tp.column.creator_digitized_by.tuple[1]}
+#{@tp.column.creator_audio.tuple[1]}
+#{@tp.column.creator_video.tuple[1]}
+#{@tp.column.language_document.tuple[1]}
+#{@tp.column.language_document_char.tuple[1]}
+#{@tp.column.language_original.tuple[1]}
+#{@tp.column.language_original_char.tuple[1]}
+#{@tp.column.date_added_to_site.tuple[1]}
+#{@tp.column.date_available.tuple[1]}
+#{@tp.column.date_created.tuple[1]}
+#{@tp.column.date_issued.tuple[1]}
+#{@tp.column.date_modified.tuple[1]}
+#{@tp.column.date_published.tuple[1]}
+#{@tp.column.date_valid.tuple[1]}
+#{@tp.column.date_translated.tuple[1]}
+#{@tp.column.date_original_publication.tuple[1]}
+#{@tp.column.date_generated.tuple[1]}
+#{@tp.column.publisher.tuple[1]}
+#{@tp.column.original_publisher.tuple[1]}
+#{@tp.column.original_language.tuple[1]}
+#{@tp.column.original_language_char.tuple[1]}
+#{@tp.column.original_source.tuple[1]}
+#{@tp.column.original_institution.tuple[1]}
+#{@tp.column.original_nationality.tuple[1]}
+#{@tp.column.rights_all.tuple[1]}
+#{@tp.column.rights_copyright_text.tuple[1]}
+#{@tp.column.rights_copyright_translation.tuple[1]}
+#{@tp.column.rights_copyright_illustrations.tuple[1]}
+#{@tp.column.rights_copyright_photographs.tuple[1]}
+#{@tp.column.rights_copyright_preparation.tuple[1]}
+#{@tp.column.rights_copyright_digitization.tuple[1]}
+#{@tp.column.rights_copyright_audio.tuple[1]}
+#{@tp.column.rights_copyright_video.tuple[1]}
+#{@tp.column.rights_license.tuple[1]}
+#{@tp.column.classify_topic_register.tuple[1]}
+#{@tp.column.classify_subject.tuple[1]}
+#{@tp.column.classify_type.tuple[1]}
+#{@tp.column.classify_loc.tuple[1]}
+#{@tp.column.classify_dewey.tuple[1]}
+#{@tp.column.classify_oclc.tuple[1]}
+#{@tp.column.classify_pg.tuple[1]}
+#{@tp.column.classify_isbn.tuple[1]}
+#{@tp.column.classify_format.tuple[1]}
+#{@tp.column.classify_identifier.tuple[1]}
+#{@tp.column.classify_relation.tuple[1]}
+#{@tp.column.classify_coverage.tuple[1]}
+#{@tp.column.classify_keywords.tuple[1]}
+#{@tp.column.notes_abstract.tuple[1]}
+#{@tp.column.notes_comment.tuple[1]}
+#{@tp.column.notes_description.tuple[1]}
+#{@tp.column.notes_history.tuple[1]}
+#{@tp.column.notes_prefix.tuple[1]}
+#{@tp.column.notes_prefix_a.tuple[1]}
+#{@tp.column.notes_prefix_b.tuple[1]}
+#{@tp.column.notes_suffix.tuple[1]}
+#{@tp.column.src_filename.tuple[1]}
+#{@tp.column.src_fingerprint.tuple[1]}
+#{@tp.column.src_filesize.tuple[1]}
+#{@tp.column.src_word_count.tuple[1]}
+#{@tp.column.src_txt.tuple[1]}
+#{@tp.column.fulltext.tuple[1]}
+#{@tp.column.skin_name.tuple[1]}
+#{@tp.column.skin_fingerprint.tuple[1]}
+#{@tp.column.skin.tuple[1]}
+#{@tp.column.links.tuple[1]}
+#{@id}
+);"
+ if @md.opt.cmd =~/M/
+ puts "maintenance mode on: creating sql transaction file (for last transaction set (document) only):\n\t#{@file.inspect}"
+ @file.puts sql_entry
+ else
+ @file.puts sql_entry if @md.opt.cmd =~/V/
+ end
+ sql_entry
+ end
+ end
+ class Load_urls
+ def initialize(conn,f,u,id,opt,file)
+ @conn,@f,@u,@id,@opt,@file=conn,f,u,id,opt,file
+ end
+ def tuple
+ sql_entry="INSERT INTO urls (#{@f[:txt]} #{@f[:html_toc]} #{@f[:html_doc]} #{@f[:xhtml]} #{@f[:xml_sax]} #{@f[:xml_dom]} #{@f[:odf]} #{@f[:pdf_p]} #{@f[:pdf_l]} #{@f[:concordance]} #{@f[:latex_p]} #{@f[:latex_l]} #{@f[:manifest]} #{@f[:digest]} #{@f[:markup]} #{@f[:sisupod]} metadata_tid) " +
+ "VALUES (#{@u[:txt]} #{@u[:html_toc]} #{@u[:html_doc]} #{@u[:xhtml]} #{@u[:xml_sax]} #{@u[:xml_dom]} #{@u[:odf]} #{@u[:pdf_p]} #{@u[:pdf_l]} #{@u[:concordance]} #{@u[:latex_p]} #{@u[:latex_l]} #{@u[:manifest]} #{@u[:digest]} #{@u[:markup]} #{@u[:sisupod]} #{@id});"
+ if @opt.cmd =~/M/
+ @file.puts sql_entry
+ else
+ @file.puts sql_entry if @opt.cmd =~/V/
+ end
+ sql_entry
+ end
+ end
+ class Load_endnotes
+ def initialize(conn,en,opt,file)
+ @conn,@en,@opt,@file=conn,en,opt,file
+ end
+ def tuple
+ sql_entry="INSERT INTO #{@en[:type]} (nid, document_lid, nr, clean, body, ocn, ocnd, ocns, metadata_tid, digest_clean) " +
+ "VALUES ('#{@en[:id]}', '#{@en[:lid]}', '#{@en[:nr]}', '#{@en[:txt]}', '#{@en[:body]}', '#{@en[:ocn]}', '#{@en[:ocnd]}', '#{@en[:ocns]}', '#{@en[:id_t]}', '#{@en[:hash]}');"
+ if @opt.cmd =~/M/
+ @file.puts sql_entry
+ else
+ @file.puts sql_entry if @opt.cmd =~/V/
+ end
+ sql_entry
+ end
+ end
+end
+__END__
diff --git a/lib/sisu/v3dv/db_remove.rb b/lib/sisu/v3dv/db_remove.rb
new file mode 100644
index 00000000..8147cda1
--- /dev/null
+++ b/lib/sisu/v3dv/db_remove.rb
@@ -0,0 +1,119 @@
+# encoding: utf-8
+=begin
+
+ * Name: SiSU
+
+ * Description: a framework for document structuring, publishing and search
+
+ * Author: Ralph Amissah
+
+ * Copyright: (C) 1997 - 2012, 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 .
+
+ If you have Internet connection, the latest version of the GPL should be
+ available at these locations:
+
+
+
+
+
+
+
+ * SiSU uses:
+ * Standard SiSU markup syntax,
+ * Standard SiSU meta-markup syntax, and the
+ * Standard SiSU object citation numbering and system
+
+ * Hompages:
+
+
+
+ * Download:
+
+
+ * Ralph Amissah
+
+
+
+ ** Description: modules shared by the different db types, dbi, postgresql,
+ sqlite
+
+=end
+module SiSU_DB_remove
+ class Remove
+ def initialize(opt,conn,file,sql_type)
+ @opt,@conn,@file,@sql_type=opt,conn,file,sql_type
+ @md=SiSU_Param::Parameters.new(@opt).get
+ @fnb=@md.fnb
+ @db=SiSU_Env::Info_db.new
+ end
+ def remove
+ driver_sqlite3=if @sql_type=='sqlite'
+ (@conn.inspect.match(/^(.{10})/)[1]==@db.sqlite.conn_sqlite3.inspect.match(/^(.{10})/)[1]) \
+ ? true
+ : false
+ end
+ del_id=if driver_sqlite3
+ @conn.get_first_value(%{
+ SELECT tid
+ FROM metadata_and_text
+ WHERE src_filename = '#{@opt.fns}'
+ AND metadata_and_text.language_document_char = '#{@opt.lng}'
+ ;}).to_i
+ else
+ x=@conn.select_one(%{
+ SELECT metadata_and_text.tid
+ FROM metadata_and_text
+ WHERE metadata_and_text.src_filename = '#{@opt.fns}'
+ AND metadata_and_text.language_document_char = '#{@opt.lng}'
+ ;})
+ x ? (x.join.to_i) : nil
+ end
+ if del_id
+ sql_entry=[
+ "DELETE FROM endnotes WHERE metadata_tid = '#{del_id}';",
+ "DELETE FROM endnotes_asterisk WHERE metadata_tid = '#{del_id}';",
+ "DELETE FROM endnotes_plus WHERE metadata_tid = '#{del_id}';",
+ "DELETE FROM doc_objects WHERE metadata_tid = '#{del_id}';",
+ "DELETE FROM urls WHERE metadata_tid = '#{del_id}';",
+ "DELETE FROM metadata_and_text WHERE metadata_and_text.tid = '#{del_id}';",
+ ]
+ if driver_sqlite3
+ @conn.transaction
+ sql_entry.each do |s|
+ @conn.execute(s)
+ end
+ @conn.commit if driver_sqlite3
+ else
+ sql_entry.each do |s|
+ @conn.execute(s)
+ end
+ end
+ if @opt.cmd =~/M/
+ @file.puts sql_entry if @opt.cmd =~/M/
+ end
+ else
+ SiSU_Screen::Ansi.new(@opt.cmd,"no such file in database #{@db.psql.db}::#{@opt.fns}").puts_grey if @opt.cmd =~/vVM/
+ end
+ end
+ end
+end
+__END__
diff --git a/lib/sisu/v3dv/db_select.rb b/lib/sisu/v3dv/db_select.rb
new file mode 100644
index 00000000..bce2b21c
--- /dev/null
+++ b/lib/sisu/v3dv/db_select.rb
@@ -0,0 +1,215 @@
+# encoding: utf-8
+=begin
+
+ * Name: SiSU
+
+ * Description: a framework for document structuring, publishing and search
+
+ * Author: Ralph Amissah
+
+ * Copyright: (C) 1997 - 2012, 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 .
+
+ If you have Internet connection, the latest version of the GPL should be
+ available at these locations:
+
+
+
+
+
+
+
+ * SiSU uses:
+ * Standard SiSU markup syntax,
+ * Standard SiSU meta-markup syntax, and the
+ * Standard SiSU object citation numbering and system
+
+ * Hompages:
+
+
+
+ * Download:
+
+
+ * Ralph Amissah
+
+
+
+ ** Description: modules shared by the different db types, dbi, postgresql,
+ sqlite
+
+=end
+module SiSU_DB_select
+ class Case
+ def initialize(opt,conn='',sql_type='pg')
+ @opt,@conn,@sql_type=opt,conn,sql_type
+ @db=SiSU_Env::Info_db.new
+ @file=sql_maintenance_file
+ @sdb=SiSU_DB_DBI::Create.new(@opt,@conn,@file,@sql_type) # db_dbi.rb
+ @sdb_index=SiSU_DB_DBI::Index.new(@opt,@conn,@file,@sql_type) # db_dbi.rb
+ @sdb_no=SiSU_DB_DBI::Drop.new(@opt,@conn,@db,@sql_type) # db_dbi.rb
+ if @opt.mod.inspect =~/update|import/
+ @sdb_import=SiSU_DB_DBI::Import.new(@opt,@conn,@file,@sql_type)
+ @sdb_remove_doc=SiSU_DB_DBI::Remove.new(@opt,@conn,@file,@sql_type)
+ elsif @opt.mod.inspect =~/remove/
+ @sdb_remove_doc=SiSU_DB_DBI::Remove.new(@opt,@conn,@file,@sql_type)
+ end
+ end
+ def db_exist?
+ if @sql_type=='sqlite' \
+ and (not (FileTest.file?(@db.sqlite.db)) or FileTest.zero?(@db.sqlite.db))
+ puts %{no connection with #{@sql_type} database established, createdb "#{@db.sqlite.db}"?}
+ exit
+ end
+ if @conn.class==NilClass
+ db=@sql_type=='sqlite' \
+ ? @db.sqlite.db
+ : @db.psql.db
+ puts %{no connection with #{@sql_type} database established, createdb "#{db}"?}
+ exit
+ end
+ end
+ def sql_maintenance_file
+ file=if @opt.inspect =~/M/
+ x=if @opt.fns and not @opt.fns.empty?
+ @env=SiSU_Env::Info_env.new(@opt.fns) if @opt.fns
+ puts "\n#{@env.processing_path.sqlite}/#{@opt.fns}.sql" if @sql_type =~/sqlite/ and @opt.cmd =~/M/
+ @db=SiSU_Env::Info_db.new
+ @job="sqlite3 #{@db.sqlite.db} < #{@env.processing_path.sqlite}/#{@opt.fns}.sql"
+ File.new("#{@env.processing_path.sqlite}/#{@opt.fns}.sql",'w+')
+ elsif @opt.fns and @opt.fns.inspect =~/create/; nil #sort variations later
+ else nil
+ end
+ else nil
+ end
+ file
+ end
+ def cases
+ @opt.mod.each do |mod|
+ case mod
+ when /^--createdb$/
+ @sdb.output_dir?
+ begin
+ @sdb.create_db
+ rescue; @sdb.output_dir?
+ end
+ when /^--(?:init(?:ialize)?|create(?:all)?)$/
+ @sdb.output_dir?
+ begin
+ @sdb.create_table.metadata_and_text
+ @sdb.create_table.doc_objects
+ @sdb.create_table.endnotes
+ @sdb.create_table.endnotes_asterisk
+ @sdb.create_table.endnotes_plus
+ @sdb.create_table.urls
+ @sdb_index.create_indexes
+ rescue; SiSU_Errors::Info_error.new($!,$@,'-D').error; @sdb.output_dir?
+ end
+ when /^--createtables?$/
+ @sdb.output_dir?
+ begin
+ @sdb.create_table.metadata_and_text
+ @sdb.create_table.doc_objects
+ @sdb.create_table.endnotes
+ @sdb.create_table.endnotes_asterisk
+ @sdb.create_table.endnotes_plus
+ @sdb.create_table.urls
+ @sdb_index.create_indexes
+ rescue; @sdb.output_dir?
+ end
+ when /^--recreate$/
+ @sdb.output_dir?
+ begin
+ @sdb_no.drop.tables
+ @sdb.create_table.metadata_and_text
+ @sdb.create_table.doc_objects
+ @sdb.create_table.endnotes
+ @sdb.create_table.endnotes_asterisk
+ @sdb.create_table.endnotes_plus
+ @sdb.create_table.urls
+ @sdb_index.create_indexes
+ rescue; @sdb.output_dir?
+ end
+ when /^--cr(eate)?lex$/
+ @sdb.output_dir?
+ begin
+ @sdb.create_table.doc_objects
+ rescue; @sdb.output_dir?
+ end
+ when /^--cr(eate)?metadata$/
+ @sdb.output_dir?
+ begin
+ @sdb.create_table.metadata_and_text
+ rescue; @sdb.output_dir?
+ end
+ when /^--import$/
+ db_exist?
+ @sdb_import.marshal_load
+ tell=case @sql_type
+ when /sqlite/; SiSU_Screen::Ansi.new(@opt.cmd,"sqlite3 #{@db.sqlite.db} database?")
+ when /pg/; SiSU_Screen::Ansi.new(@opt.cmd,"pgaccess or psql #{@db.psql.db} database?")
+ else '???'
+ end
+ tell.puts_grey if @opt.cmd =~/v/
+ when /^--update$/
+ db_exist?
+ @sdb_remove_doc.remove
+ @sdb_import.marshal_load
+ tell=case @sql_type
+ when /sqlite/; SiSU_Screen::Ansi.new(@opt.cmd,"sqlite3 #{@db.sqlite.db} database?")
+ when /pg/; SiSU_Screen::Ansi.new(@opt.cmd,"pgaccess or psql #{@db.psql.db} database?")
+ else '???'
+ end
+ tell.puts_grey if @opt.cmd =~/v/
+ when /^--update$/
+ when /^--remove$/
+ db_exist?
+ @sdb_remove_doc.remove
+ when /^--index$/
+ db_exist?
+ @sdb_index.create_indexes
+ when /^droptable(s)?$/
+ db_exist?
+ @sdb_no.drop.tables
+ when /^--dropindex(es)?$/
+ db_exist?
+ @sdb_no.drop.indexes
+ when /^--(?:dropall|drop)$/
+ db_exist?
+ @sdb_no.drop.tables
+ when /^--(?:db=)?(?:(?:sq)?lite|pg(?:sql)?|my(?:sql)?)$/
+ else
+ help=SiSU_Help::Help.new
+ help.summary
+ help.commands
+ end
+ if @opt.cmd =~/M/ \
+ and @opt.cmd =~/d/
+ puts @job
+ end
+ end
+ begin
+ rescue; @sdb.output_dir?
+ end
+ end
+ end
+end
+__END__
diff --git a/lib/sisu/v3dv/db_sqltxt.rb b/lib/sisu/v3dv/db_sqltxt.rb
new file mode 100644
index 00000000..d1705c2b
--- /dev/null
+++ b/lib/sisu/v3dv/db_sqltxt.rb
@@ -0,0 +1,132 @@
+# encoding: utf-8
+=begin
+
+ * Name: SiSU
+
+ * Description: a framework for document structuring, publishing and search
+
+ * Author: Ralph Amissah
+
+ * Copyright: (C) 1997 - 2012, 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 .
+
+ If you have Internet connection, the latest version of the GPL should be
+ available at these locations:
+
+
+
+
+
+
+
+ * SiSU uses:
+ * Standard SiSU markup syntax,
+ * Standard SiSU meta-markup syntax, and the
+ * Standard SiSU object citation numbering and system
+
+ * Hompages:
+
+
+
+ * Download:
+
+
+ * Ralph Amissah
+
+
+
+ ** Description: system environment, resource control and configuration details
+
+=end
+module SiSU_DB_text
+ class Prepare
+ def special_character_escape(str)
+ str.gsub!(/'/,"''") #string.gsub!(/'/,"\047") #string.gsub!(/'/,"\\'")
+ str.gsub!(/(\\)/m,'\1\1') #ok but with warnings, double backslash on sqlite #str.gsub!(/[\\]/m,'\\x5C') #ok but with warnings, but not for sqlite #str.gsub!(/(\\)/m,'\1') #ok for sqlite not for pgsql
+ str.gsub!(/#{Mx[:br_line]}|#{Mx[:br_nl]}/," \n")
+ str.gsub!(/#{Mx[:tag_o]}\S+?#{Mx[:tag_c]}/,'') #check
+ str.gsub!(/#{Mx[:lnk_o]}\s*(\S+?\.(?:png|jpg))(?:\s+\d+x\d+)?(.+?)#{Mx[:lnk_c]}\S+/,'[image: \1] \2')
+ str.gsub!(/#{Mx[:lnk_o]}\s*(.+?)\s*#{Mx[:lnk_c]}(?:file|ftp):\/\/\S+?([.,!?]?(?:\s|$))/,'\1\2')
+ str.gsub!(/#{Mx[:lnk_o]}\s*(.+?)\s*#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/,'\1')
+ str
+ end
+ def clean_searchable_text(arr) #produce clean, searchable, plaintext from document source
+ txt_arr,en=[],[]
+ arr=arr.class==String ? arr.split(/\n+/m) : arr
+ arr.each do |s|
+ s.gsub!(/([*\/_-])\{(.+?)\}\1/m,'\2')
+ s.gsub!(/^(?:block|group|poem|code)\{/m,''); s.gsub!(/^\}(?:block|group|poem|code)/m,'')
+ s.gsub!(/\A(?:@\S+:\s+.+)\Z/m,'')
+ if s =~/^:A~/
+ if defined? @md.creator \
+ and defined? @md.creator.author \
+ and not @md.creator.author.empty?
+ s.gsub!(/@author/,@md.creator.author)
+ else
+ SiSU_Screen::Ansi.new('v','WARNING Document Author information missing; provide @creator: :author:',@md.fnb).warn unless @md.opt.cmd.inspect =~/q/
+ end
+ if defined? @md.title \
+ and defined? @md.title.full \
+ and not @md.title.full.empty?
+ s.gsub!(/@title/,@md.title.full)
+ else
+ SiSU_Screen::Ansi.new('v','WARNING Document Title missing; provide @title:',@md.fnb).warn unless @md.opt.cmd.inspect =~/q/
+ end
+ end
+ s.gsub!(/^(?:_[1-9]\*?|_\*)\s+/m,'')
+ s.gsub!(/^(?:[1-9]\~(\S+)?)\s+/m,'')
+ s.gsub!(/^(?::?[A-C]\~(\S+)?)\s+/m,'')
+ s.gsub!(/^%{1,3} .+/m,'') #removed even if contained in code block
+ s.gsub!(/ /m,' ')
+ en << s.scan(/~\{\s*(.+?)\s*\}~/m)
+ s.gsub!(/~\{.+?\}~/m,'')
+ s.gsub!(/ \s+/m,' ')
+ #special_character_escape(s)
+ s
+ end
+ txt_arr << arr << en
+ #txt_arr=txt_arr.flatten
+ txt=txt_arr.flatten.join("\n")
+ txt=special_character_escape(txt)
+ txt
+ end
+ def strip_markup(str) #define rules, make same as in dal clean
+ str.gsub!(/#{Mx[:fa_superscript_o]}(\d+)#{Mx[:fa_superscript_c]}/,'[\1]')
+ str.gsub!(/(?: \\;|#{Mx[:nbsp]})+/,' ')
+ str.gsub!(/#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}\d+(.+)#{Mx[:tc_c]}/u,'\1') #tables
+ str.gsub!(/#{Mx[:tc_p]}#{Mx[:tc_p]}\d+#{Mx[:tc_p]}/u,' ') #tables
+ str.gsub!(/#{Mx[:tc_p]}/u,' ') #tables tidy later
+ str.gsub!(/<.+?>/,'')
+ str.gsub!(/#{Mx[:lnk_o]}.+?\.(?:png|jpg|gif).+?#{Mx[:lnk_c]}(?:file|ftp)\/\/:\S+ /,' [image] ') # else image names found in search
+ str.gsub!(/#{Mx[:lnk_o]}.+?\.(?:png|jpg|gif).+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/,' [image]') # else image names found in search
+ str.gsub!(/\s\s+/,' ')
+ str.strip!
+ str
+ end
+ def unique_words(str)
+ a=str.scan(/[a-zA-Z0-9\\\/_-]{2,}/) #a=str.scan(/\S+{2,}/)
+ str=a.uniq.sort.join(' ')
+ str
+ end
+ end
+end
+__END__
+
diff --git a/lib/sisu/v3dv/db_tests.rb b/lib/sisu/v3dv/db_tests.rb
new file mode 100644
index 00000000..0fe1370b
--- /dev/null
+++ b/lib/sisu/v3dv/db_tests.rb
@@ -0,0 +1,117 @@
+# encoding: utf-8
+=begin
+
+ * Name: SiSU
+
+ * Description: a framework for document structuring, publishing and search
+
+ * Author: Ralph Amissah
+
+ * Copyright: (C) 1997 - 2012, 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 .
+
+ If you have Internet connection, the latest version of the GPL should be
+ available at these locations:
+
+
+
+
+
+
+
+ * SiSU uses:
+ * Standard SiSU markup syntax,
+ * Standard SiSU meta-markup syntax, and the
+ * Standard SiSU object citation numbering and system
+
+ * Hompages:
+
+
+
+ * Download:
+
+
+ * Ralph Amissah
+
+
+
+ ** Description: modules shared by the different db types, dbi, postgresql,
+ sqlite
+
+=end
+module SiSU_DB_tests
+ class Test
+ def initialize(info,opt)
+ @ck,@opt=info,opt
+ unless @opt.cmd =~/q/
+ puts @ck.tp[:fns] if @ck.tp[:fns] and not @ck.tp[:fns].empty?
+ puts @ck.tp[:title] if @ck.tp[:title] and not @ck.tp[:title].empty?
+ puts @ck.tp[:creator] if @ck.tp[:creator] and not @ck.tp[:creator].empty?
+ end
+ end
+ def verify
+ unless @opt.cmd =~/q/
+ puts @ck.tp[:fns].length.to_s + ' checklength ' + @ck.tp[:fns] if @ck.tp[:fns] and @ck.tp[:fns].length >@ck.lt_filename
+ puts @ck.tp[:title].length.to_s + ' checklength ' + @ck.tp[:title] if @ck.tp[:title] and @ck.tp[:title].length >@ck.lt_title
+ puts @ck.tp[:subtitle].length.to_s + ' checklength ' + @ck.tp[:subtitle] if @ck.tp[:subtitle] and @ck.tp[:subtitle].length >@ck.lt_subtitle
+ puts @ck.tp[:creator].length.to_s + ' checklength ' + @ck.tp[:creator] if @ck.tp[:creator] and @ck.tp[:creator].length >@ck.lt_creator
+ puts @ck.tp[:author_title].length.to_s + ' checklength ' + @ck.tp[:author_title] if @ck.tp[:author_title] and @ck.tp[:author_title].length >@ck.lt_author_title
+ puts @ck.tp[:illustrator].length.to_s + ' checklength ' + @ck.tp[:illustrator] if @ck.tp[:illustrator] and @ck.tp[:illustrator].length >@ck.lt_illustrator
+ puts @ck.tp[:translator].length.to_s + ' checklength ' + @ck.tp[:translator] if @ck.tp[:translator] and @ck.tp[:translator].length >@ck.lt_translator
+ puts @ck.tp[:prepared_by].length.to_s + ' checklength ' + @ck.tp[:prepared_by] if @ck.tp[:prepared_by] and @ck.tp[:prepared_by].length >@ck.lt_prepared_by
+ puts @ck.tp[:digitized_by].length.to_s + ' checklength ' + @ck.tp[:digitized_by] if @ck.tp[:digitized_by] and @ck.tp[:digitized_by].length >@ck.lt_digitized_by
+ puts @ck.tp[:subject].length.to_s + ' checklength ' + @ck.tp[:subject] if @ck.tp[:subject] and @ck.tp[:subject].length >@ck.lt_subject
+ puts @ck.tp[:description].length.to_s + ' checklength ' + @ck.tp[:description] if @ck.tp[:description] and @ck.tp[:description].length >@ck.lt_description
+ puts @ck.tp[:publisher].length.to_s + ' checklength ' + @ck.tp[:publisher] if @ck.tp[:publisher] and @ck.tp[:publisher].length >@ck.lt_publisher
+ puts @ck.tp[:contributor].length.to_s + ' checklength ' + @ck.tp[:contributor] if @ck.tp[:contributor] and @ck.tp[:contributor].length >@ck.lt_contributor
+ puts @ck.tp[:date].length.to_s + ' checklength ' + @ck.tp[:date] if @ck.tp[:date] and @ck.tp[:date].length >@ck.lt_date
+ puts @ck.tp[:date_created].length.to_s + ' checklength ' + @ck.tp[:date_created] if @ck.tp[:date_created] and @ck.tp[:date_created].length >@ck.lt_date
+ puts @ck.tp[:date_issued].length.to_s + ' checklength ' + @ck.tp[:date_issued] if @ck.tp[:date_issued] and @ck.tp[:date_issued].length >@ck.lt_date
+ puts @ck.tp[:date_valid].length.to_s + ' checklength ' + @ck.tp[:date_valid] if @ck.tp[:date_valid] and @ck.tp[:date_valid].length >@ck.lt_date
+ puts @ck.tp[:date_available].length.to_s + ' checklength ' + @ck.tp[:date_available] if @ck.tp[:date_available] and @ck.tp[:date_available].length >@ck.lt_date
+ puts @ck.tp[:date_modified].length.to_s + ' checklength ' + @ck.tp[:date_modified] if @ck.tp[:date_modified] and @ck.tp[:date_modified].length >@ck.lt_date
+ puts @ck.tp[:date_translated].length.to_s + ' checklength ' + @ck.tp[:date_translated] if @ck.tp[:date_translated] and @ck.tp[:date_translated].length >@ck.lt_date
+ puts @ck.tp[:date_added_to_site].length.to_s + ' checklength ' + @ck.tp[:date_added_to_site] if @ck.tp[:date_added_to_site] and @ck.tp[:date_added_to_site].length >@ck.lt_date
+ puts @ck.tp[:type].length.to_s + ' checklength ' + @ck.tp[:type] if @ck.tp[:type] and @ck.tp[:type].length >@ck.lt_type
+ puts @ck.tp[:format].length.to_s + ' checklength ' + @ck.tp[:format] if @ck.tp[:format] and @ck.tp[:format].length >@ck.lt_format
+ puts @ck.tp[:identifier].length.to_s + ' checklength ' + @ck.tp[:identifier] if @ck.tp[:identifier] and @ck.tp[:identifier].length >@ck.lt_identifier
+ puts @ck.tp[:source].length.to_s + ' checklength ' + @ck.tp[:source] if @ck.tp[:source] and @ck.tp[:source].length >@ck.lt_source
+ puts @ck.tp[:language].length.to_s + ' checklength ' + @ck.tp[:language] if @ck.tp[:language] and @ck.tp[:language].length >@ck.lt_language
+ puts @ck.tp[:language_original].length.to_s + ' checklength ' + @ck.tp[:language_original] if @ck.tp[:language_original] and @ck.tp[:language_original].length >@ck.lt_language_original
+ puts @ck.tp[:relation].length.to_s + ' checklength ' + @ck.tp[:relation] if @ck.tp[:relation] and @ck.tp[:relation].length >@ck.lt_relation
+ puts @ck.tp[:coverage].length.to_s + ' checklength ' + @ck.tp[:coverage] if @ck.tp[:coverage] and @ck.tp[:coverage].length >@ck.lt_coverage
+ puts @ck.tp[:rights].length.to_s + ' checklength ' + @ck.tp[:rights] if @ck.tp[:rights] and @ck.tp[:rights].length >@ck.lt_rights
+ puts @ck.tp[:copyright].length.to_s + ' checklength ' + @ck.tp[:copyright] if @ck.tp[:copyright] and @ck.tp[:copyright].length >@ck.lt_copyright
+ puts @ck.tp[:owner].length.to_s + ' checklength ' + @ck.tp[:owner] if @ck.tp[:owner] and @ck.tp[:owner].length >@ck.lt_owner
+ puts @ck.tp[:keywords].length.to_s + ' checklength ' + @ck.tp[:keywords] if @ck.tp[:keywords] and @ck.tp[:keywords].length >@ck.lt_keywords
+ puts @ck.tp[:abstract].length.to_s + ' checklength ' + @ck.tp[:abstract] if @ck.tp[:abstract] and @ck.tp[:abstract].length >@ck.lt_abstract
+ puts @ck.tp[:comment].length.to_s + ' checklength ' + @ck.tp[:comment] if @ck.tp[:comment] and @ck.tp[:comment].length >@ck.lt_comment
+ puts @ck.tp[:loc].length.to_s + ' checklength ' + @ck.tp[:loc] if @ck.tp[:loc] and @ck.tp[:loc].length >@ck.lt_loc
+ puts @ck.tp[:dewey].length.to_s + ' checklength ' + @ck.tp[:dewey] if @ck.tp[:dewey] and @ck.tp[:dewey].length >@ck.lt_dewey
+ puts @ck.tp[:isbn].length.to_s + ' checklength ' + @ck.tp[:isbn] if @ck.tp[:isbn] and @ck.tp[:isbn].length >@ck.lt_isbn
+ puts @ck.tp[:pg].length.to_s + ' checklength ' + @ck.tp[:pg] if @ck.tp[:pg] and @ck.tp[:pg].length >@ck.lt_pg
+ puts @ck.tp[:topic_register].length.to_s + ' checklength ' + @ck.tp[:topic_register] if @ck.tp[:topic_register] and @ck.tp[:topci_register].length >@ck.lt_topic_register
+ puts @ck.tp[:date] if @ck.tp[:date] and not @ck.tp[:date].empty? and @ck.tp[:date] !~/\d\d-\d\d-\d\d/
+ end
+ end
+ end
+end
+__END__
diff --git a/lib/sisu/v3dv/dbi.rb b/lib/sisu/v3dv/dbi.rb
new file mode 100644
index 00000000..008ac5d4
--- /dev/null
+++ b/lib/sisu/v3dv/dbi.rb
@@ -0,0 +1,143 @@
+# encoding: utf-8
+=begin
+
+ * Name: SiSU
+
+ * Description: a framework for document structuring, publishing and search
+
+ * Author: Ralph Amissah
+
+ * Copyright: (C) 1997 - 2012, 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 .
+
+ If you have Internet connection, the latest version of the GPL should be
+ available at these locations:
+
+
+
+
+
+
+
+ * SiSU uses:
+ * Standard SiSU markup syntax,
+ * Standard SiSU meta-markup syntax, and the
+ * Standard SiSU object citation numbering and system
+
+ * Hompages:
+
+
+
+ * Download:
+
+
+ * Ralph Amissah
+
+
+
+ ** Description: postgresql module, dbi import frame
+
+=end
+module SiSU_DBI #% database building
+ require_relative 'help' # help.rb
+ require_relative 'sysenv' # sysenv.rb
+ include SiSU_Env; include SiSU_Screen
+ require_relative 'param' # param.rb
+ include SiSU_Param
+ require_relative 'db_dbi' # db_dbi.rb
+ include SiSU_DB_DBI
+ require_relative 'shared_html_lite' # shared_html_lite.rb
+ include SiSU_Format_Shared
+ class SiSU_SQL
+ def initialize(opt)
+ SiSU_Env::Load.new('dbi',true).prog
+ @opt=opt
+ @db=SiSU_Env::Info_db.new
+ if @opt.cmd =~/d/i \
+ or @opt.mod.inspect =~/--(pg(?:sql)?|(?:sq)?lite)/
+ @sql_type=if @opt.cmd=~/D/ \
+ or @opt.mod.inspect =~/--pg(?:sql)?/
+ maintenance_check(@opt,__FILE__,__LINE__) if @opt.cmd.inspect =~/M/
+ 'pg'
+ elsif @opt.cmd =~/d/ \
+ and @opt.mod.inspect =~/--(?:db[=-])?pg(?:sql)?/
+ maintenance_check(@opt,__FILE__,__LINE__) if @opt.cmd.inspect =~/M/
+ 'pg'
+ elsif @opt.cmd=~/d/ \
+ or @opt.mod.inspect =~/--(?:sq)?lite/
+ maintenance_check(@opt,__FILE__,__LINE__) if @opt.cmd.inspect =~/M/
+ 'sqlite'
+ elsif @opt.cmd =~/d/ \
+ and @opt.mod.inspect =~/--(?:db[=-])?(?:sq)?lite/
+ maintenance_check(@opt,__FILE__,__LINE__) if @opt.cmd.inspect =~/M/
+ 'sqlite'
+ else
+ maintenance_check(@opt,__FILE__,__LINE__) if @opt.cmd.inspect =~/M/
+ 'sqlite'
+ end
+ end
+ end
+ def maintenance_check(opt,file,line)
+ p opt.mod
+ p opt.cmd
+ p "at #{file} #{line}"
+ end
+ def read_psql
+ begin
+ @conn=@db.psql.conn_dbi
+ rescue
+ if @opt.mod.inspect=~/--(createall|create)/
+ puts %{manually create the database: "#{@db.db}" if it does not yet exist}
+ #sudo su -p postgres; createdb #{@db.db}; #[createuser?]
+ end
+ SiSU_DB_DBI::Case.new(@opt,@conn,@sql_type).cases
+ @conn=DBI.connect(@db.dbi,@db.user,@db.db)
+ ensure
+ end
+ end
+ def read_sqlite
+ begin
+ sql_type='sqlite'
+ @conn=@db.sqlite.conn_sqlite3
+ rescue
+ ensure
+ end
+ end
+ def connect
+ case @sql_type
+ when /pg/; read_psql
+ when /sqlite/; read_sqlite
+ end
+ SiSU_Screen::Ansi.new(@opt.cmd,"DBI (#{@sql_type}) #{@opt.mod}",@opt.fns).dbi_title unless @opt.cmd =~/q/
+ begin
+ SiSU_DB_DBI::Case.new(@opt,@conn,@sql_type).cases
+ rescue
+ SiSU_Errors::Info_error.new($!,$@,@cf,@opt.fns).error
+ ensure
+ end
+ begin
+ rescue
+ connect
+ end
+ end
+ end
+end
+__END__
diff --git a/lib/sisu/v3dv/defaults.rb b/lib/sisu/v3dv/defaults.rb
new file mode 100644
index 00000000..7278c5f9
--- /dev/null
+++ b/lib/sisu/v3dv/defaults.rb
@@ -0,0 +1,2267 @@
+# encoding: utf-8
+=begin
+
+ * Name: SiSU
+
+ * Description: a framework for document structuring, publishing and search
+
+ * Author: Ralph Amissah
+
+ * Copyright: (C) 1997 - 2012, 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 .
+
+ If you have Internet connection, the latest version of the GPL should be
+ available at these locations:
+
+
+
+
+
+
+
+ * SiSU uses:
+ * Standard SiSU markup syntax,
+ * Standard SiSU meta-markup syntax, and the
+ * Standard SiSU object citation numbering and system
+
+ * Hompages:
+
+
+
+ * Download:
+
+
+ * Ralph Amissah
+
+
+
+ ** Description: Default values (reset by skins)
+
+=end
+$latex_run=nil
+module SiSU_Viz
+ require 'uri'
+ require_relative 'sysenv' # sysenv.rb
+ include SiSU_Env
+ require_relative 'css' # css.rb
+ include SiSU_Style
+ class Skin
+ def initialize
+ @fonts='verdana, arial, georgia, tahoma, sans-serif, helvetica, times, roman' # 'verdana, arial, georgia, tahoma, sans-serif, helvetica, "times new roman", times, roman'
+ @dir=SiSU_Env::Info_env.new
+ @date=SiSU_Env::Info_date.new #{@date.year}
+ @v=SiSU_Env::Info_version.instance.get_version
+ end
+ #% glyph
+ def glyph_bullet # •
+ ' ' # [ flagged]
+ end
+ #% html
+ def html_hardspace
+ ' '
+ end
+ #% php
+ def php_persist
+ end
+ #% javascript #kxjs knxjs
+ def js_home
+ end
+ def js_infobox
+ end
+ def js_knxjs
+ end
+ def js_head
+ end
+ def js_top
+ end
+ def js_sisu
+ end
+ def js_home
+ end
+ def js_sponsor
+ end
+ def js_books
+ end
+ def js_journals
+ end
+ def js_conferences
+ end
+ def js_services
+ end
+ def js_catalogue
+ end
+ def js_doc
+ end
+ def js_toc
+ end
+ def js_seg
+ end
+ def js_mail
+ end
+ def js_manifest
+ end
+ def js_status
+ end
+ def js_next
+ end
+ def js_prev
+ end
+ def js_plaintext
+ end
+ def js_portrait
+ end
+ def js_landscape
+ end
+ def js_pdf
+ end
+ def js_epub
+ end
+ def js_odf
+ end
+ def js_concordance
+ end
+ def js_instruments
+ end
+ def js_external
+ end
+ def js_gopher
+ end
+ def js_ftp
+ end
+ def js_law
+ end
+ def js_disclaimer
+ end
+ def semantic_tags
+ def default
+ {
+ pub: 'publication',
+ conv: 'convention',
+ vol: 'volume',
+ pg: 'page',
+ cty: 'city',
+ org: 'organization',
+ uni: 'university',
+ dept: 'department',
+ fac: 'faculty',
+ inst: 'institute',
+ co: 'company',
+ com: 'company',
+ conv: 'convention',
+ dt: 'date',
+ y: 'year',
+ m: 'month',
+ d: 'day',
+ ti: 'title',
+ au: 'author',
+ ed: 'editor', #editor?
+ v: 'version', #edition
+ n: 'name',
+ fn: 'firstname',
+ mn: 'middlename',
+ ln: 'lastname',
+ in: 'initials',
+ qt: 'quote',
+ ct: 'cite',
+ ref: 'reference',
+ ab: 'abreviation',
+ def: 'define',
+ desc: 'description',
+ trans: 'translate',
+ }
+ end
+ self
+ end
+ #% decorate
+ def decorate_italics
+ 'title|article|book|journal'
+ end
+ def decorate_bold
+ end
+ def decorate_uppercase
+ 'surname'
+ end
+ #% semantic
+ def sem_title #dc 1
+ 'title'
+ end
+ def sem_article
+ 'article'
+ end
+ def sem_book
+ 'book'
+ end
+ def sem_journal
+ 'journal'
+ end
+ def sem_fullname # (contains: firstname, surname) #issues arise as contains surname etc.
+ 'fullname'
+ end
+ def sem_first
+ 'first'
+ end
+ def sem_surname
+ 'surname'
+ end
+ def sem_middle
+ 'middle'
+ end
+ def sem_creator #dc 2 #==fullname (contains: firstname, surname)
+ 'creator'
+ end
+ def sem_author #==fullname (contains: firstname, surname)
+ 'author'
+ end
+ def sem_editor #==fullname (contains: firstname, surname)
+ 'editor'
+ end
+ def sem_illustrator #==fullname (contains: firstname, surname)
+ 'illustrator'
+ end
+ def sem_translator #==fullname (contains: firstname, surname)
+ 'translator'
+ end
+ def sem_isbn # 10 or 13
+ 'isbn'
+ end
+ def sem_isbn_10
+ 'isbn10'
+ end
+ def sem_isbn_13
+ 'isbn13'
+ end
+ def sem_loc # library of congress
+ 'loc'
+ end
+ def sem_dewey
+ 'dewey'
+ end
+ def sem_pg # project gutenberg number
+ 'pg'
+ end
+ def sem_subject #dc 3
+ 'subject'
+ end
+ def sem_date #dc 7
+ 'date'
+ end
+ def sem_date_created
+ 'date_created'
+ end
+ def sem_date_issued
+ 'date_issued'
+ end
+ def sem_date_available
+ 'date_available'
+ end
+ def sem_date_valid
+ 'date_valid'
+ end
+ def sem_date_modified
+ 'date_modified'
+ end
+ def sem_type #dc 8
+ 'type'
+ end
+ def sem_description #dc 4
+ 'description'
+ end
+ def sem_publisher #dc 5
+ 'publisher'
+ end
+ def sem_contributor #dc 6
+ 'contributor'
+ end
+ def sem_format #dc 9
+ 'format'
+ end
+ def sem_identifier #dc 10
+ 'identifier'
+ end
+ def sem_source #dc 11
+ 'source'
+ end
+ def sem_language #dc 12
+ 'language'
+ end
+ def sem_relation #dc 13
+ 'source'
+ end
+ def sem_coverage #dc 14
+ 'coverage'
+ end
+ def sem_rights #dc 15
+ 'rights'
+ end
+ def sem_copyright
+ 'copyright'
+ end
+ def sem_license
+ 'license'
+ end
+ def sem_prepared_by
+ 'prepared_by'
+ end
+ def sem_digitized_by
+ 'digitized_by'
+ end
+ def sem_keywords
+ 'keywords'
+ end
+ def sem_comments
+ 'comments'
+ end
+ def sem_abstract
+ 'abstract'
+ end
+ #% path
+ def path_stylesheet_home
+ %{ }
+ end
+ #% text #changed from txt to avoid naming conflicts #FOLLOW
+ def txt_generator
+ %{
+ }
+ end
+ def txt_generator_comment
+ %{ }
+ end
+ def txt_hp
+ ' SiSU'
+ end
+ def txt_hp_alias
+ 'SiSU'
+ end
+ def txt_home
+ 'SiSU'
+ end
+ def txt_signature # used in latex/pdf footer
+ 'SiSU'
+ end
+ #% url
+ def url_urify(uri)
+ URI.parse(uri)
+ end
+ def url_sisu
+ 'http://www.sisudoc.org/'
+ end
+ def url_sisudoc
+ 'http://www.sisudoc.org'
+ end
+ def url_footer_signature
+ 'http://www.sisudoc.org/'
+ end
+ def url_root
+ '/sisu' #watch
+ end
+ def url_root_http
+ 'http://www.sisudoc.org/' #watch
+ end
+ def url_home
+ 'http://www.sisudoc.org/' # used in pdf header
+ end
+ def url_site #used as stub... where there are subdirectories and is different from home
+ url_home
+ #'http://www.sisudoc.org/' # used in pdf header
+ end
+ def url_txt
+ 'www.sisudoc.org/'
+ end
+ def url_path_image_base #used for html image display
+ "#{Xx[:html_relative2]}_sisu/image"
+ end
+ def url_path_image #used for html image display
+ "#{Xx[:html_relative2]}_sisu/image"
+ end
+ def url_path_image_sys #used for html image display
+ "#{Xx[:html_relative2]}_sisu/image_sys"
+ end
+ def url_path_image_epub
+ './image'
+ end
+ def url_path_ebook_dir
+ './ebook'
+ end
+ def url_path_ebook_images
+ '.'
+ end
+ def url_promo
+ ''
+ end
+ def url_promo_home
+ ''
+ end
+ def url_decoration
+ def tex_open #'{\UseTextSymbol{OML}{<}}'
+ Dx[:url_o]
+ end
+ def tex_close #'{\UseTextSymbol{OML}{>}}'
+ Dx[:url_c]
+ end
+ def xml_open #'<'
+ Dx[:url_o]
+ end
+ def xml_close #'>'
+ Dx[:url_c]
+ end
+ def txt_open
+ '<'
+ end
+ def txt_close
+ '>'
+ end
+ self
+ end
+ def rel_decoration
+ def tex_open #'{\UseTextSymbol{OML}{<}}'
+ Dx[:rel_o]
+ end
+ def tex_close #'{\UseTextSymbol{OML}{>}}'
+ Dx[:rel_c]
+ end
+ def xml_open #'<'
+ Dx[:rel_o]
+ end
+ def xml_close #'>'
+ Dx[:rel_c]
+ end
+ def txt_open
+ '<'
+ end
+ def txt_close
+ '>'
+ end
+ self
+ end
+ #% color
+ def color_shadow
+ '"4"'
+ end
+ def color_body
+ %{}
+ end
+ def color_white
+ '"#ffffff"'
+ end
+ def color_black
+ '#000000'
+ end
+ def color_shadow #hmmm
+ '"4"'
+ end
+ def color_blue_dark
+ '#000099'
+ end
+ def color_blue
+ 'blue'
+ end
+ def color_blue_base
+ '#b9d4dd'
+ end
+ def color_blue_ink
+ '#003399'
+ end
+ def color_blue_tinge
+ '#e3ecef'
+ end
+ def color_blue_grey
+ '#8faebf'
+ end
+ def color_blue_murky
+ '#437389'
+ end
+ def color_beige
+ '#f1e8de'
+ end
+ def color_subtleglow
+ '#dddccc'
+ end
+ def color_glow
+ '#fff0c3'
+ end
+ def color_rose
+ '#ffdec9'
+ end
+ def color_turquoise
+ '#1c869b'
+ end
+ def color_grey_pale
+ '#eeeeee'
+ end
+ def color_grey_medium
+ '#cccccc'
+ end
+ def color_grey
+ '#999999'
+ end
+ def color_yellow_light
+ '#fff3b6'
+ end
+ def color_yellow
+ '#ffde14'
+ end
+ def color_yellow_dark
+ '#ffcc00'
+ end
+ def color_green_light
+ '#b7d398' # #e2efd5 #b7d398 #b1c999 # '#aed19e'
+ end
+ def color_green
+ '#0a8400'
+ end
+ def color_green_dark
+ '#086800'
+ end
+ def color_ruby
+ '#a00000'
+ end
+ def color_maroon
+ '#800000'
+ end
+ def color_paper
+ %{"#{color_white}"}
+ end
+ def color_band1
+ %{"#{color_white}"}
+ end
+ def color_band2
+ %{"#{color_white}"}
+ end
+ def color_body
+ %{}
+ end
+ def color_font_face #was font WATCH
+ "#{color_black}"
+ end
+ def color_surround
+ %{"#{color_white}"}
+ end
+ def color_band
+ %{"#{color_white}"}
+ end
+ def color_table1
+ 'ffffcc'
+ end
+ def color_table2
+ 'c0d0f0'
+ end
+ def color_band1
+ '"#ffffff"'
+ end
+ def color_band2
+ '"#ffffff"'
+ end
+ #% icon
+ def icon_ico
+ 'rb7.ico'
+ end
+ def icon_sisu
+ 'sisu.png'
+ end
+ def icon_manifest
+ 'b_info.png'
+ end
+ def icon_doc
+ 'b_doc.png'
+ end
+ def icon_toc
+ 'b_toc.png'
+ end
+ def icon_wmp
+ 'b_wmp.png'
+ end
+ def icon_odf
+ 'b_odf.png'
+ end
+ def icon_epub
+ 'b_epub.png'
+ end
+ def icon_pdf
+ 'b_pdf.png'
+ end
+ def icon_pdf_portrait
+ 'b_pdf.png'
+ end
+ def icon_pdf_landscape
+ 'b_pdf.png'
+ end
+ def icon_status
+ 'b_status.png'
+ end
+ def icon_external
+ 'b_ext.png'
+ end
+ def icon_external_toc
+ 'b_ext_toc.png'
+ end
+ def icon_seg_toc
+ 'b_bluebell.png'
+ end
+ def icon_crosslink_toc
+ 'b_amber.png'
+ end
+ def icon_mail
+ 'b_mail.png'
+ end
+ def icon_para
+ 'b_para.png'
+ end
+ def icon_pdf
+ 'b_pdf.png'
+ end
+ def icon_ftp
+ 'b_ftp.png'
+ end
+ def icon_gopher
+ 'b_gopher.png'
+ end
+ def icon_choice
+ 'b_choice.png'
+ end
+ def icon_new
+ 'b_new.png'
+ end
+ def icon_book
+ 'b_amber.png'
+ # b_book.png
+ end
+ def icon_dot_clear
+ 'dot_clear.png'
+ end
+ def icon_dot_white
+ 'dot_white.png'
+ end
+ def icon_dot
+ icon_dot_white
+ end
+ def icon_amber
+ 'b_amber.png'
+ end
+ def icon_rose
+ 'b_rose.png'
+ end
+ def icon_bluebell
+ 'b_bluebell.png'
+ end
+ def icon_home_button
+ 'sisu.png'
+ end
+ def icon_home_banner
+ 'sisu.png'
+ end
+ def icon_site
+ 'b_home.png'
+ end
+ def icon_bluedot
+ 'blueband.png'
+ end
+ def icon_next
+ 'arrow_next_red.png'
+ end
+ def icon_previous
+ 'arrow_prev_red.png'
+ end
+ def icon_up
+ 'arrow_up_red.png'
+ end
+ #% font
+ def font_fonts
+ @fonts
+ end
+ def font_face
+ %{face="#{font_fonts}"}
+ end
+ def font_lmtoc_face
+ %{face="#{font_fonts}"}
+ end
+ def font_ebook_face
+ %{face="#{font_fonts}"}
+ end
+ def font_face_lmtoc
+ %{face="#{font_fonts}"}
+ end
+ def font_color
+ 'color="#000000"'
+ end
+ def font_size
+ 'size="4"'
+ end
+ def font_size_txt
+ 'size="4"'
+ end
+ def font_size_txt_00
+ 'size="3"'
+ end
+ def font_size_endnote
+ 'size="3"'
+ end
+ def font_small
+ 'size="3"'
+ end
+ def font_tiny
+ 'size="2"'
+ end
+ #% markup
+ def markup_italics_list #regular expression of words to be italised
+ end
+ def markup_bold_list #regular expression of words to be made bold
+ 'SiSU'
+ end
+ def markup_make_italic
+ if defined? italics_list \
+ and italics_list
+ make={}
+ if italics_list
+ r=italics_list.dup
+ x=case r
+ when /\/i$/; 'i'
+ else ''
+ end
+ r.gsub!(/^\/(.+?)\/i?/,'\1')
+ r.gsub!(/\(/,'(?:') # avoid need to escape use of brackets within regex provided
+ m='\b(' + r + ')\b'
+ make[:str]
+ make[:regx]=if x =~/i/; /#{m}/i
+ else /#{m}/
+ end
+ else nil
+ end
+ end
+ end
+ def markup_make_bold
+ if defined? bold_list \
+ and not bold_list.empty?
+ make={}
+ if bold_list
+ r=bold_list.dup
+ x=case r
+ when /\/i$/; 'i'
+ else ''
+ end
+ r.gsub!(/^\/(.+?)\/i?/,'\1')
+ r.gsub!(/\(/,'(?:') # avoid need to escape use of brackets within regex provided
+ m='\b(' + r + ')\b'
+ make[:str]
+ make[:regx]=if x =~/i/; /#{m}/i
+ else /#{m}/
+ end
+ else nil
+ end
+ make
+ end
+ end
+ #% paragraph
+ def paragraph_txt
+ %{
}
+ end
+ def paragraph_txt_00
+ %{
}
+ end
+ def paragraph_font_citation
+ %{}
+ end
+ def paragraph_endnote
+ %{
}
+ end
+ def paragraph_table
+ %{
}
+ end
+ def paragraph_table_xml
+ end
+ def paragraph_tiny
+ %{
}
+ end
+ def paragraph_small
+ %{
} # keep but not used?
+ end
+ def paragraph_font_tiny
+ %{}
+ end
+ def paragraph_font_small
+ %{}
+ end
+ def paragraph_heading_1
+ %{
}
+ end
+ def paragraph_heading_1_center
+ %{
}
+ end
+ #% table
+ def table_close
+ '
+'
+ end
+ def table_close_centered_table
+ end
+ def table_align_A
+ end
+ def table_align_B
+ end
+ def table_align_C
+ end
+ def table_width_1
+ '"100%"'
+ end
+ def table_width_2
+ '"99%"'
+ end
+ def table_width_3
+ '"94%"'
+ end
+ def table_width_4
+ '"90%"'
+ end
+ def table_width_txt
+ '"94%"'
+ end
+ def table_width_txt_avgo
+ '"100%"'
+ end
+ def table_width_txt_r
+ '"96%"'
+ end
+ def table_cellpad_small_paper_margins
+ '"6"'
+ end
+ def table_cellpad_paper_margins
+ '"36"'
+ end
+ def table_cellpad_A
+ '"0"'
+ end
+ def table_cellpad_B
+ '"20"'
+ end
+ def table_cellpad_shadow
+ '"4"'
+ end
+ def table_cellpad_band
+ '"16"'
+ end
+ def table_cellpad_box
+ '"20"'
+ end
+ def table_table_align_A
+ '
'
+ end
+ def table_table_align_B
+ '
'
+ end
+ def table_table_align_C
+ ' '
+ end
+ #% table_do
+ def table_do_table_paper
+ %{#{table_align_C}
\n\n}
+ end
+ def table_do_table_surround
+ %{
\n}
+ end
+ #% indent
+ def indent_level_0
+ '"1%"'
+ end
+ def indent_level_1
+ '"4%"'
+ end
+ def indent_level_2
+ '"6%"'
+ end
+ def indent_level_3
+ '"8%"'
+ end
+ def indent_level_4
+ '"10%"'
+ end
+ #% margin
+ def margin_num
+ '
'
+ end
+ def margin_numless
+ '
'
+ end
+ def margin_num_css
+ '
+
'
+ end
+ def margin_num_header
+ '
+
'
+ end
+ def margin_txt_00_1
+ %{
+
+
+
}
+ end
+ def margin_txt_w1
+ %{
+
+
}
+ end
+ def margin_txt_w2
+ %{
+
+
}
+ end
+ def margin_txt_0
+ %{
+
+
}
+ end
+ def margin_txt_1
+ %{
+
}
+ end
+ def margin_txt_2
+ %{
+
+
+
}
+ end
+ def margin_txt_3
+ %{
+
+
+
}
+ end
+ def margin_css #unused, check
+ '
+
'
+ end
+ #% png
+ def png_ico
+ %{ }
+ end
+ def png_sisu #check url path
+ %{
+
+ }
+ end
+ def png_hp
+ dir=SiSU_Env::Info_env.new #(@fns)
+ %{
+
+ }
+ end
+ def png_site
+ %{}
+ end
+ def png_homepage
+ png_site
+ end
+ def png_nav
+ %{}
+ end
+ def png_manifest
+ %{}
+ end
+ def png_doc
+ %{}
+ end
+ def png_toc
+ %{}
+ end
+ def png_odf
+ %{}
+ end
+ def png_epub
+ %{}
+ end
+ def png_pdf
+ %{}
+ end
+ def png_pdf_portrait
+ %{}
+ end
+ def png_pdf_landscape
+ %{}
+ end
+ def png_wmp
+ %{}
+ end
+ def png_para
+ %{}
+ end
+ def png_status
+ %{}
+ end
+ def png_mark
+ %{}
+ end
+ def png_doc_tiny
+ %{}
+ end
+ def png_toc_tiny
+ %{}
+ end
+ def png_status_tiny
+ %{}
+ end
+ def png_ftp
+ %{}
+ end
+ def png_gopher
+ %{}
+ end
+ def png_crosslink
+ %{}
+ end
+ def png_crosslink_ext
+ %{}
+ end
+ def png_home
+ #dir=SiSU_Env::Info_env.new #(@fns)
+ %{}
+ #%{}
+ end
+ def png_home_button
+ rel=@dir.path_rel_links.html_scroll_2
+ %{}
+ end
+ def png_book
+ %{}
+ end
+ #% png_nav
+ def png_nav_home
+ end
+ def png_nav_toc
+ %{}
+ end
+ def png_nav_doc
+ end
+ def png_nav_previous
+ %{}
+ end
+ def png_nav_next
+ %{}
+ end
+ def png_nav_pre
+ png_nav_previous
+ end
+ def png_nav_nxt
+ png_nav_next
+ end
+ def epub_png_nav_previous
+ %{}
+ end
+ def epub_png_nav_next
+ %{}
+ end
+ def epub_png_nav_up
+ %{}
+ end
+ def epub_png_nav_pre
+ epub_png_nav_previous
+ end
+ def epub_png_nav_nxt
+ epub_png_nav_next
+ end
+ def epub_png_nav_toc
+ epub_png_nav_up
+ end
+ def png_nav_pdf
+ %{}
+ end
+ def png_nav_pdf_portrait
+ %{}
+ end
+ def png_nav_pdf_landscape
+ %{}
+ end
+ def png_nav_dot_toc
+ %{}
+ end
+ def png_nav_dot_previous
+ %{}
+ end
+ def png_nav_dot_next
+ %{}
+ end
+ def png_nav_dot_pre
+ png_nav_dot_previous
+ end
+ def png_nav_dot_nxt
+ png_nav_dot_next
+ end
+ #% nav_txt
+ def nav_txt_home
+ %{
+ #{png_site}
+ }
+ end
+ def nav_txt_home_button
+ %{
+ #{png_home_button}
+ }
+ end
+ def nav_txt_homepage
+ %{
+ home
+ }
+ end
+ def nav_txt_toc_link
+ %{
+ toc
+ }
+ end
+ def nav_txt_toc_link_verbose
+ %{
+ #{png_toc} segments' toc
+ }
+ end
+ def nav_txt_doc_link
+ %{
+ scroll
+ }
+ end
+ def nav_txt_manifest
+ #{png_manifest} document manifest
+ %{
+ [ document manifest ]
+ }
+ end
+ def nav_txt_concordance
+ %{
+ A-Z
+ }
+ end
+ def nav_txt_previous
+ '
+ << Previous
+
+ Full Text '
+ end
+ def nav_txt_next
+ %{
+ Next >>
+ }
+ end
+ def nav_txt_plaintext
+ %{
+ txt
+ }
+ end
+ def nav_txt_odf
+ %{
+ odt
+ }
+ end
+ def nav_txt_pdfs
+ %{
+ pdfs
+ }
+ end
+ def nav_txt_epub
+ %{
+ epub
+ }
+ end
+ def nav_txt_pdf_portrait
+ %{
+ pdf
+ }
+ end
+ def nav_txt_pdf_landscape
+ %{
+ pdf
+ }
+ end
+ #% banner
+ def banner_home
+ %{
+
+ #{png_site}
+
+
+
+ an
+
+ ( international | transnational )
+
+ commercial law & e-commerce
+
+ infrastructure monitor
+#{table_close}}
+ end
+ def banner_credit_band
+ %{
+
+
+
+
+
}
+ end
+ def banner_instrument_cover_band_scr
+ '
+
'
+ end
+ def banner_instrument_cover_band_seg
+ '
+
'
+ end
+ #% widget
+ def widget_promo # Array used to build promo from list.yml and promo.yml
+ # ['sisu_icon','sisu','sisu_search_libre','open_society','fsf','ruby']
+ end
+ def widget_browsers
+<
+
+
+
+
+ If you have problems viewing pages on this site please update your browser:
+
+