aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/v3/sysenv.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sisu/v3/sysenv.rb')
-rw-r--r--lib/sisu/v3/sysenv.rb153
1 files changed, 91 insertions, 62 deletions
diff --git a/lib/sisu/v3/sysenv.rb b/lib/sisu/v3/sysenv.rb
index acc38507..b8dd37b0 100644
--- a/lib/sisu/v3/sysenv.rb
+++ b/lib/sisu/v3/sysenv.rb
@@ -264,8 +264,8 @@ module SiSU_Env
require @prog
else
@mandatory \
- ? (SiSU_Screen::Ansi.new(@cmd,"module required: #{@prog}").warn)
- : (SiSU_Screen::Ansi.new(@cmd,"#{@prog} load requested").warn)
+ ? (SiSU_Screen::Ansi.new(@cmd,"*WARN* module required: #{@prog}").warn)
+ : (SiSU_Screen::Ansi.new(@cmd,"*WARN* #{@prog} load requested").warn)
end
load_prog
end
@@ -300,7 +300,7 @@ module SiSU_Env
@yamlrc_path.each do |v|
if @@noyaml \
or FileTest.exist?("#{v}/noyaml")
- puts "WARNING - YAML loading switched off, to enable delete the file:\n\t#{v}/noyaml\n\n" unless @@noyaml
+ STDERR.puts "WARNING - YAML loading switched off, to enable delete the file:\n\t#{v}/noyaml\n\n" unless @@noyaml
@@noyaml=true
break
else
@@ -657,7 +657,7 @@ module SiSU_Env
program='rcs'
program_ref="\n\t\tdocument version information requested"
if program_found?(program); true
- else puts "\tWARN: #{program} is not installed #{program_ref}" #if @cmd =~/v/
+ else STDERR.puts "\t*WARN* #{program} is not installed #{program_ref}" #if @cmd =~/v/
false
end
end
@@ -665,7 +665,7 @@ module SiSU_Env
program='cvs'
program_ref="\n\t\tdocument version information requested"
if program_found?(program); true
- else puts "\tWARN: #{program} is not installed #{program_ref}" #if @cmd =~/v/
+ else STDERR.puts "\t*WARN* #{program} is not installed #{program_ref}" #if @cmd =~/v/
false
end
end
@@ -673,7 +673,7 @@ module SiSU_Env
program='openssl'
program_ref="\n\t\tused to generate requested source document identification digest"
if program_found?(program); true
- else puts "\tWARN: #{program} is not installed #{program_ref}" #if @cmd =~/v/
+ else STDERR.puts "\t*WARN* #{program} is not installed #{program_ref}" #if @cmd =~/v/
false
end
end
@@ -686,7 +686,7 @@ module SiSU_Env
dgst=%x{openssl dgst -md5 #{File.basename(filename)}}.strip #use file name without file path
Dir.chdir(pwd)
dgst.scan(/\S+/)
- else puts "\tWARN: #{program} is not installed #{program_ref}" #if @cmd =~/v/
+ else STDERR.puts "\t*WARN* #{program} is not installed #{program_ref}" #if @cmd =~/v/
false
end
end
@@ -699,7 +699,7 @@ module SiSU_Env
dgst=%x{openssl dgst -sha256 #{File.basename(filename)}}.strip #use file name without file path
Dir.chdir(pwd)
dgst.scan(/\S+/)
- else puts "\tWARN: #{program} is not installed #{program_ref}" #if @cmd =~/v/
+ else STDERR.puts "\t*WARN* #{program} is not installed #{program_ref}" #if @cmd =~/v/
false
end
end
@@ -707,7 +707,7 @@ module SiSU_Env
program='psql'
program_ref="\n\t\tpsql requested"
if program_found?(program); true
- else puts "\tWARN: #{program} is not installed #{program_ref}" #if @cmd =~/v/
+ else STDERR.puts "\t*WARN* #{program} is not installed #{program_ref}" #if @cmd =~/v/
false
end
end
@@ -722,14 +722,14 @@ module SiSU_Env
program_ref="\n\t\tcreatedb dbname #{db_name} #for postgresql database creation"
(program_found?(program)) \
? system("#{program} #{dbname_name}")
- : (puts "\tWARN: #{program} is not available #{program_ref}")
+ : (STDERR.puts "\t*WARN* #{program} is not available #{program_ref}")
end
def relaxng(cmd='') #trang - convert between different schema languages for XML
program='trang'
program_ref="\n\t\tsee <http://www.thaiopensource.com/relaxng/trang.html>"
(program_found?(program)) \
? system("#{program} #{@input} #{@output}")
- : (puts "\tWARN: #{program} is not installed #{program_ref}" if cmd =~/V/)
+ : (STDERR.puts "\t*WARN* #{program} is not installed #{program_ref}" if cmd =~/V/)
end
def qrencode #qrcode - for generating QR code
program='qrencode'
@@ -739,21 +739,21 @@ module SiSU_Env
? (system(%{
echo "#{@input}" | #{program} -s 3 -o #{@output}
}))
- : (puts "\tWARN: #{program} is not installed #{program_ref}" if cmd =~/V/)
+ : (STDERR.puts "\t*WARN* #{program} is not installed #{program_ref}" if cmd =~/V/)
#found
end
def imagemagick #imagemagick is a image manipulation program
program='identify'
program_ref="\n\t\tsee <http://www.imagemagick.org/>"
found=(program_found?(program)) ? true : false
- puts "\tWARN: #{program} is not installed #{program_ref}" unless found
+ STDERR.puts "\t*WARN* #{program} is not installed #{program_ref}" unless found
found
end
def graphicksmagick #graphicsmagick is a image manipulation program
program='gm'
program_ref="\n\t\tsee <http://www.graphicsmagick.org/>"
found=(program_found?(program)) ? true : false
- puts "\tWARN: #{program} is not installed #{program_ref}" unless found
+ STDERR.puts "\t*WARN* #{program} is not installed #{program_ref}" unless found
found
end
def well_formed? #tidy - check for well formed xml xhtml etc.
@@ -761,7 +761,7 @@ module SiSU_Env
program_ref="\n\t\tsee <http://tidy.sourceforge.net/>"
(program_found?(program)) \
? system("#{@prog.tidy} -xml #{@input} > #{@output}")
- : (puts "\tWARN: #{program} is not installed #{program_ref}")
+ : (STDERR.puts "\t*WARN* #{program} is not installed #{program_ref}")
end
def tex2pdf_engine
prog=['xetex','xelatex','pdflatex','pdfetex','pdftex']
@@ -799,7 +799,7 @@ module SiSU_Env
when /pdflatex/; "#{texpdf} -interaction=#{mode} #{@input} #{tell}\n"
end
system(texpdf_cmd)
- else puts "\tWARN: none of the following programs are installed: #{program[0]}, #{program[1]}, #{program[2]} is installed. #{program_ref}"
+ else STDERR.puts "\t*WARN* none of the following programs are installed: #{program[0]}, #{program[1]}, #{program[2]} is installed. #{program_ref}"
end
end
def makeinfo #texinfo
@@ -808,7 +808,7 @@ module SiSU_Env
program_ref="\n\t\tsee http://www.gnu.org/software/texinfo/"
(program_found?(program)) \
? system("#{program} #{options} #{@input}\n")
- : (puts "\tWARN: #{program} is not installed #{program_ref}")
+ : (STDERR.puts "\t*WARN* #{program} is not installed #{program_ref}")
end
def scp
program='scp'
@@ -816,7 +816,7 @@ module SiSU_Env
puts "scp disabled"
#(program_found?(program)) \
#? system("scp -Cr #{@input} #{@output}") \
- #: (puts "\tWARN: #{program} not found" )
+ #: (STDERR.puts "\t*WARN* #{program} not found" )
end
def rsync(action='',chdir=nil)
program='rsync'
@@ -840,7 +840,7 @@ module SiSU_Env
#{rsync_cmd} #{msg}
")
dir_return
- else puts "\tWARN: #{program} not found"
+ else STDERR.puts "\t*WARN* #{program} not found"
end
end
def rm
@@ -848,7 +848,7 @@ module SiSU_Env
elsif @cmd =~/V/; FileUtils::rm(@input)
elsif @cmd !~/q/; FileUtils::rm(@input)
elsif @cmd =~/q/; FileUtils::rm(@input)
- else puts "\tWARN: operation ignored"
+ else STDERR.puts "\t*WARN* operation ignored"
end
end
end
@@ -2141,7 +2141,10 @@ WOK
src="#{path.share}/image"
images=%W[bullet_09.png arrow_next_red.png arrow_prev_red.png arrow_up_red.png]
images.each do |i| #move to avoid repeated tests
- FileUtils::cp("#{src}/#{i}","#{pth}/#{i}") unless FileTest.file?("#{pth}/#{i}")
+ if FileTest.file?("#{src}/#{i}")
+ FileUtils::cp("#{src}/#{i}","#{pth}/#{i}") unless FileTest.file?("#{pth}/#{i}")
+ else STDERR.puts %{\t*WARN* did not find image - "#{i}" [#{__FILE__}:#{__LINE__}]}
+ end
end
pth
end
@@ -2694,7 +2697,7 @@ WOK
end
#system(tree) #enable if (/[vVM]/)
else
- SiSU_Screen::Ansi.new('',"file not found: #{fns_pod}").warn unless @cmd=~/q/
+ SiSU_Screen::Ansi.new('',"*WARN* file not found: #{fns_pod}").warn unless @cmd=~/q/
end
sisupod_processing_path
end
@@ -2710,7 +2713,7 @@ WOK
end
(FileTest.file?(fns_pod)) \
? system("unzip -q #{fns_pod} -d #{processing_path.processing}")
- : (SiSU_Screen::Ansi.new('',"file not found: #{fns_pod}").warn unless @cmd=~/q/)
+ : (SiSU_Screen::Ansi.new('',"*WARN* file not found: #{fns_pod}").warn unless @cmd=~/q/)
sisupod_processing_path
end
end
@@ -3401,28 +3404,6 @@ WOK
%x{ruby -v}.strip
end
end
- class CreateSystemLink #revisit problems created 2004w41
- require 'fileutils'
- include FileUtils::Verbose
- def initialize
- @env=SiSU_Env::InfoEnv.new
- end
- def images
- unless FileTest.directory?("#{@env.path.output}/_sisu")
- FileUtils::mkdir_p("#{@env.path.output}/_sisu")
- end
- unless File.exist?("#{@env.path.output}/_sisu/image_sys") \
- or File.symlink?("#{@env.path.output}/_sisu/image_sys")
- File.symlink("../../_sisu/image_sys", "#{@env.path.output}/_sisu/image_sys")
- end
- end
- def man_forms
- #File.symlink("../../man/form", "#{@env.path.output}/man/form") unless File.symlink?("#{@env.path.output}/man/form")==true
- end
- def man_pdf
- #File.symlink("../../man/form", "#{@env.path.output}/man/pdf") unless File.symlink?("#{@env.path.output}/man/pdf")==true
- end
- end
class InfoFile <InfoEnv #todo unify with FileOp
def initialize(fns)
begin
@@ -3445,12 +3426,12 @@ WOK
def make_file(path,filename)
(File.writable?("#{path}/.")) \
? File.new("#{path}/#{filename}",'w+')
- : (SiSU_Screen::Ansi.new('',"is the file or directory writable?, could not create #{filename}").warn)
+ : (SiSU_Screen::Ansi.new('',"*WARN* is the file or directory writable?, could not create #{filename}").warn)
end
def touch_file(path,filename)
if File.writable?("#{path}/.");
FileUtils::touch("#{path}/#{filename}")
- else SiSU_Screen::Ansi.new('',"is the file or directory writable?, could not create #{filename}").warn
+ else SiSU_Screen::Ansi.new('',"*WARN* is the file or directory writable?, could not create #{filename}").warn
end
end
def make_path(path)
@@ -4276,10 +4257,10 @@ WOK
self
end
def pdf_p
- puts 'ERROR not available due to multiple page format sizes'
+ STDERR.puts 'ERROR not available due to multiple page format sizes'
end
def pdf_l
- puts 'ERROR not available due to multiple page format sizes'
+ STDERR.puts 'ERROR not available due to multiple page format sizes'
end
def xhtml
def dir
@@ -5665,6 +5646,38 @@ WOK
@pwd_stub=@pwd[m,1]
@env=SiSU_Env::InfoEnv.new
end
+ def apply
+ if @md.make.skin
+ skin_path=unless @md.opt.f_pth[:pth] =~/\/\S+?\/sisupod\/\S+?\/sisupod\/doc/
+ [
+ "#{@env.path.pwd}/_sisu/skin",
+ "#{@env.path.home}/.sisu/skin",
+ '/etc/sisu/skin',
+ "#{@env.processing_path.processing_sisupod(@md.opt)}/external_document/skin"
+ ]
+ else #sisupod
+ pt=/(\/\S+?\/sisupod\/\S+?\/sisupod\/doc)/.match(@md.opt.f_pth[:pth])[1]
+ [ "#{pt}/_sisu/skin" ]
+ end
+ sk_doc,sk_dir="doc/#{@md.make.skin}.rb","dir/skin_#{@env.stub_pwd}.rb"
+ skin_path.each do |v| #document skin priority 1
+ if FileTest.file?("#{v}/#{sk_doc}")
+ @skin_apply={ name: @md.make.skin, name_path: "#{v}/#{sk_doc}", type: :doc }
+ break
+ end
+ end
+ unless @skin_apply.length > 0
+ skin_path.each do |v| #directory skin priority 2
+ if FileTest.file?("#{v}/#{sk_dir}")
+ @skin_apply={ name: "skin_#{@env.stub_pwd}.rb", name_path: "#{v}/#{sk_dir}", type: :dir }
+ break
+ end
+ end
+ end
+ else nil
+ end
+ @skin_apply
+ end
def select # skin loading logic here
load "#{SiSU_lib}/defaults.rb"
skin_path=[]
@@ -5882,57 +5895,73 @@ WOK
FileUtils::mkdir_p(dest_path) unless FileTest.directory?(dest_path)
FileUtils::chmod(0755,dest_path)
source.each do |i|
- FileUtils::cp_r(i,"#{dest_path}/#{i}")
- FileUtils::chmod(0644,"#{dest_path}/#{i}")
+ if FileTest.file?(i)
+ FileUtils::cp(i,"#{dest_path}/#{i}")
+ FileUtils::chmod(0644,"#{dest_path}/#{i}")
+ else STDERR.puts %{\t*WARN* did not find image - "#{i}" [#{__FILE__}:#{__LINE__}]}
+ end
end
FileUtils::cd(@pwd)
- else puts "\tWARN, did not find - #{src_path}"
+ else STDERR.puts %{\t*WARN* did not find - #{src_path} [#{__FILE__}:#{__LINE__}]}
end
end
def cp_local_images
src="#{@pwd}/_sisu/image"
dest="#{@env.path.webserv}/#{@env.path.stub_pwd}/_sisu/image"
- cp_images(src,dest)
+ cp_images(src,dest) if FileTest.directory?(src)
end
def cp_external_images
src="#{@env.processing_path.processing}/external_document/image"
dest="#{@env.path.webserv}/#{@env.path.stub_pwd}/_sisu/image_external"
if FileTest.directory?(src)
- cp_images(src,dest)
+ cp_images(src,dest) if FileTest.directory?(src)
end
end
def cp_webserver_images
src=@env.path.image_source
- dest="#{@env.path.webserv}/_sisu/image"
- cp_images(src,dest)
+ dest_arr=[
+ "#{@env.path.webserv}/_sisu/image",
+ "#{@env.path.webserv}/#{@env.path.stub_pwd}/_sisu/image"
+ ]
+ dest_arr.each do |dest|
+ cp_images(src,dest) if FileTest.directory?(src)
+ end
end
def cp_webserver_images_local #this should not have been necessary
src=@env.path.image_source
dest="#{@env.path.webserv}/#{@env.path.stub_pwd}/_sisu/image"
- cp_images(src,dest)
+ cp_images(src,dest) if FileTest.directory?(src)
end
def cp_base_images #fix images
src="#{@env.path.share}/image"
- dest="#{@env.path.webserv}/_sisu/image_sys"
- cp_images(src,dest)
+ dest_arr=[
+ "#{@env.path.webserv}/_sisu/image_sys",
+ "#{@env.path.webserv}/#{@env.path.stub_pwd}/_sisu/image_sys"
+ ]
+ dest_arr.each do |dest|
+ cp_images(src,dest) if FileTest.directory?(src)
+ end
end
def cp_css
FileUtils::mkdir_p("#{@env.path.output}/#{@env.path.style}") unless FileTest.directory?("#{@env.path.output}/#{@env.path.style}")
css_path=['/etc/sisu/css',"#{@home}/.sisu/css","#{@pwd}/_sisu/css"] #BROKEN
if defined? @rc['permission_set']['css_modify'] \
and @rc['permission_set']['css_modify']
- SiSU_Screen::Ansi.new(@cmd,"modify is css set to: #{@rc['permission_set']['css_modify']}").warn if @cmd=~/[MV]/
+ SiSU_Screen::Ansi.new(@cmd,"*WARN* modify is css set to: #{@rc['permission_set']['css_modify']}").warn if @cmd=~/[MV]/
css_path.each do |x|
if FileTest.directory?(x)
FileUtils::cd(x)
source=Dir.glob("*.{css}")
source.each do |i|
- FileUtils::cp(i,"#{@env.path.output}/#{@env.path.style}")
+ if FileTest.file?(i)
+ FileUtils::cp(i,"#{@env.path.output}/#{@env.path.style}")
+ else STDERR.puts %{\t*WARN* did not find css - "#{i}" [#{__FILE__}:#{__LINE__}]}
+ end
end
FileUtils::cd(@pwd)
end
end
- else SiSU_Screen::Ansi.new(@cmd,"modify css is not set or is set to: false").warn if @cmd=~/[MV]/
+ else SiSU_Screen::Ansi.new(@cmd,"*WARN* modify css is not set or is set to: false").warn if @cmd=~/[MV]/
end
fn_css=SiSU_Env::CSS_Default.new
css=SiSU_Style::CSS.new