From 16c30474f06ed3774ad524a38b55b7840de057d0 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Sun, 25 May 2014 10:01:43 -0400 Subject: v5: merge v6 to v5, version bump to 5.4.*, reason adds structure check * ao, document structure check, stop processing on major error (with error message & text at location of failure) [reason for version bump the addition of structure check] * utils, add ok code marker * ao, heading with no ocn, distinguish ~# from -# * ~# is general & means no ocn (for any object to which it is applied) * -# is relevant only for 1~ dummy headings & instructs that they should be removed from output where possible * applied so far to pdf, odt & plaintext * ao_images, reduce warnings when ruby RMagic absent as program used directly * reduced dependency on ruby RMagic library (as some time way back had issues) * ao, document markup structure check, skip processing file on major error * with error message & text at location of failure * texpdf, urls in creator cause breakage * texpdf, mailto markup links set for normal text objects * texpdf, '&' in heading breaks toc (now removed from toc (not heading)), bug * revisit, bug * texpdf, for urls switch to sans serif (small fontsize) * instead of typewriter, latex default * texpdf, pdf colored hyperlinks configurable * --pdf-hyperlinks-color --pdf-hyperlinks-no-color or --pdf-hyperlinks-monochrome * ['default']['pdf_hyperlinks']='color' (other options switch hyperlink color off 'no-color' 'color-off' 'monochrome') * texpdf, pdf default font size configurable (cli & sisurc.yml) (no fractions) * --pdf-fontsize-12 --pdf-fontsize-8 * default: texpdf_fontsize: 12 * texpdf, headings and table of contents representation * fixes 1~ and 2~ result in the same formatting 1~ 2~ & 3~ now differentiated, see discussion in sisu.org under #744383 * fixes :A smaller formatted than :B A~ B~ C~ now the same size, see discussion in sisu.org under #744383 * :B and :C result in the same formatting, issue explained see sisu.org * texpdf, (internal coding) fontface, rename texpdf_font texpdf_fontface * texpdf, (internal coding) use symbols to identify page orientation * param, metadata rights, line-breaks instead of semicolons separating rights * fixes remove trailing semicolon after :copyright: * digests sha512 option implemented * options sha512 sha256 md5 * command line --sha512 * rcconf.yml ['defsault']['digest'] = sha512 * xml object citation numbering (docbook fictionbook) --- lib/sisu/v5/sysenv.rb | 186 +++++++++++++++++++++++++++++++++++++------------- 1 file changed, 138 insertions(+), 48 deletions(-) (limited to 'lib/sisu/v5/sysenv.rb') diff --git a/lib/sisu/v5/sysenv.rb b/lib/sisu/v5/sysenv.rb index 4b94003c..cfd40460 100644 --- a/lib/sisu/v5/sysenv.rb +++ b/lib/sisu/v5/sysenv.rb @@ -214,7 +214,7 @@ module SiSU_Env MULTILINGUAL => false, BUNDLE => false, CONCORD_MAX => 260000, - DIGEST => 'sha256', + DIGEST => :sha256, WEBSERV_HOST_CGI => 'http://localhost', WEBSERV_PORT_CGI => 8081, #8111,8123,8081 POSTGRESQL_USER => @@user, #'ralph', # change user !!! @@ -249,7 +249,9 @@ module SiSU_Env $:.each do |reqpath| if FileTest.exist?("#{reqpath}/#{@prog}.rb") load_prog=true + #SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).ok("#{reqpath}/#{@prog}.rb loaded") break + #else SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).warn("#{reqpath}/#{@prog}.rb not found") end end if load_prog \ @@ -806,6 +808,19 @@ module SiSU_Env false end end + def sha512(filename) #sha dgst + program='openssl' + program_ref="\n\t\tsha digest requested" + if program_found?(program) + pwd=Dir.pwd + Dir.chdir(File.dirname(filename)) + dgst=%x{openssl dgst -sha512 #{File.basename(filename)}}.strip #use file name without file path + Dir.chdir(pwd) + dgst.scan(/\S+/) + else SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).warn("#{program} is not installed #{program_ref}") + false + end + end def psql #psql program='psql' program_ref="\n\t\tpsql requested" @@ -1861,59 +1876,123 @@ WOK file=@fns.gsub(/\.ssm(?:\.sst)?/,'.ssm.sst') "#{source_file_path}/#{file}" end + def texpdf_hyperlinks(cli) + @cli=cli + @hyplnks=if cli != :na + cli + elsif (defined? @rc['default']['pdf_hyperlinks']) \ + && (@rc['default']['pdf_hyperlinks']=~/color/) + :color + elsif (defined? @rc['default']['pdf_hyperlinks']) \ + && (@rc['default']['pdf_hyperlinks']=~/(?:no-color|color-off|mono(?:chrome)?)/) + :mono + else :na + end + def landscape + if @cli != :na + @cli + elsif (defined? @rc['default']['pdf_hyperlinks_landscape']) \ + && (@rc['default']['pdf_hyperlinks_landscape']=~/color/) + :color + elsif (defined? @rc['default']['pdf_hyperlinks_landscape']) \ + && (@rc['default']['pdf_hyperlinks_landscape']=~/(?:no-color|color-off|mono(?:chrome)?)/) + :mono + elsif @hyplnks != :na + @hyplnks + else :na + end + end + def portrait + if @cli != :na + @cli + elsif (defined? @rc['default']['pdf_hyperlinks_portrait']) \ + && (@rc['default']['pdf_hyperlinks_portrait']=~/color/) + :color + elsif (defined? @rc['default']['pdf_hyperlinks_portrait']) \ + && (@rc['default']['pdf_hyperlinks_portrait']=~/(?:no-color|color-off|mono(?:chrome)?)/) + :mono + elsif @hyplnks != :na + @hyprlnks + else :na + end + end + self + end def font + def size(pt=nil) + if pt && pt != :na + pt + elsif defined? @rc['default']['fontsize'] \ + && @rc['default']['fontsize']=~/\d{1,2}/ + @rc['default']['fontsize'] + else :na + end + end def texpdf # you may wish to check selected font against available fonts: # fc-list :outline -f "%{family}\n" # fc-list :lang=ja def main - (defined? @rc['default']['texpdf_font']) \ - && (@rc['default']['texpdf_font']=~/\S{3,}/) \ - ? @rc['default']['texpdf_font'] + (defined? @rc['default']['texpdf_fontface']) \ + && (@rc['default']['texpdf_fontface']=~/\S{3,}/) \ + ? @rc['default']['texpdf_fontface'] : 'Liberation Sans' end def sans # not used - (defined? @rc['default']['texpdf_font_sans']) \ - && (@rc['default']['texpdf_font_sans']=~/\S{3,}/) \ - ? @rc['default']['texpdf_font_sans'] + (defined? @rc['default']['texpdf_fontface_sans']) \ + && (@rc['default']['texpdf_fontface_sans']=~/\S{3,}/) \ + ? @rc['default']['texpdf_fontface_sans'] : 'Liberation Sans' end def serif # not used - (defined? @rc['default']['texpdf_font_serif']) \ + (defined? @rc['default']['texpdf_fontface_serif']) \ && (@rc['default']['texpdf_font_serif']=~/\S{3,}/) \ - ? @rc['default']['texpdf_font_serif'] + ? @rc['default']['texpdf_fontface_serif'] : 'Liberation Serif' end def mono - (defined? @rc['default']['texpdf_font_mono']) \ - && (@rc['default']['texpdf_font_mono']=~/\S{3,}/) \ - ? @rc['default']['texpdf_font_mono'] + (defined? @rc['default']['texpdf_fontface_mono']) \ + && (@rc['default']['texpdf_fontface_mono']=~/\S{3,}/) \ + ? @rc['default']['texpdf_fontface_mono'] : 'Liberation Mono' end def cjk - (defined? @rc['default']['texpdf_font_cjk']) \ - && (@rc['default']['texpdf_font_cjk']=~/\S{3,}/) \ - ? @rc['default']['texpdf_font_cjk'] + (defined? @rc['default']['texpdf_fontface_cjk']) \ + && (@rc['default']['texpdf_fontface_cjk']=~/\S{3,}/) \ + ? @rc['default']['texpdf_fontface_cjk'] : 'IPAGothic' # 'IPAGothic' # 'IPAMincho' # 'TakaoMincho' # 'VL Gothic' end def cjk_zh - (defined? @rc['default']['texpdf_font_cjk_zh']) \ - && (@rc['default']['texpdf_font_cjk_zh']=~/\S{3,}/) \ - ? @rc['default']['texpdf_font_cjk_zh'] + (defined? @rc['default']['texpdf_fontface_cjk_zh']) \ + && (@rc['default']['texpdf_fontface_cjk_zh']=~/\S{3,}/) \ + ? @rc['default']['texpdf_fontface_cjk_zh'] : 'IPAGothic' end def cjk_ja - (defined? @rc['default']['texpdf_font_cjk_ja']) \ - && (@rc['default']['texpdf_font_cjk_ja']=~/\S{3,}/) \ - ? @rc['default']['texpdf_font_cjk_ja'] + (defined? @rc['default']['texpdf_fontface_cjk_ja']) \ + && (@rc['default']['texpdf_fontface_cjk_ja']=~/\S{3,}/) \ + ? @rc['default']['texpdf_fontface_cjk_ja'] : 'IPAGothic' end def cjk_ko - (defined? @rc['default']['texpdf_font_cjk_ko']) \ - && (@rc['default']['texpdf_font_cjk_ko']=~/\S{3,}/) \ - ? @rc['default']['texpdf_font_cjk_ko'] + (defined? @rc['default']['texpdf_fontface_cjk_ko']) \ + && (@rc['default']['texpdf_fontface_cjk_ko']=~/\S{3,}/) \ + ? @rc['default']['texpdf_fontface_cjk_ko'] : 'IPAGothic' end + def size(pt=nil) + if pt && pt != :na + pt + elsif (defined? @rc['default']['texpdf_fontsize']) \ + && (@rc['default']['texpdf_fontsize']=~/\d{1,2}/) + @rc['default']['texpdf_fontsize'] + elsif (defined? @rc['default']['fontsize']) \ + && (@rc['default']['fontsize']=~/\d{1,2}/) + @rc['default']['fontsize'] + else + :na + end + end self end self @@ -2519,6 +2598,7 @@ WOK end end http=http.strip + #%q{http://#{ENV['HTTP_HOST']}} end def webrick #must have a port #REMOVE if defined? @rc['webserv_cgi']['host'] \ @@ -2581,6 +2661,7 @@ WOK else webserv_base_cgi(opt) end end + #%q{http://#{ENV['HTTP_HOST']}/cgi-bin} end def cgi_sample_search_form_name(opt=nil) if opt.mod.inspect =~/--(?:cgi-)?search-form-name[=-]["']?(\S+?\.cgi)/ @@ -2713,27 +2794,41 @@ WOK end self end - def digest + def digest_conf? + if defined? @rc['default']['digest'] \ + and @rc['default']['digest'] != nil + case @rc['default']['digest'] + when /^sha(?:5|512)?$/ then :sha512 + when /^sha(?:2|256)?$/ then :sha256 + when /^md5$/ then :md5 + else :sha256 + end + else :sha256 + end + end + def digest(opt=nil) + @opt=opt def type - if defined? @rc['default']['digest'] \ - and @rc['default']['digest'] != nil - case @rc['default']['digest'] - when /^sha(?:2|256)?$/ then 'sha256' - when /^md5$/ then 'md5' - else 'sha256' + if @opt + case @opt.act[:hash_digest_algo] + when :sha512 then :sha512 + when :sha256 then :sha256 + when :md5 then :md5 + else digest_conf? end - else 'sha256' + else digest_conf? end end def length - case digest.type - when /sha256/ then 64 - when /md5/ then 32 + case digest(@opt).type + when :sha512 then 128 + when :sha256 then 64 + when :md5 then 32 else 64 end end def pattern - "[0-9a-f]{#{digest.length}}" #/[0-9a-f]{#{digest.length}}/ + "[0-9a-f]{#{digest(@opt).length}}" #/[0-9a-f]{#{digest.length}}/ end self end @@ -4335,6 +4430,9 @@ WOK : '' end def dbi + PG::Connection.open(:dbname => psql.db) + end + def dbi_ (psql.host =~/(?:\S{1,3}\.){3}\S{1,3}|\S+?\.\S+/) \ ? "DBI:Pg:database=#{psql.db};host=#{psql.host};port=#{psql.port}" : "DBI:Pg:database=#{psql.db};port=#{psql.port}" @@ -4342,19 +4440,11 @@ WOK def conn_dbi DBI.connect(psql.dbi,psql.user,psql.db) end - self - end - def mysql - def db - #"#{Db[:name_prefix]}#{@pwd_stub}" - end - def port - '**' + def conn_pg + require 'pg' + PG::Connection.new(dbname: psql.db, port: psql.port) end - def dbi - "dbi:Mysql:database=#{mysql.db};port=#{mysql.port}" - end - self + self end def sqlite def db -- cgit v1.2.3