From 39e11a4420226c3238e787de5be1c9279f46cf1f Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Fri, 8 Aug 2014 00:10:22 -0400 Subject: v5 v6: code file renames, fairly extensive * v5 file renames sync with v6 for easier comparison * v5 here (5.5.6) remains as in previous version (5.5.5) --- lib/sisu/v5/air.rb | 2 +- lib/sisu/v5/ao.rb | 4 +- lib/sisu/v5/ao_composite.rb | 2 +- lib/sisu/v5/author_format.rb | 117 -- lib/sisu/v5/cgi.rb | 2 +- lib/sisu/v5/cgi_pgsql.rb | 2 +- lib/sisu/v5/cgi_sqlite.rb | 2 +- lib/sisu/v5/conf.rb | 4 +- lib/sisu/v5/css.rb | 2 +- lib/sisu/v5/db_columns.rb | 2 +- lib/sisu/v5/db_create.rb | 2 +- lib/sisu/v5/db_drop.rb | 2 +- lib/sisu/v5/db_load_tuple.rb | 2 +- lib/sisu/v5/dbi.rb | 4 +- lib/sisu/v5/dbi_discrete.rb | 4 +- lib/sisu/v5/defaults.rb | 2 +- lib/sisu/v5/digests.rb | 2 +- lib/sisu/v5/dp.rb | 1550 +++++++++++++++++++++++ lib/sisu/v5/dp_identify_markup.rb | 167 +++ lib/sisu/v5/dp_make.rb | 674 ++++++++++ lib/sisu/v5/embedded.rb | 4 +- lib/sisu/v5/errors.rb | 2 +- lib/sisu/v5/git.rb | 4 +- lib/sisu/v5/harvest.rb | 4 +- lib/sisu/v5/harvest_author_format.rb | 117 ++ lib/sisu/v5/harvest_authors.rb | 2 +- lib/sisu/v5/harvest_topics.rb | 2 +- lib/sisu/v5/html.rb | 2 +- lib/sisu/v5/html_concordance.rb | 6 +- lib/sisu/v5/html_lite_shared.rb | 2 +- lib/sisu/v5/html_promo.rb | 2 +- lib/sisu/v5/html_tune.rb | 4 +- lib/sisu/v5/hub.rb | 14 +- lib/sisu/v5/hub_options.rb | 1399 ++++++++++++++++++++ lib/sisu/v5/manifest.rb | 6 +- lib/sisu/v5/manpage.rb | 2 +- lib/sisu/v5/manpage_format.rb | 2 +- lib/sisu/v5/options.rb | 1399 -------------------- lib/sisu/v5/param.rb | 1550 ----------------------- lib/sisu/v5/param_identify_markup.rb | 167 --- lib/sisu/v5/param_make.rb | 674 ---------- lib/sisu/v5/particulars.rb | 240 ---- lib/sisu/v5/po4a.rb | 2 +- lib/sisu/v5/prog_text_translation.rb | 2 +- lib/sisu/v5/qrcode.rb | 6 +- lib/sisu/v5/relaxng.rb | 2 +- lib/sisu/v5/remote.rb | 2 +- lib/sisu/v5/response.rb | 79 -- lib/sisu/v5/rexml.rb | 4 +- lib/sisu/v5/screen_text_color.rb | 478 ------- lib/sisu/v5/se.rb | 164 +++ lib/sisu/v5/se_createsite.rb | 2 +- lib/sisu/v5/se_filemap.rb | 2 +- lib/sisu/v5/se_hub_particulars.rb | 240 ++++ lib/sisu/v5/shared_images.rb | 2 +- lib/sisu/v5/shared_sem.rb | 2 +- lib/sisu/v5/sitemaps.rb | 6 +- lib/sisu/v5/spell.rb | 105 -- lib/sisu/v5/src_kdissert_share.rb | 2 +- lib/sisu/v5/src_share.rb | 2 +- lib/sisu/v5/src_shared.rb | 4 +- lib/sisu/v5/src_sisupod_make.rb | 4 +- lib/sisu/v5/sst_convert_markup.rb | 4 +- lib/sisu/v5/sst_do_inline_footnotes.rb | 6 +- lib/sisu/v5/sst_from_xml.rb | 2 +- lib/sisu/v5/sst_to_s_xml_sax.rb | 6 +- lib/sisu/v5/sysenv.rb | 164 --- lib/sisu/v5/termsheet.rb | 6 +- lib/sisu/v5/texinfo.rb | 2 +- lib/sisu/v5/texinfo_format.rb | 2 +- lib/sisu/v5/texpdf.rb | 4 +- lib/sisu/v5/txt_asciidoc.rb | 2 +- lib/sisu/v5/txt_markdown.rb | 2 +- lib/sisu/v5/txt_plain.rb | 2 +- lib/sisu/v5/txt_rst.rb | 2 +- lib/sisu/v5/txt_textile.rb | 2 +- lib/sisu/v5/update.rb | 2 +- lib/sisu/v5/urls.rb | 4 +- lib/sisu/v5/utils_response.rb | 79 ++ lib/sisu/v5/utils_screen_text_color.rb | 478 +++++++ lib/sisu/v5/utils_spell.rb | 105 ++ lib/sisu/v5/webrick.rb | 4 +- lib/sisu/v5/wikispeak.rb | 2 +- lib/sisu/v5/xhtml.rb | 4 +- lib/sisu/v5/xhtml_epub2.rb | 2 +- lib/sisu/v5/xhtml_epub2_concordance.rb | 6 +- lib/sisu/v5/xhtml_epub2_tune.rb | 4 +- lib/sisu/v5/xml_docbook5.rb | 4 +- lib/sisu/v5/xml_dom.rb | 4 +- lib/sisu/v5/xml_fictionbook2.rb | 4 +- lib/sisu/v5/xml_format.rb | 2 +- lib/sisu/v5/xml_md_oai_pmh_dc.rb | 4 +- lib/sisu/v5/xml_odf_odt.rb | 4 +- lib/sisu/v5/xml_odf_odt_format.rb | 2 +- lib/sisu/v5/xml_sax.rb | 4 +- lib/sisu/v5/xml_scaffold_structure_collapsed.rb | 4 +- lib/sisu/v5/xml_scaffold_structure_sisu.rb | 4 +- lib/sisu/v5/xml_shared.rb | 2 +- lib/sisu/v5/zap.rb | 2 +- lib/sisu/v6/air.rb | 2 +- lib/sisu/v6/ao.rb | 4 +- lib/sisu/v6/ao_composite.rb | 2 +- lib/sisu/v6/author_format.rb | 117 -- lib/sisu/v6/cgi.rb | 4 +- lib/sisu/v6/cgi_pgsql.rb | 4 +- lib/sisu/v6/cgi_sqlite.rb | 4 +- lib/sisu/v6/conf.rb | 4 +- lib/sisu/v6/css.rb | 2 +- lib/sisu/v6/db_columns.rb | 2 +- lib/sisu/v6/db_create.rb | 2 +- lib/sisu/v6/db_drop.rb | 2 +- lib/sisu/v6/db_load_tuple.rb | 2 +- lib/sisu/v6/dbi.rb | 4 +- lib/sisu/v6/dbi_discrete.rb | 4 +- lib/sisu/v6/defaults.rb | 2 +- lib/sisu/v6/digests.rb | 2 +- lib/sisu/v6/dp.rb | 1550 +++++++++++++++++++++++ lib/sisu/v6/dp_identify_markup.rb | 167 +++ lib/sisu/v6/dp_make.rb | 674 ++++++++++ lib/sisu/v6/embedded.rb | 4 +- lib/sisu/v6/errors.rb | 2 +- lib/sisu/v6/git.rb | 4 +- lib/sisu/v6/harvest.rb | 4 +- lib/sisu/v6/harvest_author_format.rb | 117 ++ lib/sisu/v6/harvest_authors.rb | 2 +- lib/sisu/v6/harvest_topics.rb | 2 +- lib/sisu/v6/html.rb | 2 +- lib/sisu/v6/html_concordance.rb | 6 +- lib/sisu/v6/html_lite_shared.rb | 2 +- lib/sisu/v6/html_promo.rb | 2 +- lib/sisu/v6/html_tune.rb | 4 +- lib/sisu/v6/hub.rb | 14 +- lib/sisu/v6/hub_options.rb | 1399 ++++++++++++++++++++ lib/sisu/v6/manifest.rb | 6 +- lib/sisu/v6/manpage.rb | 2 +- lib/sisu/v6/manpage_format.rb | 2 +- lib/sisu/v6/options.rb | 1399 -------------------- lib/sisu/v6/param.rb | 1550 ----------------------- lib/sisu/v6/param_identify_markup.rb | 167 --- lib/sisu/v6/param_make.rb | 674 ---------- lib/sisu/v6/particulars.rb | 240 ---- lib/sisu/v6/po4a.rb | 2 +- lib/sisu/v6/prog_text_translation.rb | 2 +- lib/sisu/v6/qrcode.rb | 6 +- lib/sisu/v6/relaxng.rb | 2 +- lib/sisu/v6/remote.rb | 2 +- lib/sisu/v6/response.rb | 79 -- lib/sisu/v6/rexml.rb | 4 +- lib/sisu/v6/screen_text_color.rb | 478 ------- lib/sisu/v6/se.rb | 164 +++ lib/sisu/v6/se_createsite.rb | 2 +- lib/sisu/v6/se_filemap.rb | 2 +- lib/sisu/v6/se_hub_particulars.rb | 240 ++++ lib/sisu/v6/shared_images.rb | 2 +- lib/sisu/v6/shared_sem.rb | 2 +- lib/sisu/v6/sitemaps.rb | 6 +- lib/sisu/v6/spell.rb | 105 -- lib/sisu/v6/src_kdissert_share.rb | 2 +- lib/sisu/v6/src_share.rb | 2 +- lib/sisu/v6/src_shared.rb | 4 +- lib/sisu/v6/src_sisupod_make.rb | 4 +- lib/sisu/v6/sst_convert_markup.rb | 4 +- lib/sisu/v6/sst_do_inline_footnotes.rb | 6 +- lib/sisu/v6/sst_from_xml.rb | 2 +- lib/sisu/v6/sst_to_s_xml_sax.rb | 6 +- lib/sisu/v6/sysenv.rb | 164 --- lib/sisu/v6/termsheet.rb | 6 +- lib/sisu/v6/texinfo.rb | 2 +- lib/sisu/v6/texinfo_format.rb | 2 +- lib/sisu/v6/texpdf.rb | 4 +- lib/sisu/v6/txt_asciidoc.rb | 2 +- lib/sisu/v6/txt_markdown.rb | 2 +- lib/sisu/v6/txt_plain.rb | 2 +- lib/sisu/v6/txt_rst.rb | 2 +- lib/sisu/v6/txt_textile.rb | 2 +- lib/sisu/v6/update.rb | 2 +- lib/sisu/v6/urls.rb | 4 +- lib/sisu/v6/utils_response.rb | 79 ++ lib/sisu/v6/utils_screen_text_color.rb | 478 +++++++ lib/sisu/v6/utils_spell.rb | 105 ++ lib/sisu/v6/webrick.rb | 4 +- lib/sisu/v6/wikispeak.rb | 2 +- lib/sisu/v6/xhtml.rb | 4 +- lib/sisu/v6/xhtml_epub2.rb | 2 +- lib/sisu/v6/xhtml_epub2_concordance.rb | 6 +- lib/sisu/v6/xhtml_epub2_tune.rb | 4 +- lib/sisu/v6/xml_docbook5.rb | 4 +- lib/sisu/v6/xml_dom.rb | 4 +- lib/sisu/v6/xml_fictionbook2.rb | 4 +- lib/sisu/v6/xml_format.rb | 2 +- lib/sisu/v6/xml_md_oai_pmh_dc.rb | 4 +- lib/sisu/v6/xml_odf_odt.rb | 4 +- lib/sisu/v6/xml_odf_odt_format.rb | 2 +- lib/sisu/v6/xml_sax.rb | 4 +- lib/sisu/v6/xml_scaffold_structure_collapsed.rb | 4 +- lib/sisu/v6/xml_scaffold_structure_sisu.rb | 4 +- lib/sisu/v6/xml_shared.rb | 2 +- lib/sisu/v6/zap.rb | 2 +- 198 files changed, 10201 insertions(+), 10201 deletions(-) delete mode 100644 lib/sisu/v5/author_format.rb create mode 100644 lib/sisu/v5/dp.rb create mode 100644 lib/sisu/v5/dp_identify_markup.rb create mode 100644 lib/sisu/v5/dp_make.rb create mode 100644 lib/sisu/v5/harvest_author_format.rb create mode 100644 lib/sisu/v5/hub_options.rb delete mode 100644 lib/sisu/v5/options.rb delete mode 100644 lib/sisu/v5/param.rb delete mode 100644 lib/sisu/v5/param_identify_markup.rb delete mode 100644 lib/sisu/v5/param_make.rb delete mode 100644 lib/sisu/v5/particulars.rb delete mode 100644 lib/sisu/v5/response.rb delete mode 100644 lib/sisu/v5/screen_text_color.rb create mode 100644 lib/sisu/v5/se.rb create mode 100644 lib/sisu/v5/se_hub_particulars.rb delete mode 100644 lib/sisu/v5/spell.rb delete mode 100644 lib/sisu/v5/sysenv.rb create mode 100644 lib/sisu/v5/utils_response.rb create mode 100644 lib/sisu/v5/utils_screen_text_color.rb create mode 100644 lib/sisu/v5/utils_spell.rb delete mode 100644 lib/sisu/v6/author_format.rb create mode 100644 lib/sisu/v6/dp.rb create mode 100644 lib/sisu/v6/dp_identify_markup.rb create mode 100644 lib/sisu/v6/dp_make.rb create mode 100644 lib/sisu/v6/harvest_author_format.rb create mode 100644 lib/sisu/v6/hub_options.rb delete mode 100644 lib/sisu/v6/options.rb delete mode 100644 lib/sisu/v6/param.rb delete mode 100644 lib/sisu/v6/param_identify_markup.rb delete mode 100644 lib/sisu/v6/param_make.rb delete mode 100644 lib/sisu/v6/particulars.rb delete mode 100644 lib/sisu/v6/response.rb delete mode 100644 lib/sisu/v6/screen_text_color.rb create mode 100644 lib/sisu/v6/se.rb create mode 100644 lib/sisu/v6/se_hub_particulars.rb delete mode 100644 lib/sisu/v6/spell.rb delete mode 100644 lib/sisu/v6/sysenv.rb create mode 100644 lib/sisu/v6/utils_response.rb create mode 100644 lib/sisu/v6/utils_screen_text_color.rb create mode 100644 lib/sisu/v6/utils_spell.rb (limited to 'lib') diff --git a/lib/sisu/v5/air.rb b/lib/sisu/v5/air.rb index 12ec9ed6..aaa4340f 100644 --- a/lib/sisu/v5/air.rb +++ b/lib/sisu/v5/air.rb @@ -61,7 +61,7 @@ =end module SiSU_Air - require_relative 'particulars' # particulars.rb + require_relative 'se_hub_particulars' # se_hub_particulars.rb class Source @@ao_array=[] @@fns=nil diff --git a/lib/sisu/v5/ao.rb b/lib/sisu/v5/ao.rb index ee99805d..d7b418f5 100644 --- a/lib/sisu/v5/ao.rb +++ b/lib/sisu/v5/ao.rb @@ -64,9 +64,9 @@ module SiSU_AO require_relative 'defaults' # defaults.rb include SiSU_Viz - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env - require_relative 'param' # param.rb + require_relative 'dp' # dp.rb include SiSU_Param require_relative 'ao_doc_objects' # ao.rb require_relative 'ao_syntax' # ao_syntax.rb diff --git a/lib/sisu/v5/ao_composite.rb b/lib/sisu/v5/ao_composite.rb index 0d5905bc..af194db7 100644 --- a/lib/sisu/v5/ao_composite.rb +++ b/lib/sisu/v5/ao_composite.rb @@ -62,7 +62,7 @@ =end module SiSU_Assemble - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb class RemoteImage def initialize @env=SiSU_Env::InfoEnv.new diff --git a/lib/sisu/v5/author_format.rb b/lib/sisu/v5/author_format.rb deleted file mode 100644 index 3bda7904..00000000 --- a/lib/sisu/v5/author_format.rb +++ /dev/null @@ -1,117 +0,0 @@ -# encoding: utf-8 -=begin - - * Name: SiSU - - * Description: a framework for document structuring, publishing and search - - * Author: Ralph Amissah - - * Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, - All Rights Reserved. - - * License: GPL 3 or later: - - SiSU, a framework for document structuring, publishing and search - - Copyright (C) Ralph Amissah - - This program is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the Free - Software Foundation, either version 3 of the License, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - more details. - - You should have received a copy of the GNU General Public License along with - this program. If not, see . - - 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: - - - * Git - - - - * Ralph Amissah - - - - ** Description: system environment, resource control and configuration details - -=end -module SiSU_FormatAuthor - 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=a.strip - if a =~/"(.+?)"/ - @authors << { the: $1 } - @author_array << $1.upcase - else #if a =~/,/ - x=a.scan(/[^,]+/) - x[0]=x[0].strip - x[1]=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/v5/cgi.rb b/lib/sisu/v5/cgi.rb index cd0175b5..efea863c 100644 --- a/lib/sisu/v5/cgi.rb +++ b/lib/sisu/v5/cgi.rb @@ -62,7 +62,7 @@ =end module SiSU_CGI #% database building documents - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb require_relative 'cgi_pgsql' # cgi_pgsql.rb require_relative 'cgi_sqlite' # cgi_sqlite.rb class SearchSQL diff --git a/lib/sisu/v5/cgi_pgsql.rb b/lib/sisu/v5/cgi_pgsql.rb index a65b8a97..633e20fc 100644 --- a/lib/sisu/v5/cgi_pgsql.rb +++ b/lib/sisu/v5/cgi_pgsql.rb @@ -61,7 +61,7 @@ =end module SiSU_CGI_PgSQL #% database building documents - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb require_relative 'cgi_sql_common' # cgi_sql_common.rb include SiSU_CGI_SQL class SearchPgSQL < CGI_Common diff --git a/lib/sisu/v5/cgi_sqlite.rb b/lib/sisu/v5/cgi_sqlite.rb index fc665074..531071c4 100644 --- a/lib/sisu/v5/cgi_sqlite.rb +++ b/lib/sisu/v5/cgi_sqlite.rb @@ -61,7 +61,7 @@ =end module SiSU_CGI_SQLite #% database building documents - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb require_relative 'cgi_sql_common' # cgi_sql_common.rb include SiSU_CGI_SQL class SearchSQLite < CGI_Common diff --git a/lib/sisu/v5/conf.rb b/lib/sisu/v5/conf.rb index 04ac5cfa..820d0941 100644 --- a/lib/sisu/v5/conf.rb +++ b/lib/sisu/v5/conf.rb @@ -61,7 +61,7 @@ =end module SiSU_Initialize - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env include SiSU_Screen require_relative 'relaxng' # relaxng.rb @@ -82,7 +82,7 @@ module SiSU_Initialize end end class ConfigSite #config files such as css are not updated if they already exist unless forced using the --init=site modifier - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb def initialize(opt) @opt=opt @env=SiSU_Env::InfoEnv.new(@opt.fns) diff --git a/lib/sisu/v5/css.rb b/lib/sisu/v5/css.rb index d9b2aa8c..b99359aa 100644 --- a/lib/sisu/v5/css.rb +++ b/lib/sisu/v5/css.rb @@ -61,7 +61,7 @@ =end module SiSU_Style - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb require_relative 'defaults' # defaults.rb class CSS_HeadInfo def initialize(md,ft='html') diff --git a/lib/sisu/v5/db_columns.rb b/lib/sisu/v5/db_columns.rb index 04be289d..189e8acb 100644 --- a/lib/sisu/v5/db_columns.rb +++ b/lib/sisu/v5/db_columns.rb @@ -62,7 +62,7 @@ =end module SiSU_DbColumns - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb require_relative 'db_sqltxt' # db_sqltxt.rb class Columns < SiSU_DbText::Prepare def initialize(md=nil) diff --git a/lib/sisu/v5/db_create.rb b/lib/sisu/v5/db_create.rb index 142318f5..35b15ada 100644 --- a/lib/sisu/v5/db_create.rb +++ b/lib/sisu/v5/db_create.rb @@ -64,7 +64,7 @@ module SiSU_DbCreate require_relative 'db_columns' # db_columns.rb class Create < SiSU_DbColumns::Columns - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb @@dl=nil def initialize(opt,conn,file,sql_type=:pg) @opt,@conn,@file,@sql_type=opt,conn,file,sql_type diff --git a/lib/sisu/v5/db_drop.rb b/lib/sisu/v5/db_drop.rb index ba7b57cd..2106fe8f 100644 --- a/lib/sisu/v5/db_drop.rb +++ b/lib/sisu/v5/db_drop.rb @@ -63,7 +63,7 @@ =end module SiSU_DbDrop class Drop - require_relative 'response' # response.rb + require_relative 'utils_response' # utils_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 diff --git a/lib/sisu/v5/db_load_tuple.rb b/lib/sisu/v5/db_load_tuple.rb index 750a47f0..98310bfd 100644 --- a/lib/sisu/v5/db_load_tuple.rb +++ b/lib/sisu/v5/db_load_tuple.rb @@ -64,7 +64,7 @@ module SiSU_DbTuple require_relative 'db_columns' # db_columns.rb class LoadDocuments - require_relative 'param' # param.rb + require_relative 'dp' # dp.rb include SiSU_Param def initialize(conn,col,opt,file_maint) @conn,@col,@opt,@file_maint=conn,col,opt,file_maint diff --git a/lib/sisu/v5/dbi.rb b/lib/sisu/v5/dbi.rb index 83021b20..75b07372 100644 --- a/lib/sisu/v5/dbi.rb +++ b/lib/sisu/v5/dbi.rb @@ -61,9 +61,9 @@ =end module SiSU_DBI #% database building - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env; include SiSU_Screen - require_relative 'param' # param.rb + require_relative 'dp' # dp.rb include SiSU_Param require_relative 'db_dbi' # db_dbi.rb include SiSU_DbDBI diff --git a/lib/sisu/v5/dbi_discrete.rb b/lib/sisu/v5/dbi_discrete.rb index 9c4726c9..73976756 100644 --- a/lib/sisu/v5/dbi_discrete.rb +++ b/lib/sisu/v5/dbi_discrete.rb @@ -61,9 +61,9 @@ =end module SiSU_DBI_Discrete #% database building - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env; include SiSU_Screen - require_relative 'param' # param.rb + require_relative 'dp' # dp.rb include SiSU_Param require_relative 'db_dbi' # db_dbi.rb include SiSU_DbDBI diff --git a/lib/sisu/v5/defaults.rb b/lib/sisu/v5/defaults.rb index 25dd270a..c2f0f19c 100644 --- a/lib/sisu/v5/defaults.rb +++ b/lib/sisu/v5/defaults.rb @@ -67,7 +67,7 @@ module SiSU_Viz rescue LoadError SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('uri NOT FOUND (LoadError)') end - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env require_relative 'css' # css.rb include SiSU_Style diff --git a/lib/sisu/v5/digests.rb b/lib/sisu/v5/digests.rb index 662fa23d..83f26714 100644 --- a/lib/sisu/v5/digests.rb +++ b/lib/sisu/v5/digests.rb @@ -61,7 +61,7 @@ =end module SiSU_DigestView - require_relative 'particulars' # particulars.rb + require_relative 'se_hub_particulars' # se_hub_particulars.rb require_relative 'prog_text_translation' # prog_text_translation.rb require_relative 'shared_markup_alt.rb' # shared_markup_alt.rb class Source diff --git a/lib/sisu/v5/dp.rb b/lib/sisu/v5/dp.rb new file mode 100644 index 00000000..eb9de5e6 --- /dev/null +++ b/lib/sisu/v5/dp.rb @@ -0,0 +1,1550 @@ +# encoding: utf-8 +=begin + + * Name: SiSU + + * Description: a framework for document structuring, publishing and search + + * Author: Ralph Amissah + + * Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. + + * License: GPL 3 or later: + + SiSU, a framework for document structuring, publishing and search + + Copyright (C) Ralph Amissah + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along with + this program. If not, see . + + 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: + + + * Git + + + + * Ralph Amissah + + + + ** Description: document parameters extracted from input files for program use + +=end +module SiSU_Param + begin + require 'uri' + require 'pstore' + rescue LoadError + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). + error('uri or pstore NOT FOUND (LoadError)') + end + require_relative 'se' # se.rb + include SiSU_Env + require_relative 'dp_make' # dp_make.rb + require_relative 'dp_identify_markup' # dp_identify_markup.rb + @@date=SiSU_Env::InfoDate.new + @@proc= + @@filename_txt= + @@filename_texinfo= + @@filename_lout_portrait= + @@filename_lout_landscape= + @@filename_html_scroll= + @@filename_html_index= + @@filename_html_segtoc= + @@filename_semantic= + @@filename_rss= + @@newfile= + @@drr= + nil + @doc={ + initialise: nil, + markup: '', + lnks: '', + stmp: '', + req: {}, + } + @@yaml=@@yamladdr=nil + @@trigger=nil + @@lv,@@flag={},{} + @@tex_backslash="\\\\" + class Parameters + @@publisher='SiSU scribe' + @@md=@@fns=@@pth=nil + def initialize(opt) + @opt=opt + @cX||=SiSU_Screen::Ansi.new(@opt.act[:color_state][:set]) + @cmd,@mod=opt.cmd,opt.mod + @fns=if @opt.cmd =~/P/ #revisit CHECK + opt.fns + else opt.fns.gsub(/\.ssm$/,'.ssm.sst') + end + SiSU_Param::Instantiate.new.param_instantiate + @env=SiSU_Env::InfoEnv.new(@fns) + @pstorefile="#{@env.processing_path.ao}/#{@fns}.pstore" + end + def get + if @opt.f_pth \ + and @opt.f_pth[:pth] != Dir.pwd #BUG check + # you may need to change Dir.pwd to @opt.f_pth[:pth] where the latter + # has a path value that is different, however, f_pth is not always set! + Dir.chdir(@opt.f_pth[:pth]) + end + if @@fns !=@fns \ + or @@pth !=Dir.pwd #@opt.f_pth[:pth] + @@fns,@@pth=@fns,Dir.pwd #@opt.f_pth[:pth] + @@md=nil + end + if @@md.nil? \ + or @opt.act[:maintenance][:set]==:on #not particularly helpful, as current cycle is through output types, with files changing, only helpful if deal with a file all output types before going to next file + if File.exist?(@pstorefile) + param_msg='Parameters from pstore' + store=PStore.new(@pstorefile) + store.transaction do + @md=store['md'] + end + @md + else + param_msg='Parameters extracted' + fns_array=@env.read_source_file(@opt.fns) + @md=SiSU_Param::Parameters::Instructions.new(fns_array,@opt).extract + @md + end + if defined? @md.title.main # on removal check problems with -U + if (@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) + SiSU_Screen::Ansi.new( + @opt.act[:color_state][:set], + param_msg, + @md.title.main + ).txt_grey + end + end + @@md=@md + else @@md + end + @@md.opt=@opt + @@md + end + class MdDefault + def rights(author,date) + @author,@date=author,date + def all + s=nil + if @author + s ||=((@date =~/((?:1[4-9]|2[01])\d{2})/ ) \ + ? ("Copyright (C) #{$1} #{@author}") + : ('Copyright (C)' + @author)) #matches years 1400 through 21\d\d + end + s + end + def text + all + end + def copyright + def all + s=nil + if @author + s ||=((@date =~/((?:1[4-9]|2[01])\d{2})/ ) \ + ? ("Copyright (C) #{$1} #{@author}") + : ('Copyright (C)' + @author)) #matches years 1400 through 21\d\d + end + s + end + def text + all + end + self + end + self + end + end + class MdMake < SiSU_Param_Make::MdMake + end + class Md + def initialize(str,opt,env) + @s,@opt,@env=str,opt,env + end + def validate_length(s,l,n) + #s=(s.length <= l) ? s : nil + s=if s.is_a?(String) \ + and s.length <= l + s + elsif s.is_a?(NilClass) + nil + elsif s.class !=String + STDERR.puts "#{n} is #{s.class}: programming error, String expected #{__FILE__}:#{__LINE__}" + s + else + SiSU_Screen::Ansi.new( + 'v', + "*WARN* #{n} length #{s.length} exceeds set db field length #{l}, metadata dropped", + @opt.fns + ).warn unless @opt.act[:quiet][:set]==:on + nil + end + end + def name_format(name) + if name + name=name.strip + @name_a_h=[] + authors=name.scan(/[^;]+/) + authors.each_with_index do |a,i| + b=((a =~/\s*\|\s*/) ? (a.split(/\|/)) : [a]) + if b[0] =~/"(.+?)"/ + @name_a_h << { the: $1 } + else + x=b[0].scan(/[^,]+/) + if x.length==1 + @name_a_h << { the: x[0].strip } + elsif x.length==2 + @name_a_h << { the: x[0].strip, others: x[1].strip } + else #p x.length + end + end + b.delete_at(0) + b.each do |d| + k,c=nil + k,c=/^(\S+)\s+(.*)/.match(d)[1,2] if d + @name_a_h[i][:hon]=c.strip if k=='hon' + @name_a_h[i][:affiliation]=c.strip if k=='affiliation' + @name_a_h[i][:nationality]=c.strip if k=='nationality' + end + end + l=@name_a_h.length + name_str='' + @name_a_h.each_with_index do |a,i| + name_str += if a[:others] + z=(((l - i) > 1) ? ', ' : '') + "#{a[:others].strip} #{a[:the].strip}" + z + else + z=(((l - i) > 2) ? ', ' : '') + "#{a[:the].strip}" + z + end + end + { name_a_h: @name_a_h, name_str: name_str } + else nil + end + end + def build_hash(arr) + @h={} + arr.each_with_index do |x,i| + a,b=nil,nil + if x =~/^%\s/ #ignore comment + elsif x =~/:(\S+?):\s+(.+)/ + a,b=/:(\S+?):\s+(.+)\Z/m.match(x)[1,2] + b=b.gsub(/\s*\s*/,' \\\\\\ ') + b=if b =~/\n/m + (b =~/;\n/m) \ + ? (b.split(/;\s*\n\s*/).join(';')) + : (b.split(/\s*\n\s*/).join(' ')) + else + b + end + elsif i == 0 + a='main' + b=x + else + end + @h[a]=b + end + @h + end + def title + a=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m) + @h=build_hash(a) + def main + s=@h['main'] + l,n=Db[:col_title_part],'title.main' + validate_length(s,l,n) + end + def sub + s=@h['subtitle'] + l,n=Db[:col_title_part],'title.subtitle' + validate_length(s,l,n) + end + def edition + s=@h['edition'] + l,n=Db[:col_title_edition],'title.edition' + validate_length(s,l,n) + end + def note + s=@h['note'] + l,n=Db[:col_info_note],'title.note' + validate_length(s,l,n) + end + def short + s=@h['short'] \ + ? @h['short'] + : @h['main'] + l,n=Db[:col_title_part],'title.short' + validate_length(s,l,n) + end + def full + s=@h['subtitle'] \ + ? (@h['main'] + ' - ' + @h['subtitle']) + : @h['main'] + l,n=Db[:col_title],'title.full' + validate_length(s,l,n) + end + def language + s=@h['language'] + l,n=Db[:col_language],'title.language' + validate_length(s,l,n) + end + def language_char # look into, this must be set, from 1 directory stub (.fi), 2 filename (~fi), [3 (not used) document header (@title:\n :language_char: fi)] + s=@h['language_char'] + l,n=Db[:col_language_char],'title.language_char' + validate_length(s,l,n) + end + self + end + def creator #there are sub categories that need to be catered for and sometimes more than one author etc.; implement array.to_s.length validation test later, current test on string approximate as string is not used + a=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m) + @h=build_hash(a) + def author + @h['author']=(@h['author'] \ + ? @h['author'] + : @h['main']) + names=name_format(@h['author']) + s=names[:name_str] + l,n=Db[:col_name],'creator.author' + validate_length(s,l,n) + end + def author_detail + s=@h['author'] \ + ? @h['author'] + : @h['main'] + names=name_format(s) + names[:name_a_h] + end + def editor + names=@h['editor'] \ + ? name_format(@h['editor']) + : nil + s=(names.is_a?(Hash)) \ + ? names[:name_str] + : nil + s=if s + l,n=Db[:col_name],'creator.editor' + validate_length(s,l,n) + else nil + end + end + def editor_detail + names=@h['editor'] \ + ? name_format(@h['editor']) + : nil + (names.is_a?(Hash)) \ + ? names[:name_a_h] + : nil + end + def contributor + names=@h['contributor'] \ + ? name_format(@h['contributor']) + : nil + s=(names.is_a?(Hash)) \ + ? names[:name_str] + : nil + s=if s + l,n=Db[:col_name],'creator.author' + validate_length(s,l,n) + else nil + end + end + def contributor_detail + names=@h['contributor'] \ + ? name_format(@h['contributor']) + : nil + (names.is_a?(Hash)) \ + ? names[:name_a_h] + : nil + end + def illustrator + names=@h['illustrator'] \ + ? name_format(@h['illustrator']) + : nil + s=(names.is_a?(Hash)) \ + ? names[:name_str] + : nil + s=if s + l,n=Db[:col_name],'creator.illustrator' + validate_length(s,l,n) + else nil + end + end + def illustrator_detail + names=@h['illustrator'] \ + ? name_format(@h['illustrator']) + : nil + (names.is_a?(Hash)) \ + ? names[:name_a_h] + : nil + end + def photographer + names=@h['photographer'] \ + ? name_format(@h['photographer']) + : nil + s=(names.is_a?(Hash)) \ + ? names[:name_str] + : nil + s=if s + l,n=Db[:col_name],'creator.photographer' + validate_length(s,l,n) + else nil + end + end + def photographer_detail + names=@h['photographer'] \ + ? name_format(@h['photographer']) + : nil + (names.is_a?(Hash)) \ + ? names[:name_a_h] + : nil + end + def translator + names=@h['translator'] \ + ? name_format(@h['translator']) + : nil + s=(names.is_a?(Hash)) \ + ? names[:name_str] + : nil + s=if s + l,n=Db[:col_name],'creator.translator' + validate_length(s,l,n) + else nil + end + end + def translator_detail + names=@h['translator'] \ + ? name_format(@h['translator']) + : nil + (names.is_a?(Hash)) \ + ? names[:name_a_h] + : nil + end + def audio + names=@h['audio'] \ + ? name_format(@h['audio']) + : nil + s=(names.is_a?(Hash)) \ + ? names[:name_str] + : nil + s=if s + l,n=Db[:col_name],'creator.audio' + validate_length(s,l,n) + else nil + end + end + def audio_detail + names=@h['audio'] \ + ? name_format(@h['audio']) + : nil + (names.is_a?(Hash)) \ + ? names[:name_a_h] + : nil + end + def digitized_by + names=@h['digitized_by'] \ + ? name_format(@h['digitized_by']) + : nil + s=(names.is_a?(Hash)) \ + ? names[:name_str] + : nil + s=if s + l,n=Db[:col_name],'creator.digitized_by' + validate_length(s,l,n) + else nil + end + end + def digitized_by_detail + names=@h['digitized_by'] \ + ? name_format(@h['digitized_by']) + : nil + (names.is_a?(Hash)) \ + ? names[:name_a_h] + : nil + end + def prepared_by + names=@h['prepared_by'] \ + ? name_format(@h['prepared_by']) + : nil + s=(names.is_a?(Hash)) \ + ? names[:name_str] + : nil + s=if s + l,n=Db[:col_name],'creator.prepared_by' + validate_length(s,l,n) + else nil + end + end + def prepared_by_detail + names=@h['prepared_by'] \ + ? name_format(@h['prepared_by']) + : nil + names=name_format(@h['prepared_by']) + (names.is_a?(Hash)) \ + ? names[:name_a_h] + : nil + end + self + end + def rights + a=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m) + @h=build_hash(a) + def copyright + def text #you may wish to expand to take from all + s=if @h['copyright'] then @h['copyright'] + elsif @h['text'] then @h['text'] + elsif @h['main'] then @h['main'] + else + SiSU_Screen::Ansi.new( + @opt.act[:color_state][:set], + 'WARNING Document Copyright missing; provide @rights: :copyright:' + ).warn unless @opt.act[:quiet][:set]==:on + '' + end + l,n=Db[:col_info_note],'rights.copyright.text' + validate_length(s,l,n) + end + def translation + s=@h['translation'] \ + ? @h['translation'] + : nil + l,n=Db[:col_info_note],'rights.copyright.translation' + validate_length(s,l,n) + end + def illustrations + s=@h['illustrations'] \ + ? @h['illustrations'] + : nil + l,n=Db[:col_info_note],'rights.copyright.illustrations' + validate_length(s,l,n) + end + def photographs + s=@h['photographs'] \ + ? @h['photographs'] + : nil + l,n=Db[:col_info_note],'rights.copyright.photographs' + validate_length(s,l,n) + end + def digitization + s=@h['digitization'] \ + ? @h['digitization'] + : nil + l,n=Db[:col_info_note],'rights.copyright.digitization' + validate_length(s,l,n) + end + def audio + s=@h['audio'] \ + ? @h['audio'] + : nil + l,n=Db[:col_info_note],'rights.copyright.audio' + validate_length(s,l,n) + end + self + end + def license + s=@h['license'] \ + ? @h['license'] + : nil + l,n=Db[:col_info_note],'rights.license' + validate_length(s,l,n) + end + def sep(str) + ' \\\\ ' + end + def all + s=if @h['all'] then @h['all'] + else + s='' + if defined? copyright.text \ + and copyright.text \ + and not copyright.text.empty? + v=sep(copyright.text) + s +='Copyright: ' + copyright.text + v + end + if defined? copyright.translation \ + and copyright.translation \ + and not copyright.translation.empty? + v=sep(copyright.translation) + s +='translation: ' + copyright.translation + v + end + if defined? copyright.illustrations \ + and copyright.illustrations \ + and not copyright.illustrations.empty? + v=sep(copyright.illustrations) + s +='illustrations: ' + copyright.illustrations + v + end + if defined? copyright.photographs \ + and copyright.photographs \ + and not copyright.photographs.empty? + v=sep(copyright.photographs) + s +='photographs: ' + copyright.photographs + v + end + if defined? copyright.digitization \ + and copyright.digitization \ + and not copyright.digitization.empty? + v=sep(copyright.digitization) + s +='digitization: ' + copyright.digitization + v + end + if defined? copyright.audio \ + and copyright.audio \ + and not copyright.audio.empty? + v=sep(copyright.audio) + s +='audio: ' + copyright.audio + v + end + if defined? copyright.license \ + and copyright.license \ + and not copyright.license.empty? + s +='License: ' + copyright.license + end + if s.empty? + SiSU_Screen::Ansi.new( + @opt.act[:color_state][:set], + 'WARNING Document Rights information missing; provide @rights: :copyright:' + ).warn unless @opt.act[:quiet][:set]==:on + else + l,n=Db[:col_info_note],'rights.all' + validate_length(s,l,n) + end + s=s.gsub(/ [\\]+\s+$/,'') + end + s + end + self + end + def identifier + a=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m) + @h=build_hash(a) + def oclc + s=@h['oclc'] + l,n=Db[:col_library],'identifier.oclc' + validate_length(s,l,n) + end + def isbn + s=@h['isbn'] + l,n=Db[:col_small],'identifier.isbn' + validate_length(s,l,n) + end + def pg + s=@h['pg'] + l,n=Db[:col_small],'identifier.pg' + validate_length(s,l,n) + end + self + end + def classify + a=@s.split(/(\n%\s.+?$|[ ]*)(?:\n[ ]*(?=:)|\Z)/m) + @h=build_hash(a) + def topic_register + s=@h['topic_register'] + l,n=Db[:col_info_note],'classify.topic_register' + validate_length(s,l,n) + end + def subject + s=@h['subject'] + l,n=Db[:col_txt_long],'classify.subject' + validate_length(s,l,n) + end + def keywords + s=@h['keywords'] + l,n=Db[:col_txt_long],'classify.keywords' + validate_length(s,l,n) + end + def loc + s=@h['loc'] + l,n=Db[:col_library],'classify.loc' + validate_length(s,l,n) + end + def dewey + s=@h['dewey'] + l,n=Db[:col_library],'classify.dewey' + validate_length(s,l,n) + end + self + end + def publisher + a=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m) + @h=build_hash(a) + s=@h['main'] + l,n=Db[:col_name],'publisher' + validate_length(s,l,n) + end + def date + a=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m) + @h=build_hash(a) + def added_to_site + s=@h['added_to_site'] + l,n=Db[:col_date_text],'date.added_to_site' + validate_length(s,l,n) + end + def available + s=@h['available'] + l,n=Db[:col_date_text],'date.available' + validate_length(s,l,n) + end + def created + s=@h['created'] + l,n=Db[:col_date_text],'date.created' + validate_length(s,l,n) + end + def issued + s=@h['issued'] + l,n=Db[:col_date_text],'date.issued' + validate_length(s,l,n) + end + def modified + s=@h['modified'] + l,n=Db[:col_date_text],'date.modified' + validate_length(s,l,n) + end + def published + s=@h['published']=(@h['published'] ? @h['published'] : @h['main']) + l,n=Db[:col_date_text],'date.published' + validate_length(s,l,n) + end + def valid + s=@h['valid'] + l,n=Db[:col_date_text],'date.valid' + validate_length(s,l,n) + end + self + end + #def language # as things stand this should really be populated from title.language and original.language, resolve + # a=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m) + # @h=build_hash(a) + # def document + # s=@h['document']=(@h['document'] ? @h['document'] : @h['main']) + # l,n=Db[:col_language],'language.document' + # validate_length(s,l,n) + # end + # def document_char + # s=@h['document_char']=(@h['document_char'] ? @h['document_char'] : nil) + # l,n=Db[:col_language_char],'language.document_char' + # validate_length(s,l,n) + # end + # def original + # s=@h['original'] + # l,n=Db[:col_language],'language.original' + # validate_length(s,l,n) + # end + # def original_char + # s=@h['original_char'] + # l,n=Db[:col_language_char],'language.original_char' + # validate_length(s,l,n) + # end + # self + #end + def current_publisher + @s + end + def original + a=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m) + @h=build_hash(a) + def publisher + s=@h['publisher'] + l,n=Db[:col_name],'original.publisher' + validate_length(s,l,n) + end + def language + s=@h['language'] + l,n=Db[:col_language],'original.language' + validate_length(s,l,n) + end + def language_char + s=@h['language_char'] + l,n=Db[:col_language_char],'original.language_char' + validate_length(s,l,n) + end + def source + s=@h['source'] + l,n=Db[:col_name],'original.source' + validate_length(s,l,n) + end + def institution + s=@h['institution'] + l,n=Db[:col_name],'original.institution' + validate_length(s,l,n) + end + def nationality + s=@h['nationality'] + l,n=Db[:col_language],'original.nationality' + validate_length(s,l,n) + end + self + end + def notes + a=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m) + @h=build_hash(a) + def description + s=@h['description'] + l,n=Db[:col_info_note],'notes.description' + validate_length(s,l,n) + end + def abstract + s=@h['abstract'] + l,n=Db[:col_info_note],'notes.abstract' + validate_length(s,l,n) + end + def comment + s=@h['comment'] + l,n=Db[:col_info_note],'notes.comment' + validate_length(s,l,n) + end + def coverage + s=@h['coverage'] + l,n=Db[:col_info_note],'notes.coverage' + validate_length(s,l,n) + end + def relation + s=@h['relation'] + l,n=Db[:col_info_note],'notes.relation' + validate_length(s,l,n) + end + def source + s=@h['source'] + l,n=Db[:col_txt_long],'notes.source' + validate_length(s,l,n) + end + def history + s=@h['history'] + l,n=Db[:col_txt_long],'notes.history' + validate_length(s,l,n) + end + def type + s=@h['type'] + l,n=Db[:col_txt_long],'notes.relation' + validate_length(s,l,n) + end + def format + s=@h['format'] + l,n=Db[:col_txt_short],'notes.format' + validate_length(s,l,n) + end + def prefix + @h['prefix'] + end + self + end + end + class Instructions + @doc={ lv: [] } + @doc[:fns],@doc[:fnb],@doc[:scr_suffix]='','','' + @@publisher='SiSU scribe' + attr_accessor :make,:env,:path,:file,:fn,:fns,:fno,:fnb,:fnn,:fnt,:fnl,:flv,:fnz,:fnstex,:ocn,:sfx_src,:pdf,:file_type,:dir_out,:dir_tex,:dir_lout,:txt_path,:sisu,:sisu_version,:ruby_version,:title,:subtitle,:full_title,:html_title,:subtitle_tex,:creator,:classify,:author_home,:author,:author_title,:author_nationality,:authors,:authorship,:translator,:illustrator,:prepared_by,:digitized_by,:subject,:description,:publisher,:current_publisher,:contributor,:date,:date_created,:date_issued,:date_available,:date_valid,:date_modified,:date_translated,:date_added_to_site,:date_scheme,:date_created_scheme,:date_issued_scheme,:date_available_scheme,:date_valid_scheme,:date_modified_scheme,:type,:format,:identifier,:source,:language,:language_original,:relation,:coverage,:rights,:keywords,:comments,:abstract,:cls_loc,:cls_dewey,:cls_pg,:cls_isbn,:papersize,:papersize_array,:toc,:lv0,:lv1,:lv2,:lv3,:lv4,:lv5,:lv6,:lvs,:pagenew,:pagebreak,:pageline,:num_top,:bold_match_list,:italics_match_list,:substitution_match_list,:emphasis_set_to,:toc_lev_limit,:flag_endnotes,:flag_auto_endnotes,:flag_separate_endnotes,:flag_separate_endnotes_make,:markup,:markup_instruction,:flag_tables,:vocabulary,:doc_css,:yaml,:lnk,:links,:prefix_a,:prefix_b,:suffix,:information,:contact,:icon,:image,:ad_url,:ad_png,:ad_alt,:ad_began,:flag_promo,:promo,:ad_home,:stmp,:stmpd,:sc_filename,:sc_number,:sc_date,:sc_time,:sc_info,:yamladdr,:locale,:wc_lines,:wc_words,:wc_bytes,:file_encoding,:filesize,:user,:home,:hostname,:pwd,:firstseg,:programs,:author_copymark,:i18n,:lang,:lang_code_insert,:en,:notes,:dgst,:generated,:tags,:tag_array,:concord_make,:seg_names,:seg_autoname_safe,:set_header_title,:set_heading_top,:set_heading_seg,:heading_seg_first,:heading_seg_first_flag,:base_program,:ec,:opt,:sem_tag,:book_idx,:topic_register,:topic_register_array,:original,:writing_focus,:audio,:daisy,:home_button_image,:home_button_links,:footer_links,:cover_image,:man_section + def initialize(fns_array,opt) + @env=@path,@file=@fn=@fns=@fno=@fnb=@fnn=@fnt=@fnl=@flv=@fnz=@fnstex=@ocn=@sfx_src=@pdf=@file_type=@dir_out=@dir_tex=@dir_lout=@txt_path=@make=@flag_endnotes=@flag_auto_endnotes=@flag_separate_endnotes=@flag_separate_endnotes_make=@sisu=@sisu_version=@ruby_version=@title=@subtitle=@full_title=@html_title=@subtitle_tex=@creator=@classify=@author_home=@author=@author_title=@author_nationality=@translator=@illustrator=@prepared_by=@digitized_by=@subject=@description=@publisher=@current_publisher=@contributor=@date=@date_created=@date_issued=@date_available=@date_valid=@date_modified=@date_translated=@date_added_to_site=@date_scheme=@date_created_scheme=@date_issued_scheme=@date_available_scheme=@date_valid_scheme=@date_modified_scheme=@type=@format=@identifier=@source=@language=@language_original=@relation=@coverage=@rights=@keywords=@comments=@abstract=@cls_loc=@cls_dewey=@cls_pg=@cls_isbn=@papersize=@toc=@lv0=@lv1=@lv2=@lv3=@lv4=@lv5=@lv6=@pagenew=@pagebreak=@pageline=@num_top=@bold_match_list=@italics_match_list=@substitution_match_list=@emphasis_set_to=@toc_lev_limit=@flag_tables=@vocabulary=@doc_css=@yaml=@lnk=@links=@prefix_a=@prefix_b=@suffix=@information=@contact=@icon=@ad_url=@ad_png=@ad_alt=@ad_began=@promo=@ad_home=@stmp=@stmpd=@sc_filename=@sc_number=@sc_date=@sc_time=@sc_info=@yamladdr=@locale=@wc_lines=@wc_words=@wc_bytes=@file_encoding=@filesize=@firstseg=@programs=@author_copymark=@i18n=@lang=@lang_code_insert=@en=@notes=@dgst=@generated=@heading_seg_first=@base_program=@topic_register=@original=@writing_focus=@audio=@home_button_image=@home_button_links=@cover_image=@man_section=nil + @data, @path, @fns, @fno, @opt= + fns_array,opt.pth,opt.fns,opt.fno,opt #@data used as data + @flag_tables,@set_header_title,@set_heading_top,@set_heading_seg,@heading_seg_first_flag,@flag_promo,@book_idx= + false, false, false, false, false, false, false + @seg_autoname_safe=true + @daisy,@sem_tag=false,false + @authorship,@markup_instruction,@image='','','','' #check which other values should be set to empty rather than nil + @markup=@markup_instruction #use @markup_instruction + @doc,@fn,@make_italic,@tag_hash,@ec={},{},{},{},{},{} + @flv,@lang,@seg_names,@tags,@tag_array,@tag_a,@ec[:image],@ec[:audio],@ec[:multimedia]=Array.new(9){[]} + @authors,@topic_register_array,@papersize_array=[],[],[] + @lvs=[nil,0,0,0,0,0,0] + @emphasis_set_to='bold' + @lang_code_insert=SiSU_Env::FilenameLanguageCodeInsert.new(@opt).language_code_insert + @footer_links= { left: { say: '', url: '' }, center: { say: '', url: '' } } + @rgx_image=/(?:^|[^_\\])\{(?:\s*|\~\^\s+)(\S+?\.(?:png|jpg|gif)\b)/m + @rgx_audio=/\{\s*(\S+?\.(?:mp3|ogg))/ + @rgx_mm=/\{\s*(\S+?\.(?:ogg|mpeg))/ #expand and distinguish ogg + Dir.chdir(@opt.f_pth[:pth]) + begin + rescue + SiSU_Errors::Rescued.new($!,$@,@opt.cmd,@fns).location do + __LINE__.to_s + ':' + __FILE__ + end + ensure + end + @header_make_links_append=:no + common_makes=(defined? @opt.make_instructions_pod) \ + && @opt.make_instructions_pod !=nil \ + && @opt.make_instructions_pod[:makeset]==true \ + ? @opt.make_instructions_pod + : @opt.make_instructions + if common_makes[:makeset] + @pagenew=common_makes[:pagenew] + @pagebreak=common_makes[:pagebreak] + @pageline=common_makes[:pageline] + @toc=common_makes[:toc] + @lv0=common_makes[:lv0] + @lv1=common_makes[:lv1] + @lv2=common_makes[:lv2] + @lv3=common_makes[:lv3] + @lv4=common_makes[:lv4] + @lv5=common_makes[:lv5] + @lv6=common_makes[:lv6] + @num_top=common_makes[:num_top] + @i18n=common_makes[:i18n] + @man_section=common_makes[:man_section] + @emphasis_set_to=common_makes[:emphasis_set_to] + @bold_match_list=common_makes[:bold_match_list] + @italics_match_list=common_makes[:italics_match_list] + @substitution_match_list=common_makes[:substitution_match_list] + @footer_links=common_makes[:footer_links] + @home_button_links=common_makes[:home_button_links] + @home_button_image=common_makes[:home_button_image] + @cover_image=common_makes[:cover_image] + @lnk=@links=common_makes[:links] + @header_make_links_append=common_makes[:links_append] + end + end + #protected + def extract + @user,@home,@hostname,@pwd=ENV['USER'],ENV['HOME'],ENV['HOSTNAME'],ENV['PWD'] + @programs,@wc,@language,@language_original={},{},{},{} + @en={ sum: 0, mark: 0, note: 0, mismatch: 0 } + @prog=SiSU_Env::InfoSettings.new + @sys=SiSU_Env::SystemCall.new + @env=SiSU_Env::InfoEnv.new(@fns) #watch + if (@opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) + puts 'system locale: ' + @sys.locale + end + if @prog.wc \ + and @sys.wc + wc=%x{wc #{fns}} + wca=wc.scan(/\d+/) + @wc_lines,@wc_words,@wc_bytes=wca[0].to_i,wca[1].to_i,wca[2].to_i + else + fns_a=@data.dup + tmp=fns_a.join + fns_a=tmp.scan(/\S+/) + @wc_words=fns_a.length + fns_a=tmp=nil + end + @concord_make=(@wc_words > @env.concord_max) ? false : true + @locale=@sys.locale + @file_encoding=@sys.file_encoding(fns,@opt.cmd) + # programs set here for things that affect output appearance only + @programs[:pdf]=SiSU_Env::SystemCall.new.program_found?('pdflatex') + if @opt.cmd =~/P/ #if @env.multilingual? + m=/((.+?)(?:\~\w\w(?:_\w\w)?)?)\.((?:-|ssm\.)?sst|ssm|ssi)$/ #watch added match for sss + @fnn,@fnb,@fnt=@fns[m,1],@fns[m,2],@fns[m,3] + @flv=@env.document_language_versions_found[:f] + else + m=/((.+?)(?:\~\w\w(?:_\w\w)?)?)\.((?:-|ssm\.)?sst|ssm)$/ #watch added match for sss + @fnn,@fnb,@fnt=@fns[m,1],@fns[m,2],@fns[m,3] + @flv=@env.document_language_versions_found[:f] + @fnz=(@fns =~/\.(?:ssm\.sst|ssm)$/) ? (@fnn + '.ssm.txz') : (@fnn + '.sst.txz') + end + @papersize=@env.papersize #'A4' #default size #get first from SiSU_Env:: # @env is probably no longer most appropriate name! as default info is more general + @sfx_src=@fns[m,2] + if @fns =~ /(?:-|ssm\.)?sst$/ \ + and not @opt.cmd =~/P/ #watch + @env_out_root=@env.path.output + @dir_out="#{@env.path.output}/#{@fnb}" + @dir_tex=@env.processing_path.tex + @dir_lout=@env.processing_path.lout + @@publisher='SiSU http://www.jus.uio.no/sisu' + end + @txt_path=@txt_path ||= @env.path.output + @stmp=%{#{@fns}}[/^(.+?)\..*/m,1] + @fnstex=@fns.gsub(/_/,'\_\-').gsub(/\./,'.\-') + @flag_endnotes,@flag_auto_endnotes,@flag_separate_endnotes=false,false,false + @flag_separate_endnotes_make=true + ver=SiSU_Env::InfoVersion.instance + @sisu_version=ver.get_version + @ruby_version=ver.rbversion + @generated=Time.now + fns_array=@data.dup + skip unless fns_array # consider + @code_flag=false + fns_array.each do |para| #% scan document + if para !~/^%+\s/ \ + and para =~/|

|
|
)\s*/,' '). + gsub(/~\{.+?\}~/,'') + SiSU_Screen::Ansi.new( + @opt.act[:color_state][:set], + 'Document Parameters', + %{#{title}#{creator}} + ).txt_grey if @opt.act[:verbose][:set]==:on + end + if not @book_idx \ + and para =~/^=\{(.+?)\}[\s`]*\Z/m + @book_idx=true + end + unless @code_flag + case para + when /~\{\s+.+?\}~/m #% processing + en=para.scan(/~\{.+?\}~/m) + en.each { |e| @en[:sum] +=1 } + when /~\^(?:\s|$)/m #% processing + mk=para.scan(/~\^(?:\s|$)/) + mk.each { |e| @en[:mark] +=1 } + when /^\^~\s+\S/ then @en[:note] +=1 #% processing + end + end + if para =~/~\{|\^~ |~\^|\{.+?\[[1-6]\]\}\S+?\.ss[tm]/m + @flag_auto_endnotes,@flag_endnotes=true,true + end + if para =~/^(?:table\{|\{table)/i + @flag_tables=true + end + end + if para =~/^:?A~/ + @set_heading_top=true + end + if para =~/^1~/ + m=nil + if para =~/^1~(\S+)\s+(.+)$/ + m,t=$1,$2 + elsif para =~/^1~\s+(.+)$/ + t=$1 + end + unless @heading_seg_first_flag # extract first segment name + @heading_seg_first=t + @heading_seg_first_flag=true + end + if m # list all segment names + @seg_names << m + @set_heading_seg=true + if m=~/^\d{1,3}/ \ + and m !~/^0/ + @seg_autoname_safe=false + end + end + end + para=para.gsub(/<:=(\S+?)>/,'{ c_\1.png 14x14 }image') # embedded symbol (image) + if para !~/^%+\s/ \ + and para =~@rgx_image + @ec[:image] << para.scan(@rgx_image).uniq + end + @ec[:audio] << para.scan(@rgx_audio).uniq if para =~@rgx_audio #embedded content + @ec[:multimedia] << para.scan(@rgx_mm).uniq if para =~@rgx_mm #embedded content + unless @sem_tag + @sem_tag=true if para=~/[:;]\{.+?\}[:;][a-z+]/ #refix later + end + end #% here endeth the document loop + unless @make + if (@opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) + SiSU_Screen::Ansi.new( + @opt.act[:color_state][:set], + '@make:', + 'header absent' + ).warn + end + @make=SiSU_Param::Parameters::MdMake.new('@make: ',@opt,@env).make + end + if @cover_image \ + and @cover_image.is_a?(Hash) \ + and (@cover_image[:cover] =~@rgx_image \ + or @cover_image[:cover] =~/\S+?.(?:jpg|png|gif)/) + @ec[:image] << @cover_image[:cover] + end + if @home_button_image \ + and @home_button_image.is_a?(Hash) \ + and (@home_button_image =~@rgx_image \ + or @home_button_image =~/\S+?\.(?:jpg|png|gif)/) + @ec[:image] << @home_button_image + end + if @ec[:image].length > 0 + @ec[:image]=@ec[:image].flatten.uniq + @ec[:image].delete_if {|x| x =~/https?:\/\// } + @ec[:image]=@ec[:image].sort + end + @ec[:audio]=@ec[:audio].uniq.flatten.sort + @ec[:multimedia]=@ec[:multimedia].uniq.flatten.sort + unless @rights + if defined? @creator.author \ + and @creator.author.is_a?(String) \ + and defined? @date.published \ + and @date.published.is_a?(String) + @rights=SiSU_Param::Parameters::MdDefault.new.rights(@creator.author,@date.published) + elsif defined? @creator.author \ + and @creator.author.is_a?(String) + @rights=SiSU_Param::Parameters::MdDefault.new.rights("[#{@creator.author}]",'') + end + end + if defined? @classify.topic_register \ + and @classify.topic_register.is_a?(String) \ + and @classify.topic_register.length >3 + topic_register=@classify.topic_register + u=topic_register.scan(/[^;]+/m).sort + v=[] + u.each do |l| + v << l.scan(/[^:]+/m) + end + v.each do |s| + s[-1]=s[-1].scan(/[^|]+/m) if s[-1] =~/[|]/m + @topic_register_array << s + end + @topic_register_array + end + if @i18n + @i18n=@i18n.uniq + @i18n << 'en' unless @i18n.find_index("en") + else + @i18n=[ 'en' ] + end + translated=[] + translate_list=[@pagenew,@pagebreak,@pageline,@num_top,@toc_lev_limit] + translate_list.each do |t| + translate=t.to_s if t + translated << if translate + translate.gsub!(/3/,'6') + translate.gsub!(/2/,'5') + translate.gsub!(/1/,'4') + translate.gsub!(/:?C/,'3') + translate.gsub!(/:?B/,'2') + translate.gsub!(/:?A/,'1') + # looks like an ok substituion for the above but is not, causes problems, check why + #translate=translate.gsub(/3/,'6'). + # gsub(/2/,'5'). + # gsub(/1/,'4'). + # gsub(/:?C/,'3'). + # gsub(/:?B/,'2'). + # gsub(/:?A/,'1') + translate=(translate =~/^\d+$/) \ + ? translate.to_i + : translate + else nil + end + end + @pagenew,@pagebreak,@pageline,@num_top,@toc_lev_limit=translated + @markup=@markup.gsub(/page_new\s*=\s*([\dA-C])/,"page_new=#{@pagenew}"). + gsub(/page_break\s*=\s*([\dA-C])/,"page_break=#{@pagebreak}"). + gsub(/page_line\s*=\s*([\dA-C])/,"page_line=#{@pageline}"). + gsub(/num_top\s*=\s*([\dA-C])/,"num_top=#{@num_top}"). + gsub(/toc_lev_limit\s*=\s*([\dA-C])/,"toc_lev_limit=#{@toc_lev_limit}") + papersize_array_rc=@papersize.downcase.scan(/(?:a4|letter|legal|book|a5|b5)/) + papersize_array_opt=[ + ((@opt.act[:pdf_a4][:set]==:on) ? 'a4' : ''), + ((@opt.act[:pdf_a5][:set]==:on) ? 'a5' : ''), + ((@opt.act[:pdf_b5][:set]==:on) ? 'b5' : ''), + ((@opt.act[:pdf_letter][:set]==:on) ? 'letter' : ''), + ((@opt.act[:pdf_legal][:set]==:on) ? 'legal' : ''), + ] - [""] + @papersize_array=(papersize_array_opt.length > 0) \ + ? papersize_array_opt + : papersize_array_rc + fn=@opt.fno #decide what to do a filesize on .ssm tells very little about actual document size + @filesize=(File.size(fn)).to_s + if @sys.openssl !=false \ + and FileTest.file?(@env.source_file_with_path) + @dgst=[] + case @env.digest(@opt).type + when :sha512 + dgst=@sys.sha512(@env.source_file_with_path) + @dgst=dgst[1].length==128 ? dgst : nil + puts 'check document (sha512) digest' if not @dgst + when :sha256 + dgst=@sys.sha256(@env.source_file_with_path) + @dgst=dgst[1].length==64 ? dgst : nil + puts 'check document (sha256) digest' if not @dgst + when :md5 + dgst=@sys.md5(@env.source_file_with_path) + @dgst=dgst[1].length==32 ? dgst : nil + puts 'check document (md5) digest' if not @dgst + else + dgst=@sys.sha256(@env.source_file_with_path) + @dgst=dgst[1].length==64 ? dgst : nil + puts 'check document (sha256) digest' if not @dgst + end + elsif not FileTest.file?(@env.source_file_with_path) + #puts SiSU_Utils::CodeMarker.new(__LINE__,__FILE__).set(:fuchsia) + end + @publisher ||= "#{@@publisher} (this copy)" + fn_set_lang=SiSU_Env::StandardiseLanguage.new(@opt.lng).language + unless @language[:code] \ + and @language[:name] + lang=@env.i18n.language #default language settings for directory by name, or in sysrc.yml + @language[:code] ||= lang.code + @language[:name] ||= lang.title + end + unless fn_set_lang[:d]==true #decide, naming convention overrides other settings, within document, etc. + @language[:code]=fn_set_lang[:c] + @language[:name]=fn_set_lang[:n] + end + @fnl=@env.i18n.lang_filename(fn_set_lang[:c]) + @lang=@lang.uniq + @fn=SiSU_Env::EnvCall.new(@fns).lang(fn_set_lang[:c]) + if @en[:note] > 0 \ + and @en[:sum] > 0 + if @en[:sum] > 0 + else + SiSU_Screen::Ansi.new( + @opt.act[:color_state][:set], + '*WARN* both endnote styles used', + "~{ #{@en[:sum]} }~ and ^~ #{@en[:mark]}" + ).warn unless @opt.act[:quiet][:set]==:on + end + end + if @en[:mark] != @en[:note] \ + and @en[:note] > 0 + @en[:mismatch]=@en[:note] - @en[:mark] + SiSU_Screen::Ansi.new( + @opt.act[:color_state][:set], + '*WARN* endnote number mismatch', + "endnotes: #{@en[:note]} != endnote reference marks: #{@en[:mark]} (difference = #{@en[:mismatch]})" + ).warn unless @opt.act[:quiet][:set]==:on + footnote_conversion_errors=File.new("#{Dir.pwd}/footnote_conversion_errors.txt",'a') + footnote_conversion_errors << + "#{@fns}:\n\tendnotes: #{@en[:note]} != endnote reference marks: #{@en[:mark]} (difference = #{@en[:mismatch]})\n" + end + if not @title \ + or not defined? @title.main \ + or @title.main !~/[\S]/ + if @fns =~/\.ssm$/ \ + and @opt.inspect =~/P/ + #@title=Md.new('Text Insert',@opt,@env).title + else + SiSU_Screen::Ansi.new( + @opt.act[:color_state][:set], + 'WARNING: Document Title missing', + 'please provide @title:' + ).warn unless @opt.act[:quiet][:set]==:on + end + end + if @author !~/[\S]/ + if @fns =~/\.ssm$/ \ + and @opt.inspect =~/P/ + #@creator=SiSU_Param::Md.new('Text Insert',@opt,@env).creator + else + SiSU_Screen::Ansi.new( + @opt.act[:color_state][:set], + 'WARNING: Document Author missing', + 'please provide @creator: :author:' + ).warn unless @opt.act[:quiet][:set]==:on + end + end + @struct={} + doc_struct=Hash.new(0) + if @lv1.nil? + fns_array.each do |para| + if para =~/^(Part|Chapter|Section|Article)\b/i + case para + when /^(Part|PART)\b/ + @struct[:part]=doc_struct[:part] + doc_struct[:part]=doc_struct[:part] + 1 + when /^(Chapter|CHAPTER)\b/ + @struct[:chapter]=doc_struct[:chapter] + doc_struct[:chapter]=doc_struct[:chapter] + 1 + when /^(Section|SECTION)\b/ + @struct[:section]=doc_struct[:section] + doc_struct[:section]=doc_struct[:section] + 1 + when /^(Article|ARTICLE)\b/ + @struct[:article]=doc_struct[:article] + doc_struct[:article]=doc_struct[:article] + 1 + when /^(Clause|CLAUSE)\b/ + @struct[:clause]=doc_struct[:clause] + doc_struct[:clause]=doc_struct[:clause] + 1 + when /^\d\..*[^\.]$/ + @struct[:number]=doc_struct[:number] + doc_struct[:number]=doc_struct[:number] + 1 + end + end + end + if doc_struct[:article] > 2 #%~level 4 + @lv4=/^(?:Article|ARTICLE)\b/ + elsif doc_struct[:chapter] > 2 \ + and doc_struct[:article] \ + and doc_struct[:article] < 3 + @lv4=/^(?:Chapter|CHAPTER)\b/ + elsif doc_struct[:clause] > 2 + @lv4=/^(?:Clause|CLAUSE)\b/ + elsif doc_struct[:number] > 2 + @lv4="^\d\..*[^\.]$" + end + if doc_struct[:section] > 2 #%~level 3 + @lv3=/^(?:Section|SECTION)\b/ + end + if doc_struct[:chapter] > 2 \ + and doc_struct[:article] \ + and doc_struct[:article] > 2 + @lv2=/^(?:Chapter|CHAPTER)\b/ + end + if doc_struct[:part] > 2 \ + and @lv[2].nil? + @lv2=/^(?:Part|PART)\b/ + end + if doc_struct[:part] > 2 \ + and @lv[2].inspect !~/Part/ \ + and @lv[1].nil? + @lv1=/^(Part|PART)\b/ + end + end + @lnk=@lnk.compact if @lnk + @lv0 ||=/^0~/ + @lv1 ||=/^1~/ + @lv2 ||=/^2~/ + @lv3 ||=/^3~/ + @lv4 ||=/^4~/ + @lv5 ||=/^5~/ + @lv6 ||=/^6~/ + @data=nil #else whole file's contents are stored in md pstore & is not required to be... big waste actually + @file=SiSU_Env::FileOp.new(self) #watch + Store.new(self,@env).store #% pstore + self + end + private + class Store + def initialize(md,env) + @md,@env=md,env + end + def store + begin + pstorefile="#{@env.processing_path.ao}/#{@md.fns}.pstore" + File.unlink(pstorefile) if FileTest.file?(pstorefile) + if (@md.opt.act[:verbose_plus][:set]==:on \ + || @md.opt.act[:maintenance][:set]==:on) + SiSU_Screen::Ansi.new( + @md.opt.act[:color_state][:set], + "PStore -> #{pstorefile}" + ).txt_grey + end + store=PStore.new(pstorefile) + store.transaction do + store['md']=@md + store.commit + end + @@md=@md=nil + rescue + SiSU_Errors::Rescued.new($!,$@,@md.opt.cmd,@md.fns).location do + __LINE__.to_s + ':' + __FILE__ + end + ensure + end + end + end + end + end + class Instantiate + def param_instantiate + @@date=SiSU_Env::InfoDate.new + @@proc= + @@filename_txt= + @@filename_texinfo= + @@filename_lout_portrait= + @@filename_lout_landscape= + @@filename_html_scroll= + @@filename_html_index= + @@filename_html_segtoc= + @@filename_semantic= + @@filename_rss= + @@newfile= + @@drr= + nil + @doc={ + initialise: nil, + markup: '', + lnks: '', + stmp: '', + prefix_a: '', + prefix_b: '', + req: {} + } + @@yaml=@@yamladdr=nil + @@flag={} + @@publisher='SiSU scribe' + end + end +end +__END__ diff --git a/lib/sisu/v5/dp_identify_markup.rb b/lib/sisu/v5/dp_identify_markup.rb new file mode 100644 index 00000000..f6884c7d --- /dev/null +++ b/lib/sisu/v5/dp_identify_markup.rb @@ -0,0 +1,167 @@ +# encoding: utf-8 +=begin + + * Name: SiSU + + * Description: a framework for document structuring, publishing and search + + * Author: Ralph Amissah + + * Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. + + * License: GPL 3 or later: + + SiSU, a framework for document structuring, publishing and search + + Copyright (C) Ralph Amissah + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along with + this program. If not, see . + + 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: + + + * Git + + + + * Ralph Amissah + + + + ** 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 + +=end +module SiSU_MarkupType + class MarkupIdentify + @@version={} + @@fns,@@version[:determined],@@version[:declared],@@declared_doc_type='','','','[text?]' + attr_accessor :version,:declared_doc_type + def initialize(content,opt) + @cont,@opt=content,opt + end + def identify + @version,@declared_doc_type=@@version,@@declared_doc_type + if @opt.fns != @@fns + if @cont[0] =~ /^(?:%\s+)?SiSU\s+(text|master|insert)\s+([0-9](?:\.[0-9]+){1,2})/ \ + or @cont[0] =~ /^(?:%\s+)?sisu-([0-9](?:\.[0-9]+){1,2})/ + @declared_doc_type,@version[:declared]=$1,$2 + elsif @cont[0] =~ /^(?:%\s+)?SiSU\s+([0-9](?:\.[0-9]+){1,2})/ \ + or @cont[0] =~ /^(?:%\s+)?sisu-([0-9](?:\.[0-9]+){1,2})/ + @version[:declared]=$1 + end + @flag_2_0,@flag_66,@flag_57,@flag_38=false,false,false,false + @cont.each_with_index do |y,i| + if y =~/^@make:|^@classify|^\s\s?:\S+?:\s+\S/ + version=2.0.to_f + @version[:determined]=version + @flag_2_0=true + break + end + unless @flag_38 + if y =~/^:?A~/ + version=0.38.to_f + @version[:determined]=version + @flag_38=true + end + end + if @flag_38 + if @flag_69 \ + or y =~/^=\{.+?\}\s*$/ + version=0.69.to_f + @flag_69=true + @version[:determined]=version + break + end + if @flag_66 \ + or y =~/[:;]\{.+?\}[:;][a-z+]/ + version=0.66.to_f + @flag_66=true + @version[:determined]=version + break + end + end + end + @flag_57,@flag_38=false,false + unless @flag_2_0 \ + or @flag_66 \ + or @flag_69 + @cont.each_with_index do |y,i| + if @flag_57 \ + or y =~/^:?A~\?? @title/ + @version[:determined]=0.57.to_f + @flag_57=true + break + end + if @flag_38 \ + or y =~/^:?A~/ + @version[:determined]=0.38.to_f + @flag_38=true + break if i >= 200 + if y =~ /(?:~{\*+|~\[\*|~\[\+)\s/ + @version[:determined]=0.42 #0.38 can safely be treated as 0.42 + break + end + end + if y =~/^0~/ \ + and not @flag_38 + @version[:determined]=0.16.to_f + break + end + end + end + @@fns=@opt.fns + @@version,@@declared_doc_type=@version,@declared_doc_type + end + self + end + def markup_version? + def determined + identify.version[:determined].to_f + end + def series + s=case identify.version[:determined].to_s + when /^[01]\./ then '1.0' + when /^[2]\./ then '2.0' + else '2.0' + end + "series #{s}" + end + def declared + identify.version[:declared].to_f + end + self + end + end +end +__END__ diff --git a/lib/sisu/v5/dp_make.rb b/lib/sisu/v5/dp_make.rb new file mode 100644 index 00000000..05b5cbdf --- /dev/null +++ b/lib/sisu/v5/dp_make.rb @@ -0,0 +1,674 @@ +# encoding: utf-8 +=begin + + * Name: SiSU + + * Description: a framework for document structuring, publishing and search + + * Author: Ralph Amissah + + * Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. + + * License: GPL 3 or later: + + SiSU, a framework for document structuring, publishing and search + + Copyright (C) Ralph Amissah + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public Lic/home/ralph/live-manual/build/manual/manifest/live-manual.ca.htmlense 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: + + + * Git + + + + * Ralph Amissah + + + + ** Description: document parameters make extracted for program use + +=end + +module SiSU_Param_Make + class MdMake + def initialize(str,opt,env) + @s,@opt,@env=str,opt,env + end + def validate_length(s,l,n) + #s=(s.length <= l) ? s : nil + s=if s.is_a?(String) \ + and s.length <= l + s + elsif s.is_a?(NilClass) + nil + elsif s.class !=String + STDERR.puts "#{n} is #{s.class}: programming error, String expected #{__FILE__}:#{__LINE__}" + s + else + SiSU_Screen::Ansi.new( + 'v', + "*WARN* #{n} length #{s.length} exceeds set db field length #{l}, metadata dropped", + @opt.fns + ).warn unless @opt.act[:quiet][:set]==:on + nil + end + end + def name_format(name) + if name + name=name.strip + @name_a_h=[] + authors=name.scan(/[^;]+/) + authors.each_with_index do |a,i| + b=((a =~/\s*\|\s*/) ? (a.split(/\|/)) : [a]) + if b[0] =~/"(.+?)"/ + @name_a_h << { the: $1 } + else + x=b[0].scan(/[^,]+/) + if x.length==1 + @name_a_h << { the: x[0].strip } + elsif x.length==2 + @name_a_h << { the: x[0].strip, others: x[1].strip } + else #p x.length + end + end + b.delete_at(0) + b.each do |d| + k,c=nil + k,c=/^(\S+)\s+(.*)/.match(d)[1,2] if d + @name_a_h[i][:hon]=c.strip if k=='hon' + @name_a_h[i][:affiliation]=c.strip if k=='affiliation' + @name_a_h[i][:nationality]=c.strip if k=='nationality' + end + end + l=@name_a_h.length + name_str='' + @name_a_h.each_with_index do |a,i| + name_str += if a[:others] + z=(((l - i) > 1) ? ', ' : '') + "#{a[:others].strip} #{a[:the].strip}" + z + else + z=(((l - i) > 2) ? ', ' : '') + "#{a[:the].strip}" + z + end + end + { name_a_h: @name_a_h, name_str: name_str } + else nil + end + end + def build_hash(arr) + @h={} + arr.each_with_index do |x,i| + a,b=nil,nil + if x =~/^%[:\s]/ #ignore comment + elsif x =~/:(\S+?):\s+(.+)/ + a,b=/:(\S+?):\s+(.+)\Z/m.match(x)[1,2] + elsif i == 0 + a='main' + b=x + else + end + @h[a]=b + end + @h + end + def make + a=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m) + @h=build_hash(a) + def headings + lv=[] + x=@h['headings'] + x=((x =~/;/) ? (x.split(/;\s*/)) : [ x ]) + lv[0]=x + lv0 ||='A~ ' #root level, single document apex, document title + lv1=x[0] ||='B~ ' + lv[1]=/^#{lv1}/ + lv2=x[1] ||='C~ ' + lv[2]=/^#{lv2}/ + lv3=x[2] ||='D~ ' + lv[3]=/^#{lv3}/ + lv4=x[3] ||='1~ ' + lv[4]=/^#{lv4}/ + lv5=x[4] ||='2~ ' + lv[5]=/^#{lv5}/ + lv6=x[5] ||='3~ ' + lv[6]=/^#{lv6}/ + lv + end + def num_top + @h['num_top'] + end + def breaks + pagebreaks=((@h['breaks'] =~/;/) \ + ? (@h['breaks'].split(/;\s*/)) + : [ @h['breaks'] ]) + page_new,page_break,page_line=nil,nil,nil + pagebreaks.each do |x| + page_new=x[/(:?[\dA-C],?)+/] if x=~/new|clear/ + page_break=x[/(:?[\dA-C],?)+/] if x =~/break/ + page_line=x[/(:?[\dA-C],?)+/] if x =~/line/ + end + { page_new: page_new, page_break: page_break, page_line: page_line } + end + def language + if @h['language'] && (@h['language']=~/\S{2,}/) + ((@h['language'] =~/,/) \ + ? (@h['language'].split(/,\s*/)) + : [ @h['language'] ]) + else [ 'en' ] + end + end + def bold + m=@h['bold'] + i=(m=~/\/i$/)? 'i' : '' + if m + x=m.gsub(/^\/(.+?)\/i?/,'\1'). + gsub(/\((?:\?:)?/,'(?:') # avoid need to escape use of brackets within regex provided + rgx='\b(' + x + ')\b' + y=((i =~/i/) ? (/#{rgx}/i) : (/#{rgx}/)) + { str: '\b(?:' + x + ')\b', regx: y, i: i } + else nil + end + end + def italics + m=@h['italics'] + i=((m=~/\/i$/) ? 'i' : '') + if m + x=m.gsub(/^\/(.+?)\/i?/,'\1'). + gsub(/\((?:\?:)?/,'(?:') # avoid need to escape use of brackets within regex provided + rgx='\b(' + x + ')\b' + y=((i =~/i/) ? (/#{rgx}/i) : (/#{rgx}/)) + { str: '\b(?:' + x + ')\b', regx: y, i: i } + else nil + end + end + def emphasis + if @h['emphasis'] =~/bold/ then 'bold' + elsif @h['emphasis'] =~/italics?/ then 'italics' + elsif @h['emphasis'] =~/under(?:line|score)/ then 'underscore' + else nil + end + end + def substitute + m=@h['substitute'] + if m + w=m.scan(/\/(.+?)\/(i?,)\s*'(.+?)'(?:\s+|\s*;\s*|$)/) + arr_hash=[] + matches='' + w.each do |x| + c=(x[1] =~/[i],/) ? :i : :s + matches=matches + x[0].gsub(/([${}])/,'\\\\\1') + '|' + arr_hash << { + match: x[0].gsub(/([${}])/,'\\\\\1'), + replace: x[2], + case_s: c + } + end + matches.chop! + { match_and_replace: arr_hash, matches: matches } + else nil + end + end + def plaintext_wrap + if @h['plaintext_wrap'].to_s =~/\d\d+/ \ + and @h['plaintext_wrap'].to_i > 19 \ + and @h['plaintext_wrap'].to_i < 201 + @h['plaintext_wrap'].to_i + else nil + end + end + def omit + m=@h['omit'] + @m=m ? (m.split(/,\s+/)) : nil + def list + @m + end + self + end + def ocn? + (omit.list.inspect =~/"ocn"/) \ + ? :off + : :na + end + def toc? + (omit.list.inspect =~/"toc"/) \ + ? :off + : :na + end + def manifest? + (omit.list.inspect =~/"manifest"/) \ + ? :off + : :na + end + def links_to_manifest? + (omit.list.inspect =~/"manifest_links"|"links_to_manifest"/) \ + ? :off + : :na + end + def metadata? + (omit.list.inspect =~/"metadata"/) \ + ? :off + : :na + end + def minitoc? + (omit.list.inspect =~/"minitoc"/) \ + ? :off + : :na + end + def html_minitoc? + (omit.list.inspect =~/"html_minitoc"/) \ + ? :off + : :na + end + def html_top_band? + (omit.list.inspect =~/"html_top_band"/) \ + ? :off + : :na + end + def html_navigation? + (omit.list.inspect =~/"html_navigation"/) \ + ? :off + : :na + end + def html_navigation_bar? + (omit.list.inspect =~/"html_navigation_bar"/) \ + ? :off + : :na + end + def segsubtoc? + (omit.list.inspect =~/"segsubtoc"/) \ + ? :off + : :na + end + def search_form? + (omit.list.inspect =~/"search_form"/) \ + ? :off + : :na + end + def html_search_form? + (omit.list.inspect =~/"html_search_form"/) \ + ? :off + : :na + end + def html_right_pane? + (omit.list.inspect =~/"html_right_column"|"html_right_pane"/) \ + ? :off + : :na + end + def manifest_minitoc? + (omit.list.inspect =~/"manifest_minitoc"/) \ + ? :off + : :na + end + def cover_image? + (omit.list.inspect =~/"cover_image"/) \ + ? :off + : :na + end + def home_button_image? + (omit.list.inspect =~/"home_button_image"/) \ + ? :off + : :na + end + def texpdf_font + def main + @h['texpdf_font'] \ + && (@h['texpdf_font']=~/\S{3,}/) \ + ? @h['texpdf_font'] + : @env.font.texpdf.main + end + def sans # not used + @h['texpdf_font_sans'] \ + && (@h['texpdf_font_sans']=~/\S{3,}/) \ + ? @h['texpdf_font_sans'] + : @env.font.texpdf.sans + end + def serif # not used + @h['texpdf_font_serif'] \ + && (@h['texpdf_font_serif']=~/\S{3,}/) \ + ? @h['texpdf_font_serif'] + : @env.font.texpdf.serif + end + def mono + @h['texpdf_font_mono'] \ + && (@h['texpdf_font_mono']=~/\S{3,}/) \ + ? @h['texpdf_font_mono'] + : @env.font.texpdf.mono + end + def cjk + @h['texpdf_font_cjk'] \ + && (@h['texpdf_font_cjk']=~/\S{3,}/) \ + ? @h['texpdf_font_cjk'] + : @env.font.texpdf.cjk + end + def cjk_zh + @h['texpdf_font_cjk_zh'] \ + && (@h['texpdf_font_cjk_zh']=~/\S{3,}/) \ + ? @h['texpdf_font_cjk_zh'] + : @env.font.texpdf.cjk_zh + end + def cjk_ja + @h['texpdf_font_cjk_ja'] \ + && (@h['texpdf_font_cjk_ja']=~/\S{3,}/) \ + ? @h['texpdf_font_cjk_ja'] + : @env.font.texpdf.cjk_ja + end + def cjk_ko + @h['texpdf_font_cjk_ko'] \ + && (@h['texpdf_font_cjk_ko']=~/\S{3,}/) \ + ? @h['texpdf_font_cjk_ko'] + : @env.font.texpdf.cjk_ko + end + self + end + def promo + @h['promo'] + end + def ad + @h['ad'] + end + def manpage + manpage={} + if @h['manpage'] + if @h['manpage'] =~/;/m + man=@h['manpage'].split(/;/m) + man.each do |x| + m=(x=~/=/m) ? x.split(/=/m) : nil + if m + manpage[m[0].strip] = m[1].split(/ \. /) + end + end + end + end + if manpage['name'] + manpage['name']=manpage['name'].join("\n.br\n"). + gsub(/(-)/m,"\\\\\\1"). + gsub(/\A/,"\n.br\n.SH NAME\n.br\n") + else + manpage['name']='man page "name/whatis" information not provided, set in header @man: name=[whatis information]' + end + if manpage['synopsis'] + manpage['synopsis']=manpage['synopsis'].join("\n\n.br\n"). + gsub(/(-)/m,"\\\\\\1"). + gsub(/\A/,"\n.br\n.SH SYNOPSIS\n.br\n") + else + manpage['synopsis']='' + end + unless manpage['section'] + manpage['section']=1 + end + manpage + end + def get_image_dimensions(img) + imgk=SiSU_Env::SystemCall.new.imagemagick + gmgk=SiSU_Env::SystemCall.new.graphicksmagick + img_pth={ + sst: @env.path.image_source_include, + pod: File.expand_path("../../../sisupod/image" ) + } + path_img=if FileTest.file?("#{img_pth[:pod]}/#{img}") + "#{img_pth[:pod]}/#{img}" + elsif FileTest.file?("#{img_pth[:sst]}/#{img}") + "#{img_pth[:sst]}/#{img}" + else nil + end + if path_img + if imgk or gmgk + if imgk + imgsys=`identify #{path_img}`.strip #system call + elsif gmgk + imgsys=`gm identify #{path_img}`.strip #system call + end + w,h=/(\d+)x(\d+)/m.match(imgsys)[1,2] + else + w,h='600','800' + end + else + w,h=nil,nil + end + {w: w, h: h} + end + def home_button_text + if @h['home_button_text'] + @h['home_button_text'].split(/\s*;\s*/) + else nil + end + end + def home_button_image + s=nil + s=if @h['home_button_image'] + s=@h['home_button_image'].split(/\s*;\s*/) + s0=s[0] #if + image={} + s=if s0 =~/{(\S+\.(?:jpg|png|gif))(?:\s+(\d+x\d+))?\s*}(?:(http:\/\/\S+)|image)/ + image[:home_button]=$1 + if $2 + image[:dimensions]=$2 + image[:w],image[:h]=/(\d+)x(\d+)/m.match(image[:dimensions])[1,2] + else + d=get_image_dimensions(image[:home_button]) + image[:w],image[:h]=d[:w],d[:h] + image[:dimensions]="#{d[:w]}x#{d[:h]}" + end + image[:link]=$3 + image + end + else nil + end + end + def cover_image + s=nil + if @h['cover_image'] + s=@h['cover_image'].split(/\s*;\s*/) + s=s[0] #if + image={} + if s =~/{\s*(\S+\.(?:jpg|png|gif))(?:\s+(\d+x\d+))?(?:\s+"(.+?)")?\s*}image/ + image[:cover]=$1 + if $2 + image[:dimensions]=$2 + image[:w],image[:h]=/(\d+)x(\d+)/m.match(image[:dimensions])[1,2] + else + d=get_image_dimensions(image[:cover]) + image[:w],image[:h]=d[:w],d[:h] + image[:dimensions]="#{d[:w]}x#{d[:h]}" + end + image[:note]=$3 + elsif s =~/(\S+\.(?:jpg|png|gif))/ + image[:cover]=$1 + d=get_image_dimensions(image[:cover]) + image[:w],image[:h]=d[:w],d[:h] + image[:dimensions]="#{d[:w]}x#{d[:h]}" + image[:note]=nil + end + image + else nil + end + end + def footer + if @h['footer'] + @h['footer'].split(/\s*;\s*/) + else nil + end + end + self + end + def make_links + @doc_links=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m) + def links + lnks,a_idx=[],0 + @doc_links.each do |doc_link| + if doc_link=~/\{.+?\}(?:(?:https?|file|ftp):\/|\.\.)\/\S+(?:\s|$)/ + say,url=/\{\s*(.+?)\s*\}((?:(?:https?|file|ftp):\/|\.\.)\/\S+)/im.match(doc_link)[1,2] + lnks[a_idx]={ say: say, url: url } + a_idx +=1 + end + end + lnks + end + def append? + (@doc_links[0]=='+') \ + ? :yes + : :no + end + self + end + end + class MakeHead + attr_accessor :pagenew,:pagebreak,:pageline,:toc,:lv1,:lv2,:lv3,:lv4,:lv5,:lv6,:num_top,:i18n,:man_section,:substitution_match_list,:bold_match_list,:italics_match_list,:emphasis_set_to,:footer_links,:home_button_links,:home_button_image,:cover_image + def initialize(make) + @make=make + end + def clear + @pagenew=@pagebreak=@pageline=@toc=@lv1=@lv2=@lv3=@lv4=@lv5=@lv6=@num_top=@i18n=@man_section=@footer_links=@substitution_match_list=@bold_match_list=@italics_match_list=@emphasis_set_to=@home_button_links=@home_button_image=@cover_image=nil + end + def make_instruct + clear + if defined? @make.breaks \ + and @make.breaks[:page_new] #clearpage + @pagenew=@make.breaks[:page_new] + end + if defined? @make.breaks \ + and @make.breaks[:page_break] #newpage + @pagebreak=@make.breaks[:page_break] + end + if defined? @make.breaks \ + and @make.breaks[:page_line] #page line across + @pagebreak=@make.breaks[:page_line] + end + if defined? @make.headings \ + and @make.headings + @toc=@make.headings[0] + @lv1=@make.headings[1] + @lv2=@make.headings[2] + @lv3=@make.headings[3] + @lv4=@make.headings[4] + @lv5=@make.headings[5] + @lv6=@make.headings[6] + end + if defined? @make.num_top \ + and @make.num_top + @num_top=@make.num_top # remove @num_top + end + if defined? @make.language \ + and @make.language[0] + @i18n=@make.language + end + if defined? @make.manpage \ + and @make.manpage + @man_section=(defined? @make.manpage.section) \ + ? @make.manpage.section + : 1 + end + if defined? @make.substitute \ + and @make.substitute + @substitution_match_list=@make.substitute + end + if defined? @make.bold \ + and @make.bold + @bold_match_list=@make.bold + end + if defined? @make.italics \ + and @make.italics + @italics_match_list=@make.italics + end + if defined? @make.emphasis \ + and @make.emphasis + @emphasis_set_to=@make.emphasis + end + if defined? @make.footer \ + and @make.footer.is_a?(Array) + @footer_links= { left: { say: '', url: '' }, center: { say: '', url: '' } } #already set + @footer_links[:left]=if @make.footer[0]=~/\{.+?\}(?:(?:https?|file|ftp):\/|\.\.)\/\S+(?:\s|$)/ + say,url=/\{\s*(.+?)\s*\}((?:(?:https?|file|ftp):\/|\.\.)\/\S+)/im.match(@make.footer[0])[1,2] + { say: say, url: url } + else + { say: '', url: '' } + end + @footer_links[:center]=if @make.footer[1]=~/\{.+?\}(?:(?:https?|file|ftp):\/|\.\.)\/\S+(?:\s|$)/ + say,url=/\{\s*(.+?)\s*\}((?:(?:https?|file|ftp):\/|\.\.)\/\S+)/im.match(@make.footer[1])[1,2] + { say: say, url: url } + else + { say: '', url: '' } + end + @footer_links + else #already set + @footer_links= { left: { say: '', url: '' }, center: { say: '', url: '' } } + end + if defined? @make.home_button_text \ + and @make.home_button_text.is_a?(Array) + a_idx=0 + @home_button_links=[] + @make.home_button_text.each do |doc_link| + if doc_link=~/\{.+?\}(?:(?:https?|file|ftp):\/|\.\.)\/\S+(?:\s|$)/ + say,url=/\{\s*(.+?)\s*\}((?:(?:https?|file|ftp):\/|\.\.)\/\S+)/im.match(doc_link)[1,2] + @home_button_links[a_idx]= { say: say, url: url } + a_idx +=1 + end + end + @home_button_links + end + if defined? @make.home_button_image \ + and @make.home_button_image.is_a?(Hash) + @home_button_image=@make.home_button_image + end + if defined? @make.cover_image \ + and @make.cover_image.is_a?(Hash) + @cover_image=@make.cover_image + end + { pagenew: @pagenew, + pagebreak: @pagebreak, + pageline: @pageline, + toc: @toc, + lv1: @lv1, + lv2: @lv2, + lv3: @lv3, + lv4: @lv4, + lv5: @lv5, + lv6: @lv6, + num_top: @num_top, + i18n: @i18n, + emphasis_set_to: @emphasis_set_to, + bold_match_list: @bold_match_list, + italics_match_list: @italics_match_list, + substitution_match_list: @substitution_match_list, + man_section: @man_section, + footer_links: @footer_links, + home_button_links: @home_button_links, + home_button_image: @home_button_image, + cover_image: @cover_image, + } + end + end +end +__END__ diff --git a/lib/sisu/v5/embedded.rb b/lib/sisu/v5/embedded.rb index c013806b..b46975fd 100644 --- a/lib/sisu/v5/embedded.rb +++ b/lib/sisu/v5/embedded.rb @@ -61,9 +61,9 @@ =end module SiSU_Embedded - require_relative 'param' # param.rb + require_relative 'dp' # dp.rb include SiSU_Param - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env class Source def initialize(opt) diff --git a/lib/sisu/v5/errors.rb b/lib/sisu/v5/errors.rb index f4e05091..c3468043 100644 --- a/lib/sisu/v5/errors.rb +++ b/lib/sisu/v5/errors.rb @@ -61,7 +61,7 @@ =end module SiSU_Errors - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env; include SiSU_Screen class Rescued . + + 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: + + + * Git + + + + * Ralph Amissah + + + + ** Description: system environment, resource control and configuration details + +=end +module SiSU_FormatAuthor + 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=a.strip + if a =~/"(.+?)"/ + @authors << { the: $1 } + @author_array << $1.upcase + else #if a =~/,/ + x=a.scan(/[^,]+/) + x[0]=x[0].strip + x[1]=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/v5/harvest_authors.rb b/lib/sisu/v5/harvest_authors.rb index 361b9a8f..7904ab15 100644 --- a/lib/sisu/v5/harvest_authors.rb +++ b/lib/sisu/v5/harvest_authors.rb @@ -62,7 +62,7 @@ =end module SiSU_HarvestAuthors - require_relative 'author_format' # author_format.rb + require_relative 'harvest_author_format' # harvest_author_format.rb class Songsheet @@the_idx_authors={} def initialize(opt,env) diff --git a/lib/sisu/v5/harvest_topics.rb b/lib/sisu/v5/harvest_topics.rb index c68293b0..cd507f63 100644 --- a/lib/sisu/v5/harvest_topics.rb +++ b/lib/sisu/v5/harvest_topics.rb @@ -63,7 +63,7 @@ =end module SiSU_HarvestTopics - require_relative 'author_format' # author_format.rb + require_relative 'harvest_author_format' # harvest_author_format.rb include SiSU_Viz class Songsheet @@the_idx_topics={} diff --git a/lib/sisu/v5/html.rb b/lib/sisu/v5/html.rb index 526b41c6..a613f56f 100644 --- a/lib/sisu/v5/html.rb +++ b/lib/sisu/v5/html.rb @@ -66,7 +66,7 @@ module SiSU_HTML rescue LoadError SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('pstore NOT FOUND (LoadError)') end - require_relative 'particulars' # particulars.rb + require_relative 'se_hub_particulars' # se_hub_particulars.rb include SiSU_Particulars require_relative 'defaults' # defaults.rb include SiSU_Viz diff --git a/lib/sisu/v5/html_concordance.rb b/lib/sisu/v5/html_concordance.rb index 7bbb1a4c..dbaf83cf 100644 --- a/lib/sisu/v5/html_concordance.rb +++ b/lib/sisu/v5/html_concordance.rb @@ -62,9 +62,9 @@ =end module SiSU_Concordance - require_relative 'particulars' # particulars.rb + require_relative 'se_hub_particulars' # se_hub_particulars.rb include SiSU_Particulars - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env require_relative 'defaults' # defaults.rb include SiSU_Viz @@ -212,7 +212,7 @@ WOK include SiSU_Viz require_relative 'html_format' # html_format.rb include SiSU_HTML_Format - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Screen @@dp=nil def initialize(particulars) diff --git a/lib/sisu/v5/html_lite_shared.rb b/lib/sisu/v5/html_lite_shared.rb index 3ce59049..e9497698 100644 --- a/lib/sisu/v5/html_lite_shared.rb +++ b/lib/sisu/v5/html_lite_shared.rb @@ -66,7 +66,7 @@ module SiSU_FormatShared include SiSU_Viz class CSS_Format require_relative 'defaults' # defaults.rb - require_relative 'particulars' # particulars.rb + require_relative 'se_hub_particulars' # se_hub_particulars.rb @@fns=nil def initialize(md,t_o) @md,@t_o=md,t_o diff --git a/lib/sisu/v5/html_promo.rb b/lib/sisu/v5/html_promo.rb index f10bdb51..87f9bb31 100644 --- a/lib/sisu/v5/html_promo.rb +++ b/lib/sisu/v5/html_promo.rb @@ -61,7 +61,7 @@ =end module SiSU_HTML_Promo - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env class Ad def initialize(md) diff --git a/lib/sisu/v5/html_tune.rb b/lib/sisu/v5/html_tune.rb index 39cbb708..1a2c9dee 100644 --- a/lib/sisu/v5/html_tune.rb +++ b/lib/sisu/v5/html_tune.rb @@ -60,9 +60,9 @@ ** Description: html generation, html pre-processing =end -require_relative 'param' +require_relative 'dp' # dp.rb module SiSU_HTML_Tune - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env; include SiSU_Screen require_relative 'html_format' # html_format.rb #watch @@line_mode='' diff --git a/lib/sisu/v5/hub.rb b/lib/sisu/v5/hub.rb index 510e2092..785da84d 100644 --- a/lib/sisu/v5/hub.rb +++ b/lib/sisu/v5/hub.rb @@ -63,11 +63,11 @@ =end module SiSU require_relative 'constants' # constants.rb - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env include SiSU_Screen - require_relative 'options' # options.rb - require_relative 'param' # param.rb + require_relative 'hub_options' # hub_options.rb + require_relative 'dp' # dp.rb include SiSU_Param require_relative 'defaults' # defaults.rb include SiSU_Viz @@ -599,10 +599,10 @@ module SiSU else end if @opt.act[:urls_selected][:set]==:on #% --sitemap, -Y - require_relative 'urls' - OptionLoopFiles.new(@opt).loop_files_on_given_option do - SiSU_Urls::Source.new(@opt).read #% -u -v -V -M - end + require_relative 'urls' + OptionLoopFiles.new(@opt).loop_files_on_given_option do + SiSU_Urls::Source.new(@opt).read #% -u -v -V -M + end end end def do_initialization diff --git a/lib/sisu/v5/hub_options.rb b/lib/sisu/v5/hub_options.rb new file mode 100644 index 00000000..f851b985 --- /dev/null +++ b/lib/sisu/v5/hub_options.rb @@ -0,0 +1,1399 @@ +# encoding: utf-8 +=begin + + * Name: SiSU + + * Description: a framework for document structuring, publishing and search + + * Author: Ralph Amissah + + * Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. + + * License: GPL 3 or later: + + SiSU, a framework for document structuring, publishing and search + + Copyright (C) Ralph Amissah + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along with + this program. If not, see . + + 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: + + + * Git + + + + * Ralph Amissah + + + + ** Description: SiSU information Structuring Universe, command line options + parsing + +=end +module SiSU_Commandline + begin + require 'pathname' + rescue LoadError + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('pathname NOT FOUND (LoadError)') + end + require_relative 'se' # se.rb + require_relative 'dp_make' # dp_make.rb + class HeaderCommon + def sisu_document_make_instructions(make_instruct_array=:nil) + @pagenew= + @pagebreak= + @pageline= + @toc= + @lv1=@lv2=@lv3=@lv4=@lv5=@lv6= + @num_top= + @i18n= + @man_section= + @emphasis_set_to= + @bold_match_list= + @italics_match_list= + @substitution_match_list= + @footer_links= + @home_button_links= + @links= + nil + make_instruct_array=make_instruct_array==:nil \ + ? SiSU_Env::GetInit.new.sisu_document_make.makefile_read + : make_instruct_array + @makeset=false + if make_instruct_array + make_instruct_array.each do |para| #% scan document + if para =~/^(?:@make:|@links:)[+-]?\s/ + case para + when /^@make:(.+)/m #% header processing - make + @env=SiSU_Env::InfoEnv.new + @make=SiSU_Param_Make::MdMake.new($1.strip,@opt,@env).make + makes=SiSU_Param_Make::MakeHead.new(@make).make_instruct + @makeset=true + @pagenew=makes[:pagenew] + @pagebreak=makes[:pagenew] + @pageline=makes[:pageline] + @toc=makes[:toc] + @lv1=makes[:lv1] + @lv2=makes[:lv2] + @lv3=makes[:lv3] + @lv4=makes[:lv4] + @lv5=makes[:lv5] + @lv6=makes[:lv6] + @num_top=makes[:num_top] + @i18n=makes[:i18n] + @man_section=makes[:man_section] + @emphasis_set_to=makes[:emphasis_set_to] + @bold_match_list=makes[:bold_match_list] + @italics_match_list=makes[:italics_match_list] + @substitution_match_list=makes[:substitution_match_list] + @footer_links=makes[:footer_links] + @home_button_links=makes[:home_button_links] + @home_button_image=makes[:home_button_image] + @cover_image=makes[:cover_image] + when /^@links:(.+)/m #% header processing - make + make_links=SiSU_Param::Parameters::MdMake.new($1.strip,@opt,@env).make_links + @links,@links_append=make_links.links,make_links.append? + end + end + end #% here endeth the common header loop + end + { makeset: @makeset, + pagenew: @pagenew, + pagebreak: @pagebreak, + pageline: @pageline, + toc: @toc, + lv1: @lv1, + lv2: @lv2, + lv3: @lv3, + lv4: @lv4, + lv5: @lv5, + lv6: @lv6, + num_top: @num_top, + i18n: @i18n, + man_section: @man_section, + emphasis_set_to: @emphasis_set_to, + bold_match_list: @bold_match_list, + italics_match_list: @italics_match_list, + substitution_match_list: @substitution_match_list, + footer_links: @footer_links, + home_button_links: @home_button_links, + home_button_image: @home_button_image, + cover_image: @cover_image, + links: @links, + links_append: @links_append + } + end + end + class Options + attr_accessor :cmd,:mod,:act,:dir_structure_by,:lingual,:f_pths,:files,:files_mod,:call_path,:base_path,:base_stub,:sub_location,:image_src_path,:paths,:lngs,:f_pth,:pth,:fno,:fns,:fnb,:fnc,:fng,:fncb,:lng,:lng_base,:what,:make_instructions,:make_instructions_pod + @@act=nil + def initialize(a,call_path) + @cmd=@f_pth=@pth=@fno=@fns=@fnb=@fnc=@fng=@fncb=@what=@lng=@lng_base=@call_path=@base_path=@base_stub=@image_src_path=@sub_location='' + @f_pths,@files,@files_mod,@paths,@mod,@act=Array.new(5){[]} + @env=SiSU_Env::InfoEnv.new + @lng_base=@env.language_default_set + @dir_structure_by=SiSU_Env::EnvCall.new.output_dir_structure.by? + @lingual=SiSU_Env::EnvCall.new.mono_multi_lingual? + @call_path=call_path + pth=SiSU_Utils::Path.new(call_path) + @base_path=pth.base_markup + @base_stub=pth.base_markup_stub + @image_src_path=pth.image_src + @a=sisu_glob_rules(a) + @a.freeze + @make_instructions=HeaderCommon.new.sisu_document_make_instructions + @make_instructions_pod=nil + init + end + def find_all(find_flag,opt) + if find_flag + x=Dir.glob('*.ss[tm]') + Px[:lng_lst].each do |d| + if FileTest.directory?(d) + x << Dir.glob("#{d}/*.ss[tm]") + end + end + x=x.flatten + opt + x + end + end + def find_select(find_flag,opt) + if find_flag + x=[] + if opt.inspect =~/"[a-zA-Z][a-zA-Z0-9._-]+?"/ + opt.each do |g| + x <<=if g =~/.ss[tm]/ + Dir.glob("*#{g}") + else + Dir.glob("*#{g}*.ss[tm]") + end + Px[:lng_lst].each do |d| + if FileTest.directory?(d) + x <<=if g =~/.ss[tm]/ + Dir.glob("#{d}/*#{g}") + else + Dir.glob("#{d}/*#{g}*.ss[tm]") + end + end + end + end + end + x.flatten + end + end + def sisu_glob_rules(a) + a=if a.inspect =~/"-[A-Za-z0-9]*[fG]/ \ + or a.inspect =~/"--find"|"--glob"/ + b,f=[],[] + find_flag=false + a.each do |y| + if y =~ /^-/ + if y =~/^-/ \ + && y =~/[fG]|--find|--glob/ + find_flag=true + end + b << y + end + if find_flag \ + && y !~ /^-/ \ + && y =~ /\S+/ + if y !~/\// + f << y + else + find_flag=false + puts %{sub-directories "#{y}" cannot be provided for --find or --glob at this time} + end + end + end + r=Px[:lng_lst_rgx].gsub(/\|#{lng_base}\|/,'|') + @lang_regx=%r{(?:#{r})} + if find_flag + (f.length > 0) \ + ? (b + find_select(find_flag,f)) + : find_all(find_flag,b) + elsif a.inspect =~/"(?:-\S+?|--\S+?)"/ \ + && a.inspect =~/"#{@lang_regx}\/?"/ \ + && a.inspect =~/"#{lng_base}\/\S+?\.ss[tm]"/ + init_selected_lang_dirs(a) + else b + end + else a + end + end + def init_selected_lang_dirs(a) + @z=[] + a.each do |y| + if y =~/^#{lng_base}\/(\S+?\.ss[tm])$/ + @fn=$1 + @z << y + elsif y =~/^#{@lang_regx}\/?$/ + @z << "#{y}/#{@fn}" + else @z << y + end + end + @z + end + def init + a=@a + if a.length > 0 + s=expand_numeric_shortcuts(a) + q=set_files_and_paths_and_general_extract(s) + @cmd,@mod=opt_cmd_and_mod_adjust(q[:cmd],q[:mod]) + @what=q[:what] unless q[:what].empty? + @paths = q[:paths] + @files = q[:files] + @f_pths = q[:f_pths] + @lngs = q[:lngs] + if @files.length > 0 \ + and @cmd.empty? \ + and @mod.length==0 #% if no other action called on filename given, default is sisu --v5 -0 [filename(s)] configured as flag default + shortcut=SiSU_Env::InfoProcessingFlag.new + @mod=['--v5'] + @cmd=shortcut.cf_0 + ' --dal' + end + if @cmd =~/[vVM]/ \ + && @cmd !~/-[ku]*v[ku]*$/ + SiSU_Screen::Ansi.new( + @cmd, + "\tsisu " + @cmd + ' ' + @mod.join(' ') + ' ' + @files.join(' ') + "\n" + ).print_brown + end + end + @@act ? @act=@@act : @@act=@act=opt_act + self + end + def sisu_document_make_pod + def makefile_name + SiSU_Env::GetInit.new.sisu_document_make.makefile_name + end + def makefile(pod_make_path) + "#{pod_make_path}/#{makefile_name}" + end + def makefile_read(pod_make_path) + if FileTest.file?(makefile(pod_make_path)) + sisu_doc_makefile=IO.read(makefile(pod_make_path), mode: 'r:utf-8') + sisu_doc_makefile.split(/\s*\n\s*\n/m) + else nil + end + end + self + end + def set_files_and_paths_and_general_extract(s) + c,w='','' + m,f,pth,lng,lngs=[],[],[],[],[] + lng_is='' + a=s.split(/\s+/) + r_l=Px[:lng_lst].join('|') + a.uniq.each do |x| + if x =~/^-[a-z0-5]+/i \ + or x =~/^--\S+/ + if x =~/^-([a-z0-5]+)/i + c << $1 + end + if x =~/^--\S+/ + m << x + end + elsif x =~ /(?:\.(?:(?:-|ssm\.)?sst(?:\.xml)?|ssm|ssi|sx[sdn]\.xml|s[1-3]|kdi|ssp)|\S+?\.ss[mt]\.(?:txz|zip)|sisupod\.(?:txz|zip))$/ + if x =~/\S+?\.ss[mt]\.(?:txz|zip)|sisupod\.(?:txz|zip)/ + if x =~/^(?:https?|file):\/\/\S+/ #\ + end + pwd=Dir.pwd + fn_pod=x.gsub(/([^\/]+)\.txz$/,'\1') + fullname=@env.processing_path.processing + '/sisupod/' + fn_pod + pt=Pathname.new(fullname) + FileUtils::mkdir_p(pt.to_s) + pod_make_path=fullname + '/sisupod/doc/_sisu' + make_instruct_array=sisu_document_make_pod.makefile_read(pod_make_path) + @make_instructions_pod= + HeaderCommon.new.sisu_document_make_instructions(make_instruct_array) + Dir.chdir(pt.realpath) + system(" + chdir #{fullname} + tar xaf #{pwd}/#{x} + chdir #{pwd} + ") + Dir.chdir(pt.realpath.to_s + '/sisupod/doc') + r=Px[:lng_lst_rgx] + Dir.entries("#{fullname}/sisupod/doc").each do |d_lng| + if d_lng =~/^(?:#{r})$/ + Dir.chdir(pt.realpath.to_s + "/sisupod/doc/#{d_lng}") + filenames=Dir.glob("*.ss[mt]") + filenames.each do |fn| + f_pths << { + pth: "#{fullname}/sisupod/doc/#{d_lng}", + f: "#{fn}", + pth_stub: 'doc', + lng: d_lng, + lng_is: d_lng, + url_base: '', + url: '' + } + Dir.chdir(pwd) + f << fn + end + end + end + elsif x =~/^(?:https?|file):\/\/\S+/ \ + and x =~/\S+?\.ss[mt]$/ + r_url=/(http:\/\/\S+?\/\S+?\/src(?:\/(?:#{r_l}))?)\// + url_base = (x[r_url,1]) + url = x + y=x.gsub(/http:\/\/\S+?\/\S+?\/src\//,'') + t=/(#{r_l})\/[^\/]+?\.ss[tm]$/ + l_p = (y[t,1]) \ + ? y[t,1] + : nil + lng << l_p + lngs << if l_p + l_p + elsif x =~/~(#{r_l})\.ss[tm]/ + $1 + else lng_base + end + r_f=/(?:#{r_l})\/([^\/]+?\.ss[tm])$/ + fn = (y[r_f,1]) \ + ? y[r_f,1] + : y + fn=fn.gsub(/\.((?:ssm\.)?sst)/,'.-\1') + fullname=Dir.pwd + '/' + fn + pt=Pathname.new(fullname) + pth << Dir.pwd + r_u=/.+?\/([^\/]+)(?:\/(?:#{r_l})$|$)/ + lng_is =if l_p + l_p + elsif x =~/~(#{r_l})\.ss[tm]/ + $1 + else lng_base + end + f_pths << { + pth: pt.split[0].realpath.to_s, + f: pt.split[1].to_s, + pth_stub: pt.split[0].realpath.to_s[r_u,1], + lng: (pt.split[0].realpath.to_s[t,1]) \ + ? pt.split[0].realpath.to_s[t,1] + : nil, + lng_is: lng_is, + url_base: url_base, + url: url + } + f << fn + elsif FileTest.file?(x) + pt=Pathname.new(x) + pth << pt.split[0].realpath.to_s #remove? + f << pt.split[1].to_s #remove? + r_u=/.+?\/([^\/]+)(?:\/(?:#{r_l})$|$)/ + t=/.+\/(#{r_l})$/ + l_p = (pt.split[0].realpath.to_s[t,1]) \ + ? pt.split[0].realpath.to_s[t,1] + : nil + lngs << lng_is = if l_p + l_p + elsif x =~/~(#{r_l})\.ss[tm]/ + $1 + else lng_base + end + f_pths << { + pth: pt.split[0].realpath.to_s, + f: pt.split[1].to_s, + pth_stub: pt.split[0].realpath.to_s[r_u,1], + lng: lng_is, + lng_is: lng_is, + url_base: nil, + url: nil, + } + else puts "file not found: #{x}" + end + elsif x =~ /\.termsheet\.rb$/ + (FileTest.file?(x)) \ + ? (f << x) + : (puts "file not found: #{x}") + else w=x + puts "#{x} in #{a.join(' ')}?" + end + end + { + cmd: c, + mod: m, + what: w, + paths: pth, + files: f, + f_pths: f_pths, + lng: lng_is, + lngs: lngs, + } + end + def expand_numeric_shortcuts(a) + shortcut=SiSU_Env::InfoProcessingFlag.new + s='' + a.each do |x| + y=case x + when /0/ + (x=~/^-0\S+/) \ + ? x.gsub(/^-0(\S+)/,shortcut.cf_0 + ' -\1') + : x.gsub(/^-0/,shortcut.cf_0 + ' ') + when /1/ + (x=~/^-1\S+/) \ + ? x.gsub(/^-1(\S+)/,shortcut.cf_1 + ' -\1') + : x.gsub(/^-1/,shortcut.cf_1 + ' ') + when /2/ + (x=~/^-2\S+/) \ + ? x.gsub(/^-2(\S+)/,shortcut.cf_2 + ' -\1') + : x.gsub(/^-2/,shortcut.cf_2 + ' ') + when /3/ + (x=~/^-3\S+/) \ + ? x.gsub(/^-3(\S+)/,shortcut.cf_3 + ' -\1') + : x.gsub(/^-3/,shortcut.cf_3 + ' ') + when /4/ + (x=~/^-4\S+/) \ + ? x.gsub(/^-4(\S+)/,shortcut.cf_4 + ' -\1') + : x.gsub(/^-4/,shortcut.cf_4 + ' ') + when /5/ + (x=~/^-5\S+/) \ + ? x.gsub(/^-5(\S+)/,shortcut.cf_5 + ' -\1') + : x.gsub(/^-5/,shortcut.cf_5 + ' ') + when /6/ + (x=~/^-6\S+/) \ + ? x.gsub(/^-6(\S+)/,shortcut.cf_5 + ' -\1') + : x.gsub(/^-6/,shortcut.cf_5 + ' ') + else x + end + s << " #{y}" unless y.empty? + end + s.strip! + end + def opt_cmd_and_mod_adjust(c,m) + cmd,mod,files=@cmd,@mod,@files + if not m.empty? \ + and m.inspect =~/"--pdf-/ + mod << '--pdf' + m.each do |s| + if s =~ /^--pdf-(?:(?:l|landscape)(?:-(?:a4|letter|a5|b5|legal))?|(?:a4|letter|a5|b5|legal)-(?:l|landscape))$/ + mod << '--landscape' + end + if s =~ /^--pdf-(?:(?:p|portrait)(?:-(?:a4|letter|a5|b5|legal))?|(?:a4|letter|a5|b5|legal)-(?:p|portrait))$/ + mod << '--portrait' + end + if s =~ /^--pdf(?:-(?:a4|letter|a5|b5|legal)(?:-(?:[lp]|landscape|portrait))?|(?:-(?:[lp]|landscape|portrait))(?:-(?:a4|letter|a5|b5|legal)))$/ + if s =~ /^--pdf(?:-a4(?:-(?:[lp]|landscape|portrait))?|(?:-(?:[lp]|landscape|portrait))-a4)$/ + mod << '--papersize-a4' + end + if s =~ /^--pdf(?:-a5(?:-(?:[lp]|landscape|portrait))?|(?:-(?:[lp]|landscape|portrait))-a5)$/ + mod << '--papersize-a5' + end + if s =~ /^--pdf(?:-b5(?:-(?:[lp]|landscape|portrait))?|(?:-(?:[lp]|landscape|portrait))-b5)$/ + mod << '--papersize-b5' + end + if s =~ /^--pdf(?:-letter(?:-(?:[lp]|landscape|portrait))?|(?:-(?:[lp]|landscape|portrait))-letter)$/ + mod << '--papersize-letter' + end + if s =~ /^--pdf(?:-legal(?:-(?:[lp]|landscape|portrait))?|(?:-(?:[lp]|landscape|portrait))-legal)$/ + mod << '--papersize-legal' + end + end + end + mod=mod.uniq + end + unless m.empty? + m.each do |s| + case s + when /^--(?:color-toggle)$/ then c=c+'c' + when /^--(?:color-off)$/ then c=c+'k' + when /^--(?:conf|config|configure|init|initialize|init-site)$/ then c=c+'CC' + when /^--(?:ao|dal?|machine|abstraction|abs)$/ then c=c+'m' + when /^--(?:txt|text|plaintext)$/ then c=c+'t' + when /^--(?:html)$/ then c=c+'h' + when /^--(?:html-scroll|html-seg)$/ then c=c+'H' + mod << s + when /^--(?:epub)$/ then c=c+'e' + when /^--(?:od[ft])$/ then c=c+'o' + when /^--docbook$/ then c=c+'d' + when /^--(?:pdf)$/ then c=c+'p' + when /^--pdf-(?:a4|a5|b5|legal|letter)$/ then c=c+'p' + when /^--pdf-(?:p|l|portrait|landscape)$/ then c=c+'L' + when /^--pdf-(?:p(?:ortrait)?|l(?:andscape)?)-(?:a4|letter|a5|b5|legal)$/ then c=c+'L' + when /^--pdf-(?:a4|letter|a5|b5|legal)-(?:p(?:ortrait)?|l(?:andscape)?)$/ then c=c+'L' + when /^--(?:concordance|wordmap)$/ then c=c+'w' + when /^--(?:manpage|man)$/ then c=c+'i' + when /^--(?:texinfo)$/ then c=c+'I' + when /^--(?:xhtml)$/ then c=c+'b' + when /^--(?:xml-sax)$/ then c=c+'x' + when /^--(?:xml-dom)$/ then c=c+'X' + when /^--(?:images)$/ then c=c+'j' + when /^--(?:digests?|hash-digests)$/ then c=c+'N' + when /^--(?:po4a|pot?)$/ then c=c+'P' + when /^--(?:termsheet)$/ then c=c+'T' + when /^--(?:manifest)$/ then c=c+'y' + when /^--(?:qrcode)$/ then c=c+'Q' + when /^--(?:remote|rsync)$/ then c=c+'R' + when /^--(?:scp)$/ then c=c+'r' + when /^--(?:source)$/ then c=c+'s' + when /^--(?:sisupod|pod)$/ then c=c+'S' + when /^--(?:git)$/ then c=c+'g' + when /^--(?:urls)$/ then c=c+'U' + when /^--(?:zap|delete)$/ then c=c+'Z' + when /^--(?:sample-search-form)$/ then c=c+'F' + when /^--(?:webserv|webrick)$/ then c=c+'W' + when /^--(?:profile)$/ then c=c+'E' + when /^--(?:maintenance|keep-processing-files)$/ then c=c+'M' + when /^--(?:verbose[=-]3)$/ then c=c+'VM' + when /^--(?:verbose[=-]2|Verbose|VERBOSE)$/ then c=c+'V' + when /^--(?:verbose(?:[=-]1)?)$/ then c=c+'v' + when /^--(?:version)$/ then c=c+'v' + when /^--(?:verbose[=-]0|quiet|silent)$/ then c=c+'q' + else mod << s #mod only contains command modifiers; commands converted to character + end + end + end + ca=[] + unless c.empty? + c=c.gsub(/-/,'') + c.scan(/CC|\S/) {|x| ca << x} + cmd= '-' + ca.uniq.join + end + extra='' + if cmd !~/[mn]/ + extra+=if cmd =~/[abegHhIiLNOoPpQTtwXxyz]/ \ + and cmd !~/[mn]/ + 'm' #% add ao + elsif ((mod.inspect =~/--(?:(?:sq)?lite|pg(?:sql)?)/) \ + and mod.inspect !~/(?:remove|(?:(?:re)?create(?:all)?|dropall|drop)$)/) \ + and cmd !~/[mn]/ + 'm' #% add ao + else '' + end + end + if cmd !~/j/ + extra+=if cmd =~/[bdHhwXxyz]/ \ + and cmd !~/[j]/ + 'j' #% copy images + else '' + end + end + if cmd !~/y/ + extra+=if cmd =~/[abdeHhIiNopQSstwXxz]/ \ + and cmd !~/y/ + 'ym' #% add manifest + elsif mod.inspect =~/--(?:(?:sq)?lite|pg(?:sql)?)/ \ + and files[0] !~/^remove$/ \ + and cmd !~/y/ + 'ym' #% add manifest + else '' + end + end + if cmd !~/u/ #% add urls + extra+='u' + end + cmd=cmd + extra + cmds=cmd.scan(/CC|\S/) + [cmds.uniq.join,mod] + end + def opt_act #note mod line commands have already been converted to command characters, cmd + cmd,mod=@cmd,@mod + @@act=if @@act + @act=@@act + else + act={} + act[:license]=(mod.inspect =~/"--license/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:site_init]=(cmd =~/C/ \ + || mod.inspect =~/"--init"|"--initialize"|"--init-site"|"--conf"|"--config"|"--configure"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:rc]=if mod.inspect =~/"--rc=/ + x=Dir.pwd + '/' + mod.join.gsub(/--rc=/,'') + { bool: true, set: :on, inst: x } + else + { bool: false, set: :na, inst: '' } + end + act[:processing_path]=if mod.inspect =~/"--processing-path=/ + base_pth=mod.join(';').gsub(/^.*--processing-path=['"]?(.+?)(?:['"]?;.+)?$/,'\1') + { bool: true, set: :on, inst: base_pth } + elsif mod.inspect =~/"--processing-path/ + { bool: true, set: :on, inst: @base_path } + else + { bool: false, set: :na, inst: nil } + end + act[:dump]=if mod.inspect =~/"--dump=/ + base_pth=mod.join(';').gsub(/^.*--dump=['"]?(.+?)(?:['"]?;.+)?$/,'\1') + { bool: true, set: :on, inst: base_pth } + elsif mod.inspect =~/"--dump/ + { bool: true, set: :on, inst: @base_path } + else + { bool: false, set: :na, inst: nil } + end + act[:redirect]=if mod.inspect =~/"--redirect=/ + base_pth=mod.join(';').gsub(/^.*--redirect=['"]?(.+?)(?:['"]?;.+)?$/,'\1') + { bool: true, set: :on, inst: base_pth } + elsif mod.inspect =~/"--redirect/ + { bool: true, set: :on, inst: @base_path } + else + { bool: false, set: :na, inst: nil } + end + act[:switch]=if mod.inspect =~/"--switch-off=/ + off_list=mod.join(';').gsub(/^.*--switch-off=['"]?(.+?)(?:['"];.+)?$/,'\1') + off_list=off_list.scan(/[^,;\s]+/) + { bool: false, set: :off, off: off_list} + else { bool: true, set: :na, off: [] } + end + act[:default_language]=if mod.inspect =~/"--(?:default-)?language[-=](\S{2})"/ + { set: :on, code: $1 } + elsif lng_base + { set: :on, code: lng_base } + else { set: :na, code: 'en' } + end + act[:i18n]=if mod.inspect =~/"(?:--monolingual|--i18n-mono(?:lingual)?)"/ #if monolingual possible outputs output_by :filename & :filetype only, without language code in default language name; give warning of conflict settings if monolingual & :language selected + @lingual=:mono + { set: :mono } + elsif mod.inspect =~/"(?:--multilingual|--i18n-multi(?:lingual)?)"/ + @lingual=:multi + { set: :multi } + else { set: :na } + end + act[:output_by]=if mod.inspect =~/"--(?:output-)?by-language"/ + @dir_structure_by=:language + { set: :language } + elsif mod.inspect =~/"--(?:output-)?by-filename"/ + @dir_structure_by=:filename + { set: :filename } + elsif mod.inspect =~/"--(?:output-)?by-filetype"/ + @dir_structure_by=:filetype + { set: :filetype } + else { set: :na } + end + act[:ocn]=if mod.inspect =~/"--ocn"|"--inc-ocn"|"--numbering"|"--inc-numbering"/ + { bool: true, set: :on } + elsif mod.inspect =~/"--no-ocn"|"--exc-ocn"|"--no-numbering"|"--exc-numbering"/ \ + || act[:switch][:off].inspect =~/"ocn"|"--numbering"/ + { bool: false, set: :off } + else { bool: true, set: :na } + end + act[:toc]=if mod.inspect =~/"--inc-toc"/ + { bool: true, set: :on } + elsif mod.inspect =~/"--(?:exc|no)-toc"/ \ + || act[:switch][:off].inspect =~/"toc"/ + { bool: false, set: :off } + else { bool: true, set: :na } + end + act[:minitoc]=if mod.inspect =~/"--inc-minitoc"/ + { bool: true, set: :on } + elsif mod.inspect =~/"--(?:exc|no)-minitoc"/ \ + || act[:switch][:off].inspect =~/"minitoc"/ + { bool: false, set: :off } + else { bool: true, set: :na } + end + act[:links_to_manifest]=if mod.inspect =~/"--inc-links-to-manifest"|"--inc-manifest-links"/ + { bool: true, set: :on } + elsif mod.inspect =~/"--(?:exc|no)-manifest"/ \ + || act[:switch][:off].inspect =~/"manifest"/ #place lower + { bool: false, set: :off } + elsif mod.inspect =~/"--(?:exc|no)-links-to-manifest"|"--(?:exc|no)-manifest-links"/ \ + || act[:switch][:off].inspect =~/"links_to_manifest"|"manifest_links"|"--(?:exc|no)-manifest"/ \ + || mod.inspect =~/"--(?:redirect|dump)/ + { bool: false, set: :off } + else { bool: true, set: :na } + end + act[:manifest_minitoc]=if mod.inspect =~/"--inc-manifest-minitoc"|"--inc-minitoc"/ + { bool: true, set: :on } + elsif mod.inspect =~/"--(?:exc|no)-manifest-minitoc"|"--(?:exc|no)-minitoc"/ \ + || act[:switch][:off].inspect =~/"manifest_minitoc"|"minitoc"/ + #|| mod.inspect =~/"--(?:redirect|dump)/ + { bool: false, set: :off } + else { bool: true, set: :na } + end + act[:metadata]=if mod.inspect =~/"--inc-metadata"/ + { bool: true, set: :on } + elsif mod.inspect =~/"--(?:exc|no)-metadata"/ \ + || act[:switch][:off].inspect =~/"metadata"/ + { bool: false, set: :off } + else { bool: true, set: :na } + end + act[:html_minitoc]=if mod.inspect =~/"--inc-html-minitoc"|"--inc-minitoc"/ + { bool: true, set: :on } + elsif mod.inspect =~/"--(?:exc|no)-html-minitoc"|"--(?:exc|no)-minitoc"/ \ + || act[:switch][:off].inspect =~/"html_minitoc"|"minitoc"/ + { bool: false, set: :off } + else { bool: true, set: :na } + end + act[:html_navigation]=if mod.inspect =~/"--inc-html-navigation"|"--inc-navigation"/ + { bool: true, set: :on } + elsif mod.inspect =~/"--(?:exc|no)-html-navigation"|"--(?:exc|no)-navigation"/ \ + || act[:switch][:off].inspect =~/"html_navigation"|"nav"/ + { bool: false, set: :off } + else { bool: true, set: :na } + end + act[:html_navigation_bar]=if mod.inspect =~/"--inc-html-navigation-bar"|"--inc-navigation-bar"/ + { bool: true, set: :on } + elsif mod.inspect =~/"--(?:exc|no)-html-navigation-bar"|"--(?:exc|no)-navigation-bar"/ \ + || act[:switch][:off].inspect =~/"html_navigation_bar"|"navbar"/ + { bool: false, set: :off } + else { bool: true, set: :na } + end + act[:segsubtoc]=if mod.inspect =~/"--inc-segsubtoc"/ + { bool: true, set: :on } + elsif mod.inspect =~/"--(?:exc|no)-segsubtoc"/ \ + || act[:switch][:off].inspect =~/"segsubtoc"/ + { bool: false, set: :off } + else { bool: true, set: :na } + end + act[:search_form]=if mod.inspect =~/"--inc-search-form"/ + { bool: true, set: :on } + elsif mod.inspect =~/"--(?:exc|no)-search-form"/ \ + || act[:switch][:off].inspect =~/"search_form"|"search"/ + { bool: false, set: :off } + else { bool: true, set: :na } + end + act[:html_search_form]=if mod.inspect =~/"--inc-html-search-form"|"--inc-search-form"/ + { bool: true, set: :on } + elsif mod.inspect =~/"--(?:exc|no)-html-search-form"|"--(?:exc|no)-search-form"/ \ + || act[:switch][:off].inspect =~/"html_search_form"|"search_form"|"search"/ + { bool: false, set: :off } + else { bool: true, set: :na } + end + act[:html_right_pane]=if mod.inspect =~/"--inc-html-right-pane"|"--inc-right-pane"|"--inc-html-right-column"|"--inc-right-column"/ + { bool: true, set: :on } + elsif mod.inspect =~/"--(?:exc|no)-html-right-pane"|"--(?:exc|no)-right-pane"|"--(?:exc|no)-html-right-column"|"--(?:exc|no)-right-column"/ \ + || act[:switch][:off].inspect =~/"html_right_pane"|"html_right_column"|"promo"/ + { bool: false, set: :off } + else { bool: true, set: :na } + end + act[:html_top_band]=if mod.inspect =~/"--inc-html-top-band"|"--inc-top-band"/ + { bool: true, set: :on } + elsif mod.inspect =~/"--(?:exc|no)-html-top-band"|"--(?:exc|no)-top-band"/ \ + || act[:switch][:off].inspect =~/"html-top-band"|"top-band"/ + { bool: false, set: :off } + else { bool: true, set: :na } + end + act[:html]=if mod.inspect =~/"--html-strict"/ \ + or ((cmd =~/h/ || mod.inspect =~/"--html"/) \ + && mod.inspect =~/"--strict"/) + act[:html_strict]={ bool: true, set: :on } + act[:html_scroll]={ bool: true, set: :on } + act[:html_seg]={ bool: true, set: :on } + { bool: true, set: :on } + elsif (cmd =~/h/ \ + || mod.inspect =~/"--html"/) + act[:html_strict]={ bool: false, set: :off } + act[:html_scroll]={ bool: true, set: :on } + act[:html_seg]={ bool: true, set: :on } + { bool: true, set: :on } + else + act[:html_strict]=(mod.inspect =~/"--strict"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:html_scroll]=(mod.inspect =~/"--html-scroll"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:html_seg]=(mod.inspect =~/"--html-seg"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + { bool: false, set: :na } + end + act[:concordance]=(cmd =~/w/ \ + || mod.inspect =~/"--concordance"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:images]=(cmd =~/j/ \ + || mod.inspect =~/"--images"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + if (cmd =~/p/ \ + || mod.inspect =~/"--pdf"/) + if mod.inspect =~/"--portrait"/ + act[:pdf]= { bool: false, set: :na } + act[:pdf_l]={ bool: false, set: :na } + act[:pdf_p]={ bool: true, set: :on } + elsif mod.inspect =~/"--landscape"/ + act[:pdf]= { bool: false, set: :na } + act[:pdf_l]={ bool: true, set: :on } + act[:pdf_p]={ bool: false, set: :na } + else + act[:pdf]= { bool: true, set: :on } + act[:pdf_l]={ bool: true, set: :on } + act[:pdf_p]={ bool: true, set: :on } + end + else + act[:pdf]= { bool: false, set: :na } + act[:pdf_p]= { bool: false, set: :na } + act[:pdf_l]= { bool: false, set: :na } + act[:pdf_a4]= { bool: false, set: :na } + act[:pdf_a5]= { bool: false, set: :na } + act[:pdf_b5]= { bool: false, set: :na } + act[:pdf_letter]={ bool: false, set: :na } + act[:pdf_legal]= { bool: false, set: :na } + end + if act[:pdf][:set]==:on \ + or act[:pdf_p][:set]==:on \ + or act[:pdf_l][:set]==:on + act[:pdf_a4]=if mod.inspect =~/"--a4"|--papersize-a4"/ \ + or mod.inspect =~/"--papersize=\S*a4\b\S*"/ #--papersize=a4,a5 + { bool: true, set: :on } + else + { bool: false, set: :na } + end + act[:pdf_a5]=if mod.inspect =~/"--a5"|"--papersize-a5"/ \ + or mod.inspect =~/"--papersize=\S*a5\b\S*"/ #--papersize=a4,a5 + { bool: true, set: :on } + else + { bool: false, set: :na } + end + act[:pdf_b5]=if mod.inspect =~/"--b5"|"--papersize-b5"/ \ + or mod.inspect =~/"--papersize=\S*b5\b\S*"/ + { bool: true, set: :on } + else + { bool: false, set: :na } + end + act[:pdf_letter]=if mod.inspect =~/"--letter"|"--papersize-letter"/ \ + or mod.inspect =~/"--papersize=\S*letter\b\S*"/ + { bool: true, set: :on } + else + { bool: false, set: :na } + end + act[:pdf_legal]=if mod.inspect =~/"--legal"|"--papersize-legal"/ \ + or mod.inspect =~/"--papersize=\S*legal\b\S*"/ + { bool: true, set: :on } + else + { bool: false, set: :na } + end + end + act[:epub]=(cmd =~/e/ \ + || mod.inspect =~/"--epub"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:odt]=if cmd =~/o/ \ + or mod.inspect =~/"--odt"|"--odf"|"--odt-(?:ocn|numbering)"|"--odf-(?:ocn|numbering)"/ + act[:odt_ocn]=if (mod.inspect =~/"--odt-(?:ocn|numbering)"|"--odf-(?:ocn|numbering)"/ \ + or mod.inspect =~/"--ocn"|"--inc-ocn"|"--numbering"|"--inc-numbering"/) + { bool: true, set: :on } + elsif mod.inspect =~/"--no-ocn"|"--exc-ocn"|"--no-numbering"|"--exc-numbering"/ + { bool: false, set: :off } + else + { bool: false, set: :na } + end + { bool: true, set: :on } + else + { bool: false, set: :na } + end + act[:xml_sax]=(cmd =~/x/ \ + || mod.inspect =~/"--xml-sax"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:xml_dom]=(cmd =~/X/ \ + || mod.inspect =~/"--xml-dom"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:xml_docbook_book]=(cmd =~/d/ \ + || mod.inspect =~/"--docbook"|"--docbook-book"|"--xml-docbook"|"--xml-docbook_book"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:xml_fictionbook]=(cmd =~/f/ \ + || mod.inspect =~/"--fictionbook"|"--xml-fictionbook"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:xml_scaffold_structure_sisu]=mod.inspect =~/"--xml-scaffold"|"--xml-scaffold-sisu"/ \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:xml_scaffold_structure_collapse]=mod.inspect =~/"--xml-scaffold-collapse"/ \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:xhtml]=(cmd =~/b/ \ + || mod.inspect =~/"--xhtml"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:txt]=if cmd =~/[at]/ \ + or mod.inspect =~/"--txt"|"--text"|"--plaintext"|"--txt-(?:ocn|numbering)"|"--text-(?:ocn|numbering)"|"--plaintext-(?:ocn|numbering)"/ + act[:txt_ocn]=if (mod.inspect =~/"--txt-(?:ocn|numbering)"|"--text-(?:ocn|numbering)"|"--plaintext-(?:ocn|numbering)"/ \ + or mod.inspect =~/"--ocn"|"--inc-ocn"|"--numbering"|"--inc-numbering"/) + { bool: true, set: :on } + elsif mod.inspect =~/"--no-ocn"|"--exc-ocn"|"--no-numbering"|"--exc-numbering"/ + { bool: false, set: :off } + else + { bool: false, set: :na } + end + { bool: true, set: :on } + else + { bool: false, set: :na } + end + act[:txt_textile]=(mod.inspect =~/"--textile"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:txt_asciidoc]=(mod.inspect =~/"--asciidoc"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:txt_markdown]=(mod.inspect =~/"--markdown"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:txt_rst]=(mod.inspect =~/"--rst"|"--rest"|"--restructuredtext"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:manpage]=(cmd =~/i/ \ + || mod.inspect =~/"--manpage"|"--man"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:texinfo]=(cmd =~/I/ \ + || mod.inspect =~/"--texinfo"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:psql]=if mod.inspect =~/"--pg-\S+"/ \ + or ((mod.inspect =~/"--pg"/) \ + && (mod.inspect \ + =~/"--createdb"|"--create(?:all)?"|"--dropall"|"--recreate(?:all)?"|"--import"|"--update"|"--remove"/)) + act[:psql_createdb]=if mod.inspect \ + =~/"--pg-createdb"|"--createdb"/ + { bool: true, set: :on } + else + { bool: false, set: :na } + end + if mod.inspect \ + =~/"--pg-recreate(?:all)?"|"--recreate(?:all)?"/ + act[:psql_drop]={ bool: true, set: :on } + act[:psql_create]={ bool: true, set: :on } + else + act[:psql_drop]=if mod.inspect \ + =~/"--pg-dropall"|"--dropall"/ + { bool: true, set: :on } + else + { bool: false, set: :na } + end + act[:psql_create]=if mod.inspect \ + =~/"--pg-create(?:all)?"|"--create(?:all)?"/ + { bool: true, set: :on } + else + { bool: false, set: :na } + end + end + act[:psql_import]=if mod.inspect \ + =~/"--pg-import"|"--import"/ + { bool: true, set: :on } + else + { bool: false, set: :na } + end + act[:psql_update]=if mod.inspect \ + =~/"--pg-update"|"--update"/ + act[:psql_remove]={ bool: true, set: :on } + { bool: true, set: :on } + else + act[:psql_remove]=if mod.inspect \ + =~/"--pg-remove"|"--remove"/ + { bool: true, set: :on } + else + { bool: false, set: :na } + end + { bool: false, set: :na } + end + { bool: true, set: :on } + else + act[:psql_createdb]= + { bool: false, set: :na } + act[:psql_drop]= + { bool: false, set: :na } + act[:psql_create]= + { bool: false, set: :na } + act[:psql_import]= + { bool: false, set: :na } + act[:psql_update]= + { bool: false, set: :na } + act[:psql_remove]= + { bool: false, set: :na } + { bool: false, set: :na } + end + act[:sqlite]=if (mod.inspect =~/"--sqlite-\S+"/) \ + or ((mod.inspect =~/"--sqlite"/) \ + && (mod.inspect \ + =~/"--createdb"|"--create(?:all)?"|"--dropall"|"--recreate(?:all)?"|"--import"|"--update"|"--remove"/)) + act[:sqlite_createdb]=if mod.inspect \ + =~/"--sqlite-createdb"|"--createdb"/ + { bool: true, set: :on } + else + { bool: false, set: :na } + end + if mod.inspect \ + =~/"--sqlite-recreate(?:all)?"|"--recreate(?:all)?"/ + act[:sqlite_drop]={ bool: true, set: :on } + act[:sqlite_create]={ bool: true, set: :on } + else + act[:sqlite_create]=if mod.inspect \ + =~/"--sqlite-create(?:all)?"|"--create(?:all)?"/ + { bool: true, set: :on } + else + { bool: false, set: :na } + end + act[:sqlite_drop]=if mod.inspect \ + =~/"--sqlite-dropall"|"--dropall"/ + { bool: true, set: :on } + else + { bool: false, set: :na } + end + end + act[:sqlite_import]=if mod.inspect \ + =~/"--sqlite-import"|"--import"/ + { bool: true, set: :on } + else + { bool: false, set: :na } + end + act[:sqlite_update]=if mod.inspect \ + =~/"--sqlite-update"|"--update"/ + act[:sqlite_remove]={ bool: true, set: :on } + { bool: true, set: :on } + else + act[:sqlite_remove]=if mod.inspect \ + =~/"--sqlite-remove"|"--sqlite-remove"/ + { bool: true, set: :on } + else + { bool: false, set: :na } + end + { bool: false, set: :na } + end + { bool: true, set: :on } + else + act[:sqlite_createdb]= + { bool: false, set: :na } + act[:sqlite_drop]= + { bool: false, set: :na } + act[:sqlite_create]= + { bool: false, set: :na } + act[:sqlite_import]= + { bool: false, set: :na } + act[:sqlite_update]= + { bool: false, set: :na } + act[:sqlite_remove]= + { bool: false, set: :na } + { bool: false, set: :na } + end + act[:sqlite_discrete]=mod.inspect =~/"--sql"|"--sqlite"/ \ + && (mod.inspect !~/"--createdb"|"--create(?:all)?"|"--dropall"|"--recreate(?:all)?"|"--import"|"--update"|"--remove"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:harvest]=(mod.inspect =~/"--harvest"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:po4a]=(cmd =~/P/ \ + || mod.inspect =~/"--po4a"|"--pot?"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:git]=(cmd =~/g/ \ + || mod.inspect =~/"--git"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:hash_digests]=(cmd =~/N/ \ + || mod.inspect =~/"--digests?"|"--hash-digests"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:pdf_font_size]=if mod.inspect =~/"--(?:pdf-)?font-?size[=-](\d{1,2})(?:pt)?"/ + $1 + else :na + end + act[:pdf_hyperlink_colors]=if mod.inspect =~/"--pdf-hyperlinks-(?:mono(?:chrome)?|no-color)"/ + :mono + elsif mod.inspect =~/"--pdf-hyperlinks-color"/ + :color + else :na + end + act[:hash_digest_algo]=if mod.inspect =~/"--hash-(?:sha)?512"/ + :sha512 + elsif mod.inspect =~/"--hash-(?:sha)?256"/ + :sha256 + elsif mod.inspect =~/"--hash-md5"/ + :md5 + else :na + end + act[:sample_search_form]=(cmd =~/F/ \ + || mod.inspect =~/"--sample-search-form"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:webrick]=(cmd =~/W/ \ + || mod.inspect =~/"--webrick"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:share_source]=(cmd =~/s/ \ + || mod.inspect =~/"--source"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:sisupod]=(cmd =~/S/ \ + || mod.inspect =~/"--sisupod"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:scp]=(cmd =~/r/ \ + || mod.inspect =~/"--scp"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:rsync]=(cmd =~/R/ \ + || mod.inspect =~/"--rsync"|"--remote"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:zap]=(cmd =~/Z/ \ + || mod.inspect =~/"--zap"|"--delete"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:urls_all]=(cmd =~/U/ \ + || mod.inspect =~/"--urls-all"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:urls_selected]=(cmd =~/u/ \ + || mod.inspect =~/"--urls"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:sitemap]=(cmd =~/Y/ \ + || mod.inspect =~/"--sitemap"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:qrcode]=(cmd =~/Q/ \ + || mod.inspect =~/"--qrcode"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:help]=(mod.inspect =~/"--help/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:ao]=if (cmd =~/m/ \ + || mod.inspect =~/"--ao"|"--dal"/) + { bool: true, set: :on } + elsif (act[:txt][:set]==:on \ + || act[:txt_textile][:set]==:on \ + || act[:txt_asciidoc][:set]==:on \ + || act[:txt_markdown][:set]==:on \ + || act[:txt_rst][:set]==:on \ + || act[:xhtml][:set]==:on \ + || act[:epub][:set]==:on \ + || act[:html][:set]==:on \ + || act[:html_seg][:set]==:on \ + || act[:html_scroll][:set]==:on \ + || act[:texinfo][:set]==:on \ + || act[:manpage][:set]==:on \ + || act[:hash_digests][:set]==:on \ + || act[:odt][:set]==:on \ + || act[:pdf][:set]==:on \ + || act[:pdf_p][:set]==:on \ + || act[:pdf_l][:set]==:on \ + || act[:qrcode][:set]==:on \ + || act[:share_source][:set]==:on \ + || act[:sisupod][:set]==:on \ + || act[:concordance][:set]==:on \ + || act[:xml_dom][:set]==:on \ + || act[:xml_sax][:set]==:on \ + || act[:xml_docbook_book][:set]==:on \ + || act[:xml_fictionbook][:set]==:on \ + || act[:xml_scaffold_structure_sisu][:set]==:on \ + || act[:xml_scaffold_structure_collapse][:set]==:on ) + { bool: true, set: :on } + #if cmd !~/[mn]/ + # extra+=if cmd =~/[abegHhIiLNOoPpQTtwXxyz]/ \ + # and cmd !~/[mn]/ + # 'm' #% add ao + #elsif (act[:txt][:set]==:on \ + # { bool: true, set: :on } + # elsif ((cmd =~/[Dd]/ \ + # or (mod.inspect =~/--(?:(?:sq)?lite|pg(?:sql)?)/)) \ + # and mod.inspect !~/(?:remove|(?:(?:re)?create(?:all)?|dropall|drop)$)/) \ + # and cmd !~/[mn]/ + # 'm' #% add ao + else + { bool: false, set: :na } + end + act[:manifest]=if mod.inspect =~/"--inc-manifest"/ + { bool: true, set: :on } + elsif mod.inspect =~/"--(?:exc|no)-manifest"/ \ + || act[:switch][:off].inspect =~/"manifest"/ + { bool: false, set: :off } + elsif (cmd =~/y/ \ + || mod.inspect =~/"--manifest"/) + { bool: true, set: :on } + elsif (act[:txt][:set]==:on \ + || act[:txt_textile][:set]==:on \ + || act[:txt_asciidoc][:set]==:on \ + || act[:txt_markdown][:set]==:on \ + || act[:txt_rst][:set]==:on \ + || act[:xhtml][:set]==:on \ + || act[:epub][:set]==:on \ + || act[:html][:set]==:on \ + || act[:html_seg][:set]==:on \ + || act[:html_scroll][:set]==:on \ + || act[:texinfo][:set]==:on \ + || act[:manpage][:set]==:on \ + || act[:hash_digests][:set]==:on \ + || act[:odt][:set]==:on \ + || act[:pdf][:set]==:on \ + || act[:pdf_p][:set]==:on \ + || act[:pdf_l][:set]==:on \ + || act[:qrcode][:set]==:on \ + || act[:share_source][:set]==:on \ + || act[:sisupod][:set]==:on \ + || act[:concordance][:set]==:on \ + || act[:xml_dom][:set]==:on \ + || act[:xml_sax][:set]==:on \ + || act[:xml_docbook_book][:set]==:on \ + || act[:xml_fictionbook][:set]==:on \ + || act[:xml_scaffold_structure_sisu][:set]==:on \ + || act[:xml_scaffold_structure_collapse][:set]==:on ) + { bool: true, set: :on } + ## if cmd !~/y/ + ## extra+=if cmd =~/[abeHhIiNopQSstwXxz]/ \ + ## and cmd !~/y/ + ## 'ym' #% add manifest + #elsif (act[:txt][:set]==:on \ + # { bool: true, set: :on } + # elsif (cmd =~/[Dd]/ \ + # or mod.inspect =~/--(?:(?:sq)?lite|pg(?:sql)?)/) \ + # and files[0] !~/^remove$/ \ + # and cmd !~/y/ + # 'ym' #% add manifest + else { bool: true, set: :na } + end + act[:console_messages] = '' + act[:verbose]=if (cmd =~/v/ \ + || mod.inspect =~/"--verbose"/) + act[:console_messages] << ' --verbose ' + { bool: true, set: :on } + else + { bool: false, set: :na } + end + act[:verbose_plus]=if (cmd =~/V/ \ + || mod.inspect =~/"--very-verbose"/) + act[:console_messages] << ' --very-verbose ' + { bool: true, set: :on } + else + { bool: false, set: :na } + end + act[:version_info]=if (cmd =~/[vVM]/ \ + || mod.inspect =~/"--verbose"|"--maintenance"/) + act[:console_messages] << ' --maintenance ' + { bool: true, set: :on } + else + { bool: false, set: :na } + end + act[:quiet]=if (cmd =~/q/ \ + || mod.inspect =~/"--quiet"/) + act[:console_messages] << ' --quiet ' + { bool: true, set: :on } + else + { bool: false, set: :na } + end + act[:color_state]=if mod.inspect =~/"--color-on"|"--color"/ + act[:console_messages] << ' --color-on ' + { bool: true, set: :on } + elsif (cmd =~/k/ \ + || mod.inspect =~/"--color-off"/) + act[:console_messages] << ' --color-off ' + { bool: false, set: :off } + else { bool: true, set: :na } #fix default color + end +# act[:color_toggle]=if cmd =~/c/ \ +# or mod.inspect =~/"--color-toggle"/ +# true +# else false +# end + act[:maintenance]=if (cmd =~/M/ \ + || mod.inspect =~/"--maintenance|--keep-processing-files"/) + act[:console_messages] << ' --maintenance ' + { bool: true, set: :on } + else + { bool: false, set: :na } + end + act[:profile]=if (cmd =~/E/ \ + || mod.inspect =~/"--profile"/) + act[:console_messages] << ' --color-off ' + { bool: true, set: :on } + else + { bool: false, set: :na } + end + @act=act + end + end + def cmd + @cmd + end + def mod + @mod + end + def act + @@act + end + def files_mod + files_mod=files + @files_mod=files_mod + end + def f_pth + @f_pth + end + def pth + @pth + end + def sub_location + pth.gsub(/#{base_path}/,'') + end + def lng + @lng + end + def lng_base + @lng_base + end + def fno + @fno=(fns.nil? || fns.empty?) \ + ? '' \ + : (fns[/(.+?(?:sst|ssm))(?:\.sst)?/,1]) + end + def fng + @fng=(fno.nil? || fno.empty?) \ + ? '' \ + : (fno.gsub(/(?:~(?:#{Px[:lng_lst_rgx]}))?(\.ss[tm])$/,'\1')) + end + def fns + @fns + end + def fnl + @fns.gsub(/(\S+?)((?:\.ssm)?\.sst)/,"\\1.#{lng}\\2") + end + def what + @what + end + def fnb + (fns.nil? || fns.empty?) \ + ? '' \ + : (fns[/(.+?)\.(?:(?:-|ssm\.)?sst|ssm)$/,1]) + end + def fnc + @fnc=(@fns =~/\.(?:ssm\.sst|ssm)$/) \ + ? fnb + '.ssm.sst' + : @fns + end + def fncb + @fncb=(@fns =~/(?:\~\S{2,3})?\.(?:ssm\.sst|ssm)$/) \ + ? fnb + '.ssm.sst' + : @fns.gsub(/(?:\~\S{2,3})?(\.sst)$/,'\1') + end + end +end +__END__ +note usually named @opt is carried in dp document parameters (usually as @md.opt), @opt is a +subset of @md where @md is passed, contents of @opt are available as @md.opt +passing @opt as well is duplication check for fns & fnb diff --git a/lib/sisu/v5/manifest.rb b/lib/sisu/v5/manifest.rb index 1afe1deb..f2a9e748 100644 --- a/lib/sisu/v5/manifest.rb +++ b/lib/sisu/v5/manifest.rb @@ -61,15 +61,15 @@ =end module SiSU_Manifest - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env require_relative 'prog_text_translation' # prog_text_translation.rb - require_relative 'particulars' # particulars.rb + require_relative 'se_hub_particulars' # se_hub_particulars.rb include SiSU_Particulars require_relative 'html_minitoc' # html_minitoc.rb require_relative 'html' # html.rb include SiSU_HTML_Format - require_relative 'param' # param.rb + require_relative 'dp' # dp.rb include SiSU_Param require_relative 'i18n' # i18n.rb include SiSU_Viz diff --git a/lib/sisu/v5/manpage.rb b/lib/sisu/v5/manpage.rb index a59ba835..0bcf1799 100644 --- a/lib/sisu/v5/manpage.rb +++ b/lib/sisu/v5/manpage.rb @@ -63,7 +63,7 @@ =end module SiSU_Manpage require_relative 'ao' # ao.rb - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env include SiSU_Param include SiSU_Viz diff --git a/lib/sisu/v5/manpage_format.rb b/lib/sisu/v5/manpage_format.rb index 7a9ea98b..c46a3c7b 100644 --- a/lib/sisu/v5/manpage_format.rb +++ b/lib/sisu/v5/manpage_format.rb @@ -61,7 +61,7 @@ =end module SiSU_ManpageFormat - require_relative 'param' # param.rb + require_relative 'dp' # dp.rb include SiSU_Param include SiSU_Viz class ParagraphNumber diff --git a/lib/sisu/v5/options.rb b/lib/sisu/v5/options.rb deleted file mode 100644 index eede713a..00000000 --- a/lib/sisu/v5/options.rb +++ /dev/null @@ -1,1399 +0,0 @@ -# encoding: utf-8 -=begin - - * Name: SiSU - - * Description: a framework for document structuring, publishing and search - - * Author: Ralph Amissah - - * Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, - All Rights Reserved. - - * License: GPL 3 or later: - - SiSU, a framework for document structuring, publishing and search - - Copyright (C) Ralph Amissah - - This program is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the Free - Software Foundation, either version 3 of the License, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - more details. - - You should have received a copy of the GNU General Public License along with - this program. If not, see . - - 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: - - - * Git - - - - * Ralph Amissah - - - - ** Description: SiSU information Structuring Universe, command line options - parsing - -=end -module SiSU_Commandline - begin - require 'pathname' - rescue LoadError - SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('pathname NOT FOUND (LoadError)') - end - require_relative 'sysenv' # sysenv.rb - require_relative 'param_make' # param_make.rb - class HeaderCommon - def sisu_document_make_instructions(make_instruct_array=:nil) - @pagenew= - @pagebreak= - @pageline= - @toc= - @lv1=@lv2=@lv3=@lv4=@lv5=@lv6= - @num_top= - @i18n= - @man_section= - @emphasis_set_to= - @bold_match_list= - @italics_match_list= - @substitution_match_list= - @footer_links= - @home_button_links= - @links= - nil - make_instruct_array=make_instruct_array==:nil \ - ? SiSU_Env::GetInit.new.sisu_document_make.makefile_read - : make_instruct_array - @makeset=false - if make_instruct_array - make_instruct_array.each do |para| #% scan document - if para =~/^(?:@make:|@links:)[+-]?\s/ - case para - when /^@make:(.+)/m #% header processing - make - @env=SiSU_Env::InfoEnv.new - @make=SiSU_Param_Make::MdMake.new($1.strip,@opt,@env).make - makes=SiSU_Param_Make::MakeHead.new(@make).make_instruct - @makeset=true - @pagenew=makes[:pagenew] - @pagebreak=makes[:pagenew] - @pageline=makes[:pageline] - @toc=makes[:toc] - @lv1=makes[:lv1] - @lv2=makes[:lv2] - @lv3=makes[:lv3] - @lv4=makes[:lv4] - @lv5=makes[:lv5] - @lv6=makes[:lv6] - @num_top=makes[:num_top] - @i18n=makes[:i18n] - @man_section=makes[:man_section] - @emphasis_set_to=makes[:emphasis_set_to] - @bold_match_list=makes[:bold_match_list] - @italics_match_list=makes[:italics_match_list] - @substitution_match_list=makes[:substitution_match_list] - @footer_links=makes[:footer_links] - @home_button_links=makes[:home_button_links] - @home_button_image=makes[:home_button_image] - @cover_image=makes[:cover_image] - when /^@links:(.+)/m #% header processing - make - make_links=SiSU_Param::Parameters::MdMake.new($1.strip,@opt,@env).make_links - @links,@links_append=make_links.links,make_links.append? - end - end - end #% here endeth the common header loop - end - { makeset: @makeset, - pagenew: @pagenew, - pagebreak: @pagebreak, - pageline: @pageline, - toc: @toc, - lv1: @lv1, - lv2: @lv2, - lv3: @lv3, - lv4: @lv4, - lv5: @lv5, - lv6: @lv6, - num_top: @num_top, - i18n: @i18n, - man_section: @man_section, - emphasis_set_to: @emphasis_set_to, - bold_match_list: @bold_match_list, - italics_match_list: @italics_match_list, - substitution_match_list: @substitution_match_list, - footer_links: @footer_links, - home_button_links: @home_button_links, - home_button_image: @home_button_image, - cover_image: @cover_image, - links: @links, - links_append: @links_append - } - end - end - class Options - attr_accessor :cmd,:mod,:act,:dir_structure_by,:lingual,:f_pths,:files,:files_mod,:call_path,:base_path,:base_stub,:sub_location,:image_src_path,:paths,:lngs,:f_pth,:pth,:fno,:fns,:fnb,:fnc,:fng,:fncb,:lng,:lng_base,:what,:make_instructions,:make_instructions_pod - @@act=nil - def initialize(a,call_path) - @cmd=@f_pth=@pth=@fno=@fns=@fnb=@fnc=@fng=@fncb=@what=@lng=@lng_base=@call_path=@base_path=@base_stub=@image_src_path=@sub_location='' - @f_pths,@files,@files_mod,@paths,@mod,@act=Array.new(5){[]} - @env=SiSU_Env::InfoEnv.new - @lng_base=@env.language_default_set - @dir_structure_by=SiSU_Env::EnvCall.new.output_dir_structure.by? - @lingual=SiSU_Env::EnvCall.new.mono_multi_lingual? - @call_path=call_path - pth=SiSU_Utils::Path.new(call_path) - @base_path=pth.base_markup - @base_stub=pth.base_markup_stub - @image_src_path=pth.image_src - @a=sisu_glob_rules(a) - @a.freeze - @make_instructions=HeaderCommon.new.sisu_document_make_instructions - @make_instructions_pod=nil - init - end - def find_all(find_flag,opt) - if find_flag - x=Dir.glob('*.ss[tm]') - Px[:lng_lst].each do |d| - if FileTest.directory?(d) - x << Dir.glob("#{d}/*.ss[tm]") - end - end - x=x.flatten - opt + x - end - end - def find_select(find_flag,opt) - if find_flag - x=[] - if opt.inspect =~/"[a-zA-Z][a-zA-Z0-9._-]+?"/ - opt.each do |g| - x <<=if g =~/.ss[tm]/ - Dir.glob("*#{g}") - else - Dir.glob("*#{g}*.ss[tm]") - end - Px[:lng_lst].each do |d| - if FileTest.directory?(d) - x <<=if g =~/.ss[tm]/ - Dir.glob("#{d}/*#{g}") - else - Dir.glob("#{d}/*#{g}*.ss[tm]") - end - end - end - end - end - x.flatten - end - end - def sisu_glob_rules(a) - a=if a.inspect =~/"-[A-Za-z0-9]*[fG]/ \ - or a.inspect =~/"--find"|"--glob"/ - b,f=[],[] - find_flag=false - a.each do |y| - if y =~ /^-/ - if y =~/^-/ \ - && y =~/[fG]|--find|--glob/ - find_flag=true - end - b << y - end - if find_flag \ - && y !~ /^-/ \ - && y =~ /\S+/ - if y !~/\// - f << y - else - find_flag=false - puts %{sub-directories "#{y}" cannot be provided for --find or --glob at this time} - end - end - end - r=Px[:lng_lst_rgx].gsub(/\|#{lng_base}\|/,'|') - @lang_regx=%r{(?:#{r})} - if find_flag - (f.length > 0) \ - ? (b + find_select(find_flag,f)) - : find_all(find_flag,b) - elsif a.inspect =~/"(?:-\S+?|--\S+?)"/ \ - && a.inspect =~/"#{@lang_regx}\/?"/ \ - && a.inspect =~/"#{lng_base}\/\S+?\.ss[tm]"/ - init_selected_lang_dirs(a) - else b - end - else a - end - end - def init_selected_lang_dirs(a) - @z=[] - a.each do |y| - if y =~/^#{lng_base}\/(\S+?\.ss[tm])$/ - @fn=$1 - @z << y - elsif y =~/^#{@lang_regx}\/?$/ - @z << "#{y}/#{@fn}" - else @z << y - end - end - @z - end - def init - a=@a - if a.length > 0 - s=expand_numeric_shortcuts(a) - q=set_files_and_paths_and_general_extract(s) - @cmd,@mod=opt_cmd_and_mod_adjust(q[:cmd],q[:mod]) - @what=q[:what] unless q[:what].empty? - @paths = q[:paths] - @files = q[:files] - @f_pths = q[:f_pths] - @lngs = q[:lngs] - if @files.length > 0 \ - and @cmd.empty? \ - and @mod.length==0 #% if no other action called on filename given, default is sisu --v5 -0 [filename(s)] configured as flag default - shortcut=SiSU_Env::InfoProcessingFlag.new - @mod=['--v5'] - @cmd=shortcut.cf_0 + ' --dal' - end - if @cmd =~/[vVM]/ \ - && @cmd !~/-[ku]*v[ku]*$/ - SiSU_Screen::Ansi.new( - @cmd, - "\tsisu " + @cmd + ' ' + @mod.join(' ') + ' ' + @files.join(' ') + "\n" - ).print_brown - end - end - @@act ? @act=@@act : @@act=@act=opt_act - self - end - def sisu_document_make_pod - def makefile_name - SiSU_Env::GetInit.new.sisu_document_make.makefile_name - end - def makefile(pod_make_path) - "#{pod_make_path}/#{makefile_name}" - end - def makefile_read(pod_make_path) - if FileTest.file?(makefile(pod_make_path)) - sisu_doc_makefile=IO.read(makefile(pod_make_path), mode: 'r:utf-8') - sisu_doc_makefile.split(/\s*\n\s*\n/m) - else nil - end - end - self - end - def set_files_and_paths_and_general_extract(s) - c,w='','' - m,f,pth,lng,lngs=[],[],[],[],[] - lng_is='' - a=s.split(/\s+/) - r_l=Px[:lng_lst].join('|') - a.uniq.each do |x| - if x =~/^-[a-z0-5]+/i \ - or x =~/^--\S+/ - if x =~/^-([a-z0-5]+)/i - c << $1 - end - if x =~/^--\S+/ - m << x - end - elsif x =~ /(?:\.(?:(?:-|ssm\.)?sst(?:\.xml)?|ssm|ssi|sx[sdn]\.xml|s[1-3]|kdi|ssp)|\S+?\.ss[mt]\.(?:txz|zip)|sisupod\.(?:txz|zip))$/ - if x =~/\S+?\.ss[mt]\.(?:txz|zip)|sisupod\.(?:txz|zip)/ - if x =~/^(?:https?|file):\/\/\S+/ #\ - end - pwd=Dir.pwd - fn_pod=x.gsub(/([^\/]+)\.txz$/,'\1') - fullname=@env.processing_path.processing + '/sisupod/' + fn_pod - pt=Pathname.new(fullname) - FileUtils::mkdir_p(pt.to_s) - pod_make_path=fullname + '/sisupod/doc/_sisu' - make_instruct_array=sisu_document_make_pod.makefile_read(pod_make_path) - @make_instructions_pod= - HeaderCommon.new.sisu_document_make_instructions(make_instruct_array) - Dir.chdir(pt.realpath) - system(" - chdir #{fullname} - tar xaf #{pwd}/#{x} - chdir #{pwd} - ") - Dir.chdir(pt.realpath.to_s + '/sisupod/doc') - r=Px[:lng_lst_rgx] - Dir.entries("#{fullname}/sisupod/doc").each do |d_lng| - if d_lng =~/^(?:#{r})$/ - Dir.chdir(pt.realpath.to_s + "/sisupod/doc/#{d_lng}") - filenames=Dir.glob("*.ss[mt]") - filenames.each do |fn| - f_pths << { - pth: "#{fullname}/sisupod/doc/#{d_lng}", - f: "#{fn}", - pth_stub: 'doc', - lng: d_lng, - lng_is: d_lng, - url_base: '', - url: '' - } - Dir.chdir(pwd) - f << fn - end - end - end - elsif x =~/^(?:https?|file):\/\/\S+/ \ - and x =~/\S+?\.ss[mt]$/ - r_url=/(http:\/\/\S+?\/\S+?\/src(?:\/(?:#{r_l}))?)\// - url_base = (x[r_url,1]) - url = x - y=x.gsub(/http:\/\/\S+?\/\S+?\/src\//,'') - t=/(#{r_l})\/[^\/]+?\.ss[tm]$/ - l_p = (y[t,1]) \ - ? y[t,1] - : nil - lng << l_p - lngs << if l_p - l_p - elsif x =~/~(#{r_l})\.ss[tm]/ - $1 - else lng_base - end - r_f=/(?:#{r_l})\/([^\/]+?\.ss[tm])$/ - fn = (y[r_f,1]) \ - ? y[r_f,1] - : y - fn=fn.gsub(/\.((?:ssm\.)?sst)/,'.-\1') - fullname=Dir.pwd + '/' + fn - pt=Pathname.new(fullname) - pth << Dir.pwd - r_u=/.+?\/([^\/]+)(?:\/(?:#{r_l})$|$)/ - lng_is =if l_p - l_p - elsif x =~/~(#{r_l})\.ss[tm]/ - $1 - else lng_base - end - f_pths << { - pth: pt.split[0].realpath.to_s, - f: pt.split[1].to_s, - pth_stub: pt.split[0].realpath.to_s[r_u,1], - lng: (pt.split[0].realpath.to_s[t,1]) \ - ? pt.split[0].realpath.to_s[t,1] - : nil, - lng_is: lng_is, - url_base: url_base, - url: url - } - f << fn - elsif FileTest.file?(x) - pt=Pathname.new(x) - pth << pt.split[0].realpath.to_s #remove? - f << pt.split[1].to_s #remove? - r_u=/.+?\/([^\/]+)(?:\/(?:#{r_l})$|$)/ - t=/.+\/(#{r_l})$/ - l_p = (pt.split[0].realpath.to_s[t,1]) \ - ? pt.split[0].realpath.to_s[t,1] - : nil - lngs << lng_is = if l_p - l_p - elsif x =~/~(#{r_l})\.ss[tm]/ - $1 - else lng_base - end - f_pths << { - pth: pt.split[0].realpath.to_s, - f: pt.split[1].to_s, - pth_stub: pt.split[0].realpath.to_s[r_u,1], - lng: lng_is, - lng_is: lng_is, - url_base: nil, - url: nil, - } - else puts "file not found: #{x}" - end - elsif x =~ /\.termsheet\.rb$/ - (FileTest.file?(x)) \ - ? (f << x) - : (puts "file not found: #{x}") - else w=x - puts "#{x} in #{a.join(' ')}?" - end - end - { - cmd: c, - mod: m, - what: w, - paths: pth, - files: f, - f_pths: f_pths, - lng: lng_is, - lngs: lngs, - } - end - def expand_numeric_shortcuts(a) - shortcut=SiSU_Env::InfoProcessingFlag.new - s='' - a.each do |x| - y=case x - when /0/ - (x=~/^-0\S+/) \ - ? x.gsub(/^-0(\S+)/,shortcut.cf_0 + ' -\1') - : x.gsub(/^-0/,shortcut.cf_0 + ' ') - when /1/ - (x=~/^-1\S+/) \ - ? x.gsub(/^-1(\S+)/,shortcut.cf_1 + ' -\1') - : x.gsub(/^-1/,shortcut.cf_1 + ' ') - when /2/ - (x=~/^-2\S+/) \ - ? x.gsub(/^-2(\S+)/,shortcut.cf_2 + ' -\1') - : x.gsub(/^-2/,shortcut.cf_2 + ' ') - when /3/ - (x=~/^-3\S+/) \ - ? x.gsub(/^-3(\S+)/,shortcut.cf_3 + ' -\1') - : x.gsub(/^-3/,shortcut.cf_3 + ' ') - when /4/ - (x=~/^-4\S+/) \ - ? x.gsub(/^-4(\S+)/,shortcut.cf_4 + ' -\1') - : x.gsub(/^-4/,shortcut.cf_4 + ' ') - when /5/ - (x=~/^-5\S+/) \ - ? x.gsub(/^-5(\S+)/,shortcut.cf_5 + ' -\1') - : x.gsub(/^-5/,shortcut.cf_5 + ' ') - when /6/ - (x=~/^-6\S+/) \ - ? x.gsub(/^-6(\S+)/,shortcut.cf_5 + ' -\1') - : x.gsub(/^-6/,shortcut.cf_5 + ' ') - else x - end - s << " #{y}" unless y.empty? - end - s.strip! - end - def opt_cmd_and_mod_adjust(c,m) - cmd,mod,files=@cmd,@mod,@files - if not m.empty? \ - and m.inspect =~/"--pdf-/ - mod << '--pdf' - m.each do |s| - if s =~ /^--pdf-(?:(?:l|landscape)(?:-(?:a4|letter|a5|b5|legal))?|(?:a4|letter|a5|b5|legal)-(?:l|landscape))$/ - mod << '--landscape' - end - if s =~ /^--pdf-(?:(?:p|portrait)(?:-(?:a4|letter|a5|b5|legal))?|(?:a4|letter|a5|b5|legal)-(?:p|portrait))$/ - mod << '--portrait' - end - if s =~ /^--pdf(?:-(?:a4|letter|a5|b5|legal)(?:-(?:[lp]|landscape|portrait))?|(?:-(?:[lp]|landscape|portrait))(?:-(?:a4|letter|a5|b5|legal)))$/ - if s =~ /^--pdf(?:-a4(?:-(?:[lp]|landscape|portrait))?|(?:-(?:[lp]|landscape|portrait))-a4)$/ - mod << '--papersize-a4' - end - if s =~ /^--pdf(?:-a5(?:-(?:[lp]|landscape|portrait))?|(?:-(?:[lp]|landscape|portrait))-a5)$/ - mod << '--papersize-a5' - end - if s =~ /^--pdf(?:-b5(?:-(?:[lp]|landscape|portrait))?|(?:-(?:[lp]|landscape|portrait))-b5)$/ - mod << '--papersize-b5' - end - if s =~ /^--pdf(?:-letter(?:-(?:[lp]|landscape|portrait))?|(?:-(?:[lp]|landscape|portrait))-letter)$/ - mod << '--papersize-letter' - end - if s =~ /^--pdf(?:-legal(?:-(?:[lp]|landscape|portrait))?|(?:-(?:[lp]|landscape|portrait))-legal)$/ - mod << '--papersize-legal' - end - end - end - mod=mod.uniq - end - unless m.empty? - m.each do |s| - case s - when /^--(?:color-toggle)$/ then c=c+'c' - when /^--(?:color-off)$/ then c=c+'k' - when /^--(?:conf|config|configure|init|initialize|init-site)$/ then c=c+'CC' - when /^--(?:ao|dal?|machine|abstraction|abs)$/ then c=c+'m' - when /^--(?:txt|text|plaintext)$/ then c=c+'t' - when /^--(?:html)$/ then c=c+'h' - when /^--(?:html-scroll|html-seg)$/ then c=c+'H' - mod << s - when /^--(?:epub)$/ then c=c+'e' - when /^--(?:od[ft])$/ then c=c+'o' - when /^--docbook$/ then c=c+'d' - when /^--(?:pdf)$/ then c=c+'p' - when /^--pdf-(?:a4|a5|b5|legal|letter)$/ then c=c+'p' - when /^--pdf-(?:p|l|portrait|landscape)$/ then c=c+'L' - when /^--pdf-(?:p(?:ortrait)?|l(?:andscape)?)-(?:a4|letter|a5|b5|legal)$/ then c=c+'L' - when /^--pdf-(?:a4|letter|a5|b5|legal)-(?:p(?:ortrait)?|l(?:andscape)?)$/ then c=c+'L' - when /^--(?:concordance|wordmap)$/ then c=c+'w' - when /^--(?:manpage|man)$/ then c=c+'i' - when /^--(?:texinfo)$/ then c=c+'I' - when /^--(?:xhtml)$/ then c=c+'b' - when /^--(?:xml-sax)$/ then c=c+'x' - when /^--(?:xml-dom)$/ then c=c+'X' - when /^--(?:images)$/ then c=c+'j' - when /^--(?:digests?|hash-digests)$/ then c=c+'N' - when /^--(?:po4a|pot?)$/ then c=c+'P' - when /^--(?:termsheet)$/ then c=c+'T' - when /^--(?:manifest)$/ then c=c+'y' - when /^--(?:qrcode)$/ then c=c+'Q' - when /^--(?:remote|rsync)$/ then c=c+'R' - when /^--(?:scp)$/ then c=c+'r' - when /^--(?:source)$/ then c=c+'s' - when /^--(?:sisupod|pod)$/ then c=c+'S' - when /^--(?:git)$/ then c=c+'g' - when /^--(?:urls)$/ then c=c+'U' - when /^--(?:zap|delete)$/ then c=c+'Z' - when /^--(?:sample-search-form)$/ then c=c+'F' - when /^--(?:webserv|webrick)$/ then c=c+'W' - when /^--(?:profile)$/ then c=c+'E' - when /^--(?:maintenance|keep-processing-files)$/ then c=c+'M' - when /^--(?:verbose[=-]3)$/ then c=c+'VM' - when /^--(?:verbose[=-]2|Verbose|VERBOSE)$/ then c=c+'V' - when /^--(?:verbose(?:[=-]1)?)$/ then c=c+'v' - when /^--(?:version)$/ then c=c+'v' - when /^--(?:verbose[=-]0|quiet|silent)$/ then c=c+'q' - else mod << s #mod only contains command modifiers; commands converted to character - end - end - end - ca=[] - unless c.empty? - c=c.gsub(/-/,'') - c.scan(/CC|\S/) {|x| ca << x} - cmd= '-' + ca.uniq.join - end - extra='' - if cmd !~/[mn]/ - extra+=if cmd =~/[abegHhIiLNOoPpQTtwXxyz]/ \ - and cmd !~/[mn]/ - 'm' #% add ao - elsif ((mod.inspect =~/--(?:(?:sq)?lite|pg(?:sql)?)/) \ - and mod.inspect !~/(?:remove|(?:(?:re)?create(?:all)?|dropall|drop)$)/) \ - and cmd !~/[mn]/ - 'm' #% add ao - else '' - end - end - if cmd !~/j/ - extra+=if cmd =~/[bdHhwXxyz]/ \ - and cmd !~/[j]/ - 'j' #% copy images - else '' - end - end - if cmd !~/y/ - extra+=if cmd =~/[abdeHhIiNopQSstwXxz]/ \ - and cmd !~/y/ - 'ym' #% add manifest - elsif mod.inspect =~/--(?:(?:sq)?lite|pg(?:sql)?)/ \ - and files[0] !~/^remove$/ \ - and cmd !~/y/ - 'ym' #% add manifest - else '' - end - end - if cmd !~/u/ #% add urls - extra+='u' - end - cmd=cmd + extra - cmds=cmd.scan(/CC|\S/) - [cmds.uniq.join,mod] - end - def opt_act #note mod line commands have already been converted to command characters, cmd - cmd,mod=@cmd,@mod - @@act=if @@act - @act=@@act - else - act={} - act[:license]=(mod.inspect =~/"--license/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:site_init]=(cmd =~/C/ \ - || mod.inspect =~/"--init"|"--initialize"|"--init-site"|"--conf"|"--config"|"--configure"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:rc]=if mod.inspect =~/"--rc=/ - x=Dir.pwd + '/' + mod.join.gsub(/--rc=/,'') - { bool: true, set: :on, inst: x } - else - { bool: false, set: :na, inst: '' } - end - act[:processing_path]=if mod.inspect =~/"--processing-path=/ - base_pth=mod.join(';').gsub(/^.*--processing-path=['"]?(.+?)(?:['"]?;.+)?$/,'\1') - { bool: true, set: :on, inst: base_pth } - elsif mod.inspect =~/"--processing-path/ - { bool: true, set: :on, inst: @base_path } - else - { bool: false, set: :na, inst: nil } - end - act[:dump]=if mod.inspect =~/"--dump=/ - base_pth=mod.join(';').gsub(/^.*--dump=['"]?(.+?)(?:['"]?;.+)?$/,'\1') - { bool: true, set: :on, inst: base_pth } - elsif mod.inspect =~/"--dump/ - { bool: true, set: :on, inst: @base_path } - else - { bool: false, set: :na, inst: nil } - end - act[:redirect]=if mod.inspect =~/"--redirect=/ - base_pth=mod.join(';').gsub(/^.*--redirect=['"]?(.+?)(?:['"]?;.+)?$/,'\1') - { bool: true, set: :on, inst: base_pth } - elsif mod.inspect =~/"--redirect/ - { bool: true, set: :on, inst: @base_path } - else - { bool: false, set: :na, inst: nil } - end - act[:switch]=if mod.inspect =~/"--switch-off=/ - off_list=mod.join(';').gsub(/^.*--switch-off=['"]?(.+?)(?:['"];.+)?$/,'\1') - off_list=off_list.scan(/[^,;\s]+/) - { bool: false, set: :off, off: off_list} - else { bool: true, set: :na, off: [] } - end - act[:default_language]=if mod.inspect =~/"--(?:default-)?language[-=](\S{2})"/ - { set: :on, code: $1 } - elsif lng_base - { set: :on, code: lng_base } - else { set: :na, code: 'en' } - end - act[:i18n]=if mod.inspect =~/"(?:--monolingual|--i18n-mono(?:lingual)?)"/ #if monolingual possible outputs output_by :filename & :filetype only, without language code in default language name; give warning of conflict settings if monolingual & :language selected - @lingual=:mono - { set: :mono } - elsif mod.inspect =~/"(?:--multilingual|--i18n-multi(?:lingual)?)"/ - @lingual=:multi - { set: :multi } - else { set: :na } - end - act[:output_by]=if mod.inspect =~/"--(?:output-)?by-language"/ - @dir_structure_by=:language - { set: :language } - elsif mod.inspect =~/"--(?:output-)?by-filename"/ - @dir_structure_by=:filename - { set: :filename } - elsif mod.inspect =~/"--(?:output-)?by-filetype"/ - @dir_structure_by=:filetype - { set: :filetype } - else { set: :na } - end - act[:ocn]=if mod.inspect =~/"--ocn"|"--inc-ocn"|"--numbering"|"--inc-numbering"/ - { bool: true, set: :on } - elsif mod.inspect =~/"--no-ocn"|"--exc-ocn"|"--no-numbering"|"--exc-numbering"/ \ - || act[:switch][:off].inspect =~/"ocn"|"--numbering"/ - { bool: false, set: :off } - else { bool: true, set: :na } - end - act[:toc]=if mod.inspect =~/"--inc-toc"/ - { bool: true, set: :on } - elsif mod.inspect =~/"--(?:exc|no)-toc"/ \ - || act[:switch][:off].inspect =~/"toc"/ - { bool: false, set: :off } - else { bool: true, set: :na } - end - act[:minitoc]=if mod.inspect =~/"--inc-minitoc"/ - { bool: true, set: :on } - elsif mod.inspect =~/"--(?:exc|no)-minitoc"/ \ - || act[:switch][:off].inspect =~/"minitoc"/ - { bool: false, set: :off } - else { bool: true, set: :na } - end - act[:links_to_manifest]=if mod.inspect =~/"--inc-links-to-manifest"|"--inc-manifest-links"/ - { bool: true, set: :on } - elsif mod.inspect =~/"--(?:exc|no)-manifest"/ \ - || act[:switch][:off].inspect =~/"manifest"/ #place lower - { bool: false, set: :off } - elsif mod.inspect =~/"--(?:exc|no)-links-to-manifest"|"--(?:exc|no)-manifest-links"/ \ - || act[:switch][:off].inspect =~/"links_to_manifest"|"manifest_links"|"--(?:exc|no)-manifest"/ \ - || mod.inspect =~/"--(?:redirect|dump)/ - { bool: false, set: :off } - else { bool: true, set: :na } - end - act[:manifest_minitoc]=if mod.inspect =~/"--inc-manifest-minitoc"|"--inc-minitoc"/ - { bool: true, set: :on } - elsif mod.inspect =~/"--(?:exc|no)-manifest-minitoc"|"--(?:exc|no)-minitoc"/ \ - || act[:switch][:off].inspect =~/"manifest_minitoc"|"minitoc"/ - #|| mod.inspect =~/"--(?:redirect|dump)/ - { bool: false, set: :off } - else { bool: true, set: :na } - end - act[:metadata]=if mod.inspect =~/"--inc-metadata"/ - { bool: true, set: :on } - elsif mod.inspect =~/"--(?:exc|no)-metadata"/ \ - || act[:switch][:off].inspect =~/"metadata"/ - { bool: false, set: :off } - else { bool: true, set: :na } - end - act[:html_minitoc]=if mod.inspect =~/"--inc-html-minitoc"|"--inc-minitoc"/ - { bool: true, set: :on } - elsif mod.inspect =~/"--(?:exc|no)-html-minitoc"|"--(?:exc|no)-minitoc"/ \ - || act[:switch][:off].inspect =~/"html_minitoc"|"minitoc"/ - { bool: false, set: :off } - else { bool: true, set: :na } - end - act[:html_navigation]=if mod.inspect =~/"--inc-html-navigation"|"--inc-navigation"/ - { bool: true, set: :on } - elsif mod.inspect =~/"--(?:exc|no)-html-navigation"|"--(?:exc|no)-navigation"/ \ - || act[:switch][:off].inspect =~/"html_navigation"|"nav"/ - { bool: false, set: :off } - else { bool: true, set: :na } - end - act[:html_navigation_bar]=if mod.inspect =~/"--inc-html-navigation-bar"|"--inc-navigation-bar"/ - { bool: true, set: :on } - elsif mod.inspect =~/"--(?:exc|no)-html-navigation-bar"|"--(?:exc|no)-navigation-bar"/ \ - || act[:switch][:off].inspect =~/"html_navigation_bar"|"navbar"/ - { bool: false, set: :off } - else { bool: true, set: :na } - end - act[:segsubtoc]=if mod.inspect =~/"--inc-segsubtoc"/ - { bool: true, set: :on } - elsif mod.inspect =~/"--(?:exc|no)-segsubtoc"/ \ - || act[:switch][:off].inspect =~/"segsubtoc"/ - { bool: false, set: :off } - else { bool: true, set: :na } - end - act[:search_form]=if mod.inspect =~/"--inc-search-form"/ - { bool: true, set: :on } - elsif mod.inspect =~/"--(?:exc|no)-search-form"/ \ - || act[:switch][:off].inspect =~/"search_form"|"search"/ - { bool: false, set: :off } - else { bool: true, set: :na } - end - act[:html_search_form]=if mod.inspect =~/"--inc-html-search-form"|"--inc-search-form"/ - { bool: true, set: :on } - elsif mod.inspect =~/"--(?:exc|no)-html-search-form"|"--(?:exc|no)-search-form"/ \ - || act[:switch][:off].inspect =~/"html_search_form"|"search_form"|"search"/ - { bool: false, set: :off } - else { bool: true, set: :na } - end - act[:html_right_pane]=if mod.inspect =~/"--inc-html-right-pane"|"--inc-right-pane"|"--inc-html-right-column"|"--inc-right-column"/ - { bool: true, set: :on } - elsif mod.inspect =~/"--(?:exc|no)-html-right-pane"|"--(?:exc|no)-right-pane"|"--(?:exc|no)-html-right-column"|"--(?:exc|no)-right-column"/ \ - || act[:switch][:off].inspect =~/"html_right_pane"|"html_right_column"|"promo"/ - { bool: false, set: :off } - else { bool: true, set: :na } - end - act[:html_top_band]=if mod.inspect =~/"--inc-html-top-band"|"--inc-top-band"/ - { bool: true, set: :on } - elsif mod.inspect =~/"--(?:exc|no)-html-top-band"|"--(?:exc|no)-top-band"/ \ - || act[:switch][:off].inspect =~/"html-top-band"|"top-band"/ - { bool: false, set: :off } - else { bool: true, set: :na } - end - act[:html]=if mod.inspect =~/"--html-strict"/ \ - or ((cmd =~/h/ || mod.inspect =~/"--html"/) \ - && mod.inspect =~/"--strict"/) - act[:html_strict]={ bool: true, set: :on } - act[:html_scroll]={ bool: true, set: :on } - act[:html_seg]={ bool: true, set: :on } - { bool: true, set: :on } - elsif (cmd =~/h/ \ - || mod.inspect =~/"--html"/) - act[:html_strict]={ bool: false, set: :off } - act[:html_scroll]={ bool: true, set: :on } - act[:html_seg]={ bool: true, set: :on } - { bool: true, set: :on } - else - act[:html_strict]=(mod.inspect =~/"--strict"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:html_scroll]=(mod.inspect =~/"--html-scroll"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:html_seg]=(mod.inspect =~/"--html-seg"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - { bool: false, set: :na } - end - act[:concordance]=(cmd =~/w/ \ - || mod.inspect =~/"--concordance"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:images]=(cmd =~/j/ \ - || mod.inspect =~/"--images"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - if (cmd =~/p/ \ - || mod.inspect =~/"--pdf"/) - if mod.inspect =~/"--portrait"/ - act[:pdf]= { bool: false, set: :na } - act[:pdf_l]={ bool: false, set: :na } - act[:pdf_p]={ bool: true, set: :on } - elsif mod.inspect =~/"--landscape"/ - act[:pdf]= { bool: false, set: :na } - act[:pdf_l]={ bool: true, set: :on } - act[:pdf_p]={ bool: false, set: :na } - else - act[:pdf]= { bool: true, set: :on } - act[:pdf_l]={ bool: true, set: :on } - act[:pdf_p]={ bool: true, set: :on } - end - else - act[:pdf]= { bool: false, set: :na } - act[:pdf_p]= { bool: false, set: :na } - act[:pdf_l]= { bool: false, set: :na } - act[:pdf_a4]= { bool: false, set: :na } - act[:pdf_a5]= { bool: false, set: :na } - act[:pdf_b5]= { bool: false, set: :na } - act[:pdf_letter]={ bool: false, set: :na } - act[:pdf_legal]= { bool: false, set: :na } - end - if act[:pdf][:set]==:on \ - or act[:pdf_p][:set]==:on \ - or act[:pdf_l][:set]==:on - act[:pdf_a4]=if mod.inspect =~/"--a4"|--papersize-a4"/ \ - or mod.inspect =~/"--papersize=\S*a4\b\S*"/ #--papersize=a4,a5 - { bool: true, set: :on } - else - { bool: false, set: :na } - end - act[:pdf_a5]=if mod.inspect =~/"--a5"|"--papersize-a5"/ \ - or mod.inspect =~/"--papersize=\S*a5\b\S*"/ #--papersize=a4,a5 - { bool: true, set: :on } - else - { bool: false, set: :na } - end - act[:pdf_b5]=if mod.inspect =~/"--b5"|"--papersize-b5"/ \ - or mod.inspect =~/"--papersize=\S*b5\b\S*"/ - { bool: true, set: :on } - else - { bool: false, set: :na } - end - act[:pdf_letter]=if mod.inspect =~/"--letter"|"--papersize-letter"/ \ - or mod.inspect =~/"--papersize=\S*letter\b\S*"/ - { bool: true, set: :on } - else - { bool: false, set: :na } - end - act[:pdf_legal]=if mod.inspect =~/"--legal"|"--papersize-legal"/ \ - or mod.inspect =~/"--papersize=\S*legal\b\S*"/ - { bool: true, set: :on } - else - { bool: false, set: :na } - end - end - act[:epub]=(cmd =~/e/ \ - || mod.inspect =~/"--epub"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:odt]=if cmd =~/o/ \ - or mod.inspect =~/"--odt"|"--odf"|"--odt-(?:ocn|numbering)"|"--odf-(?:ocn|numbering)"/ - act[:odt_ocn]=if (mod.inspect =~/"--odt-(?:ocn|numbering)"|"--odf-(?:ocn|numbering)"/ \ - or mod.inspect =~/"--ocn"|"--inc-ocn"|"--numbering"|"--inc-numbering"/) - { bool: true, set: :on } - elsif mod.inspect =~/"--no-ocn"|"--exc-ocn"|"--no-numbering"|"--exc-numbering"/ - { bool: false, set: :off } - else - { bool: false, set: :na } - end - { bool: true, set: :on } - else - { bool: false, set: :na } - end - act[:xml_sax]=(cmd =~/x/ \ - || mod.inspect =~/"--xml-sax"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:xml_dom]=(cmd =~/X/ \ - || mod.inspect =~/"--xml-dom"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:xml_docbook_book]=(cmd =~/d/ \ - || mod.inspect =~/"--docbook"|"--docbook-book"|"--xml-docbook"|"--xml-docbook_book"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:xml_fictionbook]=(cmd =~/f/ \ - || mod.inspect =~/"--fictionbook"|"--xml-fictionbook"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:xml_scaffold_structure_sisu]=mod.inspect =~/"--xml-scaffold"|"--xml-scaffold-sisu"/ \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:xml_scaffold_structure_collapse]=mod.inspect =~/"--xml-scaffold-collapse"/ \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:xhtml]=(cmd =~/b/ \ - || mod.inspect =~/"--xhtml"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:txt]=if cmd =~/[at]/ \ - or mod.inspect =~/"--txt"|"--text"|"--plaintext"|"--txt-(?:ocn|numbering)"|"--text-(?:ocn|numbering)"|"--plaintext-(?:ocn|numbering)"/ - act[:txt_ocn]=if (mod.inspect =~/"--txt-(?:ocn|numbering)"|"--text-(?:ocn|numbering)"|"--plaintext-(?:ocn|numbering)"/ \ - or mod.inspect =~/"--ocn"|"--inc-ocn"|"--numbering"|"--inc-numbering"/) - { bool: true, set: :on } - elsif mod.inspect =~/"--no-ocn"|"--exc-ocn"|"--no-numbering"|"--exc-numbering"/ - { bool: false, set: :off } - else - { bool: false, set: :na } - end - { bool: true, set: :on } - else - { bool: false, set: :na } - end - act[:txt_textile]=(mod.inspect =~/"--textile"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:txt_asciidoc]=(mod.inspect =~/"--asciidoc"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:txt_markdown]=(mod.inspect =~/"--markdown"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:txt_rst]=(mod.inspect =~/"--rst"|"--rest"|"--restructuredtext"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:manpage]=(cmd =~/i/ \ - || mod.inspect =~/"--manpage"|"--man"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:texinfo]=(cmd =~/I/ \ - || mod.inspect =~/"--texinfo"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:psql]=if mod.inspect =~/"--pg-\S+"/ \ - or ((mod.inspect =~/"--pg"/) \ - && (mod.inspect \ - =~/"--createdb"|"--create(?:all)?"|"--dropall"|"--recreate(?:all)?"|"--import"|"--update"|"--remove"/)) - act[:psql_createdb]=if mod.inspect \ - =~/"--pg-createdb"|"--createdb"/ - { bool: true, set: :on } - else - { bool: false, set: :na } - end - if mod.inspect \ - =~/"--pg-recreate(?:all)?"|"--recreate(?:all)?"/ - act[:psql_drop]={ bool: true, set: :on } - act[:psql_create]={ bool: true, set: :on } - else - act[:psql_drop]=if mod.inspect \ - =~/"--pg-dropall"|"--dropall"/ - { bool: true, set: :on } - else - { bool: false, set: :na } - end - act[:psql_create]=if mod.inspect \ - =~/"--pg-create(?:all)?"|"--create(?:all)?"/ - { bool: true, set: :on } - else - { bool: false, set: :na } - end - end - act[:psql_import]=if mod.inspect \ - =~/"--pg-import"|"--import"/ - { bool: true, set: :on } - else - { bool: false, set: :na } - end - act[:psql_update]=if mod.inspect \ - =~/"--pg-update"|"--update"/ - act[:psql_remove]={ bool: true, set: :on } - { bool: true, set: :on } - else - act[:psql_remove]=if mod.inspect \ - =~/"--pg-remove"|"--remove"/ - { bool: true, set: :on } - else - { bool: false, set: :na } - end - { bool: false, set: :na } - end - { bool: true, set: :on } - else - act[:psql_createdb]= - { bool: false, set: :na } - act[:psql_drop]= - { bool: false, set: :na } - act[:psql_create]= - { bool: false, set: :na } - act[:psql_import]= - { bool: false, set: :na } - act[:psql_update]= - { bool: false, set: :na } - act[:psql_remove]= - { bool: false, set: :na } - { bool: false, set: :na } - end - act[:sqlite]=if (mod.inspect =~/"--sqlite-\S+"/) \ - or ((mod.inspect =~/"--sqlite"/) \ - && (mod.inspect \ - =~/"--createdb"|"--create(?:all)?"|"--dropall"|"--recreate(?:all)?"|"--import"|"--update"|"--remove"/)) - act[:sqlite_createdb]=if mod.inspect \ - =~/"--sqlite-createdb"|"--createdb"/ - { bool: true, set: :on } - else - { bool: false, set: :na } - end - if mod.inspect \ - =~/"--sqlite-recreate(?:all)?"|"--recreate(?:all)?"/ - act[:sqlite_drop]={ bool: true, set: :on } - act[:sqlite_create]={ bool: true, set: :on } - else - act[:sqlite_create]=if mod.inspect \ - =~/"--sqlite-create(?:all)?"|"--create(?:all)?"/ - { bool: true, set: :on } - else - { bool: false, set: :na } - end - act[:sqlite_drop]=if mod.inspect \ - =~/"--sqlite-dropall"|"--dropall"/ - { bool: true, set: :on } - else - { bool: false, set: :na } - end - end - act[:sqlite_import]=if mod.inspect \ - =~/"--sqlite-import"|"--import"/ - { bool: true, set: :on } - else - { bool: false, set: :na } - end - act[:sqlite_update]=if mod.inspect \ - =~/"--sqlite-update"|"--update"/ - act[:sqlite_remove]={ bool: true, set: :on } - { bool: true, set: :on } - else - act[:sqlite_remove]=if mod.inspect \ - =~/"--sqlite-remove"|"--sqlite-remove"/ - { bool: true, set: :on } - else - { bool: false, set: :na } - end - { bool: false, set: :na } - end - { bool: true, set: :on } - else - act[:sqlite_createdb]= - { bool: false, set: :na } - act[:sqlite_drop]= - { bool: false, set: :na } - act[:sqlite_create]= - { bool: false, set: :na } - act[:sqlite_import]= - { bool: false, set: :na } - act[:sqlite_update]= - { bool: false, set: :na } - act[:sqlite_remove]= - { bool: false, set: :na } - { bool: false, set: :na } - end - act[:sqlite_discrete]=mod.inspect =~/"--sql"|"--sqlite"/ \ - && (mod.inspect !~/"--createdb"|"--create(?:all)?"|"--dropall"|"--recreate(?:all)?"|"--import"|"--update"|"--remove"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:harvest]=(mod.inspect =~/"--harvest"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:po4a]=(cmd =~/P/ \ - || mod.inspect =~/"--po4a"|"--pot?"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:git]=(cmd =~/g/ \ - || mod.inspect =~/"--git"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:hash_digests]=(cmd =~/N/ \ - || mod.inspect =~/"--digests?"|"--hash-digests"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:pdf_font_size]=if mod.inspect =~/"--(?:pdf-)?font-?size[=-](\d{1,2})(?:pt)?"/ - $1 - else :na - end - act[:pdf_hyperlink_colors]=if mod.inspect =~/"--pdf-hyperlinks-(?:mono(?:chrome)?|no-color)"/ - :mono - elsif mod.inspect =~/"--pdf-hyperlinks-color"/ - :color - else :na - end - act[:hash_digest_algo]=if mod.inspect =~/"--hash-(?:sha)?512"/ - :sha512 - elsif mod.inspect =~/"--hash-(?:sha)?256"/ - :sha256 - elsif mod.inspect =~/"--hash-md5"/ - :md5 - else :na - end - act[:sample_search_form]=(cmd =~/F/ \ - || mod.inspect =~/"--sample-search-form"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:webrick]=(cmd =~/W/ \ - || mod.inspect =~/"--webrick"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:share_source]=(cmd =~/s/ \ - || mod.inspect =~/"--source"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:sisupod]=(cmd =~/S/ \ - || mod.inspect =~/"--sisupod"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:scp]=(cmd =~/r/ \ - || mod.inspect =~/"--scp"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:rsync]=(cmd =~/R/ \ - || mod.inspect =~/"--rsync"|"--remote"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:zap]=(cmd =~/Z/ \ - || mod.inspect =~/"--zap"|"--delete"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:urls_all]=(cmd =~/U/ \ - || mod.inspect =~/"--urls-all"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:urls_selected]=(cmd =~/u/ \ - || mod.inspect =~/"--urls"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:sitemap]=(cmd =~/Y/ \ - || mod.inspect =~/"--sitemap"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:qrcode]=(cmd =~/Q/ \ - || mod.inspect =~/"--qrcode"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:help]=(mod.inspect =~/"--help/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:ao]=if (cmd =~/m/ \ - || mod.inspect =~/"--ao"|"--dal"/) - { bool: true, set: :on } - elsif (act[:txt][:set]==:on \ - || act[:txt_textile][:set]==:on \ - || act[:txt_asciidoc][:set]==:on \ - || act[:txt_markdown][:set]==:on \ - || act[:txt_rst][:set]==:on \ - || act[:xhtml][:set]==:on \ - || act[:epub][:set]==:on \ - || act[:html][:set]==:on \ - || act[:html_seg][:set]==:on \ - || act[:html_scroll][:set]==:on \ - || act[:texinfo][:set]==:on \ - || act[:manpage][:set]==:on \ - || act[:hash_digests][:set]==:on \ - || act[:odt][:set]==:on \ - || act[:pdf][:set]==:on \ - || act[:pdf_p][:set]==:on \ - || act[:pdf_l][:set]==:on \ - || act[:qrcode][:set]==:on \ - || act[:share_source][:set]==:on \ - || act[:sisupod][:set]==:on \ - || act[:concordance][:set]==:on \ - || act[:xml_dom][:set]==:on \ - || act[:xml_sax][:set]==:on \ - || act[:xml_docbook_book][:set]==:on \ - || act[:xml_fictionbook][:set]==:on \ - || act[:xml_scaffold_structure_sisu][:set]==:on \ - || act[:xml_scaffold_structure_collapse][:set]==:on ) - { bool: true, set: :on } - #if cmd !~/[mn]/ - # extra+=if cmd =~/[abegHhIiLNOoPpQTtwXxyz]/ \ - # and cmd !~/[mn]/ - # 'm' #% add ao - #elsif (act[:txt][:set]==:on \ - # { bool: true, set: :on } - # elsif ((cmd =~/[Dd]/ \ - # or (mod.inspect =~/--(?:(?:sq)?lite|pg(?:sql)?)/)) \ - # and mod.inspect !~/(?:remove|(?:(?:re)?create(?:all)?|dropall|drop)$)/) \ - # and cmd !~/[mn]/ - # 'm' #% add ao - else - { bool: false, set: :na } - end - act[:manifest]=if mod.inspect =~/"--inc-manifest"/ - { bool: true, set: :on } - elsif mod.inspect =~/"--(?:exc|no)-manifest"/ \ - || act[:switch][:off].inspect =~/"manifest"/ - { bool: false, set: :off } - elsif (cmd =~/y/ \ - || mod.inspect =~/"--manifest"/) - { bool: true, set: :on } - elsif (act[:txt][:set]==:on \ - || act[:txt_textile][:set]==:on \ - || act[:txt_asciidoc][:set]==:on \ - || act[:txt_markdown][:set]==:on \ - || act[:txt_rst][:set]==:on \ - || act[:xhtml][:set]==:on \ - || act[:epub][:set]==:on \ - || act[:html][:set]==:on \ - || act[:html_seg][:set]==:on \ - || act[:html_scroll][:set]==:on \ - || act[:texinfo][:set]==:on \ - || act[:manpage][:set]==:on \ - || act[:hash_digests][:set]==:on \ - || act[:odt][:set]==:on \ - || act[:pdf][:set]==:on \ - || act[:pdf_p][:set]==:on \ - || act[:pdf_l][:set]==:on \ - || act[:qrcode][:set]==:on \ - || act[:share_source][:set]==:on \ - || act[:sisupod][:set]==:on \ - || act[:concordance][:set]==:on \ - || act[:xml_dom][:set]==:on \ - || act[:xml_sax][:set]==:on \ - || act[:xml_docbook_book][:set]==:on \ - || act[:xml_fictionbook][:set]==:on \ - || act[:xml_scaffold_structure_sisu][:set]==:on \ - || act[:xml_scaffold_structure_collapse][:set]==:on ) - { bool: true, set: :on } - ## if cmd !~/y/ - ## extra+=if cmd =~/[abeHhIiNopQSstwXxz]/ \ - ## and cmd !~/y/ - ## 'ym' #% add manifest - #elsif (act[:txt][:set]==:on \ - # { bool: true, set: :on } - # elsif (cmd =~/[Dd]/ \ - # or mod.inspect =~/--(?:(?:sq)?lite|pg(?:sql)?)/) \ - # and files[0] !~/^remove$/ \ - # and cmd !~/y/ - # 'ym' #% add manifest - else { bool: true, set: :na } - end - act[:console_messages] = '' - act[:verbose]=if (cmd =~/v/ \ - || mod.inspect =~/"--verbose"/) - act[:console_messages] << ' --verbose ' - { bool: true, set: :on } - else - { bool: false, set: :na } - end - act[:verbose_plus]=if (cmd =~/V/ \ - || mod.inspect =~/"--very-verbose"/) - act[:console_messages] << ' --very-verbose ' - { bool: true, set: :on } - else - { bool: false, set: :na } - end - act[:version_info]=if (cmd =~/[vVM]/ \ - || mod.inspect =~/"--verbose"|"--maintenance"/) - act[:console_messages] << ' --maintenance ' - { bool: true, set: :on } - else - { bool: false, set: :na } - end - act[:quiet]=if (cmd =~/q/ \ - || mod.inspect =~/"--quiet"/) - act[:console_messages] << ' --quiet ' - { bool: true, set: :on } - else - { bool: false, set: :na } - end - act[:color_state]=if mod.inspect =~/"--color-on"|"--color"/ - act[:console_messages] << ' --color-on ' - { bool: true, set: :on } - elsif (cmd =~/k/ \ - || mod.inspect =~/"--color-off"/) - act[:console_messages] << ' --color-off ' - { bool: false, set: :off } - else { bool: true, set: :na } #fix default color - end -# act[:color_toggle]=if cmd =~/c/ \ -# or mod.inspect =~/"--color-toggle"/ -# true -# else false -# end - act[:maintenance]=if (cmd =~/M/ \ - || mod.inspect =~/"--maintenance|--keep-processing-files"/) - act[:console_messages] << ' --maintenance ' - { bool: true, set: :on } - else - { bool: false, set: :na } - end - act[:profile]=if (cmd =~/E/ \ - || mod.inspect =~/"--profile"/) - act[:console_messages] << ' --color-off ' - { bool: true, set: :on } - else - { bool: false, set: :na } - end - @act=act - end - end - def cmd - @cmd - end - def mod - @mod - end - def act - @@act - end - def files_mod - files_mod=files - @files_mod=files_mod - end - def f_pth - @f_pth - end - def pth - @pth - end - def sub_location - pth.gsub(/#{base_path}/,'') - end - def lng - @lng - end - def lng_base - @lng_base - end - def fno - @fno=(fns.nil? || fns.empty?) \ - ? '' \ - : (fns[/(.+?(?:sst|ssm))(?:\.sst)?/,1]) - end - def fng - @fng=(fno.nil? || fno.empty?) \ - ? '' \ - : (fno.gsub(/(?:~(?:#{Px[:lng_lst_rgx]}))?(\.ss[tm])$/,'\1')) - end - def fns - @fns - end - def fnl - @fns.gsub(/(\S+?)((?:\.ssm)?\.sst)/,"\\1.#{lng}\\2") - end - def what - @what - end - def fnb - (fns.nil? || fns.empty?) \ - ? '' \ - : (fns[/(.+?)\.(?:(?:-|ssm\.)?sst|ssm)$/,1]) - end - def fnc - @fnc=(@fns =~/\.(?:ssm\.sst|ssm)$/) \ - ? fnb + '.ssm.sst' - : @fns - end - def fncb - @fncb=(@fns =~/(?:\~\S{2,3})?\.(?:ssm\.sst|ssm)$/) \ - ? fnb + '.ssm.sst' - : @fns.gsub(/(?:\~\S{2,3})?(\.sst)$/,'\1') - end - end -end -__END__ -note usually named @opt is carried in Param (usually as @md.opt), @opt is a -subset of @md where @md is passed, contents of @opt are available as @md.opt -passing @opt as well is duplication check for fns & fnb diff --git a/lib/sisu/v5/param.rb b/lib/sisu/v5/param.rb deleted file mode 100644 index 4621f460..00000000 --- a/lib/sisu/v5/param.rb +++ /dev/null @@ -1,1550 +0,0 @@ -# encoding: utf-8 -=begin - - * Name: SiSU - - * Description: a framework for document structuring, publishing and search - - * Author: Ralph Amissah - - * Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, - All Rights Reserved. - - * License: GPL 3 or later: - - SiSU, a framework for document structuring, publishing and search - - Copyright (C) Ralph Amissah - - This program is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the Free - Software Foundation, either version 3 of the License, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - more details. - - You should have received a copy of the GNU General Public License along with - this program. If not, see . - - 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: - - - * Git - - - - * Ralph Amissah - - - - ** Description: parameters extracted from input file(s) for program use - -=end -module SiSU_Param - begin - require 'uri' - require 'pstore' - rescue LoadError - SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). - error('uri or pstore NOT FOUND (LoadError)') - end - require_relative 'sysenv' # sysenv.rb - include SiSU_Env - require_relative 'param_make' # param_make.rb - require_relative 'param_identify_markup' # param_identify_markup.rb - @@date=SiSU_Env::InfoDate.new - @@proc= - @@filename_txt= - @@filename_texinfo= - @@filename_lout_portrait= - @@filename_lout_landscape= - @@filename_html_scroll= - @@filename_html_index= - @@filename_html_segtoc= - @@filename_semantic= - @@filename_rss= - @@newfile= - @@drr= - nil - @doc={ - initialise: nil, - markup: '', - lnks: '', - stmp: '', - req: {}, - } - @@yaml=@@yamladdr=nil - @@trigger=nil - @@lv,@@flag={},{} - @@tex_backslash="\\\\" - class Parameters - @@publisher='SiSU scribe' - @@md=@@fns=@@pth=nil - def initialize(opt) - @opt=opt - @cX||=SiSU_Screen::Ansi.new(@opt.act[:color_state][:set]) - @cmd,@mod=opt.cmd,opt.mod - @fns=if @opt.cmd =~/P/ #revisit CHECK - opt.fns - else opt.fns.gsub(/\.ssm$/,'.ssm.sst') - end - SiSU_Param::Instantiate.new.param_instantiate - @env=SiSU_Env::InfoEnv.new(@fns) - @pstorefile="#{@env.processing_path.ao}/#{@fns}.pstore" - end - def get - if @opt.f_pth \ - and @opt.f_pth[:pth] != Dir.pwd #BUG check - # you may need to change Dir.pwd to @opt.f_pth[:pth] where the latter - # has a path value that is different, however, f_pth is not always set! - Dir.chdir(@opt.f_pth[:pth]) - end - if @@fns !=@fns \ - or @@pth !=Dir.pwd #@opt.f_pth[:pth] - @@fns,@@pth=@fns,Dir.pwd #@opt.f_pth[:pth] - @@md=nil - end - if @@md.nil? \ - or @opt.act[:maintenance][:set]==:on #not particularly helpful, as current cycle is through output types, with files changing, only helpful if deal with a file all output types before going to next file - if File.exist?(@pstorefile) - param_msg='Parameters from pstore' - store=PStore.new(@pstorefile) - store.transaction do - @md=store['md'] - end - @md - else - param_msg='Parameters extracted' - fns_array=@env.read_source_file(@opt.fns) - @md=SiSU_Param::Parameters::Instructions.new(fns_array,@opt).extract - @md - end - if defined? @md.title.main # on removal check problems with -U - if (@opt.act[:verbose][:set]==:on \ - || @opt.act[:verbose_plus][:set]==:on \ - || @opt.act[:maintenance][:set]==:on) - SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - param_msg, - @md.title.main - ).txt_grey - end - end - @@md=@md - else @@md - end - @@md.opt=@opt - @@md - end - class MdDefault - def rights(author,date) - @author,@date=author,date - def all - s=nil - if @author - s ||=((@date =~/((?:1[4-9]|2[01])\d{2})/ ) \ - ? ("Copyright (C) #{$1} #{@author}") - : ('Copyright (C)' + @author)) #matches years 1400 through 21\d\d - end - s - end - def text - all - end - def copyright - def all - s=nil - if @author - s ||=((@date =~/((?:1[4-9]|2[01])\d{2})/ ) \ - ? ("Copyright (C) #{$1} #{@author}") - : ('Copyright (C)' + @author)) #matches years 1400 through 21\d\d - end - s - end - def text - all - end - self - end - self - end - end - class MdMake < SiSU_Param_Make::MdMake - end - class Md - def initialize(str,opt,env) - @s,@opt,@env=str,opt,env - end - def validate_length(s,l,n) - #s=(s.length <= l) ? s : nil - s=if s.is_a?(String) \ - and s.length <= l - s - elsif s.is_a?(NilClass) - nil - elsif s.class !=String - STDERR.puts "#{n} is #{s.class}: programming error, String expected #{__FILE__}:#{__LINE__}" - s - else - SiSU_Screen::Ansi.new( - 'v', - "*WARN* #{n} length #{s.length} exceeds set db field length #{l}, metadata dropped", - @opt.fns - ).warn unless @opt.act[:quiet][:set]==:on - nil - end - end - def name_format(name) - if name - name=name.strip - @name_a_h=[] - authors=name.scan(/[^;]+/) - authors.each_with_index do |a,i| - b=((a =~/\s*\|\s*/) ? (a.split(/\|/)) : [a]) - if b[0] =~/"(.+?)"/ - @name_a_h << { the: $1 } - else - x=b[0].scan(/[^,]+/) - if x.length==1 - @name_a_h << { the: x[0].strip } - elsif x.length==2 - @name_a_h << { the: x[0].strip, others: x[1].strip } - else #p x.length - end - end - b.delete_at(0) - b.each do |d| - k,c=nil - k,c=/^(\S+)\s+(.*)/.match(d)[1,2] if d - @name_a_h[i][:hon]=c.strip if k=='hon' - @name_a_h[i][:affiliation]=c.strip if k=='affiliation' - @name_a_h[i][:nationality]=c.strip if k=='nationality' - end - end - l=@name_a_h.length - name_str='' - @name_a_h.each_with_index do |a,i| - name_str += if a[:others] - z=(((l - i) > 1) ? ', ' : '') - "#{a[:others].strip} #{a[:the].strip}" + z - else - z=(((l - i) > 2) ? ', ' : '') - "#{a[:the].strip}" + z - end - end - { name_a_h: @name_a_h, name_str: name_str } - else nil - end - end - def build_hash(arr) - @h={} - arr.each_with_index do |x,i| - a,b=nil,nil - if x =~/^%\s/ #ignore comment - elsif x =~/:(\S+?):\s+(.+)/ - a,b=/:(\S+?):\s+(.+)\Z/m.match(x)[1,2] - b=b.gsub(/\s*\s*/,' \\\\\\ ') - b=if b =~/\n/m - (b =~/;\n/m) \ - ? (b.split(/;\s*\n\s*/).join(';')) - : (b.split(/\s*\n\s*/).join(' ')) - else - b - end - elsif i == 0 - a='main' - b=x - else - end - @h[a]=b - end - @h - end - def title - a=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m) - @h=build_hash(a) - def main - s=@h['main'] - l,n=Db[:col_title_part],'title.main' - validate_length(s,l,n) - end - def sub - s=@h['subtitle'] - l,n=Db[:col_title_part],'title.subtitle' - validate_length(s,l,n) - end - def edition - s=@h['edition'] - l,n=Db[:col_title_edition],'title.edition' - validate_length(s,l,n) - end - def note - s=@h['note'] - l,n=Db[:col_info_note],'title.note' - validate_length(s,l,n) - end - def short - s=@h['short'] \ - ? @h['short'] - : @h['main'] - l,n=Db[:col_title_part],'title.short' - validate_length(s,l,n) - end - def full - s=@h['subtitle'] \ - ? (@h['main'] + ' - ' + @h['subtitle']) - : @h['main'] - l,n=Db[:col_title],'title.full' - validate_length(s,l,n) - end - def language - s=@h['language'] - l,n=Db[:col_language],'title.language' - validate_length(s,l,n) - end - def language_char # look into, this must be set, from 1 directory stub (.fi), 2 filename (~fi), [3 (not used) document header (@title:\n :language_char: fi)] - s=@h['language_char'] - l,n=Db[:col_language_char],'title.language_char' - validate_length(s,l,n) - end - self - end - def creator #there are sub categories that need to be catered for and sometimes more than one author etc.; implement array.to_s.length validation test later, current test on string approximate as string is not used - a=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m) - @h=build_hash(a) - def author - @h['author']=(@h['author'] \ - ? @h['author'] - : @h['main']) - names=name_format(@h['author']) - s=names[:name_str] - l,n=Db[:col_name],'creator.author' - validate_length(s,l,n) - end - def author_detail - s=@h['author'] \ - ? @h['author'] - : @h['main'] - names=name_format(s) - names[:name_a_h] - end - def editor - names=@h['editor'] \ - ? name_format(@h['editor']) - : nil - s=(names.is_a?(Hash)) \ - ? names[:name_str] - : nil - s=if s - l,n=Db[:col_name],'creator.editor' - validate_length(s,l,n) - else nil - end - end - def editor_detail - names=@h['editor'] \ - ? name_format(@h['editor']) - : nil - (names.is_a?(Hash)) \ - ? names[:name_a_h] - : nil - end - def contributor - names=@h['contributor'] \ - ? name_format(@h['contributor']) - : nil - s=(names.is_a?(Hash)) \ - ? names[:name_str] - : nil - s=if s - l,n=Db[:col_name],'creator.author' - validate_length(s,l,n) - else nil - end - end - def contributor_detail - names=@h['contributor'] \ - ? name_format(@h['contributor']) - : nil - (names.is_a?(Hash)) \ - ? names[:name_a_h] - : nil - end - def illustrator - names=@h['illustrator'] \ - ? name_format(@h['illustrator']) - : nil - s=(names.is_a?(Hash)) \ - ? names[:name_str] - : nil - s=if s - l,n=Db[:col_name],'creator.illustrator' - validate_length(s,l,n) - else nil - end - end - def illustrator_detail - names=@h['illustrator'] \ - ? name_format(@h['illustrator']) - : nil - (names.is_a?(Hash)) \ - ? names[:name_a_h] - : nil - end - def photographer - names=@h['photographer'] \ - ? name_format(@h['photographer']) - : nil - s=(names.is_a?(Hash)) \ - ? names[:name_str] - : nil - s=if s - l,n=Db[:col_name],'creator.photographer' - validate_length(s,l,n) - else nil - end - end - def photographer_detail - names=@h['photographer'] \ - ? name_format(@h['photographer']) - : nil - (names.is_a?(Hash)) \ - ? names[:name_a_h] - : nil - end - def translator - names=@h['translator'] \ - ? name_format(@h['translator']) - : nil - s=(names.is_a?(Hash)) \ - ? names[:name_str] - : nil - s=if s - l,n=Db[:col_name],'creator.translator' - validate_length(s,l,n) - else nil - end - end - def translator_detail - names=@h['translator'] \ - ? name_format(@h['translator']) - : nil - (names.is_a?(Hash)) \ - ? names[:name_a_h] - : nil - end - def audio - names=@h['audio'] \ - ? name_format(@h['audio']) - : nil - s=(names.is_a?(Hash)) \ - ? names[:name_str] - : nil - s=if s - l,n=Db[:col_name],'creator.audio' - validate_length(s,l,n) - else nil - end - end - def audio_detail - names=@h['audio'] \ - ? name_format(@h['audio']) - : nil - (names.is_a?(Hash)) \ - ? names[:name_a_h] - : nil - end - def digitized_by - names=@h['digitized_by'] \ - ? name_format(@h['digitized_by']) - : nil - s=(names.is_a?(Hash)) \ - ? names[:name_str] - : nil - s=if s - l,n=Db[:col_name],'creator.digitized_by' - validate_length(s,l,n) - else nil - end - end - def digitized_by_detail - names=@h['digitized_by'] \ - ? name_format(@h['digitized_by']) - : nil - (names.is_a?(Hash)) \ - ? names[:name_a_h] - : nil - end - def prepared_by - names=@h['prepared_by'] \ - ? name_format(@h['prepared_by']) - : nil - s=(names.is_a?(Hash)) \ - ? names[:name_str] - : nil - s=if s - l,n=Db[:col_name],'creator.prepared_by' - validate_length(s,l,n) - else nil - end - end - def prepared_by_detail - names=@h['prepared_by'] \ - ? name_format(@h['prepared_by']) - : nil - names=name_format(@h['prepared_by']) - (names.is_a?(Hash)) \ - ? names[:name_a_h] - : nil - end - self - end - def rights - a=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m) - @h=build_hash(a) - def copyright - def text #you may wish to expand to take from all - s=if @h['copyright'] then @h['copyright'] - elsif @h['text'] then @h['text'] - elsif @h['main'] then @h['main'] - else - SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - 'WARNING Document Copyright missing; provide @rights: :copyright:' - ).warn unless @opt.act[:quiet][:set]==:on - '' - end - l,n=Db[:col_info_note],'rights.copyright.text' - validate_length(s,l,n) - end - def translation - s=@h['translation'] \ - ? @h['translation'] - : nil - l,n=Db[:col_info_note],'rights.copyright.translation' - validate_length(s,l,n) - end - def illustrations - s=@h['illustrations'] \ - ? @h['illustrations'] - : nil - l,n=Db[:col_info_note],'rights.copyright.illustrations' - validate_length(s,l,n) - end - def photographs - s=@h['photographs'] \ - ? @h['photographs'] - : nil - l,n=Db[:col_info_note],'rights.copyright.photographs' - validate_length(s,l,n) - end - def digitization - s=@h['digitization'] \ - ? @h['digitization'] - : nil - l,n=Db[:col_info_note],'rights.copyright.digitization' - validate_length(s,l,n) - end - def audio - s=@h['audio'] \ - ? @h['audio'] - : nil - l,n=Db[:col_info_note],'rights.copyright.audio' - validate_length(s,l,n) - end - self - end - def license - s=@h['license'] \ - ? @h['license'] - : nil - l,n=Db[:col_info_note],'rights.license' - validate_length(s,l,n) - end - def sep(str) - ' \\\\ ' - end - def all - s=if @h['all'] then @h['all'] - else - s='' - if defined? copyright.text \ - and copyright.text \ - and not copyright.text.empty? - v=sep(copyright.text) - s +='Copyright: ' + copyright.text + v - end - if defined? copyright.translation \ - and copyright.translation \ - and not copyright.translation.empty? - v=sep(copyright.translation) - s +='translation: ' + copyright.translation + v - end - if defined? copyright.illustrations \ - and copyright.illustrations \ - and not copyright.illustrations.empty? - v=sep(copyright.illustrations) - s +='illustrations: ' + copyright.illustrations + v - end - if defined? copyright.photographs \ - and copyright.photographs \ - and not copyright.photographs.empty? - v=sep(copyright.photographs) - s +='photographs: ' + copyright.photographs + v - end - if defined? copyright.digitization \ - and copyright.digitization \ - and not copyright.digitization.empty? - v=sep(copyright.digitization) - s +='digitization: ' + copyright.digitization + v - end - if defined? copyright.audio \ - and copyright.audio \ - and not copyright.audio.empty? - v=sep(copyright.audio) - s +='audio: ' + copyright.audio + v - end - if defined? copyright.license \ - and copyright.license \ - and not copyright.license.empty? - s +='License: ' + copyright.license - end - if s.empty? - SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - 'WARNING Document Rights information missing; provide @rights: :copyright:' - ).warn unless @opt.act[:quiet][:set]==:on - else - l,n=Db[:col_info_note],'rights.all' - validate_length(s,l,n) - end - s=s.gsub(/ [\\]+\s+$/,'') - end - s - end - self - end - def identifier - a=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m) - @h=build_hash(a) - def oclc - s=@h['oclc'] - l,n=Db[:col_library],'identifier.oclc' - validate_length(s,l,n) - end - def isbn - s=@h['isbn'] - l,n=Db[:col_small],'identifier.isbn' - validate_length(s,l,n) - end - def pg - s=@h['pg'] - l,n=Db[:col_small],'identifier.pg' - validate_length(s,l,n) - end - self - end - def classify - a=@s.split(/(\n%\s.+?$|[ ]*)(?:\n[ ]*(?=:)|\Z)/m) - @h=build_hash(a) - def topic_register - s=@h['topic_register'] - l,n=Db[:col_info_note],'classify.topic_register' - validate_length(s,l,n) - end - def subject - s=@h['subject'] - l,n=Db[:col_txt_long],'classify.subject' - validate_length(s,l,n) - end - def keywords - s=@h['keywords'] - l,n=Db[:col_txt_long],'classify.keywords' - validate_length(s,l,n) - end - def loc - s=@h['loc'] - l,n=Db[:col_library],'classify.loc' - validate_length(s,l,n) - end - def dewey - s=@h['dewey'] - l,n=Db[:col_library],'classify.dewey' - validate_length(s,l,n) - end - self - end - def publisher - a=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m) - @h=build_hash(a) - s=@h['main'] - l,n=Db[:col_name],'publisher' - validate_length(s,l,n) - end - def date - a=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m) - @h=build_hash(a) - def added_to_site - s=@h['added_to_site'] - l,n=Db[:col_date_text],'date.added_to_site' - validate_length(s,l,n) - end - def available - s=@h['available'] - l,n=Db[:col_date_text],'date.available' - validate_length(s,l,n) - end - def created - s=@h['created'] - l,n=Db[:col_date_text],'date.created' - validate_length(s,l,n) - end - def issued - s=@h['issued'] - l,n=Db[:col_date_text],'date.issued' - validate_length(s,l,n) - end - def modified - s=@h['modified'] - l,n=Db[:col_date_text],'date.modified' - validate_length(s,l,n) - end - def published - s=@h['published']=(@h['published'] ? @h['published'] : @h['main']) - l,n=Db[:col_date_text],'date.published' - validate_length(s,l,n) - end - def valid - s=@h['valid'] - l,n=Db[:col_date_text],'date.valid' - validate_length(s,l,n) - end - self - end - #def language # as things stand this should really be populated from title.language and original.language, resolve - # a=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m) - # @h=build_hash(a) - # def document - # s=@h['document']=(@h['document'] ? @h['document'] : @h['main']) - # l,n=Db[:col_language],'language.document' - # validate_length(s,l,n) - # end - # def document_char - # s=@h['document_char']=(@h['document_char'] ? @h['document_char'] : nil) - # l,n=Db[:col_language_char],'language.document_char' - # validate_length(s,l,n) - # end - # def original - # s=@h['original'] - # l,n=Db[:col_language],'language.original' - # validate_length(s,l,n) - # end - # def original_char - # s=@h['original_char'] - # l,n=Db[:col_language_char],'language.original_char' - # validate_length(s,l,n) - # end - # self - #end - def current_publisher - @s - end - def original - a=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m) - @h=build_hash(a) - def publisher - s=@h['publisher'] - l,n=Db[:col_name],'original.publisher' - validate_length(s,l,n) - end - def language - s=@h['language'] - l,n=Db[:col_language],'original.language' - validate_length(s,l,n) - end - def language_char - s=@h['language_char'] - l,n=Db[:col_language_char],'original.language_char' - validate_length(s,l,n) - end - def source - s=@h['source'] - l,n=Db[:col_name],'original.source' - validate_length(s,l,n) - end - def institution - s=@h['institution'] - l,n=Db[:col_name],'original.institution' - validate_length(s,l,n) - end - def nationality - s=@h['nationality'] - l,n=Db[:col_language],'original.nationality' - validate_length(s,l,n) - end - self - end - def notes - a=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m) - @h=build_hash(a) - def description - s=@h['description'] - l,n=Db[:col_info_note],'notes.description' - validate_length(s,l,n) - end - def abstract - s=@h['abstract'] - l,n=Db[:col_info_note],'notes.abstract' - validate_length(s,l,n) - end - def comment - s=@h['comment'] - l,n=Db[:col_info_note],'notes.comment' - validate_length(s,l,n) - end - def coverage - s=@h['coverage'] - l,n=Db[:col_info_note],'notes.coverage' - validate_length(s,l,n) - end - def relation - s=@h['relation'] - l,n=Db[:col_info_note],'notes.relation' - validate_length(s,l,n) - end - def source - s=@h['source'] - l,n=Db[:col_txt_long],'notes.source' - validate_length(s,l,n) - end - def history - s=@h['history'] - l,n=Db[:col_txt_long],'notes.history' - validate_length(s,l,n) - end - def type - s=@h['type'] - l,n=Db[:col_txt_long],'notes.relation' - validate_length(s,l,n) - end - def format - s=@h['format'] - l,n=Db[:col_txt_short],'notes.format' - validate_length(s,l,n) - end - def prefix - @h['prefix'] - end - self - end - end - class Instructions - @doc={ lv: [] } - @doc[:fns],@doc[:fnb],@doc[:scr_suffix]='','','' - @@publisher='SiSU scribe' - attr_accessor :make,:env,:path,:file,:fn,:fns,:fno,:fnb,:fnn,:fnt,:fnl,:flv,:fnz,:fnstex,:ocn,:sfx_src,:pdf,:file_type,:dir_out,:dir_tex,:dir_lout,:txt_path,:sisu,:sisu_version,:ruby_version,:title,:subtitle,:full_title,:html_title,:subtitle_tex,:creator,:classify,:author_home,:author,:author_title,:author_nationality,:authors,:authorship,:translator,:illustrator,:prepared_by,:digitized_by,:subject,:description,:publisher,:current_publisher,:contributor,:date,:date_created,:date_issued,:date_available,:date_valid,:date_modified,:date_translated,:date_added_to_site,:date_scheme,:date_created_scheme,:date_issued_scheme,:date_available_scheme,:date_valid_scheme,:date_modified_scheme,:type,:format,:identifier,:source,:language,:language_original,:relation,:coverage,:rights,:keywords,:comments,:abstract,:cls_loc,:cls_dewey,:cls_pg,:cls_isbn,:papersize,:papersize_array,:toc,:lv0,:lv1,:lv2,:lv3,:lv4,:lv5,:lv6,:lvs,:pagenew,:pagebreak,:pageline,:num_top,:bold_match_list,:italics_match_list,:substitution_match_list,:emphasis_set_to,:toc_lev_limit,:flag_endnotes,:flag_auto_endnotes,:flag_separate_endnotes,:flag_separate_endnotes_make,:markup,:markup_instruction,:flag_tables,:vocabulary,:doc_css,:yaml,:lnk,:links,:prefix_a,:prefix_b,:suffix,:information,:contact,:icon,:image,:ad_url,:ad_png,:ad_alt,:ad_began,:flag_promo,:promo,:ad_home,:stmp,:stmpd,:sc_filename,:sc_number,:sc_date,:sc_time,:sc_info,:yamladdr,:locale,:wc_lines,:wc_words,:wc_bytes,:file_encoding,:filesize,:user,:home,:hostname,:pwd,:firstseg,:programs,:author_copymark,:i18n,:lang,:lang_code_insert,:en,:notes,:dgst,:generated,:tags,:tag_array,:concord_make,:seg_names,:seg_autoname_safe,:set_header_title,:set_heading_top,:set_heading_seg,:heading_seg_first,:heading_seg_first_flag,:base_program,:ec,:opt,:sem_tag,:book_idx,:topic_register,:topic_register_array,:original,:writing_focus,:audio,:daisy,:home_button_image,:home_button_links,:footer_links,:cover_image,:man_section - def initialize(fns_array,opt) - @env=@path,@file=@fn=@fns=@fno=@fnb=@fnn=@fnt=@fnl=@flv=@fnz=@fnstex=@ocn=@sfx_src=@pdf=@file_type=@dir_out=@dir_tex=@dir_lout=@txt_path=@make=@flag_endnotes=@flag_auto_endnotes=@flag_separate_endnotes=@flag_separate_endnotes_make=@sisu=@sisu_version=@ruby_version=@title=@subtitle=@full_title=@html_title=@subtitle_tex=@creator=@classify=@author_home=@author=@author_title=@author_nationality=@translator=@illustrator=@prepared_by=@digitized_by=@subject=@description=@publisher=@current_publisher=@contributor=@date=@date_created=@date_issued=@date_available=@date_valid=@date_modified=@date_translated=@date_added_to_site=@date_scheme=@date_created_scheme=@date_issued_scheme=@date_available_scheme=@date_valid_scheme=@date_modified_scheme=@type=@format=@identifier=@source=@language=@language_original=@relation=@coverage=@rights=@keywords=@comments=@abstract=@cls_loc=@cls_dewey=@cls_pg=@cls_isbn=@papersize=@toc=@lv0=@lv1=@lv2=@lv3=@lv4=@lv5=@lv6=@pagenew=@pagebreak=@pageline=@num_top=@bold_match_list=@italics_match_list=@substitution_match_list=@emphasis_set_to=@toc_lev_limit=@flag_tables=@vocabulary=@doc_css=@yaml=@lnk=@links=@prefix_a=@prefix_b=@suffix=@information=@contact=@icon=@ad_url=@ad_png=@ad_alt=@ad_began=@promo=@ad_home=@stmp=@stmpd=@sc_filename=@sc_number=@sc_date=@sc_time=@sc_info=@yamladdr=@locale=@wc_lines=@wc_words=@wc_bytes=@file_encoding=@filesize=@firstseg=@programs=@author_copymark=@i18n=@lang=@lang_code_insert=@en=@notes=@dgst=@generated=@heading_seg_first=@base_program=@topic_register=@original=@writing_focus=@audio=@home_button_image=@home_button_links=@cover_image=@man_section=nil - @data, @path, @fns, @fno, @opt= - fns_array,opt.pth,opt.fns,opt.fno,opt #@data used as data - @flag_tables,@set_header_title,@set_heading_top,@set_heading_seg,@heading_seg_first_flag,@flag_promo,@book_idx= - false, false, false, false, false, false, false - @seg_autoname_safe=true - @daisy,@sem_tag=false,false - @authorship,@markup_instruction,@image='','','','' #check which other values should be set to empty rather than nil - @markup=@markup_instruction #use @markup_instruction - @doc,@fn,@make_italic,@tag_hash,@ec={},{},{},{},{},{} - @flv,@lang,@seg_names,@tags,@tag_array,@tag_a,@ec[:image],@ec[:audio],@ec[:multimedia]=Array.new(9){[]} - @authors,@topic_register_array,@papersize_array=[],[],[] - @lvs=[nil,0,0,0,0,0,0] - @emphasis_set_to='bold' - @lang_code_insert=SiSU_Env::FilenameLanguageCodeInsert.new(@opt).language_code_insert - @footer_links= { left: { say: '', url: '' }, center: { say: '', url: '' } } - @rgx_image=/(?:^|[^_\\])\{(?:\s*|\~\^\s+)(\S+?\.(?:png|jpg|gif)\b)/m - @rgx_audio=/\{\s*(\S+?\.(?:mp3|ogg))/ - @rgx_mm=/\{\s*(\S+?\.(?:ogg|mpeg))/ #expand and distinguish ogg - Dir.chdir(@opt.f_pth[:pth]) - begin - rescue - SiSU_Errors::Rescued.new($!,$@,@opt.cmd,@fns).location do - __LINE__.to_s + ':' + __FILE__ - end - ensure - end - @header_make_links_append=:no - common_makes=(defined? @opt.make_instructions_pod) \ - && @opt.make_instructions_pod !=nil \ - && @opt.make_instructions_pod[:makeset]==true \ - ? @opt.make_instructions_pod - : @opt.make_instructions - if common_makes[:makeset] - @pagenew=common_makes[:pagenew] - @pagebreak=common_makes[:pagebreak] - @pageline=common_makes[:pageline] - @toc=common_makes[:toc] - @lv0=common_makes[:lv0] - @lv1=common_makes[:lv1] - @lv2=common_makes[:lv2] - @lv3=common_makes[:lv3] - @lv4=common_makes[:lv4] - @lv5=common_makes[:lv5] - @lv6=common_makes[:lv6] - @num_top=common_makes[:num_top] - @i18n=common_makes[:i18n] - @man_section=common_makes[:man_section] - @emphasis_set_to=common_makes[:emphasis_set_to] - @bold_match_list=common_makes[:bold_match_list] - @italics_match_list=common_makes[:italics_match_list] - @substitution_match_list=common_makes[:substitution_match_list] - @footer_links=common_makes[:footer_links] - @home_button_links=common_makes[:home_button_links] - @home_button_image=common_makes[:home_button_image] - @cover_image=common_makes[:cover_image] - @lnk=@links=common_makes[:links] - @header_make_links_append=common_makes[:links_append] - end - end - #protected - def extract - @user,@home,@hostname,@pwd=ENV['USER'],ENV['HOME'],ENV['HOSTNAME'],ENV['PWD'] - @programs,@wc,@language,@language_original={},{},{},{} - @en={ sum: 0, mark: 0, note: 0, mismatch: 0 } - @prog=SiSU_Env::InfoSettings.new - @sys=SiSU_Env::SystemCall.new - @env=SiSU_Env::InfoEnv.new(@fns) #watch - if (@opt.act[:verbose_plus][:set]==:on \ - || @opt.act[:maintenance][:set]==:on) - puts 'system locale: ' + @sys.locale - end - if @prog.wc \ - and @sys.wc - wc=%x{wc #{fns}} - wca=wc.scan(/\d+/) - @wc_lines,@wc_words,@wc_bytes=wca[0].to_i,wca[1].to_i,wca[2].to_i - else - fns_a=@data.dup - tmp=fns_a.join - fns_a=tmp.scan(/\S+/) - @wc_words=fns_a.length - fns_a=tmp=nil - end - @concord_make=(@wc_words > @env.concord_max) ? false : true - @locale=@sys.locale - @file_encoding=@sys.file_encoding(fns,@opt.cmd) - # programs set here for things that affect output appearance only - @programs[:pdf]=SiSU_Env::SystemCall.new.program_found?('pdflatex') - if @opt.cmd =~/P/ #if @env.multilingual? - m=/((.+?)(?:\~\w\w(?:_\w\w)?)?)\.((?:-|ssm\.)?sst|ssm|ssi)$/ #watch added match for sss - @fnn,@fnb,@fnt=@fns[m,1],@fns[m,2],@fns[m,3] - @flv=@env.document_language_versions_found[:f] - else - m=/((.+?)(?:\~\w\w(?:_\w\w)?)?)\.((?:-|ssm\.)?sst|ssm)$/ #watch added match for sss - @fnn,@fnb,@fnt=@fns[m,1],@fns[m,2],@fns[m,3] - @flv=@env.document_language_versions_found[:f] - @fnz=(@fns =~/\.(?:ssm\.sst|ssm)$/) ? (@fnn + '.ssm.txz') : (@fnn + '.sst.txz') - end - @papersize=@env.papersize #'A4' #default size #get first from SiSU_Env:: # @env is probably no longer most appropriate name! as default info is more general - @sfx_src=@fns[m,2] - if @fns =~ /(?:-|ssm\.)?sst$/ \ - and not @opt.cmd =~/P/ #watch - @env_out_root=@env.path.output - @dir_out="#{@env.path.output}/#{@fnb}" - @dir_tex=@env.processing_path.tex - @dir_lout=@env.processing_path.lout - @@publisher='SiSU http://www.jus.uio.no/sisu' - end - @txt_path=@txt_path ||= @env.path.output - @stmp=%{#{@fns}}[/^(.+?)\..*/m,1] - @fnstex=@fns.gsub(/_/,'\_\-').gsub(/\./,'.\-') - @flag_endnotes,@flag_auto_endnotes,@flag_separate_endnotes=false,false,false - @flag_separate_endnotes_make=true - ver=SiSU_Env::InfoVersion.instance - @sisu_version=ver.get_version - @ruby_version=ver.rbversion - @generated=Time.now - fns_array=@data.dup - skip unless fns_array # consider - @code_flag=false - fns_array.each do |para| #% scan document - if para !~/^%+\s/ \ - and para =~/|

|
|
)\s*/,' '). - gsub(/~\{.+?\}~/,'') - SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - 'Parameters', - %{#{title}#{creator}} - ).txt_grey if @opt.act[:verbose][:set]==:on - end - if not @book_idx \ - and para =~/^=\{(.+?)\}[\s`]*\Z/m - @book_idx=true - end - unless @code_flag - case para - when /~\{\s+.+?\}~/m #% processing - en=para.scan(/~\{.+?\}~/m) - en.each { |e| @en[:sum] +=1 } - when /~\^(?:\s|$)/m #% processing - mk=para.scan(/~\^(?:\s|$)/) - mk.each { |e| @en[:mark] +=1 } - when /^\^~\s+\S/ then @en[:note] +=1 #% processing - end - end - if para =~/~\{|\^~ |~\^|\{.+?\[[1-6]\]\}\S+?\.ss[tm]/m - @flag_auto_endnotes,@flag_endnotes=true,true - end - if para =~/^(?:table\{|\{table)/i - @flag_tables=true - end - end - if para =~/^:?A~/ - @set_heading_top=true - end - if para =~/^1~/ - m=nil - if para =~/^1~(\S+)\s+(.+)$/ - m,t=$1,$2 - elsif para =~/^1~\s+(.+)$/ - t=$1 - end - unless @heading_seg_first_flag # extract first segment name - @heading_seg_first=t - @heading_seg_first_flag=true - end - if m # list all segment names - @seg_names << m - @set_heading_seg=true - if m=~/^\d{1,3}/ \ - and m !~/^0/ - @seg_autoname_safe=false - end - end - end - para=para.gsub(/<:=(\S+?)>/,'{ c_\1.png 14x14 }image') # embedded symbol (image) - if para !~/^%+\s/ \ - and para =~@rgx_image - @ec[:image] << para.scan(@rgx_image).uniq - end - @ec[:audio] << para.scan(@rgx_audio).uniq if para =~@rgx_audio #embedded content - @ec[:multimedia] << para.scan(@rgx_mm).uniq if para =~@rgx_mm #embedded content - unless @sem_tag - @sem_tag=true if para=~/[:;]\{.+?\}[:;][a-z+]/ #refix later - end - end #% here endeth the document loop - unless @make - if (@opt.act[:verbose_plus][:set]==:on \ - || @opt.act[:maintenance][:set]==:on) - SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - '@make:', - 'header absent' - ).warn - end - @make=SiSU_Param::Parameters::MdMake.new('@make: ',@opt,@env).make - end - if @cover_image \ - and @cover_image.is_a?(Hash) \ - and (@cover_image[:cover] =~@rgx_image \ - or @cover_image[:cover] =~/\S+?.(?:jpg|png|gif)/) - @ec[:image] << @cover_image[:cover] - end - if @home_button_image \ - and @home_button_image.is_a?(Hash) \ - and (@home_button_image =~@rgx_image \ - or @home_button_image =~/\S+?\.(?:jpg|png|gif)/) - @ec[:image] << @home_button_image - end - if @ec[:image].length > 0 - @ec[:image]=@ec[:image].flatten.uniq - @ec[:image].delete_if {|x| x =~/https?:\/\// } - @ec[:image]=@ec[:image].sort - end - @ec[:audio]=@ec[:audio].uniq.flatten.sort - @ec[:multimedia]=@ec[:multimedia].uniq.flatten.sort - unless @rights - if defined? @creator.author \ - and @creator.author.is_a?(String) \ - and defined? @date.published \ - and @date.published.is_a?(String) - @rights=SiSU_Param::Parameters::MdDefault.new.rights(@creator.author,@date.published) - elsif defined? @creator.author \ - and @creator.author.is_a?(String) - @rights=SiSU_Param::Parameters::MdDefault.new.rights("[#{@creator.author}]",'') - end - end - if defined? @classify.topic_register \ - and @classify.topic_register.is_a?(String) \ - and @classify.topic_register.length >3 - topic_register=@classify.topic_register - u=topic_register.scan(/[^;]+/m).sort - v=[] - u.each do |l| - v << l.scan(/[^:]+/m) - end - v.each do |s| - s[-1]=s[-1].scan(/[^|]+/m) if s[-1] =~/[|]/m - @topic_register_array << s - end - @topic_register_array - end - if @i18n - @i18n=@i18n.uniq - @i18n << 'en' unless @i18n.find_index("en") - else - @i18n=[ 'en' ] - end - translated=[] - translate_list=[@pagenew,@pagebreak,@pageline,@num_top,@toc_lev_limit] - translate_list.each do |t| - translate=t.to_s if t - translated << if translate - translate.gsub!(/3/,'6') - translate.gsub!(/2/,'5') - translate.gsub!(/1/,'4') - translate.gsub!(/:?C/,'3') - translate.gsub!(/:?B/,'2') - translate.gsub!(/:?A/,'1') - # looks like an ok substituion for the above but is not, causes problems, check why - #translate=translate.gsub(/3/,'6'). - # gsub(/2/,'5'). - # gsub(/1/,'4'). - # gsub(/:?C/,'3'). - # gsub(/:?B/,'2'). - # gsub(/:?A/,'1') - translate=(translate =~/^\d+$/) \ - ? translate.to_i - : translate - else nil - end - end - @pagenew,@pagebreak,@pageline,@num_top,@toc_lev_limit=translated - @markup=@markup.gsub(/page_new\s*=\s*([\dA-C])/,"page_new=#{@pagenew}"). - gsub(/page_break\s*=\s*([\dA-C])/,"page_break=#{@pagebreak}"). - gsub(/page_line\s*=\s*([\dA-C])/,"page_line=#{@pageline}"). - gsub(/num_top\s*=\s*([\dA-C])/,"num_top=#{@num_top}"). - gsub(/toc_lev_limit\s*=\s*([\dA-C])/,"toc_lev_limit=#{@toc_lev_limit}") - papersize_array_rc=@papersize.downcase.scan(/(?:a4|letter|legal|book|a5|b5)/) - papersize_array_opt=[ - ((@opt.act[:pdf_a4][:set]==:on) ? 'a4' : ''), - ((@opt.act[:pdf_a5][:set]==:on) ? 'a5' : ''), - ((@opt.act[:pdf_b5][:set]==:on) ? 'b5' : ''), - ((@opt.act[:pdf_letter][:set]==:on) ? 'letter' : ''), - ((@opt.act[:pdf_legal][:set]==:on) ? 'legal' : ''), - ] - [""] - @papersize_array=(papersize_array_opt.length > 0) \ - ? papersize_array_opt - : papersize_array_rc - fn=@opt.fno #decide what to do a filesize on .ssm tells very little about actual document size - @filesize=(File.size(fn)).to_s - if @sys.openssl !=false \ - and FileTest.file?(@env.source_file_with_path) - @dgst=[] - case @env.digest(@opt).type - when :sha512 - dgst=@sys.sha512(@env.source_file_with_path) - @dgst=dgst[1].length==128 ? dgst : nil - puts 'check document (sha512) digest' if not @dgst - when :sha256 - dgst=@sys.sha256(@env.source_file_with_path) - @dgst=dgst[1].length==64 ? dgst : nil - puts 'check document (sha256) digest' if not @dgst - when :md5 - dgst=@sys.md5(@env.source_file_with_path) - @dgst=dgst[1].length==32 ? dgst : nil - puts 'check document (md5) digest' if not @dgst - else - dgst=@sys.sha256(@env.source_file_with_path) - @dgst=dgst[1].length==64 ? dgst : nil - puts 'check document (sha256) digest' if not @dgst - end - elsif not FileTest.file?(@env.source_file_with_path) - #puts SiSU_Utils::CodeMarker.new(__LINE__,__FILE__).set(:fuchsia) - end - @publisher ||= "#{@@publisher} (this copy)" - fn_set_lang=SiSU_Env::StandardiseLanguage.new(@opt.lng).language - unless @language[:code] \ - and @language[:name] - lang=@env.i18n.language #default language settings for directory by name, or in sysrc.yml - @language[:code] ||= lang.code - @language[:name] ||= lang.title - end - unless fn_set_lang[:d]==true #decide, naming convention overrides other settings, within document, etc. - @language[:code]=fn_set_lang[:c] - @language[:name]=fn_set_lang[:n] - end - @fnl=@env.i18n.lang_filename(fn_set_lang[:c]) - @lang=@lang.uniq - @fn=SiSU_Env::EnvCall.new(@fns).lang(fn_set_lang[:c]) - if @en[:note] > 0 \ - and @en[:sum] > 0 - if @en[:sum] > 0 - else - SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - '*WARN* both endnote styles used', - "~{ #{@en[:sum]} }~ and ^~ #{@en[:mark]}" - ).warn unless @opt.act[:quiet][:set]==:on - end - end - if @en[:mark] != @en[:note] \ - and @en[:note] > 0 - @en[:mismatch]=@en[:note] - @en[:mark] - SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - '*WARN* endnote number mismatch', - "endnotes: #{@en[:note]} != endnote reference marks: #{@en[:mark]} (difference = #{@en[:mismatch]})" - ).warn unless @opt.act[:quiet][:set]==:on - footnote_conversion_errors=File.new("#{Dir.pwd}/footnote_conversion_errors.txt",'a') - footnote_conversion_errors << - "#{@fns}:\n\tendnotes: #{@en[:note]} != endnote reference marks: #{@en[:mark]} (difference = #{@en[:mismatch]})\n" - end - if not @title \ - or not defined? @title.main \ - or @title.main !~/[\S]/ - if @fns =~/\.ssm$/ \ - and @opt.inspect =~/P/ - #@title=Md.new('Text Insert',@opt,@env).title - else - SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - 'WARNING: Document Title missing', - 'please provide @title:' - ).warn unless @opt.act[:quiet][:set]==:on - end - end - if @author !~/[\S]/ - if @fns =~/\.ssm$/ \ - and @opt.inspect =~/P/ - #@creator=SiSU_Param::Md.new('Text Insert',@opt,@env).creator - else - SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - 'WARNING: Document Author missing', - 'please provide @creator: :author:' - ).warn unless @opt.act[:quiet][:set]==:on - end - end - @struct={} - doc_struct=Hash.new(0) - if @lv1.nil? - fns_array.each do |para| - if para =~/^(Part|Chapter|Section|Article)\b/i - case para - when /^(Part|PART)\b/ - @struct[:part]=doc_struct[:part] - doc_struct[:part]=doc_struct[:part] + 1 - when /^(Chapter|CHAPTER)\b/ - @struct[:chapter]=doc_struct[:chapter] - doc_struct[:chapter]=doc_struct[:chapter] + 1 - when /^(Section|SECTION)\b/ - @struct[:section]=doc_struct[:section] - doc_struct[:section]=doc_struct[:section] + 1 - when /^(Article|ARTICLE)\b/ - @struct[:article]=doc_struct[:article] - doc_struct[:article]=doc_struct[:article] + 1 - when /^(Clause|CLAUSE)\b/ - @struct[:clause]=doc_struct[:clause] - doc_struct[:clause]=doc_struct[:clause] + 1 - when /^\d\..*[^\.]$/ - @struct[:number]=doc_struct[:number] - doc_struct[:number]=doc_struct[:number] + 1 - end - end - end - if doc_struct[:article] > 2 #%~level 4 - @lv4=/^(?:Article|ARTICLE)\b/ - elsif doc_struct[:chapter] > 2 \ - and doc_struct[:article] \ - and doc_struct[:article] < 3 - @lv4=/^(?:Chapter|CHAPTER)\b/ - elsif doc_struct[:clause] > 2 - @lv4=/^(?:Clause|CLAUSE)\b/ - elsif doc_struct[:number] > 2 - @lv4="^\d\..*[^\.]$" - end - if doc_struct[:section] > 2 #%~level 3 - @lv3=/^(?:Section|SECTION)\b/ - end - if doc_struct[:chapter] > 2 \ - and doc_struct[:article] \ - and doc_struct[:article] > 2 - @lv2=/^(?:Chapter|CHAPTER)\b/ - end - if doc_struct[:part] > 2 \ - and @lv[2].nil? - @lv2=/^(?:Part|PART)\b/ - end - if doc_struct[:part] > 2 \ - and @lv[2].inspect !~/Part/ \ - and @lv[1].nil? - @lv1=/^(Part|PART)\b/ - end - end - @lnk=@lnk.compact if @lnk - @lv0 ||=/^0~/ - @lv1 ||=/^1~/ - @lv2 ||=/^2~/ - @lv3 ||=/^3~/ - @lv4 ||=/^4~/ - @lv5 ||=/^5~/ - @lv6 ||=/^6~/ - @data=nil #else whole file's contents are stored in md pstore & is not required to be... big waste actually - @file=SiSU_Env::FileOp.new(self) #watch - Store.new(self,@env).store #% pstore - self - end - private - class Store - def initialize(md,env) - @md,@env=md,env - end - def store - begin - pstorefile="#{@env.processing_path.ao}/#{@md.fns}.pstore" - File.unlink(pstorefile) if FileTest.file?(pstorefile) - if (@md.opt.act[:verbose_plus][:set]==:on \ - || @md.opt.act[:maintenance][:set]==:on) - SiSU_Screen::Ansi.new( - @md.opt.act[:color_state][:set], - "PStore -> #{pstorefile}" - ).txt_grey - end - store=PStore.new(pstorefile) - store.transaction do - store['md']=@md - store.commit - end - @@md=@md=nil - rescue - SiSU_Errors::Rescued.new($!,$@,@md.opt.cmd,@md.fns).location do - __LINE__.to_s + ':' + __FILE__ - end - ensure - end - end - end - end - end - class Instantiate - def param_instantiate - @@date=SiSU_Env::InfoDate.new - @@proc= - @@filename_txt= - @@filename_texinfo= - @@filename_lout_portrait= - @@filename_lout_landscape= - @@filename_html_scroll= - @@filename_html_index= - @@filename_html_segtoc= - @@filename_semantic= - @@filename_rss= - @@newfile= - @@drr= - nil - @doc={ - initialise: nil, - markup: '', - lnks: '', - stmp: '', - prefix_a: '', - prefix_b: '', - req: {} - } - @@yaml=@@yamladdr=nil - @@flag={} - @@publisher='SiSU scribe' - end - end -end -__END__ diff --git a/lib/sisu/v5/param_identify_markup.rb b/lib/sisu/v5/param_identify_markup.rb deleted file mode 100644 index f6884c7d..00000000 --- a/lib/sisu/v5/param_identify_markup.rb +++ /dev/null @@ -1,167 +0,0 @@ -# encoding: utf-8 -=begin - - * Name: SiSU - - * Description: a framework for document structuring, publishing and search - - * Author: Ralph Amissah - - * Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, - All Rights Reserved. - - * License: GPL 3 or later: - - SiSU, a framework for document structuring, publishing and search - - Copyright (C) Ralph Amissah - - This program is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the Free - Software Foundation, either version 3 of the License, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - more details. - - You should have received a copy of the GNU General Public License along with - this program. If not, see . - - 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: - - - * Git - - - - * Ralph Amissah - - - - ** 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 - -=end -module SiSU_MarkupType - class MarkupIdentify - @@version={} - @@fns,@@version[:determined],@@version[:declared],@@declared_doc_type='','','','[text?]' - attr_accessor :version,:declared_doc_type - def initialize(content,opt) - @cont,@opt=content,opt - end - def identify - @version,@declared_doc_type=@@version,@@declared_doc_type - if @opt.fns != @@fns - if @cont[0] =~ /^(?:%\s+)?SiSU\s+(text|master|insert)\s+([0-9](?:\.[0-9]+){1,2})/ \ - or @cont[0] =~ /^(?:%\s+)?sisu-([0-9](?:\.[0-9]+){1,2})/ - @declared_doc_type,@version[:declared]=$1,$2 - elsif @cont[0] =~ /^(?:%\s+)?SiSU\s+([0-9](?:\.[0-9]+){1,2})/ \ - or @cont[0] =~ /^(?:%\s+)?sisu-([0-9](?:\.[0-9]+){1,2})/ - @version[:declared]=$1 - end - @flag_2_0,@flag_66,@flag_57,@flag_38=false,false,false,false - @cont.each_with_index do |y,i| - if y =~/^@make:|^@classify|^\s\s?:\S+?:\s+\S/ - version=2.0.to_f - @version[:determined]=version - @flag_2_0=true - break - end - unless @flag_38 - if y =~/^:?A~/ - version=0.38.to_f - @version[:determined]=version - @flag_38=true - end - end - if @flag_38 - if @flag_69 \ - or y =~/^=\{.+?\}\s*$/ - version=0.69.to_f - @flag_69=true - @version[:determined]=version - break - end - if @flag_66 \ - or y =~/[:;]\{.+?\}[:;][a-z+]/ - version=0.66.to_f - @flag_66=true - @version[:determined]=version - break - end - end - end - @flag_57,@flag_38=false,false - unless @flag_2_0 \ - or @flag_66 \ - or @flag_69 - @cont.each_with_index do |y,i| - if @flag_57 \ - or y =~/^:?A~\?? @title/ - @version[:determined]=0.57.to_f - @flag_57=true - break - end - if @flag_38 \ - or y =~/^:?A~/ - @version[:determined]=0.38.to_f - @flag_38=true - break if i >= 200 - if y =~ /(?:~{\*+|~\[\*|~\[\+)\s/ - @version[:determined]=0.42 #0.38 can safely be treated as 0.42 - break - end - end - if y =~/^0~/ \ - and not @flag_38 - @version[:determined]=0.16.to_f - break - end - end - end - @@fns=@opt.fns - @@version,@@declared_doc_type=@version,@declared_doc_type - end - self - end - def markup_version? - def determined - identify.version[:determined].to_f - end - def series - s=case identify.version[:determined].to_s - when /^[01]\./ then '1.0' - when /^[2]\./ then '2.0' - else '2.0' - end - "series #{s}" - end - def declared - identify.version[:declared].to_f - end - self - end - end -end -__END__ diff --git a/lib/sisu/v5/param_make.rb b/lib/sisu/v5/param_make.rb deleted file mode 100644 index 578e4fb9..00000000 --- a/lib/sisu/v5/param_make.rb +++ /dev/null @@ -1,674 +0,0 @@ -# encoding: utf-8 -=begin - - * Name: SiSU - - * Description: a framework for document structuring, publishing and search - - * Author: Ralph Amissah - - * Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, - All Rights Reserved. - - * License: GPL 3 or later: - - SiSU, a framework for document structuring, publishing and search - - Copyright (C) Ralph Amissah - - This program is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the Free - Software Foundation, either version 3 of the License, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public Lic/home/ralph/live-manual/build/manual/manifest/live-manual.ca.htmlense 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: - - - * Git - - - - * Ralph Amissah - - - - ** Description: make parameters extracted for program use - -=end - -module SiSU_Param_Make - class MdMake - def initialize(str,opt,env) - @s,@opt,@env=str,opt,env - end - def validate_length(s,l,n) - #s=(s.length <= l) ? s : nil - s=if s.is_a?(String) \ - and s.length <= l - s - elsif s.is_a?(NilClass) - nil - elsif s.class !=String - STDERR.puts "#{n} is #{s.class}: programming error, String expected #{__FILE__}:#{__LINE__}" - s - else - SiSU_Screen::Ansi.new( - 'v', - "*WARN* #{n} length #{s.length} exceeds set db field length #{l}, metadata dropped", - @opt.fns - ).warn unless @opt.act[:quiet][:set]==:on - nil - end - end - def name_format(name) - if name - name=name.strip - @name_a_h=[] - authors=name.scan(/[^;]+/) - authors.each_with_index do |a,i| - b=((a =~/\s*\|\s*/) ? (a.split(/\|/)) : [a]) - if b[0] =~/"(.+?)"/ - @name_a_h << { the: $1 } - else - x=b[0].scan(/[^,]+/) - if x.length==1 - @name_a_h << { the: x[0].strip } - elsif x.length==2 - @name_a_h << { the: x[0].strip, others: x[1].strip } - else #p x.length - end - end - b.delete_at(0) - b.each do |d| - k,c=nil - k,c=/^(\S+)\s+(.*)/.match(d)[1,2] if d - @name_a_h[i][:hon]=c.strip if k=='hon' - @name_a_h[i][:affiliation]=c.strip if k=='affiliation' - @name_a_h[i][:nationality]=c.strip if k=='nationality' - end - end - l=@name_a_h.length - name_str='' - @name_a_h.each_with_index do |a,i| - name_str += if a[:others] - z=(((l - i) > 1) ? ', ' : '') - "#{a[:others].strip} #{a[:the].strip}" + z - else - z=(((l - i) > 2) ? ', ' : '') - "#{a[:the].strip}" + z - end - end - { name_a_h: @name_a_h, name_str: name_str } - else nil - end - end - def build_hash(arr) - @h={} - arr.each_with_index do |x,i| - a,b=nil,nil - if x =~/^%[:\s]/ #ignore comment - elsif x =~/:(\S+?):\s+(.+)/ - a,b=/:(\S+?):\s+(.+)\Z/m.match(x)[1,2] - elsif i == 0 - a='main' - b=x - else - end - @h[a]=b - end - @h - end - def make - a=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m) - @h=build_hash(a) - def headings - lv=[] - x=@h['headings'] - x=((x =~/;/) ? (x.split(/;\s*/)) : [ x ]) - lv[0]=x - lv0 ||='A~ ' #root level, single document apex, document title - lv1=x[0] ||='B~ ' - lv[1]=/^#{lv1}/ - lv2=x[1] ||='C~ ' - lv[2]=/^#{lv2}/ - lv3=x[2] ||='D~ ' - lv[3]=/^#{lv3}/ - lv4=x[3] ||='1~ ' - lv[4]=/^#{lv4}/ - lv5=x[4] ||='2~ ' - lv[5]=/^#{lv5}/ - lv6=x[5] ||='3~ ' - lv[6]=/^#{lv6}/ - lv - end - def num_top - @h['num_top'] - end - def breaks - pagebreaks=((@h['breaks'] =~/;/) \ - ? (@h['breaks'].split(/;\s*/)) - : [ @h['breaks'] ]) - page_new,page_break,page_line=nil,nil,nil - pagebreaks.each do |x| - page_new=x[/(:?[\dA-C],?)+/] if x=~/new|clear/ - page_break=x[/(:?[\dA-C],?)+/] if x =~/break/ - page_line=x[/(:?[\dA-C],?)+/] if x =~/line/ - end - { page_new: page_new, page_break: page_break, page_line: page_line } - end - def language - if @h['language'] && (@h['language']=~/\S{2,}/) - ((@h['language'] =~/,/) \ - ? (@h['language'].split(/,\s*/)) - : [ @h['language'] ]) - else [ 'en' ] - end - end - def bold - m=@h['bold'] - i=(m=~/\/i$/)? 'i' : '' - if m - x=m.gsub(/^\/(.+?)\/i?/,'\1'). - gsub(/\((?:\?:)?/,'(?:') # avoid need to escape use of brackets within regex provided - rgx='\b(' + x + ')\b' - y=((i =~/i/) ? (/#{rgx}/i) : (/#{rgx}/)) - { str: '\b(?:' + x + ')\b', regx: y, i: i } - else nil - end - end - def italics - m=@h['italics'] - i=((m=~/\/i$/) ? 'i' : '') - if m - x=m.gsub(/^\/(.+?)\/i?/,'\1'). - gsub(/\((?:\?:)?/,'(?:') # avoid need to escape use of brackets within regex provided - rgx='\b(' + x + ')\b' - y=((i =~/i/) ? (/#{rgx}/i) : (/#{rgx}/)) - { str: '\b(?:' + x + ')\b', regx: y, i: i } - else nil - end - end - def emphasis - if @h['emphasis'] =~/bold/ then 'bold' - elsif @h['emphasis'] =~/italics?/ then 'italics' - elsif @h['emphasis'] =~/under(?:line|score)/ then 'underscore' - else nil - end - end - def substitute - m=@h['substitute'] - if m - w=m.scan(/\/(.+?)\/(i?,)\s*'(.+?)'(?:\s+|\s*;\s*|$)/) - arr_hash=[] - matches='' - w.each do |x| - c=(x[1] =~/[i],/) ? :i : :s - matches=matches + x[0].gsub(/([${}])/,'\\\\\1') + '|' - arr_hash << { - match: x[0].gsub(/([${}])/,'\\\\\1'), - replace: x[2], - case_s: c - } - end - matches.chop! - { match_and_replace: arr_hash, matches: matches } - else nil - end - end - def plaintext_wrap - if @h['plaintext_wrap'].to_s =~/\d\d+/ \ - and @h['plaintext_wrap'].to_i > 19 \ - and @h['plaintext_wrap'].to_i < 201 - @h['plaintext_wrap'].to_i - else nil - end - end - def omit - m=@h['omit'] - @m=m ? (m.split(/,\s+/)) : nil - def list - @m - end - self - end - def ocn? - (omit.list.inspect =~/"ocn"/) \ - ? :off - : :na - end - def toc? - (omit.list.inspect =~/"toc"/) \ - ? :off - : :na - end - def manifest? - (omit.list.inspect =~/"manifest"/) \ - ? :off - : :na - end - def links_to_manifest? - (omit.list.inspect =~/"manifest_links"|"links_to_manifest"/) \ - ? :off - : :na - end - def metadata? - (omit.list.inspect =~/"metadata"/) \ - ? :off - : :na - end - def minitoc? - (omit.list.inspect =~/"minitoc"/) \ - ? :off - : :na - end - def html_minitoc? - (omit.list.inspect =~/"html_minitoc"/) \ - ? :off - : :na - end - def html_top_band? - (omit.list.inspect =~/"html_top_band"/) \ - ? :off - : :na - end - def html_navigation? - (omit.list.inspect =~/"html_navigation"/) \ - ? :off - : :na - end - def html_navigation_bar? - (omit.list.inspect =~/"html_navigation_bar"/) \ - ? :off - : :na - end - def segsubtoc? - (omit.list.inspect =~/"segsubtoc"/) \ - ? :off - : :na - end - def search_form? - (omit.list.inspect =~/"search_form"/) \ - ? :off - : :na - end - def html_search_form? - (omit.list.inspect =~/"html_search_form"/) \ - ? :off - : :na - end - def html_right_pane? - (omit.list.inspect =~/"html_right_column"|"html_right_pane"/) \ - ? :off - : :na - end - def manifest_minitoc? - (omit.list.inspect =~/"manifest_minitoc"/) \ - ? :off - : :na - end - def cover_image? - (omit.list.inspect =~/"cover_image"/) \ - ? :off - : :na - end - def home_button_image? - (omit.list.inspect =~/"home_button_image"/) \ - ? :off - : :na - end - def texpdf_font - def main - @h['texpdf_font'] \ - && (@h['texpdf_font']=~/\S{3,}/) \ - ? @h['texpdf_font'] - : @env.font.texpdf.main - end - def sans # not used - @h['texpdf_font_sans'] \ - && (@h['texpdf_font_sans']=~/\S{3,}/) \ - ? @h['texpdf_font_sans'] - : @env.font.texpdf.sans - end - def serif # not used - @h['texpdf_font_serif'] \ - && (@h['texpdf_font_serif']=~/\S{3,}/) \ - ? @h['texpdf_font_serif'] - : @env.font.texpdf.serif - end - def mono - @h['texpdf_font_mono'] \ - && (@h['texpdf_font_mono']=~/\S{3,}/) \ - ? @h['texpdf_font_mono'] - : @env.font.texpdf.mono - end - def cjk - @h['texpdf_font_cjk'] \ - && (@h['texpdf_font_cjk']=~/\S{3,}/) \ - ? @h['texpdf_font_cjk'] - : @env.font.texpdf.cjk - end - def cjk_zh - @h['texpdf_font_cjk_zh'] \ - && (@h['texpdf_font_cjk_zh']=~/\S{3,}/) \ - ? @h['texpdf_font_cjk_zh'] - : @env.font.texpdf.cjk_zh - end - def cjk_ja - @h['texpdf_font_cjk_ja'] \ - && (@h['texpdf_font_cjk_ja']=~/\S{3,}/) \ - ? @h['texpdf_font_cjk_ja'] - : @env.font.texpdf.cjk_ja - end - def cjk_ko - @h['texpdf_font_cjk_ko'] \ - && (@h['texpdf_font_cjk_ko']=~/\S{3,}/) \ - ? @h['texpdf_font_cjk_ko'] - : @env.font.texpdf.cjk_ko - end - self - end - def promo - @h['promo'] - end - def ad - @h['ad'] - end - def manpage - manpage={} - if @h['manpage'] - if @h['manpage'] =~/;/m - man=@h['manpage'].split(/;/m) - man.each do |x| - m=(x=~/=/m) ? x.split(/=/m) : nil - if m - manpage[m[0].strip] = m[1].split(/ \. /) - end - end - end - end - if manpage['name'] - manpage['name']=manpage['name'].join("\n.br\n"). - gsub(/(-)/m,"\\\\\\1"). - gsub(/\A/,"\n.br\n.SH NAME\n.br\n") - else - manpage['name']='man page "name/whatis" information not provided, set in header @man: name=[whatis information]' - end - if manpage['synopsis'] - manpage['synopsis']=manpage['synopsis'].join("\n\n.br\n"). - gsub(/(-)/m,"\\\\\\1"). - gsub(/\A/,"\n.br\n.SH SYNOPSIS\n.br\n") - else - manpage['synopsis']='' - end - unless manpage['section'] - manpage['section']=1 - end - manpage - end - def get_image_dimensions(img) - imgk=SiSU_Env::SystemCall.new.imagemagick - gmgk=SiSU_Env::SystemCall.new.graphicksmagick - img_pth={ - sst: @env.path.image_source_include, - pod: File.expand_path("../../../sisupod/image" ) - } - path_img=if FileTest.file?("#{img_pth[:pod]}/#{img}") - "#{img_pth[:pod]}/#{img}" - elsif FileTest.file?("#{img_pth[:sst]}/#{img}") - "#{img_pth[:sst]}/#{img}" - else nil - end - if path_img - if imgk or gmgk - if imgk - imgsys=`identify #{path_img}`.strip #system call - elsif gmgk - imgsys=`gm identify #{path_img}`.strip #system call - end - w,h=/(\d+)x(\d+)/m.match(imgsys)[1,2] - else - w,h='600','800' - end - else - w,h=nil,nil - end - {w: w, h: h} - end - def home_button_text - if @h['home_button_text'] - @h['home_button_text'].split(/\s*;\s*/) - else nil - end - end - def home_button_image - s=nil - s=if @h['home_button_image'] - s=@h['home_button_image'].split(/\s*;\s*/) - s0=s[0] #if - image={} - s=if s0 =~/{(\S+\.(?:jpg|png|gif))(?:\s+(\d+x\d+))?\s*}(?:(http:\/\/\S+)|image)/ - image[:home_button]=$1 - if $2 - image[:dimensions]=$2 - image[:w],image[:h]=/(\d+)x(\d+)/m.match(image[:dimensions])[1,2] - else - d=get_image_dimensions(image[:home_button]) - image[:w],image[:h]=d[:w],d[:h] - image[:dimensions]="#{d[:w]}x#{d[:h]}" - end - image[:link]=$3 - image - end - else nil - end - end - def cover_image - s=nil - if @h['cover_image'] - s=@h['cover_image'].split(/\s*;\s*/) - s=s[0] #if - image={} - if s =~/{\s*(\S+\.(?:jpg|png|gif))(?:\s+(\d+x\d+))?(?:\s+"(.+?)")?\s*}image/ - image[:cover]=$1 - if $2 - image[:dimensions]=$2 - image[:w],image[:h]=/(\d+)x(\d+)/m.match(image[:dimensions])[1,2] - else - d=get_image_dimensions(image[:cover]) - image[:w],image[:h]=d[:w],d[:h] - image[:dimensions]="#{d[:w]}x#{d[:h]}" - end - image[:note]=$3 - elsif s =~/(\S+\.(?:jpg|png|gif))/ - image[:cover]=$1 - d=get_image_dimensions(image[:cover]) - image[:w],image[:h]=d[:w],d[:h] - image[:dimensions]="#{d[:w]}x#{d[:h]}" - image[:note]=nil - end - image - else nil - end - end - def footer - if @h['footer'] - @h['footer'].split(/\s*;\s*/) - else nil - end - end - self - end - def make_links - @doc_links=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m) - def links - lnks,a_idx=[],0 - @doc_links.each do |doc_link| - if doc_link=~/\{.+?\}(?:(?:https?|file|ftp):\/|\.\.)\/\S+(?:\s|$)/ - say,url=/\{\s*(.+?)\s*\}((?:(?:https?|file|ftp):\/|\.\.)\/\S+)/im.match(doc_link)[1,2] - lnks[a_idx]={ say: say, url: url } - a_idx +=1 - end - end - lnks - end - def append? - (@doc_links[0]=='+') \ - ? :yes - : :no - end - self - end - end - class MakeHead - attr_accessor :pagenew,:pagebreak,:pageline,:toc,:lv1,:lv2,:lv3,:lv4,:lv5,:lv6,:num_top,:i18n,:man_section,:substitution_match_list,:bold_match_list,:italics_match_list,:emphasis_set_to,:footer_links,:home_button_links,:home_button_image,:cover_image - def initialize(make) - @make=make - end - def clear - @pagenew=@pagebreak=@pageline=@toc=@lv1=@lv2=@lv3=@lv4=@lv5=@lv6=@num_top=@i18n=@man_section=@footer_links=@substitution_match_list=@bold_match_list=@italics_match_list=@emphasis_set_to=@home_button_links=@home_button_image=@cover_image=nil - end - def make_instruct - clear - if defined? @make.breaks \ - and @make.breaks[:page_new] #clearpage - @pagenew=@make.breaks[:page_new] - end - if defined? @make.breaks \ - and @make.breaks[:page_break] #newpage - @pagebreak=@make.breaks[:page_break] - end - if defined? @make.breaks \ - and @make.breaks[:page_line] #page line across - @pagebreak=@make.breaks[:page_line] - end - if defined? @make.headings \ - and @make.headings - @toc=@make.headings[0] - @lv1=@make.headings[1] - @lv2=@make.headings[2] - @lv3=@make.headings[3] - @lv4=@make.headings[4] - @lv5=@make.headings[5] - @lv6=@make.headings[6] - end - if defined? @make.num_top \ - and @make.num_top - @num_top=@make.num_top # remove @num_top - end - if defined? @make.language \ - and @make.language[0] - @i18n=@make.language - end - if defined? @make.manpage \ - and @make.manpage - @man_section=(defined? @make.manpage.section) \ - ? @make.manpage.section - : 1 - end - if defined? @make.substitute \ - and @make.substitute - @substitution_match_list=@make.substitute - end - if defined? @make.bold \ - and @make.bold - @bold_match_list=@make.bold - end - if defined? @make.italics \ - and @make.italics - @italics_match_list=@make.italics - end - if defined? @make.emphasis \ - and @make.emphasis - @emphasis_set_to=@make.emphasis - end - if defined? @make.footer \ - and @make.footer.is_a?(Array) - @footer_links= { left: { say: '', url: '' }, center: { say: '', url: '' } } #already set - @footer_links[:left]=if @make.footer[0]=~/\{.+?\}(?:(?:https?|file|ftp):\/|\.\.)\/\S+(?:\s|$)/ - say,url=/\{\s*(.+?)\s*\}((?:(?:https?|file|ftp):\/|\.\.)\/\S+)/im.match(@make.footer[0])[1,2] - { say: say, url: url } - else - { say: '', url: '' } - end - @footer_links[:center]=if @make.footer[1]=~/\{.+?\}(?:(?:https?|file|ftp):\/|\.\.)\/\S+(?:\s|$)/ - say,url=/\{\s*(.+?)\s*\}((?:(?:https?|file|ftp):\/|\.\.)\/\S+)/im.match(@make.footer[1])[1,2] - { say: say, url: url } - else - { say: '', url: '' } - end - @footer_links - else #already set - @footer_links= { left: { say: '', url: '' }, center: { say: '', url: '' } } - end - if defined? @make.home_button_text \ - and @make.home_button_text.is_a?(Array) - a_idx=0 - @home_button_links=[] - @make.home_button_text.each do |doc_link| - if doc_link=~/\{.+?\}(?:(?:https?|file|ftp):\/|\.\.)\/\S+(?:\s|$)/ - say,url=/\{\s*(.+?)\s*\}((?:(?:https?|file|ftp):\/|\.\.)\/\S+)/im.match(doc_link)[1,2] - @home_button_links[a_idx]= { say: say, url: url } - a_idx +=1 - end - end - @home_button_links - end - if defined? @make.home_button_image \ - and @make.home_button_image.is_a?(Hash) - @home_button_image=@make.home_button_image - end - if defined? @make.cover_image \ - and @make.cover_image.is_a?(Hash) - @cover_image=@make.cover_image - end - { pagenew: @pagenew, - pagebreak: @pagebreak, - pageline: @pageline, - toc: @toc, - lv1: @lv1, - lv2: @lv2, - lv3: @lv3, - lv4: @lv4, - lv5: @lv5, - lv6: @lv6, - num_top: @num_top, - i18n: @i18n, - emphasis_set_to: @emphasis_set_to, - bold_match_list: @bold_match_list, - italics_match_list: @italics_match_list, - substitution_match_list: @substitution_match_list, - man_section: @man_section, - footer_links: @footer_links, - home_button_links: @home_button_links, - home_button_image: @home_button_image, - cover_image: @cover_image, - } - end - end -end -__END__ diff --git a/lib/sisu/v5/particulars.rb b/lib/sisu/v5/particulars.rb deleted file mode 100644 index 6efbc94c..00000000 --- a/lib/sisu/v5/particulars.rb +++ /dev/null @@ -1,240 +0,0 @@ -# encoding: utf-8 -=begin - - * Name: SiSU - - * Description: a framework for document structuring, publishing and search - particulars, composite information about document being processed - - * Author: Ralph Amissah - - * Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, - All Rights Reserved. - - * License: GPL 3 or later: - - SiSU, a framework for document structuring, publishing and search - - Copyright (C) Ralph Amissah - - This program is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the Free - Software Foundation, either version 3 of the License, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - more details. - - You should have received a copy of the GNU General Public License along with - this program. If not, see . - - 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: - - - * Git - - - - * Ralph Amissah - - - - ** Description: system environment, resource control and configuration details - -=end -module SiSU_Particulars - begin - require 'singleton' - rescue LoadError - SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('singleton NOT FOUND (LoadError)') - end - require_relative 'sysenv' # sysenv.rb - include SiSU_Env - require_relative 'param' # param.rb - include SiSU_Param - require_relative 'ao' # ao.rb - class CombinedSingleton - include Singleton - def get_all(opt) - set_env(opt) - set_file(opt) - set_md(opt) - set_ao(opt) #needs @md - end - def get_env(opt) - set_env(opt) - end - def get_file(opt) - set_file(opt) - end - def get_md(opt) - set_md(opt) - end - def get_ao_array(opt) - set_ao(opt) #needs @md - end - def get_env_md(opt) - set_env(opt) - set_md(opt) - end - def get_idx_sst(opt) - set_sst_idx(opt) - end - def get_idx_raw(opt) - set_raw_idx(opt) - end - def get_idx_html(opt) - set_html_idx(opt) - end - def get_idx_xhtml(opt) - set_xhtml_idx(opt) - end - def get_name_tags(opt) - set_name_tags(opt) - end - def get_maps(opt) - set_nametags_map(opt) - set_ocn_htmlseg_map(opt) - end - def get_map_nametags(opt) - set_nametags_map(opt) - end - def get_map_ocn_htmlseg(opt) - set_ocn_htmlseg_map(opt) - end - attr_accessor :opt,:md,:sst_idx,:raw_idx,:html_idx,:xhtml_idx - def set_md(opt) - begin - @md=SiSU_Param::Parameters.new(opt).get - self - rescue - SiSU_Errors::Rescued.new($!,$@,opt.cmd,opt.fnl).location do - __LINE__.to_s + ':' + __FILE__ - end - end - end - attr_accessor :opt,:env,:file - def set_env(opt) - begin - @env=SiSU_Env::InfoEnv.new(opt.fns) - self - rescue - SiSU_Errors::Rescued.new($!,$@,opt.cmd,opt.fnl).location do - __LINE__.to_s + ':' + __FILE__ - end - end - end - def set_file(opt) - begin - set_md(opt) unless @md - @file=SiSU_Env::FileOp.new(@md) - self - rescue - SiSU_Errors::Rescued.new($!,$@,opt.cmd,opt.fnl).location do - __LINE__.to_s + ':' + __FILE__ - end - end - end - attr_accessor :opt,:ao_array - def set_ao(opt) - begin - @ao_array=SiSU_AO::Source.new(opt).get - self - rescue - SiSU_Errors::Rescued.new($!,$@,opt.cmd,opt.fnl).location do - __LINE__.to_s + ':' + __FILE__ - end - end - end - def set_sst_idx(opt) - begin - @sst_idx=SiSU_AO::Source.new(opt).get_idx_sst - self - rescue - SiSU_Errors::Rescued.new($!,$@,opt.cmd,opt.fnl).location do - __LINE__.to_s + ':' + __FILE__ - end - end - end - def set_raw_idx(opt) - begin - @raw_idx=SiSU_AO::Source.new(opt).get_idx_raw - self - rescue - SiSU_Errors::Rescued.new($!,$@,opt.cmd,opt.fnl).location do - __LINE__.to_s + ':' + __FILE__ - end - end - end - def set_html_idx(opt) - begin - @html_idx=SiSU_AO::Source.new(opt).get_idx_html - self - rescue - SiSU_Errors::Rescued.new($!,$@,opt.cmd,opt.fnl).location do - __LINE__.to_s + ':' + __FILE__ - end - end - end - def set_xhtml_idx(opt) - begin - @xhtml_idx=SiSU_AO::Source.new(opt).get_idx_xhtml - self - rescue - SiSU_Errors::Rescued.new($!,$@,opt.cmd,opt.fnl).location do - __LINE__.to_s + ':' + __FILE__ - end - end - end - attr_accessor :nametags_map - def set_nametags_map(opt) - begin - opt=@md ? @md : opt - @nametags_map=SiSU_AO::Source.new(opt).get_map_nametags - self - rescue - if @md - SiSU_Errors::Rescued.new($!,$@,@md.opt.cmd,@md.opt.fnl).location do - __LINE__.to_s + ':' + __FILE__ - end - else - SiSU_Errors::Rescued.new($!,$@,opt.cmd,opt.fnl).location do - __LINE__.to_s + ':' + __FILE__ - end - end - end - end - attr_accessor :ocn_htmlseg_map - def set_ocn_htmlseg_map(opt) - begin - @ocn_htmlseg_map=SiSU_AO::Source.new(@md).get_map_ocn_htmlseg - self - rescue - SiSU_Errors::Rescued.new($!,$@,opt.cmd,opt.fnl).location do - __LINE__.to_s + ':' + __FILE__ - end - end - end - end -end -__END__ -consider running as separate objects diff --git a/lib/sisu/v5/po4a.rb b/lib/sisu/v5/po4a.rb index 3b800e83..b5086eb7 100644 --- a/lib/sisu/v5/po4a.rb +++ b/lib/sisu/v5/po4a.rb @@ -63,7 +63,7 @@ =end module SiSU_Po4a require_relative 'ao' # ao.rb - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env require_relative 'ao_composite' # ao_composite.rb require_relative 'shared_metadata' # shared_metadata.rb diff --git a/lib/sisu/v5/prog_text_translation.rb b/lib/sisu/v5/prog_text_translation.rb index 98319960..9a7db086 100644 --- a/lib/sisu/v5/prog_text_translation.rb +++ b/lib/sisu/v5/prog_text_translation.rb @@ -61,7 +61,7 @@ =end module SiSU_Translate - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env; include SiSU_Param class Source def initialize(md,doc_lang,trans_str='') diff --git a/lib/sisu/v5/qrcode.rb b/lib/sisu/v5/qrcode.rb index f6fd78bf..19d310c1 100644 --- a/lib/sisu/v5/qrcode.rb +++ b/lib/sisu/v5/qrcode.rb @@ -61,13 +61,13 @@ =end module SiSU_QRcode - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env require_relative 'prog_text_translation' # prog_text_translation.rb - require_relative 'particulars' # particulars.rb + require_relative 'se_hub_particulars' # se_hub_particulars.rb include SiSU_Particulars require_relative 'html' # html.rb - require_relative 'param' # param.rb + require_relative 'dp' # dp.rb include SiSU_Param require_relative 'i18n' # i18n.rb include SiSU_Viz diff --git a/lib/sisu/v5/relaxng.rb b/lib/sisu/v5/relaxng.rb index f6e86470..ebef4a31 100644 --- a/lib/sisu/v5/relaxng.rb +++ b/lib/sisu/v5/relaxng.rb @@ -61,7 +61,7 @@ =end module SiSU_Relaxng - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb class RelaxNG def gpl3_or_later @gpl3_or_later =<. - - 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: - - - * Git - - - - * Ralph Amissah - - - - ** Description: Request response - -=end -module SiSU_Response - class Response - def response?(ask) #move to more appropriate directory later - response='redo' - print ask + " ['yes', 'no' or 'quit']: " - response=File.new('/dev/tty').gets.strip - ans=if response=='yes' then true - elsif response=='no' then false - elsif response =~/^quit|exit$/ then exit - else puts "[please type: 'yes', 'no' or 'quit']" - response?(ask) - end - ans - end - end -end -__END__ diff --git a/lib/sisu/v5/rexml.rb b/lib/sisu/v5/rexml.rb index f7a2c968..c4512872 100644 --- a/lib/sisu/v5/rexml.rb +++ b/lib/sisu/v5/rexml.rb @@ -67,9 +67,9 @@ module SiSU_Rexml rescue LoadError SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('rexml/document NOT FOUND (LoadError)') end - require_relative 'param' # param.rb + require_relative 'dp' # dp.rb include SiSU_Param - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env include SiSU_Viz class Rexml diff --git a/lib/sisu/v5/screen_text_color.rb b/lib/sisu/v5/screen_text_color.rb deleted file mode 100644 index 42b0c698..00000000 --- a/lib/sisu/v5/screen_text_color.rb +++ /dev/null @@ -1,478 +0,0 @@ -# encoding: utf-8 -=begin - - * Name: SiSU - - * Description: a framework for document structuring, publishing and search - - * Author: Ralph Amissah - - * Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, - All Rights Reserved. - - * License: GPL 3 or later: - - SiSU, a framework for document structuring, publishing and search - - Copyright (C) Ralph Amissah - - This program is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the Free - Software Foundation, either version 3 of the License, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - more details. - - You should have received a copy of the GNU General Public License along with - this program. If not, see . - - 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: - - - * Git - - - - * Ralph Amissah - - - - ** Description: system environment, screen colors text - -=end -module SiSU_Screen - class Color - attr_accessor :off,:marker,:bold,:underline,:invert,:darkgrey_hi,:grey_hi,:pink_hi,:fuchsia_hi,:red_hi,:orange_hi,:yellow_hi,:brown_hi,:lightgreen_hi,:green_hi,:cyan_hi,:blue_hi,:navy_hi,:white,:white_bold,:grey,:pink,:fuchsia,:ruby,:red,:orange,:yellow,:brown,:green,:darkgreen,:cyan,:blue,:navy,:black - def initialize(&block) - instance_eval &block - end - end - class Ansi < Color - attr_reader :cX - def initialize(color_state,*txt) - @color_state,@txt=color_state,txt - @color_instruct=txt[0] - @cX=@@cX=if color_state==:on - Color.new do - self.off=self.white=self.white_bold=self.marker=self.bold=self.underline=self.invert=self.darkgrey_hi=self.grey_hi=self.pink_hi=self.fuchsia_hi=self.red_hi=self.orange_hi=self.yellow_hi=self.brown_hi=self.lightgreen_hi=self.green_hi=self.cyan_hi=self.blue_hi=self.navy_hi=self.grey=self.pink=self.fuchsia=self.ruby=self.red=self.orange=self.yellow=self.brown=self.green=self.darkgreen=self.cyan=self.blue=self.navy=self.black='' - end - else #default set to colors on - Color.new do - self.off = "\033[0m" - self.white = "\033[37m" - self.white_bold = "\033[1m" - self.marker = "\033[42m" - self.bold = "\033[1m" - self.underline = "\033[4m" - self.invert = "\033[7m" - self.darkgrey_hi = "\033[100m" - self.grey_hi = "\033[47m" - self.pink_hi = "\033[105m" - self.fuchsia_hi = "\033[45m" - self.red_hi = "\033[41m" - self.orange_hi = "\033[101m" - self.yellow_hi = "\033[103m" - self.brown_hi = "\033[43m" - self.lightgreen_hi = "\033[102m" - self.green_hi = "\033[42m" - self.cyan_hi = "\033[106m" - self.blue_hi = "\033[104m" - self.navy_hi = "\033[44m" - self.grey = "\033[90m" - self.pink = "\033[95m" - self.fuchsia = "\033[35m" - self.ruby = "\033[31m" - self.red = "\033[91m" #check - self.orange = "\033[91m" - self.yellow = "\033[93m" - self.brown = "\033[33m" - self.green = "\033[92m" - self.darkgreen = "\033[32m" - self.cyan = "\033[36m" - self.blue = "\033[94m" - self.navy = "\033[34m" - self.black = "\033[30m" - end - end - end - def colors - 0.upto(109) {|i| print "\033[#{i}m 33[#{i}m \033[m"} - puts '' - end - def color - case @color_instruct - when /invert/ then @cX.invert - when /darkgrey_hi/ then @cX.darkgrey_hi - when /grey_hi/ then @cX.grey_hi - when /pink_hi/ then @cX.pink_hi - when /fuchsia_hi/ then @cX.fuchsia_hi - when /red_hi/ then @cX.red_hi - when /orange_hi/ then @cX.orange_hi - when /yellow_hi/ then @cX.yellow_hi - when /brown_hi/ then @cX.brown_hi - when /lightgreen_hi/ then @cX.lightgreen_hi - when /green_hi/ then @cX.green_hi - when /cyan_hi/ then @cX.cyan_hi - when /blue_hi/ then @cX.blue_hi - when /navy_hi/ then @cX.navy_hi - when /white/ then @cX.white - when /grey/ then @cX.grey - when /pink/ then @cX.pink - when /fuchsia/ then @cX.fuchsia - when /ruby/ then @cX.ruby - when /red/ then @cX.red - when /orange/ then @cX.orange - when /yellow/ then @cX.yellow - when /brown/ then @cX.brown - when /green/ then @cX.green - when /darkgreen/ then @cX.darkgreen - when /cyan/ then @cX.cyan - when /blue/ then @cX.blue - when /navy/ then @cX.navy - when /close/ then @cX.off - when /off/ then @cX.off - end - end - def colorize - case @color_instruct - when /invert/ then puts "#{@cX.invert}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}" - when /darkgrey_hi/ then puts "#{@cX.darkgrey_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}" - when /grey_hi/ then puts "#{@cX.grey_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}" - when /pink_hi/ then puts "#{@cX.pink_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}" - when /fuchsia_hi/ then puts "#{@cX.fuchsia_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}" - when /red_hi/ then puts "#{@cX.red_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}" - when /orange_hi/ then puts "#{@cX.orange_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}" - when /yellow_hi/ then puts "#{@cX.yellow_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}" - when /brown_hi/ then puts "#{@cX.brown_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}" - when /lightgreen_hi/ then puts "#{@cX.lightgreen_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}" - when /green_hi/ then puts "#{@cX.green_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}" - when /cyan_hi/ then puts "#{@cX.cyan_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}" - when /blue_hi/ then puts "#{@cX.blue_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}" - when /navy_hi/ then puts "#{@cX.navy_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}" - when /bold/ then puts "#{@cX.bold}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" - when /white/ then puts "#{@cX.off}#{@txt[1]} #{@txt[2]}" - when /grey/ then puts "#{@cX.grey}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" - when /pink/ then puts "#{@cX.pink}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" - when /fuchsia/ then puts "#{@cX.fuchsia}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" - when /ruby/ then puts "#{@cX.ruby}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" - when /red/ then puts "#{@cX.red}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" - when /orange/ then puts "#{@cX.orange}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" - when /yellow/ then puts "#{@cX.yellow}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" - when /brown/ then puts "#{@cX.brown}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" - when /green/ then puts "#{@cX.green}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" - when /darkgreen/ then puts "#{@cX.darkgreen}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" - when /cyan/ then puts "#{@cX.cyan}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" - when /blue/ then puts "#{@cX.blue}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" - when /navy/ then puts "#{@cX.navy}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" - end - end - def sourcename(sourcefilename) - @sourcefilename=sourcefilename - end - def basename(sourcefilename) - @basename=sourcefilename.sub(/\.(?:(?:-|ssm\.)?sst|ssm)$/,'') - end - def sisu - end - def rescue - STDERR.puts %{\t #{@cX.orange}Rescued#{@cX.off} #{@cX.grey}#{yield if block_given?}\n\t An#{@cX.off} #{@cX.fuchsia}ERROR#{@cX.off} #{@cX.grey}occurred, message:#{@cX.off} #{@cX.fuchsia}#{@txt[0]}#{@cX.off} #{@cX.grey}#{@txt[1]}#{@cX.off} #{@cX.brown}#{@txt[2]}#{@cX.off}} - end - def warn - STDERR.puts "\t #{@cX.brown}#{@txt[0]}#{@cX.off} #{@cX.grey}#{@txt[1]}#{@cX.off}" - end - def error - STDERR.puts "\t #{@cX.fuchsia}#{@txt[0]}#{@cX.off} #{@cX.brown}#{@txt[1]}#{@cX.off}" - end - def error2 - STDERR.puts "\t #{@cX.grey}#{@txt[0]}#{@cX.off} #{@cX.fuchsia}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" - end - def version - puts "#{@cX.blue_hi}#{@txt[0]} #{@txt[1]}#{@cX.off} #{@cX.grey} (#{@txt[3]} [#{@txt[2]}])#{@txt[4]} &#{@cX.off} #{@cX.ruby}Ruby#{@cX.off} #{@cX.grey}(#{@txt[5]})#{@cX.off}\n" - end - def html3numbers - puts %{\t#{@cX.green}#{@txt[0]}#{@cX.off} #{@cX.cyan}files processed#{@cX.off}. } + - %{#{@cX.grey}} + - %{scroll only: #{@txt[1]}, seg only: #{@txt[2]},} + - %{#{@cX.off} } + - %{#{@cX.cyan}joint scroll & seg: #{@txt[3]},#{@cX.off}} + - %{#{@cX.grey} } + - %{nav only: #{@txt[4]}} + - %{#{@cX.off}} - end - def html2numbers - puts %{\t#{@cX.green}#{@txt[0]}#{@cX.off} #{@cX.cyan}files processed#{@cX.off}. } + - %{#{@cX.grey}} + - %{scroll only: #{@txt[1]},} + - %{#{@cX.off} } + - %{#{@cX.cyan}seg only: #{@txt[2]},#{@cX.off}} + - %{#{@cX.grey} } + - %{joint scroll & seg: #{@txt[3]}, nav only: #{@n_files_nav}} + - %{#{@cX.off}} - end - def html1numbers - puts %{\t#{@cX.green}#{@txt[0]}#{@cX.off} #{@cX.cyan}files processed#{@cX.off}. } + - %{#{@cX.cyan}scroll only: #{@txt[1]},#{@cX.off}} + - %{#{@cX.grey} } + - %{seg only: #{@txt[2]}, } + - %{joint scroll & seg: #{@txt[3]}, nav only: #{@n_files_nav}} + - %{#{@cX.off}} - end - def html0_numbers - puts %{\t#{@cX.ruby}#{@txt[0]} files processed#{@cX.off}. } + - %{#{@cX.grey}} + - %{scroll only: #{@txt[1]}, seg only: #{@txt[2]}, joint scroll & seg: #{@txt[3]},} + - %{#{@cX.off} } + - %{#{@cX.cyan}nav only: #{@txt[4]}#{@cX.off}.} - end - def grey - puts "#{@cX.grey}#{@txt[0]}#{@cX.off} #{@cX.cyan}#{@txt[1]}#{@cX.off}" - end - def txt_white - puts "\t#{@cX.white}#{@txt[0]}#{@cX.off} #{@cX.white}#{@txt[1]}#{@cX.off}" - end - def txt_grey - puts "\t#{@cX.grey}#{@txt[0]}#{@cX.off} #{@cX.cyan}#{@txt[1]}#{@cX.off}" - end - def txt_cyan - puts "\t#{@cX.cyan}#{@txt[0]}#{@cX.off} #{@cX.grey}#{@txt[1]}#{@cX.off}" - end - def txt_blue - puts "\t#{@cX.blue}#{@txt[0]}#{@cX.off} #{@cX.grey}#{@txt[1]}#{@cX.off}" - end - def txt_red - puts "\t#{@cX.red}#{@txt[0]}#{@cX.off} #{@cX.cyan}#{@txt[1]}#{@cX.off}" - end - def txt_green - puts "\t#{@cX.green}#{@txt[0]}#{@cX.off} #{@cX.grey}#{@txt[1]}#{@cX.off}" - end - def url #clean - blue - end - def result - puts "\t#{@cX.green}#{@txt[0]}#{@cX.off} #{@cX.blue}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" - end - def maintenance - puts "\t#{@cX.grey}#{@txt[0]}#{@cX.off} #{@cX.brown}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" - end - def instruct - puts %{\t #{@cX.grey}#{@txt[0]}#{@cX.off} #{@cX.cyan}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off} #{@cX.cyan}#{@txt[3]}#{@cX.off} #{@cX.grey}#{@txt[4]}#{@cX.off} "#{@cX.brown}#{@f}#{@cX.off}"} - end - def grey_open - print @cX.grey - end - def p_off - print @cX.off - end - def p_close - print @cX.off - end - def flow - puts %{\t#{@cX.grey}#{@txt[0]}#{@cX.off} #{@cX.ruby}->#{@cX.off}\n\t #{@cX.blue}#{@txt[1]}#{@cX.off}} - end - def output - puts %{\t#{@cX.grey}#{@txt[0]}#{@cX.off} #{@cX.ruby}->#{@cX.off}\n\t #{@cX.blue}#{@txt[1]}#{@cX.off}} - end - def generic - puts %{\t#{@cX.navy}#{@txt[0]} #{@txt[1]}#{@cX.off}. } - end - def files_processed - puts %{\t#{@cX.green}#{@txt[0]}#{@cX.off} #{@cX.grey}#{@txt[1]}#{@cX.off}} - end - def print_blue - print "#{@cX.blue}#{@txt[0]} #{@txt[1]}#{@cX.off}" - end - def puts_blue - puts "#{@cX.blue}#{@txt[0]} #{@txt[1]}#{@cX.off}" - end - def print_brown - print "#{@cX.brown}#{@txt[0]}#{@cX.off}" - end - def blue_tab - print "\t#{@cX.blue}#{@txt[0]}#{@cX.off}\n" - end - def print_grey - print "#{@cX.grey}#{@txt[0]} #{@txt[1]}#{@cX.off}" - end - def puts_grey - puts "#{@cX.grey}#{@txt[0]} #{@txt[1]}#{@cX.off}" - end - def puts_brown - puts "#{@cX.brown}#{@txt[0]} #{@txt[1]}#{@cX.off}" - end - def grey_tab - print "\t#{@cX.grey}#{@txt[0]}#{@cX.off}\n" - end - def green_title - puts %{#{@cX.green}#{@txt[0]}#{@cX.off} #{@cX.grey}#{@txt[1]}#{@cX.off}} - end - def green_title_hi - puts %{#{@cX.green_hi}#{@cX.black}#{@txt[0]}#{@cX.off*2} #{@cX.grey}#{@txt[1]}#{@cX.off}} - end - def green_hi_blue - puts %{#{@cX.green_hi}#{@cX.black}#{@txt[0]}#{@cX.off*2} #{@cX.blue}#{@txt[1]}#{@cX.off}} - end - def blue_title_hi - puts %{#{@cX.blue_hi}#{@txt[0]}#{@cX.off*2} #{@cX.blue}#{@txt[1]}#{@cX.off}} - end - def grey_title_hi - puts %{#{@cX.grey_hi}#{@cX.black}#{@txt[0]}#{@cX.off*2} #{@cX.blue}#{@txt[1]}#{@cX.off}} - end - def grey_title_grey_blue - puts %{#{@cX.grey_hi}#{@cX.black}#{@txt[0]}#{@cX.off*2} #{@cX.grey}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off}} - end - def dark_grey_title_hi - puts %{#{@cX.darkgrey_hi}#{@cX.black}#{@txt[0]}#{@cX.off*2} #{@cX.blue}#{@txt[1]}#{@cX.off}} - end - def cyan_title_hi - puts %{#{@cX.cyan_hi}#{@cX.black}#{@txt[0]}#{@cX.off*2} #{@cX.blue}#{@txt[1]}#{@cX.off}} - end - def cyan_hi_blue - puts %{#{@cX.cyan_hi}#{@cX.black}#{@txt[0]}#{@cX.off*2} #{@cX.blue}#{@txt[1]}#{@cX.off}} - end - def dbi_title - puts %{#{@cX.blue_hi}#{@cX.black}#{@txt[0]}#{@cX.off*2} #{@cX.cyan}#{@cX.grey}#{@txt[1]}#{@cX.off*2} #{@cX.green}#{@txt[2]}#{@cX.off}} - end - def yellow_title_hi - puts %{#{@cX.yellow_hi}#{@cX.black}#{@txt[0]}#{@cX.off*2} #{@cX.blue}#{@txt[1]}#{@cX.off}} - end - def term_sheet_title - puts %{\t#{@cX.green}#{@txt[0]}#{@cX.off} #{@cX.red_hi}#{@cX.black}#{@txt[1]}.#{@cX.off*2} } - end - def generic_number - puts "#{@cX.green}#{@txt[0]}#{@cX.off} #{@cX.grey}#{@txt[1]}#{@cX.off}" - end - def tex_numbers - puts %{ #{@cX.green}#{@txt[0]}#{@cX.off} #{@cX.cyan}tex/pdf files processed#{@cX.off}.} - end - def tex_info_numbers - puts %{ #{@cX.green}#{@txt[0]}#{@cX.off} #{@cX.cyan}texinfo files processed#{@cX.off}.} - end - def lout_numbers - puts %{ #{@cX.green}#{@n_lout}#{@cX.off} #{@cX.cyan}lout/pdf files processed#{@cX.off}.} - end - def parameters - end - def reserved - puts %{ #{@cX.grey_hi}#{@cX.black}reserved#{@cX.off*2}} - end - def meta_verse_title - puts %{#{@cX.green_hi}#{@cX.black}MetaVerse#{@cX.off*2} } - end - def meta_verse_title_v - b=sourcename(@txt[0]) - puts %{#{@cX.green_hi}#{@cX.black}MetaVerse#{@cX.off*2} } + - %{#{@cX.grey}#{@txt[0]}#{@cX.off} #{@cX.ruby}->#{@cX.off}\n\t #{@cX.blue}~meta/#{b}.meta#{@cX.off}} - end - def meta_verse - puts "\t#{@cX.grey}MetaVerse#{@cX.off}" - end - def meta_verse_skipped - puts %{\t#{@cX.grey}MetaVerse: MarshalLoad (creation of metaVerse skipped)#{@cX.off}} - end - def meta_verse_load - puts %{\t<>} - end - def html_title - puts %{#{@cX.green_hi}#{@cX.black}HTML#{@cX.off*2}} - end - def html_output - puts %{\t#{@cX.grey}#{@txt[0]}#{@cX.off} #{@cX.ruby}->#{@cX.off}\n\t #{@cX.blue}#{@txt[1]}#{@cX.off}} - end - def segmented - puts "\t#{@cX.grey}Seg#{@cX.off} #{@cX.green}#{@txt[0]}#{@cX.off} #{@cX.grey}segments#{@cX.off}" - end - end -end -__END__ - Color.new do - self.off = "\033[0m" - self.white = "\033[37m" - self.white_bold = "\033[1m" - self.marker = "\033[42m" - self.bold = "\033[1m" - self.underline = "\033[4m" - self.invert = "\033[7m" - self.darkgrey_hi = "\033[100m" - self.grey_hi = "\033[47m" - self.pink_hi = "\033[105m" - self.fuchsia_hi = "\033[45m" - self.red_hi = "\033[41m" - self.orange_hi = "\033[101m" - self.yellow_hi = "\033[103m" - self.brown_hi = "\033[43m" - self.lightgreen_hi = "\033[102m" - self.green_hi = "\033[42m" - self.cyan_hi = "\033[106m" - self.blue_hi = "\033[104m" - self.navy_hi = "\033[44m" - self.grey = "\033[90m" - self.pink = "\033[95m" - self.fuchsia = "\033[35m" - self.ruby = "\033[31m" - self.red = "\033[91m" #check - self.orange = "\033[91m" - self.yellow = "\033[93m" - self.brown = "\033[33m" - self.green = "\033[92m" - self.darkgreen = "\033[32m" - self.cyan = "\033[36m" - self.blue = "\033[94m" - self.navy = "\033[34m" - self.black = "\033[30m" - end -# fewer colors - Color.new do - self.off = "\033[0m" - self.white = "\033[0m" - self.marker = "\033[42m" - self.bold = "\033[1m" - self.underline = "\033[4m" - self.invert = "\033[7m" - self.darkgrey_hi = "\033[100m" - self.grey_hi = "\033[47m" - self.pink_hi = "\033[105m" - self.fuchsia_hi = "\033[45m" - self.red_hi = "\033[41m" - self.orange_hi = "\033[101m" - self.yellow_hi = "\033[103m" - self.brown_hi = "\033[43m" - self.lightgreen_hi = "\033[102m" - self.green_hi = "\033[42m" - self.cyan_hi = "\033[106m" - self.blue_hi = "\033[104m" - self.navy_hi = "\033[44m" - self.grey = "\033[90m" - self.pink = "\033[95m" - self.fuchsia = "\033[35m" - self.ruby = "\033[31m" - self.red = "\033[31m" #check - self.orange = "\033[91m" - self.yellow = "\033[33m" - self.brown = "\033[33m" - self.green = "\033[32m" - self.darkgreen = "\033[32m" - self.cyan = "\033[36m" - self.blue = "\033[34m" - self.navy = "\033[34m" - self.black = "\033[30m" - end diff --git a/lib/sisu/v5/se.rb b/lib/sisu/v5/se.rb new file mode 100644 index 00000000..cefd45d5 --- /dev/null +++ b/lib/sisu/v5/se.rb @@ -0,0 +1,164 @@ +# encoding: utf-8 +=begin + + * Name: SiSU + + * Description: a framework for document structuring, publishing and search + + * Author: Ralph Amissah + + * Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. + + * License: GPL 3 or later: + + SiSU, a framework for document structuring, publishing and search + + Copyright (C) Ralph Amissah + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along with + this program. If not, see . + + 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: + + + * Git + + + + * Ralph Amissah + + + + ** Description: system environment, resource control and configuration details + +=end +@@cX=nil +module SiSU_Env + require_relative 'constants' # constants.rb + require_relative 'utils' # utils.rb + require_relative 'se_date' # se_date.rb + require_relative 'se_info_system' # se_info_system.rb + require_relative 'se_load' # se_load.rb + require_relative 'se_get_init' # se_get_init.rb + require_relative 'se_envcall' # se_envcall.rb + require_relative 'se_programs' # se_programs.rb + require_relative 'se_standardise_lang' # se_standardise_lang.rb + require_relative 'se_info_env' # se_info_env.rb + require_relative 'se_processing' # se_processing.rb + require_relative 'se_filemap' # se_filemap.rb + require_relative 'se_file_op' # se_file_op.rb + require_relative 'se_cleanoutput' # se_cleanoutput.rb + require_relative 'se_remotes' # se_remotes.rb + require_relative 'se_version' # se_version.rb + require_relative 'se_db' # se_db.rb + require_relative 'se_css' # se_css.rb + require_relative 'se_clear' # se_clear.rb + require_relative 'se_createsite' # se_createsite.rb + require_relative 'se_info_port' # se_info_port.rb + begin + require 'singleton' + require 'fileutils' + include FileUtils::Verbose + rescue LoadError + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). + error('singleton or fileutils NOT FOUND (LoadError)') + end + @@noyaml=false + class InfoDate < SiSU_Info_Date::InfoDate # se_date.rb + end + class InfoSystemGen < SiSU_Info_Sys_Gen::InfoSystemGen # se_info_system.rb + end + class InfoSystem < SiSU_Info_Sys::InfoSystem # se_info_system.rb + end + class Load < SiSU_Load::Load # se_load.rb + end + class GetInit < SiSU_Get_Init::GetInit # se_get_init.rb + end + class EnvCall < SiSU_Env_Call::EnvCall # se_envcall.rb + end + class SystemCall < SiSU_Sys_Call::SystemCall # se_programs.rb + end + class StandardiseLanguage < SiSU_Standardise_Lang::StandardiseLanguage # se_standardise_lang.rb + end + class InfoEnv < SiSU_Info_Env::InfoEnv # se_info_env.rb + end + class InfoProcessingFlag < SiSU_Info_Processing_Flag::InfoProcessingFlag # se_processing.rb + end + class InfoSettings < SiSU_Info_Set::InfoSettings # se_programs.rb + end + class FileMap < SiSU_File_Map::FileMap # se_filemap.rb + end + class CleanOutput < SiSU_Clean_Output::CleanOutput # se_cleanoutput.rb + end + class InfoRemoteHost < SiSU_Info_Remote_Host::InfoRemoteHost # se_remotes.rb + end + class InfoRemote < SiSU_Info_Remote::InfoRemote # se_remotes.rb + end + class InfoVersion < SiSU_Info_Version::InfoVersion # se_version.rb + end + class InfoAbout < SiSU_Info_About::InfoAbout # se_version.rb + end + class InfoFile < SiSU_Info_File::InfoFile # se_file_op.rb + end + class ProcessingSettings < SiSU_Processing_Settings::ProcessingSettings # se_processing.rb + end + class InfoDb < SiSU_Info_Db::InfoDb # se_db.rb + end + class DbOp < SiSU_Db_Op::DbOp # se_db.rb + end + class FileOp < SiSU_File_Op::FileOp # se_file_op.rb + end + class FilenameLanguageCodeInsert < SiSU_Filename_Lang::FilenameLanguageCodeInsert # se_file_op.rb + end + class CreateFile < SiSU_Create_File::CreateFile # se_file_op.rb + end + class Clear < SiSU_Clear::Clear # se_clear.rb + end + class InfoPort < SiSU_Info_Port::InfoPort # se_info_port.rb + end + class InfoProgram < SiSU_Info_Program::InfoProgram # se_programs.rb + end + class CSS_Default < SiSU_CSS::CSS_Default # se_css.rb + end + class CSS_Select < SiSU_CSS::CSS_Select # se_css.rb + end + class CSS_Stylesheet < SiSU_CSS::CSS_Stylesheet # se_css.rb + end + class CreateSite < SiSU_Create_Site::CreateSite # se_createsite.rb + end +end +module SiSU_Screen + require_relative 'utils_screen_text_color' # utils_screen_text_color.rb +end +module SiSU_Errors + require_relative 'errors' # errors.rb +end +__END__ diff --git a/lib/sisu/v5/se_createsite.rb b/lib/sisu/v5/se_createsite.rb index 42d86aad..33e334ce 100644 --- a/lib/sisu/v5/se_createsite.rb +++ b/lib/sisu/v5/se_createsite.rb @@ -63,7 +63,7 @@ module SiSU_Create_Site require_relative 'constants' # constants.rb require_relative 'utils' # utils.rb - require_relative 'screen_text_color' # screen_text_color.rb + require_relative 'utils_screen_text_color' # utils_screen_text_color.rb require_relative 'se_info_env' # se_info_env.rb begin require 'fileutils' diff --git a/lib/sisu/v5/se_filemap.rb b/lib/sisu/v5/se_filemap.rb index 99de4a0c..0c4c84c0 100644 --- a/lib/sisu/v5/se_filemap.rb +++ b/lib/sisu/v5/se_filemap.rb @@ -145,7 +145,7 @@ module SiSU_File_Map ft << @md.fn[:xml_scaffold_structure_collapse] end @fnb=@md.fnb - else # still needed where/when param is not parsed + else # still needed where/when dp document param is not parsed if @opt.act[:html][:set]==:on #% --html, -h -H ft << '.html' << '.html.??' end diff --git a/lib/sisu/v5/se_hub_particulars.rb b/lib/sisu/v5/se_hub_particulars.rb new file mode 100644 index 00000000..4372ac72 --- /dev/null +++ b/lib/sisu/v5/se_hub_particulars.rb @@ -0,0 +1,240 @@ +# encoding: utf-8 +=begin + + * Name: SiSU + + * Description: a framework for document structuring, publishing and search + particulars, composite information about document being processed + + * Author: Ralph Amissah + + * Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. + + * License: GPL 3 or later: + + SiSU, a framework for document structuring, publishing and search + + Copyright (C) Ralph Amissah + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along with + this program. If not, see . + + 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: + + + * Git + + + + * Ralph Amissah + + + + ** Description: system environment, resource control and configuration details + +=end +module SiSU_Particulars + begin + require 'singleton' + rescue LoadError + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('singleton NOT FOUND (LoadError)') + end + require_relative 'se' # se.rb + include SiSU_Env + require_relative 'dp' # dp.rb + include SiSU_Param + require_relative 'ao' # ao.rb + class CombinedSingleton + include Singleton + def get_all(opt) + set_env(opt) + set_file(opt) + set_md(opt) + set_ao(opt) #needs @md + end + def get_env(opt) + set_env(opt) + end + def get_file(opt) + set_file(opt) + end + def get_md(opt) + set_md(opt) + end + def get_ao_array(opt) + set_ao(opt) #needs @md + end + def get_env_md(opt) + set_env(opt) + set_md(opt) + end + def get_idx_sst(opt) + set_sst_idx(opt) + end + def get_idx_raw(opt) + set_raw_idx(opt) + end + def get_idx_html(opt) + set_html_idx(opt) + end + def get_idx_xhtml(opt) + set_xhtml_idx(opt) + end + def get_name_tags(opt) + set_name_tags(opt) + end + def get_maps(opt) + set_nametags_map(opt) + set_ocn_htmlseg_map(opt) + end + def get_map_nametags(opt) + set_nametags_map(opt) + end + def get_map_ocn_htmlseg(opt) + set_ocn_htmlseg_map(opt) + end + attr_accessor :opt,:md,:sst_idx,:raw_idx,:html_idx,:xhtml_idx + def set_md(opt) + begin + @md=SiSU_Param::Parameters.new(opt).get + self + rescue + SiSU_Errors::Rescued.new($!,$@,opt.cmd,opt.fnl).location do + __LINE__.to_s + ':' + __FILE__ + end + end + end + attr_accessor :opt,:env,:file + def set_env(opt) + begin + @env=SiSU_Env::InfoEnv.new(opt.fns) + self + rescue + SiSU_Errors::Rescued.new($!,$@,opt.cmd,opt.fnl).location do + __LINE__.to_s + ':' + __FILE__ + end + end + end + def set_file(opt) + begin + set_md(opt) unless @md + @file=SiSU_Env::FileOp.new(@md) + self + rescue + SiSU_Errors::Rescued.new($!,$@,opt.cmd,opt.fnl).location do + __LINE__.to_s + ':' + __FILE__ + end + end + end + attr_accessor :opt,:ao_array + def set_ao(opt) + begin + @ao_array=SiSU_AO::Source.new(opt).get + self + rescue + SiSU_Errors::Rescued.new($!,$@,opt.cmd,opt.fnl).location do + __LINE__.to_s + ':' + __FILE__ + end + end + end + def set_sst_idx(opt) + begin + @sst_idx=SiSU_AO::Source.new(opt).get_idx_sst + self + rescue + SiSU_Errors::Rescued.new($!,$@,opt.cmd,opt.fnl).location do + __LINE__.to_s + ':' + __FILE__ + end + end + end + def set_raw_idx(opt) + begin + @raw_idx=SiSU_AO::Source.new(opt).get_idx_raw + self + rescue + SiSU_Errors::Rescued.new($!,$@,opt.cmd,opt.fnl).location do + __LINE__.to_s + ':' + __FILE__ + end + end + end + def set_html_idx(opt) + begin + @html_idx=SiSU_AO::Source.new(opt).get_idx_html + self + rescue + SiSU_Errors::Rescued.new($!,$@,opt.cmd,opt.fnl).location do + __LINE__.to_s + ':' + __FILE__ + end + end + end + def set_xhtml_idx(opt) + begin + @xhtml_idx=SiSU_AO::Source.new(opt).get_idx_xhtml + self + rescue + SiSU_Errors::Rescued.new($!,$@,opt.cmd,opt.fnl).location do + __LINE__.to_s + ':' + __FILE__ + end + end + end + attr_accessor :nametags_map + def set_nametags_map(opt) + begin + opt=@md ? @md : opt + @nametags_map=SiSU_AO::Source.new(opt).get_map_nametags + self + rescue + if @md + SiSU_Errors::Rescued.new($!,$@,@md.opt.cmd,@md.opt.fnl).location do + __LINE__.to_s + ':' + __FILE__ + end + else + SiSU_Errors::Rescued.new($!,$@,opt.cmd,opt.fnl).location do + __LINE__.to_s + ':' + __FILE__ + end + end + end + end + attr_accessor :ocn_htmlseg_map + def set_ocn_htmlseg_map(opt) + begin + @ocn_htmlseg_map=SiSU_AO::Source.new(@md).get_map_ocn_htmlseg + self + rescue + SiSU_Errors::Rescued.new($!,$@,opt.cmd,opt.fnl).location do + __LINE__.to_s + ':' + __FILE__ + end + end + end + end +end +__END__ +consider running as separate objects diff --git a/lib/sisu/v5/shared_images.rb b/lib/sisu/v5/shared_images.rb index e307eba3..c1e9abdc 100644 --- a/lib/sisu/v5/shared_images.rb +++ b/lib/sisu/v5/shared_images.rb @@ -60,7 +60,7 @@ ** Description: common file for xml generation =end module SiSU_Images - require_relative 'particulars' # particulars.rb + require_relative 'se_hub_particulars' # se_hub_particulars.rb class Source def initialize(opt) @particulars=SiSU_Particulars::CombinedSingleton.instance.get_all(opt) diff --git a/lib/sisu/v5/shared_sem.rb b/lib/sisu/v5/shared_sem.rb index 860457bb..6ddc3f45 100644 --- a/lib/sisu/v5/shared_sem.rb +++ b/lib/sisu/v5/shared_sem.rb @@ -62,7 +62,7 @@ =end module SiSU_Sem - require_relative 'param' # param.rb + require_relative 'dp' # dp.rb class Tags def initialize(para,md) @para,@md=para,md diff --git a/lib/sisu/v5/sitemaps.rb b/lib/sisu/v5/sitemaps.rb index b76d2d60..2d157096 100644 --- a/lib/sisu/v5/sitemaps.rb +++ b/lib/sisu/v5/sitemaps.rb @@ -57,13 +57,13 @@ - ** Description: sitemap created from parameters extracted from input file(s) + ** Description: sitemap created from document parameters =end module SiSU_Sitemaps - require_relative 'param' # param.rb + require_relative 'dp' # dp.rb include SiSU_Param - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env require_relative 'xml_shared' # xml_shared.rb include SiSU_XML_Munge diff --git a/lib/sisu/v5/spell.rb b/lib/sisu/v5/spell.rb deleted file mode 100644 index 69b6da7e..00000000 --- a/lib/sisu/v5/spell.rb +++ /dev/null @@ -1,105 +0,0 @@ -# encoding: utf-8 -=begin - - * Name: SiSU - - * Description: a framework for document structuring, publishing and search - - * Author: Ralph Amissah - - * Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, - All Rights Reserved. - - * License: GPL 3 or later: - - SiSU, a framework for document structuring, publishing and search - - Copyright (C) Ralph Amissah - - This program is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the Free - Software Foundation, either version 3 of the License, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - more details. - - You should have received a copy of the GNU General Public License along with - this program. If not, see . - - 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: - - - * Git - - - - * Ralph Amissah - - - - ** Description: spellchecking - -=end -module SiSU_SpellUtility - class Spell - def initialize(input,filesrc,flg) - @flg=flg - @filename, @filetype = /(.+?)(\.\w\w\w0$)/.match(filesrc)[1,2] #.gsub(/\.\w\w\w0$/, "") - @input=input - @allwords=[] - puts @filename - @speller='aspell' # 'ispell' - @dictionary='british' - @lang='en_GB' - end - def check - @input.each do |data| - data=data.gsub(/(https?|www|ftp|gopher|png|jpg|gif|html|htm)\S+/i,' '). - gsub(/( |#{Mx[:nbsp]})/i,' '). - gsub(/<\/?(table|tr|td|b|p|href).*?>/i,' '). - gsub(/(<==.+|<:\S+>||^@\S+?:.+|\{\{\{|~)/,' '). - gsub(/(["|<>)(\n'`.;&_-]|\=)/,' '). - gsub(/\b(altExternal| - target|externalimg| - srcimagebext| - img|src|toc|pdf| - cd|org| - helvetica|roman - )\b/i,' '). - gsub(/EOF/,'') - @words=data.scan(/\S+/) - @words.each { |y| @allwords << y } - end - @allwords=@allwords.uniq - if @flg =~ /S/ - File.open('/home/ralph/spell_error','a+') do |file| #fix - file.puts %{\n\n<<#{@filename}>>} - end - @allwords.each { |y| puts y.inspect; system(%{cat #{y} | /usr/bin/#{@speller} -l -d #{@dictionary} >> ~/spell_error })} - else - @allwords.each { |y| sp=%x{echo #{y}|#{@speller} -l }; puts sp unless sp.empty?} - end - end - end -end -__END__ diff --git a/lib/sisu/v5/src_kdissert_share.rb b/lib/sisu/v5/src_kdissert_share.rb index abf2f2d1..e67d4249 100644 --- a/lib/sisu/v5/src_kdissert_share.rb +++ b/lib/sisu/v5/src_kdissert_share.rb @@ -61,7 +61,7 @@ =end module SiSU_KdiSource - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env class Source begin diff --git a/lib/sisu/v5/src_share.rb b/lib/sisu/v5/src_share.rb index f78b922f..be789e00 100644 --- a/lib/sisu/v5/src_share.rb +++ b/lib/sisu/v5/src_share.rb @@ -63,7 +63,7 @@ module SiSU_Markup require_relative 'src_shared' # src_shared.rb include SiSU_Source - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env class Source < SiSU_Source::SiSUpodSource def initialize(opt,build=nil,place=nil) diff --git a/lib/sisu/v5/src_shared.rb b/lib/sisu/v5/src_shared.rb index 068120f5..2f6f8305 100644 --- a/lib/sisu/v5/src_shared.rb +++ b/lib/sisu/v5/src_shared.rb @@ -63,8 +63,8 @@ module SiSU_Source include SiSU_Env class SiSUpodSource - require_relative 'sysenv' # sysenv.rb - require_relative 'particulars' # particulars.rb + require_relative 'se' # se.rb + require_relative 'se_hub_particulars' # se_hub_particulars.rb def initialize(opt,build=nil,place=nil) @opt=opt @date=SiSU_Env::InfoDate.new.dt diff --git a/lib/sisu/v5/src_sisupod_make.rb b/lib/sisu/v5/src_sisupod_make.rb index 5dd8f038..fa5b6560 100644 --- a/lib/sisu/v5/src_sisupod_make.rb +++ b/lib/sisu/v5/src_sisupod_make.rb @@ -63,10 +63,10 @@ module SiSU_Doc require_relative 'src_shared' # scr_shared.rb include SiSU_Source - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env class Source < SiSU_Source::SiSUpodSource - require_relative 'response' # response.rb + require_relative 'utils_response' # utils_response.rb def initialize(opt,build=nil,place=nil) super(opt,build,place) @zipfile=@opt.fno.gsub(/(?:\~\S{2,3})?(\.ss[tm])$/,'\1') diff --git a/lib/sisu/v5/sst_convert_markup.rb b/lib/sisu/v5/sst_convert_markup.rb index cdceba7c..6002e2fc 100644 --- a/lib/sisu/v5/sst_convert_markup.rb +++ b/lib/sisu/v5/sst_convert_markup.rb @@ -65,7 +65,7 @@ module SiSU_Modify require_relative 'sst_identify_markup' # sst_identify_markup.rb require_relative 'sst_from_xml' # sst_from_xml.rb - require_relative 'response' # response.rb + require_relative 'utils_response' # utils_response.rb class ConvertMarkup def initialize(opt) @opt=opt @@ -311,7 +311,7 @@ WOK end end #%% files to match for this conversion set -------------------------> -require_relative 'options' # options.rb +require_relative 'hub_options' # hub_options.rb argv=$* base_path=Dir.pwd @opt=SiSU_Commandline::Options.new(argv,base_path) diff --git a/lib/sisu/v5/sst_do_inline_footnotes.rb b/lib/sisu/v5/sst_do_inline_footnotes.rb index ac4c63d5..c3340fbd 100644 --- a/lib/sisu/v5/sst_do_inline_footnotes.rb +++ b/lib/sisu/v5/sst_do_inline_footnotes.rb @@ -64,9 +64,9 @@ module SiSU_ConvertFootnotes require_relative 'defaults' # defaults.rb include SiSU_Viz - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env - require_relative 'param' # param.rb + require_relative 'dp' # dp.rb include SiSU_Param require_relative 'ao_syntax' # ao_syntax.rb include SiSU_AO_Syntax @@ -277,7 +277,7 @@ module SiSU_ConvertFootnotes data=@data tuned_file=[] data.each do |para| - if @md.markup =~/0\.16|0\.37/ #parameters not extracted/available + if @md.markup =~/0\.16|0\.37/ #parameters not extracted/available para.gsub!(/^0~\S+\s+/,'@\1: ') para.gsub!(/^1~/,':A~') para.gsub!(/^2~/,':B~') diff --git a/lib/sisu/v5/sst_from_xml.rb b/lib/sisu/v5/sst_from_xml.rb index 7ae4b446..b6fccd92 100644 --- a/lib/sisu/v5/sst_from_xml.rb +++ b/lib/sisu/v5/sst_from_xml.rb @@ -62,7 +62,7 @@ =end module SiSU_sstFromXML - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb class Convert begin require 'rexml/document' diff --git a/lib/sisu/v5/sst_to_s_xml_sax.rb b/lib/sisu/v5/sst_to_s_xml_sax.rb index acb3ac40..fe685983 100644 --- a/lib/sisu/v5/sst_to_s_xml_sax.rb +++ b/lib/sisu/v5/sst_to_s_xml_sax.rb @@ -61,13 +61,13 @@ =end module SiSU_SimpleXML_ModelSax - require_relative 'particulars' # particulars.rb + require_relative 'se_hub_particulars' # se_hub_particulars.rb include SiSU_Particulars require_relative 'defaults' # defaults.rb include SiSU_Viz - require_relative 'param' # param.rb + require_relative 'dp' # dp.rb include SiSU_Param - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env require_relative 'ao_doc_str' # ao_doc_str.rb require_relative 'xml_shared' # xml_shared.rb diff --git a/lib/sisu/v5/sysenv.rb b/lib/sisu/v5/sysenv.rb deleted file mode 100644 index 0d67733f..00000000 --- a/lib/sisu/v5/sysenv.rb +++ /dev/null @@ -1,164 +0,0 @@ -# encoding: utf-8 -=begin - - * Name: SiSU - - * Description: a framework for document structuring, publishing and search - - * Author: Ralph Amissah - - * Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, - All Rights Reserved. - - * License: GPL 3 or later: - - SiSU, a framework for document structuring, publishing and search - - Copyright (C) Ralph Amissah - - This program is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the Free - Software Foundation, either version 3 of the License, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - more details. - - You should have received a copy of the GNU General Public License along with - this program. If not, see . - - 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: - - - * Git - - - - * Ralph Amissah - - - - ** Description: system environment, resource control and configuration details - -=end -@@cX=nil -module SiSU_Env - require_relative 'constants' # constants.rb - require_relative 'utils' # utils.rb - require_relative 'se_date' # se_date.rb - require_relative 'se_info_system' # se_info_system.rb - require_relative 'se_load' # se_load.rb - require_relative 'se_get_init' # se_get_init.rb - require_relative 'se_envcall' # se_envcall.rb - require_relative 'se_programs' # se_programs.rb - require_relative 'se_standardise_lang' # se_standardise_lang.rb - require_relative 'se_info_env' # se_info_env.rb - require_relative 'se_processing' # se_processing.rb - require_relative 'se_filemap' # se_filemap.rb - require_relative 'se_file_op' # se_file_op.rb - require_relative 'se_cleanoutput' # se_cleanoutput.rb - require_relative 'se_remotes' # se_remotes.rb - require_relative 'se_version' # se_version.rb - require_relative 'se_db' # se_db.rb - require_relative 'se_css' # se_css.rb - require_relative 'se_clear' # se_clear.rb - require_relative 'se_createsite' # se_createsite.rb - require_relative 'se_info_port' # se_info_port.rb - begin - require 'singleton' - require 'fileutils' - include FileUtils::Verbose - rescue LoadError - SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). - error('singleton or fileutils NOT FOUND (LoadError)') - end - @@noyaml=false - class InfoDate < SiSU_Info_Date::InfoDate # se_date.rb - end - class InfoSystemGen < SiSU_Info_Sys_Gen::InfoSystemGen # se_info_system.rb - end - class InfoSystem < SiSU_Info_Sys::InfoSystem # se_info_system.rb - end - class Load < SiSU_Load::Load # se_load.rb - end - class GetInit < SiSU_Get_Init::GetInit # se_get_init.rb - end - class EnvCall < SiSU_Env_Call::EnvCall # se_envcall.rb - end - class SystemCall < SiSU_Sys_Call::SystemCall # se_programs.rb - end - class StandardiseLanguage < SiSU_Standardise_Lang::StandardiseLanguage # se_standardise_lang.rb - end - class InfoEnv < SiSU_Info_Env::InfoEnv # se_info_env.rb - end - class InfoProcessingFlag < SiSU_Info_Processing_Flag::InfoProcessingFlag # se_processing.rb - end - class InfoSettings < SiSU_Info_Set::InfoSettings # se_programs.rb - end - class FileMap < SiSU_File_Map::FileMap # se_filemap.rb - end - class CleanOutput < SiSU_Clean_Output::CleanOutput # se_cleanoutput.rb - end - class InfoRemoteHost < SiSU_Info_Remote_Host::InfoRemoteHost # se_remotes.rb - end - class InfoRemote < SiSU_Info_Remote::InfoRemote # se_remotes.rb - end - class InfoVersion < SiSU_Info_Version::InfoVersion # se_version.rb - end - class InfoAbout < SiSU_Info_About::InfoAbout # se_version.rb - end - class InfoFile < SiSU_Info_File::InfoFile # se_file_op.rb - end - class ProcessingSettings < SiSU_Processing_Settings::ProcessingSettings # se_processing.rb - end - class InfoDb < SiSU_Info_Db::InfoDb # se_db.rb - end - class DbOp < SiSU_Db_Op::DbOp # se_db.rb - end - class FileOp < SiSU_File_Op::FileOp # se_file_op.rb - end - class FilenameLanguageCodeInsert < SiSU_Filename_Lang::FilenameLanguageCodeInsert # se_file_op.rb - end - class CreateFile < SiSU_Create_File::CreateFile # se_file_op.rb - end - class Clear < SiSU_Clear::Clear # se_clear.rb - end - class InfoPort < SiSU_Info_Port::InfoPort # se_info_port.rb - end - class InfoProgram < SiSU_Info_Program::InfoProgram # se_programs.rb - end - class CSS_Default < SiSU_CSS::CSS_Default # se_css.rb - end - class CSS_Select < SiSU_CSS::CSS_Select # se_css.rb - end - class CSS_Stylesheet < SiSU_CSS::CSS_Stylesheet # se_css.rb - end - class CreateSite < SiSU_Create_Site::CreateSite # se_createsite.rb - end -end -module SiSU_Screen - require_relative 'screen_text_color' # screen_text_color.rb -end -module SiSU_Errors - require_relative 'errors' # errors.rb -end -__END__ diff --git a/lib/sisu/v5/termsheet.rb b/lib/sisu/v5/termsheet.rb index 7e8a2a30..a3fe308d 100644 --- a/lib/sisu/v5/termsheet.rb +++ b/lib/sisu/v5/termsheet.rb @@ -62,8 +62,8 @@ sample files must be provided - (saved till later as may confuse) =end -require_relative 'sysenv' # sysenv.rb -require_relative 'param' # param.rb +require_relative 'se' # se.rb +require_relative 'dp' # dp.rb include SiSU_Param @do,@done,@used,@html_output,@txt_input,@txt_output,@@report=Array.new(7){[]} @@info=nil @@ -123,7 +123,7 @@ WOK @@report << @done << @used << "\n" @done,@used=[],[] end -require_relative 'param' # param.rb +require_relative 'dp' # dp.rb @argv=$* @proc="#{@argv[0].to_s}" if @proc =~ /^-?[wft]/ diff --git a/lib/sisu/v5/texinfo.rb b/lib/sisu/v5/texinfo.rb index 4c25c1ed..e792a989 100644 --- a/lib/sisu/v5/texinfo.rb +++ b/lib/sisu/v5/texinfo.rb @@ -62,7 +62,7 @@ =end module SiSU_TexInfo require_relative 'html' # html.rb - require_relative 'param' # param.rb + require_relative 'dp' # dp.rb include SiSU_Param include SiSU_Viz #include Stamp ... needed removed arbitrarily 2005w05/1 (warnings about undefined flags) diff --git a/lib/sisu/v5/texinfo_format.rb b/lib/sisu/v5/texinfo_format.rb index 4286f50b..5bc41442 100644 --- a/lib/sisu/v5/texinfo_format.rb +++ b/lib/sisu/v5/texinfo_format.rb @@ -62,7 +62,7 @@ =end module SiSU_TexInfoFormat @@table_pg_break_counter=1 - require_relative 'param' # param.rb + require_relative 'dp' # dp.rb include SiSU_Param include SiSU_Viz class Texinfo diff --git a/lib/sisu/v5/texpdf.rb b/lib/sisu/v5/texpdf.rb index 8d6a01c5..b5d36602 100644 --- a/lib/sisu/v5/texpdf.rb +++ b/lib/sisu/v5/texpdf.rb @@ -68,7 +68,7 @@ module SiSU_TeX end require_relative 'defaults' # defaults.rb include SiSU_Viz - require_relative 'particulars' # particulars.rb + require_relative 'se_hub_particulars' # se_hub_particulars.rb include SiSU_Particulars require_relative 'texpdf_format' # texpdf_format.rb include SiSU_TeX_Pdf @@ -87,7 +87,7 @@ module SiSU_TeX rescue LoadError SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('pstore NOT FOUND (LoadError)') end - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env include SiSU_Viz require_relative 'ao' # ao.rb diff --git a/lib/sisu/v5/txt_asciidoc.rb b/lib/sisu/v5/txt_asciidoc.rb index 7ca3cc85..43e49f7b 100644 --- a/lib/sisu/v5/txt_asciidoc.rb +++ b/lib/sisu/v5/txt_asciidoc.rb @@ -62,7 +62,7 @@ =end module SiSU_Txt_AsciiDoc require_relative 'ao' # ao.rb - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env require_relative 'shared_metadata' # shared_metadata.rb require_relative 'txt_shared' # txt_shared.rb diff --git a/lib/sisu/v5/txt_markdown.rb b/lib/sisu/v5/txt_markdown.rb index 69bedbc5..1e4326a3 100644 --- a/lib/sisu/v5/txt_markdown.rb +++ b/lib/sisu/v5/txt_markdown.rb @@ -62,7 +62,7 @@ =end module SiSU_Txt_Markdown require_relative 'ao' # ao.rb - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env require_relative 'shared_metadata' # shared_metadata.rb require_relative 'txt_shared' # txt_shared.rb diff --git a/lib/sisu/v5/txt_plain.rb b/lib/sisu/v5/txt_plain.rb index 824d29c8..2f3cc134 100644 --- a/lib/sisu/v5/txt_plain.rb +++ b/lib/sisu/v5/txt_plain.rb @@ -63,7 +63,7 @@ =end module SiSU_Txt_Plain require_relative 'ao' # ao.rb - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env require_relative 'shared_metadata' # shared_metadata.rb require_relative 'txt_shared' # txt_shared.rb diff --git a/lib/sisu/v5/txt_rst.rb b/lib/sisu/v5/txt_rst.rb index c3978b06..f00c9e9c 100644 --- a/lib/sisu/v5/txt_rst.rb +++ b/lib/sisu/v5/txt_rst.rb @@ -62,7 +62,7 @@ =end module SiSU_Txt_rST require_relative 'ao' # ao.rb - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env require_relative 'shared_metadata' # shared_metadata.rb require_relative 'txt_shared' # txt_shared.rb diff --git a/lib/sisu/v5/txt_textile.rb b/lib/sisu/v5/txt_textile.rb index f5962b80..65c102fc 100644 --- a/lib/sisu/v5/txt_textile.rb +++ b/lib/sisu/v5/txt_textile.rb @@ -62,7 +62,7 @@ =end module SiSU_Txt_Textile require_relative 'ao' # ao.rb - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env require_relative 'shared_metadata' # shared_metadata.rb require_relative 'txt_shared' # txt_shared.rb diff --git a/lib/sisu/v5/update.rb b/lib/sisu/v5/update.rb index a4b6b2b3..2301990a 100644 --- a/lib/sisu/v5/update.rb +++ b/lib/sisu/v5/update.rb @@ -61,7 +61,7 @@ =end module SiSU_UpdateControlFlag - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env include SiSU_Param class Check diff --git a/lib/sisu/v5/urls.rb b/lib/sisu/v5/urls.rb index cef51ab5..815fe65a 100644 --- a/lib/sisu/v5/urls.rb +++ b/lib/sisu/v5/urls.rb @@ -61,9 +61,9 @@ =end module SiSU_Urls - require_relative 'particulars' # particulars.rb + require_relative 'se_hub_particulars' # se_hub_particulars.rb include SiSU_Particulars - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env; include SiSU_Screen class Source attr_reader :opt diff --git a/lib/sisu/v5/utils_response.rb b/lib/sisu/v5/utils_response.rb new file mode 100644 index 00000000..88209b2c --- /dev/null +++ b/lib/sisu/v5/utils_response.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, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. + + * License: GPL 3 or later: + + SiSU, a framework for document structuring, publishing and search + + Copyright (C) Ralph Amissah + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along with + this program. If not, see . + + 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: + + + * Git + + + + * Ralph Amissah + + + + ** Description: Request response + +=end +module SiSU_Response + class Response + def response?(ask) #move to more appropriate directory later + response='redo' + print ask + " ['yes', 'no' or 'quit']: " + response=File.new('/dev/tty').gets.strip + ans=if response=='yes' then true + elsif response=='no' then false + elsif response =~/^quit|exit$/ then exit + else puts "[please type: 'yes', 'no' or 'quit']" + response?(ask) + end + ans + end + end +end +__END__ diff --git a/lib/sisu/v5/utils_screen_text_color.rb b/lib/sisu/v5/utils_screen_text_color.rb new file mode 100644 index 00000000..42b0c698 --- /dev/null +++ b/lib/sisu/v5/utils_screen_text_color.rb @@ -0,0 +1,478 @@ +# encoding: utf-8 +=begin + + * Name: SiSU + + * Description: a framework for document structuring, publishing and search + + * Author: Ralph Amissah + + * Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. + + * License: GPL 3 or later: + + SiSU, a framework for document structuring, publishing and search + + Copyright (C) Ralph Amissah + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along with + this program. If not, see . + + 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: + + + * Git + + + + * Ralph Amissah + + + + ** Description: system environment, screen colors text + +=end +module SiSU_Screen + class Color + attr_accessor :off,:marker,:bold,:underline,:invert,:darkgrey_hi,:grey_hi,:pink_hi,:fuchsia_hi,:red_hi,:orange_hi,:yellow_hi,:brown_hi,:lightgreen_hi,:green_hi,:cyan_hi,:blue_hi,:navy_hi,:white,:white_bold,:grey,:pink,:fuchsia,:ruby,:red,:orange,:yellow,:brown,:green,:darkgreen,:cyan,:blue,:navy,:black + def initialize(&block) + instance_eval &block + end + end + class Ansi < Color + attr_reader :cX + def initialize(color_state,*txt) + @color_state,@txt=color_state,txt + @color_instruct=txt[0] + @cX=@@cX=if color_state==:on + Color.new do + self.off=self.white=self.white_bold=self.marker=self.bold=self.underline=self.invert=self.darkgrey_hi=self.grey_hi=self.pink_hi=self.fuchsia_hi=self.red_hi=self.orange_hi=self.yellow_hi=self.brown_hi=self.lightgreen_hi=self.green_hi=self.cyan_hi=self.blue_hi=self.navy_hi=self.grey=self.pink=self.fuchsia=self.ruby=self.red=self.orange=self.yellow=self.brown=self.green=self.darkgreen=self.cyan=self.blue=self.navy=self.black='' + end + else #default set to colors on + Color.new do + self.off = "\033[0m" + self.white = "\033[37m" + self.white_bold = "\033[1m" + self.marker = "\033[42m" + self.bold = "\033[1m" + self.underline = "\033[4m" + self.invert = "\033[7m" + self.darkgrey_hi = "\033[100m" + self.grey_hi = "\033[47m" + self.pink_hi = "\033[105m" + self.fuchsia_hi = "\033[45m" + self.red_hi = "\033[41m" + self.orange_hi = "\033[101m" + self.yellow_hi = "\033[103m" + self.brown_hi = "\033[43m" + self.lightgreen_hi = "\033[102m" + self.green_hi = "\033[42m" + self.cyan_hi = "\033[106m" + self.blue_hi = "\033[104m" + self.navy_hi = "\033[44m" + self.grey = "\033[90m" + self.pink = "\033[95m" + self.fuchsia = "\033[35m" + self.ruby = "\033[31m" + self.red = "\033[91m" #check + self.orange = "\033[91m" + self.yellow = "\033[93m" + self.brown = "\033[33m" + self.green = "\033[92m" + self.darkgreen = "\033[32m" + self.cyan = "\033[36m" + self.blue = "\033[94m" + self.navy = "\033[34m" + self.black = "\033[30m" + end + end + end + def colors + 0.upto(109) {|i| print "\033[#{i}m 33[#{i}m \033[m"} + puts '' + end + def color + case @color_instruct + when /invert/ then @cX.invert + when /darkgrey_hi/ then @cX.darkgrey_hi + when /grey_hi/ then @cX.grey_hi + when /pink_hi/ then @cX.pink_hi + when /fuchsia_hi/ then @cX.fuchsia_hi + when /red_hi/ then @cX.red_hi + when /orange_hi/ then @cX.orange_hi + when /yellow_hi/ then @cX.yellow_hi + when /brown_hi/ then @cX.brown_hi + when /lightgreen_hi/ then @cX.lightgreen_hi + when /green_hi/ then @cX.green_hi + when /cyan_hi/ then @cX.cyan_hi + when /blue_hi/ then @cX.blue_hi + when /navy_hi/ then @cX.navy_hi + when /white/ then @cX.white + when /grey/ then @cX.grey + when /pink/ then @cX.pink + when /fuchsia/ then @cX.fuchsia + when /ruby/ then @cX.ruby + when /red/ then @cX.red + when /orange/ then @cX.orange + when /yellow/ then @cX.yellow + when /brown/ then @cX.brown + when /green/ then @cX.green + when /darkgreen/ then @cX.darkgreen + when /cyan/ then @cX.cyan + when /blue/ then @cX.blue + when /navy/ then @cX.navy + when /close/ then @cX.off + when /off/ then @cX.off + end + end + def colorize + case @color_instruct + when /invert/ then puts "#{@cX.invert}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}" + when /darkgrey_hi/ then puts "#{@cX.darkgrey_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}" + when /grey_hi/ then puts "#{@cX.grey_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}" + when /pink_hi/ then puts "#{@cX.pink_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}" + when /fuchsia_hi/ then puts "#{@cX.fuchsia_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}" + when /red_hi/ then puts "#{@cX.red_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}" + when /orange_hi/ then puts "#{@cX.orange_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}" + when /yellow_hi/ then puts "#{@cX.yellow_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}" + when /brown_hi/ then puts "#{@cX.brown_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}" + when /lightgreen_hi/ then puts "#{@cX.lightgreen_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}" + when /green_hi/ then puts "#{@cX.green_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}" + when /cyan_hi/ then puts "#{@cX.cyan_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}" + when /blue_hi/ then puts "#{@cX.blue_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}" + when /navy_hi/ then puts "#{@cX.navy_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}" + when /bold/ then puts "#{@cX.bold}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" + when /white/ then puts "#{@cX.off}#{@txt[1]} #{@txt[2]}" + when /grey/ then puts "#{@cX.grey}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" + when /pink/ then puts "#{@cX.pink}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" + when /fuchsia/ then puts "#{@cX.fuchsia}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" + when /ruby/ then puts "#{@cX.ruby}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" + when /red/ then puts "#{@cX.red}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" + when /orange/ then puts "#{@cX.orange}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" + when /yellow/ then puts "#{@cX.yellow}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" + when /brown/ then puts "#{@cX.brown}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" + when /green/ then puts "#{@cX.green}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" + when /darkgreen/ then puts "#{@cX.darkgreen}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" + when /cyan/ then puts "#{@cX.cyan}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" + when /blue/ then puts "#{@cX.blue}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" + when /navy/ then puts "#{@cX.navy}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" + end + end + def sourcename(sourcefilename) + @sourcefilename=sourcefilename + end + def basename(sourcefilename) + @basename=sourcefilename.sub(/\.(?:(?:-|ssm\.)?sst|ssm)$/,'') + end + def sisu + end + def rescue + STDERR.puts %{\t #{@cX.orange}Rescued#{@cX.off} #{@cX.grey}#{yield if block_given?}\n\t An#{@cX.off} #{@cX.fuchsia}ERROR#{@cX.off} #{@cX.grey}occurred, message:#{@cX.off} #{@cX.fuchsia}#{@txt[0]}#{@cX.off} #{@cX.grey}#{@txt[1]}#{@cX.off} #{@cX.brown}#{@txt[2]}#{@cX.off}} + end + def warn + STDERR.puts "\t #{@cX.brown}#{@txt[0]}#{@cX.off} #{@cX.grey}#{@txt[1]}#{@cX.off}" + end + def error + STDERR.puts "\t #{@cX.fuchsia}#{@txt[0]}#{@cX.off} #{@cX.brown}#{@txt[1]}#{@cX.off}" + end + def error2 + STDERR.puts "\t #{@cX.grey}#{@txt[0]}#{@cX.off} #{@cX.fuchsia}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" + end + def version + puts "#{@cX.blue_hi}#{@txt[0]} #{@txt[1]}#{@cX.off} #{@cX.grey} (#{@txt[3]} [#{@txt[2]}])#{@txt[4]} &#{@cX.off} #{@cX.ruby}Ruby#{@cX.off} #{@cX.grey}(#{@txt[5]})#{@cX.off}\n" + end + def html3numbers + puts %{\t#{@cX.green}#{@txt[0]}#{@cX.off} #{@cX.cyan}files processed#{@cX.off}. } + + %{#{@cX.grey}} + + %{scroll only: #{@txt[1]}, seg only: #{@txt[2]},} + + %{#{@cX.off} } + + %{#{@cX.cyan}joint scroll & seg: #{@txt[3]},#{@cX.off}} + + %{#{@cX.grey} } + + %{nav only: #{@txt[4]}} + + %{#{@cX.off}} + end + def html2numbers + puts %{\t#{@cX.green}#{@txt[0]}#{@cX.off} #{@cX.cyan}files processed#{@cX.off}. } + + %{#{@cX.grey}} + + %{scroll only: #{@txt[1]},} + + %{#{@cX.off} } + + %{#{@cX.cyan}seg only: #{@txt[2]},#{@cX.off}} + + %{#{@cX.grey} } + + %{joint scroll & seg: #{@txt[3]}, nav only: #{@n_files_nav}} + + %{#{@cX.off}} + end + def html1numbers + puts %{\t#{@cX.green}#{@txt[0]}#{@cX.off} #{@cX.cyan}files processed#{@cX.off}. } + + %{#{@cX.cyan}scroll only: #{@txt[1]},#{@cX.off}} + + %{#{@cX.grey} } + + %{seg only: #{@txt[2]}, } + + %{joint scroll & seg: #{@txt[3]}, nav only: #{@n_files_nav}} + + %{#{@cX.off}} + end + def html0_numbers + puts %{\t#{@cX.ruby}#{@txt[0]} files processed#{@cX.off}. } + + %{#{@cX.grey}} + + %{scroll only: #{@txt[1]}, seg only: #{@txt[2]}, joint scroll & seg: #{@txt[3]},} + + %{#{@cX.off} } + + %{#{@cX.cyan}nav only: #{@txt[4]}#{@cX.off}.} + end + def grey + puts "#{@cX.grey}#{@txt[0]}#{@cX.off} #{@cX.cyan}#{@txt[1]}#{@cX.off}" + end + def txt_white + puts "\t#{@cX.white}#{@txt[0]}#{@cX.off} #{@cX.white}#{@txt[1]}#{@cX.off}" + end + def txt_grey + puts "\t#{@cX.grey}#{@txt[0]}#{@cX.off} #{@cX.cyan}#{@txt[1]}#{@cX.off}" + end + def txt_cyan + puts "\t#{@cX.cyan}#{@txt[0]}#{@cX.off} #{@cX.grey}#{@txt[1]}#{@cX.off}" + end + def txt_blue + puts "\t#{@cX.blue}#{@txt[0]}#{@cX.off} #{@cX.grey}#{@txt[1]}#{@cX.off}" + end + def txt_red + puts "\t#{@cX.red}#{@txt[0]}#{@cX.off} #{@cX.cyan}#{@txt[1]}#{@cX.off}" + end + def txt_green + puts "\t#{@cX.green}#{@txt[0]}#{@cX.off} #{@cX.grey}#{@txt[1]}#{@cX.off}" + end + def url #clean + blue + end + def result + puts "\t#{@cX.green}#{@txt[0]}#{@cX.off} #{@cX.blue}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" + end + def maintenance + puts "\t#{@cX.grey}#{@txt[0]}#{@cX.off} #{@cX.brown}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" + end + def instruct + puts %{\t #{@cX.grey}#{@txt[0]}#{@cX.off} #{@cX.cyan}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off} #{@cX.cyan}#{@txt[3]}#{@cX.off} #{@cX.grey}#{@txt[4]}#{@cX.off} "#{@cX.brown}#{@f}#{@cX.off}"} + end + def grey_open + print @cX.grey + end + def p_off + print @cX.off + end + def p_close + print @cX.off + end + def flow + puts %{\t#{@cX.grey}#{@txt[0]}#{@cX.off} #{@cX.ruby}->#{@cX.off}\n\t #{@cX.blue}#{@txt[1]}#{@cX.off}} + end + def output + puts %{\t#{@cX.grey}#{@txt[0]}#{@cX.off} #{@cX.ruby}->#{@cX.off}\n\t #{@cX.blue}#{@txt[1]}#{@cX.off}} + end + def generic + puts %{\t#{@cX.navy}#{@txt[0]} #{@txt[1]}#{@cX.off}. } + end + def files_processed + puts %{\t#{@cX.green}#{@txt[0]}#{@cX.off} #{@cX.grey}#{@txt[1]}#{@cX.off}} + end + def print_blue + print "#{@cX.blue}#{@txt[0]} #{@txt[1]}#{@cX.off}" + end + def puts_blue + puts "#{@cX.blue}#{@txt[0]} #{@txt[1]}#{@cX.off}" + end + def print_brown + print "#{@cX.brown}#{@txt[0]}#{@cX.off}" + end + def blue_tab + print "\t#{@cX.blue}#{@txt[0]}#{@cX.off}\n" + end + def print_grey + print "#{@cX.grey}#{@txt[0]} #{@txt[1]}#{@cX.off}" + end + def puts_grey + puts "#{@cX.grey}#{@txt[0]} #{@txt[1]}#{@cX.off}" + end + def puts_brown + puts "#{@cX.brown}#{@txt[0]} #{@txt[1]}#{@cX.off}" + end + def grey_tab + print "\t#{@cX.grey}#{@txt[0]}#{@cX.off}\n" + end + def green_title + puts %{#{@cX.green}#{@txt[0]}#{@cX.off} #{@cX.grey}#{@txt[1]}#{@cX.off}} + end + def green_title_hi + puts %{#{@cX.green_hi}#{@cX.black}#{@txt[0]}#{@cX.off*2} #{@cX.grey}#{@txt[1]}#{@cX.off}} + end + def green_hi_blue + puts %{#{@cX.green_hi}#{@cX.black}#{@txt[0]}#{@cX.off*2} #{@cX.blue}#{@txt[1]}#{@cX.off}} + end + def blue_title_hi + puts %{#{@cX.blue_hi}#{@txt[0]}#{@cX.off*2} #{@cX.blue}#{@txt[1]}#{@cX.off}} + end + def grey_title_hi + puts %{#{@cX.grey_hi}#{@cX.black}#{@txt[0]}#{@cX.off*2} #{@cX.blue}#{@txt[1]}#{@cX.off}} + end + def grey_title_grey_blue + puts %{#{@cX.grey_hi}#{@cX.black}#{@txt[0]}#{@cX.off*2} #{@cX.grey}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off}} + end + def dark_grey_title_hi + puts %{#{@cX.darkgrey_hi}#{@cX.black}#{@txt[0]}#{@cX.off*2} #{@cX.blue}#{@txt[1]}#{@cX.off}} + end + def cyan_title_hi + puts %{#{@cX.cyan_hi}#{@cX.black}#{@txt[0]}#{@cX.off*2} #{@cX.blue}#{@txt[1]}#{@cX.off}} + end + def cyan_hi_blue + puts %{#{@cX.cyan_hi}#{@cX.black}#{@txt[0]}#{@cX.off*2} #{@cX.blue}#{@txt[1]}#{@cX.off}} + end + def dbi_title + puts %{#{@cX.blue_hi}#{@cX.black}#{@txt[0]}#{@cX.off*2} #{@cX.cyan}#{@cX.grey}#{@txt[1]}#{@cX.off*2} #{@cX.green}#{@txt[2]}#{@cX.off}} + end + def yellow_title_hi + puts %{#{@cX.yellow_hi}#{@cX.black}#{@txt[0]}#{@cX.off*2} #{@cX.blue}#{@txt[1]}#{@cX.off}} + end + def term_sheet_title + puts %{\t#{@cX.green}#{@txt[0]}#{@cX.off} #{@cX.red_hi}#{@cX.black}#{@txt[1]}.#{@cX.off*2} } + end + def generic_number + puts "#{@cX.green}#{@txt[0]}#{@cX.off} #{@cX.grey}#{@txt[1]}#{@cX.off}" + end + def tex_numbers + puts %{ #{@cX.green}#{@txt[0]}#{@cX.off} #{@cX.cyan}tex/pdf files processed#{@cX.off}.} + end + def tex_info_numbers + puts %{ #{@cX.green}#{@txt[0]}#{@cX.off} #{@cX.cyan}texinfo files processed#{@cX.off}.} + end + def lout_numbers + puts %{ #{@cX.green}#{@n_lout}#{@cX.off} #{@cX.cyan}lout/pdf files processed#{@cX.off}.} + end + def parameters + end + def reserved + puts %{ #{@cX.grey_hi}#{@cX.black}reserved#{@cX.off*2}} + end + def meta_verse_title + puts %{#{@cX.green_hi}#{@cX.black}MetaVerse#{@cX.off*2} } + end + def meta_verse_title_v + b=sourcename(@txt[0]) + puts %{#{@cX.green_hi}#{@cX.black}MetaVerse#{@cX.off*2} } + + %{#{@cX.grey}#{@txt[0]}#{@cX.off} #{@cX.ruby}->#{@cX.off}\n\t #{@cX.blue}~meta/#{b}.meta#{@cX.off}} + end + def meta_verse + puts "\t#{@cX.grey}MetaVerse#{@cX.off}" + end + def meta_verse_skipped + puts %{\t#{@cX.grey}MetaVerse: MarshalLoad (creation of metaVerse skipped)#{@cX.off}} + end + def meta_verse_load + puts %{\t<>} + end + def html_title + puts %{#{@cX.green_hi}#{@cX.black}HTML#{@cX.off*2}} + end + def html_output + puts %{\t#{@cX.grey}#{@txt[0]}#{@cX.off} #{@cX.ruby}->#{@cX.off}\n\t #{@cX.blue}#{@txt[1]}#{@cX.off}} + end + def segmented + puts "\t#{@cX.grey}Seg#{@cX.off} #{@cX.green}#{@txt[0]}#{@cX.off} #{@cX.grey}segments#{@cX.off}" + end + end +end +__END__ + Color.new do + self.off = "\033[0m" + self.white = "\033[37m" + self.white_bold = "\033[1m" + self.marker = "\033[42m" + self.bold = "\033[1m" + self.underline = "\033[4m" + self.invert = "\033[7m" + self.darkgrey_hi = "\033[100m" + self.grey_hi = "\033[47m" + self.pink_hi = "\033[105m" + self.fuchsia_hi = "\033[45m" + self.red_hi = "\033[41m" + self.orange_hi = "\033[101m" + self.yellow_hi = "\033[103m" + self.brown_hi = "\033[43m" + self.lightgreen_hi = "\033[102m" + self.green_hi = "\033[42m" + self.cyan_hi = "\033[106m" + self.blue_hi = "\033[104m" + self.navy_hi = "\033[44m" + self.grey = "\033[90m" + self.pink = "\033[95m" + self.fuchsia = "\033[35m" + self.ruby = "\033[31m" + self.red = "\033[91m" #check + self.orange = "\033[91m" + self.yellow = "\033[93m" + self.brown = "\033[33m" + self.green = "\033[92m" + self.darkgreen = "\033[32m" + self.cyan = "\033[36m" + self.blue = "\033[94m" + self.navy = "\033[34m" + self.black = "\033[30m" + end +# fewer colors + Color.new do + self.off = "\033[0m" + self.white = "\033[0m" + self.marker = "\033[42m" + self.bold = "\033[1m" + self.underline = "\033[4m" + self.invert = "\033[7m" + self.darkgrey_hi = "\033[100m" + self.grey_hi = "\033[47m" + self.pink_hi = "\033[105m" + self.fuchsia_hi = "\033[45m" + self.red_hi = "\033[41m" + self.orange_hi = "\033[101m" + self.yellow_hi = "\033[103m" + self.brown_hi = "\033[43m" + self.lightgreen_hi = "\033[102m" + self.green_hi = "\033[42m" + self.cyan_hi = "\033[106m" + self.blue_hi = "\033[104m" + self.navy_hi = "\033[44m" + self.grey = "\033[90m" + self.pink = "\033[95m" + self.fuchsia = "\033[35m" + self.ruby = "\033[31m" + self.red = "\033[31m" #check + self.orange = "\033[91m" + self.yellow = "\033[33m" + self.brown = "\033[33m" + self.green = "\033[32m" + self.darkgreen = "\033[32m" + self.cyan = "\033[36m" + self.blue = "\033[34m" + self.navy = "\033[34m" + self.black = "\033[30m" + end diff --git a/lib/sisu/v5/utils_spell.rb b/lib/sisu/v5/utils_spell.rb new file mode 100644 index 00000000..886f6f7f --- /dev/null +++ b/lib/sisu/v5/utils_spell.rb @@ -0,0 +1,105 @@ +# encoding: utf-8 +=begin + + * Name: SiSU + + * Description: a framework for document structuring, publishing and search + + * Author: Ralph Amissah + + * Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. + + * License: GPL 3 or later: + + SiSU, a framework for document structuring, publishing and search + + Copyright (C) Ralph Amissah + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along with + this program. If not, see . + + 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: + + + * Git + + + + * Ralph Amissah + + + + ** Description: spellchecking + +=end +module SiSU_SpellUtility + class Spell + def initialize(input,filesrc,flg) + @flg=flg + @filename, @filetype = /(.+?)(\.\w\w\w0$)/.match(filesrc)[1,2] #.gsub(/\.\w\w\w0$/, "") + @input=input + @allwords=[] + puts @filename + @speller='aspell' # 'ispell' + @dictionary='british' + @lang='en_GB' + end + def check + @input.each do |data| + data=data.gsub(/(https?|www|ftp|gopher|png|jpg|gif|html|htm)\S+/i,' '). + gsub(/( |#{Mx[:nbsp]})/i,' '). + gsub(/<\/?(table|tr|td|b|p|href).*?>/i,' '). + gsub(/(<==.+|<:\S+>||^@\S+?:.+|\{\{\{|~)/,' '). + gsub(/(["|<>)(\n'`.;&_-]|\=)/,' '). + gsub(/\b(altExternal| + target|externalimg| + srcimagebext| + img|src|toc|pdf| + cd|org| + helvetica|roman + )\b/i,' '). + gsub(/EOF/,'') + @words=data.scan(/\S+/) + @words.each { |y| @allwords << y } + end + @allwords=@allwords.uniq + if @flg =~ /S/ + File.open('/home/ralph/spell_error','a+') do |file| #fix + file.puts %{\n\n<<#{@filename}>>} + end + @allwords.each { |y| puts y.inspect; system(%{cat #{y} | /usr/bin/#{@speller} -l -d #{@dictionary} >> ~/spell_error })} + else + @allwords.each { |y| sp=%x{echo #{y}|#{@speller} -l }; puts sp unless sp.empty?} + end + end + end +end +__END__ diff --git a/lib/sisu/v5/webrick.rb b/lib/sisu/v5/webrick.rb index e43d8cd1..f6ff970b 100644 --- a/lib/sisu/v5/webrick.rb +++ b/lib/sisu/v5/webrick.rb @@ -70,7 +70,7 @@ module SiSU_Webserv rescue LoadError SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('time or webrick NOT FOUND (LoadError)') end - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env include SiSU_Screen def initialize @@ -159,7 +159,7 @@ WOK get=Dir.pwd brick(@port,get) rescue - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb SiSU_Errors::Rescued.new($!,$@,'-W',nil).location do #fix __LINE__.to_s + ':' + __FILE__ end diff --git a/lib/sisu/v5/wikispeak.rb b/lib/sisu/v5/wikispeak.rb index e54b8edd..a0fba849 100644 --- a/lib/sisu/v5/wikispeak.rb +++ b/lib/sisu/v5/wikispeak.rb @@ -62,7 +62,7 @@ =end module SiSU_Wikispeak require_relative 'ao' # ao.rb - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env include SiSU_Param include SiSU_Viz diff --git a/lib/sisu/v5/xhtml.rb b/lib/sisu/v5/xhtml.rb index e1efeeaf..4253e8eb 100644 --- a/lib/sisu/v5/xhtml.rb +++ b/lib/sisu/v5/xhtml.rb @@ -63,9 +63,9 @@ module SiSU_XHTML require_relative 'defaults' # defaults.rb include SiSU_Viz - require_relative 'particulars' # particulars.rb + require_relative 'se_hub_particulars' # se_hub_particulars.rb include SiSU_Particulars - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env require_relative 'xml_shared' # xml_shared.rb include SiSU_XML_Munge diff --git a/lib/sisu/v5/xhtml_epub2.rb b/lib/sisu/v5/xhtml_epub2.rb index d0b4a7dc..9b110497 100644 --- a/lib/sisu/v5/xhtml_epub2.rb +++ b/lib/sisu/v5/xhtml_epub2.rb @@ -66,7 +66,7 @@ module SiSU_XHTML_EPUB2 rescue LoadError SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('pstore NOT FOUND (LoadError)') end - require_relative 'particulars' # particulars.rb + require_relative 'se_hub_particulars' # se_hub_particulars.rb include SiSU_Particulars require_relative 'defaults' # defaults.rb include SiSU_Viz diff --git a/lib/sisu/v5/xhtml_epub2_concordance.rb b/lib/sisu/v5/xhtml_epub2_concordance.rb index cb498d0f..447dd72e 100644 --- a/lib/sisu/v5/xhtml_epub2_concordance.rb +++ b/lib/sisu/v5/xhtml_epub2_concordance.rb @@ -62,9 +62,9 @@ =end module SiSU_XHTML_EPUB2_Concordance - require_relative 'particulars' # particulars.rb + require_relative 'se_hub_particulars' # se_hub_particulars.rb include SiSU_Particulars - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env require_relative 'defaults' # defaults.rb include SiSU_Viz @@ -157,7 +157,7 @@ WOK include SiSU_Viz require_relative 'xhtml_epub2_format' # xhtml_epub2_format.rb include SiSU_XHTML_EPUB2_Format - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Screen def initialize(particulars) @particulars=particulars diff --git a/lib/sisu/v5/xhtml_epub2_tune.rb b/lib/sisu/v5/xhtml_epub2_tune.rb index db234a19..aa748cf6 100644 --- a/lib/sisu/v5/xhtml_epub2_tune.rb +++ b/lib/sisu/v5/xhtml_epub2_tune.rb @@ -60,9 +60,9 @@ ** Description: epub generation, epub pre-processing =end -require_relative 'param' +require_relative 'dp' # dp.rb module SiSU_XHTML_EPUB2_Tune - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env; include SiSU_Screen require_relative 'xhtml_epub2_format' # xhtml_epub2_format.rb #watch @@line_mode='' diff --git a/lib/sisu/v5/xml_docbook5.rb b/lib/sisu/v5/xml_docbook5.rb index 0870c06e..8132a356 100644 --- a/lib/sisu/v5/xml_docbook5.rb +++ b/lib/sisu/v5/xml_docbook5.rb @@ -61,10 +61,10 @@ =end module SiSU_XML_Docbook_Book - require_relative 'particulars' # particulars.rb + require_relative 'se_hub_particulars' # se_hub_particulars.rb include SiSU_Particulars require_relative 'ao' # ao.rb - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env require_relative 'txt_shared' # txt_shared.rb include SiSU_TextUtils diff --git a/lib/sisu/v5/xml_dom.rb b/lib/sisu/v5/xml_dom.rb index b51a317a..a602eee3 100644 --- a/lib/sisu/v5/xml_dom.rb +++ b/lib/sisu/v5/xml_dom.rb @@ -63,9 +63,9 @@ module SiSU_XML_DOM require_relative 'defaults' # defaults.rb include SiSU_Viz - require_relative 'particulars' # particulars.rb + require_relative 'se_hub_particulars' # se_hub_particulars.rb include SiSU_Particulars - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env require_relative 'ao' # ao.rb require_relative 'xml_shared' # xml_shared.rb diff --git a/lib/sisu/v5/xml_fictionbook2.rb b/lib/sisu/v5/xml_fictionbook2.rb index 997f0b0a..74afc6ad 100644 --- a/lib/sisu/v5/xml_fictionbook2.rb +++ b/lib/sisu/v5/xml_fictionbook2.rb @@ -61,10 +61,10 @@ =end module SiSU_XML_Fictionbook - require_relative 'particulars' # particulars.rb + require_relative 'se_hub_particulars' # se_hub_particulars.rb include SiSU_Particulars require_relative 'ao' # ao.rb - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env require_relative 'txt_shared' # txt_shared.rb include SiSU_TextUtils diff --git a/lib/sisu/v5/xml_format.rb b/lib/sisu/v5/xml_format.rb index 7694f56b..871ec487 100644 --- a/lib/sisu/v5/xml_format.rb +++ b/lib/sisu/v5/xml_format.rb @@ -62,7 +62,7 @@ =end module SiSU_XML_Format - require_relative 'param' # param.rb + require_relative 'dp' # dp.rb include SiSU_Param include SiSU_Viz class ParagraphNumber diff --git a/lib/sisu/v5/xml_md_oai_pmh_dc.rb b/lib/sisu/v5/xml_md_oai_pmh_dc.rb index 7ec83ff2..9279ba11 100644 --- a/lib/sisu/v5/xml_md_oai_pmh_dc.rb +++ b/lib/sisu/v5/xml_md_oai_pmh_dc.rb @@ -61,9 +61,9 @@ =end module SiSU_XML_Metadata - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env - require_relative 'param' # param.rb + require_relative 'dp' # dp.rb include SiSU_Param class OAI_PMH def initialize(opt) diff --git a/lib/sisu/v5/xml_odf_odt.rb b/lib/sisu/v5/xml_odf_odt.rb index df71ce81..55c8d7ed 100644 --- a/lib/sisu/v5/xml_odf_odt.rb +++ b/lib/sisu/v5/xml_odf_odt.rb @@ -61,10 +61,10 @@ =end module SiSU_XML_ODF_ODT - require_relative 'particulars' # particulars.rb + require_relative 'se_hub_particulars' # se_hub_particulars.rb include SiSU_Particulars require_relative 'ao' # ao.rb - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env include SiSU_Viz require_relative 'xml_odf_odt_format' # xml_odf_odt_format.rb diff --git a/lib/sisu/v5/xml_odf_odt_format.rb b/lib/sisu/v5/xml_odf_odt_format.rb index b56e4284..bfbd075c 100644 --- a/lib/sisu/v5/xml_odf_odt_format.rb +++ b/lib/sisu/v5/xml_odf_odt_format.rb @@ -61,7 +61,7 @@ =end module SiSU_XML_ODF_ODT_Format - require_relative 'param' # param.rb + require_relative 'dp' # dp.rb include SiSU_Param include SiSU_Viz class ParagraphNumber diff --git a/lib/sisu/v5/xml_sax.rb b/lib/sisu/v5/xml_sax.rb index ac2b6d47..58719798 100644 --- a/lib/sisu/v5/xml_sax.rb +++ b/lib/sisu/v5/xml_sax.rb @@ -63,9 +63,9 @@ module SiSU_XML_SAX require_relative 'defaults' # defaults.rb include SiSU_Viz - require_relative 'particulars' # particulars.rb + require_relative 'se_hub_particulars' # se_hub_particulars.rb include SiSU_Particulars - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env require_relative 'xml_shared' # xml_shared.rb include SiSU_XML_Munge diff --git a/lib/sisu/v5/xml_scaffold_structure_collapsed.rb b/lib/sisu/v5/xml_scaffold_structure_collapsed.rb index 0395d090..f36c937f 100644 --- a/lib/sisu/v5/xml_scaffold_structure_collapsed.rb +++ b/lib/sisu/v5/xml_scaffold_structure_collapsed.rb @@ -61,10 +61,10 @@ =end module SiSU_XML_Scaffold_Structure_Collapse - require_relative 'particulars' # particulars.rb + require_relative 'se_hub_particulars' # se_hub_particulars.rb include SiSU_Particulars require_relative 'ao' # ao.rb - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env class Source def initialize(opt) diff --git a/lib/sisu/v5/xml_scaffold_structure_sisu.rb b/lib/sisu/v5/xml_scaffold_structure_sisu.rb index 39ca1e6a..44344328 100644 --- a/lib/sisu/v5/xml_scaffold_structure_sisu.rb +++ b/lib/sisu/v5/xml_scaffold_structure_sisu.rb @@ -61,10 +61,10 @@ =end module SiSU_XML_Scaffold_Structure_Sisu - require_relative 'particulars' # particulars.rb + require_relative 'se_hub_particulars' # se_hub_particulars.rb include SiSU_Particulars require_relative 'ao' # ao.rb - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env class Source def initialize(opt) diff --git a/lib/sisu/v5/xml_shared.rb b/lib/sisu/v5/xml_shared.rb index 77df1a30..bd0e383b 100644 --- a/lib/sisu/v5/xml_shared.rb +++ b/lib/sisu/v5/xml_shared.rb @@ -567,7 +567,7 @@ module SiSU_XML_Munge end end module SiSU_XML_Tags #Format - require_relative 'param' # param.rb + require_relative 'dp' # dp.rb include SiSU_Param include SiSU_Viz class RDF diff --git a/lib/sisu/v5/zap.rb b/lib/sisu/v5/zap.rb index 94a9e196..75707247 100644 --- a/lib/sisu/v5/zap.rb +++ b/lib/sisu/v5/zap.rb @@ -61,7 +61,7 @@ =end module SiSU_Zap - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env class Source def initialize(opt) diff --git a/lib/sisu/v6/air.rb b/lib/sisu/v6/air.rb index 2af4038e..11c9445d 100644 --- a/lib/sisu/v6/air.rb +++ b/lib/sisu/v6/air.rb @@ -61,7 +61,7 @@ =end module SiSU_Air - require_relative 'particulars' # particulars.rb + require_relative 'se_hub_particulars' # se_hub_particulars.rb class Source @@ao_array=[] @@fns=nil diff --git a/lib/sisu/v6/ao.rb b/lib/sisu/v6/ao.rb index 370bb7e1..9b305b37 100644 --- a/lib/sisu/v6/ao.rb +++ b/lib/sisu/v6/ao.rb @@ -64,9 +64,9 @@ module SiSU_AO require_relative 'defaults' # defaults.rb include SiSU_Viz - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env - require_relative 'param' # param.rb + require_relative 'dp' # dp.rb include SiSU_Param require_relative 'ao_doc_objects' # ao.rb require_relative 'ao_syntax' # ao_syntax.rb diff --git a/lib/sisu/v6/ao_composite.rb b/lib/sisu/v6/ao_composite.rb index eaa4e08f..bb188f4d 100644 --- a/lib/sisu/v6/ao_composite.rb +++ b/lib/sisu/v6/ao_composite.rb @@ -62,7 +62,7 @@ =end module SiSU_Assemble - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb class RemoteImage def initialize @env=SiSU_Env::InfoEnv.new diff --git a/lib/sisu/v6/author_format.rb b/lib/sisu/v6/author_format.rb deleted file mode 100644 index 7b791bd7..00000000 --- a/lib/sisu/v6/author_format.rb +++ /dev/null @@ -1,117 +0,0 @@ -# encoding: utf-8 -=begin - - * Name: SiSU - - * Description: a framework for document structuring, publishing and search - - * Author: Ralph Amissah - - * Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, - All Rights Reserved. - - * License: GPL 3 or later: - - SiSU, a framework for document structuring, publishing and search - - Copyright (C) Ralph Amissah - - This program is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the Free - Software Foundation, either version 3 of the License, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - more details. - - You should have received a copy of the GNU General Public License along with - this program. If not, see . - - 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: - - - * Git - - - - * Ralph Amissah - - - - ** Description: system environment, resource control and configuration details - -=end -module SiSU_FormatAuthor - 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=a.strip - if a =~/"(.+?)"/ - @authors << { the: $1 } - @author_array << $1.upcase - else #if a =~/,/ - x=a.scan(/[^,]+/) - x[0]=x[0].strip - x[1]=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/v6/cgi.rb b/lib/sisu/v6/cgi.rb index a4065344..d7911808 100644 --- a/lib/sisu/v6/cgi.rb +++ b/lib/sisu/v6/cgi.rb @@ -61,8 +61,8 @@ (pgsql sqlite) =end -module SiSU_CGI #% database building documents - require_relative 'sysenv' # sysenv.rb +module SiSU_CGI #% database building documents + require_relative 'se' # se.rb require_relative 'cgi_pgsql' # cgi_pgsql.rb require_relative 'cgi_sqlite' # cgi_sqlite.rb class SearchSQL diff --git a/lib/sisu/v6/cgi_pgsql.rb b/lib/sisu/v6/cgi_pgsql.rb index 38b5c09f..09ded270 100644 --- a/lib/sisu/v6/cgi_pgsql.rb +++ b/lib/sisu/v6/cgi_pgsql.rb @@ -60,8 +60,8 @@ ** Description: generates naive cgi search form for search of sisu database (pgsql) =end -module SiSU_CGI_PgSQL #% database building documents - require_relative 'sysenv' # sysenv.rb +module SiSU_CGI_PgSQL #% database building documents + require_relative 'se' # se.rb require_relative 'cgi_sql_common' # cgi_sql_common.rb include SiSU_CGI_SQL class SearchPgSQL < CGI_Common diff --git a/lib/sisu/v6/cgi_sqlite.rb b/lib/sisu/v6/cgi_sqlite.rb index 8cf01d3e..722d9033 100644 --- a/lib/sisu/v6/cgi_sqlite.rb +++ b/lib/sisu/v6/cgi_sqlite.rb @@ -60,8 +60,8 @@ ** Description: generates naive cgi search form for search of sisu database (sqlite) =end -module SiSU_CGI_SQLite #% database building documents - require_relative 'sysenv' # sysenv.rb +module SiSU_CGI_SQLite #% database building documents + require_relative 'se' # se.rb require_relative 'cgi_sql_common' # cgi_sql_common.rb include SiSU_CGI_SQL class SearchSQLite < CGI_Common diff --git a/lib/sisu/v6/conf.rb b/lib/sisu/v6/conf.rb index b3a5375e..2f29902f 100644 --- a/lib/sisu/v6/conf.rb +++ b/lib/sisu/v6/conf.rb @@ -61,7 +61,7 @@ =end module SiSU_Initialize - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env include SiSU_Screen require_relative 'relaxng' # relaxng.rb @@ -82,7 +82,7 @@ module SiSU_Initialize end end class ConfigSite #config files such as css are not updated if they already exist unless forced using the --init=site modifier - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb def initialize(opt) @opt=opt @env=SiSU_Env::InfoEnv.new(@opt.fns) diff --git a/lib/sisu/v6/css.rb b/lib/sisu/v6/css.rb index b59458ee..a2c75d3c 100644 --- a/lib/sisu/v6/css.rb +++ b/lib/sisu/v6/css.rb @@ -61,7 +61,7 @@ =end module SiSU_Style - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb require_relative 'defaults' # defaults.rb class CSS_HeadInfo def initialize(md,ft='html') diff --git a/lib/sisu/v6/db_columns.rb b/lib/sisu/v6/db_columns.rb index f7db347e..d9eda1d7 100644 --- a/lib/sisu/v6/db_columns.rb +++ b/lib/sisu/v6/db_columns.rb @@ -62,7 +62,7 @@ =end module SiSU_DbColumns - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb require_relative 'db_sqltxt' # db_sqltxt.rb class Columns < SiSU_DbText::Prepare def initialize(md=nil) diff --git a/lib/sisu/v6/db_create.rb b/lib/sisu/v6/db_create.rb index e9e6aa40..4d551ee2 100644 --- a/lib/sisu/v6/db_create.rb +++ b/lib/sisu/v6/db_create.rb @@ -64,7 +64,7 @@ module SiSU_DbCreate require_relative 'db_columns' # db_columns.rb class Create < SiSU_DbColumns::Columns - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb @@dl=nil def initialize(opt,conn,file,sql_type=:pg) @opt,@conn,@file,@sql_type=opt,conn,file,sql_type diff --git a/lib/sisu/v6/db_drop.rb b/lib/sisu/v6/db_drop.rb index e93d2889..3363746a 100644 --- a/lib/sisu/v6/db_drop.rb +++ b/lib/sisu/v6/db_drop.rb @@ -63,7 +63,7 @@ =end module SiSU_DbDrop class Drop - require_relative 'response' # response.rb + require_relative 'utils_response' # utils_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 diff --git a/lib/sisu/v6/db_load_tuple.rb b/lib/sisu/v6/db_load_tuple.rb index c4740259..46d29896 100644 --- a/lib/sisu/v6/db_load_tuple.rb +++ b/lib/sisu/v6/db_load_tuple.rb @@ -64,7 +64,7 @@ module SiSU_DbTuple require_relative 'db_columns' # db_columns.rb class LoadDocuments - require_relative 'param' # param.rb + require_relative 'dp' # dp.rb include SiSU_Param def initialize(conn,col,opt,file_maint) @conn,@col,@opt,@file_maint=conn,col,opt,file_maint diff --git a/lib/sisu/v6/dbi.rb b/lib/sisu/v6/dbi.rb index 5880aa1a..be684ab5 100644 --- a/lib/sisu/v6/dbi.rb +++ b/lib/sisu/v6/dbi.rb @@ -61,9 +61,9 @@ =end module SiSU_DBI #% database building - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env; include SiSU_Screen - require_relative 'param' # param.rb + require_relative 'dp' # dp.rb include SiSU_Param require_relative 'db_dbi' # db_dbi.rb include SiSU_DbDBI diff --git a/lib/sisu/v6/dbi_discrete.rb b/lib/sisu/v6/dbi_discrete.rb index fc5c310f..ee0737fe 100644 --- a/lib/sisu/v6/dbi_discrete.rb +++ b/lib/sisu/v6/dbi_discrete.rb @@ -61,9 +61,9 @@ =end module SiSU_DBI_Discrete #% database building - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env; include SiSU_Screen - require_relative 'param' # param.rb + require_relative 'dp' # dp.rb include SiSU_Param require_relative 'db_dbi' # db_dbi.rb include SiSU_DbDBI diff --git a/lib/sisu/v6/defaults.rb b/lib/sisu/v6/defaults.rb index a26edae9..c725b11d 100644 --- a/lib/sisu/v6/defaults.rb +++ b/lib/sisu/v6/defaults.rb @@ -67,7 +67,7 @@ module SiSU_Viz rescue LoadError SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('uri NOT FOUND (LoadError)') end - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env require_relative 'css' # css.rb include SiSU_Style diff --git a/lib/sisu/v6/digests.rb b/lib/sisu/v6/digests.rb index c7a6d3c1..5450f7b3 100644 --- a/lib/sisu/v6/digests.rb +++ b/lib/sisu/v6/digests.rb @@ -61,7 +61,7 @@ =end module SiSU_DigestView - require_relative 'particulars' # particulars.rb + require_relative 'se_hub_particulars' # se_hub_particulars.rb require_relative 'prog_text_translation' # prog_text_translation.rb require_relative 'shared_markup_alt.rb' # shared_markup_alt.rb class Source diff --git a/lib/sisu/v6/dp.rb b/lib/sisu/v6/dp.rb new file mode 100644 index 00000000..499e582f --- /dev/null +++ b/lib/sisu/v6/dp.rb @@ -0,0 +1,1550 @@ +# encoding: utf-8 +=begin + + * Name: SiSU + + * Description: a framework for document structuring, publishing and search + + * Author: Ralph Amissah + + * Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. + + * License: GPL 3 or later: + + SiSU, a framework for document structuring, publishing and search + + Copyright (C) Ralph Amissah + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along with + this program. If not, see . + + 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: + + + * Git + + + + * Ralph Amissah + + + + ** Description: document parameters extracted from input files for program use + +=end +module SiSU_Param + begin + require 'uri' + require 'pstore' + rescue LoadError + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). + error('uri or pstore NOT FOUND (LoadError)') + end + require_relative 'se' # se.rb + include SiSU_Env + require_relative 'dp_make' # dp_make.rb + require_relative 'dp_identify_markup' # dp_identify_markup.rb + @@date=SiSU_Env::InfoDate.new + @@proc= + @@filename_txt= + @@filename_texinfo= + @@filename_lout_portrait= + @@filename_lout_landscape= + @@filename_html_scroll= + @@filename_html_index= + @@filename_html_segtoc= + @@filename_semantic= + @@filename_rss= + @@newfile= + @@drr= + nil + @doc={ + initialise: nil, + markup: '', + lnks: '', + stmp: '', + req: {}, + } + @@yaml=@@yamladdr=nil + @@trigger=nil + @@lv,@@flag={},{} + @@tex_backslash="\\\\" + class Parameters + @@publisher='SiSU scribe' + @@md=@@fns=@@pth=nil + def initialize(opt) + @opt=opt + @cX||=SiSU_Screen::Ansi.new(@opt.act[:color_state][:set]) + @cmd,@mod=opt.cmd,opt.mod + @fns=if @opt.cmd =~/P/ #revisit CHECK + opt.fns + else opt.fns.gsub(/\.ssm$/,'.ssm.sst') + end + SiSU_Param::Instantiate.new.param_instantiate + @env=SiSU_Env::InfoEnv.new(@fns) + @pstorefile="#{@env.processing_path.ao}/#{@fns}.pstore" + end + def get + if @opt.f_pth \ + and @opt.f_pth[:pth] != Dir.pwd #BUG check + # you may need to change Dir.pwd to @opt.f_pth[:pth] where the latter + # has a path value that is different, however, f_pth is not always set! + Dir.chdir(@opt.f_pth[:pth]) + end + if @@fns !=@fns \ + or @@pth !=Dir.pwd #@opt.f_pth[:pth] + @@fns,@@pth=@fns,Dir.pwd #@opt.f_pth[:pth] + @@md=nil + end + if @@md.nil? \ + or @opt.act[:maintenance][:set]==:on #not particularly helpful, as current cycle is through output types, with files changing, only helpful if deal with a file all output types before going to next file + if File.exist?(@pstorefile) + param_msg='Parameters from pstore' + store=PStore.new(@pstorefile) + store.transaction do + @md=store['md'] + end + @md + else + param_msg='Parameters extracted' + fns_array=@env.read_source_file(@opt.fns) + @md=SiSU_Param::Parameters::Instructions.new(fns_array,@opt).extract + @md + end + if defined? @md.title.main # on removal check problems with -U + if (@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) + SiSU_Screen::Ansi.new( + @opt.act[:color_state][:set], + param_msg, + @md.title.main + ).txt_grey + end + end + @@md=@md + else @@md + end + @@md.opt=@opt + @@md + end + class MdDefault + def rights(author,date) + @author,@date=author,date + def all + s=nil + if @author + s ||=((@date =~/((?:1[4-9]|2[01])\d{2})/ ) \ + ? ("Copyright (C) #{$1} #{@author}") + : ('Copyright (C)' + @author)) #matches years 1400 through 21\d\d + end + s + end + def text + all + end + def copyright + def all + s=nil + if @author + s ||=((@date =~/((?:1[4-9]|2[01])\d{2})/ ) \ + ? ("Copyright (C) #{$1} #{@author}") + : ('Copyright (C)' + @author)) #matches years 1400 through 21\d\d + end + s + end + def text + all + end + self + end + self + end + end + class MdMake < SiSU_Param_Make::MdMake + end + class Md + def initialize(str,opt,env) + @s,@opt,@env=str,opt,env + end + def validate_length(s,l,n) + #s=(s.length <= l) ? s : nil + s=if s.is_a?(String) \ + and s.length <= l + s + elsif s.is_a?(NilClass) + nil + elsif s.class !=String + STDERR.puts "#{n} is #{s.class}: programming error, String expected #{__FILE__}:#{__LINE__}" + s + else + SiSU_Screen::Ansi.new( + 'v', + "*WARN* #{n} length #{s.length} exceeds set db field length #{l}, metadata dropped", + @opt.fns + ).warn unless @opt.act[:quiet][:set]==:on + nil + end + end + def name_format(name) + if name + name=name.strip + @name_a_h=[] + authors=name.scan(/[^;]+/) + authors.each_with_index do |a,i| + b=((a =~/\s*\|\s*/) ? (a.split(/\|/)) : [a]) + if b[0] =~/"(.+?)"/ + @name_a_h << { the: $1 } + else + x=b[0].scan(/[^,]+/) + if x.length==1 + @name_a_h << { the: x[0].strip } + elsif x.length==2 + @name_a_h << { the: x[0].strip, others: x[1].strip } + else #p x.length + end + end + b.delete_at(0) + b.each do |d| + k,c=nil + k,c=/^(\S+)\s+(.*)/.match(d)[1,2] if d + @name_a_h[i][:hon]=c.strip if k=='hon' + @name_a_h[i][:affiliation]=c.strip if k=='affiliation' + @name_a_h[i][:nationality]=c.strip if k=='nationality' + end + end + l=@name_a_h.length + name_str='' + @name_a_h.each_with_index do |a,i| + name_str += if a[:others] + z=(((l - i) > 1) ? ', ' : '') + "#{a[:others].strip} #{a[:the].strip}" + z + else + z=(((l - i) > 2) ? ', ' : '') + "#{a[:the].strip}" + z + end + end + { name_a_h: @name_a_h, name_str: name_str } + else nil + end + end + def build_hash(arr) + @h={} + arr.each_with_index do |x,i| + a,b=nil,nil + if x =~/^%\s/ #ignore comment + elsif x =~/:(\S+?):\s+(.+)/ + a,b=/:(\S+?):\s+(.+)\Z/m.match(x)[1,2] + b=b.gsub(/\s*\s*/,' \\\\\\ ') + b=if b =~/\n/m + (b =~/;\n/m) \ + ? (b.split(/;\s*\n\s*/).join(';')) + : (b.split(/\s*\n\s*/).join(' ')) + else + b + end + elsif i == 0 + a='main' + b=x + else + end + @h[a]=b + end + @h + end + def title + a=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m) + @h=build_hash(a) + def main + s=@h['main'] + l,n=Db[:col_title_part],'title.main' + validate_length(s,l,n) + end + def sub + s=@h['subtitle'] + l,n=Db[:col_title_part],'title.subtitle' + validate_length(s,l,n) + end + def edition + s=@h['edition'] + l,n=Db[:col_title_edition],'title.edition' + validate_length(s,l,n) + end + def note + s=@h['note'] + l,n=Db[:col_info_note],'title.note' + validate_length(s,l,n) + end + def short + s=@h['short'] \ + ? @h['short'] + : @h['main'] + l,n=Db[:col_title_part],'title.short' + validate_length(s,l,n) + end + def full + s=@h['subtitle'] \ + ? (@h['main'] + ' - ' + @h['subtitle']) + : @h['main'] + l,n=Db[:col_title],'title.full' + validate_length(s,l,n) + end + def language + s=@h['language'] + l,n=Db[:col_language],'title.language' + validate_length(s,l,n) + end + def language_char # look into, this must be set, from 1 directory stub (.fi), 2 filename (~fi), [3 (not used) document header (@title:\n :language_char: fi)] + s=@h['language_char'] + l,n=Db[:col_language_char],'title.language_char' + validate_length(s,l,n) + end + self + end + def creator #there are sub categories that need to be catered for and sometimes more than one author etc.; implement array.to_s.length validation test later, current test on string approximate as string is not used + a=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m) + @h=build_hash(a) + def author + @h['author']=(@h['author'] \ + ? @h['author'] + : @h['main']) + names=name_format(@h['author']) + s=names[:name_str] + l,n=Db[:col_name],'creator.author' + validate_length(s,l,n) + end + def author_detail + s=@h['author'] \ + ? @h['author'] + : @h['main'] + names=name_format(s) + names[:name_a_h] + end + def editor + names=@h['editor'] \ + ? name_format(@h['editor']) + : nil + s=(names.is_a?(Hash)) \ + ? names[:name_str] + : nil + s=if s + l,n=Db[:col_name],'creator.editor' + validate_length(s,l,n) + else nil + end + end + def editor_detail + names=@h['editor'] \ + ? name_format(@h['editor']) + : nil + (names.is_a?(Hash)) \ + ? names[:name_a_h] + : nil + end + def contributor + names=@h['contributor'] \ + ? name_format(@h['contributor']) + : nil + s=(names.is_a?(Hash)) \ + ? names[:name_str] + : nil + s=if s + l,n=Db[:col_name],'creator.author' + validate_length(s,l,n) + else nil + end + end + def contributor_detail + names=@h['contributor'] \ + ? name_format(@h['contributor']) + : nil + (names.is_a?(Hash)) \ + ? names[:name_a_h] + : nil + end + def illustrator + names=@h['illustrator'] \ + ? name_format(@h['illustrator']) + : nil + s=(names.is_a?(Hash)) \ + ? names[:name_str] + : nil + s=if s + l,n=Db[:col_name],'creator.illustrator' + validate_length(s,l,n) + else nil + end + end + def illustrator_detail + names=@h['illustrator'] \ + ? name_format(@h['illustrator']) + : nil + (names.is_a?(Hash)) \ + ? names[:name_a_h] + : nil + end + def photographer + names=@h['photographer'] \ + ? name_format(@h['photographer']) + : nil + s=(names.is_a?(Hash)) \ + ? names[:name_str] + : nil + s=if s + l,n=Db[:col_name],'creator.photographer' + validate_length(s,l,n) + else nil + end + end + def photographer_detail + names=@h['photographer'] \ + ? name_format(@h['photographer']) + : nil + (names.is_a?(Hash)) \ + ? names[:name_a_h] + : nil + end + def translator + names=@h['translator'] \ + ? name_format(@h['translator']) + : nil + s=(names.is_a?(Hash)) \ + ? names[:name_str] + : nil + s=if s + l,n=Db[:col_name],'creator.translator' + validate_length(s,l,n) + else nil + end + end + def translator_detail + names=@h['translator'] \ + ? name_format(@h['translator']) + : nil + (names.is_a?(Hash)) \ + ? names[:name_a_h] + : nil + end + def audio + names=@h['audio'] \ + ? name_format(@h['audio']) + : nil + s=(names.is_a?(Hash)) \ + ? names[:name_str] + : nil + s=if s + l,n=Db[:col_name],'creator.audio' + validate_length(s,l,n) + else nil + end + end + def audio_detail + names=@h['audio'] \ + ? name_format(@h['audio']) + : nil + (names.is_a?(Hash)) \ + ? names[:name_a_h] + : nil + end + def digitized_by + names=@h['digitized_by'] \ + ? name_format(@h['digitized_by']) + : nil + s=(names.is_a?(Hash)) \ + ? names[:name_str] + : nil + s=if s + l,n=Db[:col_name],'creator.digitized_by' + validate_length(s,l,n) + else nil + end + end + def digitized_by_detail + names=@h['digitized_by'] \ + ? name_format(@h['digitized_by']) + : nil + (names.is_a?(Hash)) \ + ? names[:name_a_h] + : nil + end + def prepared_by + names=@h['prepared_by'] \ + ? name_format(@h['prepared_by']) + : nil + s=(names.is_a?(Hash)) \ + ? names[:name_str] + : nil + s=if s + l,n=Db[:col_name],'creator.prepared_by' + validate_length(s,l,n) + else nil + end + end + def prepared_by_detail + names=@h['prepared_by'] \ + ? name_format(@h['prepared_by']) + : nil + names=name_format(@h['prepared_by']) + (names.is_a?(Hash)) \ + ? names[:name_a_h] + : nil + end + self + end + def rights + a=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m) + @h=build_hash(a) + def copyright + def text #you may wish to expand to take from all + s=if @h['copyright'] then @h['copyright'] + elsif @h['text'] then @h['text'] + elsif @h['main'] then @h['main'] + else + SiSU_Screen::Ansi.new( + @opt.act[:color_state][:set], + 'WARNING Document Copyright missing; provide @rights: :copyright:' + ).warn unless @opt.act[:quiet][:set]==:on + '' + end + l,n=Db[:col_info_note],'rights.copyright.text' + validate_length(s,l,n) + end + def translation + s=@h['translation'] \ + ? @h['translation'] + : nil + l,n=Db[:col_info_note],'rights.copyright.translation' + validate_length(s,l,n) + end + def illustrations + s=@h['illustrations'] \ + ? @h['illustrations'] + : nil + l,n=Db[:col_info_note],'rights.copyright.illustrations' + validate_length(s,l,n) + end + def photographs + s=@h['photographs'] \ + ? @h['photographs'] + : nil + l,n=Db[:col_info_note],'rights.copyright.photographs' + validate_length(s,l,n) + end + def digitization + s=@h['digitization'] \ + ? @h['digitization'] + : nil + l,n=Db[:col_info_note],'rights.copyright.digitization' + validate_length(s,l,n) + end + def audio + s=@h['audio'] \ + ? @h['audio'] + : nil + l,n=Db[:col_info_note],'rights.copyright.audio' + validate_length(s,l,n) + end + self + end + def license + s=@h['license'] \ + ? @h['license'] + : nil + l,n=Db[:col_info_note],'rights.license' + validate_length(s,l,n) + end + def sep(str) + ' \\\\ ' + end + def all + s=if @h['all'] then @h['all'] + else + s='' + if defined? copyright.text \ + and copyright.text \ + and not copyright.text.empty? + v=sep(copyright.text) + s +='Copyright: ' + copyright.text + v + end + if defined? copyright.translation \ + and copyright.translation \ + and not copyright.translation.empty? + v=sep(copyright.translation) + s +='translation: ' + copyright.translation + v + end + if defined? copyright.illustrations \ + and copyright.illustrations \ + and not copyright.illustrations.empty? + v=sep(copyright.illustrations) + s +='illustrations: ' + copyright.illustrations + v + end + if defined? copyright.photographs \ + and copyright.photographs \ + and not copyright.photographs.empty? + v=sep(copyright.photographs) + s +='photographs: ' + copyright.photographs + v + end + if defined? copyright.digitization \ + and copyright.digitization \ + and not copyright.digitization.empty? + v=sep(copyright.digitization) + s +='digitization: ' + copyright.digitization + v + end + if defined? copyright.audio \ + and copyright.audio \ + and not copyright.audio.empty? + v=sep(copyright.audio) + s +='audio: ' + copyright.audio + v + end + if defined? copyright.license \ + and copyright.license \ + and not copyright.license.empty? + s +='License: ' + copyright.license + end + if s.empty? + SiSU_Screen::Ansi.new( + @opt.act[:color_state][:set], + 'WARNING Document Rights information missing; provide @rights: :copyright:' + ).warn unless @opt.act[:quiet][:set]==:on + else + l,n=Db[:col_info_note],'rights.all' + validate_length(s,l,n) + end + s=s.gsub(/ [\\]+\s+$/,'') + end + s + end + self + end + def identifier + a=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m) + @h=build_hash(a) + def oclc + s=@h['oclc'] + l,n=Db[:col_library],'identifier.oclc' + validate_length(s,l,n) + end + def isbn + s=@h['isbn'] + l,n=Db[:col_small],'identifier.isbn' + validate_length(s,l,n) + end + def pg + s=@h['pg'] + l,n=Db[:col_small],'identifier.pg' + validate_length(s,l,n) + end + self + end + def classify + a=@s.split(/(\n%\s.+?$|[ ]*)(?:\n[ ]*(?=:)|\Z)/m) + @h=build_hash(a) + def topic_register + s=@h['topic_register'] + l,n=Db[:col_info_note],'classify.topic_register' + validate_length(s,l,n) + end + def subject + s=@h['subject'] + l,n=Db[:col_txt_long],'classify.subject' + validate_length(s,l,n) + end + def keywords + s=@h['keywords'] + l,n=Db[:col_txt_long],'classify.keywords' + validate_length(s,l,n) + end + def loc + s=@h['loc'] + l,n=Db[:col_library],'classify.loc' + validate_length(s,l,n) + end + def dewey + s=@h['dewey'] + l,n=Db[:col_library],'classify.dewey' + validate_length(s,l,n) + end + self + end + def publisher + a=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m) + @h=build_hash(a) + s=@h['main'] + l,n=Db[:col_name],'publisher' + validate_length(s,l,n) + end + def date + a=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m) + @h=build_hash(a) + def added_to_site + s=@h['added_to_site'] + l,n=Db[:col_date_text],'date.added_to_site' + validate_length(s,l,n) + end + def available + s=@h['available'] + l,n=Db[:col_date_text],'date.available' + validate_length(s,l,n) + end + def created + s=@h['created'] + l,n=Db[:col_date_text],'date.created' + validate_length(s,l,n) + end + def issued + s=@h['issued'] + l,n=Db[:col_date_text],'date.issued' + validate_length(s,l,n) + end + def modified + s=@h['modified'] + l,n=Db[:col_date_text],'date.modified' + validate_length(s,l,n) + end + def published + s=@h['published']=(@h['published'] ? @h['published'] : @h['main']) + l,n=Db[:col_date_text],'date.published' + validate_length(s,l,n) + end + def valid + s=@h['valid'] + l,n=Db[:col_date_text],'date.valid' + validate_length(s,l,n) + end + self + end + #def language # as things stand this should really be populated from title.language and original.language, resolve + # a=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m) + # @h=build_hash(a) + # def document + # s=@h['document']=(@h['document'] ? @h['document'] : @h['main']) + # l,n=Db[:col_language],'language.document' + # validate_length(s,l,n) + # end + # def document_char + # s=@h['document_char']=(@h['document_char'] ? @h['document_char'] : nil) + # l,n=Db[:col_language_char],'language.document_char' + # validate_length(s,l,n) + # end + # def original + # s=@h['original'] + # l,n=Db[:col_language],'language.original' + # validate_length(s,l,n) + # end + # def original_char + # s=@h['original_char'] + # l,n=Db[:col_language_char],'language.original_char' + # validate_length(s,l,n) + # end + # self + #end + def current_publisher + @s + end + def original + a=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m) + @h=build_hash(a) + def publisher + s=@h['publisher'] + l,n=Db[:col_name],'original.publisher' + validate_length(s,l,n) + end + def language + s=@h['language'] + l,n=Db[:col_language],'original.language' + validate_length(s,l,n) + end + def language_char + s=@h['language_char'] + l,n=Db[:col_language_char],'original.language_char' + validate_length(s,l,n) + end + def source + s=@h['source'] + l,n=Db[:col_name],'original.source' + validate_length(s,l,n) + end + def institution + s=@h['institution'] + l,n=Db[:col_name],'original.institution' + validate_length(s,l,n) + end + def nationality + s=@h['nationality'] + l,n=Db[:col_language],'original.nationality' + validate_length(s,l,n) + end + self + end + def notes + a=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m) + @h=build_hash(a) + def description + s=@h['description'] + l,n=Db[:col_info_note],'notes.description' + validate_length(s,l,n) + end + def abstract + s=@h['abstract'] + l,n=Db[:col_info_note],'notes.abstract' + validate_length(s,l,n) + end + def comment + s=@h['comment'] + l,n=Db[:col_info_note],'notes.comment' + validate_length(s,l,n) + end + def coverage + s=@h['coverage'] + l,n=Db[:col_info_note],'notes.coverage' + validate_length(s,l,n) + end + def relation + s=@h['relation'] + l,n=Db[:col_info_note],'notes.relation' + validate_length(s,l,n) + end + def source + s=@h['source'] + l,n=Db[:col_txt_long],'notes.source' + validate_length(s,l,n) + end + def history + s=@h['history'] + l,n=Db[:col_txt_long],'notes.history' + validate_length(s,l,n) + end + def type + s=@h['type'] + l,n=Db[:col_txt_long],'notes.relation' + validate_length(s,l,n) + end + def format + s=@h['format'] + l,n=Db[:col_txt_short],'notes.format' + validate_length(s,l,n) + end + def prefix + @h['prefix'] + end + self + end + end + class Instructions + @doc={ lv: [] } + @doc[:fns],@doc[:fnb],@doc[:scr_suffix]='','','' + @@publisher='SiSU scribe' + attr_accessor :make,:env,:path,:file,:fn,:fns,:fno,:fnb,:fnn,:fnt,:fnl,:flv,:fnz,:fnstex,:ocn,:sfx_src,:pdf,:file_type,:dir_out,:dir_tex,:dir_lout,:txt_path,:sisu,:sisu_version,:ruby_version,:title,:subtitle,:full_title,:html_title,:subtitle_tex,:creator,:classify,:author_home,:author,:author_title,:author_nationality,:authors,:authorship,:translator,:illustrator,:prepared_by,:digitized_by,:subject,:description,:publisher,:current_publisher,:contributor,:date,:date_created,:date_issued,:date_available,:date_valid,:date_modified,:date_translated,:date_added_to_site,:date_scheme,:date_created_scheme,:date_issued_scheme,:date_available_scheme,:date_valid_scheme,:date_modified_scheme,:type,:format,:identifier,:source,:language,:language_original,:relation,:coverage,:rights,:keywords,:comments,:abstract,:cls_loc,:cls_dewey,:cls_pg,:cls_isbn,:papersize,:papersize_array,:toc,:lv0,:lv1,:lv2,:lv3,:lv4,:lv5,:lv6,:lvs,:pagenew,:pagebreak,:pageline,:num_top,:bold_match_list,:italics_match_list,:substitution_match_list,:emphasis_set_to,:toc_lev_limit,:flag_endnotes,:flag_auto_endnotes,:flag_separate_endnotes,:flag_separate_endnotes_make,:markup,:markup_instruction,:flag_tables,:vocabulary,:doc_css,:yaml,:lnk,:links,:prefix_a,:prefix_b,:suffix,:information,:contact,:icon,:image,:ad_url,:ad_png,:ad_alt,:ad_began,:flag_promo,:promo,:ad_home,:stmp,:stmpd,:sc_filename,:sc_number,:sc_date,:sc_time,:sc_info,:yamladdr,:locale,:wc_lines,:wc_words,:wc_bytes,:file_encoding,:filesize,:user,:home,:hostname,:pwd,:firstseg,:programs,:author_copymark,:i18n,:lang,:lang_code_insert,:en,:notes,:dgst,:generated,:tags,:tag_array,:concord_make,:seg_names,:seg_autoname_safe,:set_header_title,:set_heading_top,:set_heading_seg,:heading_seg_first,:heading_seg_first_flag,:base_program,:ec,:opt,:sem_tag,:book_idx,:topic_register,:topic_register_array,:original,:writing_focus,:audio,:daisy,:home_button_image,:home_button_links,:footer_links,:cover_image,:man_section + def initialize(fns_array,opt) + @env=@path,@file=@fn=@fns=@fno=@fnb=@fnn=@fnt=@fnl=@flv=@fnz=@fnstex=@ocn=@sfx_src=@pdf=@file_type=@dir_out=@dir_tex=@dir_lout=@txt_path=@make=@flag_endnotes=@flag_auto_endnotes=@flag_separate_endnotes=@flag_separate_endnotes_make=@sisu=@sisu_version=@ruby_version=@title=@subtitle=@full_title=@html_title=@subtitle_tex=@creator=@classify=@author_home=@author=@author_title=@author_nationality=@translator=@illustrator=@prepared_by=@digitized_by=@subject=@description=@publisher=@current_publisher=@contributor=@date=@date_created=@date_issued=@date_available=@date_valid=@date_modified=@date_translated=@date_added_to_site=@date_scheme=@date_created_scheme=@date_issued_scheme=@date_available_scheme=@date_valid_scheme=@date_modified_scheme=@type=@format=@identifier=@source=@language=@language_original=@relation=@coverage=@rights=@keywords=@comments=@abstract=@cls_loc=@cls_dewey=@cls_pg=@cls_isbn=@papersize=@toc=@lv0=@lv1=@lv2=@lv3=@lv4=@lv5=@lv6=@pagenew=@pagebreak=@pageline=@num_top=@bold_match_list=@italics_match_list=@substitution_match_list=@emphasis_set_to=@toc_lev_limit=@flag_tables=@vocabulary=@doc_css=@yaml=@lnk=@links=@prefix_a=@prefix_b=@suffix=@information=@contact=@icon=@ad_url=@ad_png=@ad_alt=@ad_began=@promo=@ad_home=@stmp=@stmpd=@sc_filename=@sc_number=@sc_date=@sc_time=@sc_info=@yamladdr=@locale=@wc_lines=@wc_words=@wc_bytes=@file_encoding=@filesize=@firstseg=@programs=@author_copymark=@i18n=@lang=@lang_code_insert=@en=@notes=@dgst=@generated=@heading_seg_first=@base_program=@topic_register=@original=@writing_focus=@audio=@home_button_image=@home_button_links=@cover_image=@man_section=nil + @data, @path, @fns, @fno, @opt= + fns_array,opt.pth,opt.fns,opt.fno,opt #@data used as data + @flag_tables,@set_header_title,@set_heading_top,@set_heading_seg,@heading_seg_first_flag,@flag_promo,@book_idx= + false, false, false, false, false, false, false + @seg_autoname_safe=true + @daisy,@sem_tag=false,false + @authorship,@markup_instruction,@image='','','','' #check which other values should be set to empty rather than nil + @markup=@markup_instruction #use @markup_instruction + @doc,@fn,@make_italic,@tag_hash,@ec={},{},{},{},{},{} + @flv,@lang,@seg_names,@tags,@tag_array,@tag_a,@ec[:image],@ec[:audio],@ec[:multimedia]=Array.new(9){[]} + @authors,@topic_register_array,@papersize_array=[],[],[] + @lvs=[nil,0,0,0,0,0,0] + @emphasis_set_to='bold' + @lang_code_insert=SiSU_Env::FilenameLanguageCodeInsert.new(@opt).language_code_insert + @footer_links= { left: { say: '', url: '' }, center: { say: '', url: '' } } + @rgx_image=/(?:^|[^_\\])\{(?:\s*|\~\^\s+)(\S+?\.(?:png|jpg|gif)\b)/m + @rgx_audio=/\{\s*(\S+?\.(?:mp3|ogg))/ + @rgx_mm=/\{\s*(\S+?\.(?:ogg|mpeg))/ #expand and distinguish ogg + Dir.chdir(@opt.f_pth[:pth]) + begin + rescue + SiSU_Errors::Rescued.new($!,$@,@opt.cmd,@fns).location do + __LINE__.to_s + ':' + __FILE__ + end + ensure + end + @header_make_links_append=:no + common_makes=(defined? @opt.make_instructions_pod) \ + && @opt.make_instructions_pod !=nil \ + && @opt.make_instructions_pod[:makeset]==true \ + ? @opt.make_instructions_pod + : @opt.make_instructions + if common_makes[:makeset] + @pagenew=common_makes[:pagenew] + @pagebreak=common_makes[:pagebreak] + @pageline=common_makes[:pageline] + @toc=common_makes[:toc] + @lv0=common_makes[:lv0] + @lv1=common_makes[:lv1] + @lv2=common_makes[:lv2] + @lv3=common_makes[:lv3] + @lv4=common_makes[:lv4] + @lv5=common_makes[:lv5] + @lv6=common_makes[:lv6] + @num_top=common_makes[:num_top] + @i18n=common_makes[:i18n] + @man_section=common_makes[:man_section] + @emphasis_set_to=common_makes[:emphasis_set_to] + @bold_match_list=common_makes[:bold_match_list] + @italics_match_list=common_makes[:italics_match_list] + @substitution_match_list=common_makes[:substitution_match_list] + @footer_links=common_makes[:footer_links] + @home_button_links=common_makes[:home_button_links] + @home_button_image=common_makes[:home_button_image] + @cover_image=common_makes[:cover_image] + @lnk=@links=common_makes[:links] + @header_make_links_append=common_makes[:links_append] + end + end + #protected + def extract + @user,@home,@hostname,@pwd=ENV['USER'],ENV['HOME'],ENV['HOSTNAME'],ENV['PWD'] + @programs,@wc,@language,@language_original={},{},{},{} + @en={ sum: 0, mark: 0, note: 0, mismatch: 0 } + @prog=SiSU_Env::InfoSettings.new + @sys=SiSU_Env::SystemCall.new + @env=SiSU_Env::InfoEnv.new(@fns) #watch + if (@opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) + puts 'system locale: ' + @sys.locale + end + if @prog.wc \ + and @sys.wc + wc=%x{wc #{fns}} + wca=wc.scan(/\d+/) + @wc_lines,@wc_words,@wc_bytes=wca[0].to_i,wca[1].to_i,wca[2].to_i + else + fns_a=@data.dup + tmp=fns_a.join + fns_a=tmp.scan(/\S+/) + @wc_words=fns_a.length + fns_a=tmp=nil + end + @concord_make=(@wc_words > @env.concord_max) ? false : true + @locale=@sys.locale + @file_encoding=@sys.file_encoding(fns,@opt.cmd) + # programs set here for things that affect output appearance only + @programs[:pdf]=SiSU_Env::SystemCall.new.program_found?('pdflatex') + if @opt.cmd =~/P/ #if @env.multilingual? + m=/((.+?)(?:\~\w\w(?:_\w\w)?)?)\.((?:-|ssm\.)?sst|ssm|ssi)$/ #watch added match for sss + @fnn,@fnb,@fnt=@fns[m,1],@fns[m,2],@fns[m,3] + @flv=@env.document_language_versions_found[:f] + else + m=/((.+?)(?:\~\w\w(?:_\w\w)?)?)\.((?:-|ssm\.)?sst|ssm)$/ #watch added match for sss + @fnn,@fnb,@fnt=@fns[m,1],@fns[m,2],@fns[m,3] + @flv=@env.document_language_versions_found[:f] + @fnz=(@fns =~/\.(?:ssm\.sst|ssm)$/) ? (@fnn + '.ssm.txz') : (@fnn + '.sst.txz') + end + @papersize=@env.papersize #'A4' #default size #get first from SiSU_Env:: # @env is probably no longer most appropriate name! as default info is more general + @sfx_src=@fns[m,2] + if @fns =~ /(?:-|ssm\.)?sst$/ \ + and not @opt.cmd =~/P/ #watch + @env_out_root=@env.path.output + @dir_out="#{@env.path.output}/#{@fnb}" + @dir_tex=@env.processing_path.tex + @dir_lout=@env.processing_path.lout + @@publisher='SiSU http://www.jus.uio.no/sisu' + end + @txt_path=@txt_path ||= @env.path.output + @stmp=%{#{@fns}}[/^(.+?)\..*/m,1] + @fnstex=@fns.gsub(/_/,'\_\-').gsub(/\./,'.\-') + @flag_endnotes,@flag_auto_endnotes,@flag_separate_endnotes=false,false,false + @flag_separate_endnotes_make=true + ver=SiSU_Env::InfoVersion.instance + @sisu_version=ver.get_version + @ruby_version=ver.rbversion + @generated=Time.now + fns_array=@data.dup + skip unless fns_array # consider + @code_flag=false + fns_array.each do |para| #% scan document + if para !~/^%+\s/ \ + and para =~/|

|
|
)\s*/,' '). + gsub(/~\{.+?\}~/,'') + SiSU_Screen::Ansi.new( + @opt.act[:color_state][:set], + 'Document Parameters', + %{#{title}#{creator}} + ).txt_grey if @opt.act[:verbose][:set]==:on + end + if not @book_idx \ + and para =~/^=\{(.+?)\}[\s`]*\Z/m + @book_idx=true + end + unless @code_flag + case para + when /~\{\s+.+?\}~/m #% processing + en=para.scan(/~\{.+?\}~/m) + en.each { |e| @en[:sum] +=1 } + when /~\^(?:\s|$)/m #% processing + mk=para.scan(/~\^(?:\s|$)/) + mk.each { |e| @en[:mark] +=1 } + when /^\^~\s+\S/ then @en[:note] +=1 #% processing + end + end + if para =~/~\{|\^~ |~\^|\{.+?\[[1-6]\]\}\S+?\.ss[tm]/m + @flag_auto_endnotes,@flag_endnotes=true,true + end + if para =~/^(?:table\{|\{table)/i + @flag_tables=true + end + end + if para =~/^:?A~/ + @set_heading_top=true + end + if para =~/^1~/ + m=nil + if para =~/^1~(\S+)\s+(.+)$/ + m,t=$1,$2 + elsif para =~/^1~\s+(.+)$/ + t=$1 + end + unless @heading_seg_first_flag # extract first segment name + @heading_seg_first=t + @heading_seg_first_flag=true + end + if m # list all segment names + @seg_names << m + @set_heading_seg=true + if m=~/^\d{1,3}/ \ + and m !~/^0/ + @seg_autoname_safe=false + end + end + end + para=para.gsub(/<:=(\S+?)>/,'{ c_\1.png 14x14 }image') # embedded symbol (image) + if para !~/^%+\s/ \ + and para =~@rgx_image + @ec[:image] << para.scan(@rgx_image).uniq + end + @ec[:audio] << para.scan(@rgx_audio).uniq if para =~@rgx_audio #embedded content + @ec[:multimedia] << para.scan(@rgx_mm).uniq if para =~@rgx_mm #embedded content + unless @sem_tag + @sem_tag=true if para=~/[:;]\{.+?\}[:;][a-z+]/ #refix later + end + end #% here endeth the document loop + unless @make + if (@opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) + SiSU_Screen::Ansi.new( + @opt.act[:color_state][:set], + '@make:', + 'header absent' + ).warn + end + @make=SiSU_Param::Parameters::MdMake.new('@make: ',@opt,@env).make + end + if @cover_image \ + and @cover_image.is_a?(Hash) \ + and (@cover_image[:cover] =~@rgx_image \ + or @cover_image[:cover] =~/\S+?.(?:jpg|png|gif)/) + @ec[:image] << @cover_image[:cover] + end + if @home_button_image \ + and @home_button_image.is_a?(Hash) \ + and (@home_button_image =~@rgx_image \ + or @home_button_image =~/\S+?\.(?:jpg|png|gif)/) + @ec[:image] << @home_button_image + end + if @ec[:image].length > 0 + @ec[:image]=@ec[:image].flatten.uniq + @ec[:image].delete_if {|x| x =~/https?:\/\// } + @ec[:image]=@ec[:image].sort + end + @ec[:audio]=@ec[:audio].uniq.flatten.sort + @ec[:multimedia]=@ec[:multimedia].uniq.flatten.sort + unless @rights + if defined? @creator.author \ + and @creator.author.is_a?(String) \ + and defined? @date.published \ + and @date.published.is_a?(String) + @rights=SiSU_Param::Parameters::MdDefault.new.rights(@creator.author,@date.published) + elsif defined? @creator.author \ + and @creator.author.is_a?(String) + @rights=SiSU_Param::Parameters::MdDefault.new.rights("[#{@creator.author}]",'') + end + end + if defined? @classify.topic_register \ + and @classify.topic_register.is_a?(String) \ + and @classify.topic_register.length >3 + topic_register=@classify.topic_register + u=topic_register.scan(/[^;]+/m).sort + v=[] + u.each do |l| + v << l.scan(/[^:]+/m) + end + v.each do |s| + s[-1]=s[-1].scan(/[^|]+/m) if s[-1] =~/[|]/m + @topic_register_array << s + end + @topic_register_array + end + if @i18n + @i18n=@i18n.uniq + @i18n << 'en' unless @i18n.find_index("en") + else + @i18n=[ 'en' ] + end + translated=[] + translate_list=[@pagenew,@pagebreak,@pageline,@num_top,@toc_lev_limit] + translate_list.each do |t| + translate=t.to_s if t + translated << if translate + translate.gsub!(/3/,'6') + translate.gsub!(/2/,'5') + translate.gsub!(/1/,'4') + translate.gsub!(/:?C/,'3') + translate.gsub!(/:?B/,'2') + translate.gsub!(/:?A/,'1') + # looks like an ok substituion for the above but is not, causes problems, check why + #translate=translate.gsub(/3/,'6'). + # gsub(/2/,'5'). + # gsub(/1/,'4'). + # gsub(/:?C/,'3'). + # gsub(/:?B/,'2'). + # gsub(/:?A/,'1') + translate=(translate =~/^\d+$/) \ + ? translate.to_i + : translate + else nil + end + end + @pagenew,@pagebreak,@pageline,@num_top,@toc_lev_limit=translated + @markup=@markup.gsub(/page_new\s*=\s*([\dA-C])/,"page_new=#{@pagenew}"). + gsub(/page_break\s*=\s*([\dA-C])/,"page_break=#{@pagebreak}"). + gsub(/page_line\s*=\s*([\dA-C])/,"page_line=#{@pageline}"). + gsub(/num_top\s*=\s*([\dA-C])/,"num_top=#{@num_top}"). + gsub(/toc_lev_limit\s*=\s*([\dA-C])/,"toc_lev_limit=#{@toc_lev_limit}") + papersize_array_rc=@papersize.downcase.scan(/(?:a4|letter|legal|book|a5|b5)/) + papersize_array_opt=[ + ((@opt.act[:pdf_a4][:set]==:on) ? 'a4' : ''), + ((@opt.act[:pdf_a5][:set]==:on) ? 'a5' : ''), + ((@opt.act[:pdf_b5][:set]==:on) ? 'b5' : ''), + ((@opt.act[:pdf_letter][:set]==:on) ? 'letter' : ''), + ((@opt.act[:pdf_legal][:set]==:on) ? 'legal' : ''), + ] - [""] + @papersize_array=(papersize_array_opt.length > 0) \ + ? papersize_array_opt + : papersize_array_rc + fn=@opt.fno #decide what to do a filesize on .ssm tells very little about actual document size + @filesize=(File.size(fn)).to_s + if @sys.openssl !=false \ + and FileTest.file?(@env.source_file_with_path) + @dgst=[] + case @env.digest(@opt).type + when :sha512 + dgst=@sys.sha512(@env.source_file_with_path) + @dgst=dgst[1].length==128 ? dgst : nil + puts 'check document (sha512) digest' if not @dgst + when :sha256 + dgst=@sys.sha256(@env.source_file_with_path) + @dgst=dgst[1].length==64 ? dgst : nil + puts 'check document (sha256) digest' if not @dgst + when :md5 + dgst=@sys.md5(@env.source_file_with_path) + @dgst=dgst[1].length==32 ? dgst : nil + puts 'check document (md5) digest' if not @dgst + else + dgst=@sys.sha256(@env.source_file_with_path) + @dgst=dgst[1].length==64 ? dgst : nil + puts 'check document (sha256) digest' if not @dgst + end + elsif not FileTest.file?(@env.source_file_with_path) + #puts SiSU_Utils::CodeMarker.new(__LINE__,__FILE__).set(:fuchsia) + end + @publisher ||= "#{@@publisher} (this copy)" + fn_set_lang=SiSU_Env::StandardiseLanguage.new(@opt.lng).language + unless @language[:code] \ + and @language[:name] + lang=@env.i18n.language #default language settings for directory by name, or in sysrc.yml + @language[:code] ||= lang.code + @language[:name] ||= lang.title + end + unless fn_set_lang[:d]==true #decide, naming convention overrides other settings, within document, etc. + @language[:code]=fn_set_lang[:c] + @language[:name]=fn_set_lang[:n] + end + @fnl=@env.i18n.lang_filename(fn_set_lang[:c]) + @lang=@lang.uniq + @fn=SiSU_Env::EnvCall.new(@fns).lang(fn_set_lang[:c]) + if @en[:note] > 0 \ + and @en[:sum] > 0 + if @en[:sum] > 0 + else + SiSU_Screen::Ansi.new( + @opt.act[:color_state][:set], + '*WARN* both endnote styles used', + "~{ #{@en[:sum]} }~ and ^~ #{@en[:mark]}" + ).warn unless @opt.act[:quiet][:set]==:on + end + end + if @en[:mark] != @en[:note] \ + and @en[:note] > 0 + @en[:mismatch]=@en[:note] - @en[:mark] + SiSU_Screen::Ansi.new( + @opt.act[:color_state][:set], + '*WARN* endnote number mismatch', + "endnotes: #{@en[:note]} != endnote reference marks: #{@en[:mark]} (difference = #{@en[:mismatch]})" + ).warn unless @opt.act[:quiet][:set]==:on + footnote_conversion_errors=File.new("#{Dir.pwd}/footnote_conversion_errors.txt",'a') + footnote_conversion_errors << + "#{@fns}:\n\tendnotes: #{@en[:note]} != endnote reference marks: #{@en[:mark]} (difference = #{@en[:mismatch]})\n" + end + if not @title \ + or not defined? @title.main \ + or @title.main !~/[\S]/ + if @fns =~/\.ssm$/ \ + and @opt.inspect =~/P/ + #@title=Md.new('Text Insert',@opt,@env).title + else + SiSU_Screen::Ansi.new( + @opt.act[:color_state][:set], + 'WARNING: Document Title missing', + 'please provide @title:' + ).warn unless @opt.act[:quiet][:set]==:on + end + end + if @author !~/[\S]/ + if @fns =~/\.ssm$/ \ + and @opt.inspect =~/P/ + #@creator=SiSU_Param::Md.new('Text Insert',@opt,@env).creator + else + SiSU_Screen::Ansi.new( + @opt.act[:color_state][:set], + 'WARNING: Document Author missing', + 'please provide @creator: :author:' + ).warn unless @opt.act[:quiet][:set]==:on + end + end + @struct={} + doc_struct=Hash.new(0) + if @lv1.nil? + fns_array.each do |para| + if para =~/^(Part|Chapter|Section|Article)\b/i + case para + when /^(Part|PART)\b/ + @struct[:part]=doc_struct[:part] + doc_struct[:part]=doc_struct[:part] + 1 + when /^(Chapter|CHAPTER)\b/ + @struct[:chapter]=doc_struct[:chapter] + doc_struct[:chapter]=doc_struct[:chapter] + 1 + when /^(Section|SECTION)\b/ + @struct[:section]=doc_struct[:section] + doc_struct[:section]=doc_struct[:section] + 1 + when /^(Article|ARTICLE)\b/ + @struct[:article]=doc_struct[:article] + doc_struct[:article]=doc_struct[:article] + 1 + when /^(Clause|CLAUSE)\b/ + @struct[:clause]=doc_struct[:clause] + doc_struct[:clause]=doc_struct[:clause] + 1 + when /^\d\..*[^\.]$/ + @struct[:number]=doc_struct[:number] + doc_struct[:number]=doc_struct[:number] + 1 + end + end + end + if doc_struct[:article] > 2 #%~level 4 + @lv4=/^(?:Article|ARTICLE)\b/ + elsif doc_struct[:chapter] > 2 \ + and doc_struct[:article] \ + and doc_struct[:article] < 3 + @lv4=/^(?:Chapter|CHAPTER)\b/ + elsif doc_struct[:clause] > 2 + @lv4=/^(?:Clause|CLAUSE)\b/ + elsif doc_struct[:number] > 2 + @lv4="^\d\..*[^\.]$" + end + if doc_struct[:section] > 2 #%~level 3 + @lv3=/^(?:Section|SECTION)\b/ + end + if doc_struct[:chapter] > 2 \ + and doc_struct[:article] \ + and doc_struct[:article] > 2 + @lv2=/^(?:Chapter|CHAPTER)\b/ + end + if doc_struct[:part] > 2 \ + and @lv[2].nil? + @lv2=/^(?:Part|PART)\b/ + end + if doc_struct[:part] > 2 \ + and @lv[2].inspect !~/Part/ \ + and @lv[1].nil? + @lv1=/^(Part|PART)\b/ + end + end + @lnk=@lnk.compact if @lnk + @lv0 ||=/^0~/ + @lv1 ||=/^1~/ + @lv2 ||=/^2~/ + @lv3 ||=/^3~/ + @lv4 ||=/^4~/ + @lv5 ||=/^5~/ + @lv6 ||=/^6~/ + @data=nil #else whole file's contents are stored in md pstore & is not required to be... big waste actually + @file=SiSU_Env::FileOp.new(self) #watch + Store.new(self,@env).store #% pstore + self + end + private + class Store + def initialize(md,env) + @md,@env=md,env + end + def store + begin + pstorefile="#{@env.processing_path.ao}/#{@md.fns}.pstore" + File.unlink(pstorefile) if FileTest.file?(pstorefile) + if (@md.opt.act[:verbose_plus][:set]==:on \ + || @md.opt.act[:maintenance][:set]==:on) + SiSU_Screen::Ansi.new( + @md.opt.act[:color_state][:set], + "PStore -> #{pstorefile}" + ).txt_grey + end + store=PStore.new(pstorefile) + store.transaction do + store['md']=@md + store.commit + end + @@md=@md=nil + rescue + SiSU_Errors::Rescued.new($!,$@,@md.opt.cmd,@md.fns).location do + __LINE__.to_s + ':' + __FILE__ + end + ensure + end + end + end + end + end + class Instantiate + def param_instantiate + @@date=SiSU_Env::InfoDate.new + @@proc= + @@filename_txt= + @@filename_texinfo= + @@filename_lout_portrait= + @@filename_lout_landscape= + @@filename_html_scroll= + @@filename_html_index= + @@filename_html_segtoc= + @@filename_semantic= + @@filename_rss= + @@newfile= + @@drr= + nil + @doc={ + initialise: nil, + markup: '', + lnks: '', + stmp: '', + prefix_a: '', + prefix_b: '', + req: {} + } + @@yaml=@@yamladdr=nil + @@flag={} + @@publisher='SiSU scribe' + end + end +end +__END__ diff --git a/lib/sisu/v6/dp_identify_markup.rb b/lib/sisu/v6/dp_identify_markup.rb new file mode 100644 index 00000000..0281832a --- /dev/null +++ b/lib/sisu/v6/dp_identify_markup.rb @@ -0,0 +1,167 @@ +# encoding: utf-8 +=begin + + * Name: SiSU + + * Description: a framework for document structuring, publishing and search + + * Author: Ralph Amissah + + * Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. + + * License: GPL 3 or later: + + SiSU, a framework for document structuring, publishing and search + + Copyright (C) Ralph Amissah + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along with + this program. If not, see . + + 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: + + + * Git + + + + * Ralph Amissah + + + + ** 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 + +=end +module SiSU_MarkupType + class MarkupIdentify + @@version={} + @@fns,@@version[:determined],@@version[:declared],@@declared_doc_type='','','','[text?]' + attr_accessor :version,:declared_doc_type + def initialize(content,opt) + @cont,@opt=content,opt + end + def identify + @version,@declared_doc_type=@@version,@@declared_doc_type + if @opt.fns != @@fns + if @cont[0] =~ /^(?:%\s+)?SiSU\s+(text|master|insert)\s+([0-9](?:\.[0-9]+){1,2})/ \ + or @cont[0] =~ /^(?:%\s+)?sisu-([0-9](?:\.[0-9]+){1,2})/ + @declared_doc_type,@version[:declared]=$1,$2 + elsif @cont[0] =~ /^(?:%\s+)?SiSU\s+([0-9](?:\.[0-9]+){1,2})/ \ + or @cont[0] =~ /^(?:%\s+)?sisu-([0-9](?:\.[0-9]+){1,2})/ + @version[:declared]=$1 + end + @flag_2_0,@flag_66,@flag_57,@flag_38=false,false,false,false + @cont.each_with_index do |y,i| + if y =~/^@make:|^@classify|^\s\s?:\S+?:\s+\S/ + version=2.0.to_f + @version[:determined]=version + @flag_2_0=true + break + end + unless @flag_38 + if y =~/^:?A~/ + version=0.38.to_f + @version[:determined]=version + @flag_38=true + end + end + if @flag_38 + if @flag_69 \ + or y =~/^=\{.+?\}\s*$/ + version=0.69.to_f + @flag_69=true + @version[:determined]=version + break + end + if @flag_66 \ + or y =~/[:;]\{.+?\}[:;][a-z+]/ + version=0.66.to_f + @flag_66=true + @version[:determined]=version + break + end + end + end + @flag_57,@flag_38=false,false + unless @flag_2_0 \ + or @flag_66 \ + or @flag_69 + @cont.each_with_index do |y,i| + if @flag_57 \ + or y =~/^:?A~\?? @title/ + @version[:determined]=0.57.to_f + @flag_57=true + break + end + if @flag_38 \ + or y =~/^:?A~/ + @version[:determined]=0.38.to_f + @flag_38=true + break if i >= 200 + if y =~ /(?:~{\*+|~\[\*|~\[\+)\s/ + @version[:determined]=0.42 #0.38 can safely be treated as 0.42 + break + end + end + if y =~/^0~/ \ + and not @flag_38 + @version[:determined]=0.16.to_f + break + end + end + end + @@fns=@opt.fns + @@version,@@declared_doc_type=@version,@declared_doc_type + end + self + end + def markup_version? + def determined + identify.version[:determined].to_f + end + def series + s=case identify.version[:determined].to_s + when /^[01]\./ then '1.0' + when /^[2]\./ then '2.0' + else '2.0' + end + "series #{s}" + end + def declared + identify.version[:declared].to_f + end + self + end + end +end +__END__ diff --git a/lib/sisu/v6/dp_make.rb b/lib/sisu/v6/dp_make.rb new file mode 100644 index 00000000..0dacd517 --- /dev/null +++ b/lib/sisu/v6/dp_make.rb @@ -0,0 +1,674 @@ +# encoding: utf-8 +=begin + + * Name: SiSU + + * Description: a framework for document structuring, publishing and search + + * Author: Ralph Amissah + + * Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. + + * License: GPL 3 or later: + + SiSU, a framework for document structuring, publishing and search + + Copyright (C) Ralph Amissah + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public Lic/home/ralph/live-manual/build/manual/manifest/live-manual.ca.htmlense 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: + + + * Git + + + + * Ralph Amissah + + + + ** Description: document parameters make extracted for program use + +=end + +module SiSU_Param_Make + class MdMake + def initialize(str,opt,env) + @s,@opt,@env=str,opt,env + end + def validate_length(s,l,n) + #s=(s.length <= l) ? s : nil + s=if s.is_a?(String) \ + and s.length <= l + s + elsif s.is_a?(NilClass) + nil + elsif s.class !=String + STDERR.puts "#{n} is #{s.class}: programming error, String expected #{__FILE__}:#{__LINE__}" + s + else + SiSU_Screen::Ansi.new( + 'v', + "*WARN* #{n} length #{s.length} exceeds set db field length #{l}, metadata dropped", + @opt.fns + ).warn unless @opt.act[:quiet][:set]==:on + nil + end + end + def name_format(name) + if name + name=name.strip + @name_a_h=[] + authors=name.scan(/[^;]+/) + authors.each_with_index do |a,i| + b=((a =~/\s*\|\s*/) ? (a.split(/\|/)) : [a]) + if b[0] =~/"(.+?)"/ + @name_a_h << { the: $1 } + else + x=b[0].scan(/[^,]+/) + if x.length==1 + @name_a_h << { the: x[0].strip } + elsif x.length==2 + @name_a_h << { the: x[0].strip, others: x[1].strip } + else #p x.length + end + end + b.delete_at(0) + b.each do |d| + k,c=nil + k,c=/^(\S+)\s+(.*)/.match(d)[1,2] if d + @name_a_h[i][:hon]=c.strip if k=='hon' + @name_a_h[i][:affiliation]=c.strip if k=='affiliation' + @name_a_h[i][:nationality]=c.strip if k=='nationality' + end + end + l=@name_a_h.length + name_str='' + @name_a_h.each_with_index do |a,i| + name_str += if a[:others] + z=(((l - i) > 1) ? ', ' : '') + "#{a[:others].strip} #{a[:the].strip}" + z + else + z=(((l - i) > 2) ? ', ' : '') + "#{a[:the].strip}" + z + end + end + { name_a_h: @name_a_h, name_str: name_str } + else nil + end + end + def build_hash(arr) + @h={} + arr.each_with_index do |x,i| + a,b=nil,nil + if x =~/^%[:\s]/ #ignore comment + elsif x =~/:(\S+?):\s+(.+)/ + a,b=/:(\S+?):\s+(.+)\Z/m.match(x)[1,2] + elsif i == 0 + a='main' + b=x + else + end + @h[a]=b + end + @h + end + def make + a=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m) + @h=build_hash(a) + def headings + lv=[] + x=@h['headings'] + x=((x =~/;/) ? (x.split(/;\s*/)) : [ x ]) + lv[0]=x + lv0 ||='A~ ' #root level, single document apex, document title + lv1=x[0] ||='B~ ' + lv[1]=/^#{lv1}/ + lv2=x[1] ||='C~ ' + lv[2]=/^#{lv2}/ + lv3=x[2] ||='D~ ' + lv[3]=/^#{lv3}/ + lv4=x[3] ||='1~ ' + lv[4]=/^#{lv4}/ + lv5=x[4] ||='2~ ' + lv[5]=/^#{lv5}/ + lv6=x[5] ||='3~ ' + lv[6]=/^#{lv6}/ + lv + end + def num_top + @h['num_top'] + end + def breaks + pagebreaks=((@h['breaks'] =~/;/) \ + ? (@h['breaks'].split(/;\s*/)) + : [ @h['breaks'] ]) + page_new,page_break,page_line=nil,nil,nil + pagebreaks.each do |x| + page_new=x[/(:?[\dA-C],?)+/] if x=~/new|clear/ + page_break=x[/(:?[\dA-C],?)+/] if x =~/break/ + page_line=x[/(:?[\dA-C],?)+/] if x =~/line/ + end + { page_new: page_new, page_break: page_break, page_line: page_line } + end + def language + if @h['language'] && (@h['language']=~/\S{2,}/) + ((@h['language'] =~/,/) \ + ? (@h['language'].split(/,\s*/)) + : [ @h['language'] ]) + else [ 'en' ] + end + end + def bold + m=@h['bold'] + i=(m=~/\/i$/)? 'i' : '' + if m + x=m.gsub(/^\/(.+?)\/i?/,'\1'). + gsub(/\((?:\?:)?/,'(?:') # avoid need to escape use of brackets within regex provided + rgx='\b(' + x + ')\b' + y=((i =~/i/) ? (/#{rgx}/i) : (/#{rgx}/)) + { str: '\b(?:' + x + ')\b', regx: y, i: i } + else nil + end + end + def italics + m=@h['italics'] + i=((m=~/\/i$/) ? 'i' : '') + if m + x=m.gsub(/^\/(.+?)\/i?/,'\1'). + gsub(/\((?:\?:)?/,'(?:') # avoid need to escape use of brackets within regex provided + rgx='\b(' + x + ')\b' + y=((i =~/i/) ? (/#{rgx}/i) : (/#{rgx}/)) + { str: '\b(?:' + x + ')\b', regx: y, i: i } + else nil + end + end + def emphasis + if @h['emphasis'] =~/bold/ then 'bold' + elsif @h['emphasis'] =~/italics?/ then 'italics' + elsif @h['emphasis'] =~/under(?:line|score)/ then 'underscore' + else nil + end + end + def substitute + m=@h['substitute'] + if m + w=m.scan(/\/(.+?)\/(i?,)\s*'(.+?)'(?:\s+|\s*;\s*|$)/) + arr_hash=[] + matches='' + w.each do |x| + c=(x[1] =~/[i],/) ? :i : :s + matches=matches + x[0].gsub(/([${}])/,'\\\\\1') + '|' + arr_hash << { + match: x[0].gsub(/([${}])/,'\\\\\1'), + replace: x[2], + case_s: c + } + end + matches.chop! + { match_and_replace: arr_hash, matches: matches } + else nil + end + end + def plaintext_wrap + if @h['plaintext_wrap'].to_s =~/\d\d+/ \ + and @h['plaintext_wrap'].to_i > 19 \ + and @h['plaintext_wrap'].to_i < 201 + @h['plaintext_wrap'].to_i + else nil + end + end + def omit + m=@h['omit'] + @m=m ? (m.split(/,\s+/)) : nil + def list + @m + end + self + end + def ocn? + (omit.list.inspect =~/"ocn"/) \ + ? :off + : :na + end + def toc? + (omit.list.inspect =~/"toc"/) \ + ? :off + : :na + end + def manifest? + (omit.list.inspect =~/"manifest"/) \ + ? :off + : :na + end + def links_to_manifest? + (omit.list.inspect =~/"manifest_links"|"links_to_manifest"/) \ + ? :off + : :na + end + def metadata? + (omit.list.inspect =~/"metadata"/) \ + ? :off + : :na + end + def minitoc? + (omit.list.inspect =~/"minitoc"/) \ + ? :off + : :na + end + def html_minitoc? + (omit.list.inspect =~/"html_minitoc"/) \ + ? :off + : :na + end + def html_top_band? + (omit.list.inspect =~/"html_top_band"/) \ + ? :off + : :na + end + def html_navigation? + (omit.list.inspect =~/"html_navigation"/) \ + ? :off + : :na + end + def html_navigation_bar? + (omit.list.inspect =~/"html_navigation_bar"/) \ + ? :off + : :na + end + def segsubtoc? + (omit.list.inspect =~/"segsubtoc"/) \ + ? :off + : :na + end + def search_form? + (omit.list.inspect =~/"search_form"/) \ + ? :off + : :na + end + def html_search_form? + (omit.list.inspect =~/"html_search_form"/) \ + ? :off + : :na + end + def html_right_pane? + (omit.list.inspect =~/"html_right_column"|"html_right_pane"/) \ + ? :off + : :na + end + def manifest_minitoc? + (omit.list.inspect =~/"manifest_minitoc"/) \ + ? :off + : :na + end + def cover_image? + (omit.list.inspect =~/"cover_image"/) \ + ? :off + : :na + end + def home_button_image? + (omit.list.inspect =~/"home_button_image"/) \ + ? :off + : :na + end + def texpdf_font + def main + @h['texpdf_font'] \ + && (@h['texpdf_font']=~/\S{3,}/) \ + ? @h['texpdf_font'] + : @env.font.texpdf.main + end + def sans # not used + @h['texpdf_font_sans'] \ + && (@h['texpdf_font_sans']=~/\S{3,}/) \ + ? @h['texpdf_font_sans'] + : @env.font.texpdf.sans + end + def serif # not used + @h['texpdf_font_serif'] \ + && (@h['texpdf_font_serif']=~/\S{3,}/) \ + ? @h['texpdf_font_serif'] + : @env.font.texpdf.serif + end + def mono + @h['texpdf_font_mono'] \ + && (@h['texpdf_font_mono']=~/\S{3,}/) \ + ? @h['texpdf_font_mono'] + : @env.font.texpdf.mono + end + def cjk + @h['texpdf_font_cjk'] \ + && (@h['texpdf_font_cjk']=~/\S{3,}/) \ + ? @h['texpdf_font_cjk'] + : @env.font.texpdf.cjk + end + def cjk_zh + @h['texpdf_font_cjk_zh'] \ + && (@h['texpdf_font_cjk_zh']=~/\S{3,}/) \ + ? @h['texpdf_font_cjk_zh'] + : @env.font.texpdf.cjk_zh + end + def cjk_ja + @h['texpdf_font_cjk_ja'] \ + && (@h['texpdf_font_cjk_ja']=~/\S{3,}/) \ + ? @h['texpdf_font_cjk_ja'] + : @env.font.texpdf.cjk_ja + end + def cjk_ko + @h['texpdf_font_cjk_ko'] \ + && (@h['texpdf_font_cjk_ko']=~/\S{3,}/) \ + ? @h['texpdf_font_cjk_ko'] + : @env.font.texpdf.cjk_ko + end + self + end + def promo + @h['promo'] + end + def ad + @h['ad'] + end + def manpage + manpage={} + if @h['manpage'] + if @h['manpage'] =~/;/m + man=@h['manpage'].split(/;/m) + man.each do |x| + m=(x=~/=/m) ? x.split(/=/m) : nil + if m + manpage[m[0].strip] = m[1].split(/ \. /) + end + end + end + end + if manpage['name'] + manpage['name']=manpage['name'].join("\n.br\n"). + gsub(/(-)/m,"\\\\\\1"). + gsub(/\A/,"\n.br\n.SH NAME\n.br\n") + else + manpage['name']='man page "name/whatis" information not provided, set in header @man: name=[whatis information]' + end + if manpage['synopsis'] + manpage['synopsis']=manpage['synopsis'].join("\n\n.br\n"). + gsub(/(-)/m,"\\\\\\1"). + gsub(/\A/,"\n.br\n.SH SYNOPSIS\n.br\n") + else + manpage['synopsis']='' + end + unless manpage['section'] + manpage['section']=1 + end + manpage + end + def get_image_dimensions(img) + imgk=SiSU_Env::SystemCall.new.imagemagick + gmgk=SiSU_Env::SystemCall.new.graphicksmagick + img_pth={ + sst: @env.path.image_source_include, + pod: File.expand_path("../../../sisupod/image" ) + } + path_img=if FileTest.file?("#{img_pth[:pod]}/#{img}") + "#{img_pth[:pod]}/#{img}" + elsif FileTest.file?("#{img_pth[:sst]}/#{img}") + "#{img_pth[:sst]}/#{img}" + else nil + end + if path_img + if imgk or gmgk + if imgk + imgsys=`identify #{path_img}`.strip #system call + elsif gmgk + imgsys=`gm identify #{path_img}`.strip #system call + end + w,h=/(\d+)x(\d+)/m.match(imgsys)[1,2] + else + w,h='600','800' + end + else + w,h=nil,nil + end + {w: w, h: h} + end + def home_button_text + if @h['home_button_text'] + @h['home_button_text'].split(/\s*;\s*/) + else nil + end + end + def home_button_image + s=nil + s=if @h['home_button_image'] + s=@h['home_button_image'].split(/\s*;\s*/) + s0=s[0] #if + image={} + s=if s0 =~/{(\S+\.(?:jpg|png|gif))(?:\s+(\d+x\d+))?\s*}(?:(http:\/\/\S+)|image)/ + image[:home_button]=$1 + if $2 + image[:dimensions]=$2 + image[:w],image[:h]=/(\d+)x(\d+)/m.match(image[:dimensions])[1,2] + else + d=get_image_dimensions(image[:home_button]) + image[:w],image[:h]=d[:w],d[:h] + image[:dimensions]="#{d[:w]}x#{d[:h]}" + end + image[:link]=$3 + image + end + else nil + end + end + def cover_image + s=nil + if @h['cover_image'] + s=@h['cover_image'].split(/\s*;\s*/) + s=s[0] #if + image={} + if s =~/{\s*(\S+\.(?:jpg|png|gif))(?:\s+(\d+x\d+))?(?:\s+"(.+?)")?\s*}image/ + image[:cover]=$1 + if $2 + image[:dimensions]=$2 + image[:w],image[:h]=/(\d+)x(\d+)/m.match(image[:dimensions])[1,2] + else + d=get_image_dimensions(image[:cover]) + image[:w],image[:h]=d[:w],d[:h] + image[:dimensions]="#{d[:w]}x#{d[:h]}" + end + image[:note]=$3 + elsif s =~/(\S+\.(?:jpg|png|gif))/ + image[:cover]=$1 + d=get_image_dimensions(image[:cover]) + image[:w],image[:h]=d[:w],d[:h] + image[:dimensions]="#{d[:w]}x#{d[:h]}" + image[:note]=nil + end + image + else nil + end + end + def footer + if @h['footer'] + @h['footer'].split(/\s*;\s*/) + else nil + end + end + self + end + def make_links + @doc_links=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m) + def links + lnks,a_idx=[],0 + @doc_links.each do |doc_link| + if doc_link=~/\{.+?\}(?:(?:https?|file|ftp):\/|\.\.)\/\S+(?:\s|$)/ + say,url=/\{\s*(.+?)\s*\}((?:(?:https?|file|ftp):\/|\.\.)\/\S+)/im.match(doc_link)[1,2] + lnks[a_idx]={ say: say, url: url } + a_idx +=1 + end + end + lnks + end + def append? + (@doc_links[0]=='+') \ + ? :yes + : :no + end + self + end + end + class MakeHead + attr_accessor :pagenew,:pagebreak,:pageline,:toc,:lv1,:lv2,:lv3,:lv4,:lv5,:lv6,:num_top,:i18n,:man_section,:substitution_match_list,:bold_match_list,:italics_match_list,:emphasis_set_to,:footer_links,:home_button_links,:home_button_image,:cover_image + def initialize(make) + @make=make + end + def clear + @pagenew=@pagebreak=@pageline=@toc=@lv1=@lv2=@lv3=@lv4=@lv5=@lv6=@num_top=@i18n=@man_section=@footer_links=@substitution_match_list=@bold_match_list=@italics_match_list=@emphasis_set_to=@home_button_links=@home_button_image=@cover_image=nil + end + def make_instruct + clear + if defined? @make.breaks \ + and @make.breaks[:page_new] #clearpage + @pagenew=@make.breaks[:page_new] + end + if defined? @make.breaks \ + and @make.breaks[:page_break] #newpage + @pagebreak=@make.breaks[:page_break] + end + if defined? @make.breaks \ + and @make.breaks[:page_line] #page line across + @pagebreak=@make.breaks[:page_line] + end + if defined? @make.headings \ + and @make.headings + @toc=@make.headings[0] + @lv1=@make.headings[1] + @lv2=@make.headings[2] + @lv3=@make.headings[3] + @lv4=@make.headings[4] + @lv5=@make.headings[5] + @lv6=@make.headings[6] + end + if defined? @make.num_top \ + and @make.num_top + @num_top=@make.num_top # remove @num_top + end + if defined? @make.language \ + and @make.language[0] + @i18n=@make.language + end + if defined? @make.manpage \ + and @make.manpage + @man_section=(defined? @make.manpage.section) \ + ? @make.manpage.section + : 1 + end + if defined? @make.substitute \ + and @make.substitute + @substitution_match_list=@make.substitute + end + if defined? @make.bold \ + and @make.bold + @bold_match_list=@make.bold + end + if defined? @make.italics \ + and @make.italics + @italics_match_list=@make.italics + end + if defined? @make.emphasis \ + and @make.emphasis + @emphasis_set_to=@make.emphasis + end + if defined? @make.footer \ + and @make.footer.is_a?(Array) + @footer_links= { left: { say: '', url: '' }, center: { say: '', url: '' } } #already set + @footer_links[:left]=if @make.footer[0]=~/\{.+?\}(?:(?:https?|file|ftp):\/|\.\.)\/\S+(?:\s|$)/ + say,url=/\{\s*(.+?)\s*\}((?:(?:https?|file|ftp):\/|\.\.)\/\S+)/im.match(@make.footer[0])[1,2] + { say: say, url: url } + else + { say: '', url: '' } + end + @footer_links[:center]=if @make.footer[1]=~/\{.+?\}(?:(?:https?|file|ftp):\/|\.\.)\/\S+(?:\s|$)/ + say,url=/\{\s*(.+?)\s*\}((?:(?:https?|file|ftp):\/|\.\.)\/\S+)/im.match(@make.footer[1])[1,2] + { say: say, url: url } + else + { say: '', url: '' } + end + @footer_links + else #already set + @footer_links= { left: { say: '', url: '' }, center: { say: '', url: '' } } + end + if defined? @make.home_button_text \ + and @make.home_button_text.is_a?(Array) + a_idx=0 + @home_button_links=[] + @make.home_button_text.each do |doc_link| + if doc_link=~/\{.+?\}(?:(?:https?|file|ftp):\/|\.\.)\/\S+(?:\s|$)/ + say,url=/\{\s*(.+?)\s*\}((?:(?:https?|file|ftp):\/|\.\.)\/\S+)/im.match(doc_link)[1,2] + @home_button_links[a_idx]= { say: say, url: url } + a_idx +=1 + end + end + @home_button_links + end + if defined? @make.home_button_image \ + and @make.home_button_image.is_a?(Hash) + @home_button_image=@make.home_button_image + end + if defined? @make.cover_image \ + and @make.cover_image.is_a?(Hash) + @cover_image=@make.cover_image + end + { pagenew: @pagenew, + pagebreak: @pagebreak, + pageline: @pageline, + toc: @toc, + lv1: @lv1, + lv2: @lv2, + lv3: @lv3, + lv4: @lv4, + lv5: @lv5, + lv6: @lv6, + num_top: @num_top, + i18n: @i18n, + emphasis_set_to: @emphasis_set_to, + bold_match_list: @bold_match_list, + italics_match_list: @italics_match_list, + substitution_match_list: @substitution_match_list, + man_section: @man_section, + footer_links: @footer_links, + home_button_links: @home_button_links, + home_button_image: @home_button_image, + cover_image: @cover_image, + } + end + end +end +__END__ diff --git a/lib/sisu/v6/embedded.rb b/lib/sisu/v6/embedded.rb index cf294891..2405f9e7 100644 --- a/lib/sisu/v6/embedded.rb +++ b/lib/sisu/v6/embedded.rb @@ -61,9 +61,9 @@ =end module SiSU_Embedded - require_relative 'param' # param.rb + require_relative 'dp' # dp.rb include SiSU_Param - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env class Source def initialize(opt) diff --git a/lib/sisu/v6/errors.rb b/lib/sisu/v6/errors.rb index fb5117ec..4fb18f4e 100644 --- a/lib/sisu/v6/errors.rb +++ b/lib/sisu/v6/errors.rb @@ -61,7 +61,7 @@ =end module SiSU_Errors - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env; include SiSU_Screen class Rescued . + + 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: + + + * Git + + + + * Ralph Amissah + + + + ** Description: system environment, resource control and configuration details + +=end +module SiSU_FormatAuthor + 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=a.strip + if a =~/"(.+?)"/ + @authors << { the: $1 } + @author_array << $1.upcase + else #if a =~/,/ + x=a.scan(/[^,]+/) + x[0]=x[0].strip + x[1]=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/v6/harvest_authors.rb b/lib/sisu/v6/harvest_authors.rb index c84634b5..15c65813 100644 --- a/lib/sisu/v6/harvest_authors.rb +++ b/lib/sisu/v6/harvest_authors.rb @@ -62,7 +62,7 @@ =end module SiSU_HarvestAuthors - require_relative 'author_format' # author_format.rb + require_relative 'harvest_author_format' # harvest_author_format.rb class Songsheet @@the_idx_authors={} def initialize(opt,env) diff --git a/lib/sisu/v6/harvest_topics.rb b/lib/sisu/v6/harvest_topics.rb index e17b8424..c827bbbf 100644 --- a/lib/sisu/v6/harvest_topics.rb +++ b/lib/sisu/v6/harvest_topics.rb @@ -63,7 +63,7 @@ =end module SiSU_HarvestTopics - require_relative 'author_format' # author_format.rb + require_relative 'harvest_author_format' # harvest_author_format.rb include SiSU_Viz class Songsheet @@the_idx_topics={} diff --git a/lib/sisu/v6/html.rb b/lib/sisu/v6/html.rb index 1f6b787d..581c3e5e 100644 --- a/lib/sisu/v6/html.rb +++ b/lib/sisu/v6/html.rb @@ -66,7 +66,7 @@ module SiSU_HTML rescue LoadError SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('pstore NOT FOUND (LoadError)') end - require_relative 'particulars' # particulars.rb + require_relative 'se_hub_particulars' # se_hub_particulars.rb include SiSU_Particulars require_relative 'defaults' # defaults.rb include SiSU_Viz diff --git a/lib/sisu/v6/html_concordance.rb b/lib/sisu/v6/html_concordance.rb index 0f87ee0b..55bdfb6c 100644 --- a/lib/sisu/v6/html_concordance.rb +++ b/lib/sisu/v6/html_concordance.rb @@ -62,9 +62,9 @@ =end module SiSU_Concordance - require_relative 'particulars' # particulars.rb + require_relative 'se_hub_particulars' # se_hub_particulars.rb include SiSU_Particulars - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env require_relative 'defaults' # defaults.rb include SiSU_Viz @@ -212,7 +212,7 @@ WOK include SiSU_Viz require_relative 'html_format' # html_format.rb include SiSU_HTML_Format - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Screen @@dp=nil def initialize(particulars) diff --git a/lib/sisu/v6/html_lite_shared.rb b/lib/sisu/v6/html_lite_shared.rb index 7ae17350..8eace556 100644 --- a/lib/sisu/v6/html_lite_shared.rb +++ b/lib/sisu/v6/html_lite_shared.rb @@ -66,7 +66,7 @@ module SiSU_FormatShared include SiSU_Viz class CSS_Format require_relative 'defaults' # defaults.rb - require_relative 'particulars' # particulars.rb + require_relative 'se_hub_particulars' # se_hub_particulars.rb @@fns=nil def initialize(md,t_o) @md,@t_o=md,t_o diff --git a/lib/sisu/v6/html_promo.rb b/lib/sisu/v6/html_promo.rb index e2832d3c..c216af9f 100644 --- a/lib/sisu/v6/html_promo.rb +++ b/lib/sisu/v6/html_promo.rb @@ -61,7 +61,7 @@ =end module SiSU_HTML_Promo - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env class Ad def initialize(md) diff --git a/lib/sisu/v6/html_tune.rb b/lib/sisu/v6/html_tune.rb index 42568a36..afd6f604 100644 --- a/lib/sisu/v6/html_tune.rb +++ b/lib/sisu/v6/html_tune.rb @@ -60,9 +60,9 @@ ** Description: html generation, html pre-processing =end -require_relative 'param' +require_relative 'dp' # dp.rb module SiSU_HTML_Tune - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env; include SiSU_Screen require_relative 'html_format' # html_format.rb #watch @@line_mode='' diff --git a/lib/sisu/v6/hub.rb b/lib/sisu/v6/hub.rb index e061ee46..9ebb42d9 100644 --- a/lib/sisu/v6/hub.rb +++ b/lib/sisu/v6/hub.rb @@ -63,11 +63,11 @@ =end module SiSU require_relative 'constants' # constants.rb - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env include SiSU_Screen - require_relative 'options' # options.rb - require_relative 'param' # param.rb + require_relative 'hub_options' # hub_options.rb + require_relative 'dp' # dp.rb include SiSU_Param require_relative 'defaults' # defaults.rb include SiSU_Viz @@ -599,10 +599,10 @@ module SiSU else end if @opt.act[:urls_selected][:set]==:on #% --sitemap, -Y - require_relative 'urls' - OptionLoopFiles.new(@opt).loop_files_on_given_option do - SiSU_Urls::Source.new(@opt).read #% -u -v -V -M - end + require_relative 'urls' + OptionLoopFiles.new(@opt).loop_files_on_given_option do + SiSU_Urls::Source.new(@opt).read #% -u -v -V -M + end end end def do_initialization diff --git a/lib/sisu/v6/hub_options.rb b/lib/sisu/v6/hub_options.rb new file mode 100644 index 00000000..f851b985 --- /dev/null +++ b/lib/sisu/v6/hub_options.rb @@ -0,0 +1,1399 @@ +# encoding: utf-8 +=begin + + * Name: SiSU + + * Description: a framework for document structuring, publishing and search + + * Author: Ralph Amissah + + * Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. + + * License: GPL 3 or later: + + SiSU, a framework for document structuring, publishing and search + + Copyright (C) Ralph Amissah + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along with + this program. If not, see . + + 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: + + + * Git + + + + * Ralph Amissah + + + + ** Description: SiSU information Structuring Universe, command line options + parsing + +=end +module SiSU_Commandline + begin + require 'pathname' + rescue LoadError + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('pathname NOT FOUND (LoadError)') + end + require_relative 'se' # se.rb + require_relative 'dp_make' # dp_make.rb + class HeaderCommon + def sisu_document_make_instructions(make_instruct_array=:nil) + @pagenew= + @pagebreak= + @pageline= + @toc= + @lv1=@lv2=@lv3=@lv4=@lv5=@lv6= + @num_top= + @i18n= + @man_section= + @emphasis_set_to= + @bold_match_list= + @italics_match_list= + @substitution_match_list= + @footer_links= + @home_button_links= + @links= + nil + make_instruct_array=make_instruct_array==:nil \ + ? SiSU_Env::GetInit.new.sisu_document_make.makefile_read + : make_instruct_array + @makeset=false + if make_instruct_array + make_instruct_array.each do |para| #% scan document + if para =~/^(?:@make:|@links:)[+-]?\s/ + case para + when /^@make:(.+)/m #% header processing - make + @env=SiSU_Env::InfoEnv.new + @make=SiSU_Param_Make::MdMake.new($1.strip,@opt,@env).make + makes=SiSU_Param_Make::MakeHead.new(@make).make_instruct + @makeset=true + @pagenew=makes[:pagenew] + @pagebreak=makes[:pagenew] + @pageline=makes[:pageline] + @toc=makes[:toc] + @lv1=makes[:lv1] + @lv2=makes[:lv2] + @lv3=makes[:lv3] + @lv4=makes[:lv4] + @lv5=makes[:lv5] + @lv6=makes[:lv6] + @num_top=makes[:num_top] + @i18n=makes[:i18n] + @man_section=makes[:man_section] + @emphasis_set_to=makes[:emphasis_set_to] + @bold_match_list=makes[:bold_match_list] + @italics_match_list=makes[:italics_match_list] + @substitution_match_list=makes[:substitution_match_list] + @footer_links=makes[:footer_links] + @home_button_links=makes[:home_button_links] + @home_button_image=makes[:home_button_image] + @cover_image=makes[:cover_image] + when /^@links:(.+)/m #% header processing - make + make_links=SiSU_Param::Parameters::MdMake.new($1.strip,@opt,@env).make_links + @links,@links_append=make_links.links,make_links.append? + end + end + end #% here endeth the common header loop + end + { makeset: @makeset, + pagenew: @pagenew, + pagebreak: @pagebreak, + pageline: @pageline, + toc: @toc, + lv1: @lv1, + lv2: @lv2, + lv3: @lv3, + lv4: @lv4, + lv5: @lv5, + lv6: @lv6, + num_top: @num_top, + i18n: @i18n, + man_section: @man_section, + emphasis_set_to: @emphasis_set_to, + bold_match_list: @bold_match_list, + italics_match_list: @italics_match_list, + substitution_match_list: @substitution_match_list, + footer_links: @footer_links, + home_button_links: @home_button_links, + home_button_image: @home_button_image, + cover_image: @cover_image, + links: @links, + links_append: @links_append + } + end + end + class Options + attr_accessor :cmd,:mod,:act,:dir_structure_by,:lingual,:f_pths,:files,:files_mod,:call_path,:base_path,:base_stub,:sub_location,:image_src_path,:paths,:lngs,:f_pth,:pth,:fno,:fns,:fnb,:fnc,:fng,:fncb,:lng,:lng_base,:what,:make_instructions,:make_instructions_pod + @@act=nil + def initialize(a,call_path) + @cmd=@f_pth=@pth=@fno=@fns=@fnb=@fnc=@fng=@fncb=@what=@lng=@lng_base=@call_path=@base_path=@base_stub=@image_src_path=@sub_location='' + @f_pths,@files,@files_mod,@paths,@mod,@act=Array.new(5){[]} + @env=SiSU_Env::InfoEnv.new + @lng_base=@env.language_default_set + @dir_structure_by=SiSU_Env::EnvCall.new.output_dir_structure.by? + @lingual=SiSU_Env::EnvCall.new.mono_multi_lingual? + @call_path=call_path + pth=SiSU_Utils::Path.new(call_path) + @base_path=pth.base_markup + @base_stub=pth.base_markup_stub + @image_src_path=pth.image_src + @a=sisu_glob_rules(a) + @a.freeze + @make_instructions=HeaderCommon.new.sisu_document_make_instructions + @make_instructions_pod=nil + init + end + def find_all(find_flag,opt) + if find_flag + x=Dir.glob('*.ss[tm]') + Px[:lng_lst].each do |d| + if FileTest.directory?(d) + x << Dir.glob("#{d}/*.ss[tm]") + end + end + x=x.flatten + opt + x + end + end + def find_select(find_flag,opt) + if find_flag + x=[] + if opt.inspect =~/"[a-zA-Z][a-zA-Z0-9._-]+?"/ + opt.each do |g| + x <<=if g =~/.ss[tm]/ + Dir.glob("*#{g}") + else + Dir.glob("*#{g}*.ss[tm]") + end + Px[:lng_lst].each do |d| + if FileTest.directory?(d) + x <<=if g =~/.ss[tm]/ + Dir.glob("#{d}/*#{g}") + else + Dir.glob("#{d}/*#{g}*.ss[tm]") + end + end + end + end + end + x.flatten + end + end + def sisu_glob_rules(a) + a=if a.inspect =~/"-[A-Za-z0-9]*[fG]/ \ + or a.inspect =~/"--find"|"--glob"/ + b,f=[],[] + find_flag=false + a.each do |y| + if y =~ /^-/ + if y =~/^-/ \ + && y =~/[fG]|--find|--glob/ + find_flag=true + end + b << y + end + if find_flag \ + && y !~ /^-/ \ + && y =~ /\S+/ + if y !~/\// + f << y + else + find_flag=false + puts %{sub-directories "#{y}" cannot be provided for --find or --glob at this time} + end + end + end + r=Px[:lng_lst_rgx].gsub(/\|#{lng_base}\|/,'|') + @lang_regx=%r{(?:#{r})} + if find_flag + (f.length > 0) \ + ? (b + find_select(find_flag,f)) + : find_all(find_flag,b) + elsif a.inspect =~/"(?:-\S+?|--\S+?)"/ \ + && a.inspect =~/"#{@lang_regx}\/?"/ \ + && a.inspect =~/"#{lng_base}\/\S+?\.ss[tm]"/ + init_selected_lang_dirs(a) + else b + end + else a + end + end + def init_selected_lang_dirs(a) + @z=[] + a.each do |y| + if y =~/^#{lng_base}\/(\S+?\.ss[tm])$/ + @fn=$1 + @z << y + elsif y =~/^#{@lang_regx}\/?$/ + @z << "#{y}/#{@fn}" + else @z << y + end + end + @z + end + def init + a=@a + if a.length > 0 + s=expand_numeric_shortcuts(a) + q=set_files_and_paths_and_general_extract(s) + @cmd,@mod=opt_cmd_and_mod_adjust(q[:cmd],q[:mod]) + @what=q[:what] unless q[:what].empty? + @paths = q[:paths] + @files = q[:files] + @f_pths = q[:f_pths] + @lngs = q[:lngs] + if @files.length > 0 \ + and @cmd.empty? \ + and @mod.length==0 #% if no other action called on filename given, default is sisu --v5 -0 [filename(s)] configured as flag default + shortcut=SiSU_Env::InfoProcessingFlag.new + @mod=['--v5'] + @cmd=shortcut.cf_0 + ' --dal' + end + if @cmd =~/[vVM]/ \ + && @cmd !~/-[ku]*v[ku]*$/ + SiSU_Screen::Ansi.new( + @cmd, + "\tsisu " + @cmd + ' ' + @mod.join(' ') + ' ' + @files.join(' ') + "\n" + ).print_brown + end + end + @@act ? @act=@@act : @@act=@act=opt_act + self + end + def sisu_document_make_pod + def makefile_name + SiSU_Env::GetInit.new.sisu_document_make.makefile_name + end + def makefile(pod_make_path) + "#{pod_make_path}/#{makefile_name}" + end + def makefile_read(pod_make_path) + if FileTest.file?(makefile(pod_make_path)) + sisu_doc_makefile=IO.read(makefile(pod_make_path), mode: 'r:utf-8') + sisu_doc_makefile.split(/\s*\n\s*\n/m) + else nil + end + end + self + end + def set_files_and_paths_and_general_extract(s) + c,w='','' + m,f,pth,lng,lngs=[],[],[],[],[] + lng_is='' + a=s.split(/\s+/) + r_l=Px[:lng_lst].join('|') + a.uniq.each do |x| + if x =~/^-[a-z0-5]+/i \ + or x =~/^--\S+/ + if x =~/^-([a-z0-5]+)/i + c << $1 + end + if x =~/^--\S+/ + m << x + end + elsif x =~ /(?:\.(?:(?:-|ssm\.)?sst(?:\.xml)?|ssm|ssi|sx[sdn]\.xml|s[1-3]|kdi|ssp)|\S+?\.ss[mt]\.(?:txz|zip)|sisupod\.(?:txz|zip))$/ + if x =~/\S+?\.ss[mt]\.(?:txz|zip)|sisupod\.(?:txz|zip)/ + if x =~/^(?:https?|file):\/\/\S+/ #\ + end + pwd=Dir.pwd + fn_pod=x.gsub(/([^\/]+)\.txz$/,'\1') + fullname=@env.processing_path.processing + '/sisupod/' + fn_pod + pt=Pathname.new(fullname) + FileUtils::mkdir_p(pt.to_s) + pod_make_path=fullname + '/sisupod/doc/_sisu' + make_instruct_array=sisu_document_make_pod.makefile_read(pod_make_path) + @make_instructions_pod= + HeaderCommon.new.sisu_document_make_instructions(make_instruct_array) + Dir.chdir(pt.realpath) + system(" + chdir #{fullname} + tar xaf #{pwd}/#{x} + chdir #{pwd} + ") + Dir.chdir(pt.realpath.to_s + '/sisupod/doc') + r=Px[:lng_lst_rgx] + Dir.entries("#{fullname}/sisupod/doc").each do |d_lng| + if d_lng =~/^(?:#{r})$/ + Dir.chdir(pt.realpath.to_s + "/sisupod/doc/#{d_lng}") + filenames=Dir.glob("*.ss[mt]") + filenames.each do |fn| + f_pths << { + pth: "#{fullname}/sisupod/doc/#{d_lng}", + f: "#{fn}", + pth_stub: 'doc', + lng: d_lng, + lng_is: d_lng, + url_base: '', + url: '' + } + Dir.chdir(pwd) + f << fn + end + end + end + elsif x =~/^(?:https?|file):\/\/\S+/ \ + and x =~/\S+?\.ss[mt]$/ + r_url=/(http:\/\/\S+?\/\S+?\/src(?:\/(?:#{r_l}))?)\// + url_base = (x[r_url,1]) + url = x + y=x.gsub(/http:\/\/\S+?\/\S+?\/src\//,'') + t=/(#{r_l})\/[^\/]+?\.ss[tm]$/ + l_p = (y[t,1]) \ + ? y[t,1] + : nil + lng << l_p + lngs << if l_p + l_p + elsif x =~/~(#{r_l})\.ss[tm]/ + $1 + else lng_base + end + r_f=/(?:#{r_l})\/([^\/]+?\.ss[tm])$/ + fn = (y[r_f,1]) \ + ? y[r_f,1] + : y + fn=fn.gsub(/\.((?:ssm\.)?sst)/,'.-\1') + fullname=Dir.pwd + '/' + fn + pt=Pathname.new(fullname) + pth << Dir.pwd + r_u=/.+?\/([^\/]+)(?:\/(?:#{r_l})$|$)/ + lng_is =if l_p + l_p + elsif x =~/~(#{r_l})\.ss[tm]/ + $1 + else lng_base + end + f_pths << { + pth: pt.split[0].realpath.to_s, + f: pt.split[1].to_s, + pth_stub: pt.split[0].realpath.to_s[r_u,1], + lng: (pt.split[0].realpath.to_s[t,1]) \ + ? pt.split[0].realpath.to_s[t,1] + : nil, + lng_is: lng_is, + url_base: url_base, + url: url + } + f << fn + elsif FileTest.file?(x) + pt=Pathname.new(x) + pth << pt.split[0].realpath.to_s #remove? + f << pt.split[1].to_s #remove? + r_u=/.+?\/([^\/]+)(?:\/(?:#{r_l})$|$)/ + t=/.+\/(#{r_l})$/ + l_p = (pt.split[0].realpath.to_s[t,1]) \ + ? pt.split[0].realpath.to_s[t,1] + : nil + lngs << lng_is = if l_p + l_p + elsif x =~/~(#{r_l})\.ss[tm]/ + $1 + else lng_base + end + f_pths << { + pth: pt.split[0].realpath.to_s, + f: pt.split[1].to_s, + pth_stub: pt.split[0].realpath.to_s[r_u,1], + lng: lng_is, + lng_is: lng_is, + url_base: nil, + url: nil, + } + else puts "file not found: #{x}" + end + elsif x =~ /\.termsheet\.rb$/ + (FileTest.file?(x)) \ + ? (f << x) + : (puts "file not found: #{x}") + else w=x + puts "#{x} in #{a.join(' ')}?" + end + end + { + cmd: c, + mod: m, + what: w, + paths: pth, + files: f, + f_pths: f_pths, + lng: lng_is, + lngs: lngs, + } + end + def expand_numeric_shortcuts(a) + shortcut=SiSU_Env::InfoProcessingFlag.new + s='' + a.each do |x| + y=case x + when /0/ + (x=~/^-0\S+/) \ + ? x.gsub(/^-0(\S+)/,shortcut.cf_0 + ' -\1') + : x.gsub(/^-0/,shortcut.cf_0 + ' ') + when /1/ + (x=~/^-1\S+/) \ + ? x.gsub(/^-1(\S+)/,shortcut.cf_1 + ' -\1') + : x.gsub(/^-1/,shortcut.cf_1 + ' ') + when /2/ + (x=~/^-2\S+/) \ + ? x.gsub(/^-2(\S+)/,shortcut.cf_2 + ' -\1') + : x.gsub(/^-2/,shortcut.cf_2 + ' ') + when /3/ + (x=~/^-3\S+/) \ + ? x.gsub(/^-3(\S+)/,shortcut.cf_3 + ' -\1') + : x.gsub(/^-3/,shortcut.cf_3 + ' ') + when /4/ + (x=~/^-4\S+/) \ + ? x.gsub(/^-4(\S+)/,shortcut.cf_4 + ' -\1') + : x.gsub(/^-4/,shortcut.cf_4 + ' ') + when /5/ + (x=~/^-5\S+/) \ + ? x.gsub(/^-5(\S+)/,shortcut.cf_5 + ' -\1') + : x.gsub(/^-5/,shortcut.cf_5 + ' ') + when /6/ + (x=~/^-6\S+/) \ + ? x.gsub(/^-6(\S+)/,shortcut.cf_5 + ' -\1') + : x.gsub(/^-6/,shortcut.cf_5 + ' ') + else x + end + s << " #{y}" unless y.empty? + end + s.strip! + end + def opt_cmd_and_mod_adjust(c,m) + cmd,mod,files=@cmd,@mod,@files + if not m.empty? \ + and m.inspect =~/"--pdf-/ + mod << '--pdf' + m.each do |s| + if s =~ /^--pdf-(?:(?:l|landscape)(?:-(?:a4|letter|a5|b5|legal))?|(?:a4|letter|a5|b5|legal)-(?:l|landscape))$/ + mod << '--landscape' + end + if s =~ /^--pdf-(?:(?:p|portrait)(?:-(?:a4|letter|a5|b5|legal))?|(?:a4|letter|a5|b5|legal)-(?:p|portrait))$/ + mod << '--portrait' + end + if s =~ /^--pdf(?:-(?:a4|letter|a5|b5|legal)(?:-(?:[lp]|landscape|portrait))?|(?:-(?:[lp]|landscape|portrait))(?:-(?:a4|letter|a5|b5|legal)))$/ + if s =~ /^--pdf(?:-a4(?:-(?:[lp]|landscape|portrait))?|(?:-(?:[lp]|landscape|portrait))-a4)$/ + mod << '--papersize-a4' + end + if s =~ /^--pdf(?:-a5(?:-(?:[lp]|landscape|portrait))?|(?:-(?:[lp]|landscape|portrait))-a5)$/ + mod << '--papersize-a5' + end + if s =~ /^--pdf(?:-b5(?:-(?:[lp]|landscape|portrait))?|(?:-(?:[lp]|landscape|portrait))-b5)$/ + mod << '--papersize-b5' + end + if s =~ /^--pdf(?:-letter(?:-(?:[lp]|landscape|portrait))?|(?:-(?:[lp]|landscape|portrait))-letter)$/ + mod << '--papersize-letter' + end + if s =~ /^--pdf(?:-legal(?:-(?:[lp]|landscape|portrait))?|(?:-(?:[lp]|landscape|portrait))-legal)$/ + mod << '--papersize-legal' + end + end + end + mod=mod.uniq + end + unless m.empty? + m.each do |s| + case s + when /^--(?:color-toggle)$/ then c=c+'c' + when /^--(?:color-off)$/ then c=c+'k' + when /^--(?:conf|config|configure|init|initialize|init-site)$/ then c=c+'CC' + when /^--(?:ao|dal?|machine|abstraction|abs)$/ then c=c+'m' + when /^--(?:txt|text|plaintext)$/ then c=c+'t' + when /^--(?:html)$/ then c=c+'h' + when /^--(?:html-scroll|html-seg)$/ then c=c+'H' + mod << s + when /^--(?:epub)$/ then c=c+'e' + when /^--(?:od[ft])$/ then c=c+'o' + when /^--docbook$/ then c=c+'d' + when /^--(?:pdf)$/ then c=c+'p' + when /^--pdf-(?:a4|a5|b5|legal|letter)$/ then c=c+'p' + when /^--pdf-(?:p|l|portrait|landscape)$/ then c=c+'L' + when /^--pdf-(?:p(?:ortrait)?|l(?:andscape)?)-(?:a4|letter|a5|b5|legal)$/ then c=c+'L' + when /^--pdf-(?:a4|letter|a5|b5|legal)-(?:p(?:ortrait)?|l(?:andscape)?)$/ then c=c+'L' + when /^--(?:concordance|wordmap)$/ then c=c+'w' + when /^--(?:manpage|man)$/ then c=c+'i' + when /^--(?:texinfo)$/ then c=c+'I' + when /^--(?:xhtml)$/ then c=c+'b' + when /^--(?:xml-sax)$/ then c=c+'x' + when /^--(?:xml-dom)$/ then c=c+'X' + when /^--(?:images)$/ then c=c+'j' + when /^--(?:digests?|hash-digests)$/ then c=c+'N' + when /^--(?:po4a|pot?)$/ then c=c+'P' + when /^--(?:termsheet)$/ then c=c+'T' + when /^--(?:manifest)$/ then c=c+'y' + when /^--(?:qrcode)$/ then c=c+'Q' + when /^--(?:remote|rsync)$/ then c=c+'R' + when /^--(?:scp)$/ then c=c+'r' + when /^--(?:source)$/ then c=c+'s' + when /^--(?:sisupod|pod)$/ then c=c+'S' + when /^--(?:git)$/ then c=c+'g' + when /^--(?:urls)$/ then c=c+'U' + when /^--(?:zap|delete)$/ then c=c+'Z' + when /^--(?:sample-search-form)$/ then c=c+'F' + when /^--(?:webserv|webrick)$/ then c=c+'W' + when /^--(?:profile)$/ then c=c+'E' + when /^--(?:maintenance|keep-processing-files)$/ then c=c+'M' + when /^--(?:verbose[=-]3)$/ then c=c+'VM' + when /^--(?:verbose[=-]2|Verbose|VERBOSE)$/ then c=c+'V' + when /^--(?:verbose(?:[=-]1)?)$/ then c=c+'v' + when /^--(?:version)$/ then c=c+'v' + when /^--(?:verbose[=-]0|quiet|silent)$/ then c=c+'q' + else mod << s #mod only contains command modifiers; commands converted to character + end + end + end + ca=[] + unless c.empty? + c=c.gsub(/-/,'') + c.scan(/CC|\S/) {|x| ca << x} + cmd= '-' + ca.uniq.join + end + extra='' + if cmd !~/[mn]/ + extra+=if cmd =~/[abegHhIiLNOoPpQTtwXxyz]/ \ + and cmd !~/[mn]/ + 'm' #% add ao + elsif ((mod.inspect =~/--(?:(?:sq)?lite|pg(?:sql)?)/) \ + and mod.inspect !~/(?:remove|(?:(?:re)?create(?:all)?|dropall|drop)$)/) \ + and cmd !~/[mn]/ + 'm' #% add ao + else '' + end + end + if cmd !~/j/ + extra+=if cmd =~/[bdHhwXxyz]/ \ + and cmd !~/[j]/ + 'j' #% copy images + else '' + end + end + if cmd !~/y/ + extra+=if cmd =~/[abdeHhIiNopQSstwXxz]/ \ + and cmd !~/y/ + 'ym' #% add manifest + elsif mod.inspect =~/--(?:(?:sq)?lite|pg(?:sql)?)/ \ + and files[0] !~/^remove$/ \ + and cmd !~/y/ + 'ym' #% add manifest + else '' + end + end + if cmd !~/u/ #% add urls + extra+='u' + end + cmd=cmd + extra + cmds=cmd.scan(/CC|\S/) + [cmds.uniq.join,mod] + end + def opt_act #note mod line commands have already been converted to command characters, cmd + cmd,mod=@cmd,@mod + @@act=if @@act + @act=@@act + else + act={} + act[:license]=(mod.inspect =~/"--license/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:site_init]=(cmd =~/C/ \ + || mod.inspect =~/"--init"|"--initialize"|"--init-site"|"--conf"|"--config"|"--configure"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:rc]=if mod.inspect =~/"--rc=/ + x=Dir.pwd + '/' + mod.join.gsub(/--rc=/,'') + { bool: true, set: :on, inst: x } + else + { bool: false, set: :na, inst: '' } + end + act[:processing_path]=if mod.inspect =~/"--processing-path=/ + base_pth=mod.join(';').gsub(/^.*--processing-path=['"]?(.+?)(?:['"]?;.+)?$/,'\1') + { bool: true, set: :on, inst: base_pth } + elsif mod.inspect =~/"--processing-path/ + { bool: true, set: :on, inst: @base_path } + else + { bool: false, set: :na, inst: nil } + end + act[:dump]=if mod.inspect =~/"--dump=/ + base_pth=mod.join(';').gsub(/^.*--dump=['"]?(.+?)(?:['"]?;.+)?$/,'\1') + { bool: true, set: :on, inst: base_pth } + elsif mod.inspect =~/"--dump/ + { bool: true, set: :on, inst: @base_path } + else + { bool: false, set: :na, inst: nil } + end + act[:redirect]=if mod.inspect =~/"--redirect=/ + base_pth=mod.join(';').gsub(/^.*--redirect=['"]?(.+?)(?:['"]?;.+)?$/,'\1') + { bool: true, set: :on, inst: base_pth } + elsif mod.inspect =~/"--redirect/ + { bool: true, set: :on, inst: @base_path } + else + { bool: false, set: :na, inst: nil } + end + act[:switch]=if mod.inspect =~/"--switch-off=/ + off_list=mod.join(';').gsub(/^.*--switch-off=['"]?(.+?)(?:['"];.+)?$/,'\1') + off_list=off_list.scan(/[^,;\s]+/) + { bool: false, set: :off, off: off_list} + else { bool: true, set: :na, off: [] } + end + act[:default_language]=if mod.inspect =~/"--(?:default-)?language[-=](\S{2})"/ + { set: :on, code: $1 } + elsif lng_base + { set: :on, code: lng_base } + else { set: :na, code: 'en' } + end + act[:i18n]=if mod.inspect =~/"(?:--monolingual|--i18n-mono(?:lingual)?)"/ #if monolingual possible outputs output_by :filename & :filetype only, without language code in default language name; give warning of conflict settings if monolingual & :language selected + @lingual=:mono + { set: :mono } + elsif mod.inspect =~/"(?:--multilingual|--i18n-multi(?:lingual)?)"/ + @lingual=:multi + { set: :multi } + else { set: :na } + end + act[:output_by]=if mod.inspect =~/"--(?:output-)?by-language"/ + @dir_structure_by=:language + { set: :language } + elsif mod.inspect =~/"--(?:output-)?by-filename"/ + @dir_structure_by=:filename + { set: :filename } + elsif mod.inspect =~/"--(?:output-)?by-filetype"/ + @dir_structure_by=:filetype + { set: :filetype } + else { set: :na } + end + act[:ocn]=if mod.inspect =~/"--ocn"|"--inc-ocn"|"--numbering"|"--inc-numbering"/ + { bool: true, set: :on } + elsif mod.inspect =~/"--no-ocn"|"--exc-ocn"|"--no-numbering"|"--exc-numbering"/ \ + || act[:switch][:off].inspect =~/"ocn"|"--numbering"/ + { bool: false, set: :off } + else { bool: true, set: :na } + end + act[:toc]=if mod.inspect =~/"--inc-toc"/ + { bool: true, set: :on } + elsif mod.inspect =~/"--(?:exc|no)-toc"/ \ + || act[:switch][:off].inspect =~/"toc"/ + { bool: false, set: :off } + else { bool: true, set: :na } + end + act[:minitoc]=if mod.inspect =~/"--inc-minitoc"/ + { bool: true, set: :on } + elsif mod.inspect =~/"--(?:exc|no)-minitoc"/ \ + || act[:switch][:off].inspect =~/"minitoc"/ + { bool: false, set: :off } + else { bool: true, set: :na } + end + act[:links_to_manifest]=if mod.inspect =~/"--inc-links-to-manifest"|"--inc-manifest-links"/ + { bool: true, set: :on } + elsif mod.inspect =~/"--(?:exc|no)-manifest"/ \ + || act[:switch][:off].inspect =~/"manifest"/ #place lower + { bool: false, set: :off } + elsif mod.inspect =~/"--(?:exc|no)-links-to-manifest"|"--(?:exc|no)-manifest-links"/ \ + || act[:switch][:off].inspect =~/"links_to_manifest"|"manifest_links"|"--(?:exc|no)-manifest"/ \ + || mod.inspect =~/"--(?:redirect|dump)/ + { bool: false, set: :off } + else { bool: true, set: :na } + end + act[:manifest_minitoc]=if mod.inspect =~/"--inc-manifest-minitoc"|"--inc-minitoc"/ + { bool: true, set: :on } + elsif mod.inspect =~/"--(?:exc|no)-manifest-minitoc"|"--(?:exc|no)-minitoc"/ \ + || act[:switch][:off].inspect =~/"manifest_minitoc"|"minitoc"/ + #|| mod.inspect =~/"--(?:redirect|dump)/ + { bool: false, set: :off } + else { bool: true, set: :na } + end + act[:metadata]=if mod.inspect =~/"--inc-metadata"/ + { bool: true, set: :on } + elsif mod.inspect =~/"--(?:exc|no)-metadata"/ \ + || act[:switch][:off].inspect =~/"metadata"/ + { bool: false, set: :off } + else { bool: true, set: :na } + end + act[:html_minitoc]=if mod.inspect =~/"--inc-html-minitoc"|"--inc-minitoc"/ + { bool: true, set: :on } + elsif mod.inspect =~/"--(?:exc|no)-html-minitoc"|"--(?:exc|no)-minitoc"/ \ + || act[:switch][:off].inspect =~/"html_minitoc"|"minitoc"/ + { bool: false, set: :off } + else { bool: true, set: :na } + end + act[:html_navigation]=if mod.inspect =~/"--inc-html-navigation"|"--inc-navigation"/ + { bool: true, set: :on } + elsif mod.inspect =~/"--(?:exc|no)-html-navigation"|"--(?:exc|no)-navigation"/ \ + || act[:switch][:off].inspect =~/"html_navigation"|"nav"/ + { bool: false, set: :off } + else { bool: true, set: :na } + end + act[:html_navigation_bar]=if mod.inspect =~/"--inc-html-navigation-bar"|"--inc-navigation-bar"/ + { bool: true, set: :on } + elsif mod.inspect =~/"--(?:exc|no)-html-navigation-bar"|"--(?:exc|no)-navigation-bar"/ \ + || act[:switch][:off].inspect =~/"html_navigation_bar"|"navbar"/ + { bool: false, set: :off } + else { bool: true, set: :na } + end + act[:segsubtoc]=if mod.inspect =~/"--inc-segsubtoc"/ + { bool: true, set: :on } + elsif mod.inspect =~/"--(?:exc|no)-segsubtoc"/ \ + || act[:switch][:off].inspect =~/"segsubtoc"/ + { bool: false, set: :off } + else { bool: true, set: :na } + end + act[:search_form]=if mod.inspect =~/"--inc-search-form"/ + { bool: true, set: :on } + elsif mod.inspect =~/"--(?:exc|no)-search-form"/ \ + || act[:switch][:off].inspect =~/"search_form"|"search"/ + { bool: false, set: :off } + else { bool: true, set: :na } + end + act[:html_search_form]=if mod.inspect =~/"--inc-html-search-form"|"--inc-search-form"/ + { bool: true, set: :on } + elsif mod.inspect =~/"--(?:exc|no)-html-search-form"|"--(?:exc|no)-search-form"/ \ + || act[:switch][:off].inspect =~/"html_search_form"|"search_form"|"search"/ + { bool: false, set: :off } + else { bool: true, set: :na } + end + act[:html_right_pane]=if mod.inspect =~/"--inc-html-right-pane"|"--inc-right-pane"|"--inc-html-right-column"|"--inc-right-column"/ + { bool: true, set: :on } + elsif mod.inspect =~/"--(?:exc|no)-html-right-pane"|"--(?:exc|no)-right-pane"|"--(?:exc|no)-html-right-column"|"--(?:exc|no)-right-column"/ \ + || act[:switch][:off].inspect =~/"html_right_pane"|"html_right_column"|"promo"/ + { bool: false, set: :off } + else { bool: true, set: :na } + end + act[:html_top_band]=if mod.inspect =~/"--inc-html-top-band"|"--inc-top-band"/ + { bool: true, set: :on } + elsif mod.inspect =~/"--(?:exc|no)-html-top-band"|"--(?:exc|no)-top-band"/ \ + || act[:switch][:off].inspect =~/"html-top-band"|"top-band"/ + { bool: false, set: :off } + else { bool: true, set: :na } + end + act[:html]=if mod.inspect =~/"--html-strict"/ \ + or ((cmd =~/h/ || mod.inspect =~/"--html"/) \ + && mod.inspect =~/"--strict"/) + act[:html_strict]={ bool: true, set: :on } + act[:html_scroll]={ bool: true, set: :on } + act[:html_seg]={ bool: true, set: :on } + { bool: true, set: :on } + elsif (cmd =~/h/ \ + || mod.inspect =~/"--html"/) + act[:html_strict]={ bool: false, set: :off } + act[:html_scroll]={ bool: true, set: :on } + act[:html_seg]={ bool: true, set: :on } + { bool: true, set: :on } + else + act[:html_strict]=(mod.inspect =~/"--strict"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:html_scroll]=(mod.inspect =~/"--html-scroll"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:html_seg]=(mod.inspect =~/"--html-seg"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + { bool: false, set: :na } + end + act[:concordance]=(cmd =~/w/ \ + || mod.inspect =~/"--concordance"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:images]=(cmd =~/j/ \ + || mod.inspect =~/"--images"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + if (cmd =~/p/ \ + || mod.inspect =~/"--pdf"/) + if mod.inspect =~/"--portrait"/ + act[:pdf]= { bool: false, set: :na } + act[:pdf_l]={ bool: false, set: :na } + act[:pdf_p]={ bool: true, set: :on } + elsif mod.inspect =~/"--landscape"/ + act[:pdf]= { bool: false, set: :na } + act[:pdf_l]={ bool: true, set: :on } + act[:pdf_p]={ bool: false, set: :na } + else + act[:pdf]= { bool: true, set: :on } + act[:pdf_l]={ bool: true, set: :on } + act[:pdf_p]={ bool: true, set: :on } + end + else + act[:pdf]= { bool: false, set: :na } + act[:pdf_p]= { bool: false, set: :na } + act[:pdf_l]= { bool: false, set: :na } + act[:pdf_a4]= { bool: false, set: :na } + act[:pdf_a5]= { bool: false, set: :na } + act[:pdf_b5]= { bool: false, set: :na } + act[:pdf_letter]={ bool: false, set: :na } + act[:pdf_legal]= { bool: false, set: :na } + end + if act[:pdf][:set]==:on \ + or act[:pdf_p][:set]==:on \ + or act[:pdf_l][:set]==:on + act[:pdf_a4]=if mod.inspect =~/"--a4"|--papersize-a4"/ \ + or mod.inspect =~/"--papersize=\S*a4\b\S*"/ #--papersize=a4,a5 + { bool: true, set: :on } + else + { bool: false, set: :na } + end + act[:pdf_a5]=if mod.inspect =~/"--a5"|"--papersize-a5"/ \ + or mod.inspect =~/"--papersize=\S*a5\b\S*"/ #--papersize=a4,a5 + { bool: true, set: :on } + else + { bool: false, set: :na } + end + act[:pdf_b5]=if mod.inspect =~/"--b5"|"--papersize-b5"/ \ + or mod.inspect =~/"--papersize=\S*b5\b\S*"/ + { bool: true, set: :on } + else + { bool: false, set: :na } + end + act[:pdf_letter]=if mod.inspect =~/"--letter"|"--papersize-letter"/ \ + or mod.inspect =~/"--papersize=\S*letter\b\S*"/ + { bool: true, set: :on } + else + { bool: false, set: :na } + end + act[:pdf_legal]=if mod.inspect =~/"--legal"|"--papersize-legal"/ \ + or mod.inspect =~/"--papersize=\S*legal\b\S*"/ + { bool: true, set: :on } + else + { bool: false, set: :na } + end + end + act[:epub]=(cmd =~/e/ \ + || mod.inspect =~/"--epub"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:odt]=if cmd =~/o/ \ + or mod.inspect =~/"--odt"|"--odf"|"--odt-(?:ocn|numbering)"|"--odf-(?:ocn|numbering)"/ + act[:odt_ocn]=if (mod.inspect =~/"--odt-(?:ocn|numbering)"|"--odf-(?:ocn|numbering)"/ \ + or mod.inspect =~/"--ocn"|"--inc-ocn"|"--numbering"|"--inc-numbering"/) + { bool: true, set: :on } + elsif mod.inspect =~/"--no-ocn"|"--exc-ocn"|"--no-numbering"|"--exc-numbering"/ + { bool: false, set: :off } + else + { bool: false, set: :na } + end + { bool: true, set: :on } + else + { bool: false, set: :na } + end + act[:xml_sax]=(cmd =~/x/ \ + || mod.inspect =~/"--xml-sax"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:xml_dom]=(cmd =~/X/ \ + || mod.inspect =~/"--xml-dom"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:xml_docbook_book]=(cmd =~/d/ \ + || mod.inspect =~/"--docbook"|"--docbook-book"|"--xml-docbook"|"--xml-docbook_book"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:xml_fictionbook]=(cmd =~/f/ \ + || mod.inspect =~/"--fictionbook"|"--xml-fictionbook"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:xml_scaffold_structure_sisu]=mod.inspect =~/"--xml-scaffold"|"--xml-scaffold-sisu"/ \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:xml_scaffold_structure_collapse]=mod.inspect =~/"--xml-scaffold-collapse"/ \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:xhtml]=(cmd =~/b/ \ + || mod.inspect =~/"--xhtml"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:txt]=if cmd =~/[at]/ \ + or mod.inspect =~/"--txt"|"--text"|"--plaintext"|"--txt-(?:ocn|numbering)"|"--text-(?:ocn|numbering)"|"--plaintext-(?:ocn|numbering)"/ + act[:txt_ocn]=if (mod.inspect =~/"--txt-(?:ocn|numbering)"|"--text-(?:ocn|numbering)"|"--plaintext-(?:ocn|numbering)"/ \ + or mod.inspect =~/"--ocn"|"--inc-ocn"|"--numbering"|"--inc-numbering"/) + { bool: true, set: :on } + elsif mod.inspect =~/"--no-ocn"|"--exc-ocn"|"--no-numbering"|"--exc-numbering"/ + { bool: false, set: :off } + else + { bool: false, set: :na } + end + { bool: true, set: :on } + else + { bool: false, set: :na } + end + act[:txt_textile]=(mod.inspect =~/"--textile"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:txt_asciidoc]=(mod.inspect =~/"--asciidoc"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:txt_markdown]=(mod.inspect =~/"--markdown"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:txt_rst]=(mod.inspect =~/"--rst"|"--rest"|"--restructuredtext"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:manpage]=(cmd =~/i/ \ + || mod.inspect =~/"--manpage"|"--man"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:texinfo]=(cmd =~/I/ \ + || mod.inspect =~/"--texinfo"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:psql]=if mod.inspect =~/"--pg-\S+"/ \ + or ((mod.inspect =~/"--pg"/) \ + && (mod.inspect \ + =~/"--createdb"|"--create(?:all)?"|"--dropall"|"--recreate(?:all)?"|"--import"|"--update"|"--remove"/)) + act[:psql_createdb]=if mod.inspect \ + =~/"--pg-createdb"|"--createdb"/ + { bool: true, set: :on } + else + { bool: false, set: :na } + end + if mod.inspect \ + =~/"--pg-recreate(?:all)?"|"--recreate(?:all)?"/ + act[:psql_drop]={ bool: true, set: :on } + act[:psql_create]={ bool: true, set: :on } + else + act[:psql_drop]=if mod.inspect \ + =~/"--pg-dropall"|"--dropall"/ + { bool: true, set: :on } + else + { bool: false, set: :na } + end + act[:psql_create]=if mod.inspect \ + =~/"--pg-create(?:all)?"|"--create(?:all)?"/ + { bool: true, set: :on } + else + { bool: false, set: :na } + end + end + act[:psql_import]=if mod.inspect \ + =~/"--pg-import"|"--import"/ + { bool: true, set: :on } + else + { bool: false, set: :na } + end + act[:psql_update]=if mod.inspect \ + =~/"--pg-update"|"--update"/ + act[:psql_remove]={ bool: true, set: :on } + { bool: true, set: :on } + else + act[:psql_remove]=if mod.inspect \ + =~/"--pg-remove"|"--remove"/ + { bool: true, set: :on } + else + { bool: false, set: :na } + end + { bool: false, set: :na } + end + { bool: true, set: :on } + else + act[:psql_createdb]= + { bool: false, set: :na } + act[:psql_drop]= + { bool: false, set: :na } + act[:psql_create]= + { bool: false, set: :na } + act[:psql_import]= + { bool: false, set: :na } + act[:psql_update]= + { bool: false, set: :na } + act[:psql_remove]= + { bool: false, set: :na } + { bool: false, set: :na } + end + act[:sqlite]=if (mod.inspect =~/"--sqlite-\S+"/) \ + or ((mod.inspect =~/"--sqlite"/) \ + && (mod.inspect \ + =~/"--createdb"|"--create(?:all)?"|"--dropall"|"--recreate(?:all)?"|"--import"|"--update"|"--remove"/)) + act[:sqlite_createdb]=if mod.inspect \ + =~/"--sqlite-createdb"|"--createdb"/ + { bool: true, set: :on } + else + { bool: false, set: :na } + end + if mod.inspect \ + =~/"--sqlite-recreate(?:all)?"|"--recreate(?:all)?"/ + act[:sqlite_drop]={ bool: true, set: :on } + act[:sqlite_create]={ bool: true, set: :on } + else + act[:sqlite_create]=if mod.inspect \ + =~/"--sqlite-create(?:all)?"|"--create(?:all)?"/ + { bool: true, set: :on } + else + { bool: false, set: :na } + end + act[:sqlite_drop]=if mod.inspect \ + =~/"--sqlite-dropall"|"--dropall"/ + { bool: true, set: :on } + else + { bool: false, set: :na } + end + end + act[:sqlite_import]=if mod.inspect \ + =~/"--sqlite-import"|"--import"/ + { bool: true, set: :on } + else + { bool: false, set: :na } + end + act[:sqlite_update]=if mod.inspect \ + =~/"--sqlite-update"|"--update"/ + act[:sqlite_remove]={ bool: true, set: :on } + { bool: true, set: :on } + else + act[:sqlite_remove]=if mod.inspect \ + =~/"--sqlite-remove"|"--sqlite-remove"/ + { bool: true, set: :on } + else + { bool: false, set: :na } + end + { bool: false, set: :na } + end + { bool: true, set: :on } + else + act[:sqlite_createdb]= + { bool: false, set: :na } + act[:sqlite_drop]= + { bool: false, set: :na } + act[:sqlite_create]= + { bool: false, set: :na } + act[:sqlite_import]= + { bool: false, set: :na } + act[:sqlite_update]= + { bool: false, set: :na } + act[:sqlite_remove]= + { bool: false, set: :na } + { bool: false, set: :na } + end + act[:sqlite_discrete]=mod.inspect =~/"--sql"|"--sqlite"/ \ + && (mod.inspect !~/"--createdb"|"--create(?:all)?"|"--dropall"|"--recreate(?:all)?"|"--import"|"--update"|"--remove"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:harvest]=(mod.inspect =~/"--harvest"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:po4a]=(cmd =~/P/ \ + || mod.inspect =~/"--po4a"|"--pot?"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:git]=(cmd =~/g/ \ + || mod.inspect =~/"--git"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:hash_digests]=(cmd =~/N/ \ + || mod.inspect =~/"--digests?"|"--hash-digests"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:pdf_font_size]=if mod.inspect =~/"--(?:pdf-)?font-?size[=-](\d{1,2})(?:pt)?"/ + $1 + else :na + end + act[:pdf_hyperlink_colors]=if mod.inspect =~/"--pdf-hyperlinks-(?:mono(?:chrome)?|no-color)"/ + :mono + elsif mod.inspect =~/"--pdf-hyperlinks-color"/ + :color + else :na + end + act[:hash_digest_algo]=if mod.inspect =~/"--hash-(?:sha)?512"/ + :sha512 + elsif mod.inspect =~/"--hash-(?:sha)?256"/ + :sha256 + elsif mod.inspect =~/"--hash-md5"/ + :md5 + else :na + end + act[:sample_search_form]=(cmd =~/F/ \ + || mod.inspect =~/"--sample-search-form"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:webrick]=(cmd =~/W/ \ + || mod.inspect =~/"--webrick"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:share_source]=(cmd =~/s/ \ + || mod.inspect =~/"--source"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:sisupod]=(cmd =~/S/ \ + || mod.inspect =~/"--sisupod"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:scp]=(cmd =~/r/ \ + || mod.inspect =~/"--scp"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:rsync]=(cmd =~/R/ \ + || mod.inspect =~/"--rsync"|"--remote"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:zap]=(cmd =~/Z/ \ + || mod.inspect =~/"--zap"|"--delete"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:urls_all]=(cmd =~/U/ \ + || mod.inspect =~/"--urls-all"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:urls_selected]=(cmd =~/u/ \ + || mod.inspect =~/"--urls"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:sitemap]=(cmd =~/Y/ \ + || mod.inspect =~/"--sitemap"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:qrcode]=(cmd =~/Q/ \ + || mod.inspect =~/"--qrcode"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:help]=(mod.inspect =~/"--help/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:ao]=if (cmd =~/m/ \ + || mod.inspect =~/"--ao"|"--dal"/) + { bool: true, set: :on } + elsif (act[:txt][:set]==:on \ + || act[:txt_textile][:set]==:on \ + || act[:txt_asciidoc][:set]==:on \ + || act[:txt_markdown][:set]==:on \ + || act[:txt_rst][:set]==:on \ + || act[:xhtml][:set]==:on \ + || act[:epub][:set]==:on \ + || act[:html][:set]==:on \ + || act[:html_seg][:set]==:on \ + || act[:html_scroll][:set]==:on \ + || act[:texinfo][:set]==:on \ + || act[:manpage][:set]==:on \ + || act[:hash_digests][:set]==:on \ + || act[:odt][:set]==:on \ + || act[:pdf][:set]==:on \ + || act[:pdf_p][:set]==:on \ + || act[:pdf_l][:set]==:on \ + || act[:qrcode][:set]==:on \ + || act[:share_source][:set]==:on \ + || act[:sisupod][:set]==:on \ + || act[:concordance][:set]==:on \ + || act[:xml_dom][:set]==:on \ + || act[:xml_sax][:set]==:on \ + || act[:xml_docbook_book][:set]==:on \ + || act[:xml_fictionbook][:set]==:on \ + || act[:xml_scaffold_structure_sisu][:set]==:on \ + || act[:xml_scaffold_structure_collapse][:set]==:on ) + { bool: true, set: :on } + #if cmd !~/[mn]/ + # extra+=if cmd =~/[abegHhIiLNOoPpQTtwXxyz]/ \ + # and cmd !~/[mn]/ + # 'm' #% add ao + #elsif (act[:txt][:set]==:on \ + # { bool: true, set: :on } + # elsif ((cmd =~/[Dd]/ \ + # or (mod.inspect =~/--(?:(?:sq)?lite|pg(?:sql)?)/)) \ + # and mod.inspect !~/(?:remove|(?:(?:re)?create(?:all)?|dropall|drop)$)/) \ + # and cmd !~/[mn]/ + # 'm' #% add ao + else + { bool: false, set: :na } + end + act[:manifest]=if mod.inspect =~/"--inc-manifest"/ + { bool: true, set: :on } + elsif mod.inspect =~/"--(?:exc|no)-manifest"/ \ + || act[:switch][:off].inspect =~/"manifest"/ + { bool: false, set: :off } + elsif (cmd =~/y/ \ + || mod.inspect =~/"--manifest"/) + { bool: true, set: :on } + elsif (act[:txt][:set]==:on \ + || act[:txt_textile][:set]==:on \ + || act[:txt_asciidoc][:set]==:on \ + || act[:txt_markdown][:set]==:on \ + || act[:txt_rst][:set]==:on \ + || act[:xhtml][:set]==:on \ + || act[:epub][:set]==:on \ + || act[:html][:set]==:on \ + || act[:html_seg][:set]==:on \ + || act[:html_scroll][:set]==:on \ + || act[:texinfo][:set]==:on \ + || act[:manpage][:set]==:on \ + || act[:hash_digests][:set]==:on \ + || act[:odt][:set]==:on \ + || act[:pdf][:set]==:on \ + || act[:pdf_p][:set]==:on \ + || act[:pdf_l][:set]==:on \ + || act[:qrcode][:set]==:on \ + || act[:share_source][:set]==:on \ + || act[:sisupod][:set]==:on \ + || act[:concordance][:set]==:on \ + || act[:xml_dom][:set]==:on \ + || act[:xml_sax][:set]==:on \ + || act[:xml_docbook_book][:set]==:on \ + || act[:xml_fictionbook][:set]==:on \ + || act[:xml_scaffold_structure_sisu][:set]==:on \ + || act[:xml_scaffold_structure_collapse][:set]==:on ) + { bool: true, set: :on } + ## if cmd !~/y/ + ## extra+=if cmd =~/[abeHhIiNopQSstwXxz]/ \ + ## and cmd !~/y/ + ## 'ym' #% add manifest + #elsif (act[:txt][:set]==:on \ + # { bool: true, set: :on } + # elsif (cmd =~/[Dd]/ \ + # or mod.inspect =~/--(?:(?:sq)?lite|pg(?:sql)?)/) \ + # and files[0] !~/^remove$/ \ + # and cmd !~/y/ + # 'ym' #% add manifest + else { bool: true, set: :na } + end + act[:console_messages] = '' + act[:verbose]=if (cmd =~/v/ \ + || mod.inspect =~/"--verbose"/) + act[:console_messages] << ' --verbose ' + { bool: true, set: :on } + else + { bool: false, set: :na } + end + act[:verbose_plus]=if (cmd =~/V/ \ + || mod.inspect =~/"--very-verbose"/) + act[:console_messages] << ' --very-verbose ' + { bool: true, set: :on } + else + { bool: false, set: :na } + end + act[:version_info]=if (cmd =~/[vVM]/ \ + || mod.inspect =~/"--verbose"|"--maintenance"/) + act[:console_messages] << ' --maintenance ' + { bool: true, set: :on } + else + { bool: false, set: :na } + end + act[:quiet]=if (cmd =~/q/ \ + || mod.inspect =~/"--quiet"/) + act[:console_messages] << ' --quiet ' + { bool: true, set: :on } + else + { bool: false, set: :na } + end + act[:color_state]=if mod.inspect =~/"--color-on"|"--color"/ + act[:console_messages] << ' --color-on ' + { bool: true, set: :on } + elsif (cmd =~/k/ \ + || mod.inspect =~/"--color-off"/) + act[:console_messages] << ' --color-off ' + { bool: false, set: :off } + else { bool: true, set: :na } #fix default color + end +# act[:color_toggle]=if cmd =~/c/ \ +# or mod.inspect =~/"--color-toggle"/ +# true +# else false +# end + act[:maintenance]=if (cmd =~/M/ \ + || mod.inspect =~/"--maintenance|--keep-processing-files"/) + act[:console_messages] << ' --maintenance ' + { bool: true, set: :on } + else + { bool: false, set: :na } + end + act[:profile]=if (cmd =~/E/ \ + || mod.inspect =~/"--profile"/) + act[:console_messages] << ' --color-off ' + { bool: true, set: :on } + else + { bool: false, set: :na } + end + @act=act + end + end + def cmd + @cmd + end + def mod + @mod + end + def act + @@act + end + def files_mod + files_mod=files + @files_mod=files_mod + end + def f_pth + @f_pth + end + def pth + @pth + end + def sub_location + pth.gsub(/#{base_path}/,'') + end + def lng + @lng + end + def lng_base + @lng_base + end + def fno + @fno=(fns.nil? || fns.empty?) \ + ? '' \ + : (fns[/(.+?(?:sst|ssm))(?:\.sst)?/,1]) + end + def fng + @fng=(fno.nil? || fno.empty?) \ + ? '' \ + : (fno.gsub(/(?:~(?:#{Px[:lng_lst_rgx]}))?(\.ss[tm])$/,'\1')) + end + def fns + @fns + end + def fnl + @fns.gsub(/(\S+?)((?:\.ssm)?\.sst)/,"\\1.#{lng}\\2") + end + def what + @what + end + def fnb + (fns.nil? || fns.empty?) \ + ? '' \ + : (fns[/(.+?)\.(?:(?:-|ssm\.)?sst|ssm)$/,1]) + end + def fnc + @fnc=(@fns =~/\.(?:ssm\.sst|ssm)$/) \ + ? fnb + '.ssm.sst' + : @fns + end + def fncb + @fncb=(@fns =~/(?:\~\S{2,3})?\.(?:ssm\.sst|ssm)$/) \ + ? fnb + '.ssm.sst' + : @fns.gsub(/(?:\~\S{2,3})?(\.sst)$/,'\1') + end + end +end +__END__ +note usually named @opt is carried in dp document parameters (usually as @md.opt), @opt is a +subset of @md where @md is passed, contents of @opt are available as @md.opt +passing @opt as well is duplication check for fns & fnb diff --git a/lib/sisu/v6/manifest.rb b/lib/sisu/v6/manifest.rb index 21350938..e38d8424 100644 --- a/lib/sisu/v6/manifest.rb +++ b/lib/sisu/v6/manifest.rb @@ -61,15 +61,15 @@ =end module SiSU_Manifest - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env require_relative 'prog_text_translation' # prog_text_translation.rb - require_relative 'particulars' # particulars.rb + require_relative 'se_hub_particulars' # se_hub_particulars.rb include SiSU_Particulars require_relative 'html_minitoc' # html_minitoc.rb require_relative 'html' # html.rb include SiSU_HTML_Format - require_relative 'param' # param.rb + require_relative 'dp' # dp.rb include SiSU_Param require_relative 'i18n' # i18n.rb include SiSU_Viz diff --git a/lib/sisu/v6/manpage.rb b/lib/sisu/v6/manpage.rb index 4f2bb803..d3192eb9 100644 --- a/lib/sisu/v6/manpage.rb +++ b/lib/sisu/v6/manpage.rb @@ -63,7 +63,7 @@ =end module SiSU_Manpage require_relative 'ao' # ao.rb - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env include SiSU_Param include SiSU_Viz diff --git a/lib/sisu/v6/manpage_format.rb b/lib/sisu/v6/manpage_format.rb index 1bb0e423..b64911e7 100644 --- a/lib/sisu/v6/manpage_format.rb +++ b/lib/sisu/v6/manpage_format.rb @@ -61,7 +61,7 @@ =end module SiSU_ManpageFormat - require_relative 'param' # param.rb + require_relative 'dp' # dp.rb include SiSU_Param include SiSU_Viz class ParagraphNumber diff --git a/lib/sisu/v6/options.rb b/lib/sisu/v6/options.rb deleted file mode 100644 index b73dd87c..00000000 --- a/lib/sisu/v6/options.rb +++ /dev/null @@ -1,1399 +0,0 @@ -# encoding: utf-8 -=begin - - * Name: SiSU - - * Description: a framework for document structuring, publishing and search - - * Author: Ralph Amissah - - * Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, - All Rights Reserved. - - * License: GPL 3 or later: - - SiSU, a framework for document structuring, publishing and search - - Copyright (C) Ralph Amissah - - This program is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the Free - Software Foundation, either version 3 of the License, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - more details. - - You should have received a copy of the GNU General Public License along with - this program. If not, see . - - 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: - - - * Git - - - - * Ralph Amissah - - - - ** Description: SiSU information Structuring Universe, command line options - parsing - -=end -module SiSU_Commandline - begin - require 'pathname' - rescue LoadError - SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('pathname NOT FOUND (LoadError)') - end - require_relative 'sysenv' # sysenv.rb - require_relative 'param_make' # param_make.rb - class HeaderCommon - def sisu_document_make_instructions(make_instruct_array=:nil) - @pagenew= - @pagebreak= - @pageline= - @toc= - @lv1=@lv2=@lv3=@lv4=@lv5=@lv6= - @num_top= - @i18n= - @man_section= - @emphasis_set_to= - @bold_match_list= - @italics_match_list= - @substitution_match_list= - @footer_links= - @home_button_links= - @links= - nil - make_instruct_array=make_instruct_array==:nil \ - ? SiSU_Env::GetInit.new.sisu_document_make.makefile_read - : make_instruct_array - @makeset=false - if make_instruct_array - make_instruct_array.each do |para| #% scan document - if para =~/^(?:@make:|@links:)[+-]?\s/ - case para - when /^@make:(.+)/m #% header processing - make - @env=SiSU_Env::InfoEnv.new - @make=SiSU_Param_Make::MdMake.new($1.strip,@opt,@env).make - makes=SiSU_Param_Make::MakeHead.new(@make).make_instruct - @makeset=true - @pagenew=makes[:pagenew] - @pagebreak=makes[:pagenew] - @pageline=makes[:pageline] - @toc=makes[:toc] - @lv1=makes[:lv1] - @lv2=makes[:lv2] - @lv3=makes[:lv3] - @lv4=makes[:lv4] - @lv5=makes[:lv5] - @lv6=makes[:lv6] - @num_top=makes[:num_top] - @i18n=makes[:i18n] - @man_section=makes[:man_section] - @emphasis_set_to=makes[:emphasis_set_to] - @bold_match_list=makes[:bold_match_list] - @italics_match_list=makes[:italics_match_list] - @substitution_match_list=makes[:substitution_match_list] - @footer_links=makes[:footer_links] - @home_button_links=makes[:home_button_links] - @home_button_image=makes[:home_button_image] - @cover_image=makes[:cover_image] - when /^@links:(.+)/m #% header processing - make - make_links=SiSU_Param::Parameters::MdMake.new($1.strip,@opt,@env).make_links - @links,@links_append=make_links.links,make_links.append? - end - end - end #% here endeth the common header loop - end - { makeset: @makeset, - pagenew: @pagenew, - pagebreak: @pagebreak, - pageline: @pageline, - toc: @toc, - lv1: @lv1, - lv2: @lv2, - lv3: @lv3, - lv4: @lv4, - lv5: @lv5, - lv6: @lv6, - num_top: @num_top, - i18n: @i18n, - man_section: @man_section, - emphasis_set_to: @emphasis_set_to, - bold_match_list: @bold_match_list, - italics_match_list: @italics_match_list, - substitution_match_list: @substitution_match_list, - footer_links: @footer_links, - home_button_links: @home_button_links, - home_button_image: @home_button_image, - cover_image: @cover_image, - links: @links, - links_append: @links_append - } - end - end - class Options - attr_accessor :cmd,:mod,:act,:dir_structure_by,:lingual,:f_pths,:files,:files_mod,:call_path,:base_path,:base_stub,:sub_location,:image_src_path,:paths,:lngs,:f_pth,:pth,:fno,:fns,:fnb,:fnc,:fng,:fncb,:lng,:lng_base,:what,:make_instructions,:make_instructions_pod - @@act=nil - def initialize(a,call_path) - @cmd=@f_pth=@pth=@fno=@fns=@fnb=@fnc=@fng=@fncb=@what=@lng=@lng_base=@call_path=@base_path=@base_stub=@image_src_path=@sub_location='' - @f_pths,@files,@files_mod,@paths,@mod,@act=Array.new(5){[]} - @env=SiSU_Env::InfoEnv.new - @lng_base=@env.language_default_set - @dir_structure_by=SiSU_Env::EnvCall.new.output_dir_structure.by? - @lingual=SiSU_Env::EnvCall.new.mono_multi_lingual? - @call_path=call_path - pth=SiSU_Utils::Path.new(call_path) - @base_path=pth.base_markup - @base_stub=pth.base_markup_stub - @image_src_path=pth.image_src - @a=sisu_glob_rules(a) - @a.freeze - @make_instructions=HeaderCommon.new.sisu_document_make_instructions - @make_instructions_pod=nil - init - end - def find_all(find_flag,opt) - if find_flag - x=Dir.glob('*.ss[tm]') - Px[:lng_lst].each do |d| - if FileTest.directory?(d) - x << Dir.glob("#{d}/*.ss[tm]") - end - end - x=x.flatten - opt + x - end - end - def find_select(find_flag,opt) - if find_flag - x=[] - if opt.inspect =~/"[a-zA-Z][a-zA-Z0-9._-]+?"/ - opt.each do |g| - x <<=if g =~/.ss[tm]/ - Dir.glob("*#{g}") - else - Dir.glob("*#{g}*.ss[tm]") - end - Px[:lng_lst].each do |d| - if FileTest.directory?(d) - x <<=if g =~/.ss[tm]/ - Dir.glob("#{d}/*#{g}") - else - Dir.glob("#{d}/*#{g}*.ss[tm]") - end - end - end - end - end - x.flatten - end - end - def sisu_glob_rules(a) - a=if a.inspect =~/"-[A-Za-z0-9]*[fG]/ \ - or a.inspect =~/"--find"|"--glob"/ - b,f=[],[] - find_flag=false - a.each do |y| - if y =~ /^-/ - if y =~/^-/ \ - && y =~/[fG]|--find|--glob/ - find_flag=true - end - b << y - end - if find_flag \ - && y !~ /^-/ \ - && y =~ /\S+/ - if y !~/\// - f << y - else - find_flag=false - puts %{sub-directories "#{y}" cannot be provided for --find or --glob at this time} - end - end - end - r=Px[:lng_lst_rgx].gsub(/\|#{lng_base}\|/,'|') - @lang_regx=%r{(?:#{r})} - if find_flag - (f.length > 0) \ - ? (b + find_select(find_flag,f)) - : find_all(find_flag,b) - elsif a.inspect =~/"(?:-\S+?|--\S+?)"/ \ - && a.inspect =~/"#{@lang_regx}\/?"/ \ - && a.inspect =~/"#{lng_base}\/\S+?\.ss[tm]"/ - init_selected_lang_dirs(a) - else b - end - else a - end - end - def init_selected_lang_dirs(a) - @z=[] - a.each do |y| - if y =~/^#{lng_base}\/(\S+?\.ss[tm])$/ - @fn=$1 - @z << y - elsif y =~/^#{@lang_regx}\/?$/ - @z << "#{y}/#{@fn}" - else @z << y - end - end - @z - end - def init - a=@a - if a.length > 0 - s=expand_numeric_shortcuts(a) - q=set_files_and_paths_and_general_extract(s) - @cmd,@mod=opt_cmd_and_mod_adjust(q[:cmd],q[:mod]) - @what=q[:what] unless q[:what].empty? - @paths = q[:paths] - @files = q[:files] - @f_pths = q[:f_pths] - @lngs = q[:lngs] - if @files.length > 0 \ - and @cmd.empty? \ - and @mod.length==0 #% if no other action called on filename given, default is sisu --v5 -0 [filename(s)] configured as flag default - shortcut=SiSU_Env::InfoProcessingFlag.new - @mod=['--v5'] - @cmd=shortcut.cf_0 + ' --dal' - end - if @cmd =~/[vVM]/ \ - && @cmd !~/-[ku]*v[ku]*$/ - SiSU_Screen::Ansi.new( - @cmd, - "\tsisu " + @cmd + ' ' + @mod.join(' ') + ' ' + @files.join(' ') + "\n" - ).print_brown - end - end - @@act ? @act=@@act : @@act=@act=opt_act - self - end - def sisu_document_make_pod - def makefile_name - SiSU_Env::GetInit.new.sisu_document_make.makefile_name - end - def makefile(pod_make_path) - "#{pod_make_path}/#{makefile_name}" - end - def makefile_read(pod_make_path) - if FileTest.file?(makefile(pod_make_path)) - sisu_doc_makefile=IO.read(makefile(pod_make_path), mode: 'r:utf-8') - sisu_doc_makefile.split(/\s*\n\s*\n/m) - else nil - end - end - self - end - def set_files_and_paths_and_general_extract(s) - c,w='','' - m,f,pth,lng,lngs=[],[],[],[],[] - lng_is='' - a=s.split(/\s+/) - r_l=Px[:lng_lst].join('|') - a.uniq.each do |x| - if x =~/^-[a-z0-5]+/i \ - or x =~/^--\S+/ - if x =~/^-([a-z0-5]+)/i - c << $1 - end - if x =~/^--\S+/ - m << x - end - elsif x =~ /(?:\.(?:(?:-|ssm\.)?sst(?:\.xml)?|ssm|ssi|sx[sdn]\.xml|s[1-3]|kdi|ssp)|\S+?\.ss[mt]\.(?:txz|zip)|sisupod\.(?:txz|zip))$/ - if x =~/\S+?\.ss[mt]\.(?:txz|zip)|sisupod\.(?:txz|zip)/ - if x =~/^(?:https?|file):\/\/\S+/ #\ - end - pwd=Dir.pwd - fn_pod=x.gsub(/([^\/]+)\.txz$/,'\1') - fullname=@env.processing_path.processing + '/sisupod/' + fn_pod - pt=Pathname.new(fullname) - FileUtils::mkdir_p(pt.to_s) - pod_make_path=fullname + '/sisupod/doc/_sisu' - make_instruct_array=sisu_document_make_pod.makefile_read(pod_make_path) - @make_instructions_pod= - HeaderCommon.new.sisu_document_make_instructions(make_instruct_array) - Dir.chdir(pt.realpath) - system(" - chdir #{fullname} - tar xaf #{pwd}/#{x} - chdir #{pwd} - ") - Dir.chdir(pt.realpath.to_s + '/sisupod/doc') - r=Px[:lng_lst_rgx] - Dir.entries("#{fullname}/sisupod/doc").each do |d_lng| - if d_lng =~/^(?:#{r})$/ - Dir.chdir(pt.realpath.to_s + "/sisupod/doc/#{d_lng}") - filenames=Dir.glob("*.ss[mt]") - filenames.each do |fn| - f_pths << { - pth: "#{fullname}/sisupod/doc/#{d_lng}", - f: "#{fn}", - pth_stub: 'doc', - lng: d_lng, - lng_is: d_lng, - url_base: '', - url: '' - } - Dir.chdir(pwd) - f << fn - end - end - end - elsif x =~/^(?:https?|file):\/\/\S+/ \ - and x =~/\S+?\.ss[mt]$/ - r_url=/(http:\/\/\S+?\/\S+?\/src(?:\/(?:#{r_l}))?)\// - url_base = (x[r_url,1]) - url = x - y=x.gsub(/http:\/\/\S+?\/\S+?\/src\//,'') - t=/(#{r_l})\/[^\/]+?\.ss[tm]$/ - l_p = (y[t,1]) \ - ? y[t,1] - : nil - lng << l_p - lngs << if l_p - l_p - elsif x =~/~(#{r_l})\.ss[tm]/ - $1 - else lng_base - end - r_f=/(?:#{r_l})\/([^\/]+?\.ss[tm])$/ - fn = (y[r_f,1]) \ - ? y[r_f,1] - : y - fn=fn.gsub(/\.((?:ssm\.)?sst)/,'.-\1') - fullname=Dir.pwd + '/' + fn - pt=Pathname.new(fullname) - pth << Dir.pwd - r_u=/.+?\/([^\/]+)(?:\/(?:#{r_l})$|$)/ - lng_is =if l_p - l_p - elsif x =~/~(#{r_l})\.ss[tm]/ - $1 - else lng_base - end - f_pths << { - pth: pt.split[0].realpath.to_s, - f: pt.split[1].to_s, - pth_stub: pt.split[0].realpath.to_s[r_u,1], - lng: (pt.split[0].realpath.to_s[t,1]) \ - ? pt.split[0].realpath.to_s[t,1] - : nil, - lng_is: lng_is, - url_base: url_base, - url: url - } - f << fn - elsif FileTest.file?(x) - pt=Pathname.new(x) - pth << pt.split[0].realpath.to_s #remove? - f << pt.split[1].to_s #remove? - r_u=/.+?\/([^\/]+)(?:\/(?:#{r_l})$|$)/ - t=/.+\/(#{r_l})$/ - l_p = (pt.split[0].realpath.to_s[t,1]) \ - ? pt.split[0].realpath.to_s[t,1] - : nil - lngs << lng_is = if l_p - l_p - elsif x =~/~(#{r_l})\.ss[tm]/ - $1 - else lng_base - end - f_pths << { - pth: pt.split[0].realpath.to_s, - f: pt.split[1].to_s, - pth_stub: pt.split[0].realpath.to_s[r_u,1], - lng: lng_is, - lng_is: lng_is, - url_base: nil, - url: nil, - } - else puts "file not found: #{x}" - end - elsif x =~ /\.termsheet\.rb$/ - (FileTest.file?(x)) \ - ? (f << x) - : (puts "file not found: #{x}") - else w=x - puts "#{x} in #{a.join(' ')}?" - end - end - { - cmd: c, - mod: m, - what: w, - paths: pth, - files: f, - f_pths: f_pths, - lng: lng_is, - lngs: lngs, - } - end - def expand_numeric_shortcuts(a) - shortcut=SiSU_Env::InfoProcessingFlag.new - s='' - a.each do |x| - y=case x - when /0/ - (x=~/^-0\S+/) \ - ? x.gsub(/^-0(\S+)/,shortcut.cf_0 + ' -\1') - : x.gsub(/^-0/,shortcut.cf_0 + ' ') - when /1/ - (x=~/^-1\S+/) \ - ? x.gsub(/^-1(\S+)/,shortcut.cf_1 + ' -\1') - : x.gsub(/^-1/,shortcut.cf_1 + ' ') - when /2/ - (x=~/^-2\S+/) \ - ? x.gsub(/^-2(\S+)/,shortcut.cf_2 + ' -\1') - : x.gsub(/^-2/,shortcut.cf_2 + ' ') - when /3/ - (x=~/^-3\S+/) \ - ? x.gsub(/^-3(\S+)/,shortcut.cf_3 + ' -\1') - : x.gsub(/^-3/,shortcut.cf_3 + ' ') - when /4/ - (x=~/^-4\S+/) \ - ? x.gsub(/^-4(\S+)/,shortcut.cf_4 + ' -\1') - : x.gsub(/^-4/,shortcut.cf_4 + ' ') - when /5/ - (x=~/^-5\S+/) \ - ? x.gsub(/^-5(\S+)/,shortcut.cf_5 + ' -\1') - : x.gsub(/^-5/,shortcut.cf_5 + ' ') - when /6/ - (x=~/^-6\S+/) \ - ? x.gsub(/^-6(\S+)/,shortcut.cf_5 + ' -\1') - : x.gsub(/^-6/,shortcut.cf_5 + ' ') - else x - end - s << " #{y}" unless y.empty? - end - s.strip! - end - def opt_cmd_and_mod_adjust(c,m) - cmd,mod,files=@cmd,@mod,@files - if not m.empty? \ - and m.inspect =~/"--pdf-/ - mod << '--pdf' - m.each do |s| - if s =~ /^--pdf-(?:(?:l|landscape)(?:-(?:a4|letter|a5|b5|legal))?|(?:a4|letter|a5|b5|legal)-(?:l|landscape))$/ - mod << '--landscape' - end - if s =~ /^--pdf-(?:(?:p|portrait)(?:-(?:a4|letter|a5|b5|legal))?|(?:a4|letter|a5|b5|legal)-(?:p|portrait))$/ - mod << '--portrait' - end - if s =~ /^--pdf(?:-(?:a4|letter|a5|b5|legal)(?:-(?:[lp]|landscape|portrait))?|(?:-(?:[lp]|landscape|portrait))(?:-(?:a4|letter|a5|b5|legal)))$/ - if s =~ /^--pdf(?:-a4(?:-(?:[lp]|landscape|portrait))?|(?:-(?:[lp]|landscape|portrait))-a4)$/ - mod << '--papersize-a4' - end - if s =~ /^--pdf(?:-a5(?:-(?:[lp]|landscape|portrait))?|(?:-(?:[lp]|landscape|portrait))-a5)$/ - mod << '--papersize-a5' - end - if s =~ /^--pdf(?:-b5(?:-(?:[lp]|landscape|portrait))?|(?:-(?:[lp]|landscape|portrait))-b5)$/ - mod << '--papersize-b5' - end - if s =~ /^--pdf(?:-letter(?:-(?:[lp]|landscape|portrait))?|(?:-(?:[lp]|landscape|portrait))-letter)$/ - mod << '--papersize-letter' - end - if s =~ /^--pdf(?:-legal(?:-(?:[lp]|landscape|portrait))?|(?:-(?:[lp]|landscape|portrait))-legal)$/ - mod << '--papersize-legal' - end - end - end - mod=mod.uniq - end - unless m.empty? - m.each do |s| - case s - when /^--(?:color-toggle)$/ then c=c+'c' - when /^--(?:color-off)$/ then c=c+'k' - when /^--(?:conf|config|configure|init|initialize|init-site)$/ then c=c+'CC' - when /^--(?:ao|dal?|machine|abstraction|abs)$/ then c=c+'m' - when /^--(?:txt|text|plaintext)$/ then c=c+'t' - when /^--(?:html)$/ then c=c+'h' - when /^--(?:html-scroll|html-seg)$/ then c=c+'H' - mod << s - when /^--(?:epub)$/ then c=c+'e' - when /^--(?:od[ft])$/ then c=c+'o' - when /^--docbook$/ then c=c+'d' - when /^--(?:pdf)$/ then c=c+'p' - when /^--pdf-(?:a4|a5|b5|legal|letter)$/ then c=c+'p' - when /^--pdf-(?:p|l|portrait|landscape)$/ then c=c+'L' - when /^--pdf-(?:p(?:ortrait)?|l(?:andscape)?)-(?:a4|letter|a5|b5|legal)$/ then c=c+'L' - when /^--pdf-(?:a4|letter|a5|b5|legal)-(?:p(?:ortrait)?|l(?:andscape)?)$/ then c=c+'L' - when /^--(?:concordance|wordmap)$/ then c=c+'w' - when /^--(?:manpage|man)$/ then c=c+'i' - when /^--(?:texinfo)$/ then c=c+'I' - when /^--(?:xhtml)$/ then c=c+'b' - when /^--(?:xml-sax)$/ then c=c+'x' - when /^--(?:xml-dom)$/ then c=c+'X' - when /^--(?:images)$/ then c=c+'j' - when /^--(?:digests?|hash-digests)$/ then c=c+'N' - when /^--(?:po4a|pot?)$/ then c=c+'P' - when /^--(?:termsheet)$/ then c=c+'T' - when /^--(?:manifest)$/ then c=c+'y' - when /^--(?:qrcode)$/ then c=c+'Q' - when /^--(?:remote|rsync)$/ then c=c+'R' - when /^--(?:scp)$/ then c=c+'r' - when /^--(?:source)$/ then c=c+'s' - when /^--(?:sisupod|pod)$/ then c=c+'S' - when /^--(?:git)$/ then c=c+'g' - when /^--(?:urls)$/ then c=c+'U' - when /^--(?:zap|delete)$/ then c=c+'Z' - when /^--(?:sample-search-form)$/ then c=c+'F' - when /^--(?:webserv|webrick)$/ then c=c+'W' - when /^--(?:profile)$/ then c=c+'E' - when /^--(?:maintenance|keep-processing-files)$/ then c=c+'M' - when /^--(?:verbose[=-]3)$/ then c=c+'VM' - when /^--(?:verbose[=-]2|Verbose|VERBOSE)$/ then c=c+'V' - when /^--(?:verbose(?:[=-]1)?)$/ then c=c+'v' - when /^--(?:version)$/ then c=c+'v' - when /^--(?:verbose[=-]0|quiet|silent)$/ then c=c+'q' - else mod << s #mod only contains command modifiers; commands converted to character - end - end - end - ca=[] - unless c.empty? - c=c.gsub(/-/,'') - c.scan(/CC|\S/) {|x| ca << x} - cmd= '-' + ca.uniq.join - end - extra='' - if cmd !~/[mn]/ - extra+=if cmd =~/[abegHhIiLNOoPpQTtwXxyz]/ \ - and cmd !~/[mn]/ - 'm' #% add ao - elsif ((mod.inspect =~/--(?:(?:sq)?lite|pg(?:sql)?)/) \ - and mod.inspect !~/(?:remove|(?:(?:re)?create(?:all)?|dropall|drop)$)/) \ - and cmd !~/[mn]/ - 'm' #% add ao - else '' - end - end - if cmd !~/j/ - extra+=if cmd =~/[bdHhwXxyz]/ \ - and cmd !~/[j]/ - 'j' #% copy images - else '' - end - end - if cmd !~/y/ - extra+=if cmd =~/[abdeHhIiNopQSstwXxz]/ \ - and cmd !~/y/ - 'ym' #% add manifest - elsif mod.inspect =~/--(?:(?:sq)?lite|pg(?:sql)?)/ \ - and files[0] !~/^remove$/ \ - and cmd !~/y/ - 'ym' #% add manifest - else '' - end - end - if cmd !~/u/ #% add urls - extra+='u' - end - cmd=cmd + extra - cmds=cmd.scan(/CC|\S/) - [cmds.uniq.join,mod] - end - def opt_act #note mod line commands have already been converted to command characters, cmd - cmd,mod=@cmd,@mod - @@act=if @@act - @act=@@act - else - act={} - act[:license]=(mod.inspect =~/"--license/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:site_init]=(cmd =~/C/ \ - || mod.inspect =~/"--init"|"--initialize"|"--init-site"|"--conf"|"--config"|"--configure"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:rc]=if mod.inspect =~/"--rc=/ - x=Dir.pwd + '/' + mod.join.gsub(/--rc=/,'') - { bool: true, set: :on, inst: x } - else - { bool: false, set: :na, inst: '' } - end - act[:processing_path]=if mod.inspect =~/"--processing-path=/ - base_pth=mod.join(';').gsub(/^.*--processing-path=['"]?(.+?)(?:['"]?;.+)?$/,'\1') - { bool: true, set: :on, inst: base_pth } - elsif mod.inspect =~/"--processing-path/ - { bool: true, set: :on, inst: @base_path } - else - { bool: false, set: :na, inst: nil } - end - act[:dump]=if mod.inspect =~/"--dump=/ - base_pth=mod.join(';').gsub(/^.*--dump=['"]?(.+?)(?:['"]?;.+)?$/,'\1') - { bool: true, set: :on, inst: base_pth } - elsif mod.inspect =~/"--dump/ - { bool: true, set: :on, inst: @base_path } - else - { bool: false, set: :na, inst: nil } - end - act[:redirect]=if mod.inspect =~/"--redirect=/ - base_pth=mod.join(';').gsub(/^.*--redirect=['"]?(.+?)(?:['"]?;.+)?$/,'\1') - { bool: true, set: :on, inst: base_pth } - elsif mod.inspect =~/"--redirect/ - { bool: true, set: :on, inst: @base_path } - else - { bool: false, set: :na, inst: nil } - end - act[:switch]=if mod.inspect =~/"--switch-off=/ - off_list=mod.join(';').gsub(/^.*--switch-off=['"]?(.+?)(?:['"];.+)?$/,'\1') - off_list=off_list.scan(/[^,;\s]+/) - { bool: false, set: :off, off: off_list} - else { bool: true, set: :na, off: [] } - end - act[:default_language]=if mod.inspect =~/"--(?:default-)?language[-=](\S{2})"/ - { set: :on, code: $1 } - elsif lng_base - { set: :on, code: lng_base } - else { set: :na, code: 'en' } - end - act[:i18n]=if mod.inspect =~/"(?:--monolingual|--i18n-mono(?:lingual)?)"/ #if monolingual possible outputs output_by :filename & :filetype only, without language code in default language name; give warning of conflict settings if monolingual & :language selected - @lingual=:mono - { set: :mono } - elsif mod.inspect =~/"(?:--multilingual|--i18n-multi(?:lingual)?)"/ - @lingual=:multi - { set: :multi } - else { set: :na } - end - act[:output_by]=if mod.inspect =~/"--(?:output-)?by-language"/ - @dir_structure_by=:language - { set: :language } - elsif mod.inspect =~/"--(?:output-)?by-filename"/ - @dir_structure_by=:filename - { set: :filename } - elsif mod.inspect =~/"--(?:output-)?by-filetype"/ - @dir_structure_by=:filetype - { set: :filetype } - else { set: :na } - end - act[:ocn]=if mod.inspect =~/"--ocn"|"--inc-ocn"|"--numbering"|"--inc-numbering"/ - { bool: true, set: :on } - elsif mod.inspect =~/"--no-ocn"|"--exc-ocn"|"--no-numbering"|"--exc-numbering"/ \ - || act[:switch][:off].inspect =~/"ocn"|"--numbering"/ - { bool: false, set: :off } - else { bool: true, set: :na } - end - act[:toc]=if mod.inspect =~/"--inc-toc"/ - { bool: true, set: :on } - elsif mod.inspect =~/"--(?:exc|no)-toc"/ \ - || act[:switch][:off].inspect =~/"toc"/ - { bool: false, set: :off } - else { bool: true, set: :na } - end - act[:minitoc]=if mod.inspect =~/"--inc-minitoc"/ - { bool: true, set: :on } - elsif mod.inspect =~/"--(?:exc|no)-minitoc"/ \ - || act[:switch][:off].inspect =~/"minitoc"/ - { bool: false, set: :off } - else { bool: true, set: :na } - end - act[:links_to_manifest]=if mod.inspect =~/"--inc-links-to-manifest"|"--inc-manifest-links"/ - { bool: true, set: :on } - elsif mod.inspect =~/"--(?:exc|no)-manifest"/ \ - || act[:switch][:off].inspect =~/"manifest"/ #place lower - { bool: false, set: :off } - elsif mod.inspect =~/"--(?:exc|no)-links-to-manifest"|"--(?:exc|no)-manifest-links"/ \ - || act[:switch][:off].inspect =~/"links_to_manifest"|"manifest_links"|"--(?:exc|no)-manifest"/ \ - || mod.inspect =~/"--(?:redirect|dump)/ - { bool: false, set: :off } - else { bool: true, set: :na } - end - act[:manifest_minitoc]=if mod.inspect =~/"--inc-manifest-minitoc"|"--inc-minitoc"/ - { bool: true, set: :on } - elsif mod.inspect =~/"--(?:exc|no)-manifest-minitoc"|"--(?:exc|no)-minitoc"/ \ - || act[:switch][:off].inspect =~/"manifest_minitoc"|"minitoc"/ - #|| mod.inspect =~/"--(?:redirect|dump)/ - { bool: false, set: :off } - else { bool: true, set: :na } - end - act[:metadata]=if mod.inspect =~/"--inc-metadata"/ - { bool: true, set: :on } - elsif mod.inspect =~/"--(?:exc|no)-metadata"/ \ - || act[:switch][:off].inspect =~/"metadata"/ - { bool: false, set: :off } - else { bool: true, set: :na } - end - act[:html_minitoc]=if mod.inspect =~/"--inc-html-minitoc"|"--inc-minitoc"/ - { bool: true, set: :on } - elsif mod.inspect =~/"--(?:exc|no)-html-minitoc"|"--(?:exc|no)-minitoc"/ \ - || act[:switch][:off].inspect =~/"html_minitoc"|"minitoc"/ - { bool: false, set: :off } - else { bool: true, set: :na } - end - act[:html_navigation]=if mod.inspect =~/"--inc-html-navigation"|"--inc-navigation"/ - { bool: true, set: :on } - elsif mod.inspect =~/"--(?:exc|no)-html-navigation"|"--(?:exc|no)-navigation"/ \ - || act[:switch][:off].inspect =~/"html_navigation"|"nav"/ - { bool: false, set: :off } - else { bool: true, set: :na } - end - act[:html_navigation_bar]=if mod.inspect =~/"--inc-html-navigation-bar"|"--inc-navigation-bar"/ - { bool: true, set: :on } - elsif mod.inspect =~/"--(?:exc|no)-html-navigation-bar"|"--(?:exc|no)-navigation-bar"/ \ - || act[:switch][:off].inspect =~/"html_navigation_bar"|"navbar"/ - { bool: false, set: :off } - else { bool: true, set: :na } - end - act[:segsubtoc]=if mod.inspect =~/"--inc-segsubtoc"/ - { bool: true, set: :on } - elsif mod.inspect =~/"--(?:exc|no)-segsubtoc"/ \ - || act[:switch][:off].inspect =~/"segsubtoc"/ - { bool: false, set: :off } - else { bool: true, set: :na } - end - act[:search_form]=if mod.inspect =~/"--inc-search-form"/ - { bool: true, set: :on } - elsif mod.inspect =~/"--(?:exc|no)-search-form"/ \ - || act[:switch][:off].inspect =~/"search_form"|"search"/ - { bool: false, set: :off } - else { bool: true, set: :na } - end - act[:html_search_form]=if mod.inspect =~/"--inc-html-search-form"|"--inc-search-form"/ - { bool: true, set: :on } - elsif mod.inspect =~/"--(?:exc|no)-html-search-form"|"--(?:exc|no)-search-form"/ \ - || act[:switch][:off].inspect =~/"html_search_form"|"search_form"|"search"/ - { bool: false, set: :off } - else { bool: true, set: :na } - end - act[:html_right_pane]=if mod.inspect =~/"--inc-html-right-pane"|"--inc-right-pane"|"--inc-html-right-column"|"--inc-right-column"/ - { bool: true, set: :on } - elsif mod.inspect =~/"--(?:exc|no)-html-right-pane"|"--(?:exc|no)-right-pane"|"--(?:exc|no)-html-right-column"|"--(?:exc|no)-right-column"/ \ - || act[:switch][:off].inspect =~/"html_right_pane"|"html_right_column"|"promo"/ - { bool: false, set: :off } - else { bool: true, set: :na } - end - act[:html_top_band]=if mod.inspect =~/"--inc-html-top-band"|"--inc-top-band"/ - { bool: true, set: :on } - elsif mod.inspect =~/"--(?:exc|no)-html-top-band"|"--(?:exc|no)-top-band"/ \ - || act[:switch][:off].inspect =~/"html-top-band"|"top-band"/ - { bool: false, set: :off } - else { bool: true, set: :na } - end - act[:html]=if mod.inspect =~/"--html-strict"/ \ - or ((cmd =~/h/ || mod.inspect =~/"--html"/) \ - && mod.inspect =~/"--strict"/) - act[:html_strict]={ bool: true, set: :on } - act[:html_scroll]={ bool: true, set: :on } - act[:html_seg]={ bool: true, set: :on } - { bool: true, set: :on } - elsif (cmd =~/h/ \ - || mod.inspect =~/"--html"/) - act[:html_strict]={ bool: false, set: :off } - act[:html_scroll]={ bool: true, set: :on } - act[:html_seg]={ bool: true, set: :on } - { bool: true, set: :on } - else - act[:html_strict]=(mod.inspect =~/"--strict"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:html_scroll]=(mod.inspect =~/"--html-scroll"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:html_seg]=(mod.inspect =~/"--html-seg"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - { bool: false, set: :na } - end - act[:concordance]=(cmd =~/w/ \ - || mod.inspect =~/"--concordance"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:images]=(cmd =~/j/ \ - || mod.inspect =~/"--images"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - if (cmd =~/p/ \ - || mod.inspect =~/"--pdf"/) - if mod.inspect =~/"--portrait"/ - act[:pdf]= { bool: false, set: :na } - act[:pdf_l]={ bool: false, set: :na } - act[:pdf_p]={ bool: true, set: :on } - elsif mod.inspect =~/"--landscape"/ - act[:pdf]= { bool: false, set: :na } - act[:pdf_l]={ bool: true, set: :on } - act[:pdf_p]={ bool: false, set: :na } - else - act[:pdf]= { bool: true, set: :on } - act[:pdf_l]={ bool: true, set: :on } - act[:pdf_p]={ bool: true, set: :on } - end - else - act[:pdf]= { bool: false, set: :na } - act[:pdf_p]= { bool: false, set: :na } - act[:pdf_l]= { bool: false, set: :na } - act[:pdf_a4]= { bool: false, set: :na } - act[:pdf_a5]= { bool: false, set: :na } - act[:pdf_b5]= { bool: false, set: :na } - act[:pdf_letter]={ bool: false, set: :na } - act[:pdf_legal]= { bool: false, set: :na } - end - if act[:pdf][:set]==:on \ - or act[:pdf_p][:set]==:on \ - or act[:pdf_l][:set]==:on - act[:pdf_a4]=if mod.inspect =~/"--a4"|--papersize-a4"/ \ - or mod.inspect =~/"--papersize=\S*a4\b\S*"/ #--papersize=a4,a5 - { bool: true, set: :on } - else - { bool: false, set: :na } - end - act[:pdf_a5]=if mod.inspect =~/"--a5"|"--papersize-a5"/ \ - or mod.inspect =~/"--papersize=\S*a5\b\S*"/ #--papersize=a4,a5 - { bool: true, set: :on } - else - { bool: false, set: :na } - end - act[:pdf_b5]=if mod.inspect =~/"--b5"|"--papersize-b5"/ \ - or mod.inspect =~/"--papersize=\S*b5\b\S*"/ - { bool: true, set: :on } - else - { bool: false, set: :na } - end - act[:pdf_letter]=if mod.inspect =~/"--letter"|"--papersize-letter"/ \ - or mod.inspect =~/"--papersize=\S*letter\b\S*"/ - { bool: true, set: :on } - else - { bool: false, set: :na } - end - act[:pdf_legal]=if mod.inspect =~/"--legal"|"--papersize-legal"/ \ - or mod.inspect =~/"--papersize=\S*legal\b\S*"/ - { bool: true, set: :on } - else - { bool: false, set: :na } - end - end - act[:epub]=(cmd =~/e/ \ - || mod.inspect =~/"--epub"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:odt]=if cmd =~/o/ \ - or mod.inspect =~/"--odt"|"--odf"|"--odt-(?:ocn|numbering)"|"--odf-(?:ocn|numbering)"/ - act[:odt_ocn]=if (mod.inspect =~/"--odt-(?:ocn|numbering)"|"--odf-(?:ocn|numbering)"/ \ - or mod.inspect =~/"--ocn"|"--inc-ocn"|"--numbering"|"--inc-numbering"/) - { bool: true, set: :on } - elsif mod.inspect =~/"--no-ocn"|"--exc-ocn"|"--no-numbering"|"--exc-numbering"/ - { bool: false, set: :off } - else - { bool: false, set: :na } - end - { bool: true, set: :on } - else - { bool: false, set: :na } - end - act[:xml_sax]=(cmd =~/x/ \ - || mod.inspect =~/"--xml-sax"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:xml_dom]=(cmd =~/X/ \ - || mod.inspect =~/"--xml-dom"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:xml_docbook_book]=(cmd =~/d/ \ - || mod.inspect =~/"--docbook"|"--docbook-book"|"--xml-docbook"|"--xml-docbook_book"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:xml_fictionbook]=(cmd =~/f/ \ - || mod.inspect =~/"--fictionbook"|"--xml-fictionbook"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:xml_scaffold_structure_sisu]=mod.inspect =~/"--xml-scaffold"|"--xml-scaffold-sisu"/ \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:xml_scaffold_structure_collapse]=mod.inspect =~/"--xml-scaffold-collapse"/ \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:xhtml]=(cmd =~/b/ \ - || mod.inspect =~/"--xhtml"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:txt]=if cmd =~/[at]/ \ - or mod.inspect =~/"--txt"|"--text"|"--plaintext"|"--txt-(?:ocn|numbering)"|"--text-(?:ocn|numbering)"|"--plaintext-(?:ocn|numbering)"/ - act[:txt_ocn]=if (mod.inspect =~/"--txt-(?:ocn|numbering)"|"--text-(?:ocn|numbering)"|"--plaintext-(?:ocn|numbering)"/ \ - or mod.inspect =~/"--ocn"|"--inc-ocn"|"--numbering"|"--inc-numbering"/) - { bool: true, set: :on } - elsif mod.inspect =~/"--no-ocn"|"--exc-ocn"|"--no-numbering"|"--exc-numbering"/ - { bool: false, set: :off } - else - { bool: false, set: :na } - end - { bool: true, set: :on } - else - { bool: false, set: :na } - end - act[:txt_textile]=(mod.inspect =~/"--textile"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:txt_asciidoc]=(mod.inspect =~/"--asciidoc"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:txt_markdown]=(mod.inspect =~/"--markdown"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:txt_rst]=(mod.inspect =~/"--rst"|"--rest"|"--restructuredtext"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:manpage]=(cmd =~/i/ \ - || mod.inspect =~/"--manpage"|"--man"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:texinfo]=(cmd =~/I/ \ - || mod.inspect =~/"--texinfo"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:psql]=if mod.inspect =~/"--pg-\S+"/ \ - or ((mod.inspect =~/"--pg"/) \ - && (mod.inspect \ - =~/"--createdb"|"--create(?:all)?"|"--dropall"|"--recreate(?:all)?"|"--import"|"--update"|"--remove"/)) - act[:psql_createdb]=if mod.inspect \ - =~/"--pg-createdb"|"--createdb"/ - { bool: true, set: :on } - else - { bool: false, set: :na } - end - if mod.inspect \ - =~/"--pg-recreate(?:all)?"|"--recreate(?:all)?"/ - act[:psql_drop]={ bool: true, set: :on } - act[:psql_create]={ bool: true, set: :on } - else - act[:psql_drop]=if mod.inspect \ - =~/"--pg-dropall"|"--dropall"/ - { bool: true, set: :on } - else - { bool: false, set: :na } - end - act[:psql_create]=if mod.inspect \ - =~/"--pg-create(?:all)?"|"--create(?:all)?"/ - { bool: true, set: :on } - else - { bool: false, set: :na } - end - end - act[:psql_import]=if mod.inspect \ - =~/"--pg-import"|"--import"/ - { bool: true, set: :on } - else - { bool: false, set: :na } - end - act[:psql_update]=if mod.inspect \ - =~/"--pg-update"|"--update"/ - act[:psql_remove]={ bool: true, set: :on } - { bool: true, set: :on } - else - act[:psql_remove]=if mod.inspect \ - =~/"--pg-remove"|"--remove"/ - { bool: true, set: :on } - else - { bool: false, set: :na } - end - { bool: false, set: :na } - end - { bool: true, set: :on } - else - act[:psql_createdb]= - { bool: false, set: :na } - act[:psql_drop]= - { bool: false, set: :na } - act[:psql_create]= - { bool: false, set: :na } - act[:psql_import]= - { bool: false, set: :na } - act[:psql_update]= - { bool: false, set: :na } - act[:psql_remove]= - { bool: false, set: :na } - { bool: false, set: :na } - end - act[:sqlite]=if (mod.inspect =~/"--sqlite-\S+"/) \ - or ((mod.inspect =~/"--sqlite"/) \ - && (mod.inspect \ - =~/"--createdb"|"--create(?:all)?"|"--dropall"|"--recreate(?:all)?"|"--import"|"--update"|"--remove"/)) - act[:sqlite_createdb]=if mod.inspect \ - =~/"--sqlite-createdb"|"--createdb"/ - { bool: true, set: :on } - else - { bool: false, set: :na } - end - if mod.inspect \ - =~/"--sqlite-recreate(?:all)?"|"--recreate(?:all)?"/ - act[:sqlite_drop]={ bool: true, set: :on } - act[:sqlite_create]={ bool: true, set: :on } - else - act[:sqlite_create]=if mod.inspect \ - =~/"--sqlite-create(?:all)?"|"--create(?:all)?"/ - { bool: true, set: :on } - else - { bool: false, set: :na } - end - act[:sqlite_drop]=if mod.inspect \ - =~/"--sqlite-dropall"|"--dropall"/ - { bool: true, set: :on } - else - { bool: false, set: :na } - end - end - act[:sqlite_import]=if mod.inspect \ - =~/"--sqlite-import"|"--import"/ - { bool: true, set: :on } - else - { bool: false, set: :na } - end - act[:sqlite_update]=if mod.inspect \ - =~/"--sqlite-update"|"--update"/ - act[:sqlite_remove]={ bool: true, set: :on } - { bool: true, set: :on } - else - act[:sqlite_remove]=if mod.inspect \ - =~/"--sqlite-remove"|"--sqlite-remove"/ - { bool: true, set: :on } - else - { bool: false, set: :na } - end - { bool: false, set: :na } - end - { bool: true, set: :on } - else - act[:sqlite_createdb]= - { bool: false, set: :na } - act[:sqlite_drop]= - { bool: false, set: :na } - act[:sqlite_create]= - { bool: false, set: :na } - act[:sqlite_import]= - { bool: false, set: :na } - act[:sqlite_update]= - { bool: false, set: :na } - act[:sqlite_remove]= - { bool: false, set: :na } - { bool: false, set: :na } - end - act[:sqlite_discrete]=mod.inspect =~/"--sql"|"--sqlite"/ \ - && (mod.inspect !~/"--createdb"|"--create(?:all)?"|"--dropall"|"--recreate(?:all)?"|"--import"|"--update"|"--remove"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:harvest]=(mod.inspect =~/"--harvest"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:po4a]=(cmd =~/P/ \ - || mod.inspect =~/"--po4a"|"--pot?"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:git]=(cmd =~/g/ \ - || mod.inspect =~/"--git"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:hash_digests]=(cmd =~/N/ \ - || mod.inspect =~/"--digests?"|"--hash-digests"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:pdf_font_size]=if mod.inspect =~/"--(?:pdf-)?font-?size[=-](\d{1,2})(?:pt)?"/ - $1 - else :na - end - act[:pdf_hyperlink_colors]=if mod.inspect =~/"--pdf-hyperlinks-(?:mono(?:chrome)?|no-color)"/ - :mono - elsif mod.inspect =~/"--pdf-hyperlinks-color"/ - :color - else :na - end - act[:hash_digest_algo]=if mod.inspect =~/"--hash-(?:sha)?512"/ - :sha512 - elsif mod.inspect =~/"--hash-(?:sha)?256"/ - :sha256 - elsif mod.inspect =~/"--hash-md5"/ - :md5 - else :na - end - act[:sample_search_form]=(cmd =~/F/ \ - || mod.inspect =~/"--sample-search-form"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:webrick]=(cmd =~/W/ \ - || mod.inspect =~/"--webrick"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:share_source]=(cmd =~/s/ \ - || mod.inspect =~/"--source"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:sisupod]=(cmd =~/S/ \ - || mod.inspect =~/"--sisupod"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:scp]=(cmd =~/r/ \ - || mod.inspect =~/"--scp"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:rsync]=(cmd =~/R/ \ - || mod.inspect =~/"--rsync"|"--remote"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:zap]=(cmd =~/Z/ \ - || mod.inspect =~/"--zap"|"--delete"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:urls_all]=(cmd =~/U/ \ - || mod.inspect =~/"--urls-all"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:urls_selected]=(cmd =~/u/ \ - || mod.inspect =~/"--urls"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:sitemap]=(cmd =~/Y/ \ - || mod.inspect =~/"--sitemap"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:qrcode]=(cmd =~/Q/ \ - || mod.inspect =~/"--qrcode"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:help]=(mod.inspect =~/"--help/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:ao]=if (cmd =~/m/ \ - || mod.inspect =~/"--ao"|"--dal"/) - { bool: true, set: :on } - elsif (act[:txt][:set]==:on \ - || act[:txt_textile][:set]==:on \ - || act[:txt_asciidoc][:set]==:on \ - || act[:txt_markdown][:set]==:on \ - || act[:txt_rst][:set]==:on \ - || act[:xhtml][:set]==:on \ - || act[:epub][:set]==:on \ - || act[:html][:set]==:on \ - || act[:html_seg][:set]==:on \ - || act[:html_scroll][:set]==:on \ - || act[:texinfo][:set]==:on \ - || act[:manpage][:set]==:on \ - || act[:hash_digests][:set]==:on \ - || act[:odt][:set]==:on \ - || act[:pdf][:set]==:on \ - || act[:pdf_p][:set]==:on \ - || act[:pdf_l][:set]==:on \ - || act[:qrcode][:set]==:on \ - || act[:share_source][:set]==:on \ - || act[:sisupod][:set]==:on \ - || act[:concordance][:set]==:on \ - || act[:xml_dom][:set]==:on \ - || act[:xml_sax][:set]==:on \ - || act[:xml_docbook_book][:set]==:on \ - || act[:xml_fictionbook][:set]==:on \ - || act[:xml_scaffold_structure_sisu][:set]==:on \ - || act[:xml_scaffold_structure_collapse][:set]==:on ) - { bool: true, set: :on } - #if cmd !~/[mn]/ - # extra+=if cmd =~/[abegHhIiLNOoPpQTtwXxyz]/ \ - # and cmd !~/[mn]/ - # 'm' #% add ao - #elsif (act[:txt][:set]==:on \ - # { bool: true, set: :on } - # elsif ((cmd =~/[Dd]/ \ - # or (mod.inspect =~/--(?:(?:sq)?lite|pg(?:sql)?)/)) \ - # and mod.inspect !~/(?:remove|(?:(?:re)?create(?:all)?|dropall|drop)$)/) \ - # and cmd !~/[mn]/ - # 'm' #% add ao - else - { bool: false, set: :na } - end - act[:manifest]=if mod.inspect =~/"--inc-manifest"/ - { bool: true, set: :on } - elsif mod.inspect =~/"--(?:exc|no)-manifest"/ \ - || act[:switch][:off].inspect =~/"manifest"/ - { bool: false, set: :off } - elsif (cmd =~/y/ \ - || mod.inspect =~/"--manifest"/) - { bool: true, set: :on } - elsif (act[:txt][:set]==:on \ - || act[:txt_textile][:set]==:on \ - || act[:txt_asciidoc][:set]==:on \ - || act[:txt_markdown][:set]==:on \ - || act[:txt_rst][:set]==:on \ - || act[:xhtml][:set]==:on \ - || act[:epub][:set]==:on \ - || act[:html][:set]==:on \ - || act[:html_seg][:set]==:on \ - || act[:html_scroll][:set]==:on \ - || act[:texinfo][:set]==:on \ - || act[:manpage][:set]==:on \ - || act[:hash_digests][:set]==:on \ - || act[:odt][:set]==:on \ - || act[:pdf][:set]==:on \ - || act[:pdf_p][:set]==:on \ - || act[:pdf_l][:set]==:on \ - || act[:qrcode][:set]==:on \ - || act[:share_source][:set]==:on \ - || act[:sisupod][:set]==:on \ - || act[:concordance][:set]==:on \ - || act[:xml_dom][:set]==:on \ - || act[:xml_sax][:set]==:on \ - || act[:xml_docbook_book][:set]==:on \ - || act[:xml_fictionbook][:set]==:on \ - || act[:xml_scaffold_structure_sisu][:set]==:on \ - || act[:xml_scaffold_structure_collapse][:set]==:on ) - { bool: true, set: :on } - ## if cmd !~/y/ - ## extra+=if cmd =~/[abeHhIiNopQSstwXxz]/ \ - ## and cmd !~/y/ - ## 'ym' #% add manifest - #elsif (act[:txt][:set]==:on \ - # { bool: true, set: :on } - # elsif (cmd =~/[Dd]/ \ - # or mod.inspect =~/--(?:(?:sq)?lite|pg(?:sql)?)/) \ - # and files[0] !~/^remove$/ \ - # and cmd !~/y/ - # 'ym' #% add manifest - else { bool: true, set: :na } - end - act[:console_messages] = '' - act[:verbose]=if (cmd =~/v/ \ - || mod.inspect =~/"--verbose"/) - act[:console_messages] << ' --verbose ' - { bool: true, set: :on } - else - { bool: false, set: :na } - end - act[:verbose_plus]=if (cmd =~/V/ \ - || mod.inspect =~/"--very-verbose"/) - act[:console_messages] << ' --very-verbose ' - { bool: true, set: :on } - else - { bool: false, set: :na } - end - act[:version_info]=if (cmd =~/[vVM]/ \ - || mod.inspect =~/"--verbose"|"--maintenance"/) - act[:console_messages] << ' --maintenance ' - { bool: true, set: :on } - else - { bool: false, set: :na } - end - act[:quiet]=if (cmd =~/q/ \ - || mod.inspect =~/"--quiet"/) - act[:console_messages] << ' --quiet ' - { bool: true, set: :on } - else - { bool: false, set: :na } - end - act[:color_state]=if mod.inspect =~/"--color-on"|"--color"/ - act[:console_messages] << ' --color-on ' - { bool: true, set: :on } - elsif (cmd =~/k/ \ - || mod.inspect =~/"--color-off"/) - act[:console_messages] << ' --color-off ' - { bool: false, set: :off } - else { bool: true, set: :na } #fix default color - end -# act[:color_toggle]=if cmd =~/c/ \ -# or mod.inspect =~/"--color-toggle"/ -# true -# else false -# end - act[:maintenance]=if (cmd =~/M/ \ - || mod.inspect =~/"--maintenance|--keep-processing-files"/) - act[:console_messages] << ' --maintenance ' - { bool: true, set: :on } - else - { bool: false, set: :na } - end - act[:profile]=if (cmd =~/E/ \ - || mod.inspect =~/"--profile"/) - act[:console_messages] << ' --color-off ' - { bool: true, set: :on } - else - { bool: false, set: :na } - end - @act=act - end - end - def cmd - @cmd - end - def mod - @mod - end - def act - @@act - end - def files_mod - files_mod=files - @files_mod=files_mod - end - def f_pth - @f_pth - end - def pth - @pth - end - def sub_location - pth.gsub(/#{base_path}/,'') - end - def lng - @lng - end - def lng_base - @lng_base - end - def fno - @fno=(fns.nil? || fns.empty?) \ - ? '' \ - : (fns[/(.+?(?:sst|ssm))(?:\.sst)?/,1]) - end - def fng - @fng=(fno.nil? || fno.empty?) \ - ? '' \ - : (fno.gsub(/(?:~(?:#{Px[:lng_lst_rgx]}))?(\.ss[tm])$/,'\1')) - end - def fns - @fns - end - def fnl - @fns.gsub(/(\S+?)((?:\.ssm)?\.sst)/,"\\1.#{lng}\\2") - end - def what - @what - end - def fnb - (fns.nil? || fns.empty?) \ - ? '' \ - : (fns[/(.+?)\.(?:(?:-|ssm\.)?sst|ssm)$/,1]) - end - def fnc - @fnc=(@fns =~/\.(?:ssm\.sst|ssm)$/) \ - ? fnb + '.ssm.sst' - : @fns - end - def fncb - @fncb=(@fns =~/(?:\~\S{2,3})?\.(?:ssm\.sst|ssm)$/) \ - ? fnb + '.ssm.sst' - : @fns.gsub(/(?:\~\S{2,3})?(\.sst)$/,'\1') - end - end -end -__END__ -note usually named @opt is carried in Param (usually as @md.opt), @opt is a -subset of @md where @md is passed, contents of @opt are available as @md.opt -passing @opt as well is duplication check for fns & fnb diff --git a/lib/sisu/v6/param.rb b/lib/sisu/v6/param.rb deleted file mode 100644 index 25b50ba8..00000000 --- a/lib/sisu/v6/param.rb +++ /dev/null @@ -1,1550 +0,0 @@ -# encoding: utf-8 -=begin - - * Name: SiSU - - * Description: a framework for document structuring, publishing and search - - * Author: Ralph Amissah - - * Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, - All Rights Reserved. - - * License: GPL 3 or later: - - SiSU, a framework for document structuring, publishing and search - - Copyright (C) Ralph Amissah - - This program is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the Free - Software Foundation, either version 3 of the License, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - more details. - - You should have received a copy of the GNU General Public License along with - this program. If not, see . - - 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: - - - * Git - - - - * Ralph Amissah - - - - ** Description: parameters extracted from input file(s) for program use - -=end -module SiSU_Param - begin - require 'uri' - require 'pstore' - rescue LoadError - SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). - error('uri or pstore NOT FOUND (LoadError)') - end - require_relative 'sysenv' # sysenv.rb - include SiSU_Env - require_relative 'param_make' # param_make.rb - require_relative 'param_identify_markup' # param_identify_markup.rb - @@date=SiSU_Env::InfoDate.new - @@proc= - @@filename_txt= - @@filename_texinfo= - @@filename_lout_portrait= - @@filename_lout_landscape= - @@filename_html_scroll= - @@filename_html_index= - @@filename_html_segtoc= - @@filename_semantic= - @@filename_rss= - @@newfile= - @@drr= - nil - @doc={ - initialise: nil, - markup: '', - lnks: '', - stmp: '', - req: {}, - } - @@yaml=@@yamladdr=nil - @@trigger=nil - @@lv,@@flag={},{} - @@tex_backslash="\\\\" - class Parameters - @@publisher='SiSU scribe' - @@md=@@fns=@@pth=nil - def initialize(opt) - @opt=opt - @cX||=SiSU_Screen::Ansi.new(@opt.act[:color_state][:set]) - @cmd,@mod=opt.cmd,opt.mod - @fns=if @opt.cmd =~/P/ #revisit CHECK - opt.fns - else opt.fns.gsub(/\.ssm$/,'.ssm.sst') - end - SiSU_Param::Instantiate.new.param_instantiate - @env=SiSU_Env::InfoEnv.new(@fns) - @pstorefile="#{@env.processing_path.ao}/#{@fns}.pstore" - end - def get - if @opt.f_pth \ - and @opt.f_pth[:pth] != Dir.pwd #BUG check - # you may need to change Dir.pwd to @opt.f_pth[:pth] where the latter - # has a path value that is different, however, f_pth is not always set! - Dir.chdir(@opt.f_pth[:pth]) - end - if @@fns !=@fns \ - or @@pth !=Dir.pwd #@opt.f_pth[:pth] - @@fns,@@pth=@fns,Dir.pwd #@opt.f_pth[:pth] - @@md=nil - end - if @@md.nil? \ - or @opt.act[:maintenance][:set]==:on #not particularly helpful, as current cycle is through output types, with files changing, only helpful if deal with a file all output types before going to next file - if File.exist?(@pstorefile) - param_msg='Parameters from pstore' - store=PStore.new(@pstorefile) - store.transaction do - @md=store['md'] - end - @md - else - param_msg='Parameters extracted' - fns_array=@env.read_source_file(@opt.fns) - @md=SiSU_Param::Parameters::Instructions.new(fns_array,@opt).extract - @md - end - if defined? @md.title.main # on removal check problems with -U - if (@opt.act[:verbose][:set]==:on \ - || @opt.act[:verbose_plus][:set]==:on \ - || @opt.act[:maintenance][:set]==:on) - SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - param_msg, - @md.title.main - ).txt_grey - end - end - @@md=@md - else @@md - end - @@md.opt=@opt - @@md - end - class MdDefault - def rights(author,date) - @author,@date=author,date - def all - s=nil - if @author - s ||=((@date =~/((?:1[4-9]|2[01])\d{2})/ ) \ - ? ("Copyright (C) #{$1} #{@author}") - : ('Copyright (C)' + @author)) #matches years 1400 through 21\d\d - end - s - end - def text - all - end - def copyright - def all - s=nil - if @author - s ||=((@date =~/((?:1[4-9]|2[01])\d{2})/ ) \ - ? ("Copyright (C) #{$1} #{@author}") - : ('Copyright (C)' + @author)) #matches years 1400 through 21\d\d - end - s - end - def text - all - end - self - end - self - end - end - class MdMake < SiSU_Param_Make::MdMake - end - class Md - def initialize(str,opt,env) - @s,@opt,@env=str,opt,env - end - def validate_length(s,l,n) - #s=(s.length <= l) ? s : nil - s=if s.is_a?(String) \ - and s.length <= l - s - elsif s.is_a?(NilClass) - nil - elsif s.class !=String - STDERR.puts "#{n} is #{s.class}: programming error, String expected #{__FILE__}:#{__LINE__}" - s - else - SiSU_Screen::Ansi.new( - 'v', - "*WARN* #{n} length #{s.length} exceeds set db field length #{l}, metadata dropped", - @opt.fns - ).warn unless @opt.act[:quiet][:set]==:on - nil - end - end - def name_format(name) - if name - name=name.strip - @name_a_h=[] - authors=name.scan(/[^;]+/) - authors.each_with_index do |a,i| - b=((a =~/\s*\|\s*/) ? (a.split(/\|/)) : [a]) - if b[0] =~/"(.+?)"/ - @name_a_h << { the: $1 } - else - x=b[0].scan(/[^,]+/) - if x.length==1 - @name_a_h << { the: x[0].strip } - elsif x.length==2 - @name_a_h << { the: x[0].strip, others: x[1].strip } - else #p x.length - end - end - b.delete_at(0) - b.each do |d| - k,c=nil - k,c=/^(\S+)\s+(.*)/.match(d)[1,2] if d - @name_a_h[i][:hon]=c.strip if k=='hon' - @name_a_h[i][:affiliation]=c.strip if k=='affiliation' - @name_a_h[i][:nationality]=c.strip if k=='nationality' - end - end - l=@name_a_h.length - name_str='' - @name_a_h.each_with_index do |a,i| - name_str += if a[:others] - z=(((l - i) > 1) ? ', ' : '') - "#{a[:others].strip} #{a[:the].strip}" + z - else - z=(((l - i) > 2) ? ', ' : '') - "#{a[:the].strip}" + z - end - end - { name_a_h: @name_a_h, name_str: name_str } - else nil - end - end - def build_hash(arr) - @h={} - arr.each_with_index do |x,i| - a,b=nil,nil - if x =~/^%\s/ #ignore comment - elsif x =~/:(\S+?):\s+(.+)/ - a,b=/:(\S+?):\s+(.+)\Z/m.match(x)[1,2] - b=b.gsub(/\s*\s*/,' \\\\\\ ') - b=if b =~/\n/m - (b =~/;\n/m) \ - ? (b.split(/;\s*\n\s*/).join(';')) - : (b.split(/\s*\n\s*/).join(' ')) - else - b - end - elsif i == 0 - a='main' - b=x - else - end - @h[a]=b - end - @h - end - def title - a=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m) - @h=build_hash(a) - def main - s=@h['main'] - l,n=Db[:col_title_part],'title.main' - validate_length(s,l,n) - end - def sub - s=@h['subtitle'] - l,n=Db[:col_title_part],'title.subtitle' - validate_length(s,l,n) - end - def edition - s=@h['edition'] - l,n=Db[:col_title_edition],'title.edition' - validate_length(s,l,n) - end - def note - s=@h['note'] - l,n=Db[:col_info_note],'title.note' - validate_length(s,l,n) - end - def short - s=@h['short'] \ - ? @h['short'] - : @h['main'] - l,n=Db[:col_title_part],'title.short' - validate_length(s,l,n) - end - def full - s=@h['subtitle'] \ - ? (@h['main'] + ' - ' + @h['subtitle']) - : @h['main'] - l,n=Db[:col_title],'title.full' - validate_length(s,l,n) - end - def language - s=@h['language'] - l,n=Db[:col_language],'title.language' - validate_length(s,l,n) - end - def language_char # look into, this must be set, from 1 directory stub (.fi), 2 filename (~fi), [3 (not used) document header (@title:\n :language_char: fi)] - s=@h['language_char'] - l,n=Db[:col_language_char],'title.language_char' - validate_length(s,l,n) - end - self - end - def creator #there are sub categories that need to be catered for and sometimes more than one author etc.; implement array.to_s.length validation test later, current test on string approximate as string is not used - a=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m) - @h=build_hash(a) - def author - @h['author']=(@h['author'] \ - ? @h['author'] - : @h['main']) - names=name_format(@h['author']) - s=names[:name_str] - l,n=Db[:col_name],'creator.author' - validate_length(s,l,n) - end - def author_detail - s=@h['author'] \ - ? @h['author'] - : @h['main'] - names=name_format(s) - names[:name_a_h] - end - def editor - names=@h['editor'] \ - ? name_format(@h['editor']) - : nil - s=(names.is_a?(Hash)) \ - ? names[:name_str] - : nil - s=if s - l,n=Db[:col_name],'creator.editor' - validate_length(s,l,n) - else nil - end - end - def editor_detail - names=@h['editor'] \ - ? name_format(@h['editor']) - : nil - (names.is_a?(Hash)) \ - ? names[:name_a_h] - : nil - end - def contributor - names=@h['contributor'] \ - ? name_format(@h['contributor']) - : nil - s=(names.is_a?(Hash)) \ - ? names[:name_str] - : nil - s=if s - l,n=Db[:col_name],'creator.author' - validate_length(s,l,n) - else nil - end - end - def contributor_detail - names=@h['contributor'] \ - ? name_format(@h['contributor']) - : nil - (names.is_a?(Hash)) \ - ? names[:name_a_h] - : nil - end - def illustrator - names=@h['illustrator'] \ - ? name_format(@h['illustrator']) - : nil - s=(names.is_a?(Hash)) \ - ? names[:name_str] - : nil - s=if s - l,n=Db[:col_name],'creator.illustrator' - validate_length(s,l,n) - else nil - end - end - def illustrator_detail - names=@h['illustrator'] \ - ? name_format(@h['illustrator']) - : nil - (names.is_a?(Hash)) \ - ? names[:name_a_h] - : nil - end - def photographer - names=@h['photographer'] \ - ? name_format(@h['photographer']) - : nil - s=(names.is_a?(Hash)) \ - ? names[:name_str] - : nil - s=if s - l,n=Db[:col_name],'creator.photographer' - validate_length(s,l,n) - else nil - end - end - def photographer_detail - names=@h['photographer'] \ - ? name_format(@h['photographer']) - : nil - (names.is_a?(Hash)) \ - ? names[:name_a_h] - : nil - end - def translator - names=@h['translator'] \ - ? name_format(@h['translator']) - : nil - s=(names.is_a?(Hash)) \ - ? names[:name_str] - : nil - s=if s - l,n=Db[:col_name],'creator.translator' - validate_length(s,l,n) - else nil - end - end - def translator_detail - names=@h['translator'] \ - ? name_format(@h['translator']) - : nil - (names.is_a?(Hash)) \ - ? names[:name_a_h] - : nil - end - def audio - names=@h['audio'] \ - ? name_format(@h['audio']) - : nil - s=(names.is_a?(Hash)) \ - ? names[:name_str] - : nil - s=if s - l,n=Db[:col_name],'creator.audio' - validate_length(s,l,n) - else nil - end - end - def audio_detail - names=@h['audio'] \ - ? name_format(@h['audio']) - : nil - (names.is_a?(Hash)) \ - ? names[:name_a_h] - : nil - end - def digitized_by - names=@h['digitized_by'] \ - ? name_format(@h['digitized_by']) - : nil - s=(names.is_a?(Hash)) \ - ? names[:name_str] - : nil - s=if s - l,n=Db[:col_name],'creator.digitized_by' - validate_length(s,l,n) - else nil - end - end - def digitized_by_detail - names=@h['digitized_by'] \ - ? name_format(@h['digitized_by']) - : nil - (names.is_a?(Hash)) \ - ? names[:name_a_h] - : nil - end - def prepared_by - names=@h['prepared_by'] \ - ? name_format(@h['prepared_by']) - : nil - s=(names.is_a?(Hash)) \ - ? names[:name_str] - : nil - s=if s - l,n=Db[:col_name],'creator.prepared_by' - validate_length(s,l,n) - else nil - end - end - def prepared_by_detail - names=@h['prepared_by'] \ - ? name_format(@h['prepared_by']) - : nil - names=name_format(@h['prepared_by']) - (names.is_a?(Hash)) \ - ? names[:name_a_h] - : nil - end - self - end - def rights - a=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m) - @h=build_hash(a) - def copyright - def text #you may wish to expand to take from all - s=if @h['copyright'] then @h['copyright'] - elsif @h['text'] then @h['text'] - elsif @h['main'] then @h['main'] - else - SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - 'WARNING Document Copyright missing; provide @rights: :copyright:' - ).warn unless @opt.act[:quiet][:set]==:on - '' - end - l,n=Db[:col_info_note],'rights.copyright.text' - validate_length(s,l,n) - end - def translation - s=@h['translation'] \ - ? @h['translation'] - : nil - l,n=Db[:col_info_note],'rights.copyright.translation' - validate_length(s,l,n) - end - def illustrations - s=@h['illustrations'] \ - ? @h['illustrations'] - : nil - l,n=Db[:col_info_note],'rights.copyright.illustrations' - validate_length(s,l,n) - end - def photographs - s=@h['photographs'] \ - ? @h['photographs'] - : nil - l,n=Db[:col_info_note],'rights.copyright.photographs' - validate_length(s,l,n) - end - def digitization - s=@h['digitization'] \ - ? @h['digitization'] - : nil - l,n=Db[:col_info_note],'rights.copyright.digitization' - validate_length(s,l,n) - end - def audio - s=@h['audio'] \ - ? @h['audio'] - : nil - l,n=Db[:col_info_note],'rights.copyright.audio' - validate_length(s,l,n) - end - self - end - def license - s=@h['license'] \ - ? @h['license'] - : nil - l,n=Db[:col_info_note],'rights.license' - validate_length(s,l,n) - end - def sep(str) - ' \\\\ ' - end - def all - s=if @h['all'] then @h['all'] - else - s='' - if defined? copyright.text \ - and copyright.text \ - and not copyright.text.empty? - v=sep(copyright.text) - s +='Copyright: ' + copyright.text + v - end - if defined? copyright.translation \ - and copyright.translation \ - and not copyright.translation.empty? - v=sep(copyright.translation) - s +='translation: ' + copyright.translation + v - end - if defined? copyright.illustrations \ - and copyright.illustrations \ - and not copyright.illustrations.empty? - v=sep(copyright.illustrations) - s +='illustrations: ' + copyright.illustrations + v - end - if defined? copyright.photographs \ - and copyright.photographs \ - and not copyright.photographs.empty? - v=sep(copyright.photographs) - s +='photographs: ' + copyright.photographs + v - end - if defined? copyright.digitization \ - and copyright.digitization \ - and not copyright.digitization.empty? - v=sep(copyright.digitization) - s +='digitization: ' + copyright.digitization + v - end - if defined? copyright.audio \ - and copyright.audio \ - and not copyright.audio.empty? - v=sep(copyright.audio) - s +='audio: ' + copyright.audio + v - end - if defined? copyright.license \ - and copyright.license \ - and not copyright.license.empty? - s +='License: ' + copyright.license - end - if s.empty? - SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - 'WARNING Document Rights information missing; provide @rights: :copyright:' - ).warn unless @opt.act[:quiet][:set]==:on - else - l,n=Db[:col_info_note],'rights.all' - validate_length(s,l,n) - end - s=s.gsub(/ [\\]+\s+$/,'') - end - s - end - self - end - def identifier - a=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m) - @h=build_hash(a) - def oclc - s=@h['oclc'] - l,n=Db[:col_library],'identifier.oclc' - validate_length(s,l,n) - end - def isbn - s=@h['isbn'] - l,n=Db[:col_small],'identifier.isbn' - validate_length(s,l,n) - end - def pg - s=@h['pg'] - l,n=Db[:col_small],'identifier.pg' - validate_length(s,l,n) - end - self - end - def classify - a=@s.split(/(\n%\s.+?$|[ ]*)(?:\n[ ]*(?=:)|\Z)/m) - @h=build_hash(a) - def topic_register - s=@h['topic_register'] - l,n=Db[:col_info_note],'classify.topic_register' - validate_length(s,l,n) - end - def subject - s=@h['subject'] - l,n=Db[:col_txt_long],'classify.subject' - validate_length(s,l,n) - end - def keywords - s=@h['keywords'] - l,n=Db[:col_txt_long],'classify.keywords' - validate_length(s,l,n) - end - def loc - s=@h['loc'] - l,n=Db[:col_library],'classify.loc' - validate_length(s,l,n) - end - def dewey - s=@h['dewey'] - l,n=Db[:col_library],'classify.dewey' - validate_length(s,l,n) - end - self - end - def publisher - a=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m) - @h=build_hash(a) - s=@h['main'] - l,n=Db[:col_name],'publisher' - validate_length(s,l,n) - end - def date - a=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m) - @h=build_hash(a) - def added_to_site - s=@h['added_to_site'] - l,n=Db[:col_date_text],'date.added_to_site' - validate_length(s,l,n) - end - def available - s=@h['available'] - l,n=Db[:col_date_text],'date.available' - validate_length(s,l,n) - end - def created - s=@h['created'] - l,n=Db[:col_date_text],'date.created' - validate_length(s,l,n) - end - def issued - s=@h['issued'] - l,n=Db[:col_date_text],'date.issued' - validate_length(s,l,n) - end - def modified - s=@h['modified'] - l,n=Db[:col_date_text],'date.modified' - validate_length(s,l,n) - end - def published - s=@h['published']=(@h['published'] ? @h['published'] : @h['main']) - l,n=Db[:col_date_text],'date.published' - validate_length(s,l,n) - end - def valid - s=@h['valid'] - l,n=Db[:col_date_text],'date.valid' - validate_length(s,l,n) - end - self - end - #def language # as things stand this should really be populated from title.language and original.language, resolve - # a=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m) - # @h=build_hash(a) - # def document - # s=@h['document']=(@h['document'] ? @h['document'] : @h['main']) - # l,n=Db[:col_language],'language.document' - # validate_length(s,l,n) - # end - # def document_char - # s=@h['document_char']=(@h['document_char'] ? @h['document_char'] : nil) - # l,n=Db[:col_language_char],'language.document_char' - # validate_length(s,l,n) - # end - # def original - # s=@h['original'] - # l,n=Db[:col_language],'language.original' - # validate_length(s,l,n) - # end - # def original_char - # s=@h['original_char'] - # l,n=Db[:col_language_char],'language.original_char' - # validate_length(s,l,n) - # end - # self - #end - def current_publisher - @s - end - def original - a=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m) - @h=build_hash(a) - def publisher - s=@h['publisher'] - l,n=Db[:col_name],'original.publisher' - validate_length(s,l,n) - end - def language - s=@h['language'] - l,n=Db[:col_language],'original.language' - validate_length(s,l,n) - end - def language_char - s=@h['language_char'] - l,n=Db[:col_language_char],'original.language_char' - validate_length(s,l,n) - end - def source - s=@h['source'] - l,n=Db[:col_name],'original.source' - validate_length(s,l,n) - end - def institution - s=@h['institution'] - l,n=Db[:col_name],'original.institution' - validate_length(s,l,n) - end - def nationality - s=@h['nationality'] - l,n=Db[:col_language],'original.nationality' - validate_length(s,l,n) - end - self - end - def notes - a=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m) - @h=build_hash(a) - def description - s=@h['description'] - l,n=Db[:col_info_note],'notes.description' - validate_length(s,l,n) - end - def abstract - s=@h['abstract'] - l,n=Db[:col_info_note],'notes.abstract' - validate_length(s,l,n) - end - def comment - s=@h['comment'] - l,n=Db[:col_info_note],'notes.comment' - validate_length(s,l,n) - end - def coverage - s=@h['coverage'] - l,n=Db[:col_info_note],'notes.coverage' - validate_length(s,l,n) - end - def relation - s=@h['relation'] - l,n=Db[:col_info_note],'notes.relation' - validate_length(s,l,n) - end - def source - s=@h['source'] - l,n=Db[:col_txt_long],'notes.source' - validate_length(s,l,n) - end - def history - s=@h['history'] - l,n=Db[:col_txt_long],'notes.history' - validate_length(s,l,n) - end - def type - s=@h['type'] - l,n=Db[:col_txt_long],'notes.relation' - validate_length(s,l,n) - end - def format - s=@h['format'] - l,n=Db[:col_txt_short],'notes.format' - validate_length(s,l,n) - end - def prefix - @h['prefix'] - end - self - end - end - class Instructions - @doc={ lv: [] } - @doc[:fns],@doc[:fnb],@doc[:scr_suffix]='','','' - @@publisher='SiSU scribe' - attr_accessor :make,:env,:path,:file,:fn,:fns,:fno,:fnb,:fnn,:fnt,:fnl,:flv,:fnz,:fnstex,:ocn,:sfx_src,:pdf,:file_type,:dir_out,:dir_tex,:dir_lout,:txt_path,:sisu,:sisu_version,:ruby_version,:title,:subtitle,:full_title,:html_title,:subtitle_tex,:creator,:classify,:author_home,:author,:author_title,:author_nationality,:authors,:authorship,:translator,:illustrator,:prepared_by,:digitized_by,:subject,:description,:publisher,:current_publisher,:contributor,:date,:date_created,:date_issued,:date_available,:date_valid,:date_modified,:date_translated,:date_added_to_site,:date_scheme,:date_created_scheme,:date_issued_scheme,:date_available_scheme,:date_valid_scheme,:date_modified_scheme,:type,:format,:identifier,:source,:language,:language_original,:relation,:coverage,:rights,:keywords,:comments,:abstract,:cls_loc,:cls_dewey,:cls_pg,:cls_isbn,:papersize,:papersize_array,:toc,:lv0,:lv1,:lv2,:lv3,:lv4,:lv5,:lv6,:lvs,:pagenew,:pagebreak,:pageline,:num_top,:bold_match_list,:italics_match_list,:substitution_match_list,:emphasis_set_to,:toc_lev_limit,:flag_endnotes,:flag_auto_endnotes,:flag_separate_endnotes,:flag_separate_endnotes_make,:markup,:markup_instruction,:flag_tables,:vocabulary,:doc_css,:yaml,:lnk,:links,:prefix_a,:prefix_b,:suffix,:information,:contact,:icon,:image,:ad_url,:ad_png,:ad_alt,:ad_began,:flag_promo,:promo,:ad_home,:stmp,:stmpd,:sc_filename,:sc_number,:sc_date,:sc_time,:sc_info,:yamladdr,:locale,:wc_lines,:wc_words,:wc_bytes,:file_encoding,:filesize,:user,:home,:hostname,:pwd,:firstseg,:programs,:author_copymark,:i18n,:lang,:lang_code_insert,:en,:notes,:dgst,:generated,:tags,:tag_array,:concord_make,:seg_names,:seg_autoname_safe,:set_header_title,:set_heading_top,:set_heading_seg,:heading_seg_first,:heading_seg_first_flag,:base_program,:ec,:opt,:sem_tag,:book_idx,:topic_register,:topic_register_array,:original,:writing_focus,:audio,:daisy,:home_button_image,:home_button_links,:footer_links,:cover_image,:man_section - def initialize(fns_array,opt) - @env=@path,@file=@fn=@fns=@fno=@fnb=@fnn=@fnt=@fnl=@flv=@fnz=@fnstex=@ocn=@sfx_src=@pdf=@file_type=@dir_out=@dir_tex=@dir_lout=@txt_path=@make=@flag_endnotes=@flag_auto_endnotes=@flag_separate_endnotes=@flag_separate_endnotes_make=@sisu=@sisu_version=@ruby_version=@title=@subtitle=@full_title=@html_title=@subtitle_tex=@creator=@classify=@author_home=@author=@author_title=@author_nationality=@translator=@illustrator=@prepared_by=@digitized_by=@subject=@description=@publisher=@current_publisher=@contributor=@date=@date_created=@date_issued=@date_available=@date_valid=@date_modified=@date_translated=@date_added_to_site=@date_scheme=@date_created_scheme=@date_issued_scheme=@date_available_scheme=@date_valid_scheme=@date_modified_scheme=@type=@format=@identifier=@source=@language=@language_original=@relation=@coverage=@rights=@keywords=@comments=@abstract=@cls_loc=@cls_dewey=@cls_pg=@cls_isbn=@papersize=@toc=@lv0=@lv1=@lv2=@lv3=@lv4=@lv5=@lv6=@pagenew=@pagebreak=@pageline=@num_top=@bold_match_list=@italics_match_list=@substitution_match_list=@emphasis_set_to=@toc_lev_limit=@flag_tables=@vocabulary=@doc_css=@yaml=@lnk=@links=@prefix_a=@prefix_b=@suffix=@information=@contact=@icon=@ad_url=@ad_png=@ad_alt=@ad_began=@promo=@ad_home=@stmp=@stmpd=@sc_filename=@sc_number=@sc_date=@sc_time=@sc_info=@yamladdr=@locale=@wc_lines=@wc_words=@wc_bytes=@file_encoding=@filesize=@firstseg=@programs=@author_copymark=@i18n=@lang=@lang_code_insert=@en=@notes=@dgst=@generated=@heading_seg_first=@base_program=@topic_register=@original=@writing_focus=@audio=@home_button_image=@home_button_links=@cover_image=@man_section=nil - @data, @path, @fns, @fno, @opt= - fns_array,opt.pth,opt.fns,opt.fno,opt #@data used as data - @flag_tables,@set_header_title,@set_heading_top,@set_heading_seg,@heading_seg_first_flag,@flag_promo,@book_idx= - false, false, false, false, false, false, false - @seg_autoname_safe=true - @daisy,@sem_tag=false,false - @authorship,@markup_instruction,@image='','','','' #check which other values should be set to empty rather than nil - @markup=@markup_instruction #use @markup_instruction - @doc,@fn,@make_italic,@tag_hash,@ec={},{},{},{},{},{} - @flv,@lang,@seg_names,@tags,@tag_array,@tag_a,@ec[:image],@ec[:audio],@ec[:multimedia]=Array.new(9){[]} - @authors,@topic_register_array,@papersize_array=[],[],[] - @lvs=[nil,0,0,0,0,0,0] - @emphasis_set_to='bold' - @lang_code_insert=SiSU_Env::FilenameLanguageCodeInsert.new(@opt).language_code_insert - @footer_links= { left: { say: '', url: '' }, center: { say: '', url: '' } } - @rgx_image=/(?:^|[^_\\])\{(?:\s*|\~\^\s+)(\S+?\.(?:png|jpg|gif)\b)/m - @rgx_audio=/\{\s*(\S+?\.(?:mp3|ogg))/ - @rgx_mm=/\{\s*(\S+?\.(?:ogg|mpeg))/ #expand and distinguish ogg - Dir.chdir(@opt.f_pth[:pth]) - begin - rescue - SiSU_Errors::Rescued.new($!,$@,@opt.cmd,@fns).location do - __LINE__.to_s + ':' + __FILE__ - end - ensure - end - @header_make_links_append=:no - common_makes=(defined? @opt.make_instructions_pod) \ - && @opt.make_instructions_pod !=nil \ - && @opt.make_instructions_pod[:makeset]==true \ - ? @opt.make_instructions_pod - : @opt.make_instructions - if common_makes[:makeset] - @pagenew=common_makes[:pagenew] - @pagebreak=common_makes[:pagebreak] - @pageline=common_makes[:pageline] - @toc=common_makes[:toc] - @lv0=common_makes[:lv0] - @lv1=common_makes[:lv1] - @lv2=common_makes[:lv2] - @lv3=common_makes[:lv3] - @lv4=common_makes[:lv4] - @lv5=common_makes[:lv5] - @lv6=common_makes[:lv6] - @num_top=common_makes[:num_top] - @i18n=common_makes[:i18n] - @man_section=common_makes[:man_section] - @emphasis_set_to=common_makes[:emphasis_set_to] - @bold_match_list=common_makes[:bold_match_list] - @italics_match_list=common_makes[:italics_match_list] - @substitution_match_list=common_makes[:substitution_match_list] - @footer_links=common_makes[:footer_links] - @home_button_links=common_makes[:home_button_links] - @home_button_image=common_makes[:home_button_image] - @cover_image=common_makes[:cover_image] - @lnk=@links=common_makes[:links] - @header_make_links_append=common_makes[:links_append] - end - end - #protected - def extract - @user,@home,@hostname,@pwd=ENV['USER'],ENV['HOME'],ENV['HOSTNAME'],ENV['PWD'] - @programs,@wc,@language,@language_original={},{},{},{} - @en={ sum: 0, mark: 0, note: 0, mismatch: 0 } - @prog=SiSU_Env::InfoSettings.new - @sys=SiSU_Env::SystemCall.new - @env=SiSU_Env::InfoEnv.new(@fns) #watch - if (@opt.act[:verbose_plus][:set]==:on \ - || @opt.act[:maintenance][:set]==:on) - puts 'system locale: ' + @sys.locale - end - if @prog.wc \ - and @sys.wc - wc=%x{wc #{fns}} - wca=wc.scan(/\d+/) - @wc_lines,@wc_words,@wc_bytes=wca[0].to_i,wca[1].to_i,wca[2].to_i - else - fns_a=@data.dup - tmp=fns_a.join - fns_a=tmp.scan(/\S+/) - @wc_words=fns_a.length - fns_a=tmp=nil - end - @concord_make=(@wc_words > @env.concord_max) ? false : true - @locale=@sys.locale - @file_encoding=@sys.file_encoding(fns,@opt.cmd) - # programs set here for things that affect output appearance only - @programs[:pdf]=SiSU_Env::SystemCall.new.program_found?('pdflatex') - if @opt.cmd =~/P/ #if @env.multilingual? - m=/((.+?)(?:\~\w\w(?:_\w\w)?)?)\.((?:-|ssm\.)?sst|ssm|ssi)$/ #watch added match for sss - @fnn,@fnb,@fnt=@fns[m,1],@fns[m,2],@fns[m,3] - @flv=@env.document_language_versions_found[:f] - else - m=/((.+?)(?:\~\w\w(?:_\w\w)?)?)\.((?:-|ssm\.)?sst|ssm)$/ #watch added match for sss - @fnn,@fnb,@fnt=@fns[m,1],@fns[m,2],@fns[m,3] - @flv=@env.document_language_versions_found[:f] - @fnz=(@fns =~/\.(?:ssm\.sst|ssm)$/) ? (@fnn + '.ssm.txz') : (@fnn + '.sst.txz') - end - @papersize=@env.papersize #'A4' #default size #get first from SiSU_Env:: # @env is probably no longer most appropriate name! as default info is more general - @sfx_src=@fns[m,2] - if @fns =~ /(?:-|ssm\.)?sst$/ \ - and not @opt.cmd =~/P/ #watch - @env_out_root=@env.path.output - @dir_out="#{@env.path.output}/#{@fnb}" - @dir_tex=@env.processing_path.tex - @dir_lout=@env.processing_path.lout - @@publisher='SiSU http://www.jus.uio.no/sisu' - end - @txt_path=@txt_path ||= @env.path.output - @stmp=%{#{@fns}}[/^(.+?)\..*/m,1] - @fnstex=@fns.gsub(/_/,'\_\-').gsub(/\./,'.\-') - @flag_endnotes,@flag_auto_endnotes,@flag_separate_endnotes=false,false,false - @flag_separate_endnotes_make=true - ver=SiSU_Env::InfoVersion.instance - @sisu_version=ver.get_version - @ruby_version=ver.rbversion - @generated=Time.now - fns_array=@data.dup - skip unless fns_array # consider - @code_flag=false - fns_array.each do |para| #% scan document - if para !~/^%+\s/ \ - and para =~/|

|
|
)\s*/,' '). - gsub(/~\{.+?\}~/,'') - SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - 'Parameters', - %{#{title}#{creator}} - ).txt_grey if @opt.act[:verbose][:set]==:on - end - if not @book_idx \ - and para =~/^=\{(.+?)\}[\s`]*\Z/m - @book_idx=true - end - unless @code_flag - case para - when /~\{\s+.+?\}~/m #% processing - en=para.scan(/~\{.+?\}~/m) - en.each { |e| @en[:sum] +=1 } - when /~\^(?:\s|$)/m #% processing - mk=para.scan(/~\^(?:\s|$)/) - mk.each { |e| @en[:mark] +=1 } - when /^\^~\s+\S/ then @en[:note] +=1 #% processing - end - end - if para =~/~\{|\^~ |~\^|\{.+?\[[1-6]\]\}\S+?\.ss[tm]/m - @flag_auto_endnotes,@flag_endnotes=true,true - end - if para =~/^(?:table\{|\{table)/i - @flag_tables=true - end - end - if para =~/^:?A~/ - @set_heading_top=true - end - if para =~/^1~/ - m=nil - if para =~/^1~(\S+)\s+(.+)$/ - m,t=$1,$2 - elsif para =~/^1~\s+(.+)$/ - t=$1 - end - unless @heading_seg_first_flag # extract first segment name - @heading_seg_first=t - @heading_seg_first_flag=true - end - if m # list all segment names - @seg_names << m - @set_heading_seg=true - if m=~/^\d{1,3}/ \ - and m !~/^0/ - @seg_autoname_safe=false - end - end - end - para=para.gsub(/<:=(\S+?)>/,'{ c_\1.png 14x14 }image') # embedded symbol (image) - if para !~/^%+\s/ \ - and para =~@rgx_image - @ec[:image] << para.scan(@rgx_image).uniq - end - @ec[:audio] << para.scan(@rgx_audio).uniq if para =~@rgx_audio #embedded content - @ec[:multimedia] << para.scan(@rgx_mm).uniq if para =~@rgx_mm #embedded content - unless @sem_tag - @sem_tag=true if para=~/[:;]\{.+?\}[:;][a-z+]/ #refix later - end - end #% here endeth the document loop - unless @make - if (@opt.act[:verbose_plus][:set]==:on \ - || @opt.act[:maintenance][:set]==:on) - SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - '@make:', - 'header absent' - ).warn - end - @make=SiSU_Param::Parameters::MdMake.new('@make: ',@opt,@env).make - end - if @cover_image \ - and @cover_image.is_a?(Hash) \ - and (@cover_image[:cover] =~@rgx_image \ - or @cover_image[:cover] =~/\S+?.(?:jpg|png|gif)/) - @ec[:image] << @cover_image[:cover] - end - if @home_button_image \ - and @home_button_image.is_a?(Hash) \ - and (@home_button_image =~@rgx_image \ - or @home_button_image =~/\S+?\.(?:jpg|png|gif)/) - @ec[:image] << @home_button_image - end - if @ec[:image].length > 0 - @ec[:image]=@ec[:image].flatten.uniq - @ec[:image].delete_if {|x| x =~/https?:\/\// } - @ec[:image]=@ec[:image].sort - end - @ec[:audio]=@ec[:audio].uniq.flatten.sort - @ec[:multimedia]=@ec[:multimedia].uniq.flatten.sort - unless @rights - if defined? @creator.author \ - and @creator.author.is_a?(String) \ - and defined? @date.published \ - and @date.published.is_a?(String) - @rights=SiSU_Param::Parameters::MdDefault.new.rights(@creator.author,@date.published) - elsif defined? @creator.author \ - and @creator.author.is_a?(String) - @rights=SiSU_Param::Parameters::MdDefault.new.rights("[#{@creator.author}]",'') - end - end - if defined? @classify.topic_register \ - and @classify.topic_register.is_a?(String) \ - and @classify.topic_register.length >3 - topic_register=@classify.topic_register - u=topic_register.scan(/[^;]+/m).sort - v=[] - u.each do |l| - v << l.scan(/[^:]+/m) - end - v.each do |s| - s[-1]=s[-1].scan(/[^|]+/m) if s[-1] =~/[|]/m - @topic_register_array << s - end - @topic_register_array - end - if @i18n - @i18n=@i18n.uniq - @i18n << 'en' unless @i18n.find_index("en") - else - @i18n=[ 'en' ] - end - translated=[] - translate_list=[@pagenew,@pagebreak,@pageline,@num_top,@toc_lev_limit] - translate_list.each do |t| - translate=t.to_s if t - translated << if translate - translate.gsub!(/3/,'6') - translate.gsub!(/2/,'5') - translate.gsub!(/1/,'4') - translate.gsub!(/:?C/,'3') - translate.gsub!(/:?B/,'2') - translate.gsub!(/:?A/,'1') - # looks like an ok substituion for the above but is not, causes problems, check why - #translate=translate.gsub(/3/,'6'). - # gsub(/2/,'5'). - # gsub(/1/,'4'). - # gsub(/:?C/,'3'). - # gsub(/:?B/,'2'). - # gsub(/:?A/,'1') - translate=(translate =~/^\d+$/) \ - ? translate.to_i - : translate - else nil - end - end - @pagenew,@pagebreak,@pageline,@num_top,@toc_lev_limit=translated - @markup=@markup.gsub(/page_new\s*=\s*([\dA-C])/,"page_new=#{@pagenew}"). - gsub(/page_break\s*=\s*([\dA-C])/,"page_break=#{@pagebreak}"). - gsub(/page_line\s*=\s*([\dA-C])/,"page_line=#{@pageline}"). - gsub(/num_top\s*=\s*([\dA-C])/,"num_top=#{@num_top}"). - gsub(/toc_lev_limit\s*=\s*([\dA-C])/,"toc_lev_limit=#{@toc_lev_limit}") - papersize_array_rc=@papersize.downcase.scan(/(?:a4|letter|legal|book|a5|b5)/) - papersize_array_opt=[ - ((@opt.act[:pdf_a4][:set]==:on) ? 'a4' : ''), - ((@opt.act[:pdf_a5][:set]==:on) ? 'a5' : ''), - ((@opt.act[:pdf_b5][:set]==:on) ? 'b5' : ''), - ((@opt.act[:pdf_letter][:set]==:on) ? 'letter' : ''), - ((@opt.act[:pdf_legal][:set]==:on) ? 'legal' : ''), - ] - [""] - @papersize_array=(papersize_array_opt.length > 0) \ - ? papersize_array_opt - : papersize_array_rc - fn=@opt.fno #decide what to do a filesize on .ssm tells very little about actual document size - @filesize=(File.size(fn)).to_s - if @sys.openssl !=false \ - and FileTest.file?(@env.source_file_with_path) - @dgst=[] - case @env.digest(@opt).type - when :sha512 - dgst=@sys.sha512(@env.source_file_with_path) - @dgst=dgst[1].length==128 ? dgst : nil - puts 'check document (sha512) digest' if not @dgst - when :sha256 - dgst=@sys.sha256(@env.source_file_with_path) - @dgst=dgst[1].length==64 ? dgst : nil - puts 'check document (sha256) digest' if not @dgst - when :md5 - dgst=@sys.md5(@env.source_file_with_path) - @dgst=dgst[1].length==32 ? dgst : nil - puts 'check document (md5) digest' if not @dgst - else - dgst=@sys.sha256(@env.source_file_with_path) - @dgst=dgst[1].length==64 ? dgst : nil - puts 'check document (sha256) digest' if not @dgst - end - elsif not FileTest.file?(@env.source_file_with_path) - #puts SiSU_Utils::CodeMarker.new(__LINE__,__FILE__).set(:fuchsia) - end - @publisher ||= "#{@@publisher} (this copy)" - fn_set_lang=SiSU_Env::StandardiseLanguage.new(@opt.lng).language - unless @language[:code] \ - and @language[:name] - lang=@env.i18n.language #default language settings for directory by name, or in sysrc.yml - @language[:code] ||= lang.code - @language[:name] ||= lang.title - end - unless fn_set_lang[:d]==true #decide, naming convention overrides other settings, within document, etc. - @language[:code]=fn_set_lang[:c] - @language[:name]=fn_set_lang[:n] - end - @fnl=@env.i18n.lang_filename(fn_set_lang[:c]) - @lang=@lang.uniq - @fn=SiSU_Env::EnvCall.new(@fns).lang(fn_set_lang[:c]) - if @en[:note] > 0 \ - and @en[:sum] > 0 - if @en[:sum] > 0 - else - SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - '*WARN* both endnote styles used', - "~{ #{@en[:sum]} }~ and ^~ #{@en[:mark]}" - ).warn unless @opt.act[:quiet][:set]==:on - end - end - if @en[:mark] != @en[:note] \ - and @en[:note] > 0 - @en[:mismatch]=@en[:note] - @en[:mark] - SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - '*WARN* endnote number mismatch', - "endnotes: #{@en[:note]} != endnote reference marks: #{@en[:mark]} (difference = #{@en[:mismatch]})" - ).warn unless @opt.act[:quiet][:set]==:on - footnote_conversion_errors=File.new("#{Dir.pwd}/footnote_conversion_errors.txt",'a') - footnote_conversion_errors << - "#{@fns}:\n\tendnotes: #{@en[:note]} != endnote reference marks: #{@en[:mark]} (difference = #{@en[:mismatch]})\n" - end - if not @title \ - or not defined? @title.main \ - or @title.main !~/[\S]/ - if @fns =~/\.ssm$/ \ - and @opt.inspect =~/P/ - #@title=Md.new('Text Insert',@opt,@env).title - else - SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - 'WARNING: Document Title missing', - 'please provide @title:' - ).warn unless @opt.act[:quiet][:set]==:on - end - end - if @author !~/[\S]/ - if @fns =~/\.ssm$/ \ - and @opt.inspect =~/P/ - #@creator=SiSU_Param::Md.new('Text Insert',@opt,@env).creator - else - SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - 'WARNING: Document Author missing', - 'please provide @creator: :author:' - ).warn unless @opt.act[:quiet][:set]==:on - end - end - @struct={} - doc_struct=Hash.new(0) - if @lv1.nil? - fns_array.each do |para| - if para =~/^(Part|Chapter|Section|Article)\b/i - case para - when /^(Part|PART)\b/ - @struct[:part]=doc_struct[:part] - doc_struct[:part]=doc_struct[:part] + 1 - when /^(Chapter|CHAPTER)\b/ - @struct[:chapter]=doc_struct[:chapter] - doc_struct[:chapter]=doc_struct[:chapter] + 1 - when /^(Section|SECTION)\b/ - @struct[:section]=doc_struct[:section] - doc_struct[:section]=doc_struct[:section] + 1 - when /^(Article|ARTICLE)\b/ - @struct[:article]=doc_struct[:article] - doc_struct[:article]=doc_struct[:article] + 1 - when /^(Clause|CLAUSE)\b/ - @struct[:clause]=doc_struct[:clause] - doc_struct[:clause]=doc_struct[:clause] + 1 - when /^\d\..*[^\.]$/ - @struct[:number]=doc_struct[:number] - doc_struct[:number]=doc_struct[:number] + 1 - end - end - end - if doc_struct[:article] > 2 #%~level 4 - @lv4=/^(?:Article|ARTICLE)\b/ - elsif doc_struct[:chapter] > 2 \ - and doc_struct[:article] \ - and doc_struct[:article] < 3 - @lv4=/^(?:Chapter|CHAPTER)\b/ - elsif doc_struct[:clause] > 2 - @lv4=/^(?:Clause|CLAUSE)\b/ - elsif doc_struct[:number] > 2 - @lv4="^\d\..*[^\.]$" - end - if doc_struct[:section] > 2 #%~level 3 - @lv3=/^(?:Section|SECTION)\b/ - end - if doc_struct[:chapter] > 2 \ - and doc_struct[:article] \ - and doc_struct[:article] > 2 - @lv2=/^(?:Chapter|CHAPTER)\b/ - end - if doc_struct[:part] > 2 \ - and @lv[2].nil? - @lv2=/^(?:Part|PART)\b/ - end - if doc_struct[:part] > 2 \ - and @lv[2].inspect !~/Part/ \ - and @lv[1].nil? - @lv1=/^(Part|PART)\b/ - end - end - @lnk=@lnk.compact if @lnk - @lv0 ||=/^0~/ - @lv1 ||=/^1~/ - @lv2 ||=/^2~/ - @lv3 ||=/^3~/ - @lv4 ||=/^4~/ - @lv5 ||=/^5~/ - @lv6 ||=/^6~/ - @data=nil #else whole file's contents are stored in md pstore & is not required to be... big waste actually - @file=SiSU_Env::FileOp.new(self) #watch - Store.new(self,@env).store #% pstore - self - end - private - class Store - def initialize(md,env) - @md,@env=md,env - end - def store - begin - pstorefile="#{@env.processing_path.ao}/#{@md.fns}.pstore" - File.unlink(pstorefile) if FileTest.file?(pstorefile) - if (@md.opt.act[:verbose_plus][:set]==:on \ - || @md.opt.act[:maintenance][:set]==:on) - SiSU_Screen::Ansi.new( - @md.opt.act[:color_state][:set], - "PStore -> #{pstorefile}" - ).txt_grey - end - store=PStore.new(pstorefile) - store.transaction do - store['md']=@md - store.commit - end - @@md=@md=nil - rescue - SiSU_Errors::Rescued.new($!,$@,@md.opt.cmd,@md.fns).location do - __LINE__.to_s + ':' + __FILE__ - end - ensure - end - end - end - end - end - class Instantiate - def param_instantiate - @@date=SiSU_Env::InfoDate.new - @@proc= - @@filename_txt= - @@filename_texinfo= - @@filename_lout_portrait= - @@filename_lout_landscape= - @@filename_html_scroll= - @@filename_html_index= - @@filename_html_segtoc= - @@filename_semantic= - @@filename_rss= - @@newfile= - @@drr= - nil - @doc={ - initialise: nil, - markup: '', - lnks: '', - stmp: '', - prefix_a: '', - prefix_b: '', - req: {} - } - @@yaml=@@yamladdr=nil - @@flag={} - @@publisher='SiSU scribe' - end - end -end -__END__ diff --git a/lib/sisu/v6/param_identify_markup.rb b/lib/sisu/v6/param_identify_markup.rb deleted file mode 100644 index 87879e79..00000000 --- a/lib/sisu/v6/param_identify_markup.rb +++ /dev/null @@ -1,167 +0,0 @@ -# encoding: utf-8 -=begin - - * Name: SiSU - - * Description: a framework for document structuring, publishing and search - - * Author: Ralph Amissah - - * Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, - All Rights Reserved. - - * License: GPL 3 or later: - - SiSU, a framework for document structuring, publishing and search - - Copyright (C) Ralph Amissah - - This program is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the Free - Software Foundation, either version 3 of the License, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - more details. - - You should have received a copy of the GNU General Public License along with - this program. If not, see . - - 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: - - - * Git - - - - * Ralph Amissah - - - - ** 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 - -=end -module SiSU_MarkupType - class MarkupIdentify - @@version={} - @@fns,@@version[:determined],@@version[:declared],@@declared_doc_type='','','','[text?]' - attr_accessor :version,:declared_doc_type - def initialize(content,opt) - @cont,@opt=content,opt - end - def identify - @version,@declared_doc_type=@@version,@@declared_doc_type - if @opt.fns != @@fns - if @cont[0] =~ /^(?:%\s+)?SiSU\s+(text|master|insert)\s+([0-9](?:\.[0-9]+){1,2})/ \ - or @cont[0] =~ /^(?:%\s+)?sisu-([0-9](?:\.[0-9]+){1,2})/ - @declared_doc_type,@version[:declared]=$1,$2 - elsif @cont[0] =~ /^(?:%\s+)?SiSU\s+([0-9](?:\.[0-9]+){1,2})/ \ - or @cont[0] =~ /^(?:%\s+)?sisu-([0-9](?:\.[0-9]+){1,2})/ - @version[:declared]=$1 - end - @flag_2_0,@flag_66,@flag_57,@flag_38=false,false,false,false - @cont.each_with_index do |y,i| - if y =~/^@make:|^@classify|^\s\s?:\S+?:\s+\S/ - version=2.0.to_f - @version[:determined]=version - @flag_2_0=true - break - end - unless @flag_38 - if y =~/^:?A~/ - version=0.38.to_f - @version[:determined]=version - @flag_38=true - end - end - if @flag_38 - if @flag_69 \ - or y =~/^=\{.+?\}\s*$/ - version=0.69.to_f - @flag_69=true - @version[:determined]=version - break - end - if @flag_66 \ - or y =~/[:;]\{.+?\}[:;][a-z+]/ - version=0.66.to_f - @flag_66=true - @version[:determined]=version - break - end - end - end - @flag_57,@flag_38=false,false - unless @flag_2_0 \ - or @flag_66 \ - or @flag_69 - @cont.each_with_index do |y,i| - if @flag_57 \ - or y =~/^:?A~\?? @title/ - @version[:determined]=0.57.to_f - @flag_57=true - break - end - if @flag_38 \ - or y =~/^:?A~/ - @version[:determined]=0.38.to_f - @flag_38=true - break if i >= 200 - if y =~ /(?:~{\*+|~\[\*|~\[\+)\s/ - @version[:determined]=0.42 #0.38 can safely be treated as 0.42 - break - end - end - if y =~/^0~/ \ - and not @flag_38 - @version[:determined]=0.16.to_f - break - end - end - end - @@fns=@opt.fns - @@version,@@declared_doc_type=@version,@declared_doc_type - end - self - end - def markup_version? - def determined - identify.version[:determined].to_f - end - def series - s=case identify.version[:determined].to_s - when /^[01]\./ then '1.0' - when /^[2]\./ then '2.0' - else '2.0' - end - "series #{s}" - end - def declared - identify.version[:declared].to_f - end - self - end - end -end -__END__ diff --git a/lib/sisu/v6/param_make.rb b/lib/sisu/v6/param_make.rb deleted file mode 100644 index 50c9551d..00000000 --- a/lib/sisu/v6/param_make.rb +++ /dev/null @@ -1,674 +0,0 @@ -# encoding: utf-8 -=begin - - * Name: SiSU - - * Description: a framework for document structuring, publishing and search - - * Author: Ralph Amissah - - * Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, - All Rights Reserved. - - * License: GPL 3 or later: - - SiSU, a framework for document structuring, publishing and search - - Copyright (C) Ralph Amissah - - This program is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the Free - Software Foundation, either version 3 of the License, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public Lic/home/ralph/live-manual/build/manual/manifest/live-manual.ca.htmlense 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: - - - * Git - - - - * Ralph Amissah - - - - ** Description: make parameters extracted for program use - -=end - -module SiSU_Param_Make - class MdMake - def initialize(str,opt,env) - @s,@opt,@env=str,opt,env - end - def validate_length(s,l,n) - #s=(s.length <= l) ? s : nil - s=if s.is_a?(String) \ - and s.length <= l - s - elsif s.is_a?(NilClass) - nil - elsif s.class !=String - STDERR.puts "#{n} is #{s.class}: programming error, String expected #{__FILE__}:#{__LINE__}" - s - else - SiSU_Screen::Ansi.new( - 'v', - "*WARN* #{n} length #{s.length} exceeds set db field length #{l}, metadata dropped", - @opt.fns - ).warn unless @opt.act[:quiet][:set]==:on - nil - end - end - def name_format(name) - if name - name=name.strip - @name_a_h=[] - authors=name.scan(/[^;]+/) - authors.each_with_index do |a,i| - b=((a =~/\s*\|\s*/) ? (a.split(/\|/)) : [a]) - if b[0] =~/"(.+?)"/ - @name_a_h << { the: $1 } - else - x=b[0].scan(/[^,]+/) - if x.length==1 - @name_a_h << { the: x[0].strip } - elsif x.length==2 - @name_a_h << { the: x[0].strip, others: x[1].strip } - else #p x.length - end - end - b.delete_at(0) - b.each do |d| - k,c=nil - k,c=/^(\S+)\s+(.*)/.match(d)[1,2] if d - @name_a_h[i][:hon]=c.strip if k=='hon' - @name_a_h[i][:affiliation]=c.strip if k=='affiliation' - @name_a_h[i][:nationality]=c.strip if k=='nationality' - end - end - l=@name_a_h.length - name_str='' - @name_a_h.each_with_index do |a,i| - name_str += if a[:others] - z=(((l - i) > 1) ? ', ' : '') - "#{a[:others].strip} #{a[:the].strip}" + z - else - z=(((l - i) > 2) ? ', ' : '') - "#{a[:the].strip}" + z - end - end - { name_a_h: @name_a_h, name_str: name_str } - else nil - end - end - def build_hash(arr) - @h={} - arr.each_with_index do |x,i| - a,b=nil,nil - if x =~/^%[:\s]/ #ignore comment - elsif x =~/:(\S+?):\s+(.+)/ - a,b=/:(\S+?):\s+(.+)\Z/m.match(x)[1,2] - elsif i == 0 - a='main' - b=x - else - end - @h[a]=b - end - @h - end - def make - a=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m) - @h=build_hash(a) - def headings - lv=[] - x=@h['headings'] - x=((x =~/;/) ? (x.split(/;\s*/)) : [ x ]) - lv[0]=x - lv0 ||='A~ ' #root level, single document apex, document title - lv1=x[0] ||='B~ ' - lv[1]=/^#{lv1}/ - lv2=x[1] ||='C~ ' - lv[2]=/^#{lv2}/ - lv3=x[2] ||='D~ ' - lv[3]=/^#{lv3}/ - lv4=x[3] ||='1~ ' - lv[4]=/^#{lv4}/ - lv5=x[4] ||='2~ ' - lv[5]=/^#{lv5}/ - lv6=x[5] ||='3~ ' - lv[6]=/^#{lv6}/ - lv - end - def num_top - @h['num_top'] - end - def breaks - pagebreaks=((@h['breaks'] =~/;/) \ - ? (@h['breaks'].split(/;\s*/)) - : [ @h['breaks'] ]) - page_new,page_break,page_line=nil,nil,nil - pagebreaks.each do |x| - page_new=x[/(:?[\dA-C],?)+/] if x=~/new|clear/ - page_break=x[/(:?[\dA-C],?)+/] if x =~/break/ - page_line=x[/(:?[\dA-C],?)+/] if x =~/line/ - end - { page_new: page_new, page_break: page_break, page_line: page_line } - end - def language - if @h['language'] && (@h['language']=~/\S{2,}/) - ((@h['language'] =~/,/) \ - ? (@h['language'].split(/,\s*/)) - : [ @h['language'] ]) - else [ 'en' ] - end - end - def bold - m=@h['bold'] - i=(m=~/\/i$/)? 'i' : '' - if m - x=m.gsub(/^\/(.+?)\/i?/,'\1'). - gsub(/\((?:\?:)?/,'(?:') # avoid need to escape use of brackets within regex provided - rgx='\b(' + x + ')\b' - y=((i =~/i/) ? (/#{rgx}/i) : (/#{rgx}/)) - { str: '\b(?:' + x + ')\b', regx: y, i: i } - else nil - end - end - def italics - m=@h['italics'] - i=((m=~/\/i$/) ? 'i' : '') - if m - x=m.gsub(/^\/(.+?)\/i?/,'\1'). - gsub(/\((?:\?:)?/,'(?:') # avoid need to escape use of brackets within regex provided - rgx='\b(' + x + ')\b' - y=((i =~/i/) ? (/#{rgx}/i) : (/#{rgx}/)) - { str: '\b(?:' + x + ')\b', regx: y, i: i } - else nil - end - end - def emphasis - if @h['emphasis'] =~/bold/ then 'bold' - elsif @h['emphasis'] =~/italics?/ then 'italics' - elsif @h['emphasis'] =~/under(?:line|score)/ then 'underscore' - else nil - end - end - def substitute - m=@h['substitute'] - if m - w=m.scan(/\/(.+?)\/(i?,)\s*'(.+?)'(?:\s+|\s*;\s*|$)/) - arr_hash=[] - matches='' - w.each do |x| - c=(x[1] =~/[i],/) ? :i : :s - matches=matches + x[0].gsub(/([${}])/,'\\\\\1') + '|' - arr_hash << { - match: x[0].gsub(/([${}])/,'\\\\\1'), - replace: x[2], - case_s: c - } - end - matches.chop! - { match_and_replace: arr_hash, matches: matches } - else nil - end - end - def plaintext_wrap - if @h['plaintext_wrap'].to_s =~/\d\d+/ \ - and @h['plaintext_wrap'].to_i > 19 \ - and @h['plaintext_wrap'].to_i < 201 - @h['plaintext_wrap'].to_i - else nil - end - end - def omit - m=@h['omit'] - @m=m ? (m.split(/,\s+/)) : nil - def list - @m - end - self - end - def ocn? - (omit.list.inspect =~/"ocn"/) \ - ? :off - : :na - end - def toc? - (omit.list.inspect =~/"toc"/) \ - ? :off - : :na - end - def manifest? - (omit.list.inspect =~/"manifest"/) \ - ? :off - : :na - end - def links_to_manifest? - (omit.list.inspect =~/"manifest_links"|"links_to_manifest"/) \ - ? :off - : :na - end - def metadata? - (omit.list.inspect =~/"metadata"/) \ - ? :off - : :na - end - def minitoc? - (omit.list.inspect =~/"minitoc"/) \ - ? :off - : :na - end - def html_minitoc? - (omit.list.inspect =~/"html_minitoc"/) \ - ? :off - : :na - end - def html_top_band? - (omit.list.inspect =~/"html_top_band"/) \ - ? :off - : :na - end - def html_navigation? - (omit.list.inspect =~/"html_navigation"/) \ - ? :off - : :na - end - def html_navigation_bar? - (omit.list.inspect =~/"html_navigation_bar"/) \ - ? :off - : :na - end - def segsubtoc? - (omit.list.inspect =~/"segsubtoc"/) \ - ? :off - : :na - end - def search_form? - (omit.list.inspect =~/"search_form"/) \ - ? :off - : :na - end - def html_search_form? - (omit.list.inspect =~/"html_search_form"/) \ - ? :off - : :na - end - def html_right_pane? - (omit.list.inspect =~/"html_right_column"|"html_right_pane"/) \ - ? :off - : :na - end - def manifest_minitoc? - (omit.list.inspect =~/"manifest_minitoc"/) \ - ? :off - : :na - end - def cover_image? - (omit.list.inspect =~/"cover_image"/) \ - ? :off - : :na - end - def home_button_image? - (omit.list.inspect =~/"home_button_image"/) \ - ? :off - : :na - end - def texpdf_font - def main - @h['texpdf_font'] \ - && (@h['texpdf_font']=~/\S{3,}/) \ - ? @h['texpdf_font'] - : @env.font.texpdf.main - end - def sans # not used - @h['texpdf_font_sans'] \ - && (@h['texpdf_font_sans']=~/\S{3,}/) \ - ? @h['texpdf_font_sans'] - : @env.font.texpdf.sans - end - def serif # not used - @h['texpdf_font_serif'] \ - && (@h['texpdf_font_serif']=~/\S{3,}/) \ - ? @h['texpdf_font_serif'] - : @env.font.texpdf.serif - end - def mono - @h['texpdf_font_mono'] \ - && (@h['texpdf_font_mono']=~/\S{3,}/) \ - ? @h['texpdf_font_mono'] - : @env.font.texpdf.mono - end - def cjk - @h['texpdf_font_cjk'] \ - && (@h['texpdf_font_cjk']=~/\S{3,}/) \ - ? @h['texpdf_font_cjk'] - : @env.font.texpdf.cjk - end - def cjk_zh - @h['texpdf_font_cjk_zh'] \ - && (@h['texpdf_font_cjk_zh']=~/\S{3,}/) \ - ? @h['texpdf_font_cjk_zh'] - : @env.font.texpdf.cjk_zh - end - def cjk_ja - @h['texpdf_font_cjk_ja'] \ - && (@h['texpdf_font_cjk_ja']=~/\S{3,}/) \ - ? @h['texpdf_font_cjk_ja'] - : @env.font.texpdf.cjk_ja - end - def cjk_ko - @h['texpdf_font_cjk_ko'] \ - && (@h['texpdf_font_cjk_ko']=~/\S{3,}/) \ - ? @h['texpdf_font_cjk_ko'] - : @env.font.texpdf.cjk_ko - end - self - end - def promo - @h['promo'] - end - def ad - @h['ad'] - end - def manpage - manpage={} - if @h['manpage'] - if @h['manpage'] =~/;/m - man=@h['manpage'].split(/;/m) - man.each do |x| - m=(x=~/=/m) ? x.split(/=/m) : nil - if m - manpage[m[0].strip] = m[1].split(/ \. /) - end - end - end - end - if manpage['name'] - manpage['name']=manpage['name'].join("\n.br\n"). - gsub(/(-)/m,"\\\\\\1"). - gsub(/\A/,"\n.br\n.SH NAME\n.br\n") - else - manpage['name']='man page "name/whatis" information not provided, set in header @man: name=[whatis information]' - end - if manpage['synopsis'] - manpage['synopsis']=manpage['synopsis'].join("\n\n.br\n"). - gsub(/(-)/m,"\\\\\\1"). - gsub(/\A/,"\n.br\n.SH SYNOPSIS\n.br\n") - else - manpage['synopsis']='' - end - unless manpage['section'] - manpage['section']=1 - end - manpage - end - def get_image_dimensions(img) - imgk=SiSU_Env::SystemCall.new.imagemagick - gmgk=SiSU_Env::SystemCall.new.graphicksmagick - img_pth={ - sst: @env.path.image_source_include, - pod: File.expand_path("../../../sisupod/image" ) - } - path_img=if FileTest.file?("#{img_pth[:pod]}/#{img}") - "#{img_pth[:pod]}/#{img}" - elsif FileTest.file?("#{img_pth[:sst]}/#{img}") - "#{img_pth[:sst]}/#{img}" - else nil - end - if path_img - if imgk or gmgk - if imgk - imgsys=`identify #{path_img}`.strip #system call - elsif gmgk - imgsys=`gm identify #{path_img}`.strip #system call - end - w,h=/(\d+)x(\d+)/m.match(imgsys)[1,2] - else - w,h='600','800' - end - else - w,h=nil,nil - end - {w: w, h: h} - end - def home_button_text - if @h['home_button_text'] - @h['home_button_text'].split(/\s*;\s*/) - else nil - end - end - def home_button_image - s=nil - s=if @h['home_button_image'] - s=@h['home_button_image'].split(/\s*;\s*/) - s0=s[0] #if - image={} - s=if s0 =~/{(\S+\.(?:jpg|png|gif))(?:\s+(\d+x\d+))?\s*}(?:(http:\/\/\S+)|image)/ - image[:home_button]=$1 - if $2 - image[:dimensions]=$2 - image[:w],image[:h]=/(\d+)x(\d+)/m.match(image[:dimensions])[1,2] - else - d=get_image_dimensions(image[:home_button]) - image[:w],image[:h]=d[:w],d[:h] - image[:dimensions]="#{d[:w]}x#{d[:h]}" - end - image[:link]=$3 - image - end - else nil - end - end - def cover_image - s=nil - if @h['cover_image'] - s=@h['cover_image'].split(/\s*;\s*/) - s=s[0] #if - image={} - if s =~/{\s*(\S+\.(?:jpg|png|gif))(?:\s+(\d+x\d+))?(?:\s+"(.+?)")?\s*}image/ - image[:cover]=$1 - if $2 - image[:dimensions]=$2 - image[:w],image[:h]=/(\d+)x(\d+)/m.match(image[:dimensions])[1,2] - else - d=get_image_dimensions(image[:cover]) - image[:w],image[:h]=d[:w],d[:h] - image[:dimensions]="#{d[:w]}x#{d[:h]}" - end - image[:note]=$3 - elsif s =~/(\S+\.(?:jpg|png|gif))/ - image[:cover]=$1 - d=get_image_dimensions(image[:cover]) - image[:w],image[:h]=d[:w],d[:h] - image[:dimensions]="#{d[:w]}x#{d[:h]}" - image[:note]=nil - end - image - else nil - end - end - def footer - if @h['footer'] - @h['footer'].split(/\s*;\s*/) - else nil - end - end - self - end - def make_links - @doc_links=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m) - def links - lnks,a_idx=[],0 - @doc_links.each do |doc_link| - if doc_link=~/\{.+?\}(?:(?:https?|file|ftp):\/|\.\.)\/\S+(?:\s|$)/ - say,url=/\{\s*(.+?)\s*\}((?:(?:https?|file|ftp):\/|\.\.)\/\S+)/im.match(doc_link)[1,2] - lnks[a_idx]={ say: say, url: url } - a_idx +=1 - end - end - lnks - end - def append? - (@doc_links[0]=='+') \ - ? :yes - : :no - end - self - end - end - class MakeHead - attr_accessor :pagenew,:pagebreak,:pageline,:toc,:lv1,:lv2,:lv3,:lv4,:lv5,:lv6,:num_top,:i18n,:man_section,:substitution_match_list,:bold_match_list,:italics_match_list,:emphasis_set_to,:footer_links,:home_button_links,:home_button_image,:cover_image - def initialize(make) - @make=make - end - def clear - @pagenew=@pagebreak=@pageline=@toc=@lv1=@lv2=@lv3=@lv4=@lv5=@lv6=@num_top=@i18n=@man_section=@footer_links=@substitution_match_list=@bold_match_list=@italics_match_list=@emphasis_set_to=@home_button_links=@home_button_image=@cover_image=nil - end - def make_instruct - clear - if defined? @make.breaks \ - and @make.breaks[:page_new] #clearpage - @pagenew=@make.breaks[:page_new] - end - if defined? @make.breaks \ - and @make.breaks[:page_break] #newpage - @pagebreak=@make.breaks[:page_break] - end - if defined? @make.breaks \ - and @make.breaks[:page_line] #page line across - @pagebreak=@make.breaks[:page_line] - end - if defined? @make.headings \ - and @make.headings - @toc=@make.headings[0] - @lv1=@make.headings[1] - @lv2=@make.headings[2] - @lv3=@make.headings[3] - @lv4=@make.headings[4] - @lv5=@make.headings[5] - @lv6=@make.headings[6] - end - if defined? @make.num_top \ - and @make.num_top - @num_top=@make.num_top # remove @num_top - end - if defined? @make.language \ - and @make.language[0] - @i18n=@make.language - end - if defined? @make.manpage \ - and @make.manpage - @man_section=(defined? @make.manpage.section) \ - ? @make.manpage.section - : 1 - end - if defined? @make.substitute \ - and @make.substitute - @substitution_match_list=@make.substitute - end - if defined? @make.bold \ - and @make.bold - @bold_match_list=@make.bold - end - if defined? @make.italics \ - and @make.italics - @italics_match_list=@make.italics - end - if defined? @make.emphasis \ - and @make.emphasis - @emphasis_set_to=@make.emphasis - end - if defined? @make.footer \ - and @make.footer.is_a?(Array) - @footer_links= { left: { say: '', url: '' }, center: { say: '', url: '' } } #already set - @footer_links[:left]=if @make.footer[0]=~/\{.+?\}(?:(?:https?|file|ftp):\/|\.\.)\/\S+(?:\s|$)/ - say,url=/\{\s*(.+?)\s*\}((?:(?:https?|file|ftp):\/|\.\.)\/\S+)/im.match(@make.footer[0])[1,2] - { say: say, url: url } - else - { say: '', url: '' } - end - @footer_links[:center]=if @make.footer[1]=~/\{.+?\}(?:(?:https?|file|ftp):\/|\.\.)\/\S+(?:\s|$)/ - say,url=/\{\s*(.+?)\s*\}((?:(?:https?|file|ftp):\/|\.\.)\/\S+)/im.match(@make.footer[1])[1,2] - { say: say, url: url } - else - { say: '', url: '' } - end - @footer_links - else #already set - @footer_links= { left: { say: '', url: '' }, center: { say: '', url: '' } } - end - if defined? @make.home_button_text \ - and @make.home_button_text.is_a?(Array) - a_idx=0 - @home_button_links=[] - @make.home_button_text.each do |doc_link| - if doc_link=~/\{.+?\}(?:(?:https?|file|ftp):\/|\.\.)\/\S+(?:\s|$)/ - say,url=/\{\s*(.+?)\s*\}((?:(?:https?|file|ftp):\/|\.\.)\/\S+)/im.match(doc_link)[1,2] - @home_button_links[a_idx]= { say: say, url: url } - a_idx +=1 - end - end - @home_button_links - end - if defined? @make.home_button_image \ - and @make.home_button_image.is_a?(Hash) - @home_button_image=@make.home_button_image - end - if defined? @make.cover_image \ - and @make.cover_image.is_a?(Hash) - @cover_image=@make.cover_image - end - { pagenew: @pagenew, - pagebreak: @pagebreak, - pageline: @pageline, - toc: @toc, - lv1: @lv1, - lv2: @lv2, - lv3: @lv3, - lv4: @lv4, - lv5: @lv5, - lv6: @lv6, - num_top: @num_top, - i18n: @i18n, - emphasis_set_to: @emphasis_set_to, - bold_match_list: @bold_match_list, - italics_match_list: @italics_match_list, - substitution_match_list: @substitution_match_list, - man_section: @man_section, - footer_links: @footer_links, - home_button_links: @home_button_links, - home_button_image: @home_button_image, - cover_image: @cover_image, - } - end - end -end -__END__ diff --git a/lib/sisu/v6/particulars.rb b/lib/sisu/v6/particulars.rb deleted file mode 100644 index 7e850f4c..00000000 --- a/lib/sisu/v6/particulars.rb +++ /dev/null @@ -1,240 +0,0 @@ -# encoding: utf-8 -=begin - - * Name: SiSU - - * Description: a framework for document structuring, publishing and search - particulars, composite information about document being processed - - * Author: Ralph Amissah - - * Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, - All Rights Reserved. - - * License: GPL 3 or later: - - SiSU, a framework for document structuring, publishing and search - - Copyright (C) Ralph Amissah - - This program is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the Free - Software Foundation, either version 3 of the License, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - more details. - - You should have received a copy of the GNU General Public License along with - this program. If not, see . - - 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: - - - * Git - - - - * Ralph Amissah - - - - ** Description: system environment, resource control and configuration details - -=end -module SiSU_Particulars - begin - require 'singleton' - rescue LoadError - SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('singleton NOT FOUND (LoadError)') - end - require_relative 'sysenv' # sysenv.rb - include SiSU_Env - require_relative 'param' # param.rb - include SiSU_Param - require_relative 'ao' # ao.rb - class CombinedSingleton - include Singleton - def get_all(opt) - set_env(opt) - set_file(opt) - set_md(opt) - set_ao(opt) #needs @md - end - def get_env(opt) - set_env(opt) - end - def get_file(opt) - set_file(opt) - end - def get_md(opt) - set_md(opt) - end - def get_ao_array(opt) - set_ao(opt) #needs @md - end - def get_env_md(opt) - set_env(opt) - set_md(opt) - end - def get_idx_sst(opt) - set_sst_idx(opt) - end - def get_idx_raw(opt) - set_raw_idx(opt) - end - def get_idx_html(opt) - set_html_idx(opt) - end - def get_idx_xhtml(opt) - set_xhtml_idx(opt) - end - def get_name_tags(opt) - set_name_tags(opt) - end - def get_maps(opt) - set_nametags_map(opt) - set_ocn_htmlseg_map(opt) - end - def get_map_nametags(opt) - set_nametags_map(opt) - end - def get_map_ocn_htmlseg(opt) - set_ocn_htmlseg_map(opt) - end - attr_accessor :opt,:md,:sst_idx,:raw_idx,:html_idx,:xhtml_idx - def set_md(opt) - begin - @md=SiSU_Param::Parameters.new(opt).get - self - rescue - SiSU_Errors::Rescued.new($!,$@,opt.cmd,opt.fnl).location do - __LINE__.to_s + ':' + __FILE__ - end - end - end - attr_accessor :opt,:env,:file - def set_env(opt) - begin - @env=SiSU_Env::InfoEnv.new(opt.fns) - self - rescue - SiSU_Errors::Rescued.new($!,$@,opt.cmd,opt.fnl).location do - __LINE__.to_s + ':' + __FILE__ - end - end - end - def set_file(opt) - begin - set_md(opt) unless @md - @file=SiSU_Env::FileOp.new(@md) - self - rescue - SiSU_Errors::Rescued.new($!,$@,opt.cmd,opt.fnl).location do - __LINE__.to_s + ':' + __FILE__ - end - end - end - attr_accessor :opt,:ao_array - def set_ao(opt) - begin - @ao_array=SiSU_AO::Source.new(opt).get - self - rescue - SiSU_Errors::Rescued.new($!,$@,opt.cmd,opt.fnl).location do - __LINE__.to_s + ':' + __FILE__ - end - end - end - def set_sst_idx(opt) - begin - @sst_idx=SiSU_AO::Source.new(opt).get_idx_sst - self - rescue - SiSU_Errors::Rescued.new($!,$@,opt.cmd,opt.fnl).location do - __LINE__.to_s + ':' + __FILE__ - end - end - end - def set_raw_idx(opt) - begin - @raw_idx=SiSU_AO::Source.new(opt).get_idx_raw - self - rescue - SiSU_Errors::Rescued.new($!,$@,opt.cmd,opt.fnl).location do - __LINE__.to_s + ':' + __FILE__ - end - end - end - def set_html_idx(opt) - begin - @html_idx=SiSU_AO::Source.new(opt).get_idx_html - self - rescue - SiSU_Errors::Rescued.new($!,$@,opt.cmd,opt.fnl).location do - __LINE__.to_s + ':' + __FILE__ - end - end - end - def set_xhtml_idx(opt) - begin - @xhtml_idx=SiSU_AO::Source.new(opt).get_idx_xhtml - self - rescue - SiSU_Errors::Rescued.new($!,$@,opt.cmd,opt.fnl).location do - __LINE__.to_s + ':' + __FILE__ - end - end - end - attr_accessor :nametags_map - def set_nametags_map(opt) - begin - opt=@md ? @md : opt - @nametags_map=SiSU_AO::Source.new(opt).get_map_nametags - self - rescue - if @md - SiSU_Errors::Rescued.new($!,$@,@md.opt.cmd,@md.opt.fnl).location do - __LINE__.to_s + ':' + __FILE__ - end - else - SiSU_Errors::Rescued.new($!,$@,opt.cmd,opt.fnl).location do - __LINE__.to_s + ':' + __FILE__ - end - end - end - end - attr_accessor :ocn_htmlseg_map - def set_ocn_htmlseg_map(opt) - begin - @ocn_htmlseg_map=SiSU_AO::Source.new(@md).get_map_ocn_htmlseg - self - rescue - SiSU_Errors::Rescued.new($!,$@,opt.cmd,opt.fnl).location do - __LINE__.to_s + ':' + __FILE__ - end - end - end - end -end -__END__ -consider running as separate objects diff --git a/lib/sisu/v6/po4a.rb b/lib/sisu/v6/po4a.rb index c4e074ec..0e7f91b0 100644 --- a/lib/sisu/v6/po4a.rb +++ b/lib/sisu/v6/po4a.rb @@ -63,7 +63,7 @@ =end module SiSU_Po4a require_relative 'ao' # ao.rb - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env require_relative 'ao_composite' # ao_composite.rb require_relative 'shared_metadata' # shared_metadata.rb diff --git a/lib/sisu/v6/prog_text_translation.rb b/lib/sisu/v6/prog_text_translation.rb index 177f17b9..6a82f3de 100644 --- a/lib/sisu/v6/prog_text_translation.rb +++ b/lib/sisu/v6/prog_text_translation.rb @@ -61,7 +61,7 @@ =end module SiSU_Translate - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env; include SiSU_Param class Source def initialize(md,doc_lang,trans_str='') diff --git a/lib/sisu/v6/qrcode.rb b/lib/sisu/v6/qrcode.rb index b9aee5a2..b69769e6 100644 --- a/lib/sisu/v6/qrcode.rb +++ b/lib/sisu/v6/qrcode.rb @@ -61,13 +61,13 @@ =end module SiSU_QRcode - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env require_relative 'prog_text_translation' # prog_text_translation.rb - require_relative 'particulars' # particulars.rb + require_relative 'se_hub_particulars' # se_hub_particulars.rb include SiSU_Particulars require_relative 'html' # html.rb - require_relative 'param' # param.rb + require_relative 'dp' # dp.rb include SiSU_Param require_relative 'i18n' # i18n.rb include SiSU_Viz diff --git a/lib/sisu/v6/relaxng.rb b/lib/sisu/v6/relaxng.rb index 1270ada3..c8d85d44 100644 --- a/lib/sisu/v6/relaxng.rb +++ b/lib/sisu/v6/relaxng.rb @@ -61,7 +61,7 @@ =end module SiSU_Relaxng - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb class RelaxNG def gpl3_or_later @gpl3_or_later =<. - - 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: - - - * Git - - - - * Ralph Amissah - - - - ** Description: Request response - -=end -module SiSU_Response - class Response - def response?(ask) #move to more appropriate directory later - response='redo' - print ask + " ['yes', 'no' or 'quit']: " - response=File.new('/dev/tty').gets.strip - ans=if response=='yes' then true - elsif response=='no' then false - elsif response =~/^quit|exit$/ then exit - else puts "[please type: 'yes', 'no' or 'quit']" - response?(ask) - end - ans - end - end -end -__END__ diff --git a/lib/sisu/v6/rexml.rb b/lib/sisu/v6/rexml.rb index 7321ebf5..ce6b2ce6 100644 --- a/lib/sisu/v6/rexml.rb +++ b/lib/sisu/v6/rexml.rb @@ -67,9 +67,9 @@ module SiSU_Rexml rescue LoadError SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('rexml/document NOT FOUND (LoadError)') end - require_relative 'param' # param.rb + require_relative 'dp' # dp.rb include SiSU_Param - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env include SiSU_Viz class Rexml diff --git a/lib/sisu/v6/screen_text_color.rb b/lib/sisu/v6/screen_text_color.rb deleted file mode 100644 index 5c4a2f72..00000000 --- a/lib/sisu/v6/screen_text_color.rb +++ /dev/null @@ -1,478 +0,0 @@ -# encoding: utf-8 -=begin - - * Name: SiSU - - * Description: a framework for document structuring, publishing and search - - * Author: Ralph Amissah - - * Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, - All Rights Reserved. - - * License: GPL 3 or later: - - SiSU, a framework for document structuring, publishing and search - - Copyright (C) Ralph Amissah - - This program is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the Free - Software Foundation, either version 3 of the License, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - more details. - - You should have received a copy of the GNU General Public License along with - this program. If not, see . - - 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: - - - * Git - - - - * Ralph Amissah - - - - ** Description: system environment, screen colors text - -=end -module SiSU_Screen - class Color - attr_accessor :off,:marker,:bold,:underline,:invert,:darkgrey_hi,:grey_hi,:pink_hi,:fuchsia_hi,:red_hi,:orange_hi,:yellow_hi,:brown_hi,:lightgreen_hi,:green_hi,:cyan_hi,:blue_hi,:navy_hi,:white,:white_bold,:grey,:pink,:fuchsia,:ruby,:red,:orange,:yellow,:brown,:green,:darkgreen,:cyan,:blue,:navy,:black - def initialize(&block) - instance_eval &block - end - end - class Ansi < Color - attr_reader :cX - def initialize(color_state,*txt) - @color_state,@txt=color_state,txt - @color_instruct=txt[0] - @cX=@@cX=if color_state==:on - Color.new do - self.off=self.white=self.white_bold=self.marker=self.bold=self.underline=self.invert=self.darkgrey_hi=self.grey_hi=self.pink_hi=self.fuchsia_hi=self.red_hi=self.orange_hi=self.yellow_hi=self.brown_hi=self.lightgreen_hi=self.green_hi=self.cyan_hi=self.blue_hi=self.navy_hi=self.grey=self.pink=self.fuchsia=self.ruby=self.red=self.orange=self.yellow=self.brown=self.green=self.darkgreen=self.cyan=self.blue=self.navy=self.black='' - end - else #default set to colors on - Color.new do - self.off = "\033[0m" - self.white = "\033[37m" - self.white_bold = "\033[1m" - self.marker = "\033[42m" - self.bold = "\033[1m" - self.underline = "\033[4m" - self.invert = "\033[7m" - self.darkgrey_hi = "\033[100m" - self.grey_hi = "\033[47m" - self.pink_hi = "\033[105m" - self.fuchsia_hi = "\033[45m" - self.red_hi = "\033[41m" - self.orange_hi = "\033[101m" - self.yellow_hi = "\033[103m" - self.brown_hi = "\033[43m" - self.lightgreen_hi = "\033[102m" - self.green_hi = "\033[42m" - self.cyan_hi = "\033[106m" - self.blue_hi = "\033[104m" - self.navy_hi = "\033[44m" - self.grey = "\033[90m" - self.pink = "\033[95m" - self.fuchsia = "\033[35m" - self.ruby = "\033[31m" - self.red = "\033[91m" #check - self.orange = "\033[91m" - self.yellow = "\033[93m" - self.brown = "\033[33m" - self.green = "\033[92m" - self.darkgreen = "\033[32m" - self.cyan = "\033[36m" - self.blue = "\033[94m" - self.navy = "\033[34m" - self.black = "\033[30m" - end - end - end - def colors - 0.upto(109) {|i| print "\033[#{i}m 33[#{i}m \033[m"} - puts '' - end - def color - case @color_instruct - when /invert/ then @cX.invert - when /darkgrey_hi/ then @cX.darkgrey_hi - when /grey_hi/ then @cX.grey_hi - when /pink_hi/ then @cX.pink_hi - when /fuchsia_hi/ then @cX.fuchsia_hi - when /red_hi/ then @cX.red_hi - when /orange_hi/ then @cX.orange_hi - when /yellow_hi/ then @cX.yellow_hi - when /brown_hi/ then @cX.brown_hi - when /lightgreen_hi/ then @cX.lightgreen_hi - when /green_hi/ then @cX.green_hi - when /cyan_hi/ then @cX.cyan_hi - when /blue_hi/ then @cX.blue_hi - when /navy_hi/ then @cX.navy_hi - when /white/ then @cX.white - when /grey/ then @cX.grey - when /pink/ then @cX.pink - when /fuchsia/ then @cX.fuchsia - when /ruby/ then @cX.ruby - when /red/ then @cX.red - when /orange/ then @cX.orange - when /yellow/ then @cX.yellow - when /brown/ then @cX.brown - when /green/ then @cX.green - when /darkgreen/ then @cX.darkgreen - when /cyan/ then @cX.cyan - when /blue/ then @cX.blue - when /navy/ then @cX.navy - when /close/ then @cX.off - when /off/ then @cX.off - end - end - def colorize - case @color_instruct - when /invert/ then puts "#{@cX.invert}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}" - when /darkgrey_hi/ then puts "#{@cX.darkgrey_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}" - when /grey_hi/ then puts "#{@cX.grey_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}" - when /pink_hi/ then puts "#{@cX.pink_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}" - when /fuchsia_hi/ then puts "#{@cX.fuchsia_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}" - when /red_hi/ then puts "#{@cX.red_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}" - when /orange_hi/ then puts "#{@cX.orange_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}" - when /yellow_hi/ then puts "#{@cX.yellow_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}" - when /brown_hi/ then puts "#{@cX.brown_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}" - when /lightgreen_hi/ then puts "#{@cX.lightgreen_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}" - when /green_hi/ then puts "#{@cX.green_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}" - when /cyan_hi/ then puts "#{@cX.cyan_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}" - when /blue_hi/ then puts "#{@cX.blue_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}" - when /navy_hi/ then puts "#{@cX.navy_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}" - when /bold/ then puts "#{@cX.bold}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" - when /white/ then puts "#{@cX.off}#{@txt[1]} #{@txt[2]}" - when /grey/ then puts "#{@cX.grey}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" - when /pink/ then puts "#{@cX.pink}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" - when /fuchsia/ then puts "#{@cX.fuchsia}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" - when /ruby/ then puts "#{@cX.ruby}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" - when /red/ then puts "#{@cX.red}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" - when /orange/ then puts "#{@cX.orange}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" - when /yellow/ then puts "#{@cX.yellow}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" - when /brown/ then puts "#{@cX.brown}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" - when /green/ then puts "#{@cX.green}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" - when /darkgreen/ then puts "#{@cX.darkgreen}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" - when /cyan/ then puts "#{@cX.cyan}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" - when /blue/ then puts "#{@cX.blue}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" - when /navy/ then puts "#{@cX.navy}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" - end - end - def sourcename(sourcefilename) - @sourcefilename=sourcefilename - end - def basename(sourcefilename) - @basename=sourcefilename.sub(/\.(?:(?:-|ssm\.)?sst|ssm)$/,'') - end - def sisu - end - def rescue - STDERR.puts %{\t #{@cX.orange}Rescued#{@cX.off} #{@cX.grey}#{yield if block_given?}\n\t An#{@cX.off} #{@cX.fuchsia}ERROR#{@cX.off} #{@cX.grey}occurred, message:#{@cX.off} #{@cX.fuchsia}#{@txt[0]}#{@cX.off} #{@cX.grey}#{@txt[1]}#{@cX.off} #{@cX.brown}#{@txt[2]}#{@cX.off}} - end - def warn - STDERR.puts "\t #{@cX.brown}#{@txt[0]}#{@cX.off} #{@cX.grey}#{@txt[1]}#{@cX.off}" - end - def error - STDERR.puts "\t #{@cX.fuchsia}#{@txt[0]}#{@cX.off} #{@cX.brown}#{@txt[1]}#{@cX.off}" - end - def error2 - STDERR.puts "\t #{@cX.grey}#{@txt[0]}#{@cX.off} #{@cX.fuchsia}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" - end - def version - puts "#{@cX.blue_hi}#{@txt[0]} #{@txt[1]}#{@cX.off} #{@cX.grey} (#{@txt[3]} [#{@txt[2]}])#{@txt[4]} &#{@cX.off} #{@cX.ruby}Ruby#{@cX.off} #{@cX.grey}(#{@txt[5]})#{@cX.off}\n" - end - def html3numbers - puts %{\t#{@cX.green}#{@txt[0]}#{@cX.off} #{@cX.cyan}files processed#{@cX.off}. } + - %{#{@cX.grey}} + - %{scroll only: #{@txt[1]}, seg only: #{@txt[2]},} + - %{#{@cX.off} } + - %{#{@cX.cyan}joint scroll & seg: #{@txt[3]},#{@cX.off}} + - %{#{@cX.grey} } + - %{nav only: #{@txt[4]}} + - %{#{@cX.off}} - end - def html2numbers - puts %{\t#{@cX.green}#{@txt[0]}#{@cX.off} #{@cX.cyan}files processed#{@cX.off}. } + - %{#{@cX.grey}} + - %{scroll only: #{@txt[1]},} + - %{#{@cX.off} } + - %{#{@cX.cyan}seg only: #{@txt[2]},#{@cX.off}} + - %{#{@cX.grey} } + - %{joint scroll & seg: #{@txt[3]}, nav only: #{@n_files_nav}} + - %{#{@cX.off}} - end - def html1numbers - puts %{\t#{@cX.green}#{@txt[0]}#{@cX.off} #{@cX.cyan}files processed#{@cX.off}. } + - %{#{@cX.cyan}scroll only: #{@txt[1]},#{@cX.off}} + - %{#{@cX.grey} } + - %{seg only: #{@txt[2]}, } + - %{joint scroll & seg: #{@txt[3]}, nav only: #{@n_files_nav}} + - %{#{@cX.off}} - end - def html0_numbers - puts %{\t#{@cX.ruby}#{@txt[0]} files processed#{@cX.off}. } + - %{#{@cX.grey}} + - %{scroll only: #{@txt[1]}, seg only: #{@txt[2]}, joint scroll & seg: #{@txt[3]},} + - %{#{@cX.off} } + - %{#{@cX.cyan}nav only: #{@txt[4]}#{@cX.off}.} - end - def grey - puts "#{@cX.grey}#{@txt[0]}#{@cX.off} #{@cX.cyan}#{@txt[1]}#{@cX.off}" - end - def txt_white - puts "\t#{@cX.white}#{@txt[0]}#{@cX.off} #{@cX.white}#{@txt[1]}#{@cX.off}" - end - def txt_grey - puts "\t#{@cX.grey}#{@txt[0]}#{@cX.off} #{@cX.cyan}#{@txt[1]}#{@cX.off}" - end - def txt_cyan - puts "\t#{@cX.cyan}#{@txt[0]}#{@cX.off} #{@cX.grey}#{@txt[1]}#{@cX.off}" - end - def txt_blue - puts "\t#{@cX.blue}#{@txt[0]}#{@cX.off} #{@cX.grey}#{@txt[1]}#{@cX.off}" - end - def txt_red - puts "\t#{@cX.red}#{@txt[0]}#{@cX.off} #{@cX.cyan}#{@txt[1]}#{@cX.off}" - end - def txt_green - puts "\t#{@cX.green}#{@txt[0]}#{@cX.off} #{@cX.grey}#{@txt[1]}#{@cX.off}" - end - def url #clean - blue - end - def result - puts "\t#{@cX.green}#{@txt[0]}#{@cX.off} #{@cX.blue}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" - end - def maintenance - puts "\t#{@cX.grey}#{@txt[0]}#{@cX.off} #{@cX.brown}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" - end - def instruct - puts %{\t #{@cX.grey}#{@txt[0]}#{@cX.off} #{@cX.cyan}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off} #{@cX.cyan}#{@txt[3]}#{@cX.off} #{@cX.grey}#{@txt[4]}#{@cX.off} "#{@cX.brown}#{@f}#{@cX.off}"} - end - def grey_open - print @cX.grey - end - def p_off - print @cX.off - end - def p_close - print @cX.off - end - def flow - puts %{\t#{@cX.grey}#{@txt[0]}#{@cX.off} #{@cX.ruby}->#{@cX.off}\n\t #{@cX.blue}#{@txt[1]}#{@cX.off}} - end - def output - puts %{\t#{@cX.grey}#{@txt[0]}#{@cX.off} #{@cX.ruby}->#{@cX.off}\n\t #{@cX.blue}#{@txt[1]}#{@cX.off}} - end - def generic - puts %{\t#{@cX.navy}#{@txt[0]} #{@txt[1]}#{@cX.off}. } - end - def files_processed - puts %{\t#{@cX.green}#{@txt[0]}#{@cX.off} #{@cX.grey}#{@txt[1]}#{@cX.off}} - end - def print_blue - print "#{@cX.blue}#{@txt[0]} #{@txt[1]}#{@cX.off}" - end - def puts_blue - puts "#{@cX.blue}#{@txt[0]} #{@txt[1]}#{@cX.off}" - end - def print_brown - print "#{@cX.brown}#{@txt[0]}#{@cX.off}" - end - def blue_tab - print "\t#{@cX.blue}#{@txt[0]}#{@cX.off}\n" - end - def print_grey - print "#{@cX.grey}#{@txt[0]} #{@txt[1]}#{@cX.off}" - end - def puts_grey - puts "#{@cX.grey}#{@txt[0]} #{@txt[1]}#{@cX.off}" - end - def puts_brown - puts "#{@cX.brown}#{@txt[0]} #{@txt[1]}#{@cX.off}" - end - def grey_tab - print "\t#{@cX.grey}#{@txt[0]}#{@cX.off}\n" - end - def green_title - puts %{#{@cX.green}#{@txt[0]}#{@cX.off} #{@cX.grey}#{@txt[1]}#{@cX.off}} - end - def green_title_hi - puts %{#{@cX.green_hi}#{@cX.black}#{@txt[0]}#{@cX.off*2} #{@cX.grey}#{@txt[1]}#{@cX.off}} - end - def green_hi_blue - puts %{#{@cX.green_hi}#{@cX.black}#{@txt[0]}#{@cX.off*2} #{@cX.blue}#{@txt[1]}#{@cX.off}} - end - def blue_title_hi - puts %{#{@cX.blue_hi}#{@txt[0]}#{@cX.off*2} #{@cX.blue}#{@txt[1]}#{@cX.off}} - end - def grey_title_hi - puts %{#{@cX.grey_hi}#{@cX.black}#{@txt[0]}#{@cX.off*2} #{@cX.blue}#{@txt[1]}#{@cX.off}} - end - def grey_title_grey_blue - puts %{#{@cX.grey_hi}#{@cX.black}#{@txt[0]}#{@cX.off*2} #{@cX.grey}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off}} - end - def dark_grey_title_hi - puts %{#{@cX.darkgrey_hi}#{@cX.black}#{@txt[0]}#{@cX.off*2} #{@cX.blue}#{@txt[1]}#{@cX.off}} - end - def cyan_title_hi - puts %{#{@cX.cyan_hi}#{@cX.black}#{@txt[0]}#{@cX.off*2} #{@cX.blue}#{@txt[1]}#{@cX.off}} - end - def cyan_hi_blue - puts %{#{@cX.cyan_hi}#{@cX.black}#{@txt[0]}#{@cX.off*2} #{@cX.blue}#{@txt[1]}#{@cX.off}} - end - def dbi_title - puts %{#{@cX.blue_hi}#{@cX.black}#{@txt[0]}#{@cX.off*2} #{@cX.cyan}#{@cX.grey}#{@txt[1]}#{@cX.off*2} #{@cX.green}#{@txt[2]}#{@cX.off}} - end - def yellow_title_hi - puts %{#{@cX.yellow_hi}#{@cX.black}#{@txt[0]}#{@cX.off*2} #{@cX.blue}#{@txt[1]}#{@cX.off}} - end - def term_sheet_title - puts %{\t#{@cX.green}#{@txt[0]}#{@cX.off} #{@cX.red_hi}#{@cX.black}#{@txt[1]}.#{@cX.off*2} } - end - def generic_number - puts "#{@cX.green}#{@txt[0]}#{@cX.off} #{@cX.grey}#{@txt[1]}#{@cX.off}" - end - def tex_numbers - puts %{ #{@cX.green}#{@txt[0]}#{@cX.off} #{@cX.cyan}tex/pdf files processed#{@cX.off}.} - end - def tex_info_numbers - puts %{ #{@cX.green}#{@txt[0]}#{@cX.off} #{@cX.cyan}texinfo files processed#{@cX.off}.} - end - def lout_numbers - puts %{ #{@cX.green}#{@n_lout}#{@cX.off} #{@cX.cyan}lout/pdf files processed#{@cX.off}.} - end - def parameters - end - def reserved - puts %{ #{@cX.grey_hi}#{@cX.black}reserved#{@cX.off*2}} - end - def meta_verse_title - puts %{#{@cX.green_hi}#{@cX.black}MetaVerse#{@cX.off*2} } - end - def meta_verse_title_v - b=sourcename(@txt[0]) - puts %{#{@cX.green_hi}#{@cX.black}MetaVerse#{@cX.off*2} } + - %{#{@cX.grey}#{@txt[0]}#{@cX.off} #{@cX.ruby}->#{@cX.off}\n\t #{@cX.blue}~meta/#{b}.meta#{@cX.off}} - end - def meta_verse - puts "\t#{@cX.grey}MetaVerse#{@cX.off}" - end - def meta_verse_skipped - puts %{\t#{@cX.grey}MetaVerse: MarshalLoad (creation of metaVerse skipped)#{@cX.off}} - end - def meta_verse_load - puts %{\t<>} - end - def html_title - puts %{#{@cX.green_hi}#{@cX.black}HTML#{@cX.off*2}} - end - def html_output - puts %{\t#{@cX.grey}#{@txt[0]}#{@cX.off} #{@cX.ruby}->#{@cX.off}\n\t #{@cX.blue}#{@txt[1]}#{@cX.off}} - end - def segmented - puts "\t#{@cX.grey}Seg#{@cX.off} #{@cX.green}#{@txt[0]}#{@cX.off} #{@cX.grey}segments#{@cX.off}" - end - end -end -__END__ - Color.new do - self.off = "\033[0m" - self.white = "\033[37m" - self.white_bold = "\033[1m" - self.marker = "\033[42m" - self.bold = "\033[1m" - self.underline = "\033[4m" - self.invert = "\033[7m" - self.darkgrey_hi = "\033[100m" - self.grey_hi = "\033[47m" - self.pink_hi = "\033[105m" - self.fuchsia_hi = "\033[45m" - self.red_hi = "\033[41m" - self.orange_hi = "\033[101m" - self.yellow_hi = "\033[103m" - self.brown_hi = "\033[43m" - self.lightgreen_hi = "\033[102m" - self.green_hi = "\033[42m" - self.cyan_hi = "\033[106m" - self.blue_hi = "\033[104m" - self.navy_hi = "\033[44m" - self.grey = "\033[90m" - self.pink = "\033[95m" - self.fuchsia = "\033[35m" - self.ruby = "\033[31m" - self.red = "\033[91m" #check - self.orange = "\033[91m" - self.yellow = "\033[93m" - self.brown = "\033[33m" - self.green = "\033[92m" - self.darkgreen = "\033[32m" - self.cyan = "\033[36m" - self.blue = "\033[94m" - self.navy = "\033[34m" - self.black = "\033[30m" - end -# fewer colors - Color.new do - self.off = "\033[0m" - self.white = "\033[0m" - self.marker = "\033[42m" - self.bold = "\033[1m" - self.underline = "\033[4m" - self.invert = "\033[7m" - self.darkgrey_hi = "\033[100m" - self.grey_hi = "\033[47m" - self.pink_hi = "\033[105m" - self.fuchsia_hi = "\033[45m" - self.red_hi = "\033[41m" - self.orange_hi = "\033[101m" - self.yellow_hi = "\033[103m" - self.brown_hi = "\033[43m" - self.lightgreen_hi = "\033[102m" - self.green_hi = "\033[42m" - self.cyan_hi = "\033[106m" - self.blue_hi = "\033[104m" - self.navy_hi = "\033[44m" - self.grey = "\033[90m" - self.pink = "\033[95m" - self.fuchsia = "\033[35m" - self.ruby = "\033[31m" - self.red = "\033[31m" #check - self.orange = "\033[91m" - self.yellow = "\033[33m" - self.brown = "\033[33m" - self.green = "\033[32m" - self.darkgreen = "\033[32m" - self.cyan = "\033[36m" - self.blue = "\033[34m" - self.navy = "\033[34m" - self.black = "\033[30m" - end diff --git a/lib/sisu/v6/se.rb b/lib/sisu/v6/se.rb new file mode 100644 index 00000000..c79f38b5 --- /dev/null +++ b/lib/sisu/v6/se.rb @@ -0,0 +1,164 @@ +# encoding: utf-8 +=begin + + * Name: SiSU + + * Description: a framework for document structuring, publishing and search + + * Author: Ralph Amissah + + * Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. + + * License: GPL 3 or later: + + SiSU, a framework for document structuring, publishing and search + + Copyright (C) Ralph Amissah + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along with + this program. If not, see . + + 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: + + + * Git + + + + * Ralph Amissah + + + + ** Description: system environment, resource control and configuration details + +=end +@@cX=nil +module SiSU_Env + require_relative 'constants' # constants.rb + require_relative 'utils' # utils.rb + require_relative 'se_date' # se_date.rb + require_relative 'se_info_system' # se_info_system.rb + require_relative 'se_load' # se_load.rb + require_relative 'se_get_init' # se_get_init.rb + require_relative 'se_envcall' # se_envcall.rb + require_relative 'se_programs' # se_programs.rb + require_relative 'se_standardise_lang' # se_standardise_lang.rb + require_relative 'se_info_env' # se_info_env.rb + require_relative 'se_processing' # se_processing.rb + require_relative 'se_filemap' # se_filemap.rb + require_relative 'se_file_op' # se_file_op.rb + require_relative 'se_cleanoutput' # se_cleanoutput.rb + require_relative 'se_remotes' # se_remotes.rb + require_relative 'se_version' # se_version.rb + require_relative 'se_db' # se_db.rb + require_relative 'se_css' # se_css.rb + require_relative 'se_clear' # se_clear.rb + require_relative 'se_createsite' # se_createsite.rb + require_relative 'se_info_port' # se_info_port.rb + begin + require 'singleton' + require 'fileutils' + include FileUtils::Verbose + rescue LoadError + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). + error('singleton or fileutils NOT FOUND (LoadError)') + end + @@noyaml=false + class InfoDate < SiSU_Info_Date::InfoDate # se_date.rb + end + class InfoSystemGen < SiSU_Info_Sys_Gen::InfoSystemGen # se_info_system.rb + end + class InfoSystem < SiSU_Info_Sys::InfoSystem # se_info_system.rb + end + class Load < SiSU_Load::Load # se_load.rb + end + class GetInit < SiSU_Get_Init::GetInit # se_get_init.rb + end + class EnvCall < SiSU_Env_Call::EnvCall # se_envcall.rb + end + class SystemCall < SiSU_Sys_Call::SystemCall # se_programs.rb + end + class StandardiseLanguage < SiSU_Standardise_Lang::StandardiseLanguage # se_standardise_lang.rb + end + class InfoEnv < SiSU_Info_Env::InfoEnv # se_info_env.rb + end + class InfoProcessingFlag < SiSU_Info_Processing_Flag::InfoProcessingFlag # se_processing.rb + end + class InfoSettings < SiSU_Info_Set::InfoSettings # se_programs.rb + end + class FileMap < SiSU_File_Map::FileMap # se_filemap.rb + end + class CleanOutput < SiSU_Clean_Output::CleanOutput # se_cleanoutput.rb + end + class InfoRemoteHost < SiSU_Info_Remote_Host::InfoRemoteHost # se_remotes.rb + end + class InfoRemote < SiSU_Info_Remote::InfoRemote # se_remotes.rb + end + class InfoVersion < SiSU_Info_Version::InfoVersion # se_version.rb + end + class InfoAbout < SiSU_Info_About::InfoAbout # se_version.rb + end + class InfoFile < SiSU_Info_File::InfoFile # se_file_op.rb + end + class ProcessingSettings < SiSU_Processing_Settings::ProcessingSettings # se_processing.rb + end + class InfoDb < SiSU_Info_Db::InfoDb # se_db.rb + end + class DbOp < SiSU_Db_Op::DbOp # se_db.rb + end + class FileOp < SiSU_File_Op::FileOp # se_file_op.rb + end + class FilenameLanguageCodeInsert < SiSU_Filename_Lang::FilenameLanguageCodeInsert # se_file_op.rb + end + class CreateFile < SiSU_Create_File::CreateFile # se_file_op.rb + end + class Clear < SiSU_Clear::Clear # se_clear.rb + end + class InfoPort < SiSU_Info_Port::InfoPort # se_info_port.rb + end + class InfoProgram < SiSU_Info_Program::InfoProgram # se_programs.rb + end + class CSS_Default < SiSU_CSS::CSS_Default # se_css.rb + end + class CSS_Select < SiSU_CSS::CSS_Select # se_css.rb + end + class CSS_Stylesheet < SiSU_CSS::CSS_Stylesheet # se_css.rb + end + class CreateSite < SiSU_Create_Site::CreateSite # se_createsite.rb + end +end +module SiSU_Screen + require_relative 'utils_screen_text_color' # utils_screen_text_color.rb +end +module SiSU_Errors + require_relative 'errors' # errors.rb +end +__END__ diff --git a/lib/sisu/v6/se_createsite.rb b/lib/sisu/v6/se_createsite.rb index c35d24d4..7b1046f5 100644 --- a/lib/sisu/v6/se_createsite.rb +++ b/lib/sisu/v6/se_createsite.rb @@ -63,7 +63,7 @@ module SiSU_Create_Site require_relative 'constants' # constants.rb require_relative 'utils' # utils.rb - require_relative 'screen_text_color' # screen_text_color.rb + require_relative 'utils_screen_text_color' # utils_screen_text_color.rb require_relative 'se_info_env' # se_info_env.rb begin require 'fileutils' diff --git a/lib/sisu/v6/se_filemap.rb b/lib/sisu/v6/se_filemap.rb index 987f8f4f..88a80954 100644 --- a/lib/sisu/v6/se_filemap.rb +++ b/lib/sisu/v6/se_filemap.rb @@ -145,7 +145,7 @@ module SiSU_File_Map ft << @md.fn[:xml_scaffold_structure_collapse] end @fnb=@md.fnb - else # still needed where/when param is not parsed + else # still needed where/when dp document param is not parsed if @opt.act[:html][:set]==:on #% --html, -h -H ft << '.html' << '.html.??' end diff --git a/lib/sisu/v6/se_hub_particulars.rb b/lib/sisu/v6/se_hub_particulars.rb new file mode 100644 index 00000000..99bdf9f6 --- /dev/null +++ b/lib/sisu/v6/se_hub_particulars.rb @@ -0,0 +1,240 @@ +# encoding: utf-8 +=begin + + * Name: SiSU + + * Description: a framework for document structuring, publishing and search + particulars, composite information about document being processed + + * Author: Ralph Amissah + + * Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. + + * License: GPL 3 or later: + + SiSU, a framework for document structuring, publishing and search + + Copyright (C) Ralph Amissah + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along with + this program. If not, see . + + 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: + + + * Git + + + + * Ralph Amissah + + + + ** Description: system environment, resource control and configuration details + +=end +module SiSU_Particulars + begin + require 'singleton' + rescue LoadError + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('singleton NOT FOUND (LoadError)') + end + require_relative 'se' # se.rb + include SiSU_Env + require_relative 'dp' # dp.rb + include SiSU_Param + require_relative 'ao' # ao.rb + class CombinedSingleton + include Singleton + def get_all(opt) + set_env(opt) + set_file(opt) + set_md(opt) + set_ao(opt) #needs @md + end + def get_env(opt) + set_env(opt) + end + def get_file(opt) + set_file(opt) + end + def get_md(opt) + set_md(opt) + end + def get_ao_array(opt) + set_ao(opt) #needs @md + end + def get_env_md(opt) + set_env(opt) + set_md(opt) + end + def get_idx_sst(opt) + set_sst_idx(opt) + end + def get_idx_raw(opt) + set_raw_idx(opt) + end + def get_idx_html(opt) + set_html_idx(opt) + end + def get_idx_xhtml(opt) + set_xhtml_idx(opt) + end + def get_name_tags(opt) + set_name_tags(opt) + end + def get_maps(opt) + set_nametags_map(opt) + set_ocn_htmlseg_map(opt) + end + def get_map_nametags(opt) + set_nametags_map(opt) + end + def get_map_ocn_htmlseg(opt) + set_ocn_htmlseg_map(opt) + end + attr_accessor :opt,:md,:sst_idx,:raw_idx,:html_idx,:xhtml_idx + def set_md(opt) + begin + @md=SiSU_Param::Parameters.new(opt).get + self + rescue + SiSU_Errors::Rescued.new($!,$@,opt.selections.str,opt.fnl).location do + __LINE__.to_s + ':' + __FILE__ + end + end + end + attr_accessor :opt,:env,:file + def set_env(opt) + begin + @env=SiSU_Env::InfoEnv.new(opt.fns) + self + rescue + SiSU_Errors::Rescued.new($!,$@,opt.selections.str,opt.fnl).location do + __LINE__.to_s + ':' + __FILE__ + end + end + end + def set_file(opt) + begin + set_md(opt) unless @md + @file=SiSU_Env::FileOp.new(@md) + self + rescue + SiSU_Errors::Rescued.new($!,$@,opt.selections.str,opt.fnl).location do + __LINE__.to_s + ':' + __FILE__ + end + end + end + attr_accessor :opt,:ao_array + def set_ao(opt) + begin + @ao_array=SiSU_AO::Source.new(opt).get + self + rescue + SiSU_Errors::Rescued.new($!,$@,opt.selections.str,opt.fnl).location do + __LINE__.to_s + ':' + __FILE__ + end + end + end + def set_sst_idx(opt) + begin + @sst_idx=SiSU_AO::Source.new(opt).get_idx_sst + self + rescue + SiSU_Errors::Rescued.new($!,$@,opt.selections.str,opt.fnl).location do + __LINE__.to_s + ':' + __FILE__ + end + end + end + def set_raw_idx(opt) + begin + @raw_idx=SiSU_AO::Source.new(opt).get_idx_raw + self + rescue + SiSU_Errors::Rescued.new($!,$@,opt.selections.str,opt.fnl).location do + __LINE__.to_s + ':' + __FILE__ + end + end + end + def set_html_idx(opt) + begin + @html_idx=SiSU_AO::Source.new(opt).get_idx_html + self + rescue + SiSU_Errors::Rescued.new($!,$@,opt.selections.str,opt.fnl).location do + __LINE__.to_s + ':' + __FILE__ + end + end + end + def set_xhtml_idx(opt) + begin + @xhtml_idx=SiSU_AO::Source.new(opt).get_idx_xhtml + self + rescue + SiSU_Errors::Rescued.new($!,$@,opt.selections.str,opt.fnl).location do + __LINE__.to_s + ':' + __FILE__ + end + end + end + attr_accessor :nametags_map + def set_nametags_map(opt) + begin + opt=@md ? @md : opt + @nametags_map=SiSU_AO::Source.new(opt).get_map_nametags + self + rescue + if @md + SiSU_Errors::Rescued.new($!,$@,@md.opt.selections.str,@md.opt.fnl).location do + __LINE__.to_s + ':' + __FILE__ + end + else + SiSU_Errors::Rescued.new($!,$@,opt.selections.str,opt.fnl).location do + __LINE__.to_s + ':' + __FILE__ + end + end + end + end + attr_accessor :ocn_htmlseg_map + def set_ocn_htmlseg_map(opt) + begin + @ocn_htmlseg_map=SiSU_AO::Source.new(@md).get_map_ocn_htmlseg + self + rescue + SiSU_Errors::Rescued.new($!,$@,opt.selections.str,opt.fnl).location do + __LINE__.to_s + ':' + __FILE__ + end + end + end + end +end +__END__ +consider running as separate objects diff --git a/lib/sisu/v6/shared_images.rb b/lib/sisu/v6/shared_images.rb index 536a2f21..073ed6d8 100644 --- a/lib/sisu/v6/shared_images.rb +++ b/lib/sisu/v6/shared_images.rb @@ -60,7 +60,7 @@ ** Description: common file for xml generation =end module SiSU_Images - require_relative 'particulars' # particulars.rb + require_relative 'se_hub_particulars' # se_hub_particulars.rb class Source def initialize(opt) @particulars=SiSU_Particulars::CombinedSingleton.instance.get_all(opt) diff --git a/lib/sisu/v6/shared_sem.rb b/lib/sisu/v6/shared_sem.rb index 02c04a85..26fe5884 100644 --- a/lib/sisu/v6/shared_sem.rb +++ b/lib/sisu/v6/shared_sem.rb @@ -62,7 +62,7 @@ =end module SiSU_Sem - require_relative 'param' # param.rb + require_relative 'dp' # dp.rb class Tags def initialize(para,md) @para,@md=para,md diff --git a/lib/sisu/v6/sitemaps.rb b/lib/sisu/v6/sitemaps.rb index 0b19314a..e656693a 100644 --- a/lib/sisu/v6/sitemaps.rb +++ b/lib/sisu/v6/sitemaps.rb @@ -57,13 +57,13 @@ - ** Description: sitemap created from parameters extracted from input file(s) + ** Description: sitemap created from document parameters =end module SiSU_Sitemaps - require_relative 'param' # param.rb + require_relative 'dp' # dp.rb include SiSU_Param - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env require_relative 'xml_shared' # xml_shared.rb include SiSU_XML_Munge diff --git a/lib/sisu/v6/spell.rb b/lib/sisu/v6/spell.rb deleted file mode 100644 index a0f6e904..00000000 --- a/lib/sisu/v6/spell.rb +++ /dev/null @@ -1,105 +0,0 @@ -# encoding: utf-8 -=begin - - * Name: SiSU - - * Description: a framework for document structuring, publishing and search - - * Author: Ralph Amissah - - * Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, - All Rights Reserved. - - * License: GPL 3 or later: - - SiSU, a framework for document structuring, publishing and search - - Copyright (C) Ralph Amissah - - This program is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the Free - Software Foundation, either version 3 of the License, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - more details. - - You should have received a copy of the GNU General Public License along with - this program. If not, see . - - 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: - - - * Git - - - - * Ralph Amissah - - - - ** Description: spellchecking - -=end -module SiSU_SpellUtility - class Spell - def initialize(input,filesrc,flg) - @flg=flg - @filename, @filetype = /(.+?)(\.\w\w\w0$)/.match(filesrc)[1,2] #.gsub(/\.\w\w\w0$/, "") - @input=input - @allwords=[] - puts @filename - @speller='aspell' # 'ispell' - @dictionary='british' - @lang='en_GB' - end - def check - @input.each do |data| - data=data.gsub(/(https?|www|ftp|gopher|png|jpg|gif|html|htm)\S+/i,' '). - gsub(/( |#{Mx[:nbsp]})/i,' '). - gsub(/<\/?(table|tr|td|b|p|href).*?>/i,' '). - gsub(/(<==.+|<:\S+>||^@\S+?:.+|\{\{\{|~)/,' '). - gsub(/(["|<>)(\n'`.;&_-]|\=)/,' '). - gsub(/\b(altExternal| - target|externalimg| - srcimagebext| - img|src|toc|pdf| - cd|org| - helvetica|roman - )\b/i,' '). - gsub(/EOF/,'') - @words=data.scan(/\S+/) - @words.each { |y| @allwords << y } - end - @allwords=@allwords.uniq - if @flg =~ /S/ - File.open('/home/ralph/spell_error','a+') do |file| #fix - file.puts %{\n\n<<#{@filename}>>} - end - @allwords.each { |y| puts y.inspect; system(%{cat #{y} | /usr/bin/#{@speller} -l -d #{@dictionary} >> ~/spell_error })} - else - @allwords.each { |y| sp=%x{echo #{y}|#{@speller} -l }; puts sp unless sp.empty?} - end - end - end -end -__END__ diff --git a/lib/sisu/v6/src_kdissert_share.rb b/lib/sisu/v6/src_kdissert_share.rb index 8d6e95fa..ebe761f0 100644 --- a/lib/sisu/v6/src_kdissert_share.rb +++ b/lib/sisu/v6/src_kdissert_share.rb @@ -61,7 +61,7 @@ =end module SiSU_KdiSource - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env class Source begin diff --git a/lib/sisu/v6/src_share.rb b/lib/sisu/v6/src_share.rb index b132038a..c043f42b 100644 --- a/lib/sisu/v6/src_share.rb +++ b/lib/sisu/v6/src_share.rb @@ -63,7 +63,7 @@ module SiSU_Markup require_relative 'src_shared' # src_shared.rb include SiSU_Source - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env class Source < SiSU_Source::SiSUpodSource def initialize(opt,build=nil,place=nil) diff --git a/lib/sisu/v6/src_shared.rb b/lib/sisu/v6/src_shared.rb index 514e0458..f36bf308 100644 --- a/lib/sisu/v6/src_shared.rb +++ b/lib/sisu/v6/src_shared.rb @@ -63,8 +63,8 @@ module SiSU_Source include SiSU_Env class SiSUpodSource - require_relative 'sysenv' # sysenv.rb - require_relative 'particulars' # particulars.rb + require_relative 'se' # se.rb + require_relative 'se_hub_particulars' # se_hub_particulars.rb def initialize(opt,build=nil,place=nil) @opt=opt @date=SiSU_Env::InfoDate.new.dt diff --git a/lib/sisu/v6/src_sisupod_make.rb b/lib/sisu/v6/src_sisupod_make.rb index a1319e32..57f13e66 100644 --- a/lib/sisu/v6/src_sisupod_make.rb +++ b/lib/sisu/v6/src_sisupod_make.rb @@ -63,10 +63,10 @@ module SiSU_Doc require_relative 'src_shared' # scr_shared.rb include SiSU_Source - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env class Source < SiSU_Source::SiSUpodSource - require_relative 'response' # response.rb + require_relative 'utils_response' # utils_response.rb def initialize(opt,build=nil,place=nil) super(opt,build,place) @zipfile=@opt.fno.gsub(/(?:\~\S{2,3})?(\.ss[tm])$/,'\1') diff --git a/lib/sisu/v6/sst_convert_markup.rb b/lib/sisu/v6/sst_convert_markup.rb index 8d523d0f..6e73d25f 100644 --- a/lib/sisu/v6/sst_convert_markup.rb +++ b/lib/sisu/v6/sst_convert_markup.rb @@ -65,7 +65,7 @@ module SiSU_Modify require_relative 'sst_identify_markup' # sst_identify_markup.rb require_relative 'sst_from_xml' # sst_from_xml.rb - require_relative 'response' # response.rb + require_relative 'utils_response' # utils_response.rb class ConvertMarkup def initialize(opt) @opt=opt @@ -311,7 +311,7 @@ WOK end end #%% files to match for this conversion set -------------------------> -require_relative 'options' # options.rb +require_relative 'hub_options' # hub_options.rb argv=$* base_path=Dir.pwd @opt=SiSU_Commandline::Options.new(argv,base_path) diff --git a/lib/sisu/v6/sst_do_inline_footnotes.rb b/lib/sisu/v6/sst_do_inline_footnotes.rb index 7affab1f..afa4ca3a 100644 --- a/lib/sisu/v6/sst_do_inline_footnotes.rb +++ b/lib/sisu/v6/sst_do_inline_footnotes.rb @@ -64,9 +64,9 @@ module SiSU_ConvertFootnotes require_relative 'defaults' # defaults.rb include SiSU_Viz - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env - require_relative 'param' # param.rb + require_relative 'dp' # dp.rb include SiSU_Param require_relative 'ao_syntax' # ao_syntax.rb include SiSU_AO_Syntax @@ -277,7 +277,7 @@ module SiSU_ConvertFootnotes data=@data tuned_file=[] data.each do |para| - if @md.markup =~/0\.16|0\.37/ #parameters not extracted/available + if @md.markup =~/0\.16|0\.37/ #parameters not extracted/available para.gsub!(/^0~\S+\s+/,'@\1: ') para.gsub!(/^1~/,':A~') para.gsub!(/^2~/,':B~') diff --git a/lib/sisu/v6/sst_from_xml.rb b/lib/sisu/v6/sst_from_xml.rb index 12919a17..56083ff9 100644 --- a/lib/sisu/v6/sst_from_xml.rb +++ b/lib/sisu/v6/sst_from_xml.rb @@ -62,7 +62,7 @@ =end module SiSU_sstFromXML - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb class Convert begin require 'rexml/document' diff --git a/lib/sisu/v6/sst_to_s_xml_sax.rb b/lib/sisu/v6/sst_to_s_xml_sax.rb index ecdfb94e..0be6ffa0 100644 --- a/lib/sisu/v6/sst_to_s_xml_sax.rb +++ b/lib/sisu/v6/sst_to_s_xml_sax.rb @@ -61,13 +61,13 @@ =end module SiSU_SimpleXML_ModelSax - require_relative 'particulars' # particulars.rb + require_relative 'se_hub_particulars' # se_hub_particulars.rb include SiSU_Particulars require_relative 'defaults' # defaults.rb include SiSU_Viz - require_relative 'param' # param.rb + require_relative 'dp' # dp.rb include SiSU_Param - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env require_relative 'ao_doc_str' # ao_doc_str.rb require_relative 'xml_shared' # xml_shared.rb diff --git a/lib/sisu/v6/sysenv.rb b/lib/sisu/v6/sysenv.rb deleted file mode 100644 index 26ce7cdf..00000000 --- a/lib/sisu/v6/sysenv.rb +++ /dev/null @@ -1,164 +0,0 @@ -# encoding: utf-8 -=begin - - * Name: SiSU - - * Description: a framework for document structuring, publishing and search - - * Author: Ralph Amissah - - * Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, - All Rights Reserved. - - * License: GPL 3 or later: - - SiSU, a framework for document structuring, publishing and search - - Copyright (C) Ralph Amissah - - This program is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the Free - Software Foundation, either version 3 of the License, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - more details. - - You should have received a copy of the GNU General Public License along with - this program. If not, see . - - 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: - - - * Git - - - - * Ralph Amissah - - - - ** Description: system environment, resource control and configuration details - -=end -@@cX=nil -module SiSU_Env - require_relative 'constants' # constants.rb - require_relative 'utils' # utils.rb - require_relative 'se_date' # se_date.rb - require_relative 'se_info_system' # se_info_system.rb - require_relative 'se_load' # se_load.rb - require_relative 'se_get_init' # se_get_init.rb - require_relative 'se_envcall' # se_envcall.rb - require_relative 'se_programs' # se_programs.rb - require_relative 'se_standardise_lang' # se_standardise_lang.rb - require_relative 'se_info_env' # se_info_env.rb - require_relative 'se_processing' # se_processing.rb - require_relative 'se_filemap' # se_filemap.rb - require_relative 'se_file_op' # se_file_op.rb - require_relative 'se_cleanoutput' # se_cleanoutput.rb - require_relative 'se_remotes' # se_remotes.rb - require_relative 'se_version' # se_version.rb - require_relative 'se_db' # se_db.rb - require_relative 'se_css' # se_css.rb - require_relative 'se_clear' # se_clear.rb - require_relative 'se_createsite' # se_createsite.rb - require_relative 'se_info_port' # se_info_port.rb - begin - require 'singleton' - require 'fileutils' - include FileUtils::Verbose - rescue LoadError - SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). - error('singleton or fileutils NOT FOUND (LoadError)') - end - @@noyaml=false - class InfoDate < SiSU_Info_Date::InfoDate # se_date.rb - end - class InfoSystemGen < SiSU_Info_Sys_Gen::InfoSystemGen # se_info_system.rb - end - class InfoSystem < SiSU_Info_Sys::InfoSystem # se_info_system.rb - end - class Load < SiSU_Load::Load # se_load.rb - end - class GetInit < SiSU_Get_Init::GetInit # se_get_init.rb - end - class EnvCall < SiSU_Env_Call::EnvCall # se_envcall.rb - end - class SystemCall < SiSU_Sys_Call::SystemCall # se_programs.rb - end - class StandardiseLanguage < SiSU_Standardise_Lang::StandardiseLanguage # se_standardise_lang.rb - end - class InfoEnv < SiSU_Info_Env::InfoEnv # se_info_env.rb - end - class InfoProcessingFlag < SiSU_Info_Processing_Flag::InfoProcessingFlag # se_processing.rb - end - class InfoSettings < SiSU_Info_Set::InfoSettings # se_programs.rb - end - class FileMap < SiSU_File_Map::FileMap # se_filemap.rb - end - class CleanOutput < SiSU_Clean_Output::CleanOutput # se_cleanoutput.rb - end - class InfoRemoteHost < SiSU_Info_Remote_Host::InfoRemoteHost # se_remotes.rb - end - class InfoRemote < SiSU_Info_Remote::InfoRemote # se_remotes.rb - end - class InfoVersion < SiSU_Info_Version::InfoVersion # se_version.rb - end - class InfoAbout < SiSU_Info_About::InfoAbout # se_version.rb - end - class InfoFile < SiSU_Info_File::InfoFile # se_file_op.rb - end - class ProcessingSettings < SiSU_Processing_Settings::ProcessingSettings # se_processing.rb - end - class InfoDb < SiSU_Info_Db::InfoDb # se_db.rb - end - class DbOp < SiSU_Db_Op::DbOp # se_db.rb - end - class FileOp < SiSU_File_Op::FileOp # se_file_op.rb - end - class FilenameLanguageCodeInsert < SiSU_Filename_Lang::FilenameLanguageCodeInsert # se_file_op.rb - end - class CreateFile < SiSU_Create_File::CreateFile # se_file_op.rb - end - class Clear < SiSU_Clear::Clear # se_clear.rb - end - class InfoPort < SiSU_Info_Port::InfoPort # se_info_port.rb - end - class InfoProgram < SiSU_Info_Program::InfoProgram # se_programs.rb - end - class CSS_Default < SiSU_CSS::CSS_Default # se_css.rb - end - class CSS_Select < SiSU_CSS::CSS_Select # se_css.rb - end - class CSS_Stylesheet < SiSU_CSS::CSS_Stylesheet # se_css.rb - end - class CreateSite < SiSU_Create_Site::CreateSite # se_createsite.rb - end -end -module SiSU_Screen - require_relative 'screen_text_color' # screen_text_color.rb -end -module SiSU_Errors - require_relative 'errors' # errors.rb -end -__END__ diff --git a/lib/sisu/v6/termsheet.rb b/lib/sisu/v6/termsheet.rb index 834ca819..60202725 100644 --- a/lib/sisu/v6/termsheet.rb +++ b/lib/sisu/v6/termsheet.rb @@ -62,8 +62,8 @@ sample files must be provided - (saved till later as may confuse) =end -require_relative 'sysenv' # sysenv.rb -require_relative 'param' # param.rb +require_relative 'se' # se.rb +require_relative 'dp' # dp.rb include SiSU_Param @do,@done,@used,@html_output,@txt_input,@txt_output,@@report=Array.new(7){[]} @@info=nil @@ -123,7 +123,7 @@ WOK @@report << @done << @used << "\n" @done,@used=[],[] end -require_relative 'param' # param.rb +require_relative 'dp' # dp.rb @argv=$* @proc="#{@argv[0].to_s}" if @proc =~ /^-?[wft]/ diff --git a/lib/sisu/v6/texinfo.rb b/lib/sisu/v6/texinfo.rb index 459d3ac5..718d55e4 100644 --- a/lib/sisu/v6/texinfo.rb +++ b/lib/sisu/v6/texinfo.rb @@ -62,7 +62,7 @@ =end module SiSU_TexInfo require_relative 'html' # html.rb - require_relative 'param' # param.rb + require_relative 'dp' # dp.rb include SiSU_Param include SiSU_Viz #include Stamp ... needed removed arbitrarily 2005w05/1 (warnings about undefined flags) diff --git a/lib/sisu/v6/texinfo_format.rb b/lib/sisu/v6/texinfo_format.rb index 884abfcb..66ebbc7b 100644 --- a/lib/sisu/v6/texinfo_format.rb +++ b/lib/sisu/v6/texinfo_format.rb @@ -62,7 +62,7 @@ =end module SiSU_TexInfoFormat @@table_pg_break_counter=1 - require_relative 'param' # param.rb + require_relative 'dp' # dp.rb include SiSU_Param include SiSU_Viz class Texinfo diff --git a/lib/sisu/v6/texpdf.rb b/lib/sisu/v6/texpdf.rb index 2869c59b..4802614e 100644 --- a/lib/sisu/v6/texpdf.rb +++ b/lib/sisu/v6/texpdf.rb @@ -68,7 +68,7 @@ module SiSU_TeX end require_relative 'defaults' # defaults.rb include SiSU_Viz - require_relative 'particulars' # particulars.rb + require_relative 'se_hub_particulars' # se_hub_particulars.rb include SiSU_Particulars require_relative 'texpdf_format' # texpdf_format.rb include SiSU_TeX_Pdf @@ -87,7 +87,7 @@ module SiSU_TeX rescue LoadError SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('pstore NOT FOUND (LoadError)') end - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env include SiSU_Viz require_relative 'ao' # ao.rb diff --git a/lib/sisu/v6/txt_asciidoc.rb b/lib/sisu/v6/txt_asciidoc.rb index fd10b25c..2b4b8927 100644 --- a/lib/sisu/v6/txt_asciidoc.rb +++ b/lib/sisu/v6/txt_asciidoc.rb @@ -62,7 +62,7 @@ =end module SiSU_Txt_AsciiDoc require_relative 'ao' # ao.rb - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env require_relative 'shared_metadata' # shared_metadata.rb require_relative 'txt_shared' # txt_shared.rb diff --git a/lib/sisu/v6/txt_markdown.rb b/lib/sisu/v6/txt_markdown.rb index 1fc488be..f7faf077 100644 --- a/lib/sisu/v6/txt_markdown.rb +++ b/lib/sisu/v6/txt_markdown.rb @@ -62,7 +62,7 @@ =end module SiSU_Txt_Markdown require_relative 'ao' # ao.rb - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env require_relative 'shared_metadata' # shared_metadata.rb require_relative 'txt_shared' # txt_shared.rb diff --git a/lib/sisu/v6/txt_plain.rb b/lib/sisu/v6/txt_plain.rb index 3f54e749..7572b89e 100644 --- a/lib/sisu/v6/txt_plain.rb +++ b/lib/sisu/v6/txt_plain.rb @@ -63,7 +63,7 @@ =end module SiSU_Txt_Plain require_relative 'ao' # ao.rb - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env require_relative 'shared_metadata' # shared_metadata.rb require_relative 'txt_shared' # txt_shared.rb diff --git a/lib/sisu/v6/txt_rst.rb b/lib/sisu/v6/txt_rst.rb index e60d5761..cda1b631 100644 --- a/lib/sisu/v6/txt_rst.rb +++ b/lib/sisu/v6/txt_rst.rb @@ -62,7 +62,7 @@ =end module SiSU_Txt_rST require_relative 'ao' # ao.rb - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env require_relative 'shared_metadata' # shared_metadata.rb require_relative 'txt_shared' # txt_shared.rb diff --git a/lib/sisu/v6/txt_textile.rb b/lib/sisu/v6/txt_textile.rb index 00baaa1f..d59a64b9 100644 --- a/lib/sisu/v6/txt_textile.rb +++ b/lib/sisu/v6/txt_textile.rb @@ -62,7 +62,7 @@ =end module SiSU_Txt_Textile require_relative 'ao' # ao.rb - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env require_relative 'shared_metadata' # shared_metadata.rb require_relative 'txt_shared' # txt_shared.rb diff --git a/lib/sisu/v6/update.rb b/lib/sisu/v6/update.rb index 40817138..b9dc46c2 100644 --- a/lib/sisu/v6/update.rb +++ b/lib/sisu/v6/update.rb @@ -61,7 +61,7 @@ =end module SiSU_UpdateControlFlag - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env include SiSU_Param class Check diff --git a/lib/sisu/v6/urls.rb b/lib/sisu/v6/urls.rb index 9cc47afd..1a1088f9 100644 --- a/lib/sisu/v6/urls.rb +++ b/lib/sisu/v6/urls.rb @@ -61,9 +61,9 @@ =end module SiSU_Urls - require_relative 'particulars' # particulars.rb + require_relative 'se_hub_particulars' # se_hub_particulars.rb include SiSU_Particulars - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env; include SiSU_Screen class Source attr_reader :opt diff --git a/lib/sisu/v6/utils_response.rb b/lib/sisu/v6/utils_response.rb new file mode 100644 index 00000000..59037c2e --- /dev/null +++ b/lib/sisu/v6/utils_response.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, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. + + * License: GPL 3 or later: + + SiSU, a framework for document structuring, publishing and search + + Copyright (C) Ralph Amissah + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along with + this program. If not, see . + + 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: + + + * Git + + + + * Ralph Amissah + + + + ** Description: Request response + +=end +module SiSU_Response + class Response + def response?(ask) #move to more appropriate directory later + response='redo' + print ask + " ['yes', 'no' or 'quit']: " + response=File.new('/dev/tty').gets.strip + ans=if response=='yes' then true + elsif response=='no' then false + elsif response =~/^quit|exit$/ then exit + else puts "[please type: 'yes', 'no' or 'quit']" + response?(ask) + end + ans + end + end +end +__END__ diff --git a/lib/sisu/v6/utils_screen_text_color.rb b/lib/sisu/v6/utils_screen_text_color.rb new file mode 100644 index 00000000..c9842c37 --- /dev/null +++ b/lib/sisu/v6/utils_screen_text_color.rb @@ -0,0 +1,478 @@ +# encoding: utf-8 +=begin + + * Name: SiSU + + * Description: a framework for document structuring, publishing and search + + * Author: Ralph Amissah + + * Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. + + * License: GPL 3 or later: + + SiSU, a framework for document structuring, publishing and search + + Copyright (C) Ralph Amissah + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along with + this program. If not, see . + + 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: + + + * Git + + + + * Ralph Amissah + + + + ** Description: system environment, screen colors text + +=end +module SiSU_Screen + class Color + attr_accessor :off,:marker,:bold,:underline,:invert,:darkgrey_hi,:grey_hi,:pink_hi,:fuchsia_hi,:red_hi,:orange_hi,:yellow_hi,:brown_hi,:lightgreen_hi,:green_hi,:cyan_hi,:blue_hi,:navy_hi,:white,:white_bold,:grey,:pink,:fuchsia,:ruby,:red,:orange,:yellow,:brown,:green,:darkgreen,:cyan,:blue,:navy,:black + def initialize(&block) + instance_eval &block + end + end + class Ansi < Color + attr_reader :cX + def initialize(color_state,*txt) + @color_state,@txt=color_state,txt + @color_instruct=txt[0] + @cX=@@cX=if color_state==:on + Color.new do + self.off=self.white=self.white_bold=self.marker=self.bold=self.underline=self.invert=self.darkgrey_hi=self.grey_hi=self.pink_hi=self.fuchsia_hi=self.red_hi=self.orange_hi=self.yellow_hi=self.brown_hi=self.lightgreen_hi=self.green_hi=self.cyan_hi=self.blue_hi=self.navy_hi=self.grey=self.pink=self.fuchsia=self.ruby=self.red=self.orange=self.yellow=self.brown=self.green=self.darkgreen=self.cyan=self.blue=self.navy=self.black='' + end + else #default set to colors on + Color.new do + self.off = "\033[0m" + self.white = "\033[37m" + self.white_bold = "\033[1m" + self.marker = "\033[42m" + self.bold = "\033[1m" + self.underline = "\033[4m" + self.invert = "\033[7m" + self.darkgrey_hi = "\033[100m" + self.grey_hi = "\033[47m" + self.pink_hi = "\033[105m" + self.fuchsia_hi = "\033[45m" + self.red_hi = "\033[41m" + self.orange_hi = "\033[101m" + self.yellow_hi = "\033[103m" + self.brown_hi = "\033[43m" + self.lightgreen_hi = "\033[102m" + self.green_hi = "\033[42m" + self.cyan_hi = "\033[106m" + self.blue_hi = "\033[104m" + self.navy_hi = "\033[44m" + self.grey = "\033[90m" + self.pink = "\033[95m" + self.fuchsia = "\033[35m" + self.ruby = "\033[31m" + self.red = "\033[91m" #check + self.orange = "\033[91m" + self.yellow = "\033[93m" + self.brown = "\033[33m" + self.green = "\033[92m" + self.darkgreen = "\033[32m" + self.cyan = "\033[36m" + self.blue = "\033[94m" + self.navy = "\033[34m" + self.black = "\033[30m" + end + end + end + def colors + 0.upto(109) {|i| print "\033[#{i}m 33[#{i}m \033[m"} + puts '' + end + def color + case @color_instruct + when /invert/ then @cX.invert + when /darkgrey_hi/ then @cX.darkgrey_hi + when /grey_hi/ then @cX.grey_hi + when /pink_hi/ then @cX.pink_hi + when /fuchsia_hi/ then @cX.fuchsia_hi + when /red_hi/ then @cX.red_hi + when /orange_hi/ then @cX.orange_hi + when /yellow_hi/ then @cX.yellow_hi + when /brown_hi/ then @cX.brown_hi + when /lightgreen_hi/ then @cX.lightgreen_hi + when /green_hi/ then @cX.green_hi + when /cyan_hi/ then @cX.cyan_hi + when /blue_hi/ then @cX.blue_hi + when /navy_hi/ then @cX.navy_hi + when /white/ then @cX.white + when /grey/ then @cX.grey + when /pink/ then @cX.pink + when /fuchsia/ then @cX.fuchsia + when /ruby/ then @cX.ruby + when /red/ then @cX.red + when /orange/ then @cX.orange + when /yellow/ then @cX.yellow + when /brown/ then @cX.brown + when /green/ then @cX.green + when /darkgreen/ then @cX.darkgreen + when /cyan/ then @cX.cyan + when /blue/ then @cX.blue + when /navy/ then @cX.navy + when /close/ then @cX.off + when /off/ then @cX.off + end + end + def colorize + case @color_instruct + when /invert/ then puts "#{@cX.invert}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}" + when /darkgrey_hi/ then puts "#{@cX.darkgrey_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}" + when /grey_hi/ then puts "#{@cX.grey_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}" + when /pink_hi/ then puts "#{@cX.pink_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}" + when /fuchsia_hi/ then puts "#{@cX.fuchsia_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}" + when /red_hi/ then puts "#{@cX.red_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}" + when /orange_hi/ then puts "#{@cX.orange_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}" + when /yellow_hi/ then puts "#{@cX.yellow_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}" + when /brown_hi/ then puts "#{@cX.brown_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}" + when /lightgreen_hi/ then puts "#{@cX.lightgreen_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}" + when /green_hi/ then puts "#{@cX.green_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}" + when /cyan_hi/ then puts "#{@cX.cyan_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}" + when /blue_hi/ then puts "#{@cX.blue_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}" + when /navy_hi/ then puts "#{@cX.navy_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}" + when /bold/ then puts "#{@cX.bold}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" + when /white/ then puts "#{@cX.off}#{@txt[1]} #{@txt[2]}" + when /grey/ then puts "#{@cX.grey}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" + when /pink/ then puts "#{@cX.pink}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" + when /fuchsia/ then puts "#{@cX.fuchsia}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" + when /ruby/ then puts "#{@cX.ruby}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" + when /red/ then puts "#{@cX.red}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" + when /orange/ then puts "#{@cX.orange}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" + when /yellow/ then puts "#{@cX.yellow}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" + when /brown/ then puts "#{@cX.brown}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" + when /green/ then puts "#{@cX.green}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" + when /darkgreen/ then puts "#{@cX.darkgreen}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" + when /cyan/ then puts "#{@cX.cyan}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" + when /blue/ then puts "#{@cX.blue}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" + when /navy/ then puts "#{@cX.navy}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" + end + end + def sourcename(sourcefilename) + @sourcefilename=sourcefilename + end + def basename(sourcefilename) + @basename=sourcefilename.sub(/\.(?:(?:-|ssm\.)?sst|ssm)$/,'') + end + def sisu + end + def rescue + STDERR.puts %{\t #{@cX.orange}Rescued#{@cX.off} #{@cX.grey}#{yield if block_given?}\n\t An#{@cX.off} #{@cX.fuchsia}ERROR#{@cX.off} #{@cX.grey}occurred, message:#{@cX.off} #{@cX.fuchsia}#{@txt[0]}#{@cX.off} #{@cX.grey}#{@txt[1]}#{@cX.off} #{@cX.brown}#{@txt[2]}#{@cX.off}} + end + def warn + STDERR.puts "\t #{@cX.brown}#{@txt[0]}#{@cX.off} #{@cX.grey}#{@txt[1]}#{@cX.off}" + end + def error + STDERR.puts "\t #{@cX.fuchsia}#{@txt[0]}#{@cX.off} #{@cX.brown}#{@txt[1]}#{@cX.off}" + end + def error2 + STDERR.puts "\t #{@cX.grey}#{@txt[0]}#{@cX.off} #{@cX.fuchsia}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" + end + def version + puts "#{@cX.blue_hi}#{@txt[0]} #{@txt[1]}#{@cX.off} #{@cX.grey} (#{@txt[3]} [#{@txt[2]}])#{@txt[4]} &#{@cX.off} #{@cX.ruby}Ruby#{@cX.off} #{@cX.grey}(#{@txt[5]})#{@cX.off}\n" + end + def html3numbers + puts %{\t#{@cX.green}#{@txt[0]}#{@cX.off} #{@cX.cyan}files processed#{@cX.off}. } + + %{#{@cX.grey}} + + %{scroll only: #{@txt[1]}, seg only: #{@txt[2]},} + + %{#{@cX.off} } + + %{#{@cX.cyan}joint scroll & seg: #{@txt[3]},#{@cX.off}} + + %{#{@cX.grey} } + + %{nav only: #{@txt[4]}} + + %{#{@cX.off}} + end + def html2numbers + puts %{\t#{@cX.green}#{@txt[0]}#{@cX.off} #{@cX.cyan}files processed#{@cX.off}. } + + %{#{@cX.grey}} + + %{scroll only: #{@txt[1]},} + + %{#{@cX.off} } + + %{#{@cX.cyan}seg only: #{@txt[2]},#{@cX.off}} + + %{#{@cX.grey} } + + %{joint scroll & seg: #{@txt[3]}, nav only: #{@n_files_nav}} + + %{#{@cX.off}} + end + def html1numbers + puts %{\t#{@cX.green}#{@txt[0]}#{@cX.off} #{@cX.cyan}files processed#{@cX.off}. } + + %{#{@cX.cyan}scroll only: #{@txt[1]},#{@cX.off}} + + %{#{@cX.grey} } + + %{seg only: #{@txt[2]}, } + + %{joint scroll & seg: #{@txt[3]}, nav only: #{@n_files_nav}} + + %{#{@cX.off}} + end + def html0_numbers + puts %{\t#{@cX.ruby}#{@txt[0]} files processed#{@cX.off}. } + + %{#{@cX.grey}} + + %{scroll only: #{@txt[1]}, seg only: #{@txt[2]}, joint scroll & seg: #{@txt[3]},} + + %{#{@cX.off} } + + %{#{@cX.cyan}nav only: #{@txt[4]}#{@cX.off}.} + end + def grey + puts "#{@cX.grey}#{@txt[0]}#{@cX.off} #{@cX.cyan}#{@txt[1]}#{@cX.off}" + end + def txt_white + puts "\t#{@cX.white}#{@txt[0]}#{@cX.off} #{@cX.white}#{@txt[1]}#{@cX.off}" + end + def txt_grey + puts "\t#{@cX.grey}#{@txt[0]}#{@cX.off} #{@cX.cyan}#{@txt[1]}#{@cX.off}" + end + def txt_cyan + puts "\t#{@cX.cyan}#{@txt[0]}#{@cX.off} #{@cX.grey}#{@txt[1]}#{@cX.off}" + end + def txt_blue + puts "\t#{@cX.blue}#{@txt[0]}#{@cX.off} #{@cX.grey}#{@txt[1]}#{@cX.off}" + end + def txt_red + puts "\t#{@cX.red}#{@txt[0]}#{@cX.off} #{@cX.cyan}#{@txt[1]}#{@cX.off}" + end + def txt_green + puts "\t#{@cX.green}#{@txt[0]}#{@cX.off} #{@cX.grey}#{@txt[1]}#{@cX.off}" + end + def url #clean + blue + end + def result + puts "\t#{@cX.green}#{@txt[0]}#{@cX.off} #{@cX.blue}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" + end + def maintenance + puts "\t#{@cX.grey}#{@txt[0]}#{@cX.off} #{@cX.brown}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}" + end + def instruct + puts %{\t #{@cX.grey}#{@txt[0]}#{@cX.off} #{@cX.cyan}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off} #{@cX.cyan}#{@txt[3]}#{@cX.off} #{@cX.grey}#{@txt[4]}#{@cX.off} "#{@cX.brown}#{@f}#{@cX.off}"} + end + def grey_open + print @cX.grey + end + def p_off + print @cX.off + end + def p_close + print @cX.off + end + def flow + puts %{\t#{@cX.grey}#{@txt[0]}#{@cX.off} #{@cX.ruby}->#{@cX.off}\n\t #{@cX.blue}#{@txt[1]}#{@cX.off}} + end + def output + puts %{\t#{@cX.grey}#{@txt[0]}#{@cX.off} #{@cX.ruby}->#{@cX.off}\n\t #{@cX.blue}#{@txt[1]}#{@cX.off}} + end + def generic + puts %{\t#{@cX.navy}#{@txt[0]} #{@txt[1]}#{@cX.off}. } + end + def files_processed + puts %{\t#{@cX.green}#{@txt[0]}#{@cX.off} #{@cX.grey}#{@txt[1]}#{@cX.off}} + end + def print_blue + print "#{@cX.blue}#{@txt[0]} #{@txt[1]}#{@cX.off}" + end + def puts_blue + puts "#{@cX.blue}#{@txt[0]} #{@txt[1]}#{@cX.off}" + end + def print_brown + print "#{@cX.brown}#{@txt[0]}#{@cX.off}" + end + def blue_tab + print "\t#{@cX.blue}#{@txt[0]}#{@cX.off}\n" + end + def print_grey + print "#{@cX.grey}#{@txt[0]} #{@txt[1]}#{@cX.off}" + end + def puts_grey + puts "#{@cX.grey}#{@txt[0]} #{@txt[1]}#{@cX.off}" + end + def puts_brown + puts "#{@cX.brown}#{@txt[0]} #{@txt[1]}#{@cX.off}" + end + def grey_tab + print "\t#{@cX.grey}#{@txt[0]}#{@cX.off}\n" + end + def green_title + puts %{#{@cX.green}#{@txt[0]}#{@cX.off} #{@cX.grey}#{@txt[1]}#{@cX.off}} + end + def green_title_hi + puts %{#{@cX.green_hi}#{@cX.black}#{@txt[0]}#{@cX.off*2} #{@cX.grey}#{@txt[1]}#{@cX.off}} + end + def green_hi_blue + puts %{#{@cX.green_hi}#{@cX.black}#{@txt[0]}#{@cX.off*2} #{@cX.blue}#{@txt[1]}#{@cX.off}} + end + def blue_title_hi + puts %{#{@cX.blue_hi}#{@txt[0]}#{@cX.off*2} #{@cX.blue}#{@txt[1]}#{@cX.off}} + end + def grey_title_hi + puts %{#{@cX.grey_hi}#{@cX.black}#{@txt[0]}#{@cX.off*2} #{@cX.blue}#{@txt[1]}#{@cX.off}} + end + def grey_title_grey_blue + puts %{#{@cX.grey_hi}#{@cX.black}#{@txt[0]}#{@cX.off*2} #{@cX.grey}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off}} + end + def dark_grey_title_hi + puts %{#{@cX.darkgrey_hi}#{@cX.black}#{@txt[0]}#{@cX.off*2} #{@cX.blue}#{@txt[1]}#{@cX.off}} + end + def cyan_title_hi + puts %{#{@cX.cyan_hi}#{@cX.black}#{@txt[0]}#{@cX.off*2} #{@cX.blue}#{@txt[1]}#{@cX.off}} + end + def cyan_hi_blue + puts %{#{@cX.cyan_hi}#{@cX.black}#{@txt[0]}#{@cX.off*2} #{@cX.blue}#{@txt[1]}#{@cX.off}} + end + def dbi_title + puts %{#{@cX.blue_hi}#{@cX.black}#{@txt[0]}#{@cX.off*2} #{@cX.cyan}#{@cX.grey}#{@txt[1]}#{@cX.off*2} #{@cX.green}#{@txt[2]}#{@cX.off}} + end + def yellow_title_hi + puts %{#{@cX.yellow_hi}#{@cX.black}#{@txt[0]}#{@cX.off*2} #{@cX.blue}#{@txt[1]}#{@cX.off}} + end + def term_sheet_title + puts %{\t#{@cX.green}#{@txt[0]}#{@cX.off} #{@cX.red_hi}#{@cX.black}#{@txt[1]}.#{@cX.off*2} } + end + def generic_number + puts "#{@cX.green}#{@txt[0]}#{@cX.off} #{@cX.grey}#{@txt[1]}#{@cX.off}" + end + def tex_numbers + puts %{ #{@cX.green}#{@txt[0]}#{@cX.off} #{@cX.cyan}tex/pdf files processed#{@cX.off}.} + end + def tex_info_numbers + puts %{ #{@cX.green}#{@txt[0]}#{@cX.off} #{@cX.cyan}texinfo files processed#{@cX.off}.} + end + def lout_numbers + puts %{ #{@cX.green}#{@n_lout}#{@cX.off} #{@cX.cyan}lout/pdf files processed#{@cX.off}.} + end + def parameters + end + def reserved + puts %{ #{@cX.grey_hi}#{@cX.black}reserved#{@cX.off*2}} + end + def meta_verse_title + puts %{#{@cX.green_hi}#{@cX.black}MetaVerse#{@cX.off*2} } + end + def meta_verse_title_v + b=sourcename(@txt[0]) + puts %{#{@cX.green_hi}#{@cX.black}MetaVerse#{@cX.off*2} } + + %{#{@cX.grey}#{@txt[0]}#{@cX.off} #{@cX.ruby}->#{@cX.off}\n\t #{@cX.blue}~meta/#{b}.meta#{@cX.off}} + end + def meta_verse + puts "\t#{@cX.grey}MetaVerse#{@cX.off}" + end + def meta_verse_skipped + puts %{\t#{@cX.grey}MetaVerse: MarshalLoad (creation of metaVerse skipped)#{@cX.off}} + end + def meta_verse_load + puts %{\t<>} + end + def html_title + puts %{#{@cX.green_hi}#{@cX.black}HTML#{@cX.off*2}} + end + def html_output + puts %{\t#{@cX.grey}#{@txt[0]}#{@cX.off} #{@cX.ruby}->#{@cX.off}\n\t #{@cX.blue}#{@txt[1]}#{@cX.off}} + end + def segmented + puts "\t#{@cX.grey}Seg#{@cX.off} #{@cX.green}#{@txt[0]}#{@cX.off} #{@cX.grey}segments#{@cX.off}" + end + end +end +__END__ + Color.new do + self.off = "\033[0m" + self.white = "\033[37m" + self.white_bold = "\033[1m" + self.marker = "\033[42m" + self.bold = "\033[1m" + self.underline = "\033[4m" + self.invert = "\033[7m" + self.darkgrey_hi = "\033[100m" + self.grey_hi = "\033[47m" + self.pink_hi = "\033[105m" + self.fuchsia_hi = "\033[45m" + self.red_hi = "\033[41m" + self.orange_hi = "\033[101m" + self.yellow_hi = "\033[103m" + self.brown_hi = "\033[43m" + self.lightgreen_hi = "\033[102m" + self.green_hi = "\033[42m" + self.cyan_hi = "\033[106m" + self.blue_hi = "\033[104m" + self.navy_hi = "\033[44m" + self.grey = "\033[90m" + self.pink = "\033[95m" + self.fuchsia = "\033[35m" + self.ruby = "\033[31m" + self.red = "\033[91m" #check + self.orange = "\033[91m" + self.yellow = "\033[93m" + self.brown = "\033[33m" + self.green = "\033[92m" + self.darkgreen = "\033[32m" + self.cyan = "\033[36m" + self.blue = "\033[94m" + self.navy = "\033[34m" + self.black = "\033[30m" + end +# fewer colors + Color.new do + self.off = "\033[0m" + self.white = "\033[0m" + self.marker = "\033[42m" + self.bold = "\033[1m" + self.underline = "\033[4m" + self.invert = "\033[7m" + self.darkgrey_hi = "\033[100m" + self.grey_hi = "\033[47m" + self.pink_hi = "\033[105m" + self.fuchsia_hi = "\033[45m" + self.red_hi = "\033[41m" + self.orange_hi = "\033[101m" + self.yellow_hi = "\033[103m" + self.brown_hi = "\033[43m" + self.lightgreen_hi = "\033[102m" + self.green_hi = "\033[42m" + self.cyan_hi = "\033[106m" + self.blue_hi = "\033[104m" + self.navy_hi = "\033[44m" + self.grey = "\033[90m" + self.pink = "\033[95m" + self.fuchsia = "\033[35m" + self.ruby = "\033[31m" + self.red = "\033[31m" #check + self.orange = "\033[91m" + self.yellow = "\033[33m" + self.brown = "\033[33m" + self.green = "\033[32m" + self.darkgreen = "\033[32m" + self.cyan = "\033[36m" + self.blue = "\033[34m" + self.navy = "\033[34m" + self.black = "\033[30m" + end diff --git a/lib/sisu/v6/utils_spell.rb b/lib/sisu/v6/utils_spell.rb new file mode 100644 index 00000000..512280cc --- /dev/null +++ b/lib/sisu/v6/utils_spell.rb @@ -0,0 +1,105 @@ +# encoding: utf-8 +=begin + + * Name: SiSU + + * Description: a framework for document structuring, publishing and search + + * Author: Ralph Amissah + + * Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Ralph Amissah, + All Rights Reserved. + + * License: GPL 3 or later: + + SiSU, a framework for document structuring, publishing and search + + Copyright (C) Ralph Amissah + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along with + this program. If not, see . + + 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: + + + * Git + + + + * Ralph Amissah + + + + ** Description: spellchecking + +=end +module SiSU_SpellUtility + class Spell + def initialize(input,filesrc,flg) + @flg=flg + @filename, @filetype = /(.+?)(\.\w\w\w0$)/.match(filesrc)[1,2] #.gsub(/\.\w\w\w0$/, "") + @input=input + @allwords=[] + puts @filename + @speller='aspell' # 'ispell' + @dictionary='british' + @lang='en_GB' + end + def check + @input.each do |data| + data=data.gsub(/(https?|www|ftp|gopher|png|jpg|gif|html|htm)\S+/i,' '). + gsub(/( |#{Mx[:nbsp]})/i,' '). + gsub(/<\/?(table|tr|td|b|p|href).*?>/i,' '). + gsub(/(<==.+|<:\S+>||^@\S+?:.+|\{\{\{|~)/,' '). + gsub(/(["|<>)(\n'`.;&_-]|\=)/,' '). + gsub(/\b(altExternal| + target|externalimg| + srcimagebext| + img|src|toc|pdf| + cd|org| + helvetica|roman + )\b/i,' '). + gsub(/EOF/,'') + @words=data.scan(/\S+/) + @words.each { |y| @allwords << y } + end + @allwords=@allwords.uniq + if @flg =~ /S/ + File.open('/home/ralph/spell_error','a+') do |file| #fix + file.puts %{\n\n<<#{@filename}>>} + end + @allwords.each { |y| puts y.inspect; system(%{cat #{y} | /usr/bin/#{@speller} -l -d #{@dictionary} >> ~/spell_error })} + else + @allwords.each { |y| sp=%x{echo #{y}|#{@speller} -l }; puts sp unless sp.empty?} + end + end + end +end +__END__ diff --git a/lib/sisu/v6/webrick.rb b/lib/sisu/v6/webrick.rb index 97e6548d..8ebbf2d6 100644 --- a/lib/sisu/v6/webrick.rb +++ b/lib/sisu/v6/webrick.rb @@ -70,7 +70,7 @@ module SiSU_Webserv rescue LoadError SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('time or webrick NOT FOUND (LoadError)') end - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env include SiSU_Screen def initialize @@ -159,7 +159,7 @@ WOK get=Dir.pwd brick(@port,get) rescue - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb SiSU_Errors::Rescued.new($!,$@,'-W',nil).location do #fix __LINE__.to_s + ':' + __FILE__ end diff --git a/lib/sisu/v6/wikispeak.rb b/lib/sisu/v6/wikispeak.rb index a7f00dee..ac8e11a4 100644 --- a/lib/sisu/v6/wikispeak.rb +++ b/lib/sisu/v6/wikispeak.rb @@ -62,7 +62,7 @@ =end module SiSU_Wikispeak require_relative 'ao' # ao.rb - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env include SiSU_Param include SiSU_Viz diff --git a/lib/sisu/v6/xhtml.rb b/lib/sisu/v6/xhtml.rb index dc04e8b2..0f03dc5b 100644 --- a/lib/sisu/v6/xhtml.rb +++ b/lib/sisu/v6/xhtml.rb @@ -63,9 +63,9 @@ module SiSU_XHTML require_relative 'defaults' # defaults.rb include SiSU_Viz - require_relative 'particulars' # particulars.rb + require_relative 'se_hub_particulars' # se_hub_particulars.rb include SiSU_Particulars - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env require_relative 'xml_shared' # xml_shared.rb include SiSU_XML_Munge diff --git a/lib/sisu/v6/xhtml_epub2.rb b/lib/sisu/v6/xhtml_epub2.rb index e978c15d..e086d12e 100644 --- a/lib/sisu/v6/xhtml_epub2.rb +++ b/lib/sisu/v6/xhtml_epub2.rb @@ -66,7 +66,7 @@ module SiSU_XHTML_EPUB2 rescue LoadError SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('pstore NOT FOUND (LoadError)') end - require_relative 'particulars' # particulars.rb + require_relative 'se_hub_particulars' # se_hub_particulars.rb include SiSU_Particulars require_relative 'defaults' # defaults.rb include SiSU_Viz diff --git a/lib/sisu/v6/xhtml_epub2_concordance.rb b/lib/sisu/v6/xhtml_epub2_concordance.rb index 2fb8fb91..8defb75f 100644 --- a/lib/sisu/v6/xhtml_epub2_concordance.rb +++ b/lib/sisu/v6/xhtml_epub2_concordance.rb @@ -62,9 +62,9 @@ =end module SiSU_XHTML_EPUB2_Concordance - require_relative 'particulars' # particulars.rb + require_relative 'se_hub_particulars' # se_hub_particulars.rb include SiSU_Particulars - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env require_relative 'defaults' # defaults.rb include SiSU_Viz @@ -157,7 +157,7 @@ WOK include SiSU_Viz require_relative 'xhtml_epub2_format' # xhtml_epub2_format.rb include SiSU_XHTML_EPUB2_Format - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Screen def initialize(particulars) @particulars=particulars diff --git a/lib/sisu/v6/xhtml_epub2_tune.rb b/lib/sisu/v6/xhtml_epub2_tune.rb index 9222f58b..00d885e7 100644 --- a/lib/sisu/v6/xhtml_epub2_tune.rb +++ b/lib/sisu/v6/xhtml_epub2_tune.rb @@ -60,9 +60,9 @@ ** Description: epub generation, epub pre-processing =end -require_relative 'param' +require_relative 'dp' # dp.rb module SiSU_XHTML_EPUB2_Tune - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env; include SiSU_Screen require_relative 'xhtml_epub2_format' # xhtml_epub2_format.rb #watch @@line_mode='' diff --git a/lib/sisu/v6/xml_docbook5.rb b/lib/sisu/v6/xml_docbook5.rb index c5be78fe..f087ce0e 100644 --- a/lib/sisu/v6/xml_docbook5.rb +++ b/lib/sisu/v6/xml_docbook5.rb @@ -61,10 +61,10 @@ =end module SiSU_XML_Docbook_Book - require_relative 'particulars' # particulars.rb + require_relative 'se_hub_particulars' # se_hub_particulars.rb include SiSU_Particulars require_relative 'ao' # ao.rb - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env require_relative 'txt_shared' # txt_shared.rb include SiSU_TextUtils diff --git a/lib/sisu/v6/xml_dom.rb b/lib/sisu/v6/xml_dom.rb index b92c2d51..7bf34dd4 100644 --- a/lib/sisu/v6/xml_dom.rb +++ b/lib/sisu/v6/xml_dom.rb @@ -63,9 +63,9 @@ module SiSU_XML_DOM require_relative 'defaults' # defaults.rb include SiSU_Viz - require_relative 'particulars' # particulars.rb + require_relative 'se_hub_particulars' # se_hub_particulars.rb include SiSU_Particulars - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env require_relative 'ao' # ao.rb require_relative 'xml_shared' # xml_shared.rb diff --git a/lib/sisu/v6/xml_fictionbook2.rb b/lib/sisu/v6/xml_fictionbook2.rb index 04303145..6898ab16 100644 --- a/lib/sisu/v6/xml_fictionbook2.rb +++ b/lib/sisu/v6/xml_fictionbook2.rb @@ -61,10 +61,10 @@ =end module SiSU_XML_Fictionbook - require_relative 'particulars' # particulars.rb + require_relative 'se_hub_particulars' # se_hub_particulars.rb include SiSU_Particulars require_relative 'ao' # ao.rb - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env require_relative 'txt_shared' # txt_shared.rb include SiSU_TextUtils diff --git a/lib/sisu/v6/xml_format.rb b/lib/sisu/v6/xml_format.rb index d310d0ca..70c1a27f 100644 --- a/lib/sisu/v6/xml_format.rb +++ b/lib/sisu/v6/xml_format.rb @@ -62,7 +62,7 @@ =end module SiSU_XML_Format - require_relative 'param' # param.rb + require_relative 'dp' # dp.rb include SiSU_Param include SiSU_Viz class ParagraphNumber diff --git a/lib/sisu/v6/xml_md_oai_pmh_dc.rb b/lib/sisu/v6/xml_md_oai_pmh_dc.rb index f3a6fae7..96dd6749 100644 --- a/lib/sisu/v6/xml_md_oai_pmh_dc.rb +++ b/lib/sisu/v6/xml_md_oai_pmh_dc.rb @@ -61,9 +61,9 @@ =end module SiSU_XML_Metadata - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env - require_relative 'param' # param.rb + require_relative 'dp' # dp.rb include SiSU_Param class OAI_PMH def initialize(opt) diff --git a/lib/sisu/v6/xml_odf_odt.rb b/lib/sisu/v6/xml_odf_odt.rb index 224de6da..ff6de3a7 100644 --- a/lib/sisu/v6/xml_odf_odt.rb +++ b/lib/sisu/v6/xml_odf_odt.rb @@ -61,10 +61,10 @@ =end module SiSU_XML_ODF_ODT - require_relative 'particulars' # particulars.rb + require_relative 'se_hub_particulars' # se_hub_particulars.rb include SiSU_Particulars require_relative 'ao' # ao.rb - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env include SiSU_Viz require_relative 'xml_odf_odt_format' # xml_odf_odt_format.rb diff --git a/lib/sisu/v6/xml_odf_odt_format.rb b/lib/sisu/v6/xml_odf_odt_format.rb index b2539dfd..68457d00 100644 --- a/lib/sisu/v6/xml_odf_odt_format.rb +++ b/lib/sisu/v6/xml_odf_odt_format.rb @@ -61,7 +61,7 @@ =end module SiSU_XML_ODF_ODT_Format - require_relative 'param' # param.rb + require_relative 'dp' # dp.rb include SiSU_Param include SiSU_Viz class ParagraphNumber diff --git a/lib/sisu/v6/xml_sax.rb b/lib/sisu/v6/xml_sax.rb index 68932463..a99714fb 100644 --- a/lib/sisu/v6/xml_sax.rb +++ b/lib/sisu/v6/xml_sax.rb @@ -63,9 +63,9 @@ module SiSU_XML_SAX require_relative 'defaults' # defaults.rb include SiSU_Viz - require_relative 'particulars' # particulars.rb + require_relative 'se_hub_particulars' # se_hub_particulars.rb include SiSU_Particulars - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env require_relative 'xml_shared' # xml_shared.rb include SiSU_XML_Munge diff --git a/lib/sisu/v6/xml_scaffold_structure_collapsed.rb b/lib/sisu/v6/xml_scaffold_structure_collapsed.rb index 9fece3bf..de2487aa 100644 --- a/lib/sisu/v6/xml_scaffold_structure_collapsed.rb +++ b/lib/sisu/v6/xml_scaffold_structure_collapsed.rb @@ -61,10 +61,10 @@ =end module SiSU_XML_Scaffold_Structure_Collapse - require_relative 'particulars' # particulars.rb + require_relative 'se_hub_particulars' # se_hub_particulars.rb include SiSU_Particulars require_relative 'ao' # ao.rb - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env class Source def initialize(opt) diff --git a/lib/sisu/v6/xml_scaffold_structure_sisu.rb b/lib/sisu/v6/xml_scaffold_structure_sisu.rb index a21f8347..37add440 100644 --- a/lib/sisu/v6/xml_scaffold_structure_sisu.rb +++ b/lib/sisu/v6/xml_scaffold_structure_sisu.rb @@ -61,10 +61,10 @@ =end module SiSU_XML_Scaffold_Structure_Sisu - require_relative 'particulars' # particulars.rb + require_relative 'se_hub_particulars' # se_hub_particulars.rb include SiSU_Particulars require_relative 'ao' # ao.rb - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env class Source def initialize(opt) diff --git a/lib/sisu/v6/xml_shared.rb b/lib/sisu/v6/xml_shared.rb index 38c21802..35d1132d 100644 --- a/lib/sisu/v6/xml_shared.rb +++ b/lib/sisu/v6/xml_shared.rb @@ -567,7 +567,7 @@ module SiSU_XML_Munge end end module SiSU_XML_Tags #Format - require_relative 'param' # param.rb + require_relative 'dp' # dp.rb include SiSU_Param include SiSU_Viz class RDF diff --git a/lib/sisu/v6/zap.rb b/lib/sisu/v6/zap.rb index 5e30842c..829056b5 100644 --- a/lib/sisu/v6/zap.rb +++ b/lib/sisu/v6/zap.rb @@ -61,7 +61,7 @@ =end module SiSU_Zap - require_relative 'sysenv' # sysenv.rb + require_relative 'se' # se.rb include SiSU_Env class Source def initialize(opt) -- cgit v1.2.3