diff options
author | Ralph Amissah <ralph@amissah.com> | 2014-07-15 18:33:07 -0400 |
---|---|---|
committer | Ralph Amissah <ralph@amissah.com> | 2014-07-15 18:33:07 -0400 |
commit | 639c57ebfba5b860d788218f19622fb52533806f (patch) | |
tree | 8d6c4cfa198d4646174b5451f13f81f064d9a059 /lib/sisu/v6/sysenv.rb | |
parent | v5 v6: bin/sisu, hub, options, pass message: sisu_called_from_directory (diff) |
v5 v6: sysenv, general, base_markup_dir_stub (replace pwd_stub)
Diffstat (limited to 'lib/sisu/v6/sysenv.rb')
-rw-r--r-- | lib/sisu/v6/sysenv.rb | 140 |
1 files changed, 70 insertions, 70 deletions
diff --git a/lib/sisu/v6/sysenv.rb b/lib/sisu/v6/sysenv.rb index 3c774c46..ec4dbb9e 100644 --- a/lib/sisu/v6/sysenv.rb +++ b/lib/sisu/v6/sysenv.rb @@ -116,13 +116,13 @@ module SiSU_Env share=Config::CONFIG['datadir'] + '/sisu' data=Config::CONFIG['datadir'] + '/doc/sisu' m=/.+\/(?:src\/)?(\S+)/m # m=/.+?\/(?:src\/)?([^\/]+)$/im # m=/.+\/(\S+)/m - @stub_pwd ||=@@pwd[m,1] + @base_markup_dir_stub=SiSU_Utils::Path.new.base_markup_stub prcss_dir='_sisu_processing_' + '.' + SiSU_is[:version_dir] prcss_dir_tmp_root="/tmp/#{prcss_dir}" - prcss_dir_stub="#{prcss_dir}/#{@stub_pwd}" + prcss_dir_stub="#{prcss_dir}/#{@base_markup_dir_stub}" if @@user - tmp_processing="#{prcss_dir_tmp_root}/#{@@user}/#{@stub_pwd}" - tmp_processing_individual="#{prcss_dir_tmp_root}/#{@@user}/#{@stub_pwd}" + tmp_processing="#{prcss_dir_tmp_root}/#{@@user}/#{@base_markup_dir_stub}" + tmp_processing_individual="#{prcss_dir_tmp_root}/#{@@user}/#{@base_markup_dir_stub}" else #error tmp_processing=tmp_processing_individual="/tmp/#{prcss_dir_stub}" end @@ -1096,7 +1096,7 @@ module SiSU_Env rescue LoadError SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('pathname or fileutils NOT FOUND (LoadError)') end - 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 + attr_accessor :filename,:sys,:home,:hostname,:user,:env,:rc,:www,:fnb,:fnn,:fnt,:flv,:webserv_path,:base_markup_dir_stub,: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 def initialize(fns='',md=nil) @@ -1121,11 +1121,10 @@ module SiSU_Env @fnb ||=@@fb #clean up this... used primarily for zap which is not passed normal parameters @fixed_websev_root='' # @home @pwd=@@pwd=Dir.pwd - m=/.+\/(?:src\/)?(\S+)/m # m=/.+?\/(?:src\/)?([^\/]+)$/im # m=/.+\/(\S+)/m - @stub_pwd=@@pwd[m,1] || '' #; p __LINE__; #p @pwd; #p m; #p @stub_pwd - @stub_src= @stub_pwd + '/src' - @stub_pod= @stub_pwd + '/pod' - @stub_epub= @stub_pwd + '/epub' + @base_markup_dir_stub=SiSU_Utils::Path.new.base_markup_stub + @stub_src= @base_markup_dir_stub + '/src' + @stub_pod= @base_markup_dir_stub + '/pod' + @stub_epub= @base_markup_dir_stub + '/epub' pt=Pathname.new(Dir.pwd) stub=if output_dir_structure.by_language_code? r=Px[:lng_lst_rgx] @@ -1206,8 +1205,8 @@ module SiSU_Env @@current_document||=Dir.pwd @@current_document end - def stub_pwd #200412 - @stub_pwd + def base_markup_dir_stub #200412 + @base_markup_dir_stub end def stub_md_harvest #watch @stub_set_manifest @@ -2062,8 +2061,8 @@ WOK def pwd @sys.pwd end - def stub_pwd - @stub_pwd + def base_markup_dir_stub + @base_markup_dir_stub end def stub_epub @stub_epub @@ -2149,10 +2148,11 @@ WOK end def webserv_stub_ensure FileUtils::mkdir_p(path.webserv) unless FileTest.directory?(path.webserv) - FileUtils::mkdir_p("#{path.webserv}/#{@stub_pwd}") unless FileTest.directory?("#{path.webserv}/#{@stub_pwd}") + FileUtils::mkdir_p("#{path.webserv}/#{@base_markup_dir_stub}") \ + unless FileTest.directory?("#{path.webserv}/#{@base_markup_dir_stub}") end def webserv_map_pwd #dir - "#{path.webserv}/#{stub_pwd}" + "#{path.webserv}/#{base_markup_dir_stub}" end def webserv_dir #fixed/hard path to /www web/presentation directory, on Debian /var/www subdirectories are created within it, depending on markup directory stub-name (last segment of markup directory name) defaults[:webserv_dir] @@ -2288,13 +2288,13 @@ WOK end def stub_dir (usr_dir?) \ - ? ("#{root_dir}/#{user}/#{stub_pwd}") - : ("#{root_dir}/#{stub_pwd}") # see defaults[:processing_path] + ? ("#{root_dir}/#{user}/#{base_markup_dir_stub}") + : ("#{root_dir}/#{base_markup_dir_stub}") # see defaults[:processing_path] end def stub_dir_orig # ends up with lang, if lang dir (usr_dir?) \ - ? ("#{root_dir}/#{user}/#{stub_pwd}") - : ("#{root_dir}/#{stub_pwd}") # see defaults[:processing_path] + ? ("#{root_dir}/#{user}/#{base_markup_dir_stub}") + : ("#{root_dir}/#{base_markup_dir_stub}") # see defaults[:processing_path] end def processing_sisupod(opt=nil) #processing directory, used/needed for sisu work files, has sub-directories (ao,tex etc) @opt=opt @@ -2504,21 +2504,21 @@ WOK "http://#{@sys.hostname}" end def dir_url - "file://#{path.webserv}/#{stub_pwd}" + "file://#{path.webserv}/#{base_markup_dir_stub}" end def localhost - "http://localhost/#{stub_pwd}" + "http://localhost/#{base_markup_dir_stub}" end def local - "http://#{hostname}/#{@stub_pwd}" + "http://#{hostname}/#{@base_markup_dir_stub}" end def root if defined? @rc['webserv']['url_root'] \ and @rc['webserv']['url_root'] =~/https?:\/\// - "#{@rc['webserv']['url_root']}/#{@stub_pwd}" + "#{@rc['webserv']['url_root']}/#{@base_markup_dir_stub}" elsif defined? @rc['webserv']['url_root'] \ and @rc['webserv']['url_root'] =~/localhost/ - "http://localhost/#{@stub_pwd}" + "http://localhost/#{@base_markup_dir_stub}" else "file://#{path.output}" end end @@ -2567,14 +2567,14 @@ WOK and @rc['webserv_cgi']['host'].is_a?(String) http=((@rc['webserv_cgi']['host'] =~ /https?:\/\//) ? '' : 'http://') #check https? missing if port.webserv_port_cgi - "#{http}#{@rc['webserv_cgi']['host']}:#{port.webserv_port_cgi}/#{@stub_pwd}" - else "#{http}#{@rc['webserv_cgi']['host']}/#{@stub_pwd}" + "#{http}#{@rc['webserv_cgi']['host']}:#{port.webserv_port_cgi}/#{@base_markup_dir_stub}" + else "#{http}#{@rc['webserv_cgi']['host']}/#{@base_markup_dir_stub}" end else http=((webserv_host_base=~/https?:\/\//) ? '' : 'http://') if port.webserv_port_cgi(opt) - "#{http}#{webserv_host_base}:#{port.webserv_port_cgi(opt)}/#{@stub_pwd}" - else "#{http}#{webserv_host_base}/#{@stub_pwd}" + "#{http}#{webserv_host_base}:#{port.webserv_port_cgi(opt)}/#{@base_markup_dir_stub}" + else "#{http}#{webserv_host_base}/#{@base_markup_dir_stub}" end end http=http.strip @@ -2622,7 +2622,7 @@ WOK @rc['webserv']['url_root'] elsif path.webserv_dir \ and path.webserv =~ /#{path.webserv_dir}/ #revisit - "#{path.webserv}/#{@stub_pwd}".gsub(/#{path.webserv_dir}/,"#{url.hostname}/#{@stub_pwd}") + "#{path.webserv}/#{@base_markup_dir_stub}".gsub(/#{path.webserv_dir}/,"#{url.hostname}/#{@base_markup_dir_stub}") elsif defined? @rc['webserv']['webrick_url'] \ and @rc['webserv']['webrick_url']==false "file://#{path.webserv}" @@ -2635,7 +2635,7 @@ WOK def webserv_base #web url for local webserv (localhost, or hostname) if path.webserv_dir \ and path.webserv =~ /#{path.webserv_dir}/ #revisit - "#{path.webserv}/#{@stub_pwd}".gsub(/#{path.webserv_dir}/,"#{url.hostname}") + "#{path.webserv}/#{@base_markup_dir_stub}".gsub(/#{path.webserv_dir}/,"#{url.hostname}") elsif defined? @rc['webserv']['webrick_url'] \ and @rc['webserv']['webrick_url']==false "file://#{path.webserv}" @@ -2696,8 +2696,8 @@ WOK when /^filesystem(?:_url)?/ then url.dir_url when /^remote(?:_webserv)?/ then url.remote when /^(?:webserv|local_webserv)/ then url.local - when /^local(:\d+)/ then url.hostname + $1 + '/' + stub_pwd - when /^localhost(:\d+)/ then url.localhost + $1 + '/' + stub_pwd + when /^local(:\d+)/ then url.hostname + $1 + '/' + base_markup_dir_stub + when /^localhost(:\d+)/ then url.localhost + $1 + '/' + base_markup_dir_stub when /^localhost/ then url.localhost when /^webrick/ then url.webrick when /^path/ then url.webserv_map_pwd @@ -2726,7 +2726,7 @@ WOK if FileTest.directory?(image_external) if @@image_flag images=Dir.glob("#{image_external}/*.{png,jpg,gif}") - pth="#{path.webserv}/#{@stub_pwd}" + pth="#{path.webserv}/#{@base_markup_dir_stub}" FileUtils::mkdir_p("#{pth}/_sisu/image_external") unless FileTest.directory?("#{pth}/_sisu/image_external") images.each { |i| File.install(i,"#{pth}/#{i}") } unless images.length > 0 @@image_flag=false @@ -3497,9 +3497,9 @@ WOK self.remote_host_base.each do |remote_conn| local_gen=@source_path remote_gen=case @opt.cmd - when /u/ then "#{remote_conn[:name]}/#{@env.path.stub_pwd}/." #creates remote directory tree, this is not the usual function of u - when /[abhHNopwxXy]/ then "#{remote_conn[:name]}/#{@env.path.stub_pwd}/#{@fnb}/." - else "#{remote_conn[:name]}/#{@env.path.stub_pwd}/." + when /u/ then "#{remote_conn[:name]}/#{@env.path.base_markup_dir_stub}/." #creates remote directory tree, this is not the usual function of u + when /[abhHNopwxXy]/ then "#{remote_conn[:name]}/#{@env.path.base_markup_dir_stub}/#{@fnb}/." + else "#{remote_conn[:name]}/#{@env.path.base_markup_dir_stub}/." end local_epub=@source_path_epub local_src=@source_path_src @@ -3544,7 +3544,7 @@ WOK def site_base #base site self.remote_host_base.each do |remote_conn| local=@source_path - remote="#{remote_conn[:name]}/#{@env.path.stub_pwd}/." + remote="#{remote_conn[:name]}/#{@env.path.base_markup_dir_stub}/." if defined? @rc['permission_set']['remote_base_site'] \ and @rc['permission_set']['remote_base_site'] \ and @@flag_remote==true \ @@ -3562,7 +3562,7 @@ WOK def site_base_all #base site self.remote_host_base.each do |remote_conn| local=@source_path - remote="#{remote_conn[:name]}/#{@env.path.stub_pwd}/." + remote="#{remote_conn[:name]}/#{@env.path.base_markup_dir_stub}/." if defined? @rc['permission_set']['remote_base_site'] \ and @rc['permission_set']['remote_base_site'] \ and @@flag_remote==true \ @@ -3591,9 +3591,9 @@ WOK if f self.remote_host_base.each do |remote_conn| local_gen=@source_path - #local_gen_image="#{@env.path.webserv}/#{@env.path.stub_pwd}/_sisu/image" - #local_gen_image_external="#{@env.path.webserv}/#{@env.path.stub_pwd}/_sisu/image_external" - remote_gen="#{remote_conn[:name]}/#{@env.path.stub_pwd}/." + #local_gen_image="#{@env.path.webserv}/#{@env.path.base_markup_dir_stub}/_sisu/image" + #local_gen_image_external="#{@env.path.webserv}/#{@env.path.base_markup_dir_stub}/_sisu/image_external" + remote_gen="#{remote_conn[:name]}/#{@env.path.base_markup_dir_stub}/." remote_rel=remote_conn[:name] + '/' + f.output_path.stub.rcp @opt.fnc if (local_gen =~/\S/ \ @@ -3748,7 +3748,7 @@ WOK def site_harvest self.remote_host_base.each do |remote_conn| local=@source_path_harvest - l_rel="#{@env.path.webserv}/#{@env.path.stub_pwd}" + l_rel="#{@env.path.webserv}/#{@env.path.base_markup_dir_stub}" lng='en' if @env.output_dir_structure.by? == :language ldest="#{lng}/manifest" @@ -3774,10 +3774,10 @@ WOK end def site_base #base site ldest='_sisu/*' - l_rel="#{@env.path.webserv}/#{@env.path.stub_pwd}" + l_rel="#{@env.path.webserv}/#{@env.path.base_markup_dir_stub}" image_sys="#{@env.path.webserv}/_sisu/image_sys" self.remote_host_base.each do |remote_conn| - remote="#{remote_conn[:name]}/#{@env.path.stub_pwd}" + remote="#{remote_conn[:name]}/#{@env.path.base_markup_dir_stub}" remote_conf="#{remote_conn[:name]}/_sisu" SiSU_Env::SystemCall.new(image_sys,remote_conf).rsync SiSU_Env::SystemCall.new(ldest,remote).rsync('--relative',l_rel) @@ -3786,7 +3786,7 @@ WOK def site_base_sync self.remote_host_base.each do |remote_conn| local=@source_path - remote="#{remote_conn[:name]}/#{@env.path.stub_pwd}/." + remote="#{remote_conn[:name]}/#{@env.path.base_markup_dir_stub}/." if defined? @rc['permission_set']['remote_base_site'] \ and @rc['permission_set']['remote_base_site'] \ and @@flag_remote==true \ @@ -3811,7 +3811,7 @@ WOK def rsync_sitemaps #sitemap directory self.remote_host_base.each do |remote_conn| local="#{@source_path}/sitemapindex.xml" - remote="#{remote_conn[:name]}/#{@env.path.stub_pwd}/." + remote="#{remote_conn[:name]}/#{@env.path.base_markup_dir_stub}/." if @@flag_remote delete_extra_files='--delete' # '--delete-after' SiSU_Env::SystemCall.new(local,remote).rsync(delete_extra_files) @@ -6931,8 +6931,8 @@ WOK if @md.doc_css \ and FileTest.file?("#{@env.path.output}/#{@env.path.style}/#{@md.doc_css}_html.css") "#{@md.doc_css}_html.css" - elsif FileTest.file?("#{@env.path.output}/#{@env.path.style}/#{@env.path.stub_pwd}_html.css") - "#{@env.path.stub_pwd}_html.css" + elsif FileTest.file?("#{@env.path.output}/#{@env.path.style}/#{@env.path.base_markup_dir_stub}_html.css") + "#{@env.path.base_markup_dir_stub}_html.css" else SiSU_Env::CSS_Default.new.html end @@ -6941,8 +6941,8 @@ WOK if @md.doc_css \ and FileTest.file?("#{@env.path.output}/#{@env.path.style}/#{@md.doc_css}_html_tables.css") "#{@md.doc_css}_html_tables.css" - elsif FileTest.file?("#{@env.path.output}/#{@env.path.style}/#{@env.path.stub_pwd}_html_tables.css") - "#{@env.path.stub_pwd}_html_tables.css" + elsif FileTest.file?("#{@env.path.output}/#{@env.path.style}/#{@env.path.base_markup_dir_stub}_html_tables.css") + "#{@env.path.base_markup_dir_stub}_html_tables.css" else SiSU_Env::CSS_Default.new.html_tables end end @@ -6950,8 +6950,8 @@ WOK if @md.doc_css \ and FileTest.file?("#{@env.path.output}/#{@env.path.style}/#{@md.doc_css}_xhtml.css") "#{@md.doc_css}_xhtml.css" - elsif FileTest.file?("#{@env.path.output}/#{@env.path.style}/#{@env.path.stub_pwd}_xhtml.css") - "#{@env.path.stub_pwd}_xhtml.css" + elsif FileTest.file?("#{@env.path.output}/#{@env.path.style}/#{@env.path.base_markup_dir_stub}_xhtml.css") + "#{@env.path.base_markup_dir_stub}_xhtml.css" else SiSU_Env::CSS_Default.new.xhtml end end @@ -6959,8 +6959,8 @@ WOK if @md.doc_css \ and FileTest.file?("#{@env.path.output}/#{@env.path.style}/#{@md.doc_css}_xml_sax.css") "#{@md.doc_css}_xml_sax.css" - elsif FileTest.file?("#{@env.path.output}/#{@env.path.style}/#{@env.path.stub_pwd}_xml_sax.css") - "#{@env.path.stub_pwd}_xml_sax.css" + elsif FileTest.file?("#{@env.path.output}/#{@env.path.style}/#{@env.path.base_markup_dir_stub}_xml_sax.css") + "#{@env.path.base_markup_dir_stub}_xml_sax.css" else SiSU_Env::CSS_Default.new.xml_sax end end @@ -6968,8 +6968,8 @@ WOK if @md.doc_css \ and FileTest.file?("#{@env.path.output}/#{@env.path.style}/#{@md.doc_css}_xml_dom.css") "#{@md.doc_css}_xml_dom.css" - elsif FileTest.file?("#{@env.path.output}/#{@env.path.style}/#{@env.path.stub_pwd}_xml_dom.css") - "#{@env.path.stub_pwd}_xml_dom.css" + elsif FileTest.file?("#{@env.path.output}/#{@env.path.style}/#{@env.path.base_markup_dir_stub}_xml_dom.css") + "#{@env.path.base_markup_dir_stub}_xml_dom.css" else SiSU_Env::CSS_Default.new.xml_dom end end @@ -6977,8 +6977,8 @@ WOK if @md.doc_css \ and FileTest.file?("#{@env.path.output}/#{@env.path.style}/#{@md.doc_css}_docbook.css") "#{@md.doc_css}_xml_dom.css" - elsif FileTest.file?("#{@env.path.output}/#{@env.path.style}/#{@env.path.stub_pwd}_docbook.css") - "#{@env.path.stub_pwd}_docbook.css" + elsif FileTest.file?("#{@env.path.output}/#{@env.path.style}/#{@env.path.base_markup_dir_stub}_docbook.css") + "#{@env.path.base_markup_dir_stub}_docbook.css" else SiSU_Env::CSS_Default.new.docbook_xml end end @@ -6986,8 +6986,8 @@ WOK if @md.doc_css \ and FileTest.file?("#{@env.path.output}/#{@env.path.style}/#{@md.doc_css}_homepage.css") "#{@md.doc_css}_homepage.css" - elsif FileTest.file?("#{@env.path.output}/#{@env.path.style}/#{@env.path.stub_pwd}_homepage.css") - "#{@env.path.stub_pwd}_homepage.css" + elsif FileTest.file?("#{@env.path.output}/#{@env.path.style}/#{@env.path.base_markup_dir_stub}_homepage.css") + "#{@env.path.base_markup_dir_stub}_homepage.css" else SiSU_Env::CSS_Default.new.homepage end end @@ -7047,8 +7047,8 @@ WOK puts %{ place your homepages in directory:\n "#{@env.path.rc}/home/*.html"\n (no action taken)} else puts %{ place your homepages in directory:\n "#{@env.path.rc}/home/*.html"\n (in order to replace default sisu homepage)} - filename_homepage="#{@env.path.webserv}/#{@env.path.stub_pwd}/index.html" - filename_home_toc="#{@env.path.webserv}/#{@env.path.stub_pwd}/toc.html" + filename_homepage="#{@env.path.webserv}/#{@env.path.base_markup_dir_stub}/index.html" + filename_home_toc="#{@env.path.webserv}/#{@env.path.base_markup_dir_stub}/toc.html" file_homepage=File.new(filename_homepage,'w') file_home_toc=File.new(filename_home_toc,'w') file_homepage << @vz_home.homepage @@ -7059,10 +7059,10 @@ WOK end def homepage home_pages_manually_created=Dir.glob("#{@env.path.rc}/home/*.html") - FileUtils::mkdir_p("#{@env.path.webserv}/#{@env.path.stub_pwd}") unless FileTest.directory?("#{@env.path.webserv}/#{@env.path.stub_pwd}") + FileUtils::mkdir_p("#{@env.path.webserv}/#{@env.path.base_markup_dir_stub}") unless FileTest.directory?("#{@env.path.webserv}/#{@env.path.base_markup_dir_stub}") if home_pages_manually_created.length > 0 home_pages_manually_created.each do |homepage| - FileUtils.cp(homepage,"#{@env.path.webserv}/#{@env.path.stub_pwd}") + FileUtils.cp(homepage,"#{@env.path.webserv}/#{@env.path.base_markup_dir_stub}") end else create_default_sisu_homepage(:none) @@ -7088,12 +7088,12 @@ WOK end def cp_local_images src="#{@pwd}/_sisu/image" - dest="#{@env.path.webserv}/#{@env.path.stub_pwd}/_sisu/image" + dest="#{@env.path.webserv}/#{@env.path.base_markup_dir_stub}/_sisu/image" 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" + dest="#{@env.path.webserv}/#{@env.path.base_markup_dir_stub}/_sisu/image_external" if FileTest.directory?(src) cp_images(src,dest) if FileTest.directory?(src) end @@ -7102,7 +7102,7 @@ WOK src=@env.path.image_source dest_arr=[ "#{@env.path.webserv}/_sisu/image", - "#{@env.path.webserv}/#{@env.path.stub_pwd}/_sisu/image" + "#{@env.path.webserv}/#{@env.path.base_markup_dir_stub}/_sisu/image" ] dest_arr.each do |dest| cp_images(src,dest) if FileTest.directory?(src) @@ -7110,14 +7110,14 @@ WOK 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" + dest="#{@env.path.webserv}/#{@env.path.base_markup_dir_stub}/_sisu/image" cp_images(src,dest) if FileTest.directory?(src) end def cp_base_images #fix images src=SiSU_is[:path_base_system_data] + '/image' dest_arr=[ "#{@env.path.webserv}/_sisu/image_sys", - "#{@env.path.webserv}/#{@env.path.stub_pwd}/_sisu/image_sys" + "#{@env.path.webserv}/#{@env.path.base_markup_dir_stub}/_sisu/image_sys" ] dest_arr.each do |dest| cp_images(src,dest) if FileTest.directory?(src) |