From 1d40176070feb0f19b5aa69f670d6f5bd66695ed Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Wed, 29 Aug 2012 21:26:18 -0400 Subject: v3: constants, year static (current): YEAR=2012 --- lib/sisu/v3/constants.rb | 1 + lib/sisu/v3/sysenv.rb | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v3/constants.rb b/lib/sisu/v3/constants.rb index 2921b670..a4de5898 100644 --- a/lib/sisu/v3/constants.rb +++ b/lib/sisu/v3/constants.rb @@ -57,6 +57,7 @@ =end #Ax,Xx,Mx,Rx,Hx,Dx,Px,Ep,Db,Gt,Tex=Array.new(11){{}} +YEAR='2012' Sfx={ txt: '.txt', html: '.html', xhtml: '.xhtml', xml: '.xml', epub: '.epub', epub_xhtml: '.xhtml', odt: '.odt', pdf: '.pdf'} Ax={ tab: "\t", diff --git a/lib/sisu/v3/sysenv.rb b/lib/sisu/v3/sysenv.rb index 23326b40..22b60a6d 100644 --- a/lib/sisu/v3/sysenv.rb +++ b/lib/sisu/v3/sysenv.rb @@ -87,7 +87,7 @@ module SiSU_Env @t.month end def year_static - '2012' + YEAR end end class InfoSystem @@ -781,7 +781,7 @@ module SiSU_Env @texpdf end def latex2pdf(md,papersize='a4') #convert from latex to pdf - tell=if @cmd =~/[MV]/ + tell=if @cmd =~/[MV]/ '' elsif @cmd =~/[v]/ %q{2>&1 | grep -v ' WARNING '} -- cgit v1.2.3 From 8f9076f374c6b4e67db9a6c28c3d44b3ede5679e Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Wed, 29 Aug 2012 21:27:59 -0400 Subject: v3: sisu -v, provide version information, fix --- lib/sisu/v3/hub.rb | 6 ++---- lib/sisu/v3/options.rb | 6 ++++++ 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v3/hub.rb b/lib/sisu/v3/hub.rb index c4eed640..6fa69753 100644 --- a/lib/sisu/v3/hub.rb +++ b/lib/sisu/v3/hub.rb @@ -501,10 +501,8 @@ p "#{__LINE__}:#{__FILE__}" if @opt.act[:maintenance][:set] ==:on def do_initialization @cX=SiSU_Screen::Ansi.new(@opt.cmd).cX flag=SiSU_Env::InfoProcessingFlag.new - if @opt.cmd =~/[vVM]/ #% version information - unless @opt.files.empty? - SiSU_Help::Help.new('env',@opt).sisu_version - end + if @opt.act[:version_info][:set]==:on #% version information + SiSU_Help::Help.new('env',@opt).sisu_version end if @opt.act[:license][:set]==:on #% license information SiSU_Help::Help.new('license',@opt).help_request diff --git a/lib/sisu/v3/options.rb b/lib/sisu/v3/options.rb index 7aa3622d..5871d8db 100644 --- a/lib/sisu/v3/options.rb +++ b/lib/sisu/v3/options.rb @@ -509,6 +509,12 @@ module SiSU_Commandline { bool: false, set: :off } else { bool: true, set: :na } #fix default color end + act[:version_info]=if cmd =~/[vVM]/ \ + || mod.inspect =~/"--verbose"|"--maintenance"/ + { bool: true, set: :on } + else + { bool: false, set: :na } + end # act[:color_toggle]=if cmd =~/c/ \ # or mod.inspect =~/"--color-toggle"/ # true -- cgit v1.2.3 From b4694609f708d52b7dbd88dfab53f3178451ad27 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Wed, 29 Aug 2012 21:30:02 -0400 Subject: v3: bin/sisu, hub, reorganize call --- lib/sisu/v3/hub.rb | 58 ++++++++++++++++++++++++++---------------------------- 1 file changed, 28 insertions(+), 30 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v3/hub.rb b/lib/sisu/v3/hub.rb index 6fa69753..ac103830 100644 --- a/lib/sisu/v3/hub.rb +++ b/lib/sisu/v3/hub.rb @@ -59,8 +59,33 @@ module SiSU require_relative 'constants' # constants.rb require_relative 'sysenv' # sysenv.rb + include SiSU_Env include SiSU_Screen - @@pwd_the=Dir.pwd + require_relative 'options' # options.rb + require_relative 'param' # param.rb + include SiSU_Param + require_relative 'defaults' # defaults.rb + include SiSU_Viz + require_relative 'help' # help.rb + include SiSU_Help + require 'uri' + class HubMaster + def initialize(argv) + pwd_the=Dir.pwd + begin #% select what to do + home=ENV['HOME'] + opt=SiSU_Commandline::Options.new(argv) + SiSU::Processing.new(opt).actions + rescue + cmd=(opt ? opt.cmd : '') + SiSU_Screen::Ansi.new(cmd,$!,$@).rescue do + __LINE__.to_s + ':' + __FILE__ + end + ensure + Dir.chdir(pwd_the) + end + end + end class OptionLoopFiles def initialize(opt) @opt=opt @@ -229,10 +254,11 @@ p "#{__LINE__}:#{__FILE__}" if @opt.act[:maintenance][:set] ==:on class Processing require 'fileutils' include FileUtils - @@env=SiSU_Env::InfoEnv.new + @@env=nil attr_accessor :op def initialize(opt) @opt=opt + @@env=SiSU_Env::InfoEnv.new @msg,@msgs='',nil @tell=lambda { SiSU_Screen::Ansi.new(@opt.cmd,@msg,"#{@msgs.inspect if @msgs}") } end @@ -690,33 +716,5 @@ p "#{__LINE__}:#{__FILE__}" if @opt.act[:maintenance][:set] ==:on end end end - begin #% select what to do - if RUBY_VERSION < '1.9' - require 'jcode' - $KCODE='UTF8' - end - require_relative 'constants' # constants.rb - require_relative 'options' # options.rb - require_relative 'sysenv' # sysenv.rb - include SiSU_Env; include SiSU_Screen - require_relative 'param' # param.rb - include SiSU_Param - require_relative 'defaults' # defaults.rb - include SiSU_Viz - require_relative 'help' # help.rb - include SiSU_Help - require 'uri' - home=ENV['HOME'] - argv=$* - @opt=SiSU_Commandline::Options.new(argv) - SiSU::Processing.new(@opt).actions - rescue - cmd=(@opt ? @opt.cmd : '') - SiSU_Screen::Ansi.new(cmd,$!,$@).rescue do - __LINE__.to_s + ':' + __FILE__ - end - ensure - Dir.chdir(@@pwd_the) - end end __END__ -- cgit v1.2.3 From 662cd26d73ba8307144c35369a398bb274f980e1 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Wed, 29 Aug 2012 21:31:57 -0400 Subject: v3: some pre-unicode meddling sorted * covers bug reported as middle dot changed to asterisk by chals --- lib/sisu/v3/character_encoding.rb | 378 ------------------------------------- lib/sisu/v3/dal_character_check.rb | 6 +- lib/sisu/v3/hub.rb | 4 - 3 files changed, 3 insertions(+), 385 deletions(-) delete mode 100644 lib/sisu/v3/character_encoding.rb (limited to 'lib') diff --git a/lib/sisu/v3/character_encoding.rb b/lib/sisu/v3/character_encoding.rb deleted file mode 100644 index 17bf336b..00000000 --- a/lib/sisu/v3/character_encoding.rb +++ /dev/null @@ -1,378 +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 Ralph Amissah, All Rights Reserved. - - * License: GPL 3 or later: - - SiSU, a framework for document structuring, publishing and search - - Copyright (C) Ralph Amissah - - This program is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the Free - Software Foundation, either version 3 of the License, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - more details. - - You should have received a copy of the GNU General Public License along with - this program. If not, see . - - If you have Internet connection, the latest version of the GPL should be - available at these locations: - - - - - - * SiSU uses: - * Standard SiSU markup syntax, - * Standard SiSU meta-markup syntax, and the - * Standard SiSU object citation numbering and system - - * Hompages: - - - - * Download: - - - * Ralph Amissah - - - - ** Description: modules related to locales, character encoding for different - output generators [requires kirbybase] - -=end -module SiSU_CharacterEncode - require 'kirbybase' - require_relative 'sysenv' # sysenv.rb - class Characters - attr_accessor(:character_encoding,:glyph,:dec,:hex,:rb,:html,:html_name,:tex,:tex_licr,:tex_alt,:name) - def initialize(&block) - instance_eval(&block) - end - end - class Create ', 62, '76', '\76', '>', '>', '', '', '', 'Greater than >' ], - ['?', 63, '77', '\77', '?', nil, '?', '?', '?', 'Punctuation Question mark ?' ], - ['@', 64, '100', '\100', '@', nil, '', '', '', 'Commercial at sign @' ], - ['A', 65, '101', '\101', 'A', nil, 'A', 'A', 'A', 'Captial A' ], - ['B', 66, '102', '\102', 'B', nil, 'B', 'B', 'B', 'Captial B' ], - ['C', 67, '103', '\103', 'C', nil, 'C', 'C', 'C', 'Captial C' ], - ['D', 68, '104', '\104', 'D', nil, 'D', 'D', 'D', 'Captial D' ], - ['E', 69, '105', '\105', 'E', nil, 'E', 'E', 'E', 'Captial E' ], - ['F', 70, '106', '\106', 'F', nil, 'F', 'F', 'F', 'Captial F' ], - ['G', 71, '107', '\107', 'G', nil, 'G', 'G', 'G', 'Captial G' ], - ['H', 72, '110', '\110', 'H', nil, 'H', 'H', 'H', 'Captial H' ], - ['I', 73, '111', '\111', 'I', nil, 'I', 'I', 'I', 'Captial I' ], - ['J', 74, '112', '\112', 'J', nil, 'J', 'J', 'J', 'Captial J' ], - ['K', 75, '113', '\113', 'K', nil, 'K', 'K', 'K', 'Captial K' ], - ['L', 76, '114', '\114', 'L', nil, 'L', 'L', 'L', 'Captial L' ], - ['M', 77, '115', '\115', 'M', nil, 'M', 'M', 'M', 'Captial M' ], - ['N', 78, '116', '\116', 'N', nil, 'N', 'N', 'N', 'Captial N' ], - ['O', 79, '117', '\117', 'O', nil, 'O', 'O', 'O', 'Captial O' ], - ['P', 80, '120', '\120', 'P', nil, 'P', 'P', 'P', 'Captial P' ], - ['Q', 81, '121', '\121', 'Q', nil, 'Q', 'Q', 'Q', 'Captial Q' ], - ['R', 82, '122', '\122', 'R', nil, 'R', 'R', 'R', 'Captial R' ], - ['S', 83, '123', '\123', 'S', nil, 'S', 'S', 'S', 'Captial S' ], - ['T', 84, '124', '\124', 'T', nil, 'T', 'T', 'T', 'Captial T' ], - ['U', 85, '125', '\125', 'U', nil, 'U', 'U', 'U', 'Captial U' ], - ['V', 86, '126', '\126', 'V', nil, 'V', 'V', 'V', 'Captial V' ], - ['W', 87, '127', '\127', 'W', nil, 'W', 'W', 'W', 'Captial W' ], - ['X', 88, '130', '\130', 'X', nil, 'X', 'X', 'X', 'Captial X' ], - ['Y', 89, '131', '\131', 'Y', nil, 'Y', 'Y', 'Y', 'Captial Y' ], - ['Z', 90, '132', '\132', 'Z', nil, 'Z', 'Z', 'Z', 'Captial Z' ], - ['[', 91, '133', '\133', '[', nil, '', '', '', 'Left square bracket [' ], - ['\\', 92, '134', '\134', '\', nil, '', '\textbackslash', '', 'Backslash \\'], - [']', 93, '135', '\135', ']', nil, '', '', '', 'Right square bracket ]' ], - ['^', 94, '136', '\136', '^', nil, '', '', '', 'Caret ^' ], - ['_', 95, '137', '\137', '_', nil, '{\_}', '\textunderscore', '', 'Underscore _' ], - ['`', 96, '140', '\140', '`', nil, '', '', '', 'Grave accent `' ], - ['a', 97, '141', '\141', 'a', nil, 'a', 'a', 'a', 'Small a' ], - ['b', 98, '142', '\142', 'b', nil, 'b', 'b', 'b', 'Small b' ], - ['c', 99, '143', '\143', 'c', nil, 'c', 'c', 'c', 'Small c' ], - ['d', 100, '144', '\144', 'd', nil, 'd', 'd', 'd', 'Small d' ], - ['e', 101, '145', '\145', 'e', nil, 'e', 'e', 'e', 'Small e' ], - ['f', 102, '146', '\146', 'f', nil, 'f', 'f', 'f', 'Small f' ], - ['g', 103, '147', '\147', 'g', nil, 'g', 'g', 'g', 'Small g' ], - ['h', 104, '150', '\150', 'h', nil, 'h', 'h', 'h', 'Small h' ], - ['i', 105, '151', '\151', 'i', nil, 'i', 'i', 'i', 'Small i' ], - ['j', 106, '152', '\152', 'j', nil, 'j', 'j', 'j', 'Small j' ], - ['k', 107, '153', '\153', 'k', nil, 'k', 'k', 'k', 'Small k' ], - ['l', 108, '154', '\154', 'l', nil, 'l', 'l', 'l', 'Small l' ], - ['m', 109, '155', '\155', 'm', nil, 'm', 'm', 'm', 'Small m' ], - ['n', 110, '156', '\156', 'n', nil, 'n', 'n', 'n', 'Small n' ], - ['o', 111, '157', '\157', 'o', nil, 'o', 'o', 'o', 'Small o' ], - ['p', 112, '160', '\160', 'p', nil, 'p', 'p', 'p', 'Small p' ], - ['q', 113, '161', '\161', 'q', nil, 'q', 'q', 'q', 'Small q' ], - ['r', 114, '162', '\162', 'r', nil, 'r', 'r', 'r', 'Small r' ], - ['s', 115, '163', '\163', 's', nil, 's', 's', 's', 'Small s' ], - ['t', 116, '164', '\164', 't', nil, 't', 't', 't', 'Small t' ], - ['u', 117, '165', '\165', 'u', nil, 'u', 'u', 'u', 'Small u' ], - ['v', 118, '166', '\166', 'v', nil, 'v', 'v', 'v', 'Small v' ], - ['w', 119, '167', '\167', 'w', nil, 'w', 'w', 'w', 'Small w' ], - ['x', 120, '170', '\170', 'x', nil, 'x', 'x', 'x', 'Small x' ], - ['y', 121, '171', '\171', 'y', nil, 'y', 'y', 'y', 'Small y' ], - ['z', 122, '172', '\172', 'z', nil, 'z', 'z', 'z', 'Small z' ], - ['{', 123, '173', '\173', '{', nil, '{\{}', '\{', '', 'Left curly brace {' ], - ['|', 124, '174', '\174', '|', nil, '', '', '', 'Vertical bar / pipe |' ], - ['}', 125, '175', '\175', '}', nil, '{\}}', '\}', '', 'Right curly brace }' ], - ['~', 126, '176', '\176', '~', nil, '', '', '', 'Tilde ~' ], - ['', 127, '177', '', '', nil, '', '', '', ' ' ], - ['', 128, '200', '', '€', nil, '', '', '', ' ' ], - ['', 129, '201', '', '', nil, '', '', '', ' ' ], - ['\'', 130, '202', '', '‚', nil, '', '', '', 'Low left single quote \''], - [' ', 131, '203', '', 'ƒ', nil, '', '', '', 'Florin ' ], - ['"', 132, '204', '', '„', nil, '', '', '', 'Low left double quote "' ], - ['…', 133, '205', '\342\200\246', '…', nil, '…', '\textellipsis', '', 'Ellipsis …' ], - ['†', 134, '206', '\342\200\240', '†', nil, '†', '\textdagger', '', 'Dagger †' ], - ['‡', 135, '207', '\342\200\241', '‡', nil, '‡', '\textdaggerbl', '', 'Double dagger ‡' ], - ['^', 136, '210', '', 'ˆ', nil, '', '', '', 'Circumflex ^' ], - ['', 137, '211', '', '‰', nil, '', '', '', 'Permil ' ], - ['', 138, '212', '', 'Š', nil, '', '', '', 'Capital S, caron ' ], - ['<', 139, '213', '', '‹', nil, '', '', '', 'Less than sign (see &060;) <' ], - ['', 140, '214', '', 'Œ', nil, '', '', '', 'Capital OE ligature ' ], - ['', 141, '215', '', '', nil, '', '', '', ' ' ], - ['', 142, '216', '', 'Ž', nil, '', '', '', 'Capital Z, caron ' ], - ['', 143, '217', '', '', nil, '', '', '', ' ' ], - ['', 144, '220', '', '', nil, '', '', '', ' ' ], - ['', 145, '221', '', '‘', nil, '', '', '', 'Left single quote ' ], - ['', 146, '222', '', '’', nil, '', '', '', 'Right single quote ' ], - ['', 147, '223', '', '“', nil, '', '', '', 'Left double quote ' ], - ['', 148, '224', '', '”', nil, '', '', '', 'Right double quote ' ], - ['', 149, '225', '', '•', nil, '', '', '', 'Bullet ' ], - ['-', 150, '226', '', '–', nil, '', '', '', 'En dash -' ], - ['', 151, '227', '', '—', nil, '', '', '', 'Em dash -' ], - ['~', 152, '230', '', '˜', nil, '', '', '', 'Tilde (see &126;) ~' ], - ['t', 153, '231', '', '™', nil, '', '', '', 'Trademark t' ], - ['', 154, '232', '', 'š', nil, '', '', '', 'small s, caron ' ], - ['', 155, '233', '', '›', nil, '', '', '', 'Greater than sign (see &062;) ' ], - ['', 156, '234', '', 'œ', nil, '', '', '', 'Small oe ligature ' ], - ['', 157, '235', '', '', nil, '', '', '', ' ' ], - ['', 158, '236', '', 'ž', nil, '', '', '', 'Small z, caron ' ], - ['', 159, '237', '', 'Ÿ', nil, '', '', '', 'Capital Y, umlaut ' ], - ['', 160, '240', '', ' ', ' ', '', '', '', 'Non-breaking space ' ], - ['¡', 161, '241', '\302\241', '¡', '¡', '¡', '', '', 'Inverted exclamation ' ], - ['¢', 162, '242', '\302\242', '¢', '¢', '¢', '', '', 'Cent sign ¢' ], - ['£', 163, '243', '\302\243', '£', '£', '£', '\textsterling', '', 'Pound sign £' ], - ['¤', 164, '244', '\302\244', '¤', '¤', '¤', '\textcurrency', '', 'General currency sign ' ], - ['¥', 165, '245', '\302\245', '¥', '¥', '¥', '', '', 'Yen sign ¥' ], - ['¦', 166, '246', '\302\246', '¦', '¦', '¦', '', '', 'Broken vertical bar ' ], - ['§', 167, '247', '\302\247', '§', '§', '§', '\textsection', '', 'Section sign §' ], - ['¨', 168, '250', '\302\250', '¨', '¨', '¨', '\"', '', 'Umlaut ' ], - ['©', 169, '251', '\302\251', '©', '©', '©', '\copyright', '\textcopyright', 'Copyright ©' ], - ['ª', 170, '252', '\302\252', 'ª', 'ª', 'ª', '', '', 'Feminine ordinal ª' ], - ['«', 171, '253', '\302\253', '«', '«', '«', '', '', 'Left angle quote «' ], - ['¬', 172, '254', '\302\254', '¬', '¬', '¬', '', '', 'Not sign ' ], - ['­', 173, '255', '\302\255', '­', '­', '­', '', '', 'Soft hyphen ' ], - ['®', 174, '256', '\302\256', '®', '®', '®', '', '', 'Registered trademark ®' ], - ['¯', 175, '257', '\302\257', '¯', '¯', '¯', '', '', 'Macron accent ' ], - ['°', 176, '260', '\302\260', '°', '°', '°', '', '', 'Degree sign °' ], - ['±', 177, '261', '\302\261', '±', '&plusmin;', '±', '', '', 'Plus or minus ±' ], - ['²', 178, '262', '\302\262', '²', '²', '²', '', '', 'Superscript 2 ²' ], - ['³', 179, '263', '\302\263', '³', '³', '³', '', '', 'Superscript 3 ³' ], - ['', 180, '264', '\302\264', '´', '´', ''', '', '', 'Acute accent ' ], - ['µ', 181, '265', '\302\265', 'µ', 'µ', 'µ', '', '', 'Micro sign (Greek mu) µ' ], - ['¶', 182, '266', '\302\266', '¶', '¶', '¶', '\textparagraph', '', 'Paragraph sign ¶' ], - ['·', 183, '267', '\302\267', '·', '·', %q{·}, '', %q{}, 'Middle dot ' ], - ['¸', 184, '270', '\302\270', '¸', '¸', '¸', '', '', 'Cedilla ' ], - ['¹', 185, '271', '\302\271', '¹', '¹', '¹', '', '', 'Superscript 1 ¹' ], - ['º', 186, '272', '\302\272', 'º', 'º', 'º', '', '', 'Masculine ordinal º' ], - ['»', 187, '273', '\302\273', '»', '»', '»', '', '', 'Right angle quote ' ], - ['¼', 188, '274', '\302\274', '¼', '¼', '¼', '', '', 'Fraction one quarter ¼' ], - ['½', 189, '275', '\302\275', '½', '½', '½', '', '', 'Fraction on half ½' ], - ['¾', 190, '276', '\302\276', '¾', '¾', '¾', '', '', 'Fraction three quarters ¾' ], - ['¿', 191, '277', '\302\277', '¿', '¿', '¿', '', '', 'Inverted question mark ¿' ], - ['À', 192, '300', '\303\200', 'À', 'À', 'À', '\`{A}', '', 'Capital A, grave accent À' ], - ['Á', 193, '301', '\303\201', 'Á', 'Á', 'Á', %q{\'{A}}, '', 'Capital A, acute accent Á' ], - ['Â', 194, '302', '\303\202', 'Â', 'Â', 'Â', '^{A}', '', 'Capital A, circumflex accent Â' ], - ['Ã', 195, '303', '\303\203', 'Ã', 'Ã', 'Ã', '~{A}', '', 'Capital A, tilde Ã' ], - ['Ä', 196, '304', '\303\204', 'Ä', 'Ä', 'Ä', '"{A}', '', 'Capital A, umlaut Ä' ], - ['Å', 197, '305', '\303\205', 'Å', 'Å', 'Å', 'r{A}', '', 'Capital A, ring Å' ], - ['Æ', 198, '306', '\303\206', 'Æ', 'Æ', 'Æ', 'AE', '', 'Capital AE ligature Æ' ], - ['Ç', 199, '307', '\303\207', 'Ç', 'Ç', 'Ç', '', '', 'Capital C, cedilla Ç' ], - ['È', 200, '310', '\303\210', 'È', 'È', 'È', '`{E}', '', 'Capital E, grave accent È' ], - ['É', 201, '311', '\303\211', 'É', 'É', 'É', ''{E}', '', 'Capital E, acute accent É' ], - ['Ê', 202, '312', '\303\212', 'Ê', 'Ê', 'Ê', '^{E}', '', 'Capital E, circumflex accent Ê' ], - ['Ë', 203, '313', '\303\213', 'Ë', 'Ë', 'Ë', '"{E}', '', 'Capital E, umlaut Ë' ], - ['Ì', 204, '314', '\303\214', 'Ì', 'Ì', 'Ì', '`{I}', '', 'Capital I, grave accent Ì' ], - ['Í', 205, '315', '\303\215', 'Í', 'Í', 'Í', ''{I}', '', 'Capital I, acute accent Í' ], - ['Î', 206, '316', '\303\216', 'Î', 'Î', 'Î', '^{I}', '', 'Capital I, circumflex accent Î' ], - ['Ï', 207, '317', '\303\217', 'Ï', 'Ï', 'Ï', '"{I}', '', 'Capital I, umlaut Ï' ], - ['Ð', 208, '320', '\303\220', 'Ð', 'Ð', 'Ð', '', '', 'Capital eth, Icelandic ' ], - ['Ñ', 209, '321', '\303\221', 'Ñ', 'Ñ', 'Ñ', '', '', 'Capital N, tilde Ñ' ], - ['Ò', 210, '322', '\303\222', 'Ò', 'Ò', 'Ò', '`{O}', '', 'Capital O, grave accent Ò' ], - ['Ó', 211, '323', '\303\223', 'Ó', 'Ó', 'Ó', ''{O}', '', 'Capital O, acute accent Ó' ], - ['Ô', 212, '324', '\303\224', 'Ô', 'Ô', 'Ô', '^{O}', '', 'Capital O, circumflex accent Ô' ], - ['Õ', 213, '325', '\303\225', 'Õ', 'Õ', 'Õ', '~{O}', '', 'Capital O, tilde Õ' ], - ['Ö', 214, '326', '\303\226', 'Ö', 'Ö', 'Ö', '"{O}', '', 'Capital O, umlaut Ö' ], - ['×', 215, '327', '\303\227', '×', '×', '×', '', '', 'Multiply sign ×' ], - ['Ø', 216, '330', '\303\230', 'Ø', 'Ø', 'Ø', 'O', '', 'Capital O, slash Ø' ], - ['Ù', 217, '331', '\303\231', 'Ù', 'Ù', 'Ù', '', '', 'Capital U, grave accent Ù' ], - ['Ú', 218, '332', '\303\232', 'Ú', 'Ú', 'Ú', '', '', 'Capital U, acute accent Ú' ], - ['Û', 219, '333', '\303\233', 'Û', 'Û', 'Û', '', '', 'Capital U, circumflex accent Û' ], - ['Ü', 220, '334', '\303\234', 'Ü', 'Ü', 'Ü', '', '', 'Capital U, umlaut Ü' ], - ['Ý', 221, '335', '\303\235', 'Ý', 'Ý', 'Ý', '', '', 'Capital Y, acute accent Ý' ], - ['Þ', 222, '336', '\303\236', 'Þ', 'Þ', 'Þ', '', '', 'Capital thorn, Icelandic Þ' ], - ['ß', 223, '337', '\303\237', 'ß', 'ß', 'ß', '', '', 'Small sz ligature, German ß' ], - ['à', 224, '340', '\303\240', 'à', 'à', 'à', '\`{a}', '', 'Small a, grave accent à' ], - ['á', 225, '341', '\303\241', 'á', 'á', 'á', %q{\'{a}}, '', 'Small a, acute accent á' ], - ['â', 226, '342', '\303\242', 'â', 'â', 'â', '\^{a}', '', 'Small a, circumflex accent â' ], - ['ã', 227, '343', '\303\243', 'ã', 'ã', 'ã', '\~{a}', '', 'Small a, tilde ã' ], - ['ä', 228, '344', '\303\244', 'ä', 'ä', 'ä', '\"{a}', '', 'Small a, umlaut ä' ], - ['å', 229, '345', '\303\245', 'å', 'å', 'å', '\r{a}', '', 'Small a, ring å' ], - ['æ', 230, '346', '\303\246', 'æ', 'æ', 'æ', '\ae', '', 'Small ae ligature æ' ], - ['ç', 231, '347', '\303\257', 'ç', 'ç', 'ç', '', '', 'Small c, cedilla ç' ], - ['è', 232, '350', '\303\250', 'è', 'è', 'è', '\`{e}', '', 'Small e, grave accent è' ], - ['é', 233, '351', '\303\251', 'é', 'é', 'é', %q{\'{e}}, '', 'Small e, acute accent é' ], - ['ê', 234, '352', '\303\252', 'ê', 'ê', 'ê', '\^{e}', '', 'Small e, circumflex accent ê' ], - ['ë', 235, '353', '\303\253', 'ë', 'ë', 'ë', '\"{e}', '', 'Small e, umlaut ë' ], - ['ì', 236, '354', '\303\254', 'ì', 'ì', 'ì', '\`{i}', '', 'Small i, grave accent ì' ], - ['í', 237, '355', '\303\255', 'í', 'í', 'í', '\'{i}', '', 'Small i, acute accent í' ], - ['î', 238, '356', '\303\256', 'î', 'î', 'î', '\^{i}', '', 'Small i, circumflex accent î' ], - ['ï', 239, '357', '\303\257', 'ï', 'ï', 'ï', '\"{i}', '', 'Small i, umlaut ï' ], - ['ð', 240, '360', '\303\260', 'ð', 'ð', 'ð', '', '', 'Small eth, Icelandic ð' ], - ['ñ', 241, '361', '\303\261', 'ñ', 'ñ', 'ñ', '', '', 'Small n, tilde ñ' ], - ['ò', 242, '362', '\303\262', 'ò', 'ò', 'ò', '\`{o}', '', 'Small o, grave accent ò' ], - ['ó', 243, '363', '\303\263', 'ó', 'ó', 'ó', %q{\'{o}}, '', 'Small o, acute accent ó' ], - ['ô', 244, '364', '\303\264', 'ô', 'ô', 'ô', '\^{o}', '', 'Small o, circumflex accent ô' ], - ['õ', 245, '365', '\303\265', 'õ', 'õ', 'õ', '\^{o}', '', 'Small o, tilde õ' ], - ['ö', 246, '366', '\303\266', 'ö', 'ö', 'ö', '\"{o}', '', 'Small o, umlaut ö' ], - ['÷', 247, '367', '\303\267', '÷', '÷', '÷', '', '', 'Divide sign ÷' ], - ['ø', 248, '370', '\303\270', 'ø', 'ø', 'ø', '', '', 'Small o, slash ø' ], - ['ù', 249, '371', '\303\271', 'ù', 'ù', 'ù', '\`{u}', '', 'Small u, grave accent ù' ], - ['ú', 250, '372', '\303\272', 'ú', 'ú', 'ú', %q{\'{u}}, '', 'Small u, acute accent ú' ], - ['û', 251, '373', '\303\273', 'û', 'û', 'û', '\^{u}', '', 'Small u, circumflex accent û' ], - ['ü', 252, '374', '\303\274', 'ü', 'ü', 'ü', '\"{u}', '', 'Small u, umlaut ü' ], - ['ý', 253, '375', '\303\275', 'ý', 'ý', 'ý', '', '', 'Small y, acute accent ý' ], - ['þ', 254, '376', '\303\276', 'þ', 'þ', 'þ', '', '', 'Small thorn, Icelandic þ' ], - ['ÿ', 255, '377', '\303\277', 'ÿ', 'ÿ', 'ÿ', '', '', 'Smally y, umlaut ÿ' ], - ['∝', , '', '', '∝', '∝', '∝', '', '', 'proportional to U+221D (8733) ∝' ], - ['∞', , '', '', '∞', '∞', '∞', '', '', 'infinity U+221E (8734) ∞' ], -] - end - end -end -__END__ diff --git a/lib/sisu/v3/dal_character_check.rb b/lib/sisu/v3/dal_character_check.rb index fdba5086..df14e1aa 100644 --- a/lib/sisu/v3/dal_character_check.rb +++ b/lib/sisu/v3/dal_character_check.rb @@ -78,8 +78,6 @@ module SiSU_DAL_CharacterCheck gsub(/
/,"#{Mx[:br_line]}"). #needed by xml, xhtml etc. gsub(/\t/,' '). gsub(/\342\200\231/u,"'"). #if dob =~/’/ #Avoid #‘ ’ #“ ” - gsub(/�/u,' '). #watch, replace with char code - gsub(/·/u,'*'). gsub(/\\copy(?:right)?\b/,'©'). gsub(/\\trademark\b|\\tm\b/,'®') dob.obj=dob.obj + "\n" @@ -87,7 +85,9 @@ module SiSU_DAL_CharacterCheck case dob.obj when /\^~/ #% Note must do this first (earlier loop) and then enter gathered data into ~^\d+ sub_dob=dob.obj.dup - @endnote_array << sub_dob.gsub(/\n/,'').gsub(/\^~\s+(.+)\s*/,%{#{Mx[:en_a_o]}#{endnote_no} \\1 #{Mx[:en_a_c]}}).strip + @endnote_array << sub_dob.gsub(/\n/,''). + gsub(/\^~\s+(.+)\s*/,%{#{Mx[:en_a_o]}#{endnote_no} \\1 #{Mx[:en_a_c]}}). + strip endnote_no+=1 dob=nil if dob.obj =~/\^~ .+/ #watch, removes 'binary' endnote now in endnote array for later insertion end diff --git a/lib/sisu/v3/hub.rb b/lib/sisu/v3/hub.rb index ac103830..2ab95052 100644 --- a/lib/sisu/v3/hub.rb +++ b/lib/sisu/v3/hub.rb @@ -209,10 +209,6 @@ p "#{__LINE__}:#{__FILE__}" if @opt.act[:maintenance][:set] ==:on require_relative 'cgi' # cgi.rb SiSU_CGI::SearchSQL.new(@opt).read end - def encoding # -K build character encoding db (uses KirbyBase) - require_relative 'character_encoding' # character_encoding.rb - SiSU_CharacterEncode::Create.new.db - end def termsheet # -t system("sisu_termsheet #{@opt.cmd} #{@opt.fns}\n") @@n_do=@@n_do+1 -- cgit v1.2.3 From dd13f639ddc54bc9d5519c41d685dd9b23500702 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Wed, 29 Aug 2012 21:58:48 -0400 Subject: v3: dbi, pgsql, report need for instructions when none given --- lib/sisu/v3/db_import.rb | 2 +- lib/sisu/v3/db_select.rb | 7 +++++-- lib/sisu/v3/dbi.rb | 2 -- 3 files changed, 6 insertions(+), 5 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v3/db_import.rb b/lib/sisu/v3/db_import.rb index 03f5d221..225e9da2 100644 --- a/lib/sisu/v3/db_import.rb +++ b/lib/sisu/v3/db_import.rb @@ -76,7 +76,7 @@ module SiSU_DbImport if @opt.fns.empty? or @opt.cmd.empty?; @fnb='' else @md=SiSU_Param::Parameters.new(@opt).get - @fnb=@md.fnb + @md.fnb end @suffix=@opt.fns[/(?:.+?)(?:\.ssm\.sst|\.-?sst)/,1] @fnc="#{@dal}/#{@opt.fns}.content.rbm" diff --git a/lib/sisu/v3/db_select.rb b/lib/sisu/v3/db_select.rb index 932bc551..e446c48a 100644 --- a/lib/sisu/v3/db_select.rb +++ b/lib/sisu/v3/db_select.rb @@ -181,14 +181,13 @@ module SiSU_DbSelect else '???' end tell.puts_grey if @opt.cmd =~/v/ - when /^--update$/ when /^--remove$/ db_exist? @sdb_remove_doc.remove when /^--index$/ db_exist? @sdb_index.create_indexes - when /^droptable(s)?$/ + when /^--droptable(s)?$/ db_exist? @sdb_no.drop.tables when /^--dropindex(es)?$/ @@ -209,6 +208,10 @@ module SiSU_DbSelect puts @job end end + if @opt.act[:psql][:set]==:on \ + and @opt.mod.inspect !~/--(?:createdb|init(?:ialize)?|create(?:all)?|createtables?|recreate|cr(eate)?lex|cr(eate)?metadata|import|update|remove|index|droptable(s)?|dropindex(es)?|dropall|drop)/ + SiSU_Screen::Ansi.new(@opt.cmd,"--pg requires further instruction").warn unless @opt.cmd =~/[q]/ + end begin rescue; @sdb.output_dir? end diff --git a/lib/sisu/v3/dbi.rb b/lib/sisu/v3/dbi.rb index 535ab0f2..cd44b808 100644 --- a/lib/sisu/v3/dbi.rb +++ b/lib/sisu/v3/dbi.rb @@ -107,8 +107,6 @@ module SiSU_DBI puts %{manually create the database: "#{@db.db}" if it does not yet exist} #sudo su -p postgres; createdb #{@db.db}; #[createuser?] end - SiSU_DbDBI::Case.new(@opt,@conn,@sql_type).cases - @conn=DBI.connect(@db.dbi,@db.user,@db.db) ensure end end -- cgit v1.2.3 From 2ea56a48ef3d3d599eb71c49a74eb9affb8df9ad Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Mon, 1 Oct 2012 13:48:00 -0400 Subject: v3: sisupod source, paths fix --- lib/sisu/v3/shared_sisupod_source.rb | 43 ++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 22 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v3/shared_sisupod_source.rb b/lib/sisu/v3/shared_sisupod_source.rb index 2aff984c..18821e37 100644 --- a/lib/sisu/v3/shared_sisupod_source.rb +++ b/lib/sisu/v3/shared_sisupod_source.rb @@ -86,7 +86,6 @@ module SiSU_Source image: path_pod + '/' + Gt[:image], audio: path_pod + '/' + Gt[:audio], video: path_pod + '/' + Gt[:video], - conf: path_pod + '/' + Gt[:conf] } end def read @@ -107,7 +106,7 @@ module SiSU_Source load "#{SiSU_lib}/defaults.rb" @skin={} skin_path = [ - "#{@env.path.pwd}/_sisu/skin", + "#{@opt.base_path}/_sisu/skin", "#{@env.path.home}/.sisu/skin", '/etc/sisu/skin', "#{@path_pod[:pod]}/external_document/skin" #CHECK @@ -214,7 +213,7 @@ module SiSU_Source FileUtils::mkdir_p(@path_pod[:image]) #unattractive hard coding ... ! image_path='_sisu/image' - images_pwd="#{@env.path.pwd}/#{image_path}" + images_pwd="#{@opt.base_path}/#{image_path}" ##sequence copies base images, defaults used in all html outputs #image_source_base='/usr/share/sisu/image' #dir_pwd=Dir.pwd @@ -238,9 +237,9 @@ module SiSU_Source if doc_import.length > 0 \ and @opt.fno =~/\.ssm$/ doc_import.each do |f| - if FileTest.file?("#{@env.path.pwd}#{doc_import_dir}/#{f}") - FileUtils::cp("#{@env.path.pwd}#{doc_import_dir}/#{f}","#{@path_pod[:doc]}/#{f}") - else STDERR.puts %{\t*WARN* did not find image - "#{@env.path.pwd}#{doc_import_dir}/#{f}" [#{__FILE__}:#{__LINE__}]} + if FileTest.file?("#{@opt.base_path}#{doc_import_dir}/#{f}") + FileUtils::cp("#{@opt.base_path}#{doc_import_dir}/#{f}","#{@path_pod[:doc]}/#{f}") + else STDERR.puts %{\t*WARN* did not find image - "#{@opt.base_path}#{doc_import_dir}/#{f}" [#{__FILE__}:#{__LINE__}]} end end end @@ -253,57 +252,57 @@ module SiSU_Source lng_f=$1 if @opt.lng == lng_f if @opt.fno =~/\.ssm$/ - if FileTest.file?("#{@env.path.pwd}#{doc_import_dir}/#{f[:f]}") - FileUtils::cp("#{@env.path.pwd}#{doc_import_dir}/#{f[:f]}", + if FileTest.file?("#{@opt.base_path}#{doc_import_dir}/#{f[:f]}") + FileUtils::cp("#{@opt.base_path}#{doc_import_dir}/#{f[:f]}", "#{@path_pod[:doc]}/#{f[:n]}") - else STDERR.puts %{\t*WARN* did not find - "#{@env.path.pwd}#{doc_import_dir}/#{f[:f]}" [#{__FILE__}:#{__LINE__}]} + else STDERR.puts %{\t*WARN* did not find - "#{@opt.base_path}#{doc_import_dir}/#{f[:f]}" [#{__FILE__}:#{__LINE__}]} end else - if FileTest.file?("#{@env.path.pwd}/#{f[:f]}") + if FileTest.file?("#{@opt.base_path}/#{f[:f]}") cpy= :no cpy=if f[:f] =~ /^#{@opt.f_pth[:lng_is]}\// \ or f[:f] =~ /~#{@opt.f_pth[:lng_is]}\.sst/ - p "#{@env.path.pwd}/#{f[:f]} --> #{@path_pod[:doc]}/#{f[:n]}" + p "#{@opt.base_path}/#{f[:f]} --> #{@path_pod[:doc]}/#{f[:n]}" :yes elsif f[:f] !~ /^(?:#{Px[:lng_lst_rgx]})\/|~(?:#{Px[:lng_lst_rgx]})\.sst/ \ and @opt.f_pth[:lng_is] == 'en' - p "#{@env.path.pwd}/#{f[:f]} --> #{@path_pod[:doc]}/#{f[:n]}" + p "#{@opt.base_path}/#{f[:f]} --> #{@path_pod[:doc]}/#{f[:n]}" :yes else :no end if cpy == :yes - FileUtils::cp("#{@env.path.pwd}/#{f[:f]}", + FileUtils::cp("#{@opt.base_path}/#{f[:f]}", "#{@path_pod[:doc]}/#{f[:n]}") end - else STDERR.puts %{\t*WARN* did not find - "#{@env.path.pwd}/#{f[:f]}" [#{__FILE__}:#{__LINE__}]} + else STDERR.puts %{\t*WARN* did not find - "#{@opt.base_path}/#{f[:f]}" [#{__FILE__}:#{__LINE__}]} end end end else if @opt.fno =~/\.ssm$/ - if FileTest.file?("#{@env.path.pwd}#{doc_import_dir}/#{f[:f]}") - FileUtils::cp_r("#{@env.path.pwd}#{doc_import_dir}/#{f[:f]}", + if FileTest.file?("#{@opt.base_path}#{doc_import_dir}/#{f[:f]}") + FileUtils::cp_r("#{@opt.base_path}#{doc_import_dir}/#{f[:f]}", "#{@path_pod[:doc]}/#{f[:n]}") - else STDERR.puts %{\t*WARN* did not find - "#{@env.path.pwd}#{doc_import_dir}/#{f[:f]}" [#{__FILE__}:#{__LINE__}]} + else STDERR.puts %{\t*WARN* did not find - "#{@opt.base_path}#{doc_import_dir}/#{f[:f]}" [#{__FILE__}:#{__LINE__}]} end else - if FileTest.file?("#{@env.path.pwd}/#{f[:f]}") + if FileTest.file?("#{@opt.base_path}/#{f[:f]}") cpy= :no cpy=if f[:f] =~ /^#{@opt.f_pth[:lng_is]}\// \ or f[:f] =~ /~#{@opt.f_pth[:lng_is]}\.sst/ - p "#{@env.path.pwd}/#{f[:f]} --> #{@path_pod[:doc]}/#{f[:n]}" + p "#{@opt.base_path}/#{f[:f]} --> #{@path_pod[:doc]}/#{f[:n]}" :yes elsif f[:f] !~ /^(?:#{Px[:lng_lst_rgx]})\/|~(?:#{Px[:lng_lst_rgx]})\.sst/ \ and @opt.f_pth[:lng_is] == 'en' - p "#{@env.path.pwd}/#{f[:f]} --> #{@path_pod[:doc]}/#{f[:n]}" + p "#{@opt.base_path}/#{f[:f]} --> #{@path_pod[:doc]}/#{f[:n]}" :yes else :no end if cpy == :yes - FileUtils::cp("#{@env.path.pwd}/#{f[:f]}", + FileUtils::cp("#{@opt.base_path}/#{f[:f]}", "#{@path_pod[:doc]}/#{f[:n]}") end - else STDERR.puts %{\t*WARN* did not find - "#{@env.path.pwd}/#{f[:f]}" [#{__FILE__}:#{__LINE__}]} + else STDERR.puts %{\t*WARN* did not find - "#{@opt.base_path}/#{f[:f]}" [#{__FILE__}:#{__LINE__}]} end end end -- cgit v1.2.3 From 78566728a9dcb96decff67d146fa20a485034be8 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Mon, 1 Oct 2012 13:55:31 -0400 Subject: v3: options, opt_act, limit calls * ruby profiler indicates much time spent here, reduce --- lib/sisu/v3/options.rb | 682 +++++++++++++++++++++++++------------------------ 1 file changed, 344 insertions(+), 338 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v3/options.rb b/lib/sisu/v3/options.rb index 5871d8db..ba2864fd 100644 --- a/lib/sisu/v3/options.rb +++ b/lib/sisu/v3/options.rb @@ -62,6 +62,7 @@ module SiSU_Commandline @@base_path=nil class Options attr_accessor :cmd,:mod,:act,:dir_structure_by,:f_pths,:files,:files_mod,:base_path,:base_stub,:sub_location,:paths,:lngs,:f_pth,:pth,:fno,:fns,:fnb,:fnc,:fng,:fncb,:lng,:lng_base,:what + @@act=nil def initialize(a) @cmd,@f_pth,@pth,@fno,@fns,@fnb,@fnc,@fng,@fncb,@what,@lng,@lng_base,@base_path,@base_stub,@sub_location='','','','','','','','','','','','','','' @f_pths,@files,@files_mod,@paths,@mod,@act=Array.new(5){[]} @@ -185,10 +186,13 @@ module SiSU_Commandline @mod=['--v3'] @cmd=shortcut.cf_0 + 'm' end - SiSU_Screen::Ansi.new(@cmd,"\tsisu " + @cmd + ' ' + @mod.join(' ') + ' ' + @files.join(' ') + "\n").print_brown if @cmd =~/[vVM]/ + if @cmd =~/[vVM]/ \ + && @cmd !~/-vu?$/ + SiSU_Screen::Ansi.new(@cmd,"\tsisu " + @cmd + ' ' + @mod.join(' ') + ' ' + @files.join(' ') + "\n").print_brown + end end # @files=@files.uniq - @act=opt_act + @@act ? @act=@@act : @@act=@act=opt_act @files self end @@ -315,9 +319,9 @@ module SiSU_Commandline else puts "file not found: #{x}" end elsif x =~ /\.termsheet\.rb$/ - if FileTest.file?(x); f << x - else puts "file not found: #{x}" - end + (FileTest.file?(x)) \ + ? (f << x) + : (puts "file not found: #{x}") else w=x puts "#{x} in #{a.join(' ')}?" end @@ -456,340 +460,342 @@ module SiSU_Commandline end def opt_act #note mod line commands have already been converted to command characters, cmd cmd,mod=@cmd,@mod - act={} - act[:license]=(cmd =~/L/ \ - || mod.inspect =~/"--license/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:site_init]=(cmd =~/C/ \ - || mod.inspect =~/"--init-site"|"--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 } + @@act=if @@act + @act=@@act 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[:verbose]=(cmd =~/v/ \ - || mod.inspect =~/"--verbose"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:quiet]=(cmd =~/q/ \ - || mod.inspect =~/"--quiet"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:color_state]=if mod.inspect =~/"--color-on"|"--color"/ - { bool: true, set: :on } - elsif mod.inspect =~/"--color-off"/ - { bool: false, set: :off } - else { bool: true, set: :na } #fix default color - end - act[:version_info]=if cmd =~/[vVM]/ \ - || mod.inspect =~/"--verbose"|"--maintenance"/ - { bool: true, set: :on } - else - { bool: false, set: :na } - end -# act[:color_toggle]=if cmd =~/c/ \ -# or mod.inspect =~/"--color-toggle"/ -# true -# else false -# end - act[:maintenance]=(cmd =~/M/ \ - || mod.inspect =~/"--maintenance|--keep-processing-files"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:profile]=(cmd =~/E/ \ - || mod.inspect =~/"--profile"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - 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[:output_by]=if mod.inspect =~/"--(?:output-)?by-language"/ - { set: :language } - elsif mod.inspect =~/"--(?:output-)?by-filename"/ - { set: :filename } - elsif mod.inspect =~/"--(?:output-)?by-filetype"/ - { set: :filetype } - else { set: :na } - end - act[:ocn]=if mod.inspect =~/"--inc-ocn"/ - { bool: true, set: :on } - elsif mod.inspect =~/"--(?:exc|no)-ocn"/ \ - || act[:switch][:off].inspect =~/"ocn"/ - { 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[: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 act[:manifest]=(cmd =~/y/ \ - || mod.inspect =~/"--manifest"/) - { bool: true, set: :on } - 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)-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 } + act={} + act[:license]=(cmd =~/L/ \ + || mod.inspect =~/"--license/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:site_init]=(cmd =~/C/ \ + || mod.inspect =~/"--init-site"|"--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[:verbose]=(cmd =~/v/ \ + || mod.inspect =~/"--verbose"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:version_info]=(cmd =~/[vVM]/ \ + || mod.inspect =~/"--verbose"|"--maintenance"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:quiet]=(cmd =~/q/ \ + || mod.inspect =~/"--quiet"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:color_state]=if mod.inspect =~/"--color-on"|"--color"/ + { bool: true, set: :on } + elsif mod.inspect =~/"--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]=(cmd =~/M/ \ + || mod.inspect =~/"--maintenance|--keep-processing-files"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:profile]=(cmd =~/E/ \ + || mod.inspect =~/"--profile"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + 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[:output_by]=if mod.inspect =~/"--(?:output-)?by-language"/ + { set: :language } + elsif mod.inspect =~/"--(?:output-)?by-filename"/ + { set: :filename } + elsif mod.inspect =~/"--(?:output-)?by-filetype"/ + { set: :filetype } + else { set: :na } + end + act[:ocn]=if mod.inspect =~/"--inc-ocn"/ + { bool: true, set: :on } + elsif mod.inspect =~/"--(?:exc|no)-ocn"/ \ + || act[:switch][:off].inspect =~/"ocn"/ + { 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[: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 act[:manifest]=(cmd =~/y/ \ + || mod.inspect =~/"--manifest"/) + { bool: true, set: :on } + 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)-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[:dal]=(cmd =~/m/ \ + || mod.inspect =~/"--dal"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:html]=(cmd =~/h/ \ + || mod.inspect =~/"--html"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + 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 } + act[:pdf]=(cmd =~/p/ \ + || mod.inspect =~/"--pdf"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:epub]=(cmd =~/e/ \ + || mod.inspect =~/"--epub"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:odt]=(cmd =~/o/ \ + || mod.inspect =~/"--odt"|"--odf"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + 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[:xhtml]=(cmd =~/b/ \ + || mod.inspect =~/"--xhtml"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:txt]=(cmd =~/[at]/ \ + || mod.inspect =~/"--txt"/) \ + ? { 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[:fictionbook]=(cmd =~/f/ \ + || mod.inspect =~/"--fictionbook"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:psql]=(cmd =~/D/ \ + || mod.inspect =~/"--pg"|"--pgsql"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:sqlite]=(cmd =~/d/ \ + || mod.inspect =~/"--sqlite"/) \ + && (mod.inspect =~/"--createdb"|"--create(?:all)?"|"--dropall"|"--recreate(?:all)?"|"--import"|"--update"|"--remove"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:sqlite_discreet]=(cmd =~/d/ \ + || mod.inspect =~/"--sql"|"--sqlite"/) \ + && (mod.inspect =~/"--both"/ \ + || 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[:zap]=(cmd =~/Z/ \ + || mod.inspect =~/"--zap"|"--delete"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:hash_digests]=(cmd =~/N/ \ + || mod.inspect =~/"--hash-digests"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + 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"/) \ + ? { bool: true, set: :on } + : { bool: false, set: :na } + act[:delete_output]=(cmd =~/z/ \ + || mod.inspect =~/"--delete"|"--zap"/) \ + ? { 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=act end - act[:dal]=(cmd =~/m/ \ - || mod.inspect =~/"--dal"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:html]=(cmd =~/h/ \ - || mod.inspect =~/"--html"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - 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 } - act[:pdf]=(cmd =~/p/ \ - || mod.inspect =~/"--pdf"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:epub]=(cmd =~/e/ \ - || mod.inspect =~/"--epub"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:odt]=(cmd =~/o/ \ - || mod.inspect =~/"--odt"|"--odf"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - 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[:xhtml]=(cmd =~/b/ \ - || mod.inspect =~/"--xhtml"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:txt]=(cmd =~/[at]/ \ - || mod.inspect =~/"--txt"/) \ - ? { 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[:fictionbook]=(cmd =~/f/ \ - || mod.inspect =~/"--fictionbook"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:psql]=(cmd =~/D/ \ - || mod.inspect =~/"--pg"|"--pgsql"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:sqlite]=(cmd =~/d/ \ - || mod.inspect =~/"--sqlite"/) \ - && (mod.inspect =~/"--createdb"|"--create(?:all)?"|"--dropall"|"--recreate(?:all)?"|"--import"|"--update"|"--remove"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:sqlite_discreet]=(cmd =~/d/ \ - || mod.inspect =~/"--sql"|"--sqlite"/) \ - && (mod.inspect =~/"--both"/ \ - || 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[:zap]=(cmd =~/Z/ \ - || mod.inspect =~/"--zap"|"--delete"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:hash_digests]=(cmd =~/N/ \ - || mod.inspect =~/"--hash-digests"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - 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"/) \ - ? { bool: true, set: :on } - : { bool: false, set: :na } - act[:delete_output]=(cmd =~/z/ \ - || mod.inspect =~/"--delete"|"--zap"/) \ - ? { 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=act end def cmd @cmd @@ -798,7 +804,7 @@ module SiSU_Commandline @mod end def act - @act + @@act end def files_mod files_mod=files -- cgit v1.2.3 From f90e9b268dde7516c1dae4bd58845b84fabb1a2b Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Mon, 1 Oct 2012 15:15:38 -0400 Subject: v3: pdflatex, landscape cover page was botched, came out as portrait, fix --- lib/sisu/v3/sysenv.rb | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v3/sysenv.rb b/lib/sisu/v3/sysenv.rb index 22b60a6d..be13c4fc 100644 --- a/lib/sisu/v3/sysenv.rb +++ b/lib/sisu/v3/sysenv.rb @@ -790,18 +790,16 @@ module SiSU_Env mode='batchmode' #mode='nonstopmode' program_ref="\n\t\tSee http://www.tug.org/applications/pdftex/\n\t\tOn Debian this is is included in tetex-extra" texpdf=tex2pdf_engine - if @pdfetex_flag; + if @pdfetex_flag texpdf_cmd=case texpdf when /xetex/ - @input =~/landscape\.tex$/ \ - ? %{#{texpdf} -interaction=#{mode} -fmt=xelatex -papersize="#{papersize} -l" #{@input} #{tell}\n} - : %{#{texpdf} -interaction=#{mode} -fmt=xelatex -papersize="#{papersize}" #{@input} #{tell}\n} + %{#{texpdf} -interaction=#{mode} -fmt=xelatex -papersize="#{papersize}" #{@input} #{tell}\n} when /xelatex/ - @input =~/landscape\.tex$/ \ - ? %{#{texpdf} -interaction=#{mode} -papersize="#{papersize} -l" #{@input} #{tell}\n} - : %{#{texpdf} -interaction=#{mode} -papersize="#{papersize}" #{@input} #{tell}\n} - when /pdftex/; "#{texpdf} -interaction=#{mode} -fmt=pdflatex #{@input} #{tell}\n" - when /pdflatex/; "#{texpdf} -interaction=#{mode} #{@input} #{tell}\n" + %{#{texpdf} -interaction=#{mode} -papersize="#{papersize}" #{@input} #{tell}\n} + when /pdftex/ + "#{texpdf} -interaction=#{mode} -fmt=pdflatex #{@input} #{tell}\n" + when /pdflatex/ + "#{texpdf} -interaction=#{mode} #{@input} #{tell}\n" end system(texpdf_cmd) else STDERR.puts "\t*WARN* none of the following programs are installed: #{program[0]}, #{program[1]}, #{program[2]} is installed. #{program_ref}" -- cgit v1.2.3 From d96753b4e4b7b0f2748064bc35aeaa8418deb7fa Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Mon, 1 Oct 2012 15:17:03 -0400 Subject: v3: texpdf fixes * group text, bullet * group text, hardspaces at start of line (indent) * group text, pass through special characters safe * poem, bold etc. --- lib/sisu/v3/texpdf.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v3/texpdf.rb b/lib/sisu/v3/texpdf.rb index 4c224b22..618c891e 100644 --- a/lib/sisu/v3/texpdf.rb +++ b/lib/sisu/v3/texpdf.rb @@ -468,13 +468,14 @@ module SiSU_TeX || dob.is==:group \ || dob.is==:alt \ || dob.is==:verse - dob.tmp=dob.tmp.gsub(/#{Mx[:nbsp]}/m,'{~}'). - gsub(/#{Mx[:gl_bullet]}/m,'$\txtbullet$\hspace{\enspace}'). #Bullet environment not used for grouped text, ∴ no hanging indent here + dob.tmp=dob.tmp.gsub(/#{Mx[:nbsp]}/m,' \hardspace '). + gsub(/#{Mx[:gl_bullet]}/m,'\txtbullet \hardspace '). #Bullet environment not used for grouped text, no hanging indent here gsub(/#{Mx[:br_nl]}+/m,"\n\n") #match not ideal, but currently not inserting extra newlines anyway ocn=SiSU_TeX_Pdf::FormatTextObject.new(@md).ocn_display(dob) dob.tmp=if dob.is==:group \ || dob.is==:block \ || dob.is==:alt + dob.tmp=SiSU_TeX_Pdf::SpecialCharacters.new(@md,dob.tmp).special_characters_safe ocn \ + @tex_ml.paraskip_small \ + "\n" \ @@ -485,6 +486,9 @@ module SiSU_TeX + "\n" \ + @tex_ml.paraskip_normal elsif dob.is==:verse + dob.tmp=dob.tmp.gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/m,'\begin{bfseries}\1 \end{bfseries}'). + gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/m,'\emph{\1}'). + gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/m,'\uline{\1}') ocn \ + @tex_ml.paraskip_tiny \ + "\n" \ -- cgit v1.2.3 From e5fe0553d62a1a5f5047451faaaa9792c483b493 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Mon, 1 Oct 2012 15:21:25 -0400 Subject: v3: html, epub, group text, bullet, fix --- lib/sisu/v3/dal_syntax.rb | 4 ++-- lib/sisu/v3/epub_tune.rb | 2 +- lib/sisu/v3/html_tune.rb | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v3/dal_syntax.rb b/lib/sisu/v3/dal_syntax.rb index 5b308009..8f029fe5 100644 --- a/lib/sisu/v3/dal_syntax.rb +++ b/lib/sisu/v3/dal_syntax.rb @@ -453,8 +453,8 @@ module SiSU_DAL_Syntax dob=fontface(dob) dob.obj=dob.obj.gsub(/<[:e]\s+(.+?)!?>/, "#{Mx[:en_a_o]}\\1#{Mx[:en_a_c]}"). #not tested - gsub(/^\s*_\*\s*/, - "#{Mx[:gl_bullet]}"). #bullets, shortcut + gsub(/(^|#{Mx[:br_nl]})\s*_\*\s*/, + "\\1#{Mx[:gl_bullet]}"). #bullets, shortcut gsub(/=\{(.+?)\}/, "#{Mx[:idx_o]}\\1#{Mx[:idx_c]}"). gsub(/^\s*_([1-9])\*\s*/, diff --git a/lib/sisu/v3/epub_tune.rb b/lib/sisu/v3/epub_tune.rb index 3a5669c6..a9bf31b0 100644 --- a/lib/sisu/v3/epub_tune.rb +++ b/lib/sisu/v3/epub_tune.rb @@ -238,7 +238,7 @@ module SiSU_EPUB_Tune gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,'\1'). gsub(/#{Mx[:fa_monospace_o]}(.+?)#{Mx[:fa_monospace_c]}/,'\1'). # tt, kbd gsub(/#{Mx[:mk_o]}:name#(\S+?)#{Mx[:mk_c]}/,''). - gsub(/^#{Mx[:gl_bullet]}/m,'●  '). + gsub(/#{Mx[:gl_bullet]}/m,'●  '). gsub(/#{Mx[:nbsp]}/,' '). gsub(/<(p|br)>/,'<\1 />') dob.obj=SiSU_EPUB_Tune::CleanXHTML.new(dob.obj).clean diff --git a/lib/sisu/v3/html_tune.rb b/lib/sisu/v3/html_tune.rb index a1c9a8dc..f7b60cff 100644 --- a/lib/sisu/v3/html_tune.rb +++ b/lib/sisu/v3/html_tune.rb @@ -354,7 +354,7 @@ module SiSU_HTML_Tune gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,'\1'). gsub(/#{Mx[:fa_monospace_o]}(.+?)#{Mx[:fa_monospace_c]}/,'\1'). # tt, kbd gsub(/#{Mx[:mk_o]}:name#(\S+?)#{Mx[:mk_c]}/,''). - gsub(/^#{Mx[:gl_bullet]}/m,'●  '). + gsub(/#{Mx[:gl_bullet]}/m,'●  '). gsub(/#{Mx[:nbsp]}/,' '). gsub(/<(p|br)>/,'<\1 />') dob=SiSU_HTML_Tune::CleanHTML.new(dob).clean -- cgit v1.2.3 From ef4da2e9bf2b690e484d8bda196a178f986aeaec Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Mon, 1 Oct 2012 15:23:47 -0400 Subject: v3: dal_syntax, new syntax: =\\= page new & -\\- page break * alias for <:pn> and <:pb> respectively --- lib/sisu/v3/constants.rb | 4 ++-- lib/sisu/v3/dal_doc_str.rb | 6 +++--- lib/sisu/v3/dal_syntax.rb | 6 +++++- 3 files changed, 10 insertions(+), 6 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v3/constants.rb b/lib/sisu/v3/constants.rb index a4de5898..a786a8b4 100644 --- a/lib/sisu/v3/constants.rb +++ b/lib/sisu/v3/constants.rb @@ -98,8 +98,8 @@ Mx={ br_nl: '╲', #lB ▌ 』 ┘ br_paragraph: '█', #FB █ 9608 # PP ∥ 8741 #▐ #'┘' #'¶' #FB █ 9608 lB ▌ 9612 RB ▐ 9616 br_obj: 'break_obj', - br_page: 'break_page', - br_page_new: 'break_page_new', + br_page: '┼', + br_page_new: '╋', lnk_o: '⌠', lnk_c: '⌡', #'⌈' '⌋' '⌠' '⌡' #Mx[:lnk_o: '◁'; Mx[:lnk_c: '▷' #‹ › url_o: '「', url_c: '」', rel_o: '⌈', rel_c: '⌋', diff --git a/lib/sisu/v3/dal_doc_str.rb b/lib/sisu/v3/dal_doc_str.rb index ab5f9199..0abaf4d0 100644 --- a/lib/sisu/v3/dal_doc_str.rb +++ b/lib/sisu/v3/dal_doc_str.rb @@ -233,11 +233,11 @@ module SiSU_DAL_DocumentStructureExtract end else nil end - when /^[<\[](?:br)?:(?:pa?r|o(?:bj|---)?)[>\]]\s*$/ #[br:par] #[br:obj] + when /^<(?:br)?:(?:pa?r|o(?:bj|---)?)>\s*$/ #[br:par] #[br:obj] SiSU_DAL_DocumentStructure::ObjectLayout.new.break(Hx[:br_obj]) - when /^(?:[<\[](?:br)?:pg[>\]]|?)\s*$/ #[br:pg] + when /^(?:-\\\\-|<:pb>)\s*$/ #[br:pg] SiSU_DAL_DocumentStructure::ObjectLayout.new.break(Hx[:br_page]) - when /^[<\[](?:br)?:pg?n[>\]]\s*$/ #[br:pgn] + when /^(?:=\\\\=|<:pn>)\s*$/ #[br:pgn] SiSU_DAL_DocumentStructure::ObjectLayout.new.break(Hx[:br_page_new]) else #paragraph image=image_test(t_o) diff --git a/lib/sisu/v3/dal_syntax.rb b/lib/sisu/v3/dal_syntax.rb index 8f029fe5..75bb8f53 100644 --- a/lib/sisu/v3/dal_syntax.rb +++ b/lib/sisu/v3/dal_syntax.rb @@ -141,7 +141,11 @@ module SiSU_DAL_Syntax && dob.is !=:comment \ && dob.is !=:code \ && dob.is !=:table - dob.obj=dob.obj.gsub(/ \\\\(?: |$)/,"#{Mx[:br_line]}"). + dob.obj=dob.obj.gsub(/^-\\\\-\s*$/,"#{Mx[:br_page]}"). + gsub(/^=\\\\=\s*$/,"#{Mx[:br_page_new]}"). + gsub(/ \\\\(?: |$)/,"#{Mx[:br_line]}"). + gsub(/(?:<:?pb>)/,"#{Mx[:br_page]}"). # depreciated + gsub(/(?:<:?pn>)/,"#{Mx[:br_page_new]}"). # depreciated gsub(/(?:<:?br>|
)/,"#{Mx[:br_line]}") # depreciated end dob -- cgit v1.2.3 From 58c13f49d81e3a6448a0f4dabf44b3bfb52ea84c Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Mon, 1 Oct 2012 15:27:56 -0400 Subject: v3: odf, internal links/bookmarks, toc, book index --- lib/sisu/v3/dal.rb | 14 ++-- lib/sisu/v3/odf.rb | 170 +++++++++++++++++++++++++-------------------- lib/sisu/v3/odf_format.rb | 60 ++++++++++++++-- lib/sisu/v3/particulars.rb | 10 +-- lib/sisu/v3/sysenv.rb | 4 +- lib/sisu/v3/texpdf.rb | 2 +- 6 files changed, 164 insertions(+), 96 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v3/dal.rb b/lib/sisu/v3/dal.rb index 6c7fef79..a039545f 100644 --- a/lib/sisu/v3/dal.rb +++ b/lib/sisu/v3/dal.rb @@ -100,7 +100,7 @@ module SiSU_DAL @fnm=@make_fns.marshal.dal_metadata @fnc=@make_fns.marshal.dal_content @idx_sst=@make_fns.marshal.dal_idx_sst_rel_html_seg - @idx_tex=@make_fns.marshal.dal_idx_sst_rel + @idx_raw=@make_fns.marshal.dal_idx_sst_rel @idx_html=@make_fns.marshal.dal_idx_html @idx_xhtml=@make_fns.marshal.dal_idx_xhtml @map_nametags=@make_fns.marshal.dal_map_nametags @@ -163,7 +163,7 @@ module SiSU_DAL SiSU_DAL::Instantiate.new end end - def get_idx_tex #reads dal idx.tex, #unless does not exist then creates first + def get_idx_raw begin dal=[] unless @@fns==@opt.fns \ @@ -173,7 +173,7 @@ module SiSU_DAL : @opt.fns @@idx_arr[:tex]=[] end - dal=(@@idx_arr[:tex].empty?) ? read_idx_tex : @@idx_arr[:tex].dup #check + dal=(@@idx_arr[:tex].empty?) ? read_idx_raw : @@idx_arr[:tex].dup #check rescue SiSU_Errors::InfoError.new($!,$@,@opt.cmd,@opt.fns).error do __LINE__.to_s + ':' + __FILE__ @@ -318,12 +318,12 @@ module SiSU_DAL else nil end end - def read_idx_tex + def read_idx_raw m=[] - m=if FileTest.file?(@idx_tex) + m=if FileTest.file?(@idx_raw) (RUBY_VERSION < '1.9') \ - ? (File.open(@idx_tex){ |f| m=Marshal.load(f)}) - : (File.open(@idx_tex,'r:utf-8'){ |f| m=Marshal.load(f)}) + ? (File.open(@idx_raw){ |f| m=Marshal.load(f)}) + : (File.open(@idx_raw,'r:utf-8'){ |f| m=Marshal.load(f)}) else nil end end diff --git a/lib/sisu/v3/odf.rb b/lib/sisu/v3/odf.rb index 4985b3dd..2830b24d 100644 --- a/lib/sisu/v3/odf.rb +++ b/lib/sisu/v3/odf.rb @@ -101,7 +101,7 @@ module SiSU_ODF require_relative 'defaults' # defaults.rb require_relative 'shared_txt' # shared_txt.rb @@img_count=0 - @@odf={ body: [], open: [], close: [], head: [], metadata: [], tail: [], endnotes: [] } + @@odf={ body: [], head: [], toc: [], metadata: [], tail: [], book_idx: [], endnotes: [] } @@docstart=true @@fns=nil def initialize(particulars) @@ -144,6 +144,19 @@ module SiSU_ODF end end end + def odf_book_idx + if @md.book_idx + idx_arr,idx_raw=[],SiSU_Particulars::CombinedSingleton.instance.get_idx_raw(@md.opt).raw_idx + idx_raw.each do |x| + x=if x.is_a?(String) + SiSU_ODF_Format::FormatBookIndex.new(x).book_idx_bookmark + else nil + end + idx_arr << x.strip if x.is_a?(String) + end + @@odf[:book_idx]=idx_arr.join + end + end def odf_metadata @@odf[:metadata]=SiSU_Metadata::Summary.new(@md).odf.metadata end @@ -162,8 +175,10 @@ module SiSU_ODF @@odf[:tail] << %{\nSiSU: <www.jus.uio.no/sisu> and <www.sisudoc.org>} @@odf[:tail] << "\n" end - def heading(dob,p_num='') - dob.obj=dob.obj.gsub(/#{Mx[:tag_o]}\S+?#{Mx[:tag_c]}/,'') #check + def set_bookmark_tag(dob) + tags=SiSU_ODF_Format::Tags.new.set_bookmark_tag(dob) + end + def heading(dob,p_num) m=/#{$1}/ breakpage='' if @md.fns \ @@ -180,7 +195,19 @@ module SiSU_ODF end end @@docstart=false - dob.obj=%{#{breakpage}#{dob.obj}#{p_num}} + dob.tmp=dob.obj + dob.obj=%{#{breakpage}#{p_num[:set_ref]}#{set_bookmark_tag(dob)}#{dob.obj}#{p_num[:display]}} + dob + end + def toc(dob,p_num) + m=/#{$1}/ + hardspace=(dob.lv =~/[A-C]/i) \ + ? '' + : '' + toc_heading=dob.ocn \ + ? %{#{dob.tmp}} + : dob.tmp + dob.obj=%{#{toc_heading}#{hardspace}} dob end def image_src(i) @@ -282,6 +309,10 @@ module SiSU_ODF end t end + def text_link_odf_bookmark(txt,url,trail) + map_nametags=SiSU_Particulars::CombinedSingleton.instance.get_map_nametags(@md).nametags_map + %{#{txt.strip}#{trail}} + end def text_link(dob) m=dob.obj.scan(/(#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]})/) #sort if m @@ -305,6 +336,19 @@ module SiSU_ODF txt=txt.gsub(/([)(\]\[])/,"\\\\\\1"). gsub(/([+?*])/,"\\\\\\1") # problems with + url=url.gsub(/([+?])/,"\\\\\\1") # problems with + + dob.obj=dob.obj.gsub(/#{Mx[:lnk_o]}[ ]*#{txt}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{url}#{Mx[:rel_c]}/m,text_link_odf_bookmark(txt,url,trail)). #make sure trailing ']' are not caught in url + gsub(/\\([)(\]\[?])/,'\1') #clumsy fix + end + m=nil + end + dob + end + def text_link_relative_(dob) + m=dob.obj.scan(/(#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:rel_o]}(\S+?)#{Mx[:rel_c]})/) #sort + if m + m.each do |i| + txt,url,trail=i[1],i[2] + txt=txt.gsub(/([)(\]\[])/,"\\\\\\1") dob.obj=dob.obj.gsub(/#{Mx[:lnk_o]}[ ]*#{txt}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{url}#{Mx[:rel_c]}/m,text_link_odf(txt,url,trail)). #make sure trailing ']' are not caught in url gsub(/\\([)(\]\[?])/,'\1') #clumsy fix end @@ -312,7 +356,7 @@ module SiSU_ODF end dob end - def normal(dob,p_num='') #P1 - P3 + def normal(dob,p_num) #P1 - P3 dob.obj=dob.obj.gsub(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/, '\1'). #http ftp matches escaped, no decoration gsub(/#{Mx[:url_o]}([a-zA-Z0-9._-]+\@\S+?\.[a-zA-Z0-9._-]+)#{Mx[:url_c]}/, @@ -322,12 +366,12 @@ module SiSU_ODF dob.obj= if dob.is==:para \ and dob.indent.to_s =~/[0-9]/ \ and dob.indent == dob.hang - %{#{dob.obj}#{p_num}} + %{#{p_num[:set_ref]}#{set_bookmark_tag(dob)}#{dob.obj}#{p_num[:display]}} elsif dob.is==:para \ and dob.hang.to_s =~/[0-9]/ \ and dob.indent != dob.hang - %{#{dob.obj}#{p_num}} - else %{#{dob.obj}#{p_num}} + %{#{p_num[:set_ref]}#{set_bookmark_tag(dob)}#{dob.obj}#{p_num[:display]}} + else %{#{p_num[:set_ref]}#{set_bookmark_tag(dob)}#{dob.obj}#{p_num[:display]}} end dob end @@ -390,12 +434,13 @@ module SiSU_ODF end def poem(dob,p_num) #P4 #same as group parray=[] - dob.obj.split(/#{Mx[:br_line]}|#{Mx[:br_nl]}/).each do |parablock| + dob.obj.split(/#{Mx[:br_line]}|#{Mx[:br_nl]}/).each_with_index do |parablock,i| + set_ref=(i==0) ? "#{p_num[:set_ref]}#{set_bookmark_tag(dob)}" : '' parablock=group_clean(parablock) - parray << %{#{parablock}} if parablock =~/\S+/ + parray << %{#{set_ref}#{parablock}} if parablock =~/\S+/ end dob.obj=parray.join \ - + %{#{p_num}} \ + + %{#{p_num[:display]}} \ + '' dob end @@ -407,7 +452,8 @@ module SiSU_ODF %{#{@brace_url.xml_open}\\1#{@brace_url.xml_close}}). gsub(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/, %{#{@brace_url.xml_open}\\1#{@brace_url.xml_close}}) #http ftp matches with decoration - dob.obj.split(/#{Mx[:br_line]}|#{Mx[:br_nl]}/).each do |parablock| + dob.obj.split(/#{Mx[:br_line]}|#{Mx[:br_nl]}/).each_with_index do |parablock,i| + set_ref=(i==0) ? "#{p_num[:set_ref]}#{set_bookmark_tag(dob)}" : '' parablock=group_clean(parablock) parablock=parablock.gsub(/<text:a xlink:type="simple" xlink:href="(.+?)">/m,''). gsub(/<(\/text:a)>/,'<\1>'). @@ -415,10 +461,10 @@ module SiSU_ODF gsub(/<(text:p text:style-name="Footnote")>/,'<\1>'). gsub(/<(\/?text:(?:note-citation|note-body|note|p))>/,'<\1>') parablock=footnote(parablock) - parray << %{#{parablock}} if parablock =~/\S+/ + parray << %{#{set_ref}#{parablock}} if parablock =~/\S+/ end dob.obj=parray.join \ - + %{#{p_num}} \ + + %{#{p_num[:display]}} \ + '' dob end @@ -430,7 +476,8 @@ module SiSU_ODF %{#{@brace_url.xml_open}\\1#{@brace_url.xml_close}}). gsub(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/, %{#{@brace_url.xml_open}\\1#{@brace_url.xml_close}}) #http ftp matches with decoration - dob.obj.split(/#{Mx[:br_line]}|#{Mx[:br_nl]}/).each do |parablock| + dob.obj.split(/#{Mx[:br_line]}|#{Mx[:br_nl]}/).each_with_index do |parablock,i| + set_ref=(i==0) ? "#{p_num[:set_ref]}#{set_bookmark_tag(dob)}" : '' parablock=group_clean(parablock) parablock=parablock.gsub(/<text:a xlink:type="simple" xlink:href="(.+?)">/m,''). gsub(/<(\/text:a)>/,'<\1>'). @@ -438,10 +485,10 @@ module SiSU_ODF gsub(/<(text:p text:style-name="Footnote")>/,'<\1>'). gsub(/<(\/?text:(?:note-citation|note-body|note|p))>/,'<\1>') parablock=footnote(parablock) - parray << %{#{parablock}} if parablock =~/\S+/ + parray << %{#{set_ref}#{parablock}} if parablock =~/\S+/ end dob.obj=parray.join \ - + %{#{p_num}} \ + + %{#{p_num[:display]}} \ + '' dob end @@ -449,15 +496,16 @@ module SiSU_ODF if dob.is==:code dob.obj=dob.obj.gsub(/\s\s/,'  ') parray=[] - dob.obj.split(/#{Mx[:br_line]}|#{Mx[:br_nl]}/).each do |parablock| + dob.obj.split(/#{Mx[:br_line]}|#{Mx[:br_nl]}/).each_with_index do |parablock,i| + set_ref=(i==0) ? "#{p_num[:set_ref]}#{set_bookmark_tag(dob)}" : '' parablock=group_clean(parablock) parablock=parablock.gsub(/^\s*$/,'
'). gsub(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/, '\1') #http ftp matches escaped, no decoration - parray << %{#{parablock}} if parablock =~/\S+/ + parray << %{#{set_ref}#{parablock}} if parablock =~/\S+/ end dob.obj=parray.join \ - + %{#{p_num}} \ + + %{#{p_num[:display]}} \ + '' end dob @@ -490,18 +538,22 @@ module SiSU_ODF dob else dob end - p_num='' - if @env.odt_ocn? - if dob.is !~/(^#{Rx[:meta]}|#{Mx[:br_eof]}|#{Mx[:br_endnotes]})/ - if defined? dob.ocn \ - and not dob.ocn.nil? - p_num=SiSU_ODF_Format::ParagraphNumber.new(dob.ocn).display - end + p_num={ display: '', set_ref: '' } + if dob.is !~/(^#{Rx[:meta]}|#{Mx[:br_eof]}|#{Mx[:br_endnotes]})/ + if defined? dob.ocn \ + and dob.ocn.is_a?(Fixnum) + p_num=SiSU_ODF_Format::ParagraphNumber.new(dob.ocn).set_bookmark_and_display + #p_num=SiSU_ODF_Format::ParagraphNumber.new(dob.ocn).set_ref_and_display end end dob=footnote(dob) if dob.is==:heading @@odf[:body] << heading(dob,p_num).obj << @br*2 + if SiSU_Env::ProcessingSettings.new(md).build.toc? + if dob.lv =~/[A-C1]/i + @@odf[:toc] << toc(dob,p_num).obj + end + end elsif dob.is ==:verse @@odf[:body] << poem(dob,p_num).obj << @br*2 elsif dob.is==:group @@ -539,6 +591,7 @@ module SiSU_ODF else STDERR.puts %{\t*WARN* did not find image - "#{bullet}/bullet_09.png" [#{__FILE__}:#{__LINE__}]} end end + odf_book_idx odf_metadata data.each do |dob| #p dob.obj if dob.obj =~safe_characters and @md.opt.cmd =~/V/ #KEEP @@ -573,7 +626,7 @@ module SiSU_ODF dob.obj=dob.obj.gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,'\1'). gsub(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'\1'). gsub(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,'\1'). - gsub(/#{Mx[:tag_o]}\S+?#{Mx[:tag_c]}/,''). #check + gsub(/#{Mx[:tag_o]}\S+?#{Mx[:tag_c]}/,''). #check gsub(/#{Mx[:mk_o]}#([a-zA-Z]+)#{Mx[:mk_c]}/,'&\1;'). gsub(/#{Mx[:mk_o]}(#[0-9]+)#{Mx[:mk_c]}/,'&\1;'). gsub(/#{Mx[:mk_o]}[~-]##{Mx[:mk_c]}/,'') @@ -693,14 +746,19 @@ WOK def publish divider='=' content=[] + br_pg=' ' data=@data - content << @@odf[:open] - content << @@odf[:head] - content << @@odf[:body] - content << @@odf[:metadata] - content << @@odf[:tail] + content << + @@odf[:head] << + @@odf[:toc] << + br_pg << + @@odf[:body] << + @@odf[:book_idx] << + br_pg << + @@odf[:metadata] << + @@odf[:tail] SiSU_ODF::Source::Output.new(content,@md,@env).odf - @@odf[:head],@@odf[:body],@@odf[:tail],@@odf[:metadata]=[],[],[],[] + @@odf={ head: [], toc: [], body: [], tail: [], book_idx: [], metadata: [] } end end class Output ● #bullet -dob.obj.gsub!(/^(#{Mx[:pa_o]}:i[1-9]#{Mx[:pa_c]})\s*#{Mx[:gl_bullet]}/,'\1 · ') #bullet -dob.obj.gsub!(/^#{Mx[:gl_bullet]}/,'· ') #bullet diff --git a/lib/sisu/v3/odf_format.rb b/lib/sisu/v3/odf_format.rb index ae5c4aec..cd998f43 100644 --- a/lib/sisu/v3/odf_format.rb +++ b/lib/sisu/v3/odf_format.rb @@ -63,8 +63,15 @@ module SiSU_ODF_Format def initialize(paranum) @paranum=/(\d+)/m.match(paranum.to_s)[1] end - def display - @paranum.gsub(/(\d+)/,' [\1]') + def set_ref_and_display + set_ref=@paranum.gsub(/(\d+)/,' ') + disp=@paranum.gsub(/(\d+)/,' [\1]') + ocn={ display: disp, set_ref: set_ref } + end + def set_bookmark_and_display + set_ref=@paranum.gsub(/(\d+)/,' ') + disp=@paranum.gsub(/(\d+)/,' [\1]') + ocn={ display: disp, set_ref: set_ref } end def name @paranum.gsub(/(\d+)/,'') @@ -73,6 +80,50 @@ module SiSU_ODF_Format @paranum.gsub(/(\d+)/,'') end end + class FormatBookIndex + def initialize(idx_str) + @idx_str=idx_str + end + def book_idx_bookmark + map_nametags=SiSU_Particulars::CombinedSingleton.instance.get_map_nametags(@md).nametags_map #p map_nametags + rgx_bookmark=/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:rel_o]}#?\S+?#{Mx[:rel_c]}/m + while @idx_str =~/#{Mx[:lnk_o]}([^#{Mx[:lnk_o]}#{Mx[:lnk_c]}]+)#{Mx[:lnk_c]}#{Mx[:rel_o]}#?(\S+?)#{Mx[:rel_c]}/m + link,url=$1,$2 + link,url=link.strip,url.strip + @idx_str=@idx_str.gsub(/&/m,"&") + ocn_lnk=if map_nametags[url] \ + and map_nametags[url][:ocn] + map_nametags[url][:ocn] + else nil + end + ocn_lnk=(url=~/^\d+$/ ? url : ocn_lnk) + if ocn_lnk and not ocn_lnk.empty? + @idx_str=@idx_str.sub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/, + '\1'). + sub(rgx_bookmark, + %{#{link.strip}}) + else + puts %{name tag: "#{url}" not found} + @idx_str.sub!(rgx_bookmark,"#{link}") + end + end + @idx_str=@idx_str.gsub(/#{Xx[:protect]}/m,''). + sub(/,\s*$/m,''). + gsub(/\n/,'') + @idx_str='' + @idx_str + '' + end + end + class Tags + def set_bookmark_tag(dob) + tags='' + if dob.tags.length > 0 + dob.tags.each do |tag| + tags +=%{ } + end + end + tags + end + end class FormatTextObject def initialize(md,t_o) @md,@t_o=md,t_o @@ -136,12 +187,13 @@ module SiSU_ODF_Format when 14; 'N' else 'D' end - %{#{@br}} + + tag=SiSU_ODF_Format::Tags.new.set_bookmark_tag(@dob) + %{#{@p_num[:set_ref]}#{tag}#{@br}} + %{#{@br}} end def table_close(tablefoot='') '' \ - + %{#{@p_num}} + + %{#{@p_num[:display]}} end def table_tag_cell(str,i) txt_name_cell=if i==0 \ diff --git a/lib/sisu/v3/particulars.rb b/lib/sisu/v3/particulars.rb index b95ba52a..97a3da3e 100644 --- a/lib/sisu/v3/particulars.rb +++ b/lib/sisu/v3/particulars.rb @@ -97,9 +97,9 @@ module SiSU_Particulars @opt=opt set_sst_idx end - def get_idx_tex(opt) + def get_idx_raw(opt) @opt=opt - set_tex_idx + set_raw_idx end def get_idx_html(opt) @opt=opt @@ -126,7 +126,7 @@ module SiSU_Particulars @opt=opt set_ocn_htmlseg_map end - attr_accessor :opt,:md,:sst_idx,:tex_idx,:html_idx,:xhtml_idx + attr_accessor :opt,:md,:sst_idx,:raw_idx,:html_idx,:xhtml_idx def set_md begin @md=SiSU_Param::Parameters.new(@opt).get @@ -180,9 +180,9 @@ module SiSU_Particulars end end end - def set_tex_idx + def set_raw_idx begin - @tex_idx=SiSU_DAL::Source.new(@opt).get_idx_tex + @raw_idx=SiSU_DAL::Source.new(@opt).get_idx_raw self rescue SiSU_Errors::InfoError.new($!,$@,@opt.cmd,@opt.fns).error do diff --git a/lib/sisu/v3/sysenv.rb b/lib/sisu/v3/sysenv.rb index be13c4fc..0786119c 100644 --- a/lib/sisu/v3/sysenv.rb +++ b/lib/sisu/v3/sysenv.rb @@ -3465,8 +3465,8 @@ WOK def dal_idx_sst_rel_html_seg "#{@env.processing_path.dal}/#{@fns}.idx_sst.rbm" end - def dal_idx_sst_rel - "#{@env.processing_path.dal}/#{@fns}.idx_tex.rbm" + def dal_idx_sst_rel #used by tex & odf + "#{@env.processing_path.dal}/#{@fns}.idx_raw.rbm" end def dal_idx_html "#{@env.processing_path.dal}/#{@fns}.idx_html.rbm" diff --git a/lib/sisu/v3/texpdf.rb b/lib/sisu/v3/texpdf.rb index 618c891e..aba92c3e 100644 --- a/lib/sisu/v3/texpdf.rb +++ b/lib/sisu/v3/texpdf.rb @@ -535,7 +535,7 @@ module SiSU_TeX h=tst.heading_major heading="\\clearpage\n" + h.tmp idx_arr=[] - idx=SiSU_Particulars::CombinedSingleton.instance.get_idx_tex(@md.opt).tex_idx + idx=SiSU_Particulars::CombinedSingleton.instance.get_idx_raw(@md.opt).raw_idx idx.each do |x| x=if x.class==String x=SiSU_TeX_Pdf::SpecialCharacters.new(@md,x).special_characters -- cgit v1.2.3 From 7d4665f60be31a0481416cfc152bac4442cc6e74 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Mon, 1 Oct 2012 15:33:55 -0400 Subject: v3: cosmetic code, true ? x : y --- lib/sisu/v3/dal_doc_objects.rb | 282 ++++++++++++++++----------------- lib/sisu/v3/dal_numbering.rb | 6 +- lib/sisu/v3/defaults.rb | 12 +- lib/sisu/v3/digests.rb | 6 +- lib/sisu/v3/epub.rb | 6 +- lib/sisu/v3/epub_format.rb | 18 +-- lib/sisu/v3/epub_segments.rb | 24 +-- lib/sisu/v3/help.rb | 54 +++---- lib/sisu/v3/html.rb | 18 +-- lib/sisu/v3/html_format.rb | 12 +- lib/sisu/v3/html_segments.rb | 24 +-- lib/sisu/v3/manifest.rb | 12 +- lib/sisu/v3/manpage.rb | 6 +- lib/sisu/v3/odf_format.rb | 6 +- lib/sisu/v3/param.rb | 6 +- lib/sisu/v3/qrcode.rb | 6 +- lib/sisu/v3/screen_text_color.rb | 15 +- lib/sisu/v3/sitemaps.rb | 7 +- lib/sisu/v3/sst_convert_markup.rb | 12 +- lib/sisu/v3/sst_do_inline_footnotes.rb | 30 ++-- lib/sisu/v3/sst_identify_markup.rb | 6 +- 21 files changed, 281 insertions(+), 287 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v3/dal_doc_objects.rb b/lib/sisu/v3/dal_doc_objects.rb index dd2c9cf0..f77348ec 100644 --- a/lib/sisu/v3/dal_doc_objects.rb +++ b/lib/sisu/v3/dal_doc_objects.rb @@ -71,7 +71,7 @@ module SiSU_DAL_DocumentStructure def metadata(tags) of= @of #String, classification - group is= :meta #String, classification - specific type - tags= tags || ((defined? o.tags) ? o.tags : {}) #String, metadata type/tag + tags= tags || ((defined? o.tags) ? o.tags : {}) #String, metadata type/tag obj= nil @of,@is,@tags,@obj=of,is,tags,obj self @@ -86,10 +86,10 @@ module SiSU_DAL_DocumentStructure def metadata(h,o=nil) of= @of #String, classification - group is= :meta #String, classification - specific type - tag= h[:tag] || ((defined? o.tag) ? o.tag : nil) #String, metadata type/tag - obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content - tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use - digest= h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, either sha256 or md5 + tag= h[:tag] || ((defined? o.tag) ? o.tag : nil) #String, metadata type/tag + obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content + tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use + digest= h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, either sha256 or md5 @of,@is,@tag,@obj,@digest,@tmp=of,is,tag,obj,digest,tmp self end @@ -135,27 +135,27 @@ module SiSU_DAL_DocumentStructure end of= @of #String, classification - group is= :heading #String, classification - specific type - name= h[:name] || ((defined? o.name) ? o.name : nil) #String, named object? - tags= h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any - obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content - idx= h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? - ocn= h[:ocn] || ((defined? o.ocn) ? o.ocn : nil) #Integer, sequential on substantive-content objects - odv= h[:odv] || ((defined? o.odv) ? o.odv : nil) - osp= h[:osp] || ((defined? o.osp) ? o.osp : nil) - node= h[:node] || ((defined? o.node) ? o.node : nil) #[Node relationship doc structure info] - parent= h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] - lv= h[:lv] || ((defined? o.lv) ? o.lv : nil) #Alpha-numeric, document structure as used in markup, A-C then 1-6 - ln= h[:ln] || ((defined? o.ln) ? o.ln : nil) #Integer, document structure level, for convenience in processing 1-9 - toc_= h[:toc_] || ((defined? o.toc_) ? o.toc_ : false) #Bool, do not include in toc, (relevant to headings) - ocn_=if h[:ocn_].nil?; ((defined? o.ocn_) ? o.ocn_ : true) #Bool? no ocn, non-substantive content, do not include in toc #consider + name= h[:name] || ((defined? o.name) ? o.name : nil) #String, named object? + tags= h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any + obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content + idx= h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? + ocn= h[:ocn] || ((defined? o.ocn) ? o.ocn : nil) #Integer, sequential on substantive-content objects + odv= h[:odv] || ((defined? o.odv) ? o.odv : nil) + osp= h[:osp] || ((defined? o.osp) ? o.osp : nil) + node= h[:node] || ((defined? o.node) ? o.node : nil) #[Node relationship doc structure info] + parent= h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] + lv= h[:lv] || ((defined? o.lv) ? o.lv : nil) #Alpha-numeric, document structure as used in markup, A-C then 1-6 + ln= h[:ln] || ((defined? o.ln) ? o.ln : nil) #Integer, document structure level, for convenience in processing 1-9 + toc_= h[:toc_] || ((defined? o.toc_) ? o.toc_ : false) #Bool, do not include in toc, (relevant to headings) + ocn_=if h[:ocn_].nil? then ((defined? o.ocn_) ? o.ocn_ : true) #Bool? no ocn, non-substantive content, do not include in toc #consider else h[:ocn_] end - autonum_= if h[:autonum_].nil?; ((defined? o.autonum_) ? o.autonum_ : true) #Bool? auto-numbering if requested default on, false suppresses + autonum_= if h[:autonum_].nil? then ((defined? o.autonum_) ? o.autonum_ : true) #Bool? auto-numbering if requested default on, false suppresses else h[:autonum_] end - note_= h[:note_] || ((defined? o.note_) ? o.note_ : false) #Bool, endnotes/footnotes? (processing optimization) - digest= h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, either sha256 or md5 - tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use + note_= h[:note_] || ((defined? o.note_) ? o.note_ : false) #Bool, endnotes/footnotes? (processing optimization) + digest= h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, either sha256 or md5 + tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use @of,@is,@lv,@ln,@name,@tags,@obj,@idx,@ocn,@odv,@osp,@node,@parent,@toc_,@ocn_,@note_,@autonum_,@digest,@tmp=of,is,lv,ln,name,tags,obj,idx,ocn,odv,osp,node,parent,toc_,ocn_,note_,autonum_,digest,tmp self end @@ -175,48 +175,48 @@ module SiSU_DAL_DocumentStructure def paragraph(h,o=nil) of= @of #String, classification - group is= :para #String, classification - specific type - name= h[:name] || ((defined? o.name) ? o.name : nil) #String, named object? - tags= h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any - obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content - idx= h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? - ocn= h[:ocn] || ((defined? o.ocn) ? o.ocn : nil) #Integer, sequential on substantive-content objects - odv= h[:odv] || ((defined? o.odv) ? o.odv : nil) - osp= h[:osp] || ((defined? o.osp) ? o.osp : nil) - parent= h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] + name= h[:name] || ((defined? o.name) ? o.name : nil) #String, named object? + tags= h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any + obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content + idx= h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? + ocn= h[:ocn] || ((defined? o.ocn) ? o.ocn : nil) #Integer, sequential on substantive-content objects + odv= h[:odv] || ((defined? o.odv) ? o.odv : nil) + osp= h[:osp] || ((defined? o.osp) ? o.osp : nil) + parent= h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] indent= h[:indent].to_s || ((defined? o.indent) ? o.indent.to_s : nil) #Integer, indent level - hang= h[:hang].to_s || ((defined? o.hang) ? o.hang.to_s : nil) #Integer, hanging indent level - bullet_=h[:bullet_] || ((defined? o.bullet_) ? o.bullet_ : false) #Bool, bulleted? - note_= h[:note_] || ((defined? o.note_) ? o.note_ : false) #Bool, endnotes/footnotes? (processing optimization) - image_= h[:image_] || ((defined? o.image_) ? o.image_ : false) #Bool, images? (processing optimization) - ocn_=if h[:ocn_].nil?; ((defined? o.ocn_) ? o.ocn_ : true) #Bool? no ocn, non-substantive content, do not include in toc #consider + hang= h[:hang].to_s || ((defined? o.hang) ? o.hang.to_s : nil) #Integer, hanging indent level + bullet_=h[:bullet_] || ((defined? o.bullet_) ? o.bullet_ : false) #Bool, bulleted? + note_= h[:note_] || ((defined? o.note_) ? o.note_ : false) #Bool, endnotes/footnotes? (processing optimization) + image_= h[:image_] || ((defined? o.image_) ? o.image_ : false) #Bool, images? (processing optimization) + ocn_=if h[:ocn_].nil? then ((defined? o.ocn_) ? o.ocn_ : true) #Bool? no ocn, non-substantive content, do not include in toc #consider else h[:ocn_] end - digest= h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, either sha256 or md5 - tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use + digest= h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, either sha256 or md5 + tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use @of,@is,@name,@tags,@obj,@indent,@hang,@bullet_,@idx,@ocn,@odv,@osp,@parent,@image_,@note_,@ocn_,@digest,@tmp=of,is,name,tags,obj,indent,hang,bullet_,idx,ocn,odv,osp,parent,image_,note_,ocn_,digest,tmp self end def docinfo(h,o=nil) of= @of #String, classification - group is= :docinfo #String, classification - specific type - name= h[:name] || ((defined? o.name) ? o.name : nil) #String, named object? - tags= h[:tags] || ((defined? o.tags) ? o.tags : nil) #Array, associated object tags, names if any - obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content + name= h[:name] || ((defined? o.name) ? o.name : nil) #String, named object? + tags= h[:tags] || ((defined? o.tags) ? o.tags : nil) #Array, associated object tags, names if any + obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content idx= nil #String, book index provided? ocn= nil #Integer, sequential on substantive-content objects - odv= h[:odv] || ((defined? o.odv) ? o.odv : nil) - osp= h[:osp] || ((defined? o.osp) ? o.osp : nil) - parent= h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] + odv= h[:odv] || ((defined? o.odv) ? o.odv : nil) + osp= h[:osp] || ((defined? o.osp) ? o.osp : nil) + parent= h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] indent= nil #Integer, indent level - hang= nil #Integer, indent level + hang= nil #Integer, indent level bullet_=false #Bool, bulleted? note_= false #Bool, endnotes/footnotes? (processing optimization) - image_= h[:image_] || ((defined? o.image_) ? o.image_ : false) #Bool, images? (processing optimization) - ocn_=if h[:ocn_].nil?; ((defined? o.ocn_) ? o.ocn_ : true) #Bool? no ocn, non-substantive content, do not include in toc #consider + image_= h[:image_] || ((defined? o.image_) ? o.image_ : false) #Bool, images? (processing optimization) + ocn_=if h[:ocn_].nil? then ((defined? o.ocn_) ? o.ocn_ : true) #Bool? no ocn, non-substantive content, do not include in toc #consider else h[:ocn_] end - digest= h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, either sha256 or md5 - tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use + digest= h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, either sha256 or md5 + tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use @of,@is,@name,@tags,@obj,@indent,@hang,@bullet_,@idx,@ocn,@odv,@osp,@parent,@image_,@note_,@ocn_,@digest,@tmp=of,is,name,tags,obj,indent,hang,bullet_,idx,ocn,odv,osp,parent,image_,note_,ocn_,digest,tmp self end @@ -231,95 +231,95 @@ module SiSU_DAL_DocumentStructure def code(h,o=nil) of= @of #String, classification - group #alt 'code' is= :code #String, classification - specific type - tags= h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any - obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content - idx= h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? - ocn= h[:ocn] || ((defined? o.ocn) ? o.ocn : nil) #Integer, sequential on substantive-content objects - odv= h[:odv] || ((defined? o.odv) ? o.odv : nil) - osp= h[:osp] || ((defined? o.osp) ? o.osp : nil) - parent= h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] - number_= h[:number_] || ((defined? o.number_) ? o.number_ : false) #Bool, numbered or not? - note_= h[:note_] || ((defined? o.note_) ? o.note_ : false) #Bool, endnotes/footnotes? (processing optimization) - ocn_= if h[:ocn_].nil?; ((defined? o.ocn_) ? o.ocn_ : true) #Bool? no ocn, non-substantive content, do not include in toc #consider + tags= h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any + obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content + idx= h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? + ocn= h[:ocn] || ((defined? o.ocn) ? o.ocn : nil) #Integer, sequential on substantive-content objects + odv= h[:odv] || ((defined? o.odv) ? o.odv : nil) + osp= h[:osp] || ((defined? o.osp) ? o.osp : nil) + parent= h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] + number_= h[:number_] || ((defined? o.number_) ? o.number_ : false) #Bool, numbered or not? + note_= h[:note_] || ((defined? o.note_) ? o.note_ : false) #Bool, endnotes/footnotes? (processing optimization) + ocn_= if h[:ocn_].nil? then ((defined? o.ocn_) ? o.ocn_ : true) #Bool? no ocn, non-substantive content, do not include in toc #consider else h[:ocn_] end - digest= h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, either sha256 or md5 - tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use + digest= h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, either sha256 or md5 + tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use @of,@is,@tags,@obj,@idx,@ocn,@odv,@osp,@parent,@number_,@note_,@ocn_,@digest,@tmp=of,is,tags,obj,idx,ocn,odv,osp,parent,number_,note_,ocn_,digest,tmp self end def block(h,o=nil) of= @of #String, classification - group is= :block #String, classification - specific type - tags= h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any - obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content - idx= h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? - ocn= h[:ocn] || ((defined? o.ocn) ? o.ocn : nil) #Integer, sequential on substantive-content objects - odv= h[:odv] || ((defined? o.odv) ? o.odv : nil) - osp= h[:osp] || ((defined? o.osp) ? o.osp : nil) - parent= h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] - note_= h[:note_] || ((defined? o.note_) ? o.note_ : false) #Bool, endnotes/footnotes? (processing optimization) - ocn_= if h[:ocn_].nil?; ((defined? o.ocn_) ? o.ocn_ : true) #Bool? no ocn, non-substantive content, do not include in toc #consider + tags= h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any + obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content + idx= h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? + ocn= h[:ocn] || ((defined? o.ocn) ? o.ocn : nil) #Integer, sequential on substantive-content objects + odv= h[:odv] || ((defined? o.odv) ? o.odv : nil) + osp= h[:osp] || ((defined? o.osp) ? o.osp : nil) + parent= h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] + note_= h[:note_] || ((defined? o.note_) ? o.note_ : false) #Bool, endnotes/footnotes? (processing optimization) + ocn_= if h[:ocn_].nil? then ((defined? o.ocn_) ? o.ocn_ : true) #Bool? no ocn, non-substantive content, do not include in toc #consider else h[:ocn_] end - digest= h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, either sha256 or md5 - tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use + digest= h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, either sha256 or md5 + tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use @of,@is,@tags,@obj,@idx,@ocn,@odv,@osp,@parent,@note_,@ocn_,@digest,@tmp=of,is,tags,obj,idx,ocn,odv,osp,parent,note_,ocn_,digest,tmp self end def group(h,o=nil) of= @of #String, classification - group is= :group #String, classification - specific type - tags= h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any - obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content - idx= h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? - ocn= h[:ocn] || ((defined? o.ocn) ? o.ocn : nil) #Integer, sequential on substantive-content objects - odv= h[:odv] || ((defined? o.odv) ? o.odv : nil) - osp= h[:osp] || ((defined? o.osp) ? o.osp : nil) - parent= h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] - note_= h[:note_] || ((defined? o.note_) ? o.note_ : false) #Bool, endnotes/footnotes? (processing optimization) - ocn_= if h[:ocn_].nil?; ((defined? o.ocn_) ? o.ocn_ : true) #Bool? no ocn, non-substantive content, do not include in toc #consider + tags= h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any + obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content + idx= h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? + ocn= h[:ocn] || ((defined? o.ocn) ? o.ocn : nil) #Integer, sequential on substantive-content objects + odv= h[:odv] || ((defined? o.odv) ? o.odv : nil) + osp= h[:osp] || ((defined? o.osp) ? o.osp : nil) + parent= h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] + note_= h[:note_] || ((defined? o.note_) ? o.note_ : false) #Bool, endnotes/footnotes? (processing optimization) + ocn_= if h[:ocn_].nil? then ((defined? o.ocn_) ? o.ocn_ : true) #Bool? no ocn, non-substantive content, do not include in toc #consider else h[:ocn_] end - digest= h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, either sha256 or md5 - tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use + digest= h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, either sha256 or md5 + tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use @of,@is,@tags,@obj,@idx,@ocn,@odv,@osp,@parent,@note_,@ocn_,@digest,@tmp=of,is,tags,obj,idx,ocn,odv,osp,parent,note_,ocn_,digest,tmp self end def alt(h,o=nil) #see block of= @of #String, classification - group is= :alt #String, classification - specific type - tags= h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any - obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content - idx= h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? - ocn= h[:ocn] || ((defined? o.ocn) ? o.ocn : nil) #Integer, sequential on substantive-content objects - odv= h[:odv] || ((defined? o.odv) ? o.odv : nil) - osp= h[:osp] || ((defined? o.osp) ? o.osp : nil) - parent= h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] - note_= h[:note_] || ((defined? o.note_) ? o.note_ : false) #Bool, endnotes/footnotes? (processing optimization) - ocn_= if h[:ocn_].nil?; ((defined? o.ocn_) ? o.ocn_ : true) #Bool? no ocn, non-substantive content, do not include in toc #consider + tags= h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any + obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content + idx= h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? + ocn= h[:ocn] || ((defined? o.ocn) ? o.ocn : nil) #Integer, sequential on substantive-content objects + odv= h[:odv] || ((defined? o.odv) ? o.odv : nil) + osp= h[:osp] || ((defined? o.osp) ? o.osp : nil) + parent= h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] + note_= h[:note_] || ((defined? o.note_) ? o.note_ : false) #Bool, endnotes/footnotes? (processing optimization) + ocn_= if h[:ocn_].nil? then ((defined? o.ocn_) ? o.ocn_ : true) #Bool? no ocn, non-substantive content, do not include in toc #consider else h[:ocn_] end - digest= h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, either sha256 or md5 - tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use + digest= h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, either sha256 or md5 + tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use @of,@is,@tags,@obj,@idx,@ocn,@odv,@osp,@parent,@note_,@ocn_,@digest,@tmp=of,is,tags,obj,idx,ocn,odv,osp,parent,note_,ocn_,digest,tmp self end def verse(h,o=nil) #part of poem decide how you deal with this of= @of #String, classification - group is= :verse #String, classification - specific type - tags= h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any - obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content - idx= h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? - ocn= h[:ocn] || ((defined? o.ocn) ? o.ocn : nil) #Integer, sequential on substantive-content objects - odv= h[:odv] || ((defined? o.odv) ? o.odv : nil) - osp= h[:osp] || ((defined? o.osp) ? o.osp : nil) - parent= h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] - ocn_= if h[:ocn_].nil?; ((defined? o.ocn_) ? o.ocn_ : true) #Bool? no ocn, non-substantive content, do not include in toc #consider + tags= h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any + obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content + idx= h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? + ocn= h[:ocn] || ((defined? o.ocn) ? o.ocn : nil) #Integer, sequential on substantive-content objects + odv= h[:odv] || ((defined? o.odv) ? o.odv : nil) + osp= h[:osp] || ((defined? o.osp) ? o.osp : nil) + parent= h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] + ocn_= if h[:ocn_].nil? then ((defined? o.ocn_) ? o.ocn_ : true) #Bool? no ocn, non-substantive content, do not include in toc #consider else h[:ocn_] end - digest= h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, either sha256 or md5 - tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use + digest= h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, either sha256 or md5 + tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use @of,@is,@tags,@obj,@idx,@ocn,@odv,@osp,@parent,@note_,@ocn_,@digest,@tmp=of,is,tags,obj,idx,ocn,odv,osp,parent,note_,ocn_,digest,tmp @h=nil self @@ -335,22 +335,22 @@ module SiSU_DAL_DocumentStructure def table(h,o=nil) of= @of #String, classification - group is= :table #String, classification - specific type - tags= h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any - cols= h[:cols] || ((defined? o.cols) ? o.cols : nil) - widths= h[:widths] || ((defined? o.widths) ? o.widths : nil) - obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content - idx= h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? - ocn= h[:ocn] || ((defined? o.ocn) ? o.ocn : nil) #Integer, sequential on substantive-content objects - odv= h[:odv] || ((defined? o.odv) ? o.odv : nil) - osp= h[:osp] || ((defined? o.osp) ? o.osp : nil) - parent= h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] - head_= h[:head_] || ((defined? o.head_) ? o.head_ : false) - note_= h[:note_] || ((defined? o.note_) ? o.note_ : false) #Bool, endnotes/footnotes? (processing optimization) - ocn_=if h[:ocn_].nil?; ((defined? o.ocn_) ? o.ocn_ : true) #Bool? no ocn, non-substantive content, do not include in toc #consider + tags= h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any + cols= h[:cols] || ((defined? o.cols) ? o.cols : nil) + widths= h[:widths] || ((defined? o.widths) ? o.widths : nil) + obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content + idx= h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? + ocn= h[:ocn] || ((defined? o.ocn) ? o.ocn : nil) #Integer, sequential on substantive-content objects + odv= h[:odv] || ((defined? o.odv) ? o.odv : nil) + osp= h[:osp] || ((defined? o.osp) ? o.osp : nil) + parent= h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] + head_= h[:head_] || ((defined? o.head_) ? o.head_ : false) + note_= h[:note_] || ((defined? o.note_) ? o.note_ : false) #Bool, endnotes/footnotes? (processing optimization) + ocn_=if h[:ocn_].nil? then ((defined? o.ocn_) ? o.ocn_ : true) #Bool? no ocn, non-substantive content, do not include in toc #consider else h[:ocn_] end - digest= h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, either sha256 or md5 - tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use + digest= h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, either sha256 or md5 + tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use @of,@is,@tags,@cols,@widths,@obj,@idx,@ocn,@odv,@osp,@parent,@head_,@note_,@ocn_,@digest,@tmp=of,is,tags,cols,widths,obj,idx,ocn,odv,osp,parent,head_,note_,ocn_,digest,tmp self end @@ -365,20 +365,20 @@ module SiSU_DAL_DocumentStructure def image(h,o=nil) #not yet used, and what of a paragraph containing several images, consider of= @of #String, classification - group is= :image #String, classification - specific type - tags= h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any - obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content - size= h[:size] || ((defined? o.size) ? o.size : nil) - idx= h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? - ocn= h[:ocn] || ((defined? o.ocn) ? o.ocn : nil) #Integer, sequential on substantive-content objects - odv= h[:odv] || ((defined? o.odv) ? o.odv : nil) - osp= h[:osp] || ((defined? o.osp) ? o.osp : nil) - parent= h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] - note_= h[:note_] || ((defined? o.note_) ? o.note_ : false) #Bool, endnotes/footnotes? (processing optimization) - ocn_=if h[:ocn_].nil?; ((defined? o.ocn_) ? o.ocn_ : true) #Bool? no ocn, non-substantive content, do not include in toc #consider + tags= h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any + obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content + size= h[:size] || ((defined? o.size) ? o.size : nil) + idx= h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? + ocn= h[:ocn] || ((defined? o.ocn) ? o.ocn : nil) #Integer, sequential on substantive-content objects + odv= h[:odv] || ((defined? o.odv) ? o.odv : nil) + osp= h[:osp] || ((defined? o.osp) ? o.osp : nil) + parent= h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] + note_= h[:note_] || ((defined? o.note_) ? o.note_ : false) #Bool, endnotes/footnotes? (processing optimization) + ocn_=if h[:ocn_].nil? then ((defined? o.ocn_) ? o.ocn_ : true) #Bool? no ocn, non-substantive content, do not include in toc #consider else h[:ocn_] end - digest= h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, either sha256 or md5 - tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use + digest= h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, either sha256 or md5 + tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use @of,@is,@tags,@obj,@size,@idx,@ocn,@odv,@osp,@parent,@note_,@ocn_,@digest,@tmp=of,is,tags,obj,size,idx,ocn,odv,osp,parent,note_,ocn_,digest,tmp self end @@ -392,12 +392,12 @@ module SiSU_DAL_DocumentStructure def xml_dom(h,o=nil) of= @of #String, classification - group is= :xml_dom #String, classification - specific type - obj= h[:obj] || ((defined? o.obj) ? o.obj : '') #String, text content - lv= h[:lv] || ((defined? o.lv) ? o.lv : nil) #Alpha-numeric, document structure as used in markup, A-C then 1-6 - ln= h[:ln] || ((defined? o.ln) ? o.ln : nil) #Integer, document structure level, for convenience in processing 1-9 - node= h[:node] || ((defined? o.node) ? o.node : nil) #[Node relationship doc structure info] - status= h[:status] || ((defined? o.status) ? o.status : nil) #tag status open or close - tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use + obj= h[:obj] || ((defined? o.obj) ? o.obj : '') #String, text content + lv= h[:lv] || ((defined? o.lv) ? o.lv : nil) #Alpha-numeric, document structure as used in markup, A-C then 1-6 + ln= h[:ln] || ((defined? o.ln) ? o.ln : nil) #Integer, document structure level, for convenience in processing 1-9 + node= h[:node] || ((defined? o.node) ? o.node : nil) #[Node relationship doc structure info] + status= h[:status] || ((defined? o.status) ? o.status : nil) #tag status open or close + tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use @of,@is,@obj,@status,@node,@lv,@ln,@tmp=of,is,obj,status,node,lv,ln,tmp self end @@ -411,8 +411,8 @@ module SiSU_DAL_DocumentStructure def comment(h,o=nil) of= @of #String, classification - group is= :comment #String, classification - specific type - obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content - tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use + obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content + tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use @of,@is,@obj,@tmp=of,is,obj,tmp self end @@ -426,16 +426,16 @@ module SiSU_DAL_DocumentStructure def break(h,o=nil) #decide how to deal with, perhaps no obj? of= @of #String, classification - group is= :break #String, classification - specific type - obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content - tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use + obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content + tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use @of,@is,@obj,@tmp=of,is,obj,tmp self end def insert(h,o=nil) #decide how to deal with, could mimic paragraph? of= @of #String, classification - group is= :insert #String, classification - specific type - obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content - tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use + obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content + tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use @of,@is,@obj,@tmp=of,is,obj,tmp self end diff --git a/lib/sisu/v3/dal_numbering.rb b/lib/sisu/v3/dal_numbering.rb index c0bb4cb1..4c7ad642 100644 --- a/lib/sisu/v3/dal_numbering.rb +++ b/lib/sisu/v3/dal_numbering.rb @@ -435,9 +435,9 @@ module SiSU_DAL_Numbering and dob.obj !~/\A\s*\Z/m \ and dob.is !=:layout @md.set_heading_seg=true - head=if @md.title.main ; dob.ln,dob.name,dob.obj=4,'seg',@md.title.main - else dob.ln,dob.name,dob.obj=4,'seg','[segment]' - end + head=@md.title.main \ + ? (dob.ln,dob.name,dob.obj=4,'seg',@md.title.main) + : (dob.ln,dob.name,dob.obj=4,'seg','[segment]') @tuned_file << head end end diff --git a/lib/sisu/v3/defaults.rb b/lib/sisu/v3/defaults.rb index 0c45ecdd..47e3c970 100644 --- a/lib/sisu/v3/defaults.rb +++ b/lib/sisu/v3/defaults.rb @@ -738,9 +738,9 @@ module SiSU_Viz gsub(/\(/,'(?:') # avoid need to escape use of brackets within regex provided m='\b(' + r + ')\b' make[:str] - make[:regx]=if x =~/i/; /#{m}/i - else /#{m}/ - end + make[:regx]=(x =~/i/) \ + ? (/#{m}/i) + : (/#{m}/) else nil end end @@ -759,9 +759,9 @@ module SiSU_Viz gsub(/\(/,'(?:') # avoid need to escape use of brackets within regex provided m='\b(' + r + ')\b' make[:str] - make[:regx]=if x =~/i/; /#{m}/i - else /#{m}/ - end + make[:regx]=(x =~/i/) \ + ? (/#{m}/i) + : (/#{m}/) else nil end make diff --git a/lib/sisu/v3/digests.rb b/lib/sisu/v3/digests.rb index 5ffabb58..129b6b10 100644 --- a/lib/sisu/v3/digests.rb +++ b/lib/sisu/v3/digests.rb @@ -208,9 +208,9 @@ module SiSU_DigestView if image_source para_image = image_source + '/' + i @image_name << i - @image_dgst << if @dg =~/^sha(?:2|256)$/; sys.sha256(para_image) - else sys.md5(para_image) - end + @image_dgst << (@dg =~/^sha(?:2|256)$/) \ + ? sys.sha256(para_image) + : sys.md5(para_image) else @image_name << ' '*16 + i + ' [image missing]' @image_dgst << '' diff --git a/lib/sisu/v3/epub.rb b/lib/sisu/v3/epub.rb index 06021574..a3364606 100644 --- a/lib/sisu/v3/epub.rb +++ b/lib/sisu/v3/epub.rb @@ -357,9 +357,9 @@ module SiSU_EPUB end else @@toc[:scr] << '
' - link=if dob.ln; dob.ln - else '' - end + link=(dob.ln) \ + ? dob.ln + : '' %{
#{linkname}} end txt_obj={ txt: title } diff --git a/lib/sisu/v3/epub_format.rb b/lib/sisu/v3/epub_format.rb index c08ae492..06a6d623 100644 --- a/lib/sisu/v3/epub_format.rb +++ b/lib/sisu/v3/epub_format.rb @@ -1740,9 +1740,9 @@ WOK end end def links_guide_open(type='horizontal') - if type=='vertical'; links_guide_vertical_open - else links_guide_horizontal_open - end + (type=='vertical') \ + ? links_guide_vertical_open + : links_guide_horizontal_open end def prefix_a end @@ -1853,12 +1853,12 @@ WOK if @format and not @format.empty? if @format=~/^\d:(\S+)/ #need more reliable marker #if @format =~ /#{Rx[:lv]}/ headname=$1 #format[/\d~(\S+)/m,1] - @headname=if headname =~/^[a-zA-Z]/; %{} #consider: h_#{headname} - else %{} - end - @headname=if headname =~/^[a-zA-Z]/; %{} #consider: h_#{headname} - else %{} - end + @headname=(headname =~/^[a-zA-Z]/) \ + ? %{} + : %{} + @headname=(headname =~/^[a-zA-Z]/) \ + ? %{} + : %{} end end elsif t_o.class.inspect =~/Object/ diff --git a/lib/sisu/v3/epub_segments.rb b/lib/sisu/v3/epub_segments.rb index 57e6580b..0f45fe23 100644 --- a/lib/sisu/v3/epub_segments.rb +++ b/lib/sisu/v3/epub_segments.rb @@ -298,9 +298,9 @@ WOK and @md.creator.author @author=%{#{@md.creator.author}\n} end - ocn=if @@heading1[/.+?#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#{@dp}:#{@dp}#{Mx[:id_c]}$/]; $1 #fix - else '' - end + ocn=(@@heading1[/.+?#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#{@dp}:#{@dp}#{Mx[:id_c]}$/]) \ + ? $1 + : '' @p_num=SiSU_EPUB_Format::ParagraphNumber.new(@md,ocn) txt_obj={ txt: @@heading1, ocn_display: @p_num.ocn_display } format_seg=SiSU_EPUB_Format::FormatSeg.new(@md,txt_obj) @@ -309,9 +309,9 @@ WOK end if @@is2==1 heading2=@@heading2 - ocn=if heading2[/.+?#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#{@dp}:#{@dp}#{Mx[:id_c]}$/]; $1 #fix - else '' - end + ocn=(heading2[/.+?#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#{@dp}:#{@dp}#{Mx[:id_c]}$/]) \ + ? $1 + : '' @p_num=SiSU_EPUB_Format::ParagraphNumber.new(@md,ocn) txt_obj={ txt: heading2, ocn_display: @p_num.ocn_display } format_seg=SiSU_EPUB_Format::FormatSeg.new(@md,txt_obj) @@ -320,9 +320,9 @@ WOK end if @@is3==1 heading3=@@heading3 - ocn=if heading3[/.+?#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#{@dp}:#{@dp}#{Mx[:id_c]}$/]; $1 #fix - else '' - end + ocn=(heading3[/.+?#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#{@dp}:#{@dp}#{Mx[:id_c]}$/]) \ + ? $1 + : '' @p_num=SiSU_EPUB_Format::ParagraphNumber.new(@md,ocn) txt_obj={ txt: heading3, ocn_display: @p_num.ocn_display } format_seg=SiSU_EPUB_Format::FormatSeg.new(@md,txt_obj) @@ -331,9 +331,9 @@ WOK end if @@is4==1 heading4=@@heading4 - ocn=if heading4[/.+?#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#{@dp}:#{@dp}#{Mx[:id_c]}$/]; $1 #fix - else '' - end + ocn=(heading4[/.+?#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#{@dp}:#{@dp}#{Mx[:id_c]}$/]) \ + ? $1 + : '' @p_num=SiSU_EPUB_Format::ParagraphNumber.new(@md,ocn) txt_obj={ txt: heading4, ocn_display: @p_num.ocn_display } format_seg=SiSU_EPUB_Format::FormatSeg.new(@md,txt_obj) diff --git a/lib/sisu/v3/help.rb b/lib/sisu/v3/help.rb index 9ca8ef20..421594fb 100644 --- a/lib/sisu/v3/help.rb +++ b/lib/sisu/v3/help.rb @@ -63,9 +63,9 @@ module SiSU_Help require_relative 'i18n' # i18n.rb def initialize(request='',color='') @request,@color=request,color - if color =~/color_off/; @cX=SiSU_Screen::Ansi.new('k').cX - else @cX=SiSU_Screen::Ansi.new('yes').cX - end + @cX=(color =~/color_off/) \ + ? (SiSU_Screen::Ansi.new('k').cX) + : (SiSU_Screen::Ansi.new('yes').cX) fns='help_example_dummy_file_name.sst' @env=SiSU_Env::InfoEnv.new(fns) @db=SiSU_Env::InfoDb.new @@ -909,9 +909,9 @@ WOK end else bin,rc='false','false' end - if program; "#{@cX.blue}#{program}#{@cX.off} bin: #{@cX.brown}#{bin}#{@cX.off} rc: #{@cX.brown}#{rc}#{@cX.off}" - else "bin: #{@cX.brown}#{bin}#{@cX.off} rc: #{@cX.brown}#{rc}#{@cX.off}" - end + (program) \ + ? ("#{@cX.blue}#{program}#{@cX.off} bin: #{@cX.brown}#{bin}#{@cX.off} rc: #{@cX.brown}#{rc}#{@cX.off}") + : ("bin: #{@cX.brown}#{bin}#{@cX.off} rc: #{@cX.brown}#{rc}#{@cX.off}") end def sisu_version version=SiSU_Env::InfoVersion.instance.get_version @@ -925,40 +925,40 @@ WOK @ls=leading_spaces=' '*49 @rhost=SiSU_Env::InfoRemoteHost.new.rhost def r1 - if @rhost.r1; @rhost.r1 + "\n" - else '' - end + (@rhost.r1) \ + ? @rhost.r1 + "\n" + : '' end def r2 - if @rhost.r2; @ls + @rhost.r2 + "\n" - else '' - end + (@rhost.r2) \ + ? @ls + @rhost.r2 + "\n" + : '' end def r3 - if @rhost.r3; @ls + @rhost.r3 + "\n" - else '' - end + (@rhost.r3) \ + ? @ls + @rhost.r3 + "\n" + : '' end def r4 - if @rhost.r4; @ls + @rhost.r4 + "\n" - else '' - end + (@rhost.r4) \ + ? @ls + @rhost.r4 + "\n" + : '' end def r5 - if @rhost.r5; @ls + @rhost.r5 + "\n" - else '' - end + (@rhost.r5) \ + ? @ls + @rhost.r5 + "\n" + : '' end def r6 - if @rhost.r6; @ls + @rhost.r6 + "\n" - else '' - end + (@rhost.r6) \ + ? @ls + @rhost.r6 + "\n" + : '' end def note msg='(remote settings user and host set in sisurc.yml under remote:)' - if @rhost.r1; @ls + msg - else msg - end + (@rhost.r1) \ + ? @ls + msg + : msg end self end diff --git a/lib/sisu/v3/html.rb b/lib/sisu/v3/html.rb index 100916ff..3a2f8a0d 100644 --- a/lib/sisu/v3/html.rb +++ b/lib/sisu/v3/html.rb @@ -90,9 +90,9 @@ module SiSU_HTML @env=@particulars.env loc=@env.url.output_tell unless @opt.cmd =~/q/ - tool=if @opt.cmd =~/[MVvz]/; "#{@env.program.web_browser} file://#{@md.file.output_path.html_seg.dir}/#{@md.file.base_filename.html_segtoc}" - else "[#{@opt.f_pth[:lng_is]}] #{@opt.fno}" - end + tool=(@opt.cmd =~/[MVvz]/) \ + ? ("#{@env.program.web_browser} file://#{@md.file.output_path.html_seg.dir}/#{@md.file.base_filename.html_segtoc}") + : ("[#{@opt.f_pth[:lng_is]}] #{@opt.fno}") @opt.cmd=~/[MVvz]/ \ ? SiSU_Screen::Ansi.new(@opt.cmd,'HTML',tool).green_hi_blue : SiSU_Screen::Ansi.new(@opt.cmd,'HTML',tool).green_title_hi @@ -167,9 +167,9 @@ module SiSU_HTML and @md.lnk @md.lnk.each do |l| if defined? l[:say] - target=if l[:url] !~/^\.(\.)?\//; 'external' - else '_top' - end + target=(l[:url] !~/^\.(\.)?\//) \ + ? 'external' + : '_top' s_lnk_url,s_lnk_lnk=l[:url],l[:say] txt_obj={ lnk_url: s_lnk_url, lnk_txt: s_lnk_lnk, target: target } lev_dob_ocn=SiSU_HTML_Format::FormatToc.new(@md,txt_obj) @@ -350,9 +350,9 @@ WOK end else @@toc[:scr] << '
' - link=if dob.ln; dob.ln - else '' - end + link=(dob.ln) \ + ? dob.ln + : '' %{#{linkname}} end txt_obj={ txt: title } diff --git a/lib/sisu/v3/html_format.rb b/lib/sisu/v3/html_format.rb index 85e47e0b..1b950358 100644 --- a/lib/sisu/v3/html_format.rb +++ b/lib/sisu/v3/html_format.rb @@ -454,9 +454,9 @@ WOK } end def links_guide_open(type='horizontal') - if type=='vertical'; links_guide_vertical_open - else links_guide_horizontal_open - end + (type=='vertical') \ + ? links_guide_vertical_open + : links_guide_horizontal_open end def links_guide_close insert='' @@ -957,9 +957,9 @@ WOK def headname #check whether used hn=if @t_o.is ==:heading \ and not @t_o.name.empty? #determine use - hn=if @t_o.is ==:heading; %{} - else %{} - end + hn=(@t_o.is ==:heading) \ + ? (%{}) + : (%{}) else nil end hn diff --git a/lib/sisu/v3/html_segments.rb b/lib/sisu/v3/html_segments.rb index b527eaba..bb77cb36 100644 --- a/lib/sisu/v3/html_segments.rb +++ b/lib/sisu/v3/html_segments.rb @@ -374,9 +374,9 @@ module SiSU_HTML_Seg if @title_banner_ @@seg[:headings] << format_head_seg.title_banner(@md.title.main,@md.title.sub,@author).gsub(clean,'') end - ocn=if @@heading1[/.+?#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#{@dp}:#{@dp}#{Mx[:id_c]}$/]; $1 #fix - else '' - end + ocn=(@@heading1[/.+?#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#{@dp}:#{@dp}#{Mx[:id_c]}$/]) \ + ? $1 + : '' @p_num=SiSU_HTML_Format::ParagraphNumber.new(@md,ocn) txt_obj={ txt: @@heading1, ocn_display: @p_num.ocn_display } format_seg=SiSU_HTML_Format::FormatSeg.new(@md,txt_obj) @@ -385,9 +385,9 @@ module SiSU_HTML_Seg end if @@is2==1 heading2=@@heading2 - ocn=if heading2[/.+?#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#{@dp}:#{@dp}#{Mx[:id_c]}$/]; $1 #fix - else '' - end + ocn=(heading2[/.+?#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#{@dp}:#{@dp}#{Mx[:id_c]}$/]) \ + ? $1 + : '' @p_num=SiSU_HTML_Format::ParagraphNumber.new(@md,ocn) txt_obj={ txt: heading2, ocn_display: @p_num.ocn_display } format_seg=SiSU_HTML_Format::FormatSeg.new(@md,txt_obj) @@ -396,9 +396,9 @@ module SiSU_HTML_Seg end if @@is3==1 heading3=@@heading3 - ocn=if heading3[/.+?#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#{@dp}:#{@dp}#{Mx[:id_c]}$/]; $1 #fix - else '' - end + ocn=(heading3[/.+?#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#{@dp}:#{@dp}#{Mx[:id_c]}$/]) \ + ? $1 + : '' @p_num=SiSU_HTML_Format::ParagraphNumber.new(@md,ocn) txt_obj={ txt: heading3, ocn_display: @p_num.ocn_display } format_seg=SiSU_HTML_Format::FormatSeg.new(@md,txt_obj) @@ -407,9 +407,9 @@ module SiSU_HTML_Seg end if @@is4==1 heading4=@@heading4 - ocn=if heading4[/.+?#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#{@dp}:#{@dp}#{Mx[:id_c]}$/]; $1 #fix - else '' - end + ocn=(heading4[/.+?#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#{@dp}:#{@dp}#{Mx[:id_c]}$/]) \ + ? $1 + : '' @p_num=SiSU_HTML_Format::ParagraphNumber.new(@md,ocn) txt_obj={ txt: heading4, ocn_display: @p_num.ocn_display } format_seg=SiSU_HTML_Format::FormatSeg.new(@md,txt_obj) diff --git a/lib/sisu/v3/manifest.rb b/lib/sisu/v3/manifest.rb index 20983d7f..446a8716 100644 --- a/lib/sisu/v3/manifest.rb +++ b/lib/sisu/v3/manifest.rb @@ -155,9 +155,9 @@ module SiSU_Manifest end def summarize_sources(id,file,pth,rel,url) sys=SiSU_Env::SystemCall.new - dgst =if @dg =~/^sha(?:2|256)$/; sys.sha256("#{pth}/#{file}") - else sys.md5("#{pth}/#{file}") - end + dgst=(@dg =~/^sha(?:2|256)$/) \ + ? sys.sha256("#{pth}/#{file}") + : sys.md5("#{pth}/#{file}") SiSU_Screen::Ansi.new(@md.opt.cmd,"#{dgst[1]} #{file}").warn if @md.opt.cmd =~/[vVM]/ size=(File.size("#{pth}/#{file}")/1024.00).to_s kb=/([0-9]+\.[0-9]{0,1})/m.match(size)[1] @@ -749,9 +749,9 @@ WOK and @md.lnk @md.lnk.each do |l| if defined? l[:say] - target=if l[:url] !~/^\.(\.)?\//; 'external' - else '_top' - end + target=(l[:url] !~/^\.(\.)?\//) \ + ? 'external' + : '_top' url,lnk=l[:url],l[:say] unless url.nil? \ or url.empty? diff --git a/lib/sisu/v3/manpage.rb b/lib/sisu/v3/manpage.rb index d292900c..31a64a57 100644 --- a/lib/sisu/v3/manpage.rb +++ b/lib/sisu/v3/manpage.rb @@ -136,9 +136,9 @@ module SiSU_Manpage end notes=@n.flatten notes.each do |e| - util=if e.to_s =~/^\[[\d*+]+\]:/; SiSU_TextUtils::Wrap.new(e.to_s,78,4,1) - else SiSU_TextUtils::Wrap.new(e.to_s,78,0,1) - end + util=(e.to_s =~/^\[[\d*+]+\]:/) \ + ? (SiSU_TextUtils::Wrap.new(e.to_s,78,4,1)) + : (SiSU_TextUtils::Wrap.new(e.to_s,78,0,1)) wrap=util.line_wrap wrap=if wrap =~ /^\s*[\d*+]+\s+.+?\s*\Z/m wrap.gsub(/(^| |#{Mx[:nbsp]}|\s|\*)\\\*/,'\1\\\\\*'). #man page requires diff --git a/lib/sisu/v3/odf_format.rb b/lib/sisu/v3/odf_format.rb index cd998f43..62eae47a 100644 --- a/lib/sisu/v3/odf_format.rb +++ b/lib/sisu/v3/odf_format.rb @@ -167,9 +167,9 @@ module SiSU_ODF_Format end end def table_head_open(count) - type=if @dob.head_; 1 - else 2 - end + type=(@dob.head_) \ + ? 1 + : 2 alpha=case @dob.cols when 1; 'A' when 2; 'B' diff --git a/lib/sisu/v3/param.rb b/lib/sisu/v3/param.rb index f6084aab..dbcbcbab 100644 --- a/lib/sisu/v3/param.rb +++ b/lib/sisu/v3/param.rb @@ -1453,9 +1453,9 @@ module SiSU_Param # gsub(/:?C/,'3'). # gsub(/:?B/,'2'). # gsub(/:?A/,'1') - translate=if translate =~/^\d+$/; translate.to_i - else translate - end + translate=(translate =~/^\d+$/) \ + ? translate.to_i + : translate else nil end end diff --git a/lib/sisu/v3/qrcode.rb b/lib/sisu/v3/qrcode.rb index d05bf442..d668c813 100644 --- a/lib/sisu/v3/qrcode.rb +++ b/lib/sisu/v3/qrcode.rb @@ -166,9 +166,9 @@ WOK end def summarize_sources(id,file,pth,rel,url) sys=SiSU_Env::SystemCall.new - dgst =if @dg =~/^sha(?:2|256)$/; sys.sha256("#{pth}/#{file}") - else sys.md5("#{pth}/#{file}") - end + dgst=(@dg =~/^sha(?:2|256)$/) \ + ? (sys.sha256("#{pth}/#{file}")) + : (sys.md5("#{pth}/#{file}")) SiSU_Screen::Ansi.new(@md.opt.cmd,"#{dgst[1]} #{file}").warn if @md.opt.cmd =~/[vVM]/ size=(File.size("#{pth}/#{file}")/1024.00).to_s kb=/([0-9]+\.[0-9]{0,1})/m.match(size)[1] diff --git a/lib/sisu/v3/screen_text_color.rb b/lib/sisu/v3/screen_text_color.rb index 67022087..cef15585 100644 --- a/lib/sisu/v3/screen_text_color.rb +++ b/lib/sisu/v3/screen_text_color.rb @@ -69,16 +69,11 @@ module SiSU_Screen @color_instruct=txt[0] flag=SiSU_Env::InfoProcessingFlag.new if @cmd - if flag.color #set default colors on or off -c acts as toggle against this default, if default is off -c turns on, if default is on -c turns off - @use_color=if @cmd =~/c/; false - else true - end - else - @use_color=if @cmd =~/c/; true - else false - end - end - if @cmd =~/k/; @use_color=false + #set default colors on or off -c acts as toggle against this default, if default is off -c turns on, if default is on -c turns off + @use_color=(flag.color) \ + ? ((@cmd =~/c/) ? false : true) + : ((@cmd =~/c/) ? true : false) + if @cmd =~/k/ then @use_color=false end else @use_color=false end diff --git a/lib/sisu/v3/sitemaps.rb b/lib/sisu/v3/sitemaps.rb index 86a8e2fb..d45af899 100644 --- a/lib/sisu/v3/sitemaps.rb +++ b/lib/sisu/v3/sitemaps.rb @@ -97,10 +97,9 @@ module SiSU_Sitemaps end end def make_file(path,filename) - if File.writable?("#{path}/."); File.new("#{path}/#{filename}",'w+') - else - SiSU_Screen::Ansi.new('',"is the file or directory writable?, could not create #{filename}").warn - end + (File.writable?("#{path}/.")) \ + ? (File.new("#{path}/#{filename}",'w+')) + : (SiSU_Screen::Ansi.new('',"is the file or directory writable?, could not create #{filename}").warn) end def output_map(sitemap) path=@md.file.output_path.sitemaps.dir diff --git a/lib/sisu/v3/sst_convert_markup.rb b/lib/sisu/v3/sst_convert_markup.rb index 6b224ddb..47426490 100644 --- a/lib/sisu/v3/sst_convert_markup.rb +++ b/lib/sisu/v3/sst_convert_markup.rb @@ -272,13 +272,13 @@ WOK end end end - if y=~/^\s*$/; @empty1=true - else @empty1=false - end + @empty1=(y=~/^\s*$/) \ + ? true + : false @file.puts y unless (@empty1==true and @empty2==true) - if y=~/^\s*$/; @empty2=true - else @empty2=false - end + @empty2=(y=~/^\s*$/) \ + ? true + : false end @file.close else puts "NO conversion match in #{i}" unless @opt.cmd=~/q/ diff --git a/lib/sisu/v3/sst_do_inline_footnotes.rb b/lib/sisu/v3/sst_do_inline_footnotes.rb index 4ceb54fa..08c599ce 100644 --- a/lib/sisu/v3/sst_do_inline_footnotes.rb +++ b/lib/sisu/v3/sst_do_inline_footnotes.rb @@ -107,9 +107,9 @@ module SiSU_ConvertFootnotes @@fns=@opt.fns @@dal_array=[] end - dal=if @@dal_array.empty?; read_fnm - else @@dal_array.dup #check - end + dal=(@@dal_array.empty?) \ + ? read_fnm + : @@dal_array.dup #check rescue SiSU_Errors::InfoError.new($!,$@,@opt.cmd,@opt.fns).error do __LINE__.to_s + ':' + __FILE__ @@ -145,9 +145,9 @@ module SiSU_ConvertFootnotes end def read_fnm dal=[] - dal=if FileTest.file?(@fnm); File.open(@fnm){ |f| dal=Marshal.load(f)} - else SiSU_ConvertFootnotes::Source.new(@opt).create_dal #watch - end + dal=(FileTest.file?(@fnm)) \ + ? (File.open(@fnm){ |f| dal=Marshal.load(f)}) + : (SiSU_ConvertFootnotes::Source.new(@opt).create_dal) #watch end end class Output @@ -192,9 +192,9 @@ module SiSU_ConvertFootnotes data=data.join.split("\n\n") data_new=[] data.each do |x| - data_new << if x =~ /\n\n/m; x.split(/\n\n+/) - else x - end + data_new << (x =~ /\n\n/m) \ + ? (x.split(/\n\n+/)) + : x end data=data_new.flatten data=SiSU_ConvertFootnotes::Make.new(@md,data).substitutions_and_insertions? @@ -360,9 +360,9 @@ module SiSU_ConvertFootnotes if para !~/^(?:@\S+:|0~\S+)\s/m \ and para !~/\A\s*\Z/m @md.set_heading_top=true - head=if @md.title.full ; ":A~ #{@md.title.full}" - else ':A~ [no title provided]' - end + head=(@md.title.full) \ + ? (":A~ #{@md.title.full}") + : (':A~ [no title provided]') @tuned_file << head end end @@ -382,9 +382,9 @@ module SiSU_ConvertFootnotes and para !~/\A\s*\Z/m \ and para !~/<:p[bn]>/ @md.set_heading_seg=true - head=if @md.title.full ; "1~seg [#{@md.title.full}]" - else '1~seg [segment]' - end + head=(@md.title.full) \ + ? ("1~seg [#{@md.title.full}]") + : ('1~seg [segment]') @tuned_file << head end end diff --git a/lib/sisu/v3/sst_identify_markup.rb b/lib/sisu/v3/sst_identify_markup.rb index 60c28bf5..012475be 100644 --- a/lib/sisu/v3/sst_identify_markup.rb +++ b/lib/sisu/v3/sst_identify_markup.rb @@ -236,9 +236,9 @@ WOK end else puts 'file not found: ' + @opt.fns end - if defined? markup.version; markup.version - else 'markup type/version not determined' - end + (defined? markup.version) \ + ? markup.version + : 'markup type/version not determined' end def markup_version? if @opt.fns.empty? -- cgit v1.2.3 From 02cc96fb1393812f5b35fbb6770d0469cafe07f0 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Mon, 1 Oct 2012 15:36:21 -0400 Subject: v3: cosmetic code, if, else, remove some semicolons (;) replace with newlines --- lib/sisu/v3/cgi_sql_common.rb | 2 +- lib/sisu/v3/dal_syntax.rb | 6 ++++-- lib/sisu/v3/db_import.rb | 4 +++- lib/sisu/v3/db_select.rb | 4 +++- lib/sisu/v3/dbi_discreet.rb | 4 +++- lib/sisu/v3/epub.rb | 3 ++- lib/sisu/v3/epub_segments.rb | 3 ++- lib/sisu/v3/param.rb | 6 ++++-- lib/sisu/v3/shared_sem.rb | 6 ++++-- lib/sisu/v3/sysenv.rb | 3 ++- 10 files changed, 28 insertions(+), 13 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v3/cgi_sql_common.rb b/lib/sisu/v3/cgi_sql_common.rb index 401b67f6..7a3ba387 100644 --- a/lib/sisu/v3/cgi_sql_common.rb +++ b/lib/sisu/v3/cgi_sql_common.rb @@ -652,7 +652,7 @@ module SiSU_CGI_SQL begin # all code goes in begin section @search={ :text => [], :endnotes => [] } q=CGI.new - @db=if cgi['db'] =~/\S+/; + @db=if cgi['db'] =~/\S+/ @stub=/#{@db_name_prefix}(\S+)/.match(cgi['db'])[1] cgi['db'] else diff --git a/lib/sisu/v3/dal_syntax.rb b/lib/sisu/v3/dal_syntax.rb index 75bb8f53..839fb399 100644 --- a/lib/sisu/v3/dal_syntax.rb +++ b/lib/sisu/v3/dal_syntax.rb @@ -285,8 +285,10 @@ module SiSU_DAL_Syntax w=w.gsub(@vz.markup_make_bold,"#{Mx[:fa_bold_o]}\\1#{Mx[:fa_bold_c]}") end else - w=if w =~ /(?:^!_|^#{Mx[:lv_o]}[7-9]:\S*?#{Mx[:lv_c]})\s+/; embolden(w) #bold paragraph/emphasize #may wish to remove think about 7{ 8{ conversion not satisfactory, as information is lost! - elsif w =~/^\/_\s+/; italicise(w) + w=if w =~ /(?:^!_|^#{Mx[:lv_o]}[7-9]:\S*?#{Mx[:lv_c]})\s+/ + embolden(w) #bold paragraph/emphasize #may wish to remove think about 7{ 8{ conversion not satisfactory, as information is lost! + elsif w =~/^\/_\s+/ + italicise(w) else w end end diff --git a/lib/sisu/v3/db_import.rb b/lib/sisu/v3/db_import.rb index 225e9da2..f533e7f1 100644 --- a/lib/sisu/v3/db_import.rb +++ b/lib/sisu/v3/db_import.rb @@ -73,7 +73,9 @@ module SiSU_DbImport @cX=SiSU_Screen::Ansi.new(@opt.cmd).cX @env=SiSU_Env::InfoEnv.new(@opt.fns) @dal="#{@env.processing_path.dal}" - if @opt.fns.empty? or @opt.cmd.empty?; @fnb='' + @fnb=if @opt.fns.empty? \ + or @opt.cmd.empty? + '' else @md=SiSU_Param::Parameters.new(@opt).get @md.fnb diff --git a/lib/sisu/v3/db_select.rb b/lib/sisu/v3/db_select.rb index e446c48a..b2773b97 100644 --- a/lib/sisu/v3/db_select.rb +++ b/lib/sisu/v3/db_select.rb @@ -94,7 +94,9 @@ module SiSU_DbSelect @db=SiSU_Env::InfoDb.new @job="sqlite3 #{@db.sqlite.db} < #{@env.processing_path.sqlite}/#{@opt.fns}.sql" File.new("#{@env.processing_path.sqlite}/#{@opt.fns}.sql",'w+') - elsif @opt.fns and @opt.fns.inspect =~/create/; nil #sort variations later + elsif @opt.fns \ + and @opt.fns.inspect =~/create/ + nil #sort variations later else nil end else nil diff --git a/lib/sisu/v3/dbi_discreet.rb b/lib/sisu/v3/dbi_discreet.rb index 49313a93..fc10fd71 100644 --- a/lib/sisu/v3/dbi_discreet.rb +++ b/lib/sisu/v3/dbi_discreet.rb @@ -168,7 +168,9 @@ module SiSU_DBI_Discreet #% database building @db=SiSU_Env::InfoDb.new @job="sqlite3 #{@db.sqlite.db} < #{@env.processing_path.sqlite}/#{@opt.fns}.sql" File.new("#{@env.processing_path.sqlite}/#{@opt.fns}.sql",'w+') - elsif @opt.fns and @opt.fns.inspect =~/create/; nil #sort variations later + elsif @opt.fns \ + and @opt.fns.inspect =~/create/ + nil #sort variations later else nil end else nil diff --git a/lib/sisu/v3/epub.rb b/lib/sisu/v3/epub.rb index a3364606..f3b94e3d 100644 --- a/lib/sisu/v3/epub.rb +++ b/lib/sisu/v3/epub.rb @@ -336,7 +336,8 @@ module SiSU_EPUB and link !~/#/ #% keep eye on link p_num=SiSU_EPUB_Format::ParagraphNumber.new(@md,link) end - title=if dob.obj !~/Document Information/; linkname + title=if dob.obj !~/Document Information/ + linkname else link='metadata' %{#{linkname}} diff --git a/lib/sisu/v3/epub_segments.rb b/lib/sisu/v3/epub_segments.rb index 0f45fe23..896ed152 100644 --- a/lib/sisu/v3/epub_segments.rb +++ b/lib/sisu/v3/epub_segments.rb @@ -359,7 +359,8 @@ WOK sto.seg_heading4 # work on see SplitTextObject elsif dob.ln==5 sto.seg_heading5 - elsif dob.ln==6; sto.seg_heading6 + elsif dob.ln==6 + sto.seg_heading6 end elsif dob.is==:para if dob.indent \ diff --git a/lib/sisu/v3/param.rb b/lib/sisu/v3/param.rb index dbcbcbab..26d09041 100644 --- a/lib/sisu/v3/param.rb +++ b/lib/sisu/v3/param.rb @@ -168,7 +168,8 @@ module SiSU_Param s=if s.class==String \ and s.length <= l s - elsif s.class==NilClass; nil + elsif s.class==NilClass + nil elsif s.class !=String STDERR.puts "#{n} is #{s.class}: programming error, String expected #{__FILE__}:#{__LINE__}" s @@ -1358,7 +1359,8 @@ module SiSU_Param if para =~/~\{|\^~ |~\^|\{.+?\[[1-6]\]\}\S+?\.ss[tm]/m @flag_auto_endnotes,@flag_endnotes=true,true end - if para =~/^(?:table\{|\{table)/i; @flag_tables=true + if para =~/^(?:table\{|\{table)/i + @flag_tables=true end end if para =~/^:?A~/ diff --git a/lib/sisu/v3/shared_sem.rb b/lib/sisu/v3/shared_sem.rb index bd906efc..1fa919c2 100644 --- a/lib/sisu/v3/shared_sem.rb +++ b/lib/sisu/v3/shared_sem.rb @@ -104,11 +104,13 @@ module SiSU_Sem puts matched[0] unless matched[0].nil? end def if_pair_c - if @para=~/([a-z](?:[a-z_:.]+?[a-z])?)+(?::\{(.+?)\}:\1)/m; puts "#{$1}:{ #{$2} }:#{$1}" + if @para=~/([a-z](?:[a-z_:.]+?[a-z])?)+(?::\{(.+?)\}:\1)/m + puts "#{$1}:{ #{$2} }:#{$1}" end end def if_pair_sc - if @para=~/;\{\s*(.+?)\s*\};([a-z]+(?:[_:.][a-z]+)*)/; puts ";{ #{$1} };#{$2}" + if @para=~/;\{\s*(.+?)\s*\};([a-z]+(?:[_:.][a-z]+)*)/ + puts ";{ #{$1} };#{$2}" end end def match_pair_c diff --git a/lib/sisu/v3/sysenv.rb b/lib/sisu/v3/sysenv.rb index 0786119c..a9df7b2a 100644 --- a/lib/sisu/v3/sysenv.rb +++ b/lib/sisu/v3/sysenv.rb @@ -5641,7 +5641,8 @@ WOK class InfoSkin def initialize(md=nil,skin=nil) @md=md - @d_sk=if skin.class==String ; skin + @d_sk=if skin.class==String + skin elsif defined? md.doc_skin \ and md.doc_skin md.doc_skin -- cgit v1.2.3 From 32d32bf7ecfbc84a58d67a920135ef0bddfb9ee0 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Mon, 1 Oct 2012 15:40:42 -0400 Subject: v3: cosmetic code, if true ; x, remove semicolons replace with "then" --- lib/sisu/v3/cgi_pgsql.rb | 4 ++-- lib/sisu/v3/cgi_sql_common.rb | 10 +++++----- lib/sisu/v3/cgi_sqlite.rb | 4 ++-- lib/sisu/v3/composite.rb | 4 ++-- lib/sisu/v3/dal.rb | 2 +- lib/sisu/v3/dal_expand_insertions.rb | 28 ++++++++++++++-------------- lib/sisu/v3/db_import.rb | 6 +++--- lib/sisu/v3/epub_concordance.rb | 2 +- lib/sisu/v3/help.rb | 2 +- lib/sisu/v3/html.rb | 2 +- lib/sisu/v3/manifest.rb | 16 ++++++++-------- lib/sisu/v3/odf.rb | 12 ++++++------ lib/sisu/v3/param.rb | 16 ++++++++-------- lib/sisu/v3/qrcode.rb | 18 +++++++++--------- lib/sisu/v3/response.rb | 6 +++--- lib/sisu/v3/shared_xml.rb | 4 ++-- lib/sisu/v3/sst_convert_markup.rb | 2 +- lib/sisu/v3/sst_do_inline_footnotes.rb | 2 +- lib/sisu/v3/texpdf.rb | 7 ++++--- 19 files changed, 74 insertions(+), 73 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v3/cgi_pgsql.rb b/lib/sisu/v3/cgi_pgsql.rb index f78f65f5..d2c13132 100644 --- a/lib/sisu/v3/cgi_pgsql.rb +++ b/lib/sisu/v3/cgi_pgsql.rb @@ -146,8 +146,8 @@ module SiSU_CGI_PgSQL def string search={ :search => [], :flag => false } if @t =~/\S+/ or @q =~/\S+/ - if @t =~/\S+/; unescaped_search=CGI.unescape(@t) - elsif @q =~/\S+/; unescaped_search=CGI.unescape(@q) + if @t =~/\S+/ then unescaped_search=CGI.unescape(@t) + elsif @q =~/\S+/ then unescaped_search=CGI.unescape(@q) end search_construct=[] unescaped_search=if @c diff --git a/lib/sisu/v3/cgi_sql_common.rb b/lib/sisu/v3/cgi_sql_common.rb index 7a3ba387..5a044d5f 100644 --- a/lib/sisu/v3/cgi_sql_common.rb +++ b/lib/sisu/v3/cgi_sql_common.rb @@ -292,8 +292,8 @@ module SiSU_CGI_SQL @date_modified=q['dtm'] if q['dtm']=~/\S/ @date_available=q['dta'] if q['dta']=~/\S/ @date_valid=q['dtv'] if q['dtv']=~/\S/ - @filename=if q['doc'] and q['search'] !~/search db/; q['doc'] - elsif q['fns']=~/\S/; q['fns'] + @filename=if q['doc'] and q['search'] !~/search db/ then q['doc'] + elsif q['fns']=~/\S/ then q['fns'] end @@limit=q['ltd'] if q['ltd']=~/\d+/ # 1000 @@offset=q['off'] if q['off']=~/\d+/ # 0 @@ -306,8 +306,8 @@ module SiSU_CGI_SQL :word => /#{identifier}[\s(]*(\S+)/ } search_string=if @search_field =~m[:word] - search_string=if @search_field =~m[:braces]; m[:braces].match(@search_field)[1] - elsif @search_field =~m[:string]; m[:string].match(@search_field)[1] + search_string=if @search_field =~m[:braces] then m[:braces].match(@search_field)[1] + elsif @search_field =~m[:string] then m[:string].match(@search_field)[1] else str=m[:word].match(@search_field)[1] str=str.gsub(/[()]/,'') @@ -512,7 +512,7 @@ module SiSU_CGI_SQL } end else - if page.to_s =~ /^1$/; '' + if page.to_s =~ /^1$/ then '' elsif page.to_s =~ /^2$/ %{
diff --git a/lib/sisu/v3/cgi_sqlite.rb b/lib/sisu/v3/cgi_sqlite.rb index ccb1fb50..a9f9d277 100644 --- a/lib/sisu/v3/cgi_sqlite.rb +++ b/lib/sisu/v3/cgi_sqlite.rb @@ -143,8 +143,8 @@ module SiSU_CGI_SQLite def string search={ :search => [], :flag => false } if @t =~/\S+/ or @q =~/\S+/ - if @t =~/\S+/; unescaped_search=CGI.unescape(@t) - elsif @q =~/\S+/; unescaped_search=CGI.unescape(@q) + if @t =~/\S+/ then unescaped_search=CGI.unescape(@t) + elsif @q =~/\S+/ then unescaped_search=CGI.unescape(@q) end search_construct=[] unescaped_search=unescaped_search.gsub(/\s*(AND|OR)\s*/,"%' \) \\1 #{@l} LIKE \( '%"). diff --git a/lib/sisu/v3/composite.rb b/lib/sisu/v3/composite.rb index 90ec28dc..d73b0c73 100644 --- a/lib/sisu/v3/composite.rb +++ b/lib/sisu/v3/composite.rb @@ -160,8 +160,8 @@ module SiSU_Assemble file[:prepared] << "\n% |#{fni}|@|^|>>ok\n" @code_flag=false insert_array.each do |i| - @code_flag=if i =~/^code\{/; true - elsif i =~/^\}code/; false + @code_flag=if i =~/^code\{/ then true + elsif i =~/^\}code/ then false else @code_flag end if not @code_flag \ diff --git a/lib/sisu/v3/dal.rb b/lib/sisu/v3/dal.rb index a039545f..79e12e2d 100644 --- a/lib/sisu/v3/dal.rb +++ b/lib/sisu/v3/dal.rb @@ -275,7 +275,7 @@ module SiSU_DAL end file_array=@env.read_source_file(fn) file_array.each do |l| - if l =~/\r\n/; l.gsub!(/\r\n/,"\n") + if l =~/\r\n/ then l.gsub!(/\r\n/,"\n") end end meta=file_array.dup diff --git a/lib/sisu/v3/dal_expand_insertions.rb b/lib/sisu/v3/dal_expand_insertions.rb index 5903d242..2ec4945f 100644 --- a/lib/sisu/v3/dal_expand_insertions.rb +++ b/lib/sisu/v3/dal_expand_insertions.rb @@ -72,33 +72,33 @@ module SiSU_DAL_Insertions end file_type_names={} file_type_names[:gen],file_type_names[:src]=[],[] - file_type_names[:gen] <<= if cmd_list =~ /y/; "~^ { document manifest }#{lnk[:manifest]}" + file_type_names[:gen] <<= if cmd_list =~ /y/ then "~^ { document manifest }#{lnk[:manifest]}" end - file_type_names[:gen] <<= if cmd_list =~ /h/; [" { html, segmented text }#{lnk[:html_toc]}"," { html, scroll, document in one }#{lnk[:html_doc]}"] + file_type_names[:gen] <<= if cmd_list =~ /h/ then [" { html, segmented text }#{lnk[:html_toc]}"," { html, scroll, document in one }#{lnk[:html_doc]}"] end - file_type_names[:gen] <<= if cmd_list =~ /e/; [" { epub }#{lnk[:epub]}"] + file_type_names[:gen] <<= if cmd_list =~ /e/ then [" { epub }#{lnk[:epub]}"] end - file_type_names[:gen] <<= if cmd_list =~ /p/; [" { pdf, landscape }#{lnk[:pdf_landscape]}"," { pdf, portrait }#{lnk[:pdf_portrait]}"] + file_type_names[:gen] <<= if cmd_list =~ /p/ then [" { pdf, landscape }#{lnk[:pdf_landscape]}"," { pdf, portrait }#{lnk[:pdf_portrait]}"] end - file_type_names[:gen] <<= if cmd_list =~ /o/; " { odf:odt, open document text }#{lnk[:odt]}" + file_type_names[:gen] <<= if cmd_list =~ /o/ then " { odf:odt, open document text }#{lnk[:odt]}" end - file_type_names[:gen] <<= if cmd_list =~ /b/; " { xhtml scroll }#{lnk[:xhtml]}" + file_type_names[:gen] <<= if cmd_list =~ /b/ then " { xhtml scroll }#{lnk[:xhtml]}" end - file_type_names[:gen] <<= if cmd_list =~ /x/; " { xml, sax }#{lnk[:xml_sax]}" + file_type_names[:gen] <<= if cmd_list =~ /x/ then " { xml, sax }#{lnk[:xml_sax]}" end - file_type_names[:gen] <<= if cmd_list =~ /X/; " { xml, dom }#{lnk[:xml_dom]}" + file_type_names[:gen] <<= if cmd_list =~ /X/ then " { xml, dom }#{lnk[:xml_dom]}" end - file_type_names[:gen] <<= if cmd_list =~ /a/; " { plain text utf-8 }#{lnk[:txt]}" + file_type_names[:gen] <<= if cmd_list =~ /a/ then " { plain text utf-8 }#{lnk[:txt]}" end - file_type_names[:gen] <<= if cmd_list =~ /g/; 'wiki.txt' + file_type_names[:gen] <<= if cmd_list =~ /g/ then 'wiki.txt' end - file_type_names[:gen] <<= if cmd_list =~ /w/; " { concordance }#{lnk[:html_concordance]}" + file_type_names[:gen] <<= if cmd_list =~ /w/ then " { concordance }#{lnk[:html_concordance]}" end - file_type_names[:gen] <<= if cmd_list =~ /N/; " { dcc, document content certificate (digests) }#{lnk[:digest]}" + file_type_names[:gen] <<= if cmd_list =~ /N/ then " { dcc, document content certificate (digests) }#{lnk[:digest]}" end - file_type_names[:src] <<= if source and cmd_shortcut =~ /s/; " { markup source text }#{lnk[:source]}" + file_type_names[:src] <<= if source and cmd_shortcut =~ /s/ then " { markup source text }#{lnk[:source]}" end - file_type_names[:src] <<= if cmd_shortcut =~ /S/; " { markup source (zipped) pod }#{lnk[:sisupod]}" + file_type_names[:src] <<= if cmd_shortcut =~ /S/ then " { markup source (zipped) pod }#{lnk[:sisupod]}" end file_type_names[:gen]=file_type_names[:gen].flatten file_type_names[:src]=file_type_names[:src].flatten diff --git a/lib/sisu/v3/db_import.rb b/lib/sisu/v3/db_import.rb index f533e7f1..0cae5872 100644 --- a/lib/sisu/v3/db_import.rb +++ b/lib/sisu/v3/db_import.rb @@ -283,11 +283,11 @@ module SiSU_DbImport @col[:plaintext]=@col[:body].dup @col[:plaintext]=strip_markup(@col[:plaintext]) @col[:plaintext]=clean_searchable_text(@col[:plaintext]) - if @en[0]; @en_a,@en_z=@en[0].first,@en[0].last + if @en[0] then @en_a,@en_z=@en[0].first,@en[0].last end - if @en_ast[0]; @en_a_asterisk,@en_z_asterisk=@en_ast[0].first,@en_ast[0].last + if @en_ast[0] then @en_a_asterisk,@en_z_asterisk=@en_ast[0].first,@en_ast[0].last end - if @en_pls[0]; @en_a_plus,@en_z_plus=@en_pls[0].first,@en_pls[0].last + if @en_pls[0] then @en_a_plus,@en_z_plus=@en_pls[0].first,@en_pls[0].last end t=SiSU_DbTuple::LoadDocuments.new(@conn,@col,@opt,@file_maint) @tuple_array << t.tuple diff --git a/lib/sisu/v3/epub_concordance.rb b/lib/sisu/v3/epub_concordance.rb index df975a48..224578b6 100644 --- a/lib/sisu/v3/epub_concordance.rb +++ b/lib/sisu/v3/epub_concordance.rb @@ -219,7 +219,7 @@ WOK && line.ln==4 @seg=line.name end - if line.ocn.to_s =~/\d+/; toy=line.ocn.to_s + if line.ocn.to_s =~/\d+/ then toy=line.ocn.to_s end if toy =~/\d+/ \ and toy !~/^0$/ diff --git a/lib/sisu/v3/help.rb b/lib/sisu/v3/help.rb index 421594fb..980380c3 100644 --- a/lib/sisu/v3/help.rb +++ b/lib/sisu/v3/help.rb @@ -901,7 +901,7 @@ WOK SiSU_Env::InfoSettings.new.program?(program) else '' end - if program =='rmagick'; program='identify' #rmagick is ruby lib uses imagemagick's identify + if program =='rmagick' then program='identify' #rmagick is ruby lib uses imagemagick's identify end bin=if SiSU_Env::SystemCall.new.program_found?(program) SiSU_Env::SystemCall.new.program_found?(program) diff --git a/lib/sisu/v3/html.rb b/lib/sisu/v3/html.rb index 3a2f8a0d..b4fd96ba 100644 --- a/lib/sisu/v3/html.rb +++ b/lib/sisu/v3/html.rb @@ -321,7 +321,7 @@ WOK and link !~/#/ #% keep eye on link p_num=SiSU_HTML_Format::ParagraphNumber.new(@md,link) end - title=if dob.obj !~/Metadata/; linkname + title=if dob.obj !~/Metadata/ then linkname else link='metadata' %{#{linkname}} diff --git a/lib/sisu/v3/manifest.rb b/lib/sisu/v3/manifest.rb index 446a8716..743bc090 100644 --- a/lib/sisu/v3/manifest.rb +++ b/lib/sisu/v3/manifest.rb @@ -229,9 +229,9 @@ module SiSU_Manifest @manifest[:html] << %{

#{id}:

#{info}

\n} end def links(url,lnk,target) - static=if url =~/^\.\//; url.gsub(/^\.(\.)?/,@base_url) - elsif url =~/^\.\.\//; url.gsub(/^\.(\.)?/,@env.url.root) - else url + static=if url =~/^\.\// then url.gsub(/^\.(\.)?/,@base_url) + elsif url =~/^\.\.\// then url.gsub(/^\.(\.)?/,@env.url.root) + else url end @manifest[:html] << %{

#{lnk}

  #{@brace_url.xml_open}#{static}#{@brace_url.xml_close}

\n} end @@ -406,11 +406,11 @@ module SiSU_Manifest summarize(id,file,pth,rel,url) end if FileTest.file?(@f.place_file.txt.dir)==true - if @md.opt.cmd =~/a/; id='Plaintext (Unix (UTF-8) with footnotes)' - elsif @md.opt.cmd =~/e/; id='Plaintext (Unix (UTF-8) with endnotes)' - elsif @md.opt.cmd =~/A/; id='Plaintext (dos (UTF-8) with footnotes)' - elsif @md.opt.cmd =~/E/; id='Plaintext (dos (UTF-8) with endnotes)' - else id='Plaintext (UTF-8)' + id=if @md.opt.cmd =~/a/ then 'Plaintext (Unix (UTF-8) with footnotes)' + elsif @md.opt.cmd =~/e/ then 'Plaintext (Unix (UTF-8) with endnotes)' + elsif @md.opt.cmd =~/A/ then 'Plaintext (dos (UTF-8) with footnotes)' + elsif @md.opt.cmd =~/E/ then 'Plaintext (dos (UTF-8) with endnotes)' + else 'Plaintext (UTF-8)' end pth=@f.output_path.txt.dir rel=@f.output_path.txt.rel_sm diff --git a/lib/sisu/v3/odf.rb b/lib/sisu/v3/odf.rb index 2830b24d..d4d16b1d 100644 --- a/lib/sisu/v3/odf.rb +++ b/lib/sisu/v3/odf.rb @@ -137,7 +137,7 @@ module SiSU_ODF if n =~/#{Mx[:br_line]}/ fix=n.split(/#{Mx[:br_line]}/) #watch #added fix.each do |x| - if x =~/\S+/; @n << x + if x =~/\S+/ then @n << x end end else @n << n @@ -271,7 +271,7 @@ module SiSU_ODF dob.obj.scan(/(#{Mx[:lnk_o]}[ ]*(.+?)[ ]*#{Mx[:lnk_c]}(image))/) else nil end - if m; m.each do |i| + if m then m.each do |i| cont,url=i[1],i[2] cont=cont.gsub(/([)(\]\[])/,"\\\\\\1"). gsub(/([+?])/,"\\\\\\1") # incorrect handling of + @@ -385,8 +385,8 @@ module SiSU_ODF str end def footnote(t_o) - str=if defined? t_o.obj; t_o.obj - elsif t_o.class==String; t_o + str=if defined? t_o.obj then t_o.obj + elsif t_o.class==String then t_o end if str @astx||=10000 @@ -420,8 +420,8 @@ module SiSU_ODF end end end - if defined? t_o.obj; t_o.obj=str - elsif t_o.class==String; t_o=str + if defined? t_o.obj then t_o.obj=str + elsif t_o.class==String then t_o=str end t_o end diff --git a/lib/sisu/v3/param.rb b/lib/sisu/v3/param.rb index 26d09041..7a416bd9 100644 --- a/lib/sisu/v3/param.rb +++ b/lib/sisu/v3/param.rb @@ -541,7 +541,7 @@ module SiSU_Param (str =~/https?:\/\/\S+$/) ? ' ;' : ';' end def all - s=if @h['all']; @h['all'] + s=if @h['all'] then @h['all'] else s='' if defined? copyright.text \ @@ -798,9 +798,9 @@ module SiSU_Param end end def emphasis - if @h['emphasis'] =~/bold/; 'bold' - elsif @h['emphasis'] =~/italics?/; 'italics' - elsif @h['emphasis'] =~/under(?:line|score)/; 'underscore' + if @h['emphasis'] =~/bold/ then 'bold' + elsif @h['emphasis'] =~/italics?/ then 'italics' + elsif @h['emphasis'] =~/under(?:line|score)/ then 'underscore' else nil end end @@ -1331,7 +1331,7 @@ module SiSU_Param if @markup.nil? \ or @markup.empty? @markup=@markup_version.determined.to_s - elsif @markup !~/0\.38/; @markup=@markup.strip + "; #{@markup_version.determined}" + elsif @markup !~/0\.38/ then @markup=@markup.strip + "; #{@markup_version.determined}" end if not defined? @title.full.nil? tf=para[/^:A~\S*(.+)$/m,1] @@ -1508,9 +1508,9 @@ module SiSU_Param # @flv.each do |l| # lang=SiSU_Env::StandardiseLanguage.new.file_to_language(l) # c={ a: '', b: '', c: '' } -# if @fnl[:pre] =~/\S/; c[:a]="#{lang[:c]}." -# elsif @fnl[:mid] =~/\S/; c[:b]=".#{lang[:c]}" -# elsif @fnl[:post] =~/\S/; c[:c]=".#{lang[:c]}" +# if @fnl[:pre] =~/\S/ then c[:a]="#{lang[:c]}." +# elsif @fnl[:mid] =~/\S/ then c[:b]=".#{lang[:c]}" +# elsif @fnl[:post] =~/\S/ then c[:c]=".#{lang[:c]}" # end # @lang << [lang[:n],"#{c[:a]}sisu_manifest#{c[:b]}.html#{c[:c]}"] # end if @flv diff --git a/lib/sisu/v3/qrcode.rb b/lib/sisu/v3/qrcode.rb index d668c813..dfd253d8 100644 --- a/lib/sisu/v3/qrcode.rb +++ b/lib/sisu/v3/qrcode.rb @@ -242,9 +242,9 @@ WOK @manifest[:txt_title] << %{#{info}\n} end def links(url,lnk,target) - static=if url =~/^\.\//; url.gsub(/^\.(\.)?/,@base_url) - elsif url =~/^\.\.\//; url.gsub(/^\.(\.)?/,@env.url.root) - else url + static=if url =~/^\.\// then url.gsub(/^\.(\.)?/,@base_url) + elsif url =~/^\.\.\// then url.gsub(/^\.(\.)?/,@env.url.root) + else url end @manifest[:txt] << %{#{url} #{lnk} #{@brace_url.txt_open}#{static}#{@brace_url.txt_close}\n} end @@ -384,12 +384,12 @@ WOK summarize(id,file,pth,rel,url) end if FileTest.file?(@f.place_file.txt.dir)==true - if @md.opt.cmd =~/a/; id='Plaintext (Unix (UTF-8) with footnotes)' - elsif @md.opt.cmd =~/e/; id='Plaintext (Unix (UTF-8) with endnotes)' - elsif @md.opt.cmd =~/A/; id='Plaintext (dos (UTF-8) with footnotes)' - elsif @md.opt.cmd =~/E/; id='Plaintext (dos (UTF-8) with endnotes)' - else id='Plaintext (UTF-8)' - end + id=if @md.opt.cmd =~/a/ then 'Plaintext (Unix (UTF-8) with footnotes)' + elsif @md.opt.cmd =~/e/ then 'Plaintext (Unix (UTF-8) with endnotes)' + elsif @md.opt.cmd =~/A/ then 'Plaintext (dos (UTF-8) with footnotes)' + elsif @md.opt.cmd =~/E/ then 'Plaintext (dos (UTF-8) with endnotes)' + else 'Plaintext (UTF-8)' + end pth=@f.output_path.txt.dir rel=@f.output_path.txt.rel_sm url=@f.output_path.txt.url diff --git a/lib/sisu/v3/response.rb b/lib/sisu/v3/response.rb index 675b249e..d660d398 100644 --- a/lib/sisu/v3/response.rb +++ b/lib/sisu/v3/response.rb @@ -61,9 +61,9 @@ module SiSU_Response response='redo' print ask + " ['yes', 'no' or 'quit']: " response=File.new('/dev/tty').gets.strip - ans=if response=='yes'; true - elsif response=='no'; false - elsif response =~/^quit|exit$/; exit + 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 diff --git a/lib/sisu/v3/shared_xml.rb b/lib/sisu/v3/shared_xml.rb index cff58007..959170b6 100644 --- a/lib/sisu/v3/shared_xml.rb +++ b/lib/sisu/v3/shared_xml.rb @@ -109,8 +109,8 @@ module SiSU_XML_Munge def char_enc #character encode def utf8(dob='') if @sys.locale =~/utf-?8/i # instead ucs for utf8 # String#encode Iñtërnâtiônàlizætiøn - str=if defined? dob.obj; dob.obj - elsif dob.class==String; dob + str=if defined? dob.obj then dob.obj + elsif dob.class==String then dob end if str #¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûü diff --git a/lib/sisu/v3/sst_convert_markup.rb b/lib/sisu/v3/sst_convert_markup.rb index 47426490..20b6d775 100644 --- a/lib/sisu/v3/sst_convert_markup.rb +++ b/lib/sisu/v3/sst_convert_markup.rb @@ -196,7 +196,7 @@ WOK and @opt.files.length > 0 mr=nil #%% changes to make m match, r replace --------------------------> - if @opt.mod.inspect =~/--help/; help + if @opt.mod.inspect =~/--help/ then help elsif @opt.mod.inspect =~/(?:convert|to)[=-](?:xml |sxs|sax|sxd|dom|sxn|node)/ ext=case @opt.mod.inspect when /(?:convert|to)[=-](?:xml|sxs|sax)/; '.sxs.xml' diff --git a/lib/sisu/v3/sst_do_inline_footnotes.rb b/lib/sisu/v3/sst_do_inline_footnotes.rb index 08c599ce..b30fa8d2 100644 --- a/lib/sisu/v3/sst_do_inline_footnotes.rb +++ b/lib/sisu/v3/sst_do_inline_footnotes.rb @@ -124,7 +124,7 @@ module SiSU_ConvertFootnotes SiSU_Screen::Ansi.new(@opt.cmd,'convert footnotes').green_title_hi unless @opt.cmd =~/q/ file_array=IO.readlines(@opt.fns,'') file_array.each do |l| - if l =~/\r\n/; l.gsub!(/\r\n/,"\n") + if l =~/\r\n/ then l.gsub!(/\r\n/,"\n") end end meta=file_array.dup diff --git a/lib/sisu/v3/texpdf.rb b/lib/sisu/v3/texpdf.rb index aba92c3e..fc007a4f 100644 --- a/lib/sisu/v3/texpdf.rb +++ b/lib/sisu/v3/texpdf.rb @@ -402,7 +402,8 @@ module SiSU_TeX @tex_file=[] data.each do |dob| @tex_file << if dob.class==String \ - or dob.class==Hash; dob + or dob.class==Hash + dob elsif dob.is==:table tables_hash(@md,dob) #Hash result else dob @@ -709,8 +710,8 @@ WOK % \\sloppy \\begin{document} WOK - sisu_rc_footnote=if @md.sc_info; @tex_ml.doc_sc_info_footnote_full - else @tex_ml.doc_sc_info_footnote_brief + sisu_rc_footnote=if @md.sc_info then @tex_ml.doc_sc_info_footnote_full + else @tex_ml.doc_sc_info_footnote_brief end @copymark='' #check and remove as now is superflous x={} -- cgit v1.2.3 From 6b2c44794b8aeeca96a9b3114b87b3c1df69fd9d Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Mon, 1 Oct 2012 15:43:19 -0400 Subject: v3: cosmetic code, .is_a?(X) replaces .class==X (& some defined? & nil? tests) --- lib/sisu/v3/cgi_pgsql.rb | 2 +- lib/sisu/v3/cgi_sql_common.rb | 5 +- lib/sisu/v3/dal.rb | 20 +++---- lib/sisu/v3/dal_character_check.rb | 2 +- lib/sisu/v3/dal_doc_str.rb | 11 ++-- lib/sisu/v3/dal_hash_digest.rb | 4 +- lib/sisu/v3/dal_idx.rb | 22 ++++--- lib/sisu/v3/dal_numbering.rb | 10 ++-- lib/sisu/v3/dal_syntax.rb | 2 +- lib/sisu/v3/db_columns.rb | 24 ++++---- lib/sisu/v3/db_select.rb | 2 +- lib/sisu/v3/db_sqltxt.rb | 2 +- lib/sisu/v3/dbi_discreet.rb | 2 +- lib/sisu/v3/epub_format.rb | 2 +- lib/sisu/v3/epub_segments.rb | 4 +- lib/sisu/v3/epub_tune.rb | 2 +- lib/sisu/v3/harvest_authors.rb | 16 +++--- lib/sisu/v3/harvest_topics.rb | 114 ++++++++++++++++++------------------- lib/sisu/v3/html_format.rb | 2 +- lib/sisu/v3/html_promo.rb | 4 +- lib/sisu/v3/html_segments.rb | 4 +- lib/sisu/v3/html_tune.rb | 2 +- lib/sisu/v3/hub.rb | 2 +- lib/sisu/v3/manifest.rb | 2 +- lib/sisu/v3/manpage.rb | 2 +- lib/sisu/v3/odf.rb | 4 +- lib/sisu/v3/odf_format.rb | 2 +- lib/sisu/v3/param.rb | 46 +++++++-------- lib/sisu/v3/plaintext.rb | 4 +- lib/sisu/v3/plaintext_format.rb | 2 +- lib/sisu/v3/po4a.rb | 12 ++-- lib/sisu/v3/po4a_set.rb | 2 +- lib/sisu/v3/qrcode.rb | 2 +- lib/sisu/v3/shared_markup_alt.rb | 4 +- lib/sisu/v3/shared_metadata.rb | 18 +++--- lib/sisu/v3/shared_txt.rb | 2 +- lib/sisu/v3/shared_xml.rb | 4 +- lib/sisu/v3/sst_to_s_xml_sax.rb | 2 +- lib/sisu/v3/sysenv.rb | 80 +++++++++++--------------- lib/sisu/v3/texinfo_format.rb | 4 +- lib/sisu/v3/texpdf.rb | 24 ++++---- lib/sisu/v3/texpdf_format.rb | 2 +- lib/sisu/v3/xhtml_table.rb | 2 +- lib/sisu/v3/xml_format.rb | 2 +- 44 files changed, 235 insertions(+), 247 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v3/cgi_pgsql.rb b/lib/sisu/v3/cgi_pgsql.rb index d2c13132..83a1cecf 100644 --- a/lib/sisu/v3/cgi_pgsql.rb +++ b/lib/sisu/v3/cgi_pgsql.rb @@ -75,7 +75,7 @@ module SiSU_CGI_PgSQL available_db_table=`psql --list` # system call requires psql available_db=available_db_table.scan(/(#{Db[:name_prefix]}\S+)/) if not available_db_table.nil? if available_db \ - and available_db.class==Array + and available_db.is_a?(Array) available_db.flatten.each do |x| serve << x.gsub(/#{Db[:name_prefix]}(\S+)/,'\1') end diff --git a/lib/sisu/v3/cgi_sql_common.rb b/lib/sisu/v3/cgi_sql_common.rb index 5a044d5f..94026ce7 100644 --- a/lib/sisu/v3/cgi_sql_common.rb +++ b/lib/sisu/v3/cgi_sql_common.rb @@ -1024,8 +1024,9 @@ module SiSU_CGI_SQL if cgi['view']=~/text/ \ or (cgi['view']!~/index/ and cgi['search'] !~/search db/) #% txt endnotes @counter_endn_ocn+=1 - matched_endnote=(@search_regx.to_s.class==String && @search_regx.to_s=~/\S\S+/) \ - ? matched=e['body'].gsub(/(<\s]+#{@search_regx}[^>]+?>|#{@search_regx})/mi,%{\\1}) + matched_endnote=(@search_regx.to_s.is_a?(String) \ + && @search_regx.to_s=~/\S\S+/) \ + ? (matched=e['body'].gsub(/(<\s]+#{@search_regx}[^>]+?>|#{@search_regx})/mi,%{\\1})) : e['body'] output=%{#{title}
note #{e['nr']} referred to from ocn #{e['ocn']}: #{matched_endnote}} else #elsif cgi['view']=~/index/ #doc #FIX #% idx endnotes diff --git a/lib/sisu/v3/dal.rb b/lib/sisu/v3/dal.rb index 79e12e2d..a03ed55c 100644 --- a/lib/sisu/v3/dal.rb +++ b/lib/sisu/v3/dal.rb @@ -445,18 +445,18 @@ module SiSU_DAL end def make_marshal_content marshal_dal=@make.marshal.dal_content - File.open(marshal_dal,'w'){|f| Marshal.dump(@data,f)} if @data.class==Array + File.open(marshal_dal,'w'){|f| Marshal.dump(@data,f)} if @data.is_a?(Array) end def make_marshal_metadata marshal_dal=@make.marshal.dal_metadata - File.open(marshal_dal,'w'){|f| Marshal.dump(@data,f)} if @data.class==Array + File.open(marshal_dal,'w'){|f| Marshal.dump(@data,f)} if @data.is_a?(Array) end def idx_html_hard_output if @md.book_idx \ and @md.opt.cmd =~/M/ filename_meta=@cf.file_meta_idx_html - unless @data.nil? #REMOVE earliest possible - @data.each {|s| p s.inspect + "\n" unless s.class==String} + if @data.is_a?(Array) + @data.each {|s| p s.inspect + "\n" unless s.is_a?(String)} @data.each {|s| filename_meta.puts s.strip + "\n" unless s.strip.empty?} end else @@ -466,27 +466,27 @@ module SiSU_DAL end def make_marshal_idx_sst_html_seg marshal_dal=@make.marshal.dal_idx_sst_rel_html_seg - File.open(marshal_dal,'w'){|f| Marshal.dump(@data,f)} if @data.class==Array + File.open(marshal_dal,'w'){|f| Marshal.dump(@data,f)} if @data.is_a?(Array) end def make_marshal_idx_sst_rel marshal_dal=@make.marshal.dal_idx_sst_rel - File.open(marshal_dal,'w'){|f| Marshal.dump(@data,f)} if @data.class==Array + File.open(marshal_dal,'w'){|f| Marshal.dump(@data,f)} if @data.is_a?(Array) end def make_marshal_idx_html marshal_dal=@make.marshal.dal_idx_html - File.open(marshal_dal,'w'){|f| Marshal.dump(@data,f)} if @data.class==Array + File.open(marshal_dal,'w'){|f| Marshal.dump(@data,f)} if @data.is_a?(Array) end def make_marshal_idx_xhtml marshal_dal=@make.marshal.dal_idx_xhtml - File.open(marshal_dal,'w'){|f| Marshal.dump(@data,f)} if @data.class==Array + File.open(marshal_dal,'w'){|f| Marshal.dump(@data,f)} if @data.is_a?(Array) end def make_marshal_map_nametags marshal_dal=@make.marshal.dal_map_nametags - File.open(marshal_dal,'w'){|f| Marshal.dump(@data,f)} if @data.class==Hash + File.open(marshal_dal,'w'){|f| Marshal.dump(@data,f)} if @data.is_a?(Hash) end def make_marshal_map_name_ocn_htmlseg marshal_dal=@make.marshal.dal_map_ocn_htmlseg - File.open(marshal_dal,'w'){|f| Marshal.dump(@data,f)} if @data.class==Hash + File.open(marshal_dal,'w'){|f| Marshal.dump(@data,f)} if @data.is_a?(Hash) end end class Make diff --git a/lib/sisu/v3/dal_character_check.rb b/lib/sisu/v3/dal_character_check.rb index df14e1aa..f20d4106 100644 --- a/lib/sisu/v3/dal_character_check.rb +++ b/lib/sisu/v3/dal_character_check.rb @@ -93,7 +93,7 @@ module SiSU_DAL_CharacterCheck end end end - @tuned_file << dob unless dob.nil? + @tuned_file << dob if dob.is_a?(Object) end @tuned_file=@tuned_file.flatten.compact [@tuned_file,@endnote_array] diff --git a/lib/sisu/v3/dal_doc_str.rb b/lib/sisu/v3/dal_doc_str.rb index 0abaf4d0..6bde88e2 100644 --- a/lib/sisu/v3/dal_doc_str.rb +++ b/lib/sisu/v3/dal_doc_str.rb @@ -363,8 +363,8 @@ module SiSU_DAL_DocumentStructureExtract t_o=SiSU_DAL_DocumentStructure::ObjectComment.new.comment(h) #t_o=SiSU_DAL_DocumentStructure::ObjectLayout.new.insert(h) t_o else - if t_o !~/^table\{/ \ - and not t_o.nil? + if t_o.is_a?(String) \ + and t_o !~/^table\{/ t_o=t_o.gsub(/^\n+/m,''). #check added for ruby 1.9.2 not needed in 1.8 series (tested in v2) gsub(/\n+/m,"#{Mx[:tc_p]}") @rows += t_o + Mx[:tc_c] @@ -385,8 +385,7 @@ module SiSU_DAL_DocumentStructureExtract t_o=SiSU_DAL_DocumentStructure::ObjectComment.new.comment(h) #t_o=SiSU_DAL_DocumentStructure::ObjectLayout.new.insert(h) end if @@flag['code'] \ - and t_o.class==String \ - and not t_o.nil? #you may need to introduce t_o.class==String test more widely + and t_o.is_a?(String) sub_array=t_o.dup + "#{Mx[:br_nl]}" @line_mode=sub_array.scan(/.+/) @line_mode=[] @@ -461,7 +460,7 @@ module SiSU_DAL_DocumentStructureExtract if @@flag['poem'] \ or @@flag['group'] \ or @@flag['alt'] - if t_o.class==String + if t_o.is_a?(String) t_o=t_o.gsub(/\n/m,"#{Mx[:br_nl]}"). gsub(/[ ][ ]/m,"#{Mx[:nbsp]*2}"). gsub(/#{Mx[:nbsp]}\s/,"#{Mx[:nbsp]*2}") @@ -527,7 +526,7 @@ module SiSU_DAL_DocumentStructureExtract lines.each do |line| line=if line =~/\S/ \ and line !~/^code\{|^\}code/ \ - and line.class != Hash + and not line.is_a?(Hash) @@counter+=1 if @@flag['code'] line=line.gsub(/\s\s/,"#{Mx[:nbsp]*2}"). gsub(/#{Mx[:nbsp]}\s/,"#{Mx[:nbsp]*2}") diff --git a/lib/sisu/v3/dal_hash_digest.rb b/lib/sisu/v3/dal_hash_digest.rb index c30048db..8718c461 100644 --- a/lib/sisu/v3/dal_hash_digest.rb +++ b/lib/sisu/v3/dal_hash_digest.rb @@ -72,13 +72,13 @@ module SiSU_DAL_Hash sha_ =(@env.digest.type=='sha256' ? true : false) sha_ ? (require 'digest/sha2') : (require 'digest/md5') data.each do |t_o| - unless t_o.obj.class==Array + unless t_o.obj.is_a?(Array) t_o.obj=t_o.obj.strip end if (t_o.of !=:structure \ && t_o.of !=:comment \ && t_o.of !=:layout) \ - && t_o.ocn.class==Fixnum + && t_o.ocn.is_a?(Fixnum) if sha_ for hash_class in [ Digest::SHA256 ] @tuned_file << stamped(t_o,hash_class) diff --git a/lib/sisu/v3/dal_idx.rb b/lib/sisu/v3/dal_idx.rb index 63735bde..a90217c4 100644 --- a/lib/sisu/v3/dal_idx.rb +++ b/lib/sisu/v3/dal_idx.rb @@ -79,7 +79,11 @@ module SiSU_DAL_BookIndex && dob.ln==4 @seg=dob.name end - idx_array << "#{dob.idx}~#{dob.ocn}~#{@seg}" if defined? dob.idx and not (dob.idx.nil? or dob.idx.empty?) + if defined? dob.idx \ + and dob.idx.is_a?(String) \ + and not dob.idx.empty? + idx_array << "#{dob.idx}~#{dob.ocn}~#{@seg}" + end tuned_file << dob if dob end idx_array=construct_idx_array(idx_array) if idx_array.length > 0 @@ -193,7 +197,7 @@ module SiSU_DAL_BookIndex idx[:xhtml] << %{\n

0 - 9

} the_idx.each do |i| i.each do |x| - if x.class==String + if x.is_a?(String) f=/^(\S)/.match(x)[1] if letter < f while letter < f @@ -216,11 +220,11 @@ module SiSU_DAL_BookIndex @q=idx[:html].index(idx[:html].last) @r=idx[:xhtml].index(idx[:xhtml].last) print "\n" + x + ', ' if @md.opt.cmd =~/V/ - elsif x.class==Array + elsif x.is_a?(Array) p 'array error? -->' print x - elsif x.class==Hash - if x['term_node_lev1'].class==Array + elsif x.is_a?(Hash) + if x['term_node_lev1'].is_a?(Array) x['term_node_lev1'].each do |a| if a[:range] idx[:sst_rel_html_seg][@o]=idx[:sst_rel_html_seg][@o] + %{#{Mx[:lnk_o]}#{a[:range]}#{Mx[:lnk_c]}#{Mx[:rel_o]}/#{a[:seg]}.html##{a[:ocn]}#{Mx[:rel_c]}, } @@ -283,13 +287,13 @@ module SiSU_DAL_BookIndex def screen_print(the_idx) the_idx.each do |i| i.each do |x| - if x.class==String + if x.is_a?(String) print "\n" + x + ', ' - elsif x.class==Array + elsif x.is_a?(Array) p 'array error? -->' print x - elsif x.class==Hash - if x['term_node_lev1'].class==Array + elsif x.is_a?(Hash) + if x['term_node_lev1'].is_a?(Array) x['term_node_lev1'].each do |a| if a[:range] print a[:range] + ', ' diff --git a/lib/sisu/v3/dal_numbering.rb b/lib/sisu/v3/dal_numbering.rb index 4c7ad642..f81563f3 100644 --- a/lib/sisu/v3/dal_numbering.rb +++ b/lib/sisu/v3/dal_numbering.rb @@ -82,7 +82,7 @@ module SiSU_DAL_Numbering && dob.ocn_ #and dob.obj !~ /#{Mx[:gr_o]}Th|#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}/ #FIX dob.obj=dob.obj.gsub(/(.+)\n/,'\1 ') #messy, but idea is that tables should retain breaks end - unless dob.obj.class==Array + unless dob.obj.is_a?(Array) dob.obj=dob.obj.gsub(/^\s+/,''). gsub(/\s$/,"\n") end @@ -160,7 +160,7 @@ module SiSU_DAL_Numbering if dob.ln==no1 t_no1+=1; t_no2=0; t_no3=0 title_no="#{t_no1}" - if not @md.seg_names.nil? \ + if @md.seg_names.is_a?(Array) \ and not @md.seg_names.include?(title_no) if dob.ln==no1 dob.name="#{title_no}" if not dob.name @@ -303,7 +303,7 @@ module SiSU_DAL_Numbering possible_seg_name=$1 possible_seg_name=possible_seg_name.gsub(/(?:[:,-]|\W)/,'.'). gsub(/\.$/,'') - if not @md.seg_names.nil? \ + if @md.seg_names.is_a?(Array) \ and not @md.seg_names.include?(possible_seg_name) dob.name=possible_seg_name dob.tags=[dob.name,dob.tags].flatten if dob.name !~/^\d+$/ @@ -313,7 +313,7 @@ module SiSU_DAL_Numbering end if dob.ln==4 \ and dob.name #extract segment name from embedded document structure info - if not @md.seg_names.nil? \ + if @md.seg_names.is_a?(Array) \ and not @md.seg_names.include?(dob.name) dob.tags=[dob.name,dob.tags].flatten if dob.name !~/^\d+$/ @md.seg_names << dob.name @@ -323,7 +323,7 @@ module SiSU_DAL_Numbering and not dob.name #if still no segment name, provide a numerical one pf='_' #pg='' #may use e.g. '' or '~' or '_' segn_auto="#{pf}#{art_filename_auto.to_s}" - if not @md.seg_names.nil? \ + if @md.seg_names.is_a?(Array) \ and not @md.seg_names.include?(segn_auto) dob.name=segn_auto dob.tags=[dob.name,dob.tags].flatten if dob.name !~/^\d+$/ #check whether will work across file types with stop signs diff --git a/lib/sisu/v3/dal_syntax.rb b/lib/sisu/v3/dal_syntax.rb index 839fb399..b21f94a5 100644 --- a/lib/sisu/v3/dal_syntax.rb +++ b/lib/sisu/v3/dal_syntax.rb @@ -238,7 +238,7 @@ module SiSU_DAL_Syntax def substitutions(dob) dob=dob.dup dob=if defined? @md.make.substitute[:match_and_replace] \ - and @md.make.substitute[:match_and_replace].class == Array + and @md.make.substitute[:match_and_replace].is_a?(Array) dob=if dob.is !=:meta \ && dob.is !=:heading_insert \ && dob.is !=:code \ diff --git a/lib/sisu/v3/db_columns.rb b/lib/sisu/v3/db_columns.rb index 5ae17707..7c4fa9eb 100644 --- a/lib/sisu/v3/db_columns.rb +++ b/lib/sisu/v3/db_columns.rb @@ -295,7 +295,7 @@ module SiSU_DbColumns end def tuple t=if defined? @md.creator.author_detail \ - and @md.creator.author_detail.class==Array \ + and @md.creator.author_detail.is_a?(Array) \ and @md.creator.author_detail.length > 0 txt='' @md.creator.author_detail.each do |h| @@ -366,7 +366,7 @@ module SiSU_DbColumns end def tuple t=if defined? @md.creator.editor_detail \ - and @md.creator.editor_detail.class==Array \ + and @md.creator.editor_detail.is_a?(Array) \ and @md.creator.editor_detail.length > 0 txt=@md.creator.editor_detail #dc txt='' @@ -394,7 +394,7 @@ module SiSU_DbColumns end def tuple t=if defined? @md.creator.contributor_detail \ - and @md.creator.contributor_detail.class==Array \ + and @md.creator.contributor_detail.is_a?(Array) \ and @md.creator.contributor_detail.length > 0 txt=@md.creator.contributor_detail #dc txt='' @@ -422,7 +422,7 @@ module SiSU_DbColumns end def tuple t=if defined? @md.creator.illustrator_detail \ - and @md.creator.illustrator_detail.class==Array \ + and @md.creator.illustrator_detail.is_a?(Array) \ and @md.creator.illustrator_detail.length > 0 txt=@md.creator.illustrator_detail txt='' @@ -450,7 +450,7 @@ module SiSU_DbColumns end def tuple t=if defined? @md.creator.photographer_detail \ - and @md.creator.photographer_detail.class==Array \ + and @md.creator.photographer_detail.is_a?(Array) \ and @md.creator.photographer_detail.length > 0 txt=@md.creator.photographer_detail txt='' @@ -478,7 +478,7 @@ module SiSU_DbColumns end def tuple t=if defined? @md.creator.translator_detail \ - and @md.creator.translator_detail.class==Array \ + and @md.creator.translator_detail.is_a?(Array) \ and @md.creator.translator_detail.length > 0 txt='' @md.creator.translator_detail.each do |h| @@ -505,7 +505,7 @@ module SiSU_DbColumns end def tuple t=if defined? @md.creator.prepared_by_detail \ - and @md.creator.prepared_by_detail.class==Array \ + and @md.creator.prepared_by_detail.is_a?(Array) \ and @md.creator.prepared_by_detail.length > 0 txt=@md.creator.prepared_by_detail txt='' @@ -533,7 +533,7 @@ module SiSU_DbColumns end def tuple t=if defined? @md.creator.digitized_by_detail \ - and @md.creator.digitized_by_detail.class==Array \ + and @md.creator.digitized_by_detail.is_a?(Array) \ and @md.creator.digitized_by_detail.length > 0 txt=@md.creator.digitized_by_detail txt='' @@ -561,7 +561,7 @@ module SiSU_DbColumns end def tuple t=if defined? @md.creator.audio_detail \ - and @md.creator.audio_detail.class==Array \ + and @md.creator.audio_detail.is_a?(Array) \ and @md.creator.audio_detail.length > 0 txt=@md.creator.audio_detail txt='' @@ -589,7 +589,7 @@ module SiSU_DbColumns end def tuple t=if defined? @md.creator.video_detail \ - and @md.creator.video_detail.class==Array \ + and @md.creator.video_detail.is_a?(Array) \ and @md.creator.video_detail.length > 0 txt='' @md.creator.video_detail.each do |h| @@ -1891,7 +1891,7 @@ module SiSU_DbColumns end def tuple t=if defined? @md.dgst \ - and @md.dgst.class==Array \ + and @md.dgst.is_a?(Array) \ and @md.dgst[1]=~/\S+/ txt=@md.dgst[1] ["#{name}, ","'#{txt}', "] @@ -2025,7 +2025,7 @@ module SiSU_DbColumns end def tuple t=if defined? @md.dgst_skin \ - and @md.dgst_skin.class==Array \ + and @md.dgst_skin.is_a?(Array) \ and @md.dgst_skin[1]=~/\S+/ txt=@md.dgst_skin[1] txt=special_character_escape(txt) diff --git a/lib/sisu/v3/db_select.rb b/lib/sisu/v3/db_select.rb index b2773b97..a013c00b 100644 --- a/lib/sisu/v3/db_select.rb +++ b/lib/sisu/v3/db_select.rb @@ -78,7 +78,7 @@ module SiSU_DbSelect puts %{no connection with #{@sql_type} database established, createdb "#{@db.sqlite.db}"?} exit end - if @conn.class==NilClass + if @conn.is_a?(NilClass) db=@sql_type=='sqlite' \ ? @db.sqlite.db : @db.psql.db diff --git a/lib/sisu/v3/db_sqltxt.rb b/lib/sisu/v3/db_sqltxt.rb index f6651724..53c15ed3 100644 --- a/lib/sisu/v3/db_sqltxt.rb +++ b/lib/sisu/v3/db_sqltxt.rb @@ -68,7 +68,7 @@ module SiSU_DbText end def clean_searchable_text(arr) #produce clean, searchable, plaintext from document source txt_arr,en=[],[] - arr=arr.class==String ? arr.split(/\n+/m) : arr + arr=(arr.is_a?(String)) ? arr.split(/\n+/m) : arr arr.each do |s| s=s.gsub(/([*\/_-])\{(.+?)\}\1/m,'\2'). gsub(/^(?:block|group|poem|code)\{/m,'').gsub(/^\}(?:block|group|poem|code)/m,''). diff --git a/lib/sisu/v3/dbi_discreet.rb b/lib/sisu/v3/dbi_discreet.rb index fc10fd71..07814a1a 100644 --- a/lib/sisu/v3/dbi_discreet.rb +++ b/lib/sisu/v3/dbi_discreet.rb @@ -106,7 +106,7 @@ module SiSU_DBI_Discreet #% database building puts msg exit end - if conn.class==NilClass + if conn.is_a?(NilClass) puts msg exit end diff --git a/lib/sisu/v3/epub_format.rb b/lib/sisu/v3/epub_format.rb index 06a6d623..cc98219c 100644 --- a/lib/sisu/v3/epub_format.rb +++ b/lib/sisu/v3/epub_format.rb @@ -1838,7 +1838,7 @@ WOK attr_accessor :md,:t_o,:txt,:ocn,:format,:table,:link,:linkname,:paranum,:p_num,:headname,:banner,:url def initialize(md,t_o) @md,@t_o=md,t_o - if t_o.class==Hash + if t_o.is_a?(Hash) @txt =t_o[:txt] || nil @ocn =t_o[:ocn] || nil @ocn_display =t_o[:ocn_display] || nil diff --git a/lib/sisu/v3/epub_segments.rb b/lib/sisu/v3/epub_segments.rb index 896ed152..5a3f3092 100644 --- a/lib/sisu/v3/epub_segments.rb +++ b/lib/sisu/v3/epub_segments.rb @@ -271,9 +271,9 @@ WOK @@get_hash_to=dob.name @@get_hash_fn=dob.name end - if dob.obj.class==String + if dob.obj.is_a?(String) markup(dob) - elsif dob.obj.class==Array + elsif dob.obj.is_a?(Array) dob.obj.each do |pg| markup(pg) end diff --git a/lib/sisu/v3/epub_tune.rb b/lib/sisu/v3/epub_tune.rb index a9bf31b0..1362815e 100644 --- a/lib/sisu/v3/epub_tune.rb +++ b/lib/sisu/v3/epub_tune.rb @@ -96,7 +96,7 @@ module SiSU_EPUB_Tune end def clean html=@html - str=if html.class==String + str=if html.is_a?(String) html else html.obj end diff --git a/lib/sisu/v3/harvest_authors.rb b/lib/sisu/v3/harvest_authors.rb index 6036816d..7c044425 100644 --- a/lib/sisu/v3/harvest_authors.rb +++ b/lib/sisu/v3/harvest_authors.rb @@ -157,7 +157,7 @@ module SiSU_HarvestAuthors idx_array.each do |idx| idx[:author][:last_first_format_a].each do |author| author=author.strip - if @@the_idx_authors[lang][author].class==NilClass + if @@the_idx_authors[lang][author].is_a?(NilClass) @@the_idx_authors[lang][author]={ md: [] } end @@the_idx_authors[lang][author][:md] << { filename: idx[:filename], file: idx[:file], author: idx[:author], title: idx[:title], date: idx[:date], page: idx[:page], lang: idx[:lang] } @@ -201,7 +201,7 @@ module SiSU_HarvestAuthors def html_file_close @the_idx.keys.each do |lng| @output[lng][:html].close - @output[lng][:html_mnt].close if @output[lng][:html_mnt].class==File + @output[lng][:html_mnt].close if @output[lng][:html_mnt].is_a?(File) end end def html_print @@ -305,12 +305,12 @@ WOK WOK @the_idx.keys.each do |lng| - @output[lng][:html_mnt] << a if @output[lng][:html_mnt].class==File + @output[lng][:html_mnt] << a if @output[lng][:html_mnt].is_a?(File) @output[lng][:html] << a end end def do_html(lng,html) - @output[lng][:html_mnt] << html if @output[lng][:html_mnt].class==File + @output[lng][:html_mnt] << html if @output[lng][:html_mnt].is_a?(File) @output[lng][:html] << html end def do_string_name(lng,attrib,string) @@ -324,7 +324,7 @@ WOK while @letter < f if @alph.length > 0 @letter=@alph.shift - if @output[lng][:html_mnt].class==File + if @output[lng][:html_mnt].is_a?(File) @output[lng][:html_mnt] << %{\n

#{@letter}

} end @output[lng][:html] << %{\n

#{@letter}

} @@ -340,7 +340,7 @@ WOK do_string_name(lng,'',a) name=a[0].sub(/(.+?)(?:,.+|$)/,'\1').gsub(/\s+/,'_') x = %{

#{a[0]}

} - if @output[lng][:html_mnt].class==File + if @output[lng][:html_mnt].is_a?(File) @output[lng][:html_mnt] << x end @output[lng][:html] << x @@ -356,13 +356,13 @@ WOK "../#{x[:file]}/#{x[:page]}" end work=[ "#{x[:date]} #{x[:title]}", %{

#{x[:date]} #{x[:title]}, #{x[:author][:authors_s]}

} ] - works<<=(@output[lng][:html_mnt].class==File) \ + works<<=(@output[lng][:html_mnt].is_a?(File)) \ ? (work.concat([%{

[src]  #{x[:date]} #{x[:title]}, #{x[:author][:authors_s]} -- [#{x[:file]}.sst]

}])) : work end works.sort_by {|x| x[0]}.each do |x| @output[lng][:html] << x[1] - @output[lng][:html_mnt] << x[2] if @output[lng][:html_mnt].class==File + @output[lng][:html_mnt] << x[2] if @output[lng][:html_mnt].is_a?(File) end end end diff --git a/lib/sisu/v3/harvest_topics.rb b/lib/sisu/v3/harvest_topics.rb index 3487ab6b..952f1411 100644 --- a/lib/sisu/v3/harvest_topics.rb +++ b/lib/sisu/v3/harvest_topics.rb @@ -233,8 +233,8 @@ module SiSU_HarvestTopics end @idx_a.each do |c| if c.length > 1 \ - and c.class == Array - if c[2].class == Hash + and c.is_a?(Array) + if c[2].is_a?(Hash) c[1].each do |alt| v=key_create(c,alt) @the_a << [v, c[2]] if v @@ -242,8 +242,8 @@ module SiSU_HarvestTopics end end if c.length > 2 \ - and c.class == Array - if c[3].class == Hash + and c.is_a?(Array) + if c[3].is_a?(Hash) c[2].each do |alt| v=key_create(c,alt) @the_a << [v, c[3]] if v @@ -251,8 +251,8 @@ module SiSU_HarvestTopics end end if c.length > 3 \ - and c.class == Array - if c[4].class == Hash + and c.is_a?(Array) + if c[4].is_a?(Hash) c[3].each do |alt| v=key_create(c,alt) @the_a << [v, c[4]] if v @@ -260,8 +260,8 @@ module SiSU_HarvestTopics end end if c.length > 4 \ - and c.class == Array - if c[5].class == Hash + and c.is_a?(Array) + if c[5].is_a?(Hash) c[4].each do |alt| v=key_create(c,alt) @the_a << [v, c[5]] if v @@ -269,8 +269,8 @@ module SiSU_HarvestTopics end end if c.length > 5 \ - and c.class == Array - if c[6].class == Hash + and c.is_a?(Array) + if c[6].is_a?(Hash) c[5].each do |alt| v=key_create(c,alt) @the_a << [v, c[6]] if v @@ -278,8 +278,7 @@ module SiSU_HarvestTopics end end end - y=@the_a.sort_by { |x| x[0] } - #y.each {|z| puts z} + y=@the_a.sort_by { |x| x[0] } #; y.each {|z| puts z} end def construct_book_topic_hash(y) @the_h={} @@ -369,22 +368,22 @@ module SiSU_HarvestTopics end def traverse_base @the_h.each_pair do |x0,y| - puts ' '*0 + x0 if x0.class == String - if y.class == Hash + puts ' '*0 + x0 if x0.is_a?(String) + if y.is_a?(Hash) y.each_pair do |x1,y| - puts ' '*1 + x1 if x1.class == String - if y.class == Hash + puts ' '*1 + x1 if x1.is_a?(String) + if y.is_a?(Hash) y.each_pair do |x2,y| - puts ' '*2 + x2 if x2.class == String - if y.class == Hash + puts ' '*2 + x2 if x2.is_a?(String) + if y.is_a?(Hash) y.each_pair do |x3,y| - puts ' '*3 + x3 if x3.class == String - if y.class == Hash + puts ' '*3 + x3 if x3.is_a?(String) + if y.is_a?(Hash) y.each_pair do |x4,y| - puts ' '*4 + x4 if x4.class == String - if y.class == Hash + puts ' '*4 + x4 if x4.is_a?(String) + if y.is_a?(Hash) y.each_pair do |x5,y| - puts ' '*5 + x5 if x5.class == String + puts ' '*5 + x5 if x5.is_a?(String) end end end @@ -399,37 +398,37 @@ module SiSU_HarvestTopics end def traverse @the_h.each_pair do |x0,y| - puts ' '*0 + x0 if x0.class == String - if y.class == Hash + puts ' '*0 + x0 if x0.is_a?(String) + if y.is_a?(Hash) if y.has_key?(:md) y[:md].each { |x| puts ' '*5 + x[:title] } end y.each_pair do |x1,y| - puts ' '*1 + x1 if x1.class == String - if y.class == Hash + puts ' '*1 + x1 if x1.is_a?(String) + if y.is_a?(Hash) if y.has_key?(:md) y[:md].each { |x| puts ' '*5 + x[:title] } end y.each_pair do |x2,y| - puts ' '*2 + x2 if x2.class == String - if y.class == Hash + puts ' '*2 + x2 if x2.is_a?(String) + if y.is_a?(Hash) if y.has_key?(:md) y[:md].each { |x| puts ' '*5 + x[:title] } end y.each_pair do |x3,y| - puts ' '*3 + x3 if x3.class == String - if y.class == Hash + puts ' '*3 + x3 if x3.is_a?(String) + if y.is_a?(Hash) if y.has_key?(:md) y[:md].each { |x| puts ' '*5 + x[:title] } end y.each_pair do |x4,y| - puts ' '*4 + x4 if x4.class == String - if y.class == Hash + puts ' '*4 + x4 if x4.is_a?(String) + if y.is_a?(Hash) if y.has_key?(:md) y[:md].each { |x| puts ' '*5 + x[:title] } end y.each_pair do |x5,y| - puts ' '*5 + x4 if x4.class == String + puts ' '*5 + x4 if x4.is_a?(String) end end end @@ -480,7 +479,7 @@ module SiSU_HarvestTopics def html_file_close @the_idx.keys.each do |lng| @output[lng][:html].close - @output[lng][:html_mnt].close if @output[lng][:html_mnt].class==File + @output[lng][:html_mnt].close if @output[lng][:html_mnt].is_a?(File) end end def html_print @@ -496,11 +495,11 @@ module SiSU_HarvestTopics def html_body_traverse @the_idx.each_pair do |x0,y| lng=x0 - if x0.class == String + if x0.is_a?(String) #do_string_name(lng,'lev0',x0) #puts ' '*0 + x0 end - if y.class == Hash + if y.is_a?(Hash) if y.has_key?(:md) y[:md].each do |x| #do_hash(lng,attrib,x) #lv==0 ? @@ -508,11 +507,11 @@ module SiSU_HarvestTopics end end y.each_pair do |x1,y| - if x1.class == String + if x1.is_a?(String) do_string_name(lng,'lev0',x1) #puts ' '*1 + x1 end - if y.class == Hash + if y.is_a?(Hash) if y.has_key?(:md) y[:md].each do |x| do_hash(lng,0,x) @@ -520,11 +519,11 @@ module SiSU_HarvestTopics end end y.each_pair do |x2,y| - if x2.class == String + if x2.is_a?(String) do_string(lng,'lev1',x2) #puts ' '*2 + x2 end - if y.class == Hash + if y.is_a?(Hash) if y.has_key?(:md) y[:md].each do |x| do_hash(lng,1,x) @@ -532,11 +531,11 @@ module SiSU_HarvestTopics end end y.each_pair do |x3,y| - if x3.class == String + if x3.is_a?(String) do_string(lng,'lev2',x3) #puts ' '*3 + x3 end - if y.class == Hash + if y.is_a?(Hash) if y.has_key?(:md) y[:md].each do |x| do_hash(lng,2,x) @@ -544,11 +543,11 @@ module SiSU_HarvestTopics end end y.each_pair do |x4,y| - if x4.class == String + if x4.is_a?(String) do_string(lng,'lev3',x4) #puts ' '*4 + x4 end - if y.class == Hash + if y.is_a?(Hash) if y.has_key?(:md) y[:md].each do |x| do_hash(lng,3,x) @@ -556,7 +555,7 @@ module SiSU_HarvestTopics end end y.each_pair do |x5,y| - if x5.class == String + if x5.is_a?(String) do_string(lng,'lev4',x5) #puts ' '*5 + x5 end @@ -667,7 +666,7 @@ WOK WOK @the_idx.keys.each do |lng| - @output[lng][:html_mnt] << a if @output[lng][:html_mnt].class==File + @output[lng][:html_mnt] << a if @output[lng][:html_mnt].is_a?(File) @output[lng][:html] << a end end @@ -675,12 +674,12 @@ WOK @output[lng][:html] << html end def do_html_maintenance(lng,html) - @output[lng][:html_mnt] << html if @output[lng][:html_mnt].class==File + @output[lng][:html_mnt] << html if @output[lng][:html_mnt].is_a?(File) end def do_string(lng,attrib,string) html=%{

#{string}

} do_html(lng,html) - do_html_maintenance(lng,html) if @output[lng][:html_mnt].class==File + do_html_maintenance(lng,html) if @output[lng][:html_mnt].is_a?(File) end def do_string_default(lng,attrib,string) html=%{

#{string}

} @@ -688,7 +687,7 @@ WOK end def do_string_maintenance(lng,attrib,string) html=%{

#{string}

} - do_html_maintenance(lng,html) if @output[lng][:html_mnt].class==File + do_html_maintenance(lng,html) if @output[lng][:html_mnt].is_a?(File) end def do_string_name(lng,attrib,string) f=/^(\S)/.match(string)[1] @@ -701,7 +700,7 @@ WOK while @letter < f if @alph.length > 0 @letter=@alph.shift - if @output[lng][:html_mnt].class==File + if @output[lng][:html_mnt].is_a?(File) @output[lng][:html_mnt] << %{\n

#{@letter}

} end @output[lng][:html] << %{\n

#{@letter}

} @@ -712,7 +711,7 @@ WOK name=string.strip.gsub(/\s+/,'_') html=%{

#{string}

} do_html(lng,html) - do_html_maintenance(lng,html) if @output[lng][:html_mnt].class==File + do_html_maintenance(lng,html) if @output[lng][:html_mnt].is_a?(File) end def do_array(lng,lv,array) lv+=1 @@ -733,7 +732,7 @@ WOK do_string_default(lng,attrib,html) end def do_hash_md_maintenance(lng,attrib,hash) - if @output[lng][:html_mnt].class==File #should not be run for presentation output + if @output[lng][:html_mnt].is_a?(File) #should not be run for presentation output html=%{[src]  #{hash[:title]} - #{hash[:author]}} do_string_maintenance(lng,attrib,html) end @@ -765,16 +764,15 @@ WOK end end def do_case(lng,lv,a) - y = a.class - case - when y==String + case a + when String attrib="lev#{lv}" if a=~/S/ lv==0 ? do_string_name(lng,attrib,a) : do_string(lng,attrib,a) end - when y==Array + when Array do_array(lng,lv,a) - when y==Hash + when Hash do_hash(lng,lv,a) end end diff --git a/lib/sisu/v3/html_format.rb b/lib/sisu/v3/html_format.rb index 1b950358..e16cbc5d 100644 --- a/lib/sisu/v3/html_format.rb +++ b/lib/sisu/v3/html_format.rb @@ -903,7 +903,7 @@ WOK attr_accessor :md,:t_o,:txt,:ocn,:format,:table,:link,:linkname,:paranum,:p_num,:headname,:banner,:url def initialize(md,t_o) @md,@t_o=md,t_o - if t_o.class==Hash + if t_o.is_a?(Hash) @txt =t_o[:txt] || nil @ocn =t_o[:ocn] || nil @ocn_display =t_o[:ocn_display] || nil diff --git a/lib/sisu/v3/html_promo.rb b/lib/sisu/v3/html_promo.rb index a2edea47..387da244 100644 --- a/lib/sisu/v3/html_promo.rb +++ b/lib/sisu/v3/html_promo.rb @@ -98,7 +98,7 @@ module SiSU_HTML_Promo elsif @flag[:sk] #promo set in associated skin promo_array=@vz.widget_promo elsif @flag[:rc] #promo set in rc file - promo_array=if @rc['html']['promo'].class==String + promo_array=if @rc['html']['promo'].is_a?(String) @rc['html']['promo'].split(/[,;]\s*/) else @rc['html']['promo'] end @@ -406,7 +406,7 @@ WOK adverts << output_form_select(type,id) else if defined? @ad[:promo][category][type][id] \ - and @ad[:promo][category][type][id].class==Array \ + and @ad[:promo][category][type][id].is_a?(Array) \ and @ad[:promo][category][type][id].length > 0 adverts << @ad[:promo][category][type][id].join("\n") end diff --git a/lib/sisu/v3/html_segments.rb b/lib/sisu/v3/html_segments.rb index bb77cb36..14c13d36 100644 --- a/lib/sisu/v3/html_segments.rb +++ b/lib/sisu/v3/html_segments.rb @@ -312,9 +312,9 @@ module SiSU_HTML_Seg @@get_hash_to=dob.name @@get_hash_fn=dob.name end - if dob.obj.class==String + if dob.obj.is_a?(String) markup(dob) - elsif dob.obj.class==Array + elsif dob.obj.is_a?(Array) dob.obj.each do |pg| markup(pg) end diff --git a/lib/sisu/v3/html_tune.rb b/lib/sisu/v3/html_tune.rb index f7b60cff..05126ede 100644 --- a/lib/sisu/v3/html_tune.rb +++ b/lib/sisu/v3/html_tune.rb @@ -101,7 +101,7 @@ module SiSU_HTML_Tune end def clean html=@html - str=if html.class==String + str=if html.is_a?(String) html else html.obj end diff --git a/lib/sisu/v3/hub.rb b/lib/sisu/v3/hub.rb index 2ab95052..8a67ce10 100644 --- a/lib/sisu/v3/hub.rb +++ b/lib/sisu/v3/hub.rb @@ -141,7 +141,7 @@ module SiSU number_of_files={} @opt.files.each_with_index do |fns,i| fn=fns.gsub(/(?:~(?:#{@r}))?\.ss[tm]$/,'') - if number_of_files[fn].class == Array + if number_of_files[fn].is_a?(Array) number_of_files[fn] << i else number_of_files.store(fn,[i]) diff --git a/lib/sisu/v3/manifest.rb b/lib/sisu/v3/manifest.rb index 743bc090..fdacf164 100644 --- a/lib/sisu/v3/manifest.rb +++ b/lib/sisu/v3/manifest.rb @@ -697,7 +697,7 @@ WOK @manifest[:html] << %{

#{@translate.topic_register}:

\n} @md.topic_register_array.each do |t| t.each_with_index do |st,i| - if st.class==Array + if st.is_a?(Array) st.each do |v| @manifest[:html] << %{

#{v}

\n} end diff --git a/lib/sisu/v3/manpage.rb b/lib/sisu/v3/manpage.rb index 31a64a57..81f2ed2c 100644 --- a/lib/sisu/v3/manpage.rb +++ b/lib/sisu/v3/manpage.rb @@ -415,7 +415,7 @@ WOK filename_manpage=SiSU_Env::FileOp.new(@md).write_file.manpage @sisu=[] @content.each do |para| # this is a hack - if para.class==Array \ + if para.is_a?(Array) \ and para.length > 0 para.each do |line| line=line.gsub(/\s+$/m,'') diff --git a/lib/sisu/v3/odf.rb b/lib/sisu/v3/odf.rb index d4d16b1d..807d2832 100644 --- a/lib/sisu/v3/odf.rb +++ b/lib/sisu/v3/odf.rb @@ -386,7 +386,7 @@ module SiSU_ODF end def footnote(t_o) str=if defined? t_o.obj then t_o.obj - elsif t_o.class==String then t_o + elsif t_o.is_a?(String) then t_o end if str @astx||=10000 @@ -421,7 +421,7 @@ module SiSU_ODF end end if defined? t_o.obj then t_o.obj=str - elsif t_o.class==String then t_o=str + elsif t_o.is_a?(String) then t_o=str end t_o end diff --git a/lib/sisu/v3/odf_format.rb b/lib/sisu/v3/odf_format.rb index 62eae47a..adfcf684 100644 --- a/lib/sisu/v3/odf_format.rb +++ b/lib/sisu/v3/odf_format.rb @@ -127,7 +127,7 @@ module SiSU_ODF_Format class FormatTextObject def initialize(md,t_o) @md,@t_o=md,t_o - if t_o.class==Hash + if t_o.is_a?(Hash) @txt =t_o[:txt] || nil else p t_o.class diff --git a/lib/sisu/v3/param.rb b/lib/sisu/v3/param.rb index 7a416bd9..64baf271 100644 --- a/lib/sisu/v3/param.rb +++ b/lib/sisu/v3/param.rb @@ -165,10 +165,10 @@ module SiSU_Param end def validate_length(s,l,n) #s=(s.length <= l) ? s : nil - s=if s.class==String \ + s=if s.is_a?(String) \ and s.length <= l s - elsif s.class==NilClass + elsif s.is_a?(NilClass) nil elsif s.class !=String STDERR.puts "#{n} is #{s.class}: programming error, String expected #{__FILE__}:#{__LINE__}" @@ -308,7 +308,7 @@ module SiSU_Param names=@h['editor'] \ ? name_format(@h['editor']) : nil - s=(names.class==Hash) \ + s=(names.is_a?(Hash)) \ ? names[:name_str] : nil s=if s @@ -321,7 +321,7 @@ module SiSU_Param names=@h['editor'] \ ? name_format(@h['editor']) : nil - (names.class==Hash) \ + (names.is_a?(Hash)) \ ? names[:name_a_h] : nil end @@ -329,7 +329,7 @@ module SiSU_Param names=@h['contributor'] \ ? name_format(@h['contributor']) : nil - s=(names.class==Hash) \ + s=(names.is_a?(Hash)) \ ? names[:name_str] : nil s=if s @@ -342,7 +342,7 @@ module SiSU_Param names=@h['contributor'] \ ? name_format(@h['contributor']) : nil - (names.class==Hash) \ + (names.is_a?(Hash)) \ ? names[:name_a_h] : nil end @@ -350,7 +350,7 @@ module SiSU_Param names=@h['illustrator'] \ ? name_format(@h['illustrator']) : nil - s=(names.class==Hash) \ + s=(names.is_a?(Hash)) \ ? names[:name_str] : nil s=if s @@ -363,7 +363,7 @@ module SiSU_Param names=@h['illustrator'] \ ? name_format(@h['illustrator']) : nil - (names.class==Hash) \ + (names.is_a?(Hash)) \ ? names[:name_a_h] : nil end @@ -371,7 +371,7 @@ module SiSU_Param names=@h['photographer'] \ ? name_format(@h['photographer']) : nil - s=(names.class==Hash) \ + s=(names.is_a?(Hash)) \ ? names[:name_str] : nil s=if s @@ -384,7 +384,7 @@ module SiSU_Param names=@h['photographer'] \ ? name_format(@h['photographer']) : nil - (names.class==Hash) \ + (names.is_a?(Hash)) \ ? names[:name_a_h] : nil end @@ -392,7 +392,7 @@ module SiSU_Param names=@h['translator'] \ ? name_format(@h['translator']) : nil - s=(names.class==Hash) \ + s=(names.is_a?(Hash)) \ ? names[:name_str] : nil s=if s @@ -405,7 +405,7 @@ module SiSU_Param names=@h['translator'] \ ? name_format(@h['translator']) : nil - (names.class==Hash) \ + (names.is_a?(Hash)) \ ? names[:name_a_h] : nil end @@ -413,7 +413,7 @@ module SiSU_Param names=@h['audio'] \ ? name_format(@h['audio']) : nil - s=(names.class==Hash) \ + s=(names.is_a?(Hash)) \ ? names[:name_str] : nil s=if s @@ -426,7 +426,7 @@ module SiSU_Param names=@h['audio'] \ ? name_format(@h['audio']) : nil - (names.class==Hash) \ + (names.is_a?(Hash)) \ ? names[:name_a_h] : nil end @@ -434,7 +434,7 @@ module SiSU_Param names=@h['digitized_by'] \ ? name_format(@h['digitized_by']) : nil - s=(names.class==Hash) \ + s=(names.is_a?(Hash)) \ ? names[:name_str] : nil s=if s @@ -447,7 +447,7 @@ module SiSU_Param names=@h['digitized_by'] \ ? name_format(@h['digitized_by']) : nil - (names.class==Hash) \ + (names.is_a?(Hash)) \ ? names[:name_a_h] : nil end @@ -455,7 +455,7 @@ module SiSU_Param names=@h['prepared_by'] \ ? name_format(@h['prepared_by']) : nil - s=(names.class==Hash) \ + s=(names.is_a?(Hash)) \ ? names[:name_str] : nil s=if s @@ -469,7 +469,7 @@ module SiSU_Param ? name_format(@h['prepared_by']) : nil names=name_format(@h['prepared_by']) - (names.class==Hash) \ + (names.is_a?(Hash)) \ ? names[:name_a_h] : nil end @@ -1186,7 +1186,7 @@ module SiSU_Param SiSU_Screen::Ansi.new(@opt.cmd,'No SiSU markup version provided').warn if @opt.cmd =~/[VM]/ end else - mv=if defined? @markup_version.determined and not @markup_version.determined.nil? + mv=if @markup_version.determined.is_a?(Float) x=@markup_version.determined "markup version determined #{x}" else '' @@ -1406,17 +1406,17 @@ module SiSU_Param @ec[:multimedia]=@ec[:multimedia].uniq.flatten.sort unless @rights if defined? @creator.author \ - and @creator.author \ + and @creator.author.is_a?(String) \ and defined? @date.published \ - and @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 + and @creator.author.is_a?(String) @rights=SiSU_Param::Parameters::MdDefault.new.rights("[#{@creator.author}]",'') end end if defined? @classify.topic_register \ - and not @classify.topic_register.nil? \ + and @classify.topic_register.is_a?(String) \ and @classify.topic_register.length >3 topic_register=@classify.topic_register u=topic_register.scan(/[^;]+/) diff --git a/lib/sisu/v3/plaintext.rb b/lib/sisu/v3/plaintext.rb index 2fa98883..c86fddb9 100644 --- a/lib/sisu/v3/plaintext.rb +++ b/lib/sisu/v3/plaintext.rb @@ -350,7 +350,7 @@ WOK p_num='' if @env.plaintext_ocn? if defined? dob.ocn \ - and not dob.ocn.nil? + and dob.ocn.is_a?(Fixnum) p_num=SiSU_PlaintextFormat::ParagraphNumber.new(dob.ocn).display end end @@ -409,7 +409,7 @@ WOK @sisu=[] emptyline=0 @content.each do |para| # this is a hack - if para.class==Array \ + if para.is_a?(Array) \ and para.length > 0 para.each do |line| if line diff --git a/lib/sisu/v3/plaintext_format.rb b/lib/sisu/v3/plaintext_format.rb index 445d8c66..fe24112d 100644 --- a/lib/sisu/v3/plaintext_format.rb +++ b/lib/sisu/v3/plaintext_format.rb @@ -76,7 +76,7 @@ module SiSU_PlaintextFormat class FormatTextObject def initialize(md,t_o) @md,@t_o=md,t_o - if t_o.class==Hash + if t_o.is_a?(Hash) @txt =t_o[:txt] || nil @lnk_url =t_o[:lnk_url] || nil @lnk_txt =t_o[:lnk_txt] || nil diff --git a/lib/sisu/v3/po4a.rb b/lib/sisu/v3/po4a.rb index 7ce825ee..53bab960 100644 --- a/lib/sisu/v3/po4a.rb +++ b/lib/sisu/v3/po4a.rb @@ -214,7 +214,7 @@ module SiSU_Po4a end desc="#{d}#{s_mark}#{instruct}" orig=(orig_notes[i].to_s =~/^\^~[\d*+]+/) ? (orig_notes[i].to_s.gsub(/^\^~[\d*+]+/,'^~')) : orig_notes[i].to_s - trans=if trn_notes.class==Array \ + trans=if trn_notes.is_a?(Array) \ and trn_notes.length==orig_notes.length (trn_notes[i].to_s =~/^\^~[\d*+]+/) ? (trn_notes[i].to_s.gsub(/^\^~[\d*+]+/,'^~')) : trn_notes[i].to_s else '' @@ -749,12 +749,12 @@ GSUB #next if data_trn[t].is == :comment end end - if (defined? data_src[s].ocn and data_src[s].ocn.class == Fixnum) \ - and (defined? data_trn[t].ocn and data_trn[t].ocn.class == Fixnum) \ + if (defined? data_src[s].ocn and data_src[s].ocn.is_a?(Fixnum)) \ + and (defined? data_trn[t].ocn and data_trn[t].ocn.is_a?(Fixnum)) \ and (data_src[s].ocn == data_trn[t].ocn) @m_s,@m_t=s,t - elsif (defined? data_src[s].ocn and data_src[s].ocn.class == Fixnum) \ - and (defined? data_trn[t].ocn and data_trn[t].ocn.class == Fixnum) \ + elsif (defined? data_src[s].ocn and data_src[s].ocn.is_a?(Fixnum)) \ + and (defined? data_trn[t].ocn and data_trn[t].ocn.is_a?(Fixnum)) \ and (data_src[s].ocn != data_trn[t].ocn) p '--- OCN ---' p 'mis-match' @@ -934,7 +934,7 @@ GSUB @sisu=[] emptyline=0 @content.each do |para| # this is a hack - if para.class==Array \ + if para.is_a?(Array) \ and para.length > 0 para.each do |line| if line diff --git a/lib/sisu/v3/po4a_set.rb b/lib/sisu/v3/po4a_set.rb index af6fba88..0dcc25a9 100644 --- a/lib/sisu/v3/po4a_set.rb +++ b/lib/sisu/v3/po4a_set.rb @@ -162,7 +162,7 @@ WOK line_wrap end def array_wrap - if @orig.class==Array + if @orig.is_a?(Array) @arr=[] @orig.each do |line| @arr << SiSU_TextUtils::Wrap.new(line,@n_char_max,@n_indent,@n_hang).line_wrap diff --git a/lib/sisu/v3/qrcode.rb b/lib/sisu/v3/qrcode.rb index dfd253d8..3908a1d4 100644 --- a/lib/sisu/v3/qrcode.rb +++ b/lib/sisu/v3/qrcode.rb @@ -668,7 +668,7 @@ WOK @sp=' ' @md.topic_register_array.each do |t| t.each_with_index do |st,i| - if st.class==Array + if st.is_a?(Array) st.each do |v| @manifest[:txt] << %{#{@sp*i}#{v}\n} end diff --git a/lib/sisu/v3/shared_markup_alt.rb b/lib/sisu/v3/shared_markup_alt.rb index 98c55e66..4efedff1 100644 --- a/lib/sisu/v3/shared_markup_alt.rb +++ b/lib/sisu/v3/shared_markup_alt.rb @@ -58,7 +58,7 @@ module SiSU_TextRepresentation class Alter def initialize(x) - if x.class==String + if x.is_a?(String) @t_o,@s=nil,x else @t_o,@s=x,x.obj.dup @@ -196,7 +196,7 @@ module SiSU_TextRepresentation class ModifiedTextPlusHashDigest def initialize(md,x) @md=md - if x.class==String + if x.is_a?(String) @t_o,@s=nil,x else @t_o,@s=x,x.obj.dup diff --git a/lib/sisu/v3/shared_metadata.rb b/lib/sisu/v3/shared_metadata.rb index a8698fd7..cd1e97db 100644 --- a/lib/sisu/v3/shared_metadata.rb +++ b/lib/sisu/v3/shared_metadata.rb @@ -259,12 +259,12 @@ module SiSU_Metadata meta << self.meta_para end if defined? @md.dgst \ - and @md.dgst.class==Array + and @md.dgst.is_a?(Array) @tag,@inf,@class='Source Digest',"#{@md.dgst[0]} #{@md.dgst[1]}",'src' meta << self.meta_para end if defined? @md.dgst_skin \ - and @md.dgst_skin.class==Array + and @md.dgst_skin.is_a?(Array) @tag,@inf,@class='Skin Digest',"#{@md.dgst_skin[0]} #{@md.dgst_skin[1]}",'src' meta << self.meta_para end @@ -288,7 +288,7 @@ module SiSU_Metadata meta << self.meta_para end if defined? @md.generated \ - and @md.generated.class==Time + and @md.generated.is_a?(Time) @tag,@inf,@class=tr.last_generated,@md.generated,'date' meta << self.meta_para end @@ -734,7 +734,7 @@ module SiSU_Metadata @s=str def utf8 if @s \ - and @s.class==String + and @s.is_a?(String) @s=@s.gsub(//u,Mx[:br_paragraph]). gsub(//,'>'). gsub(/<br(?: \/)?>/,'
') if @inf =~/&/ @@ -979,7 +979,7 @@ WOK @br="\\\\\n" end def meta_para(tag,inf,sc=true) - inf=((inf.class==String && sc) ? spec_char(inf) : inf) + inf=((inf.is_a?(String) && sc) ? spec_char(inf) : inf) %{\\begin\{bfseries\}#{tag}:\\end\{bfseries\} #{inf} } end @@ -1193,7 +1193,7 @@ WOK meta << meta_para(tag,inf) end if defined? @md.dgst \ - and @md.dgst.class==Array + and @md.dgst.is_a?(Array) hash_of=spec_char(@md.dgst[0]) hash_of=word_break_points(hash_of) dgst=number_break_points(@md.dgst[1]) @@ -1201,7 +1201,7 @@ WOK meta << meta_para(tag,inf,false) end if defined? @md.dgst_skin \ - and @md.dgst_skin.class==Array + and @md.dgst_skin.is_a?(Array) hash_of=spec_char(@md.dgst_skin[0]) hash_of=word_break_points(hash_of) dgst=number_break_points(@md.dgst_skin[1]) @@ -1210,7 +1210,7 @@ WOK end meta << %{#{@br}\\begin\{bfseries\}Generated \\end\{bfseries\}} if defined? @md.generated \ - and @md.generated.class==Time + and @md.generated.is_a?(Time) tag,inf=tr.last_generated,@md.generated meta << meta_para(tag,inf) end diff --git a/lib/sisu/v3/shared_txt.rb b/lib/sisu/v3/shared_txt.rb index 39363fcf..228109c1 100644 --- a/lib/sisu/v3/shared_txt.rb +++ b/lib/sisu/v3/shared_txt.rb @@ -114,7 +114,7 @@ module SiSU_TextUtils line_wrap end def array_wrap - if @para.class==Array + if @para.is_a?(Array) @arr=[] @para.each do |line| @arr << SiSU_TextUtils::Wrap.new(line,@n_char_max,@n_indent,@n_hang).line_wrap diff --git a/lib/sisu/v3/shared_xml.rb b/lib/sisu/v3/shared_xml.rb index 959170b6..6860d80c 100644 --- a/lib/sisu/v3/shared_xml.rb +++ b/lib/sisu/v3/shared_xml.rb @@ -110,7 +110,7 @@ module SiSU_XML_Munge def utf8(dob='') if @sys.locale =~/utf-?8/i # instead ucs for utf8 # String#encode Iñtërnâtiônàlizætiøn str=if defined? dob.obj then dob.obj - elsif dob.class==String then dob + elsif dob.is_a?(String) then dob end if str #¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûü @@ -217,7 +217,7 @@ module SiSU_XML_Munge dob=if defined? dob.obj dob.obj=str dob - elsif dob.class==String + elsif dob.is_a?(String) str end dob diff --git a/lib/sisu/v3/sst_to_s_xml_sax.rb b/lib/sisu/v3/sst_to_s_xml_sax.rb index 20f68aca..cc08be70 100644 --- a/lib/sisu/v3/sst_to_s_xml_sax.rb +++ b/lib/sisu/v3/sst_to_s_xml_sax.rb @@ -427,7 +427,7 @@ WOK @sisu=new_file_data.scan(/.+/) SiSU_Env::FileOp.new(@md).mkdir filename_sxm=SiSU_Env::FileOp.new(@md,@md.fn[:sxs]).mkfile_pwd - if filename_sxm.class==File + if filename_sxm.is_a?(File) @sisu.each {|para| filename_sxm.puts para} filename_sxm.close else puts 'file not created, is directory writable?' diff --git a/lib/sisu/v3/sysenv.rb b/lib/sisu/v3/sysenv.rb index a9df7b2a..1c813fd8 100644 --- a/lib/sisu/v3/sysenv.rb +++ b/lib/sisu/v3/sysenv.rb @@ -467,8 +467,8 @@ module SiSU_Env filename=(@fns =~/\.ssm\.sst$/) \ ? @fns.gsub(/\.ssm\.sst$/,'.ssm') : @fns - unless (filename.nil? \ - or filename.empty?) + if filename.is_a?(String) \ + and not filename.empty? if output_dir_structure.by_language_code? m=/((.+?)(?:\~\w{2,3})?)\.(sst|ssm)$/ @fn[:b],@fn[:m],@fn[:t]=filename[m,1],filename[m,2],filename[m,3] @@ -988,7 +988,7 @@ module SiSU_Env elsif defined? @env.fnb \ and @env.fnb @env.fnb - elsif not @fns.nil? \ + elsif @fns.is_a?(String) \ and not @fns.empty? m=/(.+)?\.(?:(?:-|ssm\.)?sst|ssm)$/m @fns[m,1] if not @fns.empty? @@ -1191,25 +1191,25 @@ module SiSU_Env end def html_minitoc? flag=if defined? @rc['html']['minitoc'] \ - and not @rc['html']['minitoc'].nil? + and @rc['html']['minitoc'].is_a?(String) @rc['html']['minitoc'] else false end end def manifest_minitoc? - flag=if (defined? @rc['manifest']['minitoc'] \ - and not @rc['manifest']['minitoc'].nil?) + flag=if defined? @rc['manifest']['minitoc'] \ + and @rc['manifest']['minitoc'].is_a?(String) @rc['manifest']['minitoc'] else false end end def build def omit_list - @off_list ||=if (defined? @rc['omit_list'] \ - and not @rc['omit_list'].nil?) + @off_list ||=if defined? @rc['omit_list'] \ + and @rc['omit_list'].is_a?(String) @rc['omit_list'] - elsif (defined? @rc['omit']['list'] \ - and not @rc['omit']['list'].nil?) + elsif defined? @rc['omit']['list'] \ + and @rc['omit']['list'].is_a?(String) @rc['omit']['list'] else nil @@ -1388,7 +1388,7 @@ module SiSU_Env true elsif defined? @vz.widget_promo \ and not @vz.widget_promo.nil? \ - and @vz.widget_promo.class==Array \ + and @vz.widget_promo.is_a?(Array) \ and @vz.widget_promo.length > 0 @flag[:sk]=true true @@ -2075,8 +2075,7 @@ WOK end def dal pth=if defined? @rc['processing']['dal'] \ - and not @rc['processing']['dal'].nil? \ - and not @rc['processing']['dal'].empty? + and @rc['processing']['dal'].is_a?(String) "#{processing}/#{@rc['processing']['dal']}" else "#{processing}/#{defaults[:processing_dal]}" end @@ -2085,8 +2084,7 @@ WOK end def tune pth=if defined? @rc['processing']['tune'] \ - and not @rc['processing']['tune'].nil? \ - and not @rc['processing']['tune'].empty? + and @rc['processing']['tune'].is_a?(String) "#{processing}/#{@rc['processing']['tune']}" else "#{processing}/#{defaults[:processing_tune]}" end @@ -2100,8 +2098,7 @@ WOK end def git pth=if defined? @rc['git']['dir'] \ - and not @rc['git']['dir'].nil? \ - and not @rc['git']['dir'].empty? + and @rc['git']['dir'].is_a?(String) x=(@rc['git']['dir'] =~/^(?:~|home)$/) \ ? home + '/' + Gt[:git] : @rc['git']['dir'] + '/' + Gt[:git] @@ -2166,8 +2163,7 @@ WOK end def tex pth=if defined? @rc['processing']['latex'] \ - and not @rc['processing']['latex'].nil? \ - and not @rc['processing']['latex'].empty? + and @rc['processing']['latex'].is_a?(String) "#{processing}/#{@rc['processing']['latex']}" else "#{processing}/#{defaults[:processing_latex]}" end @@ -2176,8 +2172,7 @@ WOK end def texi pth=if defined? @rc['processing']['texinfo'] \ - and not @rc['processing']['texinfo'].nil? \ - and not @rc['processing']['texinfo'].empty? + and @rc['processing']['texinfo'].is_a?(String) "#{processing}/#{@rc['processing']['texinfo']}" else "#{processing}/#{defaults[:processing_texinfo]}" end @@ -2192,8 +2187,7 @@ WOK end def lout pth=if defined? @rc['processing']['lout'] \ - and not @rc['processing']['lout'].nil? \ - and not @rc['processing']['lout'].empty? + and @rc['processing']['lout'].is_a?(String) "#{processing}/#{@rc['processing']['lout']}" else "#{processing}/#{defaults[:processing_lout]}" end @@ -2207,8 +2201,7 @@ WOK end def sqlite pth=if defined? @rc['processing']['sqlite'] \ - and not @rc['processing']['sqlite'].nil? \ - and not @rc['processing']['sqlite'].empty? + and @rc['processing']['sqlite'].is_a?(String) "#{processing}/#{@rc['processing']['sqlite']}" else "#{processing}/#{defaults[:processing_sqlite]}" end @@ -2217,8 +2210,7 @@ WOK end def postgresql pth=if defined? @rc['processing']['postgresql'] \ - and not @rc['processing']['postgresql'].nil? \ - and not @rc['processing']['postgresql'].empty? + and @rc['processing']['postgresql'].is_a?(String) "#{processing}/#{@rc['processing']['postgresql']}" else "#{processing}/#{defaults[:processing_postgresql]}" end @@ -2333,7 +2325,7 @@ WOK end def webserv_cgi #web url for local webserv (localhost, or hostname) if defined? @rc['webserv_cgi']['host'] \ - and not @rc['webserv_cgi']['host'].nil? + and @rc['webserv_cgi']['host'].is_a?(String) http=((@rc['webserv_cgi']['host'] =~ /https?:\/\//) ? '' : 'http://') #check https? missing if webserv_port_cgi "#{http}#{@rc['webserv_cgi']['host']}:#{webserv_port_cgi}/#{@stub_pwd}" @@ -2349,7 +2341,7 @@ WOK end def webserv_base_cgi #web url for local webserv (localhost, or hostname) if defined? @rc['webserv_cgi']['host'] \ - and not @rc['webserv_cgi']['host'].nil? + and @rc['webserv_cgi']['host'].is_a?(String) http=((@rc['webserv_cgi']['host'] =~ /https?:\/\//) ? '' : 'http://') if webserv_port_cgi "#{http}#{@rc['webserv_cgi']['host']}:#{webserv_port_cgi}" @@ -2365,7 +2357,7 @@ WOK end def webrick #must have a port #REMOVE if defined? @rc['webserv_cgi']['host'] \ - and not @rc['webserv_cgi']['host'].nil? + and @rc['webserv_cgi']['host'].is_a?(String) http=if @rc['webserv_cgi']['host'] =~/http:\/\// 'http://' elsif @rc['webserv_cgi']['host'] =~/https:\/\// @@ -2374,7 +2366,7 @@ WOK end "#{http}#{@rc['webserv_cgi']['host']}" elsif webserv_host_base \ - and not webserv_host_base.nil? + and webserv_host_base.is_a?(String) "#{http}#{webserv_host_base}" else "#{http}localhost" end end @@ -2743,48 +2735,42 @@ WOK end def cf_0 #processing flag shortcuts if defined? @rc['flag']['default'] \ - and not (@rc['flag']['default'].nil? \ - or @rc['flag']['default'].empty?) + and @rc['flag']['default'].is_a?(String) @rc['flag']['default'] else '-NQhewpotbxXdyYv' end end def cf_1 #processing flag shortcuts if defined? @rc['flag']['i'] \ - and not (@rc['flag']['i'].nil? \ - or @rc['flag']['i'].empty?) + and @rc['flag']['i'].is_a?(String) @rc['flag']['i'] else '-Qhewpoty' end end def cf_2 #processing flag shortcuts if defined? @rc['flag']['ii'] \ - and not (@rc['flag']['ii'].nil? \ - or @rc['flag']['ii'].empty?) + and @rc['flag']['ii'].is_a?(String) @rc['flag']['ii'] else '-NQhewpotbxXdy' end end def cf_3 #processing flag shortcuts if defined? @rc['flag']['iii'] \ - and not (@rc['flag']['iii'].nil? \ - or @rc['flag']['iii'].empty?) + and @rc['flag']['iii'].is_a?(String) @rc['flag']['iii'] else '-NQhewpotbxXdyY' end end def cf_4 #processing flag shortcuts if defined? @rc['flag']['iv'] \ - and not (@rc['flag']['iv'].nil? \ - or @rc['flag']['iv'].empty?) + and @rc['flag']['iv'].is_a?(String) @rc['flag']['iv'] else '-NQhewpotbxXdDyY --update' end end def cf_5 #processing flag shortcuts if defined? @rc['flag']['v'] \ - and not (@rc['flag']['v'].nil? \ - or @rc['flag']['v'].empty?) + and @rc['flag']['v'].is_a?(String) @rc['flag']['v'] else '-NQhewpotbxXdDyYv --update' end @@ -2982,7 +2968,7 @@ WOK def remote_host #see InfoRemote remote_host_base_general r=[] r=if (defined? @rc['remote'] \ - and @rc['remote'].class==Array) + and @rc['remote'].is_a?(Array)) r_array=@rc['remote'] r_array.each_with_index do |renv,i| r[i]={} @@ -2999,7 +2985,7 @@ WOK end r elsif (defined? @rc['remote'] \ - and @rc['remote'].class==Hash \ + and @rc['remote'].is_a?(Hash) \ and defined? @rc['remote']['user'] \ and defined? @rc['remote']['host']) r[0]={} @@ -3877,7 +3863,7 @@ WOK def port #PGPORT ((defined? @rc['db']['postgresql']['port']) \ && ( @rc['db']['postgresql']['port'] =~/\d+/ \ - || @rc['db']['postgresql']['port'].class==Fixnum)) \ + || @rc['db']['postgresql']['port'].is_a?(Fixnum))) \ ? @rc['db']['postgresql']['port'] : (@defaults[:postgresql_port]) end @@ -5641,7 +5627,7 @@ WOK class InfoSkin def initialize(md=nil,skin=nil) @md=md - @d_sk=if skin.class==String + @d_sk=if skin.is_a?(String) skin elsif defined? md.doc_skin \ and md.doc_skin diff --git a/lib/sisu/v3/texinfo_format.rb b/lib/sisu/v3/texinfo_format.rb index 7374d01e..78f2a188 100644 --- a/lib/sisu/v3/texinfo_format.rb +++ b/lib/sisu/v3/texinfo_format.rb @@ -66,10 +66,10 @@ module SiSU_TexInfoFormat @@tex_pattern_margin_number="\\\\marginpar.+?\s+" def initialize(md,dob=nil) @md,@dob=md,dob - if dob.class==Hash + if dob.is_a?(Hash) p dob.class p caller - elsif dob.class==String + elsif dob.is_a?(String) p dob.class p caller end diff --git a/lib/sisu/v3/texpdf.rb b/lib/sisu/v3/texpdf.rb index fc007a4f..0665c9b4 100644 --- a/lib/sisu/v3/texpdf.rb +++ b/lib/sisu/v3/texpdf.rb @@ -401,8 +401,8 @@ module SiSU_TeX def tables(data) @tex_file=[] data.each do |dob| - @tex_file << if dob.class==String \ - or dob.class==Hash + @tex_file << if dob.is_a?(String) \ + or dob.is_a?(Hash) dob elsif dob.is==:table tables_hash(@md,dob) #Hash result @@ -538,12 +538,12 @@ module SiSU_TeX idx_arr=[] idx=SiSU_Particulars::CombinedSingleton.instance.get_idx_raw(@md.opt).raw_idx idx.each do |x| - x=if x.class==String + x=if x.is_a?(String) x=SiSU_TeX_Pdf::SpecialCharacters.new(@md,x).special_characters x=SiSU_TeX_Pdf::FormatTextObject.new(@md,x).url_str_internal(x,true) else x=nil end - idx_arr << x.sub(/,$/,'') if x.class==String + idx_arr << x.sub(/,$/,'') if x.is_a?(String) end idx_str=idx_arr.join(br) l=heading + br + idx_str @@ -582,7 +582,7 @@ module SiSU_TeX dob.tmp=dob.tmp.strip unless dob.is==:code dob=enclose(dob) unless dob.tmp =~/^$/ end - if dob.class==String + if dob.is_a?(String) dob.tmp=dob.tmp.gsub(/\s*(?:#{Mx[:br_line]}|#{Mx[:br_nl]})\s*/,' \newline '). #% tread with care gsub(/(\.#{Tex[:tilde]}\S*\s*|<:\S+>|#{Mx[:fa_o]}.*?#{Mx[:fa_c]}|#{Mx[:gr_o]}.*?#{Mx[:gr_c]}||)/,' ') #% tread with care end @@ -776,7 +776,7 @@ WOK @tex_file << x x=nil data.each do |dob| #% case follows with levels 1-6 indents & graphics - if dob.class==Hash + if dob.is_a?(Hash) elsif dob.of==:para \ || dob.of==:block #GATEWAY FIX FIX stuff dob=markup_common(dob) @@ -797,7 +797,7 @@ WOK end end end - elsif dob.tmp.class==Hash \ + elsif dob.tmp.is_a?(Hash) \ and (dob.tmp[:p] and dob.tmp[:l]) dob = { p: markup_common(dob.tmp[:p]), @@ -844,7 +844,7 @@ WOK def number_paras(data) tex_file=[] data.each do |dob| - dob=if dob.class==Hash + dob=if dob.is_a?(Hash) if ( dob['a4'] \ or dob['a5'] \ or dob['b5'] \ @@ -932,7 +932,7 @@ WOK file[:portrait] << @@tex_head[ps][:p] file[:landscape] << @@tex_head[ps][:l] array.each do |morph| - if morph.class==String + if morph.is_a?(String) #morph.gsub!(/^\s+/,'') if morph !~/\A\s*\Z/ file[:portrait].puts morph,"\n" @@ -940,7 +940,7 @@ WOK end elsif morph.class.inspect =~ /SiSU_DAL_DocumentStructure/ \ and morph.tmp \ - and morph.tmp.class==String + and morph.tmp.is_a?(String) if morph.is !=:code \ && morph.of !=:block morph.tmp=morph.tmp.gsub(/^\s+/,'') @@ -951,10 +951,10 @@ WOK file[:portrait].puts morph.tmp,"\n" file[:landscape].puts morph.tmp,"\n" end - elsif morph.class==Hash #inserted headers and the like, only + elsif morph.is_a?(Hash) #inserted headers and the like, only h={ ps: ps, h: morph, filename: file } output_morph_hash(h) - elsif morph.tmp.class==Hash #tables & images? + elsif morph.tmp.is_a?(Hash) #tables & images? h={ ps: ps, h: morph.tmp, filename: file } output_morph_hash(h) end diff --git a/lib/sisu/v3/texpdf_format.rb b/lib/sisu/v3/texpdf_format.rb index 43763157..a7331447 100644 --- a/lib/sisu/v3/texpdf_format.rb +++ b/lib/sisu/v3/texpdf_format.rb @@ -719,7 +719,7 @@ module SiSU_TeX_Pdf def initialize(md,t_o) @md,@t_o=md,t_o @env=SiSU_Env::InfoEnv.new(@md.fns) - if t_o.class==Hash + if t_o.is_a?(Hash) @txt =t_o[:txt] || nil @subtitle=t_o[:subtitle] || nil @ps=t_o[:paper_size] || nil diff --git a/lib/sisu/v3/xhtml_table.rb b/lib/sisu/v3/xhtml_table.rb index 753b0242..30701433 100644 --- a/lib/sisu/v3/xhtml_table.rb +++ b/lib/sisu/v3/xhtml_table.rb @@ -84,7 +84,7 @@ module SiSU_XHTML_Table end nc+=1 end - trc=trc.class==Array ? trc.flatten.join : trc + trc=(trc.is_a?(Array)) ? trc.flatten.join : trc trc=" #{trc}\n" nr+=1 table_rows << trc diff --git a/lib/sisu/v3/xml_format.rb b/lib/sisu/v3/xml_format.rb index a9f6fb01..54d889cd 100644 --- a/lib/sisu/v3/xml_format.rb +++ b/lib/sisu/v3/xml_format.rb @@ -999,7 +999,7 @@ WOK attr_accessor :md,:dob,:txt,:ocn,:format,:table,:link,:linkname,:paranum,:p_num,:headname,:banner,:url def initialize(md,t_o) @md,@t_o=md,t_o - if t_o.class==Hash + if t_o.is_a?(Hash) @txt =t_o[:txt] || nil @ocn =t_o[:ocn] || nil @ocn_display =t_o[:ocn_display] || nil -- cgit v1.2.3 From 5e1bcfbb6cdde447298d10115d1d2f9de0bb99a2 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Mon, 1 Oct 2012 15:45:00 -0400 Subject: v3: cosmetic code, remove javascript holders js_ (not used) --- lib/sisu/v3/concordance.rb | 4 +- lib/sisu/v3/defaults.rb | 105 +++++++--------------------------------- lib/sisu/v3/epub_concordance.rb | 2 +- lib/sisu/v3/epub_format.rb | 13 +++-- lib/sisu/v3/html_format.rb | 52 ++++++++++---------- lib/sisu/v3/xml_format.rb | 25 +++++----- 6 files changed, 62 insertions(+), 139 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v3/concordance.rb b/lib/sisu/v3/concordance.rb index 2a3b585a..a7581112 100644 --- a/lib/sisu/v3/concordance.rb +++ b/lib/sisu/v3/concordance.rb @@ -118,7 +118,7 @@ module SiSU_Concordance @fnb=@md.fnb @lex_button=%{SiSU home -->} @doc_details =< 

#{@md.title.full}

#{@md.author}

+
 

#{@md.title.full}

#{@md.author}

WOK end def create @@ -151,10 +151,8 @@ WOK #{stylesheet.css_head_seg} - #{@vz.js_head} - #{@vz.js_top} #{top_band} #{toc}
diff --git a/lib/sisu/v3/defaults.rb b/lib/sisu/v3/defaults.rb index 47e3c970..6a082813 100644 --- a/lib/sisu/v3/defaults.rb +++ b/lib/sisu/v3/defaults.rb @@ -80,75 +80,6 @@ module SiSU_Viz #% php def php_persist end - #% javascript #kxjs knxjs - def js_home - end - def js_infobox - end - def js_knxjs - end - def js_head - end - def js_top - end - def js_sisu - end - def js_home - end - def js_sponsor - end - def js_books - end - def js_journals - end - def js_conferences - end - def js_services - end - def js_catalogue - end - def js_doc - end - def js_toc - end - def js_seg - end - def js_mail - end - def js_manifest - end - def js_status - end - def js_next - end - def js_prev - end - def js_plaintext - end - def js_portrait - end - def js_landscape - end - def js_pdf - end - def js_epub - end - def js_odf - end - def js_concordance - end - def js_instruments - end - def js_external - end - def js_gopher - end - def js_ftp - end - def js_law - end - def js_disclaimer - end def semantic_tags def default { @@ -1187,7 +1118,7 @@ module SiSU_Viz #% banner def banner_home %{
- + #{png_site}
@@ -1202,23 +1133,23 @@ module SiSU_Viz end def banner_home_guide %{
- + #{png_doc} LM toc - + #{png_doc} LM 20**
} end def banner_home_button_only - %{ + %{ #{png_home_button} } end def banner_home_button #yellow_dark now white %{ @@ -1230,7 +1161,7 @@ module SiSU_Viz
- + #{png_home_button}
@@ -1240,7 +1171,7 @@ module SiSU_Viz
- + #{png_home}
@@ -222,7 +222,7 @@ module SiSU_HTML_Format end def seg(text) %{ @@ -244,7 +244,7 @@ module SiSU_HTML_Format else @file.base_filename.manifest end %{} @@ -256,12 +256,12 @@ module SiSU_HTML_Format and @cf_defaults.cf_0 =~/p/ %{ @@ -331,13 +331,13 @@ WOK def manifest_link(text) # @file=SiSU_Env::FileOp.new(@md) if @md %{ - #{text} + #{text} } end def concordance_link(text) if @md.concord_make %{ - + #{text} } @@ -394,14 +394,13 @@ WOK #{@vz.color_body} - -#{@vz.js_top}} +} end def concordance if @md.concord_make %{#{@vz.margin_css}

- + Concordance

@@ -418,7 +417,7 @@ WOK
- +  This text's sub- 
 Table of Contents  @@ -1254,12 +1185,12 @@ module SiSU_Viz #{table_close}} end def banner_url_txt_sisu - %{
SiSU} + %{SiSU} end def banner_band #yellow_dark now white %{ @@ -1541,7 +1472,7 @@ WOK < Output generated by - + #{@v[:project]} #{@v[:version]} #{@v[:date]} (#{@v[:date_stamp]}) @@ -1562,7 +1493,7 @@ WOK
- + #{png_home}

- + SiSU

@@ -1570,33 +1501,33 @@ WOK

Output generated by - + #{@v[:project]} #{@v[:version]} #{@v[:date]} (#{@v[:date_stamp]})
- + #{@v[:project]} Copyright © Ralph Amissah 1997, current #{@date.year_static}. All Rights Reserved.
- + #{@v[:project]} is software for document structuring, publishing and search,
- + www.sisudoc.org/ and - + www.sisudoc.org
w3 since October 3 1993 - + ralph@amissah.com

@@ -1624,7 +1555,7 @@ WOK

- + #{@v[:project]} is released under diff --git a/lib/sisu/v3/epub_concordance.rb b/lib/sisu/v3/epub_concordance.rb index 224578b6..b8db317d 100644 --- a/lib/sisu/v3/epub_concordance.rb +++ b/lib/sisu/v3/epub_concordance.rb @@ -105,7 +105,7 @@ module SiSU_EPUB_Concordance @fnb=@md.fnb @lex_button=%{SiSU home -->} @doc_details =<

 

#{@md.title.full}

#{@md.creator.author}

+
 

#{@md.title.full}

#{@md.creator.author}

WOK end def create diff --git a/lib/sisu/v3/epub_format.rb b/lib/sisu/v3/epub_format.rb index cc98219c..ab6f34c7 100644 --- a/lib/sisu/v3/epub_format.rb +++ b/lib/sisu/v3/epub_format.rb @@ -1673,7 +1673,7 @@ WOK end def copyat %{

copy @ - + #{@vz.txt_home}

} end @@ -1706,11 +1706,11 @@ WOK : %{

#{firstseg}

} end def manifest_link(text) - %{ #{text}} + %{ #{text}} end def concordance_link(text) if @md.concord_make - %{ + %{ #{text} } else '' @@ -1722,14 +1722,13 @@ WOK #{@css.xhtml_epub} -#{@vz.color_body} -#{@vz.js_top}} +#{@vz.color_body}} end def concordance if @md.concord_make %{#{@vz.margin_css}

- + Concordance

@@ -1787,7 +1786,7 @@ WOK def metadata %{#{@vz.margin_css}

- + MetaData

diff --git a/lib/sisu/v3/html_format.rb b/lib/sisu/v3/html_format.rb index e16cbc5d..433652e0 100644 --- a/lib/sisu/v3/html_format.rb +++ b/lib/sisu/v3/html_format.rb @@ -184,7 +184,7 @@ module SiSU_HTML_Format end def copyat %{#{@vz.paragraph_font_tiny}copy @ - + #{@vz.txt_home} } end @@ -213,7 +213,7 @@ module SiSU_HTML_Format def scroll(text) if @md.fns =~ /\.(?:-|ssm\.)?sst$/ scroll=%{
- + #{text} - + #{text} - + #{@vz.nav_txt_manifest} - + #{@vz.nav_txt_pdf_portrait} - + #{@vz.nav_txt_pdf_landscape}
- + #{png_nav.dot_pre} - + #{png_nav.dot_toc} - + #{png_nav.dot_nxt} #{@vz.table_close}} @@ -655,17 +654,17 @@ WOK nxt="#{@md.file.base_filename.html_segtoc}" %{} pre=%{} if f_pre==true nxt=%{} if f_nxt==true @@ -714,7 +713,7 @@ WOK end def manifest_link(text) %{ - + #{text} } @@ -722,7 +721,7 @@ WOK def concordance_link(text) if @md.concord_make %{ - + #{text} } @@ -856,8 +855,7 @@ WOK #{@vz.color_body} - -#{@vz.js_top}} +} end def title_banner(title,subtitle,creator) %{ diff --git a/lib/sisu/v3/xml_format.rb b/lib/sisu/v3/xml_format.rb index 54d889cd..1c6aa67d 100644 --- a/lib/sisu/v3/xml_format.rb +++ b/lib/sisu/v3/xml_format.rb @@ -389,7 +389,7 @@ WOK end def copyat %{#{@vz.paragraph_font_tiny}copy @ - + #{@vz.txt_home} } end @@ -541,8 +541,7 @@ WOK #{@vz.color_body} - -#{@vz.js_top}} +} end def links_guide_open(type='horizontal') if type=='vertical'; links_guide_vertical_open @@ -629,7 +628,7 @@ WOK def metadata %{#{@vz.margin_css}

- + MetaData

@@ -719,25 +718,24 @@ WOK #{@vz.color_body} - -#{@vz.js_top}} +} end def title_banner(title,subtitle,creator) end def dot_control_pre_next %{
- + #{png_nav.dot_pre} - + #{png_nav.dot_toc} - + #{png_nav.dot_nxt} #{@vz.table_close}} @@ -673,17 +672,17 @@ WOK def toc_nav(f_pre=false,f_nxt=false,use=1) pre=nxt='' toc=%{ - + #{png_nav.toc} - + #{png_nav.pre} - + #{png_nav.nxt}
} pre=%{} if f_pre==true nxt=%{} if f_nxt==true @@ -935,8 +933,7 @@ WOK #{@vz.color_body} - -#{@vz.js_top}} +} end def title_banner(title,subtitle,creator) %{ -- cgit v1.2.3 From d98f27086318452017b80952a297f2ccb05bc4b1 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Mon, 1 Oct 2012 16:09:17 -0400 Subject: v3: some fixes, cleaning, removing --- lib/sisu/v3/concordance.rb | 2 +- lib/sisu/v3/defaults.rb | 5 - lib/sisu/v3/epub.rb | 15 +-- lib/sisu/v3/epub_format.rb | 43 ++------- lib/sisu/v3/harvest_authors.rb | 3 +- lib/sisu/v3/harvest_topics.rb | 12 +-- lib/sisu/v3/html.rb | 5 +- lib/sisu/v3/html_format.rb | 48 +--------- lib/sisu/v3/html_scroll.rb | 36 +++++--- lib/sisu/v3/html_segments.rb | 2 - lib/sisu/v3/hub.rb | 9 +- lib/sisu/v3/manifest.rb | 6 +- lib/sisu/v3/manpage_format.rb | 5 - lib/sisu/v3/options.rb | 6 +- lib/sisu/v3/param.rb | 33 ++++--- lib/sisu/v3/qrcode.rb | 8 +- lib/sisu/v3/screen_text_color.rb | 15 +-- lib/sisu/v3/shared_images.rb | 2 +- lib/sisu/v3/sysenv.rb | 131 ++++++++++++-------------- lib/sisu/v3/texpdf_format.rb | 3 +- lib/sisu/v3/urls.rb | 5 +- lib/sisu/v3/webrick.rb | 195 ++++++++++++++++++++------------------- lib/sisu/v3/xml_format.rb | 19 ---- lib/sisu/v3/xml_tables.rb | 12 +-- 24 files changed, 251 insertions(+), 369 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v3/concordance.rb b/lib/sisu/v3/concordance.rb index a7581112..84245643 100644 --- a/lib/sisu/v3/concordance.rb +++ b/lib/sisu/v3/concordance.rb @@ -134,7 +134,7 @@ WOK div_class='content0' end top_band=if make.build.html_top_band? - head_banner.concordance_navigation_band('pdf') + head_banner.concordance_navigation_band else '' end <} end - def paragraph_table_xml - end def paragraph_tiny %{

} end diff --git a/lib/sisu/v3/epub.rb b/lib/sisu/v3/epub.rb index f3b94e3d..a4dce6ab 100644 --- a/lib/sisu/v3/epub.rb +++ b/lib/sisu/v3/epub.rb @@ -142,7 +142,6 @@ module SiSU_EPUB def tuned_file_instructions @tell=SiSU_Screen::Ansi.new(@md.opt.cmd) @md.opt.cmd=@md.opt.cmd.gsub(/H/,'h') - @md.file_type='html' if @md.opt.cmd =~/[hon]/ directories dal_array=@particulars.dal_array # dal file drawn here @tuned_file_array=SiSU_EPUB_Tune::Tune.new(dal_array,@md).songsheet @@ -490,10 +489,6 @@ module SiSU_EPUB dochead=dochead.gsub(/toc\.(html)/,'doc.\1') #kludge toc_shared << dochead #<< ads.div.major segtoc << format_head_toc.head #<< ads.div.major - if SiSU_EPUB_Format::HeadToc.method_defined? :toc_head_escript - toc_shared << format_head_toc.toc_head_escript - segtoc << format_head_toc.toc_head_escript - end if defined? @md.rights.all \ and @md.rights.all rights=format_head_toc.rights.all @@ -504,8 +499,6 @@ module SiSU_EPUB prefix_b=format_head_toc.prefix_b prefix_b=SiSU_EPUB_Tune::CleanXHTML.new(prefix_b).clean end - seg_toc_band=format_head_toc.seg_head_navigation_band - seg_toc_band_bottom=format_head_toc.seg_head_navigation_band_bottom tmp_head=nil doc_title_endnote=@md.title.full.gsub(/(\*+)/,'\1') tmp_head=doc_title_endnote + "\n" @@ -522,7 +515,6 @@ module SiSU_EPUB toc_shared << format_txt_obj.center_bold segtoc << format_txt_obj.center_bold end - segtoc << seg_toc_band tmp_head=nil if defined? @md.prefix_a \ and @md.prefix_a @@ -553,7 +545,6 @@ module SiSU_EPUB segtoc << prefix_b end #Segtoc tail added here - segtoc << seg_toc_band_bottom segtoc << format_head_toc.xhtml_close segtoc=segtoc.flatten.compact #watch SiSU_EPUB::Source::Output.new(@md,segtoc).segtoc @@ -667,14 +658,14 @@ module SiSU_EPUB def segtoc begin if @make.build.toc? - filename_html_index=@make_file.epub.xhtml_index + filename_xhtml=@make_file.epub.xhtml_index @output.each do |para| para=para.strip unless para =~/\A\s*\Z/ - filename_html_index.puts para,"\n" + filename_xhtml.puts para,"\n" end end - filename_html_index.close + filename_xhtml.close end rescue SiSU_Errors::InfoError.new($!,$@,@md.opt.cmd,@md.fns).error do diff --git a/lib/sisu/v3/epub_format.rb b/lib/sisu/v3/epub_format.rb index ab6f34c7..70636fb1 100644 --- a/lib/sisu/v3/epub_format.rb +++ b/lib/sisu/v3/epub_format.rb @@ -1233,7 +1233,7 @@ WOK end def doc_type_xhtml < + @@ -1277,7 +1277,7 @@ WOK #simple, make sure full-path of rootfile points to metadata.opf #epub_metadata.opf content.opf < + @@ -1298,7 +1298,7 @@ WOK #{dob.obj} - #{@md.html_title} - + #{@css.xhtml_epub} #{@vz.color_body} @@ -1435,7 +1435,7 @@ WOK end def package_open < + WOK end @@ -1658,24 +1658,9 @@ WOK end self end - def toc_head_escript - end - def seg_head_escript - end def table_close %{ #{@vz.table_close}} - end - def buttons_home - %{ - #{@vz.banner_home_and_index_buttons} -} - end - def copyat - %{

copy @ - - #{@vz.txt_home} -

} end def xhtml_close %{#{@vz.credits_sisu_epub} @@ -1689,22 +1674,6 @@ WOK @md=md @tocband_segtoc=make_seg end - def seg_head_navigation_band - firstseg=%{ - #{@vz.epub_png_nav_nxt} - } if @md.firstseg =~/\S+/ - DISABLE[:epub][:internal_navigation] \ - ? '' - : %{

#{firstseg}

} - end - def seg_head_navigation_band_bottom - firstseg=%{ - #{@vz.epub_png_nav_nxt} - } if @md.firstseg =~/\S+/ - DISABLE[:epub][:internal_navigation] \ - ? '' - : %{

#{firstseg}

} - end def manifest_link(text) %{ #{text}} end @@ -1719,7 +1688,7 @@ WOK def head %{#{doc_type} - + #{@css.xhtml_epub} #{@vz.color_body}} @@ -1804,7 +1773,7 @@ WOK #{@seg_name_xhtml[@seg_name_xhtml_tracker]} - #{@md.html_title} - + #{@css.xhtml_epub} #{@vz.color_body}} diff --git a/lib/sisu/v3/harvest_authors.rb b/lib/sisu/v3/harvest_authors.rb index 7c044425..1846584a 100644 --- a/lib/sisu/v3/harvest_authors.rb +++ b/lib/sisu/v3/harvest_authors.rb @@ -117,7 +117,7 @@ module SiSU_HarvestAuthors if para=~ rgx[:date] @date=rgx[:date].match(para)[1] end - break if @title and @subtitle and @author and @date + break if @title && @subtitle && @author && @date end @fulltitle=@subtitle ? (@title + ' - ' + @subtitle) : @title if @title \ @@ -354,6 +354,7 @@ WOK x[:file] + '.' + lng + '.html' elsif @env.output_dir_structure.by? == :filename "../#{x[:file]}/#{x[:page]}" + else '' #error end work=[ "#{x[:date]} #{x[:title]}", %{

#{x[:date]} #{x[:title]}, #{x[:author][:authors_s]}

} ] works<<=(@output[lng][:html_mnt].is_a?(File)) \ diff --git a/lib/sisu/v3/harvest_topics.rb b/lib/sisu/v3/harvest_topics.rb index 952f1411..445d8c8e 100644 --- a/lib/sisu/v3/harvest_topics.rb +++ b/lib/sisu/v3/harvest_topics.rb @@ -118,7 +118,7 @@ module SiSU_HarvestTopics if para=~ rgx[:author] @author_format=rgx[:author].match(para)[1] end - break if @title and @subtitle and @author and @idx_lst + break if @title && @subtitle && @author && @idx_lst end @fulltitle=@subtitle ? (@title + ' - ' + @subtitle) : @title if @title \ @@ -324,7 +324,7 @@ module SiSU_HarvestTopics else @the_h[x0][x1][x2] ||={} end - #puts ' '*2 + x2 + #puts ' '*2 + x2 if extract >= 3 y.each_pair do |x3,y| if extract == 3 @@ -333,7 +333,7 @@ module SiSU_HarvestTopics else @the_h[x0][x1][x2][x3] ||={} end - #puts ' '*3 + x3 + #puts ' '*3 + x3 if extract == 4 y.each_pair do |x4,y| if extract == 4 @@ -342,14 +342,14 @@ module SiSU_HarvestTopics else @the_h[x0][x1][x2][x3][x4] ||={} end - #puts ' '*4 + x4 + #puts ' '*4 + x4 if extract == 5 y.each_pair do |x5,y| if extract == 5 @the_h[x0][x1][x2][x3][x4][x5] ||={ md: [] } @the_h[x0][x1][x2][x3][x4][x5][:md] << y end - #puts ' '*5 + x5 + #puts ' '*5 + x5 end end end @@ -502,7 +502,7 @@ module SiSU_HarvestTopics if y.is_a?(Hash) if y.has_key?(:md) y[:md].each do |x| - #do_hash(lng,attrib,x) #lv==0 ? + #do_hash(lng,attrib,x) #lv==0 ? #puts ' '*5 + x[:title] end end diff --git a/lib/sisu/v3/html.rb b/lib/sisu/v3/html.rb index b4fd96ba..132394d6 100644 --- a/lib/sisu/v3/html.rb +++ b/lib/sisu/v3/html.rb @@ -528,8 +528,6 @@ WOK ads=SiSU_HTML_Promo::Ad.new(@md) toc_shared << dochead << ads.div.major @segtoc << format_head_toc.head << ads.div.major - toc_shared << format_head_toc.toc_head_escript if SiSU_HTML_Format::HeadToc.method_defined? :toc_head_escript - @segtoc << format_head_toc.toc_head_escript if SiSU_HTML_Format::HeadToc.method_defined? :toc_head_escript if @make.build.html_top_band? toc_shared << format_head_toc.scroll_head_navigation_band end @@ -609,8 +607,7 @@ WOK end def publish scroll=[] - hr='

' - scroll << @scr_toc << '
' << hr << @scr_body << @scr_endnotes << hr << @scr_owner_details << '
' << @scr_tails + scroll << @scr_toc << '
' << @scr_body << @scr_endnotes << @scr_owner_details << '
' << @scr_tails scroll=scroll.flatten.compact #watch end end diff --git a/lib/sisu/v3/html_format.rb b/lib/sisu/v3/html_format.rb index 433652e0..fa9ac462 100644 --- a/lib/sisu/v3/html_format.rb +++ b/lib/sisu/v3/html_format.rb @@ -135,7 +135,7 @@ module SiSU_HTML_Format end def png_nav def toc - %{TOC} + %{toc} end def pre %{<< previous} @@ -744,42 +744,6 @@ WOK %{
- + #{@vz.png_nav_dot_pre} - + #{@vz.png_nav_dot_toc} - + #{@vz.png_nav_dot_nxt} #{@vz.table_close}} @@ -745,17 +743,17 @@ WOK def toc_nav(f_pre=false,f_nxt=false,use=1) pre=nxt='' toc=%{ - + #{@vz.png_nav_toc} - + #{@vz.png_nav_pre} - + #{@vz.png_nav_nxt}
} - end - def heading_advert_local_1 - dir=SiSU_Env::InfoEnv.new(@fns) - %{
- -
- - #{@md.ad_alt} - -

-#{@vz.table_close} -} - end - def heading_advert_local_2 - dir=SiSU_Env::InfoEnv.new(@fns) - %{

- - - \n") @@tablehead=0 end @@ -109,13 +107,11 @@ module SiSU_Tables else @parablock=@parablock.gsub(/#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u, %{ - - \n\n") end @parablock -- cgit v1.2.3 From 52e870e3e04b3848d024e144ffb2a7f26b078cb3 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Mon, 1 Oct 2012 16:12:14 -0400 Subject: v3: dal, sysenv, file processing, split objects; remove ref to old ruby * markup file processing, change to sourcefile readlines & split of sourcefile array * removal of RUBY_VERSION references to older versions of ruby --- lib/sisu/v3/dal.rb | 41 +++++++----------------------- lib/sisu/v3/dal_doc_str.rb | 7 +++--- lib/sisu/v3/dal_idx.rb | 63 +++++++++++++++++++++++++--------------------- lib/sisu/v3/sysenv.rb | 19 ++++++-------- 4 files changed, 55 insertions(+), 75 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v3/dal.rb b/lib/sisu/v3/dal.rb index a03ed55c..0e816091 100644 --- a/lib/sisu/v3/dal.rb +++ b/lib/sisu/v3/dal.rb @@ -273,13 +273,7 @@ module SiSU_DAL if @opt.fno =~/\.txz$/ Dir.chdir(@opt.f_pth[:pth]) end - file_array=@env.read_source_file(fn) - file_array.each do |l| - if l =~/\r\n/ then l.gsub!(/\r\n/,"\n") - end - end - meta=file_array.dup - meta=meta.join.split("\n\n") #check whether can be eliminated, some of these are large objects to have twice + meta=file_array=@env.source_file_processing_array(fn) @md=SiSU_Param::Parameters::Instructions.new(meta,@opt).extract meta=nil dal=SiSU_DAL::Make.new(fn,@md,file_array).song @@ -294,72 +288,56 @@ module SiSU_DAL def read_fnm dal=[] dal=if FileTest.file?(@fnm) - (RUBY_VERSION < '1.9') \ - ? (File.open(@fnm){ |f| dal=Marshal.load(f)}) - : (File.open(@fnm,'r:utf-8'){ |f| dal=Marshal.load(f)}) + File.open(@fnm,'r:utf-8'){ |f| dal=Marshal.load(f)} else SiSU_DAL::Source.new(@opt).create_dal end end def read_fnc dal=[] dal=if FileTest.file?(@fnc) - (RUBY_VERSION < '1.9') \ - ? (File.open(@fnc){ |f| dal=Marshal.load(f)}) - : (File.open(@fnc,'r:utf-8'){ |f| dal=Marshal.load(f)}) + File.open(@fnc,'r:utf-8'){ |f| dal=Marshal.load(f)} else SiSU_DAL::Source.new(@opt).create_dal end end def read_idx_sst m=[] m=if FileTest.file?(@idx_sst) - (RUBY_VERSION < '1.9') \ - ? (File.open(@idx_sst){ |f| m=Marshal.load(f)}) - : (File.open(@idx_sst,'r:utf-8'){ |f| m=Marshal.load(f)}) + File.open(@idx_sst,'r:utf-8'){ |f| m=Marshal.load(f)} else nil end end def read_idx_raw m=[] m=if FileTest.file?(@idx_raw) - (RUBY_VERSION < '1.9') \ - ? (File.open(@idx_raw){ |f| m=Marshal.load(f)}) - : (File.open(@idx_raw,'r:utf-8'){ |f| m=Marshal.load(f)}) + File.open(@idx_raw,'r:utf-8'){ |f| m=Marshal.load(f)} else nil end end def read_idx_html m=[] m=if FileTest.file?(@idx_html) - (RUBY_VERSION < '1.9') \ - ? (File.open(@idx_html){ |f| m=Marshal.load(f)}) - : (File.open(@idx_html,'r:utf-8'){ |f| m=Marshal.load(f)}) + File.open(@idx_html,'r:utf-8'){ |f| m=Marshal.load(f)} else nil end end def read_idx_xhtml m=[] m=if FileTest.file?(@idx_xhtml) - (RUBY_VERSION < '1.9') \ - ? (File.open(@idx_xhtml){ |f| m=Marshal.load(f)}) - : (File.open(@idx_xhtml,'r:utf-8'){ |f| m=Marshal.load(f)}) + File.open(@idx_xhtml,'r:utf-8'){ |f| m=Marshal.load(f)} else nil end end def read_map_nametags m=[] m=if FileTest.file?(@map_nametags) - (RUBY_VERSION < '1.9') \ - ? (File.open(@map_nametags){ |f| m=Marshal.load(f)}) - : (File.open(@map_nametags,'r:utf-8'){ |f| m=Marshal.load(f)}) + File.open(@map_nametags,'r:utf-8'){ |f| m=Marshal.load(f)} else nil end end def read_map_ocn_htmlseg m=[] m=if FileTest.file?(@map_ocn_htmlseg) - (RUBY_VERSION < '1.9') \ - ? (File.open(@map_ocn_htmlseg){ |f| m=Marshal.load(f)}) - : (File.open(@map_ocn_htmlseg,'r:utf-8'){ |f| m=Marshal.load(f)}) + File.open(@map_ocn_htmlseg,'r:utf-8'){ |f| m=Marshal.load(f)} else nil end end @@ -501,7 +479,6 @@ module SiSU_DAL def song reset data=@data - data=data.join.split("\n\n") data=SiSU_DAL_Insertions::Insertions.new(@md,data).expand_insertions? # dal_expand_insertions.rb data=SiSU_DAL_SubstituteAndInsert::SI.new(@md,data).substitutions_and_insertions? # dal_substitutions_and_insertions.rb data,metadata=SiSU_DAL_DocumentStructureExtract::Build.new(@md,data).identify_parts # dal_doc_str.rb diff --git a/lib/sisu/v3/dal_doc_str.rb b/lib/sisu/v3/dal_doc_str.rb index 6bde88e2..012e7a33 100644 --- a/lib/sisu/v3/dal_doc_str.rb +++ b/lib/sisu/v3/dal_doc_str.rb @@ -857,10 +857,9 @@ module SiSU_DAL_DocumentStructureExtract tuned_file=tuned_file.flatten end def tags(o) - tag=if o[:status]=='open' - %{<#{o[:lv]} id="#{o[:node]}">} - else "" - end + tag=(o[:status]=='open') \ + ? %{<#{o[:lv]} id="#{o[:node]}">} + : "" ln=case o[:lv] when 'A'; 1 when 'B'; 2 diff --git a/lib/sisu/v3/dal_idx.rb b/lib/sisu/v3/dal_idx.rb index a90217c4..db4ba9c1 100644 --- a/lib/sisu/v3/dal_idx.rb +++ b/lib/sisu/v3/dal_idx.rb @@ -117,35 +117,42 @@ module SiSU_DAL_BookIndex def construct_book_index(idx_array) the_idx={} idx_array.each do |idx| - idx_lst=idx[:rough_idx].scan(/[^|:]+/) - idx_lst[0]=idx_lst[0].strip - if idx_lst[0] =~/.+?\+\d+/ - use,plus=/(.+?)\+(\d+)/.match(idx_lst[0])[1,2] - else use=idx_lst[0] - end - use=use[0].chr.capitalize + use[1,use.length] - the_idx[use]={} unless the_idx[use] and defined? the_idx[use] - idx_lst.each do |i| - i=i.strip - i,r=/(.+?)\+(\d+)/.match(i)[1,2] if i =~/.+?\+\d+/ - x=if idx_lst.length==1 or idx_lst[0].gsub(/\+\d+/,'')==i - the_idx[use]['term_node_lev1']=[] unless the_idx[use]['term_node_lev1'] and defined? the_idx[use]['term_node_lev1'] - x=if r - the_idx[use]['term_node_lev1'] << { ocn: idx[:ocn], range: "#{idx[:ocn]}-#{idx[:ocn].to_i+r.to_i}", seg: idx[:seg] } - "#{i} #{idx[:ocn]}-#{idx[:ocn].to_i+r.to_i}" - else - the_idx[use]['term_node_lev1'] << { ocn: idx[:ocn], seg: idx[:seg] } - "#{i} #{idx[:ocn]}" - end - else - the_idx[use]['term_node_lev2']={} unless the_idx[use]['term_node_lev2'] and defined? the_idx[use]['term_node_lev2'] - the_idx[use]['term_node_lev2'][i]=[] unless the_idx[use]['term_node_lev2'][i] and defined? the_idx[use]['term_node_lev2'][i] - x=if r - the_idx[use]['term_node_lev2'][i] << { ocn: idx[:ocn], range: "#{idx[:ocn]}-#{idx[:ocn].to_i+r.to_i}", seg: idx[:seg] } - "#{idx_lst[0]}:#{i} #{idx[:ocn]}-#{idx[:ocn].to_i+r.to_i}" + if idx[:rough_idx] =~/[|]/ \ + && idx[:rough_idx] !~/[:]/ + if @md.opt.cmd =~/[MVv]/ + p 'book index error? --> ' + idx[:rough_idx] + end + else + idx_lst=idx[:rough_idx].scan(/[^|:]+/) + idx_lst[0]=idx_lst[0].strip + if idx_lst[0] =~/.+?\+\d+/ + use,plus=/(.+?)\+(\d+)/.match(idx_lst[0])[1,2] + else use=idx_lst[0] + end + use=use[0].chr.capitalize + use[1,use.length] + the_idx[use]={} unless the_idx[use] and defined? the_idx[use] + idx_lst.each do |i| + i=i.strip + i,r=/(.+?)\+(\d+)/.match(i)[1,2] if i =~/.+?\+\d+/ + x=if idx_lst.length==1 or idx_lst[0].gsub(/\+\d+/,'')==i + the_idx[use]['term_node_lev1']=[] unless the_idx[use]['term_node_lev1'] and defined? the_idx[use]['term_node_lev1'] + x=if r + the_idx[use]['term_node_lev1'] << { ocn: idx[:ocn], range: "#{idx[:ocn]}-#{idx[:ocn].to_i+r.to_i}", seg: idx[:seg] } + "#{i} #{idx[:ocn]}-#{idx[:ocn].to_i+r.to_i}" + else + the_idx[use]['term_node_lev1'] << { ocn: idx[:ocn], seg: idx[:seg] } + "#{i} #{idx[:ocn]}" + end else - the_idx[use]['term_node_lev2'][i] << { ocn: idx[:ocn], seg: idx[:seg] } - "#{idx_lst[0]}:#{i} #{idx[:ocn]}" + the_idx[use]['term_node_lev2']={} unless the_idx[use]['term_node_lev2'] and defined? the_idx[use]['term_node_lev2'] + the_idx[use]['term_node_lev2'][i]=[] unless the_idx[use]['term_node_lev2'][i] and defined? the_idx[use]['term_node_lev2'][i] + x=if r + the_idx[use]['term_node_lev2'][i] << { ocn: idx[:ocn], range: "#{idx[:ocn]}-#{idx[:ocn].to_i+r.to_i}", seg: idx[:seg] } + "#{idx_lst[0]}:#{i} #{idx[:ocn]}-#{idx[:ocn].to_i+r.to_i}" + else + the_idx[use]['term_node_lev2'][i] << { ocn: idx[:ocn], seg: idx[:seg] } + "#{idx_lst[0]}:#{i} #{idx[:ocn]}" + end end end end diff --git a/lib/sisu/v3/sysenv.rb b/lib/sisu/v3/sysenv.rb index 40880701..c4b364ad 100644 --- a/lib/sisu/v3/sysenv.rb +++ b/lib/sisu/v3/sysenv.rb @@ -973,7 +973,7 @@ module SiSU_Env include FileUtils attr_accessor :filename,:sys,:home,:hostname,:user,:env,:rc,:www,:fnb,:fnn,:fnt,:flv,:webserv_path,:stub_pwd,:stub_src,:webserv_host_cgi,:webserv_port_cgi,:processing,:processing_git,:etc,:yamlrc_dir @@image_flag,@@local_image=true,true #warning on @@image_flag - @@fb=@@man_path=nil,nil + @@fb,@@man_path=nil,nil def initialize(fns='',md=nil) super() #you may not want to re-execute this static info so frequently! @fns,@md=fns,md @@ -1739,18 +1739,15 @@ WOK self end def read_source_file(fns) - fns_array=if RUBY_VERSION < '1.9' - x=unless fns =~/\.ssm.sst$/ - IO.readlines(fns,'') - else IO.readlines("#{processing_path.composite_file}/#{fns}",'') - end - else #ruby version >= '1.9' - x=unless fns =~/\.ssm.sst$/ - IO.readlines(fns,'r:utf-8') - else IO.readlines("#{processing_path.composite_file}/#{fns}",'r:utf-8') - end + fns_array=unless fns =~/\.ssm.sst$/ + IO.readlines(fns, mode: 'r:utf-8', cr_newline: true) + else + IO.readlines("#{processing_path.composite_file}/#{fns}", mode: 'r:utf-8', cr_newline: true) end end + def source_file_processing_array(fns) + sf=read_source_file(fns).join.split(/\s*\n\s*\n/m) + end def path #dir def home @sys.home -- cgit v1.2.3 From d6ef30b3f58d9278c11ca7de73b012968a35ba9b Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Mon, 1 Oct 2012 16:17:42 -0400 Subject: v3: header @classify: :topic_register: provide greater classification "depth" * param, manifest * harvest_topics --- lib/sisu/v3/harvest_topics.rb | 4 ++-- lib/sisu/v3/manifest.rb | 8 +++++++- lib/sisu/v3/param.rb | 17 ++++++++++++----- 3 files changed, 21 insertions(+), 8 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v3/harvest_topics.rb b/lib/sisu/v3/harvest_topics.rb index 445d8c8e..762f4be0 100644 --- a/lib/sisu/v3/harvest_topics.rb +++ b/lib/sisu/v3/harvest_topics.rb @@ -104,10 +104,10 @@ module SiSU_HarvestTopics rgx[:author]=/^@creator:(?:[ ]+|.+?:author:[ ]+)(.+?)(?:\||\n)/m rgx[:title]=/^@title:[ ]+(.+)/ rgx[:subtitle]=/^@title:.+?:subtitle:[ ]+(.+?)\n/m - rgx[:idx]=/^@classify:.+?:topic_register:[ ]+(.+?)\n/m + rgx[:idx]=/^@classify:.+?:topic_register:[ ]+(.+?)(?:\n\n|\n\s+:\S|\n%)/m data.each do |para| if para=~ rgx[:idx] - @idx_list=rgx[:idx].match(para)[1] + @idx_list=(rgx[:idx].match(para)[1]).split(/\s*\n\s*/).join end if para=~ rgx[:title] @title=rgx[:title].match(para)[1] diff --git a/lib/sisu/v3/manifest.rb b/lib/sisu/v3/manifest.rb index c2490837..58f2d8eb 100644 --- a/lib/sisu/v3/manifest.rb +++ b/lib/sisu/v3/manifest.rb @@ -699,7 +699,13 @@ WOK t.each_with_index do |st,i| if st.is_a?(Array) st.each do |v| - @manifest[:html] << %{

#{v}

\n} + if v.is_a?(Array) + v.each do |w,i| + @manifest[:html] << %{

#{w}

\n} + end + else + @manifest[:html] << %{

#{v}

\n} + end end else @manifest[:html] << %{

#{st}

\n} end diff --git a/lib/sisu/v3/param.rb b/lib/sisu/v3/param.rb index 492b8044..bffba529 100644 --- a/lib/sisu/v3/param.rb +++ b/lib/sisu/v3/param.rb @@ -227,6 +227,13 @@ module SiSU_Param if x =~/^%\s/ #ignore comment elsif x =~/:(\S+?):\s+(.+)/ a,b=/:(\S+?):\s+(.+)\Z/m.match(x)[1,2] + 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 @@ -598,7 +605,7 @@ module SiSU_Param self end def classify - a=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m) + a=@s.split(/(\n%\s.+?$|[ ]*)(?:\n[ ]*(?=:)|\Z)/m) @h=build_hash(a) def coverage s=@h['coverage'] @@ -1424,16 +1431,16 @@ module SiSU_Param and @classify.topic_register.is_a?(String) \ and @classify.topic_register.length >3 topic_register=@classify.topic_register - u=topic_register.scan(/[^;]+/) + u=topic_register.scan(/[^;]+/m).sort v=[] u.each do |l| - v << l.scan(/[^:]+/) + v << l.scan(/[^:]+/m) end v.each do |m| - m[-1]=m[-1].scan(/[^|]+/) if m[-1] =~/[|]/ + m[-1]=m[-1].scan(/[^|]+/m) if m[-1] =~/[|]/m @topic_register_array << m end - @topic_register_array=@topic_register_array.sort + @topic_register_array end if @i18n @i18n=@i18n.uniq -- cgit v1.2.3 From 8e40c8f68d80f05d5bcb8880b38caece4fdb3936 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Mon, 1 Oct 2012 16:31:23 -0400 Subject: v3: db, book_idx field & minor re-arrangement --- lib/sisu/v3/constants.rb | 38 ++++++++++++++-------------- lib/sisu/v3/db_create.rb | 45 ++++++++++++++++++++------------- lib/sisu/v3/db_import.rb | 60 ++++++++++++++++++++++++++------------------ lib/sisu/v3/db_load_tuple.rb | 8 +++--- lib/sisu/v3/db_remove.rb | 10 +++++--- 5 files changed, 91 insertions(+), 70 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v3/constants.rb b/lib/sisu/v3/constants.rb index a786a8b4..b38e3313 100644 --- a/lib/sisu/v3/constants.rb +++ b/lib/sisu/v3/constants.rb @@ -203,25 +203,25 @@ Ep={ f_opf: 'content.opf', } Db={ - name_prefix: "SiSU#{SiSU_version_dir}e_", - name_prefix_db: "sisu_#{SiSU_version_dir}e_", - col_title: 800, - col_title_part: 400, - col_title_edition: 10, - col_name: 600, - col_creator_misc_short: 100, - col_language: 100, - col_language_char: 6, - col_date_text: 10, - col_classify_txt_long: 600, - col_classify_txt_short: 600, - col_classify_short: 200, - col_classify_identify: 256, - col_classify_library: 30, - col_classify_small: 16, - col_filename: 256, - col_digest: 64, - col_filesize: 10, + name_prefix: "SiSU#{SiSU_version_dir}f_", + name_prefix_db: "sisu_#{SiSU_version_dir}f_", + col_title: 800, + col_title_part: 400, + col_title_edition: 10, + col_name: 600, + col_creator_misc_short: 100, + col_language: 100, + col_language_char: 6, + col_date_text: 10, + col_classify_txt_long: 600, + col_classify_txt_short: 600, + col_classify_short: 200, + col_classify_identify: 256, + col_classify_library: 30, + col_classify_small: 16, + col_filename: 256, + col_digest: 64, + col_filesize: 10, col_info_note: 2500, } Gt={ diff --git a/lib/sisu/v3/db_create.rb b/lib/sisu/v3/db_create.rb index 9fe35193..e302a94f 100644 --- a/lib/sisu/v3/db_create.rb +++ b/lib/sisu/v3/db_create.rb @@ -99,7 +99,7 @@ module SiSU_DbCreate create tables metadata_and_text data import through ruby transfer } if @opt.cmd =~/[VM]/ - @conn.execute(%{ + create_metadata_and_text=%{ CREATE TABLE metadata_and_text ( tid BIGINT PRIMARY KEY, /* title */ @@ -201,8 +201,9 @@ module SiSU_DbCreate /* types CHAR(1) NULL, */ /* writing_focus_nationality VARCHAR(100) NULL, */ ); - }) - @comment.psql.metadata_and_text if @comment + } + @conn.execute(create_metadata_and_text) + @comment.psql.metadata_and_text if @comment end def doc_objects # create doc_objects base print %{ @@ -210,7 +211,7 @@ module SiSU_DbCreate create tables doc_objects data import through ruby transfer } if @opt.cmd =~/[VM]/ - @conn.execute(%{ + create_doc_objects=%{ CREATE TABLE doc_objects ( lid BIGINT PRIMARY KEY, metadata_tid BIGINT REFERENCES metadata_and_text, @@ -219,6 +220,7 @@ module SiSU_DbCreate ocns VARCHAR(6), clean TEXT NULL, body TEXT NULL, + book_idx TEXT NULL, seg VARCHAR(256) NULL, lev_an VARCHAR(1), lev SMALLINT NULL, @@ -242,8 +244,9 @@ module SiSU_DbCreate digest_all CHAR(#{@@dl}), types CHAR(1) NULL ); - }) - @comment.psql.doc_objects if @comment + } + @conn.execute(create_doc_objects) + @comment.psql.doc_objects if @comment end def endnotes print %{ @@ -251,7 +254,7 @@ module SiSU_DbCreate create tables endnotes data import through ruby transfer } if @opt.cmd =~/[VM]/ - @conn.execute(%{ + create_endnotes=%{ CREATE TABLE endnotes ( nid BIGINT PRIMARY KEY, document_lid BIGINT REFERENCES doc_objects, @@ -264,8 +267,9 @@ module SiSU_DbCreate digest_clean CHAR(#{@@dl}), metadata_tid BIGINT REFERENCES metadata_and_text ); - }) - @comment.psql.endnotes if @comment + } + @conn.execute(create_endnotes) + @comment.psql.endnotes if @comment end def endnotes_asterisk print %{ @@ -273,7 +277,7 @@ module SiSU_DbCreate create tables endnotes_asterisk data import through ruby transfer } if @opt.cmd =~/[VM]/ - @conn.execute(%{ + create_endnotes_asterisk=%{ CREATE TABLE endnotes_asterisk ( nid BIGINT PRIMARY KEY, document_lid BIGINT REFERENCES doc_objects, @@ -286,8 +290,9 @@ module SiSU_DbCreate digest_clean CHAR(#{@@dl}), metadata_tid BIGINT REFERENCES metadata_and_text ); - }) - @comment.psql.endnotes_asterisk if @comment + } + @conn.execute(create_endnotes_asterisk) + @comment.psql.endnotes_asterisk if @comment end def endnotes_plus print %{ @@ -295,7 +300,7 @@ module SiSU_DbCreate create tables endnotes_plus data import through ruby transfer } if @opt.cmd =~/[VM]/ - @conn.execute(%{ + create_endnotes_plus=%{ CREATE TABLE endnotes_plus ( nid BIGINT PRIMARY KEY, document_lid BIGINT REFERENCES doc_objects, @@ -308,8 +313,9 @@ module SiSU_DbCreate digest_clean CHAR(#{@@dl}), metadata_tid BIGINT REFERENCES metadata_and_text ); - }) - @comment.psql.endnotes_plus if @comment + } + @conn.execute(create_endnotes_plus) + @comment.psql.endnotes_plus if @comment end def urls # create doc_objects file links mapping print %{ @@ -318,7 +324,7 @@ module SiSU_DbCreate create tables urls data import through ruby transfer } if @opt.cmd =~/[VM]/ - @conn.execute(%{ + create_urls=%{ CREATE TABLE urls ( metadata_tid BIGINT REFERENCES metadata_and_text, plaintext varchar(512), @@ -338,8 +344,9 @@ module SiSU_DbCreate markup varchar(512), sisupod varchar(512) ); - }) - @comment.psql.urls if @comment + } + @conn.execute(create_urls) + @comment.psql.urls if @comment end self end @@ -483,6 +490,8 @@ module SiSU_DbCreate IS 'text object - substantive text: clean, stripped of markup';}, %{COMMENT ON COLUMN doc_objects.body IS 'text object - substantive text: light html markup';}, + %{COMMENT ON COLUMN doc_objects.book_idx + IS 'book index creation information for paragraph, if provided';}, %{COMMENT ON COLUMN doc_objects.lev1 IS 'document structure, level number 1';}, %{COMMENT ON COLUMN doc_objects.lev2 diff --git a/lib/sisu/v3/db_import.rb b/lib/sisu/v3/db_import.rb index 0cae5872..ae808cf8 100644 --- a/lib/sisu/v3/db_import.rb +++ b/lib/sisu/v3/db_import.rb @@ -278,11 +278,13 @@ module SiSU_DbImport @col[:lev],txt,@col[:ocn],@col[:lev_an],@col[:ocnd],@col[:ocns],@col[:t_of],@col[:t_is],@col[:node],@col[:parent],@col[:digest_clean],@col[:digest_all]=data.ln,data.obj,data.ocn,data.lv,data.odv,data.osp,data.of,data.is,data.node,data.parent,'','' @col[:lid]+=1 txt=endnotes(txt).extract_any - @col[:body]=SiSU_FormatShared::CSS_Format.new(@md,data).lev4_minus - @col[:body]=special_character_escape(@col[:body]) - @col[:plaintext]=@col[:body].dup - @col[:plaintext]=strip_markup(@col[:plaintext]) - @col[:plaintext]=clean_searchable_text(@col[:plaintext]) + body=SiSU_FormatShared::CSS_Format.new(@md,data).lev4_minus + @col[:body]=special_character_escape(body) + plaintext=@col[:body].dup + plaintext=strip_markup(plaintext) + @col[:plaintext]=clean_searchable_text(plaintext) + book_idx=data.idx ? data.idx : '' + @col[:book_idx]=clean_searchable_text(book_idx) if @en[0] then @en_a,@en_z=@en[0].first,@en[0].last end if @en_ast[0] then @en_a_asterisk,@en_z_asterisk=@en_ast[0].first,@en_ast[0].last @@ -312,11 +314,13 @@ module SiSU_DbImport @env=SiSU_Env::InfoEnv.new(@md.fns) @base_url="#{@env.url.root}/#{@md.fnb}/#{@hname}.html" txt=endnotes(txt).extract_any - @col[:body]=SiSU_FormatShared::CSS_Format.new(@md,data).lev4_plus - @col[:body]=special_character_escape(@col[:body]) - @col[:plaintext]=@col[:body].dup - @col[:plaintext]=strip_markup(@col[:plaintext]) - @col[:plaintext]=clean_searchable_text(@col[:plaintext]) + body=SiSU_FormatShared::CSS_Format.new(@md,data).lev4_plus + @col[:body]=special_character_escape(body) + plaintext=@col[:body].dup + plaintext=strip_markup(plaintext) + @col[:plaintext]=clean_searchable_text(plaintext) + book_idx=data.idx ? data.idx : '' + @col[:book_idx]=clean_searchable_text(book_idx) @en_a,@en_z=@en[0].first,@en[0].last if @en[0] @en_a_asterisk,@en_z_asterisk=@en_ast[0].first,@en_ast[0].last if @en_ast[0] @en_a_plus,@en_z_plus=@en_pls[0].first,@en_pls[0].last if @en_pls[0] @@ -342,11 +346,13 @@ module SiSU_DbImport @env=SiSU_Env::InfoEnv.new(@md.fns) @base_url="#{@env.url.root}/#{@md.fnb}/#{@hname}.html" txt=endnotes(txt).extract_any - @col[:body]=SiSU_FormatShared::CSS_Format.new(@md,data).lev4_plus - @col[:body]=special_character_escape(@col[:body]) - @col[:plaintext]=@col[:body].dup - @col[:plaintext]=strip_markup(@col[:plaintext]) - @col[:plaintext]=clean_searchable_text(@col[:plaintext]) + body=SiSU_FormatShared::CSS_Format.new(@md,data).lev4_plus + @col[:body]=special_character_escape(body) + plaintext=@col[:body].dup + plaintext=strip_markup(plaintext) + @col[:plaintext]=clean_searchable_text(plaintext) + book_idx=data.idx ? data.idx : '' + @col[:book_idx]=clean_searchable_text(book_idx) @en_a,@en_z=@en[0].first,@en[0].last if @en[0] @en_a_asterisk,@en_z_asterisk=@en_ast[0].first,@en_ast[0].last if @en_ast[0] @en_a_plus,@en_z_plus=@en_pls[0].first,@en_pls[0].last if @en_pls[0] @@ -370,11 +376,13 @@ module SiSU_DbImport @env=SiSU_Env::InfoEnv.new(@md.fns) @base_url="#{@env.url.root}/#{@md.fnb}/#{@hname}.html" txt=endnotes(txt).extract_any - @col[:body]=SiSU_FormatShared::CSS_Format.new(@md,data).lev4_plus - @col[:body]=special_character_escape(@col[:body]) - @col[:plaintext]=@col[:body].dup - @col[:plaintext]=strip_markup(@col[:plaintext]) - @col[:plaintext]=clean_searchable_text(@col[:plaintext]) + body=SiSU_FormatShared::CSS_Format.new(@md,data).lev4_plus + @col[:body]=special_character_escape(body) + plaintext=@col[:body].dup + plaintext=strip_markup(plaintext) + @col[:plaintext]=clean_searchable_text(plaintext) + book_idx=data.idx ? data.idx : '' + @col[:book_idx]=clean_searchable_text(book_idx) @en_a,@en_z=@en[0].first,@en[0].last if @en[0] @en_a_asterisk,@en_z_asterisk=@en_ast[0].first,@en_ast[0].last if @en_ast[0] @en_a_plus,@en_z_plus=@en_pls[0].first,@en_pls[0].last if @en_pls[0] @@ -410,7 +418,7 @@ module SiSU_DbImport @en_a,@en_z=@en[0].first,@en[0].last if @en[0] @en_a_asterisk,@en_z_asterisk=@en_ast[0].first,@en_ast[0].last if @en_ast[0] @en_a_plus,@en_z_plus=@en_pls[0].first,@en_pls[0].last if @en_pls[0] - @col[:body]=if data.is==:table + body=if data.is==:table SiSU_FormatShared::CSS_Format.new(@md,data).html_table elsif data.is==:code SiSU_FormatShared::CSS_Format.new(@md,data).code @@ -427,10 +435,12 @@ module SiSU_DbImport else SiSU_FormatShared::CSS_Format.new(@md,data).norm end - @col[:body]=special_character_escape(@col[:body]) - @col[:plaintext]=@col[:body].dup - @col[:plaintext]=strip_markup(@col[:plaintext]) - @col[:plaintext]=clean_searchable_text(@col[:plaintext]) + @col[:body]=special_character_escape(body) + plaintext=@col[:body].dup + plaintext=strip_markup(plaintext) + @col[:plaintext]=clean_searchable_text(plaintext) + book_idx=data.idx ? data.idx : '' + @col[:book_idx]=clean_searchable_text(book_idx) t=SiSU_DbTuple::LoadDocuments.new(@conn,@col,@opt,@file_maint) @tuple_array << t.tuple @en,@en_ast,@en_pls=[],[],[] diff --git a/lib/sisu/v3/db_load_tuple.rb b/lib/sisu/v3/db_load_tuple.rb index 39ea9022..f55ce66c 100644 --- a/lib/sisu/v3/db_load_tuple.rb +++ b/lib/sisu/v3/db_load_tuple.rb @@ -78,11 +78,11 @@ module SiSU_DbTuple end def tuple #% import line sql_entry=if @col[:en_a] - "INSERT INTO doc_objects (lid, metadata_tid, lev, lev_an, clean, body, ocn, ocnd, ocns, seg, lev1, lev2, lev3, lev4, lev5, lev6, en_a, en_z, t_of, t_is, node, parent, digest_clean, digest_all) " + - "VALUES (#{@col[:lid]}, #{@col[:tid]}, #{@col[:lev]}, '#{@col[:lev_an]}', '#{@col[:plaintext]}', '#{@col[:body]}', '#{@col[:ocn]}', '#{@col[:ocnd]}', '#{@col[:ocns]}', '#{@col[:seg]}', '#{@col[:lv1]}', '#{@col[:lv2]}', '#{@col[:lv3]}', '#{@col[:lv4]}', '#{@col[:lv5]}', '#{@col[:lv6]}', '#{@col[:en_a]}', '#{@col[:en_z]}', '#{@col[:t_of]}', '#{@col[:t_is]}', '#{@col[:node]}', '#{@col[:parent]}', '#{@col[:digest_clean]}', '#{@col[:digest_all]}');" + "INSERT INTO doc_objects (lid, metadata_tid, lev, lev_an, clean, body, book_idx, ocn, ocnd, ocns, seg, lev1, lev2, lev3, lev4, lev5, lev6, en_a, en_z, t_of, t_is, node, parent, digest_clean, digest_all) " + + "VALUES (#{@col[:lid]}, #{@col[:tid]}, #{@col[:lev]}, '#{@col[:lev_an]}', '#{@col[:plaintext]}', '#{@col[:body]}', '#{@col[:book_idx]}', '#{@col[:ocn]}', '#{@col[:ocnd]}', '#{@col[:ocns]}', '#{@col[:seg]}', '#{@col[:lv1]}', '#{@col[:lv2]}', '#{@col[:lv3]}', '#{@col[:lv4]}', '#{@col[:lv5]}', '#{@col[:lv6]}', '#{@col[:en_a]}', '#{@col[:en_z]}', '#{@col[:t_of]}', '#{@col[:t_is]}', '#{@col[:node]}', '#{@col[:parent]}', '#{@col[:digest_clean]}', '#{@col[:digest_all]}');" else - "INSERT INTO doc_objects (lid, metadata_tid, lev, lev_an, clean, body, ocn, ocnd, ocns, seg, lev1, lev2, lev3, lev4, lev5, lev6, t_of, t_is, node, parent, digest_clean, digest_all) " + - "VALUES (#{@col[:lid]}, #{@col[:tid]}, #{@col[:lev]}, '#{@col[:lev_an]}', '#{@col[:plaintext]}', '#{@col[:body]}', '#{@col[:ocn]}', '#{@col[:ocnd]}', '#{@col[:ocns]}', '#{@col[:seg]}', '#{@col[:lv1]}', '#{@col[:lv2]}', '#{@col[:lv3]}', '#{@col[:lv4]}', '#{@col[:lv5]}', '#{@col[:lv6]}', '#{@col[:t_of]}', '#{@col[:t_is]}', '#{@col[:node]}', '#{@col[:parent]}', '#{@col[:digest_clean]}', '#{@col[:digest_all]}');" + "INSERT INTO doc_objects (lid, metadata_tid, lev, lev_an, clean, body, book_idx, ocn, ocnd, ocns, seg, lev1, lev2, lev3, lev4, lev5, lev6, t_of, t_is, node, parent, digest_clean, digest_all) " + + "VALUES (#{@col[:lid]}, #{@col[:tid]}, #{@col[:lev]}, '#{@col[:lev_an]}', '#{@col[:plaintext]}', '#{@col[:body]}', '#{@col[:book_idx]}', '#{@col[:ocn]}', '#{@col[:ocnd]}', '#{@col[:ocns]}', '#{@col[:seg]}', '#{@col[:lv1]}', '#{@col[:lv2]}', '#{@col[:lv3]}', '#{@col[:lv4]}', '#{@col[:lv5]}', '#{@col[:lv6]}', '#{@col[:t_of]}', '#{@col[:t_is]}', '#{@col[:node]}', '#{@col[:parent]}', '#{@col[:digest_clean]}', '#{@col[:digest_all]}');" end if @opt.cmd =~/M/ if @opt.cmd =~/V/ diff --git a/lib/sisu/v3/db_remove.rb b/lib/sisu/v3/db_remove.rb index 6d481cb4..3371a9be 100644 --- a/lib/sisu/v3/db_remove.rb +++ b/lib/sisu/v3/db_remove.rb @@ -71,19 +71,21 @@ module SiSU_DbRemove : false end del_id=if driver_sqlite3 - @conn.get_first_value(%{ + remove_selected=%{ SELECT tid FROM metadata_and_text WHERE src_filename = '#{@opt.fns}' AND metadata_and_text.language_document_char = '#{@opt.lng}' - ;}).to_i + ;} + @conn.get_first_value(remove_selected).to_i else - x=@conn.select_one(%{ + remove_selected=%{ SELECT metadata_and_text.tid FROM metadata_and_text WHERE metadata_and_text.src_filename = '#{@opt.fns}' AND metadata_and_text.language_document_char = '#{@opt.lng}' - ;}) + ;} + x=@conn.select_one(remove_selected) x ? (x.join.to_i) : nil end if del_id -- cgit v1.2.3 From 610573c495420ebf3661e9e1829405179d8e6aa3 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Mon, 1 Oct 2012 16:39:32 -0400 Subject: v3: cgi search script, minor --- lib/sisu/v3/cgi_pgsql.rb | 12 +++++------- lib/sisu/v3/cgi_sql_common.rb | 22 +++++++++++----------- lib/sisu/v3/cgi_sqlite.rb | 12 +++++------- 3 files changed, 21 insertions(+), 25 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v3/cgi_pgsql.rb b/lib/sisu/v3/cgi_pgsql.rb index 83a1cecf..1264d922 100644 --- a/lib/sisu/v3/cgi_pgsql.rb +++ b/lib/sisu/v3/cgi_pgsql.rb @@ -144,7 +144,7 @@ module SiSU_CGI_PgSQL @l,@t,@q,@c=l,t,q,cse end def string - search={ :search => [], :flag => false } + search={ search: [], flag: false } if @t =~/\S+/ or @q =~/\S+/ if @t =~/\S+/ then unescaped_search=CGI.unescape(@t) elsif @q =~/\S+/ then unescaped_search=CGI.unescape(@q) @@ -171,12 +171,10 @@ module SiSU_CGI_PgSQL def search_query1 <<-'WOK_SQL' @search_text,@search_endnotes='','' - search[:text].flatten.each {|x| @search_text << "#{x} AND " } - @search_text=@search_text.gsub(/AND\s+$/m,''). #watch - gsub(/(doc_objects\.clean~[*]?\(\s*'[^']+'\s*\)\s+(?:(?:AND|OR)\s+doc_objects\.clean~[*]?\(\s*'[^']+'\s*\))+)/,'(\1)') - search[:endnotes].flatten.each {|x| @search_endnotes << "#{x} AND " } - @search_endnotes=@search_endnotes.gsub(/AND\s+$/m,''). #watch - gsub(/(endnotes\.clean~\(\s*'[^']+'\s*\)\s+(?:(?:AND|OR)\s+endnotes\.clean~\(\s*'[^']+'\s*\))+)/,'(\1)') + @search_text=search[:text].flatten.join(' AND ') + @search_text=@search_text.gsub(/(doc_objects\.clean~[*]?\(\s*'[^']+'\s*\)\s+(?:(?:AND|OR)\s+doc_objects\.clean~[*]?\(\s*'[^']+'\s*\))+)/,'(\1)') + @search_endnotes=search[:endnotes].flatten.join(' AND ') + @search_endnotes=@search_endnotes.gsub(/(endnotes\.clean~\(\s*'[^']+'\s*\)\s+(?:(?:AND|OR)\s+endnotes\.clean~\(\s*'[^']+'\s*\))+)/,'(\1)') end WOK_SQL end diff --git a/lib/sisu/v3/cgi_sql_common.rb b/lib/sisu/v3/cgi_sql_common.rb index 94026ce7..18e1ab1e 100644 --- a/lib/sisu/v3/cgi_sql_common.rb +++ b/lib/sisu/v3/cgi_sql_common.rb @@ -301,9 +301,9 @@ module SiSU_CGI_SQL end def text_to_match(identifier='') m={ - :string => /#{identifier}\s*(.+?)/, - :string => /#{identifier}\s*(.+?)(?:;|\n|\r|$)/, - :word => /#{identifier}[\s(]*(\S+)/ + string: /#{identifier}\s*(.+?)/, + string: /#{identifier}\s*(.+?)(?:;|\n|\r|$)/, + word: /#{identifier}[\s(]*(\S+)/ } search_string=if @search_field =~m[:word] search_string=if @search_field =~m[:braces] then m[:braces].match(@search_field)[1] @@ -313,7 +313,7 @@ module SiSU_CGI_SQL str=str.gsub(/[()]/,'') str end - search_string=search_string.strip.search_string.gsub(/\s+/,'+') + search_string=search_string.strip.gsub(/\s+/,'+') #else # "__" end @@ -328,10 +328,10 @@ module SiSU_CGI_SQL def initialize(conn,search_for,q,c) @conn=conn @text_search_flag=false - @sql_statement={ :body => '', :endnotes => '', :range => '' } + @sql_statement={ body: '', endnotes: '', range: '' } #@offset||=@@offset #@offset+=@@limit - search={ :text => [], :endnotes => [] } + search={ text: [], endnotes: [] } cse=(c =~/\S/) ? true : false st=DBI_SearchString.new('doc_objects.clean',search_for.text1,q['s1'],cse).string se=DBI_SearchString.new('endnotes.clean',search_for.text1,q['s1'],cse).string @@ -650,7 +650,7 @@ module SiSU_CGI_SQL @counters_txt,@counters_endn,@sql_select_body,@sql_select_endnotes='','','','' FCGI.each_cgi do |cgi| begin # all code goes in begin section - @search={ :text => [], :endnotes => [] } + @search={ text: [], endnotes: [] } q=CGI.new @db=if cgi['db'] =~/\S+/ @stub=/#{@db_name_prefix}(\S+)/.match(cgi['db'])[1] @@ -661,13 +661,13 @@ module SiSU_CGI_SQL end checked_url,checked_stats,checked_searched,checked_tip,checked_case,checked_echo,checked_sql,checked_all,checked_none,checked_selected,checked_default,selected_db='','','','','','','','','' result_type=(cgi['view']=~/text/) \ - ? result_type={ :index => '', :text => 'checked'} - : result_type={ :index => 'checked', :text => ''} + ? result_type={ index: '', text: 'checked'} + : result_type={ index: 'checked', text: ''} @@limit=if cgi['sql_match_limit'].to_s=~/2500/ - checked_sql_limit={ :l1000 => '', :l2500 => 'checked'} + checked_sql_limit={ l1000: '', l2500: 'checked'} '2500' else - checked_sql_limit={ :l1000 => 'checked', :l2500 => ''} + checked_sql_limit={ l1000: 'checked', l2500: ''} '1000' end checked_echo='checked' if cgi['echo'] =~/\S/ diff --git a/lib/sisu/v3/cgi_sqlite.rb b/lib/sisu/v3/cgi_sqlite.rb index a9f9d277..78ae0f9a 100644 --- a/lib/sisu/v3/cgi_sqlite.rb +++ b/lib/sisu/v3/cgi_sqlite.rb @@ -141,7 +141,7 @@ module SiSU_CGI_SQLite @l,@t,@q=l,t,q end def string - search={ :search => [], :flag => false } + search={ search: [], flag: false } if @t =~/\S+/ or @q =~/\S+/ if @t =~/\S+/ then unescaped_search=CGI.unescape(@t) elsif @q =~/\S+/ then unescaped_search=CGI.unescape(@q) @@ -163,12 +163,10 @@ module SiSU_CGI_SQLite def search_query1 <<-'WOK_SQL' @search_text,@search_endnotes='','' - search[:text].flatten.each {|x| @search_text << "#{x} AND " } - @search_text=@search_text.gsub(/AND\s+$/m,''). - gsub(/(doc_objects\.clean\s+LIKE\s+\(\s*'%[^']+%'\s*\)\s+(?:(?:AND|OR)\s+doc_objects\.clean\s+LIKE\s+\(\s*'%[^']+%'\s*\))+)/,'(\1)') - search[:endnotes].flatten.each {|x| @search_endnotes << "#{x} AND " } - @search_endnotes=@search_endnotes.gsub(/AND\s+$/m,''). - gsub(/(endnotes\.clean\s+LIKE\s+\(\s*'%[^']+%'\s*\)\s+(?:(?:AND|OR)\s+endnotes\.clean\s+LIKE\s+\(\s*'%[^']+%'\s*\))+)/,'(\1)') + @search_text=search[:text].flatten.join(' AND ') + @search_text=@search_text.gsub(/(doc_objects\.clean\s+LIKE\s+\(\s*'%[^']+%'\s*\)\s+(?:(?:AND|OR)\s+doc_objects\.clean\s+LIKE\s+\(\s*'%[^']+%'\s*\))+)/,'(\1)') + @search_endnotes=search[:endnotes].flatten.join(' AND ') + @search_endnotes=@search_endnotes.gsub(/(endnotes\.clean\s+LIKE\s+\(\s*'%[^']+%'\s*\)\s+(?:(?:AND|OR)\s+endnotes\.clean\s+LIKE\s+\(\s*'%[^']+%'\s*\))+)/,'(\1)') end WOK_SQL end -- cgit v1.2.3 From 78b703344df880ea5dc0a7e0bdb482fc118161b0 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Mon, 1 Oct 2012 16:58:53 -0400 Subject: v3: markup samples, and help, minor updates --- lib/sisu/v3/help.rb | 203 +++++++++++++++++++++++++--------------------------- 1 file changed, 96 insertions(+), 107 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v3/help.rb b/lib/sisu/v3/help.rb index 980380c3..0ab87fdd 100644 --- a/lib/sisu/v3/help.rb +++ b/lib/sisu/v3/help.rb @@ -397,9 +397,12 @@ sisu Note: files for SiSU should be in UTF-8 character encoding. #{@cX.cyan}Data text markup#{@cX.off} (alternative to available html subset) - #{@cX.green}% SiSU 0.38#{@cX.off} [statement on first line of document, declared file-type identifier, SiSU markup document, markup used is version 0.38] - #{@cX.green}:A~#{@cX.off} heading/title [levels :A to :C available (and beneath that 1 to 6)] + #{@cX.green}% SiSU 2.00#{@cX.off} [statement on first line of document, declared file-type identifier, SiSU markup document, markup used is version 0.38] + + #{@cX.green}A~#{@cX.off} heading/title [levels A to C available (and beneath that 1 to 6)] + #{@cX.green}1~#{@cX.off}filename heading [segmentation level, levels 1 to 6 available] + #{@cX.green}!{#{@cX.off}emphasis#{@cX.green}}!#{@cX.off} #{@cX.green}*{#{@cX.off}bold text#{@cX.green}}*#{@cX.off} #{@cX.green}_{#{@cX.off}underscore#{@cX.green}}_#{@cX.off} @@ -409,18 +412,28 @@ sisu #{@cX.green},{#{@cX.off}subscript#{@cX.green}},#{@cX.off} #{@cX.green}+{#{@cX.off}inserted text#{@cX.green}}+#{@cX.off} #{@cX.green}-{#{@cX.off}strikethrough#{@cX.green}}-#{@cX.off} + ------------------------------------------ #{@cX.cyan}Indentation and bullets#{@cX.off} + #{@cX.green}_1#{@cX.off} indent paragraph one level + #{@cX.green}_2#{@cX.off} indent paragraph two steps + #{@cX.green}_*#{@cX.off} bullet text + #{@cX.green}_1*#{@cX.off} bullet text, first indent + ------------------------------------------ #{@cX.cyan}Numbered List#{@cX.off} (not to be confused with headings/titles, (document structure)) + #{@cX.green}##{@cX.off} numbered list numbered list 1., 2., 3, etc. + #{@cX.green}_##{@cX.off} numbered list numbered list indented second level a., b., c., d., etc. + ------------------------------------------ #{@cX.cyan}Endnotes#{@cX.off} + #{@cX.green}~{#{@cX.off}footnote/endnote#{@cX.green}}~#{@cX.off} endnote#{@cX.green}~{#{@cX.off}self contained endnote marker & endnote in one#{@cX.green}}~#{@cX.off} #{@cX.green}~{*#{@cX.off}asterisk footnote/endnote#{@cX.green}}~#{@cX.off} editor's annotations, square bracket notes @@ -430,8 +443,10 @@ sisu alternative endnote pair notation #{@cX.green}~^#{@cX.off} endnote marker #{@cX.green}^~#{@cX.off} endnote text following the paragraph in which the marker occurs + ------------------------------------------ #{@cX.cyan}Links#{@cX.off} + http://url.org on its own would be automatically marked up and hyperlinked to itself #{@cX.green}{#{@cX.off} [text to link] #{@cX.green}}#{@cX.off}http://url.org #{@cX.green}{#{@cX.off}image.png#{@cX.green}}#{@cX.off}http://url.org @@ -450,19 +465,24 @@ sisu if a server host name has been provided/configured, will provide a list of available output types that would be generated using the shortcut command and the markup file provided, i.e. output generated using the command (as configured): "sisu -3sS markup_source_filename.sst" using server host, directory stub, filename to compose the link. + ------------------------------------------ adding fixed names in html, manual location marker/tagging #{@cX.green}*~[name]#{@cX.off} + ------------------------------------------ #{@cX.green}~##{@cX.off} unnumbered paragraph (place marker at end of paragraph) #{@cX.green}-##{@cX.off} unnumbered paragraph, delete when not required (place marker at end of paragraph) [used in dummy headings, eg. for segmented html] + ------------------------------------------ manual page breaks (LaTeX/pdf) #{@cX.green}<:pb>#{@cX.off} page break, which breaks a page, starting a new page in single column text and a new column in double column text #{@cX.green}<:pn>#{@cX.off} page new, which starts a new page, in both single and double column text (leaving an empty column in double column text if necessary). Note: page breaks are usually introduced to pdfs either as header instructions, indicating that pages should break at given levels + ------------------------------------------ #{@cX.cyan}Composite documents#{@cX.off} + It is possible to build a document by creating a master document that requires other documents. The documents required may complete documents that could be generated independently, or they could be markup snippets, prepared so as to be easily available to be placed within another text. If the calling document is a master document (built mainly from other documents), it should be named with the suffix #{@cX.blue}.ssm#{@cX.off} Within this document you would provide information on the other documents that should be included within the text. These may be other documents that would be processed in a regular way, or markup bits prepared only for inclusion within a master document #{@cX.blue}.sst#{@cX.off} regular markup file, or #{@cX.blue}.ssi#{@cX.off} (insert/information) A secondary file of the composite document is built prior to processing with the same prefix and the suffix #{@cX.blue}.ssm.sst#{@cX.off} #{@cX.cyan}#basic sisu markup alternatives#{@cX.off} @@ -522,9 +542,9 @@ WOK @links: { SiSU }http://www.jus.uio.no/sisu { FSF }http://www.fsf.org -:A~ A Sample Document +A~ A Sample Document -:B~ just for fun +B~ just for fun 1~ This is Chapter One or Article One @@ -570,9 +590,9 @@ WOK @links: { SiSU }http://www.jus.uio.no/sisu { FSF }http://www.fsf.org -:A~ @title @author +A~ @title @author -:B~ just for fun +B~ just for fun 1~ This is Chapter One or Article One @@ -600,109 +620,79 @@ Header tags appear at the beginning of a document and provide meta information o All header instructions take either the form #{@cX.green}@headername:#{@cX.off} followed on the next line by an indented sub-category header if any #{@cX.green}:sub-headername:#{@cX.off}. #{@cX.green}@indentifier:#{@cX.off} information or instructions where the #{@cX.green}"identifier"#{@cX.off} is a tag recognised by the program, and the #{@cX.green}"information"#{@cX.off} or #{@cX.green}"instructions"#{@cX.off} belong to the tag/indentifier specified - Note: a header where used should only be used once; all headers apart from @title: are optional; the @structure: or 0~toc header is used to describe document structure, and can be useful to know. -This is a sample header (#{@cX.fuschia}Dublin Core in fuschia,#{@cX.off} #{@cX.cyan}other information headers in cyan,#{@cX.off} #{@cX.ruby}markup instructions in red#{@cX.off}): - -#{@cX.fuschia}@title:#{@cX.off} My Title - This is now the Title of the Document and used as such - #{@cX.cyan}:subtitle:#{@cX.off} The Subtitle if any - -#{@cX.fuschia}@creator:#{@cX.off} - #{@cX.fuschia}:author:#{@cX.off} Surname, Other names (if more than one author separate author names with a semi colon, if name is of an institution just write name or the name contains a comma enclose in quotation marks) - -#{@cX.fuschia}@classify:#{@cX.off} - #{@cX.fuschia}:topic_register:#{@cX.off} [e.g.:] text markup language; application:text processing;output:html|xml|latex|pdf|sql - -#{@cX.fuschia}@subject:#{@cX.off} (whatever your subject) - -#{@cX.fuschia}@description:#{@cX.off} - -#{@cX.fuschia}@publisher:#{@cX.off} - -#{@cX.fuschia}@contributor:#{@cX.off} - -#{@cX.fuschia}@translator:#{@cX.off} [or @translated_by:] - -#{@cX.fuschia}@illustrator:#{@cX.off} [or @illustrated_by:] - -#{@cX.fuschia}@prepared_by:#{@cX.off} [or @digitized_by:] - -#{@cX.fuschia}@date:#{@cX.off} 2000-08-27 -\t[ also #{@cX.fuschia}@date.created:#{@cX.off} #{@cX.fuschia}@date.issued:#{@cX.off} #{@cX.fuschia}@date.available:#{@cX.off} #{@cX.fuschia}@date.valid:#{@cX.off} #{@cX.fuschia}@date.modified:#{@cX.off} ] - -#{@cX.fuschia}@type:#{@cX.off} article - -#{@cX.fuschia}@format:#{@cX.off} - -#{@cX.fuschia}@identifier:#{@cX.off} - -#{@cX.fuschia}@source:#{@cX.off} - -#{@cX.fuschia}@language:#{@cX.off} [or @language.document:] [country code for language if available, or language, English, en is the default setting] (en - English, fr - French, de - German, it - Italian, es - Spanish, pt - Portuguese, sv - Swedish, da - Danish, fi - Finnish, no - Norwegian, is - Icelandic, nl - Dutch, et - Estonian, hu - Hungarian, pl - Polish, ro - Romanian, ru - Russian, el - Greek, uk - Ukranian, tr - Turkish, sk - Slovak, sl - Slovenian, hr - Croatian, cs - Czech, bg - Bulgarian ) [however, encodings are not available for all of the languages listed.] - -#{@cX.fuschia}@language.original:#{@cX.off} + Note: a header where used should only be used once; all headers apart from #{@cX.ruby}@title:#{@cX.off} are optional. + +#{@cX.ruby}@title:#{@cX.off} My Title - This is now the Title of the Document and used as such + #{@cX.cyan}:subtitle:#{@cX.off} The Subtitle if any + +#{@cX.ruby}@creator:#{@cX.off} + #{@cX.cyan}:author:#{@cX.off} Surname, Other names (if more than one author separate author names with a semi colon, if name is of an institution just write name or the name contains a comma enclose in quotation marks) + #{@cX.cyan}:contributor:#{@cX.off} + #{@cX.cyan}:translator:#{@cX.off} [or :translated_by:] + #{@cX.cyan}:illustrator:#{@cX.off} [or :illustrated_by:] + #{@cX.cyan}:prepared_by:#{@cX.off} [or :digitized_by:] + +#{@cX.ruby}@date:#{@cX.off} + #{@cX.cyan}:published:#{@cX.off} + #{@cX.cyan}:created:#{@cX.off} + #{@cX.cyan}:issued:#{@cX.off} + #{@cX.cyan}:available:#{@cX.off} + #{@cX.cyan}:valid:#{@cX.off} + #{@cX.cyan}:modified:#{@cX.off} + +#{@cX.ruby}@rights:#{@cX.off} + #{@cX.cyan}:copyright:#{@cX.off} Author's name, all rights reserved + #{@cX.cyan}:license:#{@cX.off} public domain, copyleft, creative commons variant, etc. + +#{@cX.ruby}@classify:#{@cX.off} + #{@cX.cyan}:topic_register:#{@cX.off} [e.g.:] text markup language; application:text processing;output:html|xml|latex|pdf|sql + #{@cX.cyan}:subject:#{@cX.off} (whatever your subject) + #{@cX.cyan}:keywords:#{@cX.off} + #{@cX.cyan}:coverage:#{@cX.off} + #{@cX.cyan}:relation:#{@cX.off} + #{@cX.cyan}:type:#{@cX.off} + #{@cX.cyan}:identifier:#{@cX.off} + #{@cX.cyan}:loc:#{@cX.off} [Library of Congress classification] + #{@cX.cyan}:dewey:#{@cX.off} [Dewey classification] + #{@cX.cyan}:isbn:#{@cX.off} + #{@cX.cyan}:oclc:#{@cX.off} + +#{@cX.ruby}@notes:#{@cX.off} + #{@cX.cyan}:description:#{@cX.off} + #{@cX.cyan}:abstract:#{@cX.off} + #{@cX.cyan}:comment:#{@cX.off} + #{@cX.cyan}:history:#{@cX.off} + #{@cX.cyan}:prefix:#{@cX.off} + #{@cX.cyan}:suffix:#{@cX.off} + +#{@cX.ruby}@publisher:#{@cX.off} + +#{@cX.ruby}@language:#{@cX.off} [or @language.document:] [country code for language if available, or language, English, en is the default setting] (en - English, fr - French, de - German, it - Italian, es - Spanish, pt - Portuguese, sv - Swedish, da - Danish, fi - Finnish, no - Norwegian, is - Icelandic, nl - Dutch, et - Estonian, hu - Hungarian, pl - Polish, ro - Romanian, ru - Russian, el - Greek, uk - Ukranian, tr - Turkish, sk - Slovak, sl - Slovenian, hr - Croatian, cs - Czech, bg - Bulgarian ) [however, encodings are not available for all of the languages listed.] + +#{@cX.ruby}@language.original:#{@cX.off} original language in which the work was published -#{@cX.fuschia}@papersize:#{@cX.off} -(A4|US_letter|book_B5|book_A5|US_legal) - -#{@cX.fuschia}@relation:#{@cX.off} - -#{@cX.fuschia}@coverage:#{@cX.off} - -#{@cX.fuschia}@rights:#{@cX.off} copyright, all rights reserved, public domain, copyleft, creative commons variant, etc. - -#{@cX.cyan}@owner:#{@cX.off} - -#{@cX.cyan}@keywords:#{@cX.off} text document generation processing management latex pdf structured xml citation [your keywords here, used for example by rss feeds, and in sql searches] - -#{@cX.cyan}@abstract:#{@cX.off} [paper abstract, placed after table of contents] - -#{@cX.cyan}@comment:#{@cX.off} [...] - -#{@cX.cyan}@catalogue:#{@cX.off} #{@cX.green}loc=#{@cX.off}[Library of Congress classification]; #{@cX.green}dewey=#{@cX.off}[Dewey classification]; #{@cX.green}isbn=#{@cX.off}[ISBN]; #{@cX.green}pg=#{@cX.off}[Project Gutenberg text number] - -#{@cX.cyan}@classify_loc:#{@cX.off} [Library of Congress classification] - -#{@cX.cyan}@classify_dewey:#{@cX.off} [Dewey classification] - -#{@cX.cyan}@classify_isbn:#{@cX.off} [ISBN] - -#{@cX.cyan}@classify_pg:#{@cX.off} [Project Gutenberg text number] - -#{@cX.cyan}@prefix_a:#{@cX.off} [prefix is placed just before table of contents - not implemented] - -#{@cX.cyan}@prefix_b:#{@cX.off} or #{@cX.cyan}@prefix:#{@cX.off} [prefix is placed just after table of contents] - -#{@cX.cyan}@rcs:#{@cX.off} $Id$ [used by rcs or cvs to embed version (revision control) information into document, rcs or cvs can usefully provide a history of updates to a document ] - -#{@cX.ruby}@structure:#{@cX.off} PART; CHAPTER; SECTION; ARTICLE; none; none; -optional, document structure can be defined by words to match or regular expression (the regular expression is assumed to start at the beginning of a line of text i.e. ^) default markers :A~ to :C~ and 1~ to 6~ can be used within text instead, without this header tag, and may be used to supplement the instructions provided in this header tag if provided (@structure: is a synonym for @toc:) - -#{@cX.ruby}@level:#{@cX.off} newpage=3; breakpage=4 [paragraph level, used by latex to breakpages, the page is optional eg. in newpage] - -#{@cX.ruby}@markup:#{@cX.off} num_top=4 [various markup instructions, eg: num_top=4 headings tobe numbered, starting at heading level 4... the default is to provide 3 levels, as in 1 level 4, 1.1 level 5, 1.1.1 level 6, markup to be merged within level] - -#{@cX.ruby}@bold:#{@cX.off} [regular expression of words/phrases to be made bold] - -#{@cX.ruby}@italics:#{@cX.off} [regular expression of words/phrases to italize] - -#{@cX.ruby}@vocabulary:#{@cX.off} name of taxonomy/vocabulary/wordlist to use against document - -#{@cX.ruby}@skin:#{@cX.off} skin_doc_[name_of_desired_document_skin] - -#{@cX.ruby}@links:#{@cX.off} { SiSU }http://www.jus.uio.no/sisu/; { FSF }http://www.fsf.org +#{@cX.ruby}@links:#{@cX.off} + { SiSU }http://www.jus.uio.no/sisu/ + { FSF }http://www.fsf.org -#{@cX.ruby}@@promo:#{@cX.off} sisu, ruby, search_libre_docs, open_society [places content in right pane in html, makes use of list.yml and promo.yml, commented out sample in document sample: free_as_in_freedom.richard_stallman_crusade_for_free_software.sam_williams.sst] +#{@cX.ruby}@make:#{@cX.off} + #{@cX.cyan}:breaks:#{@cX.off} new=:B; break=1 + #{@cX.cyan}:bold:#{@cX.off} [regular expression of words/phrases to be made bold] + #{@cX.cyan}:italics:#{@cX.off} [regular expression of words/phrases to italize] + #{@cX.cyan}:headings:#{@cX.off} PART; CHAPTER; Section; Article; + #{@cX.grey}% optional, document structure can be defined by words to match or regular expression (the regular expression is assumed to start at the beginning of a line of text i.e. ^) default markers A~ to C~ and 1~ to 6~ can be used within text instead, without this header tag, and may be used to supplement the instructions provided in this header tag if provided#{@cX.off} + #{@cX.cyan}:papersize:#{@cX.off} (A4|US_letter|book_B5|book_A5|US_legal) + #{@cX.cyan}:markup:#{@cX.off} num_top=4 [various markup instructions, eg: num_top=4 headings tobe numbered, starting at heading level 4... the default is to provide 3 levels, as in 1 level 4, 1.1 level 5, 1.1.1 level 6, markup to be merged within level] + #{@cX.cyan}:promo:#{@cX.off} sisu, ruby, search_libre_docs, open_society [places content in right pane in html, makes use of list.yml and promo.yml, commented out sample in document sample: free_as_in_freedom.richard_stallman_crusade_for_free_software.sam_williams.sst] #{@cX.grey}% header ends here, NB only @title: is mandatory [this would be a comment]#{@cX.off} -#{@cX.grey}% NOTE: headings/levels below refer to 0.38 expermental markup - (a conversion script provided in sisu-examples, modify.rb makes conversion between 0.37 and 0.38 markup simple)#{@cX.off} -#{@cX.blue}:A~#{@cX.off} Top level heading [this is usually the same as the title @title: ] +#{@cX.blue}A~#{@cX.off} Top level heading [this is usually the same as the title @title: ] -#{@cX.blue}:B~#{@cX.off} Second level heading [this is a heading level divider] +#{@cX.blue}B~#{@cX.off} Second level heading [this is a heading level divider] -#{@cX.blue}:C~#{@cX.off} Third level heading [this is a heading level divider] +#{@cX.blue}C~#{@cX.off} Third level heading [this is a heading level divider] #{@cX.blue}1~#{@cX.off} Top level heading preceding substantive text of document or sub-heading 5, the heading level that would normally be marked 1. or 2. or 3. etc. in a document @@ -1082,7 +1072,7 @@ The following heading or level (structuring) defaults are available (for use ins or, [0.38] - :A~ :B~ :C~ 1~ 2~ 3~ + A~ B~ C~ 1~ 2~ 3~ Heading tags take either of the forms above, ranging from 1-6 @@ -1114,11 +1104,11 @@ in the 0.38 notation this maps to: % SiSU 0.38 -:A~ Document Title +A~ Document Title -:B~ Document Subtitle whatever it is +B~ Document Subtitle whatever it is -:C~ Part +C~ Part 1~ Chapter @@ -1291,8 +1281,7 @@ WOK WOK end - def install - #% system configuration + def install #% system configuration print <
- - #{@md.ad_alt} - -

-#{@vz.table_close} -} - end - def heading_advert_external - dir=SiSU_Env::InfoEnv.new(@fns) - %{

- -\n} end def links(url,lnk,target) diff --git a/lib/sisu/v3/manpage_format.rb b/lib/sisu/v3/manpage_format.rb index 8698ee40..a102b094 100644 --- a/lib/sisu/v3/manpage_format.rb +++ b/lib/sisu/v3/manpage_format.rb @@ -76,11 +76,6 @@ module SiSU_ManpageFormat class FormatTextObject def initialize(md,dob) @md,@dob=md,dob -if @dob.class==Hash - puts __FILE__ + ' ' + __LINE__.to_s #+ "-->\n" + caller.inspect -elsif @dob.class==String - puts __FILE__ + ' ' + __LINE__.to_s #+ "-->\n" + caller.inspect -end rgx=/#{Mx[:en_a_o]}[\d*+]+\s+(.+?)#{Mx[:en_a_c]}/ @dob.obj.gsub!(rgx,'\1') if @dob.obj =~rgx @vz=SiSU_Env::GetInit.instance.skin diff --git a/lib/sisu/v3/options.rb b/lib/sisu/v3/options.rb index ba2864fd..39c392a9 100644 --- a/lib/sisu/v3/options.rb +++ b/lib/sisu/v3/options.rb @@ -57,7 +57,7 @@ =end module SiSU_Commandline - require "pathname" + require 'pathname' require_relative 'sysenv' # sysenv.rb @@base_path=nil class Options @@ -216,7 +216,7 @@ module SiSU_Commandline if x =~/^(?:https?|file):\/\/\S+/ #\ end pwd=Dir.pwd - fn_pod=x.gsub(/.+?([^\/]+)\.txz$/,'\1') + fn_pod=x.gsub(/([^\/]+)\.txz$/,'\1') fullname=@env.processing_path.processing + '/sisupod/' + fn_pod pt=Pathname.new(fullname) FileUtils::mkdir_p(pt.to_s) @@ -224,7 +224,7 @@ module SiSU_Commandline options=s.gsub(/(\s+--?\S+)+.+/,'\1') system(" chdir #{fullname} - tar xaf #{x} + tar xaf #{pwd}/#{x} chdir #{pwd} ") Dir.chdir(pt.realpath.to_s + '/sisupod/doc') diff --git a/lib/sisu/v3/param.rb b/lib/sisu/v3/param.rb index 64baf271..492b8044 100644 --- a/lib/sisu/v3/param.rb +++ b/lib/sisu/v3/param.rb @@ -554,36 +554,36 @@ module SiSU_Param and copyright.translation \ and not copyright.translation.empty? v=sep(copyright.translation) - s +='
translation ' + copyright.translation + v + 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 + 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 + 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 + 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 + s +='\\\\ audio ' + copyright.audio + v end if defined? copyright.license \ and copyright.license \ and not copyright.license.empty? - s +='
License: ' + copyright.license + s +='\\\\ License: ' + copyright.license end if s.empty? SiSU_Screen::Ansi.new(@opt.cmd,'WARNING Document Rights information missing; provide @rights: :copyright:').warn unless @opt.cmd =~/q/ @@ -812,8 +812,8 @@ module SiSU_Param matches='' w.each do |x| c=(x[1] =~/[i],/) ? :i : :s - matches=matches + x[0].gsub(/([${}])/,'\\\\\1') + '|' - arr_hash << { + matches=matches + x[0].gsub(/([${}])/,'\\\\\1') + '|' + arr_hash << { match: x[0].gsub(/([${}])/,'\\\\\1'), replace: x[2], case_s: c @@ -1025,7 +1025,6 @@ module SiSU_Param end def links a=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m) - a end def notes a=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m) @@ -1230,13 +1229,13 @@ module SiSU_Param @notes=SiSU_Param::Parameters::Md.new($1.strip,@opt,@env).notes when /^@links:\s+(.+?)\Z/m #% * header metadata - links doc_links=SiSU_Param::Parameters::Md.new($1.strip,@opt,@env).links - count=1 + a_idx=0 @links=[] doc_links.each do |doc_link| if doc_link=~/\{.+?\}(?:(?:https?|file|ftp):\/|\.\.)\/\S+(?:\s|$)/ - @links[count]={} - @links[count][:say],@links[count][:url]=/\{\s*(.+?)\s*\}((?:(?:https?|file|ftp):\/|\.\.)\/\S+)/im.match(doc_link)[1,2] - count +=1 + @links[a_idx]={} + @links[a_idx][:say],@links[a_idx][:url]=/\{\s*(.+?)\s*\}((?:(?:https?|file|ftp):\/|\.\.)\/\S+)/im.match(doc_link)[1,2] + a_idx +=1 end end @lnk=@links @@ -1397,6 +1396,12 @@ module SiSU_Param @sem_tag=true if para=~/[:;]\{.+?\}[:;][a-z+]/ #refix later end end #% here endeth the document loop + unless @make + if @opt.cmd =~/[VM]/ + SiSU_Screen::Ansi.new(@opt.cmd,'@make:','header absent').warn + end + @make=SiSU_Param::Parameters::Md.new('@make: ',@opt,@env).make + end if @ec[:image].length > 0 @ec[:image]=@ec[:image].flatten.uniq @ec[:image].delete_if {|x| x =~/https?:\/\// } @@ -1491,7 +1496,7 @@ module SiSU_Param @dgst_skin=skin ? (@sys.md5(skin)) : nil end end - @publisher ||= "#@@publisher (this copy)" + @publisher ||= "#{@@publisher} (this copy)" fn_set_lang=SiSU_Env::StandardiseLanguage.new(@opt.lng).language unless @language[:code] \ and @language[:name] diff --git a/lib/sisu/v3/qrcode.rb b/lib/sisu/v3/qrcode.rb index 3908a1d4..0d126266 100644 --- a/lib/sisu/v3/qrcode.rb +++ b/lib/sisu/v3/qrcode.rb @@ -117,16 +117,18 @@ module SiSU_QRcode def output_metadata fn=@f.base_filename.manifest_txt mn='' - if @md.opt =~/M/ + if @md.opt.cmd =~/M/ pt=@f.output_path.manifest.dir fn=@f.base_filename.manifest_txt manifest=@f.write_file.manifest_txt end @manifest[:txt].each do |x| - manifest << x if @md.opt =~/M/ + x=x.gsub(/\\\\/m,"\n") + puts x if @md.opt.cmd =~/V/ + manifest << x if @md.opt.cmd =~/M/ mn += x end - manifest.close if @md.opt =~/M/ + manifest.close if @md.opt.cmd =~/M/ #system(%{ # cat #{pt}/#{fn} | qrencode -s 3 -o qrcm.autonomy_markup0.png #}) diff --git a/lib/sisu/v3/screen_text_color.rb b/lib/sisu/v3/screen_text_color.rb index cef15585..a9c0b367 100644 --- a/lib/sisu/v3/screen_text_color.rb +++ b/lib/sisu/v3/screen_text_color.rb @@ -73,7 +73,7 @@ module SiSU_Screen @use_color=(flag.color) \ ? ((@cmd =~/c/) ? false : true) : ((@cmd =~/c/) ? true : false) - if @cmd =~/k/ then @use_color=false + if @cmd =~/k/ then @use_color=false # useful color off switch, however, k may be used for something else in future end else @use_color=false end @@ -249,13 +249,6 @@ module SiSU_Screen %{#{@cX.off} } + %{#{@cX.cyan}nav only: #{@txt[4]}#{@cX.off}.} end - def php_numbers - puts %{ #{@cX.green}#{@txt[0]}#{@cX.off} #{@cX.cyan}files processed#{@cX.off}. } + - %{php_scr only: #{@txt[1]}, } + - %{#{@cX.cyan}php_seg only: #{@txt[2]}#{@cX.off}, } + - %{joint php scroll & seg: #{@txt[3]}, } + - %{php_nav only: #{@txt[4]}} - end def txt_white puts "\t#{@cX.white}#{@txt[0]}#{@cX.off} #{@cX.white}#{@txt[1]}#{@cX.off}" end @@ -343,6 +336,9 @@ module SiSU_Screen 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 @@ -398,9 +394,6 @@ module SiSU_Screen 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 php_title - puts %{\n#{@cX.green_hi}#{@cX.black}PHP#{@cX.off*2}} - end def segmented puts "\t#{@cX.grey}Seg#{@cX.off} #{@cX.green}#{@txt[0]}#{@cX.off} #{@cX.grey}segments#{@cX.off}" end diff --git a/lib/sisu/v3/shared_images.rb b/lib/sisu/v3/shared_images.rb index c92719f6..e55f03ad 100644 --- a/lib/sisu/v3/shared_images.rb +++ b/lib/sisu/v3/shared_images.rb @@ -78,7 +78,7 @@ module SiSU_Images end end def images_set - @pwd=ENV['PWD'] + @pwd=(/(\S+?)(?:\/(?:#{Px[:lng_lst_rgx]}))?$/).match(Dir.pwd)[1] def copy(src_path,dest_path,images=nil) if FileTest.directory?(src_path) FileUtils::cd(src_path) diff --git a/lib/sisu/v3/sysenv.rb b/lib/sisu/v3/sysenv.rb index 1c813fd8..40880701 100644 --- a/lib/sisu/v3/sysenv.rb +++ b/lib/sisu/v3/sysenv.rb @@ -224,10 +224,6 @@ module SiSU_Env "#{@@home}/.sisu", "#{@@sisu_etc}/#{SiSU_version_dir}", ] - @@yamlrc_path=@@rc_path - #@@yamlrc_path=(stub_pwd !~/^sisupod$/) \ - #? (["#{@@pwd}/_sisu/#{SiSU_version_dir}","#{@@pwd}/_sisu","#{@@home}/.sisu/#{SiSU_version_dir}","#{@@home}/.sisu","#{@@sisu_etc}/#{SiSU_version_dir}"]) - #: ["#{@@home}/.sisu/#{SiSU_version_dir}","#{@@home}/.sisu","#{@@sisu_etc}/#{SiSU_version_dir}"] #security policy: prevent reading of sisurc.yml in sisupod @@ad_path=(stub_pwd !~/^sisupod$/) \ ? ([ "#{@@pwd}/.sisu/skin/yml", @@ -236,10 +232,10 @@ module SiSU_Env "#{@@sisu_etc}/skin/yml", ]) : ["#{@@home}/.sisu",@@sisu_etc] - attr_accessor :user,:home,:hostname,:pwd,:host,:arch,:rbver,:dir_arch,:dir_sitearch,:dir_bin,:locale,:webserv_path,:webserv_host_cgi,:webserv_port_cgi,:default_dir,:rc_path,:yamlrc_path,:ad_path + attr_accessor :user,:home,:hostname,:pwd,:host,:arch,:rbver,:dir_arch,:dir_sitearch,:dir_bin,:locale,:webserv_path,:webserv_host_cgi,:webserv_port_cgi,:default_dir,:rc_path,:ad_path def initialize - @user,@home,@hostname,@pwd,@sisu_etc,@host,@arch,@rbver,@dir_arch,@dir_sitearch,@dir_bin,@locale,@default_dir,@rc_path,@yamlrc_path,@ad_path=\ - @@user,@@home,@@hostname,@@pwd,@@sisu_etc,@@host,@@arch,@@rbver,@@dir_arch,@@dir_sitearch,@@dir_bin,@@locale,@@default_dir,@@rc_path,@@yamlrc_path,@@ad_path + @user,@home,@hostname,@pwd,@sisu_etc,@host,@arch,@rbver,@dir_arch,@dir_sitearch,@dir_bin,@locale,@default_dir,@rc_path,@ad_path=\ + @@user,@@home,@@hostname,@@pwd,@@sisu_etc,@@host,@@arch,@@rbver,@@dir_arch,@@dir_sitearch,@@dir_bin,@@locale,@@default_dir,@@rc_path,@@ad_path #note rbver is duplicated in InfoVersion end end @@ -297,7 +293,7 @@ module SiSU_Env def sisu_yaml def rc unless @@rc - @yamlrc_path.each do |v| + @rc_path.each do |v| if @@noyaml \ or FileTest.exist?("#{v}/noyaml") STDERR.puts "WARNING - YAML loading switched off, to enable delete the file:\n\t#{v}/noyaml\n\n" unless @@noyaml @@ -2282,59 +2278,18 @@ WOK else defaults[:webserv_host_cgi] end end - def webrick_port - if @md \ - and @md.opt.cmd.inspect=~/-F/ \ - and @md.opt.mod.inspect=~/port=(\d+)/ - $1 - else - if defined? @rc['webserv_cgi']['port'] - if @rc['webserv_cgi']['port'].nil? \ - and (defined? @md.opt.mod \ - and not @md.opt.mod.nil? \ - and @md.opt.mod.inspect=~/webrick/) - defaults[:webserv_port_cgi] - elsif not @rc['webserv_cgi']['port'].nil? - @rc['webserv_cgi']['port'] - else defaults[:webserv_port_cgi] - end - else defaults[:webserv_port_cgi] - end - end - end - def webserv_port_cgi - if @md \ - and defined? @md.opt \ - and @md.opt.cmd.inspect=~/-F/ \ - and @md.opt.mod.inspect=~/port=(\d+)/ - $1 - else - if defined? @rc['webserv_cgi']['port'] - if @rc['webserv_cgi']['port'].nil? \ - and (defined? @md.opt.mod \ - and not @md.opt.mod.nil? \ - and @md.opt.mod.inspect=~/webrick/) - defaults[:webserv_port_cgi] - elsif not @rc['webserv_cgi']['port'].nil? - @rc['webserv_cgi']['port'] - else nil - end - else nil - end - end - end def webserv_cgi #web url for local webserv (localhost, or hostname) if defined? @rc['webserv_cgi']['host'] \ and @rc['webserv_cgi']['host'].is_a?(String) http=((@rc['webserv_cgi']['host'] =~ /https?:\/\//) ? '' : 'http://') #check https? missing - if webserv_port_cgi - "#{http}#{@rc['webserv_cgi']['host']}:#{webserv_port_cgi}/#{@stub_pwd}" + if port.webserv_port_cgi + "#{http}#{@rc['webserv_cgi']['host']}:#{port.webserv_port_cgi}/#{@stub_pwd}" else "#{http}#{@rc['webserv_cgi']['host']}/#{@stub_pwd}" end else http=((webserv_host_base=~/https?:\/\//) ? '' : 'http://') - if webserv_port_cgi - "#{http}#{webserv_host_base}:#{webserv_port_cgi}/#{@stub_pwd}" + if port.webserv_port_cgi + "#{http}#{webserv_host_base}:#{port.webserv_port_cgi}/#{@stub_pwd}" else "#{http}#{webserv_host_base}/#{@stub_pwd}" end end @@ -2343,14 +2298,14 @@ WOK if defined? @rc['webserv_cgi']['host'] \ and @rc['webserv_cgi']['host'].is_a?(String) http=((@rc['webserv_cgi']['host'] =~ /https?:\/\//) ? '' : 'http://') - if webserv_port_cgi - "#{http}#{@rc['webserv_cgi']['host']}:#{webserv_port_cgi}" + if port.webserv_port_cgi + "#{http}#{@rc['webserv_cgi']['host']}:#{port.webserv_port_cgi}" else "#{http}#{@rc['webserv_cgi']['host']}" end else http=((webserv_host_base=~/https?:\/\//) ? '' : 'http://') - if webserv_port_cgi - "#{http}#{webserv_host_base}:#{webserv_port_cgi}" + if port.webserv_port_cgi + "#{http}#{webserv_host_base}:#{port.webserv_port_cgi}" else "#{http}#{webserv_host_base}" end end @@ -2381,8 +2336,8 @@ WOK elsif defined? @rc['webserv']['webrick_url'] \ and @rc['webserv']['webrick_url']==false "file://#{path.webserv}" - elsif webserv_port_cgi =~/\S+/ - "#{url.hostname}:#{webserv_port_cgi}" + elsif port.webserv_port_cgi =~/\S+/ + "#{url.hostname}:#{port.webserv_port_cgi}" else url.hostname end @@ -2475,6 +2430,50 @@ WOK end self end + def port + def webrick_port + if @md \ + and @md.opt.cmd.inspect=~/-F/ \ + and @md.opt.mod.inspect=~/port=(\d+)/ + $1 + else + if defined? @rc['webserv_cgi']['port'] + if @rc['webserv_cgi']['port'].nil? \ + and (defined? @md.opt.mod \ + and not @md.opt.mod.nil? \ + and @md.opt.mod.inspect=~/webrick/) + defaults[:webserv_port_cgi] + elsif not @rc['webserv_cgi']['port'].nil? + @rc['webserv_cgi']['port'] + else defaults[:webserv_port_cgi] + end + else defaults[:webserv_port_cgi] + end + end + end + def webserv_port_cgi + if @md \ + and defined? @md.opt \ + and @md.opt.cmd.inspect=~/-F/ \ + and @md.opt.mod.inspect=~/port=(\d+)/ + $1 + else + if defined? @rc['webserv_cgi']['port'] + if @rc['webserv_cgi']['port'].nil? \ + and (defined? @md.opt.mod \ + and not @md.opt.mod.nil? \ + and @md.opt.mod.inspect=~/webrick/) + defaults[:webserv_port_cgi] + elsif not @rc['webserv_cgi']['port'].nil? + @rc['webserv_cgi']['port'] + else nil + end + else nil + end + end + end + self + end def digest def type if defined? @rc['default']['digest'] \ @@ -5614,7 +5613,7 @@ WOK @env=SiSU_Env::InfoEnv.new end def webrick - @env.url.webrick_port + @env.port.webrick_port end end class InfoProgram < InfoEnv #revisit @@ -6017,15 +6016,3 @@ module SiSU_Errors end __END__ https? intro check 2007-09-22 - -fns_array=unless fns =~/\.ssm.sst$/ - if RUBY_VERSION < '1.9' - IO.readlines(fns,'') - else IO.readlines(fns,'r:utf-8') - end -else - if RUBY_VERSION < '1.9' - IO.readlines("#{processing_path.composite_file}/#{fns}",'') - else IO.readlines("#{processing_path.composite_file}/#{fns}",'r:utf-8') - end -end diff --git a/lib/sisu/v3/texpdf_format.rb b/lib/sisu/v3/texpdf_format.rb index a7331447..2bd558bc 100644 --- a/lib/sisu/v3/texpdf_format.rb +++ b/lib/sisu/v3/texpdf_format.rb @@ -1284,8 +1284,7 @@ WOK "\\1#{@brace_url.tex_open}\\begin{scriptsize}\\url{\\2}\\end{scriptsize}#{@brace_url.tex_close}\\3") #url matching with decoration positive lookahead, sequence issue with { linked }http://url cannot use \b at start end str=str.gsub(/<:ee>/,''). - gsub(//,' '). - #proposed change, insert, but may be redundant + gsub(//,' '). #proposed change, insert, but may be redundant gsub(/<(br|p)>|<\/\s*(br|p)>|<(br|p)\s*\/>/," #{Tex[:backslash]*2} "). # Work Area gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'\begin{bfseries}\1 \end{bfseries}'). gsub(/(.+?)<\/h\d+>/,'\begin{bfseries}\1 \end{bfseries}'). diff --git a/lib/sisu/v3/urls.rb b/lib/sisu/v3/urls.rb index 1dcf988f..0aba1d89 100644 --- a/lib/sisu/v3/urls.rb +++ b/lib/sisu/v3/urls.rb @@ -278,10 +278,11 @@ module SiSU_Urls end def urls_select unless @opt.cmd =~/q/ - i="(output manifest) [#{@opt.f_pth[:lng_is]}] #{@md.file.output_path.manifest.dir}/#{@md.file.base_filename.manifest}" + i1="[#{@opt.f_pth[:lng_is]}]" + i2="file://#{@md.file.output_path.manifest.dir}/#{@md.file.base_filename.manifest}" @opt.cmd=~/[MVvz]/ \ ? SiSU_Screen::Ansi.new(@opt.cmd,'URLs').green_title_hi - : SiSU_Screen::Ansi.new(@opt.cmd,'URL',i).grey_title_hi + : SiSU_Screen::Ansi.new(@opt.cmd,'URL (output manifest)',i1, i2).grey_title_grey_blue SiSU_Screen::Ansi.new(@opt.cmd,@opt.fns,"#{@md.file.output_path.manifest.dir}/#{@md.file.base_filename.manifest}").flow if @opt.cmd =~/[MVv]/ end m=/.+\/(?:src\/)?(\S+)/im # m=/.+?\/(?:src\/)?([^\/]+)$/im # m=/.+\/(\S+)/m diff --git a/lib/sisu/v3/webrick.rb b/lib/sisu/v3/webrick.rb index f8189bba..96280d0c 100644 --- a/lib/sisu/v3/webrick.rb +++ b/lib/sisu/v3/webrick.rb @@ -56,77 +56,54 @@ suffixes, see man pages for options =end -def brick(port,get='') - cgidir=if get=~/pwd/; Dir.pwd - else '/usr/lib/cgi-bin' # @env.path.cgi - end - port=SiSU_Env::InfoPort.new.webrick - begin - s=HTTPServer.new( - Port: port, - DocumentRoot: Dir::pwd + '/htdocs', - CGIPathEnv: ENV['PATH'] - ) - cgi_dir=File.expand_path(cgidir) - @mount.each { |x,y| # mount subdirectories - s.mount(x, HTTPServlet::FileHandler, y, true) - } - s.mount('/cgi-bin', HTTPServlet::FileHandler, cgi_dir, { FancyIndexing: true }) - trap("INT"){ s.shutdown } - s.start - rescue - SiSU_Errors::InfoError.new($!,$@,'-W',nil).error do #fix - __LINE__.to_s + ':' + __FILE__ - end - ensure - end -end -begin #% - require 'webrick' - include WEBrick - require 'time' - require_relative 'sysenv' # sysenv.rb - include SiSU_Env; include SiSU_Screen - @cX=SiSU_Screen::Ansi.new('yes').cX - @env=SiSU_Env::InfoEnv.new - port=SiSU_Env::InfoPort.new - @argv=$* - @host=@env.url.webrick - host='localhost' - @port="#{@argv[0].to_i}" - @port="#{port.webrick}" if @port =~ /^0$/ - @serve=[] - Dir.foreach(@env.path.webserv) do |x| - if x !~/^\./ \ - and FileTest.directory?("#{@env.path.webserv}/#{x}") - @serve << x - end - end - @mount=[] - @serve.each {|x| @mount << ["/#{x}", "#{@env.path.webserv}/#{x}"]} - @pwd=Dir.pwd - @week=Time.now.strftime(%{%Yw%W}) - puts "\n" - @mount.each { |x,y| - puts " #{@cX.cyan}#{x}#{@cX.off}\t#{@cX.grey}see#{@cX.off} #{@cX.blue}#{@host}:#{@port}#{x}/wb.cgi#{@cX.off} #{@cX.ruby}@#{@cX.off} #{@cX.blue}#{@host}:#{@port}#{x}/#{@cX.off}" - } - puts "#{@cX.grey}" - wb_s2=[] - #% writes file wb.cgi to shared directories ... - #% wb_top - wb_top=%q(#!/usr/bin/env ruby - # * arch-tag: webrick info on environment, mounted directories, and contents of pwd - require 'time' - require 'cgi' - require 'fcgi' - ls=Dir.entries('./') - dir_contents=[] - ls.each { |x| dir_contents << "#{x}
" unless x =~/^(\.)+$/ } - dir_contents=dir_contents.sort.join(' ') - #host=ENV['HOSTNAME'] - #host=%x{echo $HOSTNAME} - ) - wb_s1=<#{x}
" unless x =~/^(\.)+$/ } + dir_contents=dir_contents.sort.join(' ') + #host=ENV['HOSTNAME'] + #host=%x{echo $HOSTNAME} + ) + wb_s1=<#{x} '} + '#{@host}:#{@port}#{x} (mounts: #{y}/) info (wb.cgi)'} + + #% wb_s2 (mounts) + @mount.each do |x,y| wb_s2 <<<#{x} '} + '#{@host}:#{@port}#{x} (mounts: #{y}/) info (wb.cgi)'} + WOK -end - #% wb_end - wb_end=<
- - #{@md.ad_alt} - -

-#{@vz.table_close} -} end def credit %{ @@ -1033,16 +997,14 @@ WOK end para_form_css('p','norm') end - def break - @txt=@txt.gsub(/#{Mx[:br_page_new]}|#{Mx[:br_page]}/,'



'). - gsub(/#{Mx[:br_obj]}/,'

') - para_form_css('p','norm') - end def format(tag,attrib) para_form_css(tag,attrib) end def heading_normal(tag,attrib) - %{ + section_break=(tag=~/h[1-4]/) \ + ? '


' + : '' + %{#{section_break}
#{@p_num.ocn_display} <#{tag} class="#{attrib}" #{@p_num.id}>#{@p_num.name} diff --git a/lib/sisu/v3/html_scroll.rb b/lib/sisu/v3/html_scroll.rb index 8e9b6e11..170285cf 100644 --- a/lib/sisu/v3/html_scroll.rb +++ b/lib/sisu/v3/html_scroll.rb @@ -125,14 +125,22 @@ module SiSU_HTML_Scroll end elsif dob.is==:heading_insert x=if dob.ln==1 - sto.heading_body1 + unless dob.obj.empty? + sto.heading_body1 + end elsif dob.ln==2 - sto.heading_body2 + unless dob.obj.empty? + sto.heading_body2 + end elsif dob.ln==3 - sto.heading_body3 + unless dob.obj.empty? + sto.heading_body3 + end elsif dob.ln==4 \ and dob.obj !~/^(?:Endnotes|Index|Metadata|Manifest)$/ - sto.heading_body4 + unless dob.obj.empty? + sto.heading_body4 + end elsif dob.ln==4 \ and dob.obj=='Endnotes' sto.heading_body4 @@ -141,19 +149,18 @@ module SiSU_HTML_Scroll and dob.obj=='Index' sto.heading_body4 book_idx=SiSU_Particulars::CombinedSingleton.instance.get_idx_html(@md.opt).html_idx - book_idx.each do |x| #takes book index prepared for segments and strips segment identifying info + book_idx.each do |x| #takes book index prepared for segments & strips segment identifying info x=x.gsub(/(\1(?:-\d+)?)<\/a>/,'\2') end book_idx.join("\n") - #elsif dob.ln==4 \ - #and dob.obj=~/Meta/ - #p __LINE__ - ##and dob.obj=='Metadata' - #metadata=SiSU_Metadata::Summary.new(@md).xhtml.metadata elsif dob.ln==5 - sto.heading_body5 + unless dob.obj.empty? + sto.heading_body5 + end elsif dob.ln==6 - sto.heading_body6 + unless dob.obj.empty? + sto.heading_body6 + end end elsif dob.is==:para if dob.indent \ @@ -187,14 +194,13 @@ module SiSU_HTML_Scroll elsif dob.is==:table sto.table elsif dob.is==:break - sto.break end if dob =~// \ and dob =~/^(?:\^~\d+\s|)/ # hmmm re-adjusted 200507, for alt endnote which should again be matched ^~ ... not in response to problem though dob='' end - unless @rcdc; @scr[:body] << para_html unless para_html =~/\A\s*\Z/ - else #@scr[:metadata] << dob.obj + unless @rcdc + @scr[:body] << para_html unless para_html =~/\A\s*\Z/ end end end diff --git a/lib/sisu/v3/html_segments.rb b/lib/sisu/v3/html_segments.rb index 14c13d36..81bb08d4 100644 --- a/lib/sisu/v3/html_segments.rb +++ b/lib/sisu/v3/html_segments.rb @@ -370,7 +370,6 @@ module SiSU_HTML_Seg else '' end @@seg[:tocband_bannerless] << '
' << conditional_div_close << format_head_seg.navigation_band_bottom(@@segtocband,@@seg[:dot_nav]) - @@seg[:headings] << format_head_seg.seg_head_escript if SiSU_HTML_Format::HeadSeg.method_defined? :seg_head_escript #debug PHP move up in text #bug if @title_banner_ @@seg[:headings] << format_head_seg.title_banner(@md.title.main,@md.title.sub,@author).gsub(clean,'') end @@ -472,7 +471,6 @@ module SiSU_HTML_Seg elsif dob.is==:table sto.table elsif dob.is==:break - sto.break end if @md.flag_separate_endnotes dob.obj=dob.obj.gsub(/"\s+href="#_(\d+)">/,%{" href=\"endnotes#{Sfx[:html]}#_\\1">}) #endnote- twice #removed file type diff --git a/lib/sisu/v3/hub.rb b/lib/sisu/v3/hub.rb index 8a67ce10..2e0fb92c 100644 --- a/lib/sisu/v3/hub.rb +++ b/lib/sisu/v3/hub.rb @@ -215,13 +215,10 @@ p "#{__LINE__}:#{__FILE__}" if @opt.act[:maintenance][:set] ==:on SiSU_Screen::Ansi.new(@opt.cmd,@@n_do,'Termsheet(s) processed').term_sheet_title unless @opt.act[:quiet][:set] ==:on end def webrick # -W - port=prt=@fns - prt=if prt !~/\d+/ - 'webrick default (sysenv)' - else "webrick port set to #{prt}" - end + prt=SiSU_Env::InfoEnv.new(@fns).port.webrick_port puts %{#{@cX.blue}<<#{@cX.off}#{@cX.green}Start Webrick web server on port: #{prt}#{@cX.off}#{@cX.blue}>> #{@cX.off*2} } - system("sisu_webrick #{port}&\n") + require_relative 'webrick' + SiSU_Webserv::WebrickStart.new end def not_found puts "\n#{@cX.fuschia}FILE NOT FOUND:#{@cX.off} << #{@opt.fns} >> - requested #{@opt.cmd} processing skipped\n" diff --git a/lib/sisu/v3/manifest.rb b/lib/sisu/v3/manifest.rb index fdacf164..c2490837 100644 --- a/lib/sisu/v3/manifest.rb +++ b/lib/sisu/v3/manifest.rb @@ -87,7 +87,7 @@ module SiSU_Manifest url_html="file://#{@md.file.output_path.manifest.dir}/#{@md.file.base_filename.manifest}" @opt.cmd=~/[MVvz]/ \ ? SiSU_Screen::Ansi.new(@opt.cmd,'Manifest',"#{xbrowser} #{url_html}").green_hi_blue - : SiSU_Screen::Ansi.new(@opt.cmd,'Manifest',"[#{@opt.f_pth[:lng_is]}] #{@opt.fno}").grey_title_hi + : SiSU_Screen::Ansi.new(@opt.cmd,'Manifest',"[#{@opt.f_pth[:lng_is]}]", "#{url_html}").grey_title_grey_blue SiSU_Screen::Ansi.new(@opt.cmd,"#{browser} #{url_html}").grey_tab if @opt.cmd =~/v/i end data=SiSU_HTML::Source::HTML_Environment.new(@particulars).tuned_file_instructions @@ -111,7 +111,7 @@ module SiSU_Manifest @base_url="#{@env.url.root}/#{@fnb}" @o_str=SiSU_Env::FileOp.new(md).output_dir_structure @image_path=if @o_str.dump_or_redirect? - %{./image} + './image' else %{#{@f.path_rel_links.html_scroll_2}_sisu/image_sys} end @@ -225,7 +225,7 @@ module SiSU_Manifest end end def metadata(id,info) - info=info.to_s.gsub(/#{Mx[:br_line]}/,'
') + info=info.to_s.gsub(/(?:#{Mx[:br_line]}|\\)+/,'
') @manifest[:html] << %{

#{id}:

#{info}

' end - def buttons_home - %{\n#{@banner.home_and_index_buttons}\n} - end - def copyat - %{copy @ #{@txt.home}} - end def toc_head < @@ -381,17 +373,6 @@ WOK def table_close %{ #{@vz.table_close}} - end - def buttons_home - %{ - #{@vz.banner_home_and_index_buttons} -} - end - def copyat - %{#{@vz.paragraph_font_tiny}copy @ - - #{@vz.txt_home} - } end def html_close #moved %{ diff --git a/lib/sisu/v3/xml_tables.rb b/lib/sisu/v3/xml_tables.rb index 98dc0140..ba89e791 100644 --- a/lib/sisu/v3/xml_tables.rb +++ b/lib/sisu/v3/xml_tables.rb @@ -97,11 +97,9 @@ module SiSU_Tables if @parablock =~/#{Mx[:tc_p]}#{Mx[:tc_p]}/u @parablock=@parablock.gsub(/#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u, %{
- #{@vz.paragraph_table_xml}}). + }). gsub(/#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u, - %{ - #{@vz.paragraph_table_xml}}). + %{}). gsub(/#{Mx[:tc_c]}/,"\n
- #{@vz.paragraph_table_xml}}). + }). gsub(/#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u, %{ - #{@vz.paragraph_table_xml}}). + }). gsub(/#{Mx[:tc_c]}/,"\n