From 69e8c05210e249e679b259cb843a5e708273e9be Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Sun, 14 Oct 2007 21:29:55 +0100 Subject: shared markup source output moved to own common src directory --- lib/sisu/v0/dal.rb | 58 +++++++++------ lib/sisu/v0/help.rb | 2 +- lib/sisu/v0/manifest.rb | 20 ++--- lib/sisu/v0/options.rb | 14 +++- lib/sisu/v0/param.rb | 10 ++- lib/sisu/v0/share_src.rb | 7 +- lib/sisu/v0/sisupod_make.rb | 30 ++++---- lib/sisu/v0/sysenv.rb | 173 ++++++++++++++++++++++++++++---------------- lib/sisu/v0/urls.rb | 14 +++- 9 files changed, 209 insertions(+), 119 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v0/dal.rb b/lib/sisu/v0/dal.rb index 132da336..3631a77c 100644 --- a/lib/sisu/v0/dal.rb +++ b/lib/sisu/v0/dal.rb @@ -324,36 +324,39 @@ module SiSU_DAL when /4/; cf_defaults.cf_4 when /5/; cf_defaults.cf_5 end - file_type_names=[] - file_type_names <<= if cmd_list =~ /y/; 'sisu_manifest.html' + file_type_names={} + file_type_names[:gen],file_type_names[:src]=[],[] + file_type_names[:gen] <<= if cmd_list =~ /y/; 'sisu_manifest.html' end - file_type_names <<= if cmd_list =~ /h/; ['toc.html', 'doc.html'] + file_type_names[:gen] <<= if cmd_list =~ /h/; ['toc.html', 'doc.html'] end - file_type_names <<= if cmd_list =~ /p/; ['landscape.pdf', 'portrait.pdf'] + file_type_names[:gen] <<= if cmd_list =~ /p/; ['landscape.pdf', 'portrait.pdf'] end - #file_type_names <<= if cmd_list =~ /i/; 'manpage.1' + #file_type_names[:gen] <<= if cmd_list =~ /i/; 'manpage.1' #end - file_type_names <<= if cmd_list =~ /o/; 'opendocument.odt' + file_type_names[:gen] <<= if cmd_list =~ /o/; 'opendocument.odt' end - file_type_names <<= if cmd_list =~ /b/; 'scroll.xhtml' + file_type_names[:gen] <<= if cmd_list =~ /b/; 'scroll.xhtml' end - file_type_names <<= if cmd_list =~ /x/; 'sax.xml' + file_type_names[:gen] <<= if cmd_list =~ /x/; 'sax.xml' end - file_type_names <<= if cmd_list =~ /X/; 'dom.xml' + file_type_names[:gen] <<= if cmd_list =~ /X/; 'dom.xml' end - file_type_names <<= if cmd_list =~ /a/; 'plain.txt' + file_type_names[:gen] <<= if cmd_list =~ /a/; 'plain.txt' end - file_type_names <<= if cmd_list =~ /g/; 'wiki.txt' + file_type_names[:gen] <<= if cmd_list =~ /g/; 'wiki.txt' end - file_type_names <<= if cmd_list =~ /w/; 'concordance.html' + file_type_names[:gen] <<= if cmd_list =~ /w/; 'concordance.html' end - file_type_names <<= if cmd_list =~ /N/; 'digest.txt' + file_type_names[:gen] <<= if cmd_list =~ /N/; 'digest.txt' end - file_type_names <<= if source and cmd_shortcut =~ /s/; source + file_type_names[:src] <<= if source and cmd_shortcut =~ /s/; source end - file_type_names <<= if cmd_shortcut =~ /S/; 'sisupod.zip' + file_type_names[:src] <<= if cmd_shortcut =~ /S/; "#{source}.zip" end - file_type_names=file_type_names.flatten + file_type_names[:gen]=file_type_names[:gen].flatten + file_type_names[:src]=file_type_names[:src].flatten + file_type_names end def expand_insertions?(data) tuned_file,tuned_file_tmp=[],[] @@ -378,7 +381,8 @@ module SiSU_DAL end end tuned_file_tmp << manifest - output_filetypes_in_cmd(cmd,source).each do |o_f| + output_filetypes=output_filetypes_in_cmd(cmd,source) + output_filetypes[:gen].each do |o_f| describe = case o_f when /sisu_manifest.html/; '~^ document manifest' when /toc.html/; ' html, segmented text' @@ -394,15 +398,25 @@ module SiSU_DAL when /wiki.txt/; ' wiki text' when /concordance.html/; ' concordance' when /digest.txt/; ' dcc, document content certificate (digests)' + else nil + end + if describe + tuned_file_tmp << if @output_url #to double space <:br> at beginning of entry + "     {#{describe} }#@output_url/#{url_dir}/#{o_f}" if describe + else "     { #{describe} }../#{url_dir}/#{o_f}" + end + end + end + output_filetypes[:src].each do |o_f| + describe = case o_f + when /#{source}\.zip/; ' markup source (zipped) pod' when /#{source}/; ' markup source text' - when /sisupod.zip/; ' zipped markup source pod' else nil end if describe - if @output_url - tuned_file_tmp << "     {#{describe} }#@output_url/#{url_dir}/#{o_f}" if describe #to double space <:br> at beginning of entry - else - tuned_file_tmp << "     { #{describe} }../#{url_dir}/#{o_f}" #to double space <:br> at beginning of entry + tuned_file_tmp << if @output_url + "     {#{describe} }#@output_url/src/#{o_f}" if describe + else "     { #{describe} }../#{url_dir}/#{o_f}" end end end diff --git a/lib/sisu/v0/help.rb b/lib/sisu/v0/help.rb index 0cd100f4..5c568074 100644 --- a/lib/sisu/v0/help.rb +++ b/lib/sisu/v0/help.rb @@ -64,7 +64,7 @@ module SiSU_Help if color =~/color_off/; @cX=SiSU_Screen::Ansi.new('k').cX else @cX=SiSU_Screen::Ansi.new('yes').cX end - fns='dummy_file_ref.sst' + fns='help_example_dummy_file_name.sst' @env=SiSU_Env::Info_env.new(fns) @db=SiSU_Env::Info_db.new m=/.+\/(\S+)/m diff --git a/lib/sisu/v0/manifest.rb b/lib/sisu/v0/manifest.rb index da123216..8a1f0cd3 100644 --- a/lib/sisu/v0/manifest.rb +++ b/lib/sisu/v0/manifest.rb @@ -93,7 +93,9 @@ module SiSU_Manifest @fnb=@md.fnb out=@env.path.output @base_url="#{@env.url.root}/#@fnb" + @base_url_src="#{@env.url.root}/src" @base_path="#{out}/#@fnb" + @base_path_src="#{out}/src" @@dg ||=SiSU_Env::Info_env.new.digest.type @dg=@@dg l=SiSU_Env::Standardise_language.new.file_to_language(@md.fns) @@ -116,15 +118,15 @@ module SiSU_Manifest end def summarize_source(id,file) sys=SiSU_Env::System_call.new - dgst =if @dg =~/^sha(?:2|256)$/; sys.sha256("#{@base_path}/#{file}") - else sys.md5("#{@base_path}/#{file}") + dgst =if @dg =~/^sha(?:2|256)$/; sys.sha256("#{@base_path_src}/#{file}") + else sys.md5("#{@base_path_src}/#{file}") end tell=SiSU_Screen::Ansi.new(@md.cmd,"#{dgst[1]} #{file}") tell.warn if @md.cmd =~/[vVM]/ - size=(File.size("#{@base_path}/#{file}")/1024.00).to_s + size=(File.size("#{@base_path_src}/#{file}")/1024.00).to_s kb=/([0-9]+\.[0-9]{0,1})/m.match(size)[1] @manifest[:txt] << "#{file} #{id} #{kb}\n" - @manifest[:html] << %{

#{id}

#{file}   #{dgst[1]}
#{@url_brace.xml_open}#@base_url/#{file}#{@url_brace.xml_close}

#{kb}

+ @manifest[:html] << %{

#{id}

#{file}   #{dgst[1]}
#{@url_brace.xml_open}#@base_url_src/#{file}#{@url_brace.xml_close}

#{kb}

\n} if kb and kb =~/\d+/ end def languages(id,file) @@ -233,18 +235,18 @@ module SiSU_Manifest end def source_tests if @md.fns =~/\._sst$/ #% decide whether to extract and include requested/required documents - req=@md.fns.gsub(/(.+)?\._sst$/,'\1.composite.sst') #watch strange - if FileTest.file?("#@base_path/#{req}")==true + req=@md.fns.gsub(/(.+)?\._sst$/,'\1.ssm.sst') #watch strange + if FileTest.file?("#@base_path_src/#{req}")==true id,file='Markup Composite File (SiSU source)',req summarize_source(id,file) end end - if FileTest.file?("#@base_path/#{@md.fns}")==true + if FileTest.file?("#@base_path_src/#{@md.fns}")==true id,file='Markup (SiSU source)',@md.fns summarize_source(id,file) end - if FileTest.file?("#@base_path/sisupod.zip")==true - id,file='SiSU doc (zip)','sisupod.zip' + if FileTest.file?("#@base_path_src/#{@md.fn[:sisupod]}")==true + id,file='SiSU doc (zip)',@md.fn[:sisupod] summarize_source(id,file) end if FileTest.file?("#@base_path/#{@md.fnb}")==true and @md.fnb =~/\.kdi$/ diff --git a/lib/sisu/v0/options.rb b/lib/sisu/v0/options.rb index 8b014c04..7f94306e 100644 --- a/lib/sisu/v0/options.rb +++ b/lib/sisu/v0/options.rb @@ -58,9 +58,9 @@ module SiSU_commandline require "#{SiSU_lib}/sysenv" class Options - attr_accessor :cmd,:mod,:files,:fns,:fnb,:what + attr_accessor :cmd,:mod,:files,:fns,:fnb,:fnc,:fncb,:what def initialize(a) - @cmd,@files,@fns,@fnb,@what,c,w,s='','','','','','','','','' + @cmd,@files,@fns,@fnb,@fnc,@fncb,@what,c,w,s='','','','','','','','','','','' @files,@mod,m,f,z,ca=[],[],[],[],[],[] @env=SiSU_Env::Info_env.new shortcut=SiSU_Env::Info_processing_flag.new @@ -165,6 +165,16 @@ module SiSU_commandline fns[/(.+?)\.(?:[_-]?sst|ssm)$/,1] end end + def fnc + @fnc=if @fns =~/\.(?:_sst|ssm)$/; fnb + '.ssm.sst' + else @fns + end + end + def fncb + @fncb=if @fns =~/(?:\~\S{2,3})?\.(?:_sst|ssm)$/; fnb + '.ssm.sst' + else @fns.gsub(/(?:\~\S{2,3})?(\.sst)$/,'\1') + end + end end end __END__ diff --git a/lib/sisu/v0/param.rb b/lib/sisu/v0/param.rb index 9655afed..e154b903 100644 --- a/lib/sisu/v0/param.rb +++ b/lib/sisu/v0/param.rb @@ -115,9 +115,9 @@ module SiSU_Param @doc={ :lv=>[] } @doc[:fns],@doc[:fnb],@doc[:scr_suffix]='','','' @@publisher='SiSU scribe' - attr_accessor :cmd,:mod,:env,:fn,:fns,:fnb,:fnn,:fnt,:fnl,:flv,:fnstex,:ocn,:sfx_src,:sfx,:pdf,:file_type,:dir_out,:dir_tex,:dir_lout,:txt_path,:site_skin,:sisu,:sisu_version,:ruby_version,:title,:dc_title,:html_title,:subtitle,:subtitle_tex,:creator_home,:dc_creator,:translator,:illustrator,:prepared_by,:digitized_by,:dc_subject,:dc_description,:dc_publisher,:dc_contributor,:dc_date,:dc_date_created,:dc_date_issued,:dc_date_available,:dc_date_valid,:dc_date_modified,:date_scheme,:date_created_scheme,:date_issued_scheme,:date_available_scheme,:date_valid_scheme,:date_modified_scheme,:dc_type,:dc_format,:dc_identifier,:dc_source,:dc_language,:language_original,:dc_relation,:dc_coverage,:dc_rights,:keywords,:comments,:abstract,:cls_loc,:cls_dewey,:cls_pg,:cls_isbn,:papersize,:toc,:lv1,:lv2,:lv3,:lv4,:lv5,:lv6,:pagenew,:pagebreak,:num_top,:toc_lev_limit,:flag_endnotes,:flag_auto_endnotes,:flag_separate_endnotes,:flag_separate_endnotes_make,:flag_auto_heading_num,:markup,:markup_instruction,:markup_version,:markup_declared,:make_bold,:make_italic,:flag_tables,:vocabulary,:doc_skin,:doc_css,:yaml,:lnk,:prefix_a,:prefix_b,:suffix,:information,:contact,:icon,:image,:ad_url,:ad_png,:ad_alt,:ad_began,:flag_promo,:promo,:ad_home,:stmp,:stmpd,:sc_filename,:sc_number,:sc_date,:sc_time,:sc_info,:yamladdr,:locale,:wc_lines,:wc_words,:wc_bytes,:file_encoding,:file_size,:user,:home,:hostname,:pwd,:firstseg,:programs,:creator_copymark,:lang,:en,:dgst,:dgst_skin,:generated,:tags,:tag_array,:concord_make,:seg_names,:seg_autoname_safe,:set_header_title,:set_heading_top,:set_heading_seg,:heading_seg_first,:heading_seg_first_flag,:base_program,:man_section,:man_name,:man_synopsis,:ec + attr_accessor :cmd,:mod,:env,:fn,:fns,:fnb,:fnn,:fnt,:fnl,:flv,:fnz,:fnstex,:ocn,:sfx_src,:sfx,:pdf,:file_type,:dir_out,:dir_tex,:dir_lout,:txt_path,:site_skin,:sisu,:sisu_version,:ruby_version,:title,:dc_title,:html_title,:subtitle,:subtitle_tex,:creator_home,:dc_creator,:translator,:illustrator,:prepared_by,:digitized_by,:dc_subject,:dc_description,:dc_publisher,:dc_contributor,:dc_date,:dc_date_created,:dc_date_issued,:dc_date_available,:dc_date_valid,:dc_date_modified,:date_scheme,:date_created_scheme,:date_issued_scheme,:date_available_scheme,:date_valid_scheme,:date_modified_scheme,:dc_type,:dc_format,:dc_identifier,:dc_source,:dc_language,:language_original,:dc_relation,:dc_coverage,:dc_rights,:keywords,:comments,:abstract,:cls_loc,:cls_dewey,:cls_pg,:cls_isbn,:papersize,:toc,:lv1,:lv2,:lv3,:lv4,:lv5,:lv6,:pagenew,:pagebreak,:num_top,:toc_lev_limit,:flag_endnotes,:flag_auto_endnotes,:flag_separate_endnotes,:flag_separate_endnotes_make,:flag_auto_heading_num,:markup,:markup_instruction,:markup_version,:markup_declared,:make_bold,:make_italic,:flag_tables,:vocabulary,:doc_skin,:doc_css,:yaml,:lnk,:prefix_a,:prefix_b,:suffix,:information,:contact,:icon,:image,:ad_url,:ad_png,:ad_alt,:ad_began,:flag_promo,:promo,:ad_home,:stmp,:stmpd,:sc_filename,:sc_number,:sc_date,:sc_time,:sc_info,:yamladdr,:locale,:wc_lines,:wc_words,:wc_bytes,:file_encoding,:file_size,:user,:home,:hostname,:pwd,:firstseg,:programs,:creator_copymark,:lang,:en,:dgst,:dgst_skin,:generated,:tags,:tag_array,:concord_make,:seg_names,:seg_autoname_safe,:set_header_title,:set_heading_top,:set_heading_seg,:heading_seg_first,:heading_seg_first_flag,:base_program,:man_section,:man_name,:man_synopsis,:ec def initialize(fns_array,opt) - @env=@fn=@fns=@fnb=@fnn=@fnt=@fnl=@flv=@fnstex=@ocn=@sfx_src=@sfx=@pdf=@file_type=@dir_out=@dir_tex=@dir_lout=@txt_path=@flag_endnotes=@flag_auto_endnotes=@flag_separate_endnotes=@flag_separate_endnotes_make=@site_skin=@sisu=@sisu_version=@ruby_version=@title=@dc_title=@html_title=@subtitle=@subtitle_tex=@creator_home=@dc_creator=@translator=@illustrator=@prepared_by=@digitized_by=@dc_subject=@dc_description=@dc_publisher=@dc_contributor=@dc_date=@dc_date_created=@dc_date_issued=@dc_date_available=@dc_date_valid=@dc_date_modified=@date_scheme=@date_created_scheme=@date_issued_scheme=@date_available_scheme=@date_valid_scheme=@date_modified_scheme=@dc_type=@dc_format=@dc_identifier=@dc_source=@dc_language=@language_original=@dc_relation=@dc_coverage=@dc_rights=@keywords=@comments=@abstract=@cls_loc=@cls_dewey=@cls_pg=@cls_isbn=@papersize=@toc=@lv1=@lv2=@lv3=@lv4=@lv5=@lv6=@pagenew=@pagebreak=@num_top=@toc_lev_limit=@flag_auto_heading_num=@make_bold=@make_italic=@flag_tables=@vocabulary=@doc_skin=@doc_css=@yaml=@lnk=@prefix_a=@prefix_b=@suffix=@information=@contact=@icon=@ad_url=@ad_png=@ad_alt=@ad_began=@promo=@ad_home=@stmp=@stmpd=@sc_filename=@sc_number=@sc_date=@sc_time=@sc_info=@yamladdr=@locale=@wc_lines=@wc_words=@wc_bytes=@file_encoding=@file_size=@firstseg=@programs=@creator_copymark=@lang=@en=@dgst=@dgst_skin=@generated=@heading_seg_first=@base_program=@man_synopsis=nil + @env=@fn=@fns=@fnb=@fnn=@fnt=@fnl=@flv=@fnz=@fnstex=@ocn=@sfx_src=@sfx=@pdf=@file_type=@dir_out=@dir_tex=@dir_lout=@txt_path=@flag_endnotes=@flag_auto_endnotes=@flag_separate_endnotes=@flag_separate_endnotes_make=@site_skin=@sisu=@sisu_version=@ruby_version=@title=@dc_title=@html_title=@subtitle=@subtitle_tex=@creator_home=@dc_creator=@translator=@illustrator=@prepared_by=@digitized_by=@dc_subject=@dc_description=@dc_publisher=@dc_contributor=@dc_date=@dc_date_created=@dc_date_issued=@dc_date_available=@dc_date_valid=@dc_date_modified=@date_scheme=@date_created_scheme=@date_issued_scheme=@date_available_scheme=@date_valid_scheme=@date_modified_scheme=@dc_type=@dc_format=@dc_identifier=@dc_source=@dc_language=@language_original=@dc_relation=@dc_coverage=@dc_rights=@keywords=@comments=@abstract=@cls_loc=@cls_dewey=@cls_pg=@cls_isbn=@papersize=@toc=@lv1=@lv2=@lv3=@lv4=@lv5=@lv6=@pagenew=@pagebreak=@num_top=@toc_lev_limit=@flag_auto_heading_num=@make_bold=@make_italic=@flag_tables=@vocabulary=@doc_skin=@doc_css=@yaml=@lnk=@prefix_a=@prefix_b=@suffix=@information=@contact=@icon=@ad_url=@ad_png=@ad_alt=@ad_began=@promo=@ad_home=@stmp=@stmpd=@sc_filename=@sc_number=@sc_date=@sc_time=@sc_info=@yamladdr=@locale=@wc_lines=@wc_words=@wc_bytes=@file_encoding=@file_size=@firstseg=@programs=@creator_copymark=@lang=@en=@dgst=@dgst_skin=@generated=@heading_seg_first=@base_program=@man_synopsis=nil @man_section=1 @man_name='man page "name/whatis" information not provided, set in header @man: name=[whatis information]' @data,@fns,@cmd,@mod,@opt=fns_array,opt.fns,opt.cmd,opt.mod,opt #@data used as data @@ -175,10 +175,16 @@ module SiSU_Param m=/((.+?)(?:\~\w{2,3})?)\.([_-]?sst)$/ #watch added match for sss @fnn,@fnb,@fnt=@fns[m,1],@fns[m,2],@fns[m,3] @flv=@env.document_language_versions_found[:f] + @fnz=if @fns =~/\.(?:_sst|ssm)$/; @fnn + '.ssm.zip' + else @fnn + '.sst.zip' + end else m=/(.+?)\.([_-]?sst)$/ @fnb=@fnn=@fns[m,1] @fnt=@fns[m,2] @flv<<@fns + @fnz=if @fns =~/\.(?:_sst|ssm)$/; @fnb + '.ssm.zip' + else @@fnb + '.sst.zip' + end end @papersize=@env.papersize #'A4' #default size #get first from SiSU_Env:: # @env is probably no longer most appropriate name! as default info is more general @sfx_src=@fns[m,2] diff --git a/lib/sisu/v0/share_src.rb b/lib/sisu/v0/share_src.rb index 53e19f1c..3d2bf8db 100644 --- a/lib/sisu/v0/share_src.rb +++ b/lib/sisu/v0/share_src.rb @@ -65,19 +65,20 @@ module SiSU_Markup @opt=opt @env=SiSU_Env::Info_env.new(@opt.fns) stub=@opt.fnb.gsub(/~[a-z]+$/,'') - @output_path="#{@env.path.output}/#{stub}" + @output_path="#{@env.path.output}/src" + #@output_path="#{@env.path.output}/#{stub}" end def read tell=SiSU_Screen::Ansi.new(@opt.cmd,'Share Document Source!',@opt.fns) tell.green_hi_blue unless @opt.cmd =~/q/ tell=SiSU_Screen::Ansi.new(@opt.cmd,"Copy sisu markup file to output directory","#{@opt.fns} -> #@output_path") tell.warn unless @opt.cmd =~/q/ - File.mkpath(@env.path.output) unless FileTest.directory?(@env.path.output) + File.mkpath("#{@env.path.output}/src") unless FileTest.directory?("#{@env.path.output}/src") File.mkpath(@output_path) unless FileTest.directory?(@output_path) if FileTest.directory?(@output_path) unless @opt.fns =~/\.ssm$/; cp(@opt.fns,@output_path) else - req=@opt.fns.gsub(/(.+)?\.ssm$/,'\1.composite.sst') + req=@opt.fns.gsub(/(.+?\.ssm)$/,'\1.sst') file="#{@env.path.composite_file}/#{@opt.fnb}._sst" if FileTest.file?(file); cp(file,"#@output_path/#{req}") else print "did not find #{file} to copy" diff --git a/lib/sisu/v0/sisupod_make.rb b/lib/sisu/v0/sisupod_make.rb index 8e6932f0..10ec76e5 100644 --- a/lib/sisu/v0/sisupod_make.rb +++ b/lib/sisu/v0/sisupod_make.rb @@ -72,6 +72,10 @@ module SiSU_Doc @v=if @opt.cmd =~/[VM]/; 'v' else '' end + @local_path="#{@env.path.output}/src" #@local_path="#{@env.path.output}/#{@env.fnb}" + @zipfile=if @opt.fns =~/\._sst$/; @opt.fns.gsub(/(?:\~\S{2,3})?\._sst$/,'.ssm') + else @opt.fns.gsub(/(?:\~\S{2,3})?(\.sst)$/,'\1') + end File.mkpath(pod_path) unless FileTest.directory?(pod_path) rm_rf("#{@env.path.processing}sisupod/*") if FileTest.directory?("#{@env.path.processing}sisupod") end @@ -79,7 +83,7 @@ module SiSU_Doc tell=SiSU_Screen::Ansi.new(@opt.cmd,'Share SiSU Document (zip)',@opt.fns) tell.green_hi_blue unless @opt.cmd =~/q/ unless @opt.fns.empty? - tell=SiSU_Screen::Ansi.new(@opt.cmd,'Make sisu document (zip) and place in output directory',"#{@opt.fns}.zip -> #{@env.path.output}/#{@opt.fnb}/sisupod.zip") + tell=SiSU_Screen::Ansi.new(@opt.cmd,'Make sisu document (zip) and place in output directory',"#{@opt.fns} -> file://#{@env.path.output}/src/#{@zipfile}.zip") tell.warn unless @opt.cmd =~/q/ directories sisupod_build @@ -240,35 +244,31 @@ module SiSU_Doc end #NB not all possibilies met, revisit, also in case of composite file may wish to add README end def sisupod_7zip #look at later - dir=SiSU_Env::Info_env.new(@opt.fns) - local_path="#{dir.path.output}/#{dir.fnb}" - File.mkpath(local_path) unless FileTest.directory?(local_path) + File.mkpath(@local_path) unless FileTest.directory?(@local_path) system(%{ cd #{@env.path.processing} echo "SiSU sisupod #{@ver[:version]}" > sisu_zip.txt #7zip -qz #{@opt.fns}.7z sisu_zip.txt < sisu_zip.txt - 7zr a -t7z -m0=lzma -mx=9 -ms=on #{@opt.fns}.7z sisu_zip.txt - 7zr a -t7z -m0=lzma -mx=9 -ms=on #{@opt.fns}.7z sisupod - #7zip -qr #{@opt.fns}.7z sisupod - mv #{@opt.fns}.7z #{local_path}/sisupod.7z & + 7zr a -t7z -m0=lzma -mx=9 -ms=on #{@zipfile}.7z sisu_zip.txt + 7zr a -t7z -m0=lzma -mx=9 -ms=on #{@zipfile}.7z sisupod + #7zip -qr #{@zipfile}.7z sisupod + mv #{@zipfile}.7z #{@local_path}/. & rm -r sisupod/* && cd #{@env.path.pwd} }) tell=SiSU_Screen::Ansi.new('',"#{@opt.fns}.7z") tell.blue_tab unless @opt.cmd =~/q/ end def sisupod_zip - dir=SiSU_Env::Info_env.new(@opt.fns) - local_path="#{dir.path.output}/#{dir.fnb}" - File.mkpath(local_path) unless FileTest.directory?(local_path) + File.mkpath(@local_path) unless FileTest.directory?(@local_path) system(%{ cd #{@env.path.processing} echo "SiSU sisupod #{@ver[:version]}" > sisu_zip.txt - zip -qz #{@opt.fns}.zip sisu_zip.txt < sisu_zip.txt - zip -qr #{@opt.fns}.zip sisupod - mv #{@opt.fns}.zip #{local_path}/sisupod.zip & + zip -qz #{@zipfile}.zip sisu_zip.txt < sisu_zip.txt + zip -qr #{@zipfile}.zip sisupod + mv #{@zipfile}.zip #{@local_path}/. & rm -r sisupod/* && cd #{@env.path.pwd} }) - tell=SiSU_Screen::Ansi.new('',"#{@opt.fns}.zip") + tell=SiSU_Screen::Ansi.new('',"#{@zipfile}.zip") tell.blue_tab unless @opt.cmd =~/q/ end end diff --git a/lib/sisu/v0/sysenv.rb b/lib/sisu/v0/sysenv.rb index 4080795d..1c684052 100644 --- a/lib/sisu/v0/sysenv.rb +++ b/lib/sisu/v0/sysenv.rb @@ -339,9 +339,9 @@ module SiSU_Env end end class Env_call - @@rc,@@fns,@@fnn,@@fnb,@@fnt,@@flv=nil,nil,nil,nil,nil,nil + @@rc,@@fns,@@fnn,@@fnb,@@fnt,@@flv,@@fnz=nil,nil,nil,nil,nil,nil,nil @@ad={} - attr_accessor :rc,:fnn,:fnb,:fnt,:fnv,:ad + attr_accessor :rc,:fnn,:fnb,:fnt,:fnv,:fnz,:ad def initialize(fns='') super() @fns=fns @@ -349,7 +349,7 @@ module SiSU_Env @rc=Get_init.instance.yamlrc @ad=Get_init.instance.ads if @fns and @fns != '' and @fns !=@@fns - @@fns,@@fnn,@@fnb,@@fnt,@@flv=@fns,nil,nil,nil,nil + @@fns,@@fnn,@@fnb,@@fnt,@@flv,@@fnz=@fns,nil,nil,nil,nil,nil end if @fns and @fns != '' #watch if multilingual @@ -358,13 +358,19 @@ module SiSU_Env @@fnb ||=@fns[m,2] @@fnt ||=@fns[m,3] @@flv ||=document_language_versions_found[:f] + @@fnz ||=if @@fns =~/(?:\~\S{2,3})?\.(?:_sst|ssm)$/; @@fnb + '.ssm.zip' + else @@fnb + '.sst.zip' + end else m=/(.+?)\.([_-]?sst|ssm)$/ @@fnb ||=@fns[m,1] @@fnm ||=@fns[m,1] @@fnt ||=@fns[m,2] + @@fnz ||=if @@fns =~/(?:\~\S{2,3})?\.(?:_sst|ssm)$/; @@fnb + '.ssm.zip' + else @@fnb + '.sst.zip' + end end end - @fnn,@fnb,@fnt,@flv=@@fnn,@@fnb,@@fnt,@@flv + @fnn,@fnb,@fnt,@flv,@fnz=@@fnn,@@fnb,@@fnt,@@flv,@@fnz end def multilingual if defined? @rc['default']['multilingual'] and @rc['default']['multilingual'] != nil; @rc['default']['multilingual'] @@ -442,7 +448,10 @@ module SiSU_Env def filename(code,name,suffix) d=SiSU_Env::Info_env.new(@fns) fnl=d.i18n.lang_filename(code) - "#{fnl[:pre]}#{name}#{fnl[:mid]}#{suffix}#{fnl[:post]}" + if code + "#{fnl[:pre]}#{name}#{fnl[:mid]}#{suffix}#{fnl[:post]}" + else "#{name}#{suffix}" + end end def lang(code) @fn={ @@ -469,7 +478,8 @@ module SiSU_Env :sitemap_touch => filename(code,"sitemap_#@fnb",'.xml'), :sxs => filename(code,@fnb,'.sxs.xml'), :sxd => filename(code,@fnb,'.sxd.xml'), - :sxn => filename(code,@fnb,'.sxn.xml') + :sxn => filename(code,@fnb,'.sxn.xml'), + :sisupod => filename(nil,@fnz,'') } @fn end @@ -747,7 +757,7 @@ module SiSU_Env class Info_env < Env_call require 'fileutils' include FileUtils - attr_accessor :filename,:sys,:home,:hostname,:user,:env,:rc,:www,:fnb,:fnn,:fnt,:flv,:webserv_path,:stub_pwd,:webserv_host_cgi,:webserv_port_cgi,:processing,:etc,:yamlrc_dir + 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,:etc,:yamlrc_dir @@image_flag,@@local_image=true,true #warning on @@image_flag @@fb=@@man_path=nil,nil def initialize(fns='',md=nil) @@ -768,6 +778,7 @@ module SiSU_Env @pwd=@@pwd||=Dir.pwd m=/.+\/(\S+)/m @stub_pwd=@@pwd[m,1] + @stub_src=@stub_pwd + '/src' end def user @sys.user @@ -800,6 +811,9 @@ module SiSU_Env def stub_pwd #200412 @stub_pwd end + def stub_src + @stub_src + end def sisupod #path.processing # sisupod @@ -1121,6 +1135,9 @@ WOK def stub_pwd @stub_pwd end + def stub_src + @stub_src + end def etc defaults[:sisu_etc] #live/dynamic # @sys.sisu_etc #broken: live/dynamic @@ -1208,6 +1225,9 @@ WOK def output #web/webserv output directory... subdirectory into which further subdirectories are made based on file names "#{path.webserv}/#@stub_pwd" end + def output_src #web/webserv output directory... subdirectory into which further subdirectories are made based on file names + "#{path.webserv}/src" + end def manpage "#{path.output}/man" end @@ -1892,7 +1912,7 @@ WOK end if @md.cmd =~ /s/; ft << @md.fns end - if @md.cmd =~ /S/; ft << 'sisupod.zip' << '.kdi' + if @md.cmd =~ /S/; ft << @md.fn[:sisupod] << '.kdi' end @fnb=@md.fnb else # still needed where/when param is not parsed @@ -1912,7 +1932,7 @@ WOK end if @opt.cmd =~ /i/; ft << '.1' << '??.man.1' << 'man.??.1' end - if @opt.cmd =~ /a/; ft << 'plain.txt' << '??.plain.txt' << 'plain.??.txt' + if @opt.cmd =~ /a/; ft << 'plain.txt' << '??.plain.txt' << 'plain.??.txt' end if @opt.cmd =~ /[g]/; ft << 'wiki.txt' << '??.wiki.txt' << 'wiki.??.txt' end @@ -1924,7 +1944,7 @@ WOK end if @opt.cmd =~ /s/; ft << '.sst' << '.ssi' << '.ssm' end - if @opt.cmd =~ /S/; ft << 'sisupod.zip' << '.kdi' + if @opt.cmd =~ /S/; ft << '.zip' << '.kdi' end if @opt.mod.inspect =~ /sxm|sxs|xml/; ft << @fnb << '.sxs.xml' end @@ -1943,6 +1963,9 @@ WOK @source_path=if @fnb and not @fnb.empty?; "#{@env.path.output}/#@fnb" else @env.path.output end + @source_path_src=if @fnb and not @fnb.empty?; "#{@env.path.output}/src" + else @env.path.output_src + end @local_sisu_source=if @filetypes =~/\S/; "#@source_path/#@filetypes" else @source_path end @@ -2019,105 +2042,131 @@ WOK remote_host_base_general[:name] end def scp #sort out later using ruby libraries #not ideal, first time each file is sent, -r must be called separately for subdir to be built - input=@local_sisu_source - output=case @opt.cmd + local=@source_path + remote=case @opt.cmd when /u/; "#{self.remote_host_base}/#{@env.path.stub_pwd}/." #creates remote directory tree, this is not the usual function of u when /[abhHNopwxXy]/; "#{self.remote_host_base}/#{@env.path.stub_pwd}/#{@fnb}/." else "#{self.remote_host_base}/#{@env.path.stub_pwd}/." end - if (input =~/\S/ and input !~/\/\//) and (output =~/\S/ and output !~/\/\//) and @@flag_remote==true and @opt.cmd !~/U/ - System_call.new(input,output).scp - elsif @opt.cmd =~/U/; puts "#{input} -> #{output}" - else puts 'suspect scp request, ignored' + #remote="#{self.remote_host_base}/#{@env.path.stub_pwd}/." + local_src=@source_path_src + remote_src="#{self.remote_host_base}/#{@env.path.stub_src}/." + src_txt=@opt.fnc + src_pod=@opt.fncb.gsub(/(\.ss[mt])(?:\.sst)?$/,'\1.zip') + if (local =~/\S/ and local !~/\/\//) and (remote =~/\S/ and remote !~/\/\//) and @@flag_remote==true and @opt.cmd !~/U/ + System_call.new(local,remote).scp + if FileTest.file?("#{local_src}/#{src_txt}") or FileTest.file?("#{local_src}/#{src_pod}") + System_call.new("#{local_src}/#{src_txt} #{local_src}/#{src_pod}",remote_src).scp + end + elsif @opt.cmd =~/U/ + puts "#{__FILE__} #{__LINE__}" if @opt.cmd =~/M/ + puts "#{local} -> #{remote}" + if FileTest.file?("#{local_src}/#{src_doc}") or FileTest.file?("#{local_src}/#{src_doc}.zip") + puts "#{local_src}/#{src_doc}* -> #{remote_src}" + end + else + puts 'suspect scp request, ignored' + puts "#{local} -> #{remote} remote flag: #@@flag_remote" + puts "permission not granted #{__FILE__} #{__LINE__}" if @opt.cmd =~/M/ end end def rsync - input=@source_path - output="#{self.remote_host_base}/#{@env.path.stub_pwd}/." - if (input =~/\S/ and input !~/\/\//) and (output =~/\S/ and output !~/\/\//) and @@flag_remote==true and @opt.cmd !~/U/ - System_call.new(input,output,@opt.cmd).rsync('--delete-after') + local=@source_path + remote="#{self.remote_host_base}/#{@env.path.stub_pwd}/." + local_src=@source_path_src + remote_src="#{self.remote_host_base}/#{@env.path.stub_src}/." + src_txt=@opt.fnc + src_pod=@opt.fncb.gsub(/(\.ss[mt])(?:\.sst)?$/,'\1.zip') + if (local =~/\S/ and local !~/\/\//) and (remote =~/\S/ and remote !~/\/\//) and @@flag_remote==true and @opt.cmd !~/U/ + System_call.new(local,remote,@opt.cmd).rsync('--delete-after') + if FileTest.file?("#{local_src}/#{src_txt}") or FileTest.file?("#{local_src}/#{src_pod}") + System_call.new("#{local_src}/#{src_txt} #{local_src}/#{src_pod}",remote_src,@opt.cmd).rsync + end elsif @opt.cmd =~/U/ puts "#{__FILE__} #{__LINE__}" if @opt.cmd =~/M/ - puts "#{input} -> #{output}" + puts "#{local} -> #{remote}" + if FileTest.file?("#{local_src}/#{src_doc}") or FileTest.file?("#{local_src}/#{src_doc}.zip") + puts "#{local_src}/#{src_doc}* -> #{remote_src}" + end else puts 'suspect rsync request, ignored' - puts "#{input} -> #{output} remote flag: #@@flag_remote" + puts "#{local} -> #{remote} remote flag: #@@flag_remote" puts "permission not granted #{__FILE__} #{__LINE__}" if @opt.cmd =~/M/ end end def scp_base #base site - input=@source_path - output="#{remote_host_base}/#{@env.path.stub_pwd}/." + local=@source_path + remote="#{remote_host_base}/#{@env.path.stub_pwd}/." if defined? @rc['permission_set']['remote_base_site'] and @rc['permission_set']['remote_base_site'] and @@flag_remote==true and @opt.cmd !~/U/ - puts "begin scp_base: #{input} -> #{output}" - System_call.new("#{input}/#{@env.path.style}/",output).scp + puts "begin scp_base: #{local} -> #{remote}" + System_call.new("#{local}/#{@env.path.style}/",remote).scp elsif @opt.cmd =~/U/ puts "#{__FILE__} #{__LINE__}" if @opt.cmd =~/M/ - puts "begin scp_base: #{input} -> #{output}" - puts "#{input}/#{@env.path.style}/ -> #{output}" + puts "begin scp_base: #{local} -> #{remote}" + puts "#{local}/#{@env.path.style}/ -> #{remote}" else puts "permission not granted #{__FILE__} #{__LINE__}" if @opt.cmd =~/M/ end end def scp_base_all #base site - input=@source_path - output="#{remote_host_base}/#{@env.path.stub_pwd}/." + local=@source_path + remote="#{remote_host_base}/#{@env.path.stub_pwd}/." if defined? @rc['permission_set']['remote_base_site'] and @rc['permission_set']['remote_base_site'] and @@flag_remote==true and @opt.cmd !~/U/ - puts "begin scp_base_all: #{input} -> #{output}" - System_call.new("#{input}/_sisu/image/",output).scp - System_call.new("#{input}/_sisu/image_local/",output).scp - System_call.new("#{input}/#{@env.path.style}/",output).scp + puts "begin scp_base_all: #{local} -> #{remote}" + System_call.new("#{local}/_sisu/image/",remote).scp + System_call.new("#{local}/_sisu/image_local/",remote).scp + System_call.new("#{local}/#{@env.path.style}/",remote).scp elsif @opt.cmd =~/U/ puts "#{__FILE__} #{__LINE__}" if @opt.cmd =~/M/ - puts "scp_base_all: #{input} -> #{output}" - puts "#{input}/_sisu/image/ -> #{output}" - puts "#{input}/_sisu/image_local/ -> #{output}" - puts "#{input}/#{@env.path.style}/ -> #{output}" + puts "scp_base_all: #{local} -> #{remote}" + puts "#{local}/_sisu/image/ -> #{remote}" + puts "#{local}/_sisu/image_local/ -> #{remote}" + puts "#{local}/#{@env.path.style}/ -> #{remote}" else puts "permission not granted #{__FILE__} #{__LINE__}" if @opt.cmd =~/M/ end end def rsync_base #base site - input=@source_path - output="#{remote_host_base}/#{@env.path.stub_pwd}/." + local=@source_path + remote="#{remote_host_base}/#{@env.path.stub_pwd}/." if defined? @rc['permission_set']['remote_base_site'] and @rc['permission_set']['remote_base_site'] and @@flag_remote==true and @opt.cmd !~/U/ - #puts "begin rsync_base: #{input} -> #{output}" - #System_call.new("#{input}/_sisu/image/",output).rsync - #System_call.new("#{input}/_sisu/image_local/",output).rsync - #System_call.new("#{input}/#{@env.path.style}/",output).rsync + #puts "begin rsync_base: #{local} -> #{remote}" + #System_call.new("#{local}/_sisu/image/",remote).rsync + #System_call.new("#{local}/_sisu/image_local/",remote).rsync + #System_call.new("#{local}/#{@env.path.style}/",remote).rsync elsif @opt.cmd =~/U/ puts "#{__FILE__} #{__LINE__}" if @opt.cmd =~/M/ - puts "rsync_base: #{input} -> #{output}" - puts "#{input}/_sisu/image/ -> #{output}" - puts "#{input}/_sisu/image_local/ -> #{output}" - puts "#{input}/#{@env.path.style}/ -> #{output}" + puts "rsync_base: #{local} -> #{remote}" + puts "#{local}/_sisu/image/ -> #{remote}" + puts "#{local}/_sisu/image_local/ -> #{remote}" + puts "#{local}/#{@env.path.style}/ -> #{remote}" else puts "permission not granted #{__FILE__} #{__LINE__}" if @opt.cmd =~/M/ end end def rsync_base_sync #base site - input=@source_path - output="#{remote_host_base}/#{@env.path.stub_pwd}/." + local=@source_path + remote="#{remote_host_base}/#{@env.path.stub_pwd}/." if defined? @rc['permission_set']['remote_base_site'] and @rc['permission_set']['remote_base_site'] and @@flag_remote==true and @opt.cmd !~/U/ - puts "begin rsync_base_sync: #{input} -> #{output}" - System_call.new("#{input}/_sisu/image/",output).rsync('--delete-after') - System_call.new("#{input}/_sisu/image_local/",output).rsync('--delete-after') - System_call.new("#{input}/#{@env.path.style}/",output).rsync('--delete-after') + puts "begin rsync_base_sync: #{local} -> #{remote}" + System_call.new("#{local}/_sisu/image/",remote).rsync('--delete-after') + System_call.new("#{local}/_sisu/image_local/",remote).rsync('--delete-after') + System_call.new("#{local}/#{@env.path.style}/",remote).rsync('--delete-after') elsif @opt.cmd =~/U/ puts "#{__FILE__} #{__LINE__}" if @opt.cmd =~/M/ - puts "rsync_base_sync: #{input} -> #{output}" - puts "#{input}/_sisu/image/ -> #{output}" - puts "#{input}/_sisu/image_local/ -> #{output}" - puts "#{input}/#{@env.path.style}/ -> #{output}" + puts "rsync_base_sync: #{local} -> #{remote}" + puts "#{local}/_sisu/image/ -> #{remote}" + puts "#{local}/_sisu/image_local/ -> #{remote}" + puts "#{local}/#{@env.path.style}/ -> #{remote}" else puts "permission not granted #{__FILE__} #{__LINE__}" if @opt.cmd =~/M/ end end def rsync_sitemaps #sitemap directory - input="#@source_path/sitemapindex.xml" - output="#{remote_host_base}/#{@env.path.stub_pwd}/." + local="#@source_path/sitemapindex.xml" + remote="#{remote_host_base}/#{@env.path.stub_pwd}/." if @@flag_remote #if defined? @rc['permission_set']['remote_base_site'] and @rc['permission_set']['remote_base_site'] #and @@flag_remote==true and @opt.cmd !~/U/ - System_call.new(input,output).rsync('--delete-after') + System_call.new(local,remote).rsync('--delete-after') elsif @opt.cmd =~/U/ puts "#{__FILE__} #{__LINE__}" if @opt.cmd =~/M/ - puts "rsync_sitemaps: #{input} -> #{output}" + puts "rsync_sitemaps: #{local} -> #{remote}" else puts "permission not granted #{__FILE__} #{__LINE__}" if @opt.cmd =~/M/ end end diff --git a/lib/sisu/v0/urls.rb b/lib/sisu/v0/urls.rb index 7f087b95..1f9cfbe8 100644 --- a/lib/sisu/v0/urls.rb +++ b/lib/sisu/v0/urls.rb @@ -97,7 +97,7 @@ module SiSU_urls @odf_viewer=@env.program.odf_viewer @manpage_gen=@env.program.manpage_generator source=if @opt.fns =~/\.sst$/; @opt.fns - elsif @opt.fns =~/\._sst/; "#@fnb.composite.sst" + elsif @opt.fns =~/\._sst/; "#@fnb.ssm.sst" else 'not recognised file' end @u ||= { @@ -122,7 +122,7 @@ module SiSU_urls 'p (PDF portrait)'=>@fn[:pdf_p], 'P[iu] (DB postgresql import/update)'=>'psql', 's (sisu markup)'=>source, - 'S (sisupod)'=>'sisupod.zip', + 'S (sisupod)'=>@fn[:sisupod], 'x (XML sax type)'=>@fn[:sax], 'X (XML dom type)'=>@fn[:dom], 'y (Manifest, html)'=>@fn[:manifest], @@ -185,7 +185,7 @@ module SiSU_urls @pwd_stub="#@webserv_url"[m,1] @u.each do |x,y| if @opt.fns =~ @m_regular - if x=~/^([abchHNopsSwxXyY])/ and @opt.cmd=~/[abchHNopsSwxXyY]/ and x=~/^[#{@opt.cmd}]/ + if x=~/^([abchHNopwxXyY])/ and @opt.cmd=~/[abchHNopwxXyY]/ and x=~/^[#{@opt.cmd}]/ m=$1 tell=SiSU_Screen::Ansi.new(@opt.cmd,"-#{x}","#@browser #@webserv_url/#@fnb/#{y}") tell.result unless @opt.cmd =~/q/ @@ -216,6 +216,14 @@ module SiSU_urls tell.result unless @opt.cmd =~/q/ @opt.cmd.gsub!(/P[iu]/,'') end + if x=~/^[sS]/ and @opt.cmd =~/[sS]/ + zipfile=if @opt.fns =~/\._sst$/; y.gsub(/(?:\~\S{2,3})?(\._sst\.zip)$/,'.ssm.zip') + else y.gsub(/(?:\~\S{2,3})?(\.sst\.zip)$/,'\1') + end + tell=SiSU_Screen::Ansi.new(@opt.cmd,"-#{x}","#@browser #@webserv_url/src/#{y}") + tell.result unless @opt.cmd =~/q/ + @opt.cmd.gsub!(/I/,'') + end urls_maintenance(@opt,x,y) if @opt.cmd =~/[MV]/ end end -- cgit v1.2.3