diff options
Diffstat (limited to 'lib/sisu/v4')
-rw-r--r-- | lib/sisu/v4/constants.rb | 4 | ||||
-rw-r--r-- | lib/sisu/v4/options.rb | 36 | ||||
-rw-r--r-- | lib/sisu/v4/param.rb | 6 | ||||
-rw-r--r-- | lib/sisu/v4/shared_sisupod_source.rb | 17 | ||||
-rw-r--r-- | lib/sisu/v4/sysenv.rb | 69 |
5 files changed, 112 insertions, 20 deletions
diff --git a/lib/sisu/v4/constants.rb b/lib/sisu/v4/constants.rb index 261756df..24ec53a0 100644 --- a/lib/sisu/v4/constants.rb +++ b/lib/sisu/v4/constants.rb @@ -240,6 +240,10 @@ Gt={ video: 'video', conf: 'doc/_sisu', } +S_CONF={ + header_make: 'sisu_document_make', + rc_yml: 'sisurc.yml', +} DISABLE={ epub: { internal_navigation: true, diff --git a/lib/sisu/v4/options.rb b/lib/sisu/v4/options.rb index ddf9737b..b26bada2 100644 --- a/lib/sisu/v4/options.rb +++ b/lib/sisu/v4/options.rb @@ -62,15 +62,17 @@ module SiSU_Commandline require_relative 'param_make' # param_make.rb @@sisu_call_origin_path=nil class HeaderCommon + def initialize(make_instruct_array) + @make_instruct_array=make_instruct_array + end def sisu_document_make_instructions @pagenew=@pagebreak=@toc=@lv1=@lv2=@lv3=@lv4=@lv5=@lv6=@num_top=@i18n=@man_section=@emphasis_set_to=@bold_match_list=@italics_match_list=@substitution_match_list=@footer_links=@home_button_links=@links=nil @makeset=false - make_instruct_array=SiSU_Env::GetInit.new.sisu_document_make.makefile - if make_instruct_array - make_instruct_array.each do |para| #% scan document + if @make_instruct_array + @make_instruct_array.each do |para| #% scan document if para =~/^(?:@make:|@links:)[+-]?\s/ case para - when /^@make:(.+)/m #% * header processing - make + when /^@make:(.+)/m #% header processing - make @env=SiSU_Env::InfoEnv.new @make=SiSU_Param_Make::MdMake.new($1.strip,@opt,@env).make makes=SiSU_Param_Make::MakeHead.new(@make).make_instruct @@ -129,7 +131,7 @@ module SiSU_Commandline end end 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,:make_instructions + 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,:make_instructions,:make_instructions_pod @@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='','','','','','','','','','','','','','' @@ -144,7 +146,9 @@ module SiSU_Commandline @base_stub=@base_path.gsub(u,'\1') @a=sisu_glob_rules(a) @a.freeze - @make_instructions=HeaderCommon.new.sisu_document_make_instructions + make_instruct_array=SiSU_Env::GetInit.new.sisu_document_make.makefile_read + @make_instructions=HeaderCommon.new(make_instruct_array).sisu_document_make_instructions + @make_instructions_pod=nil init end def find_all(find_flag,opt) @@ -265,6 +269,22 @@ module SiSU_Commandline @files self end + def sisu_document_make_pod + def makefile_name + SiSU_Env::GetInit.new.sisu_document_make.makefile_name + end + def makefile(pod_make_path) + "#{pod_make_path}/#{makefile_name}" + end + def makefile_read(pod_make_path) + f=if FileTest.file?(makefile(pod_make_path)) + sisu_doc_makefile=IO.read(makefile(pod_make_path), mode: 'r:utf-8') + sisu_doc_makefile.split(/\s*\n\s*\n/m) + else nil + end + end + self + end def set_files_and_paths_and_general_extract(s) c,w='','' m,f,pth,z,lng,lngs=[],[],[],[],[],[] @@ -289,6 +309,10 @@ module SiSU_Commandline fullname=@env.processing_path.processing + '/sisupod/' + fn_pod pt=Pathname.new(fullname) FileUtils::mkdir_p(pt.to_s) + pod_make_path=fullname + '/sisupod/doc/_sisu' + pod_make_path_file=pod_make_path + make_instruct_array=sisu_document_make_pod.makefile_read(pod_make_path) + @make_instructions_pod=HeaderCommon.new(make_instruct_array).sisu_document_make_instructions Dir.chdir(pt.realpath) options=s.gsub(/(\s+--?\S+)+.+/,'\1') system(" diff --git a/lib/sisu/v4/param.rb b/lib/sisu/v4/param.rb index 925723f8..e3742967 100644 --- a/lib/sisu/v4/param.rb +++ b/lib/sisu/v4/param.rb @@ -839,7 +839,11 @@ module SiSU_Param ensure end @header_make_links_append=:no - common_makes=@opt.make_instructions + common_makes=(defined? @opt.make_instructions_pod) \ + && @opt.make_instructions_pod !=nil \ + && @opt.make_instructions_pod[:makeset]==true \ + ? @opt.make_instructions_pod + : @opt.make_instructions if common_makes[:makeset] @pagenew=common_makes[:pagenew] @pagebreak=common_makes[:pagenew] diff --git a/lib/sisu/v4/shared_sisupod_source.rb b/lib/sisu/v4/shared_sisupod_source.rb index eede4e15..38213858 100644 --- a/lib/sisu/v4/shared_sisupod_source.rb +++ b/lib/sisu/v4/shared_sisupod_source.rb @@ -99,7 +99,7 @@ module SiSU_Source end end def directories - SiSU_Env::InfoEnv.new.sisupod_v3(@opt) + SiSU_Env::InfoEnv.new.sisupod_v4(@opt) end def images_extract(f,images) # consider using param info rgx_image=/(?:^|[^_\\])\{(?:\s*|\~\^\s+)(\S+?\.(?:png|jpg|gif)\b)/m @@ -141,6 +141,15 @@ module SiSU_Source end end end + gi=SiSU_Env::GetInit.new + unless FileTest.file?("#{@path_pod[:conf]}/#{gi.makefile_name}") + if gi.makefile \ + && FileTest.file?(gi.makefile) + FileUtils::mkdir_p(@path_pod[:conf]) unless FileTest.directory?(@path_pod[:conf]) + FileUtils::cp(gi.makefile,"#{@path_pod[:conf]}/#{gi.makefile_name}") + end + #get images from makefile, consider placing in param + end if images \ and images.length > 1 images=images.flatten.uniq @@ -163,7 +172,7 @@ module SiSU_Source images=images.uniq images.each do |i| if FileTest.file?("#{images_pwd}/#{i}") - FileUtils::cp("#{images_pwd}/#{i}","#{@path_pod[:image]}/#{i}") if FileTest.file?("#{images_pwd}/#{i}") + FileUtils::cp("#{images_pwd}/#{i}","#{@path_pod[:image]}/#{i}") else STDERR.puts %{\t*WARN* did not find image - "#{images_pwd}/#{i}" [#{__FILE__}:#{__LINE__}]} end end @@ -198,11 +207,9 @@ module SiSU_Source cpy= :no cpy=if f[:f] =~ /^#{@opt.f_pth[:lng_is]}\// \ or f[:f] =~ /~#{@opt.f_pth[:lng_is]}\.sst/ - 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 "#{@opt.base_path}/#{f[:f]} --> #{@path_pod[:doc]}/#{f[:n]}" :yes else :no end @@ -226,11 +233,9 @@ module SiSU_Source cpy= :no cpy=if f[:f] =~ /^#{@opt.f_pth[:lng_is]}\// \ or f[:f] =~ /~#{@opt.f_pth[:lng_is]}\.sst/ - 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 "#{@opt.base_path}/#{f[:f]} --> #{@path_pod[:doc]}/#{f[:n]}" :yes else :no end diff --git a/lib/sisu/v4/sysenv.rb b/lib/sisu/v4/sysenv.rb index 22a520f6..f1dfdb16 100644 --- a/lib/sisu/v4/sysenv.rb +++ b/lib/sisu/v4/sysenv.rb @@ -295,19 +295,28 @@ module SiSU_Env ] end def sisu_document_make + def makefile_name + S_CONF[:header_make] + end def makefile #if @markup_dir_changed_ rc_path_options.each do |v| - f='sisu_document_make' - if FileTest.exist?("#{v}/#{f}") - @@sisu_make_path=v - sisu_doc_makefile=IO.read("#{@@sisu_make_path}/#{f}", mode: 'r:utf-8') - @@sisu_doc_makefile=sisu_doc_makefile.split(/\s*\n\s*\n/m) + if FileTest.exist?("#{v}/#{makefile_name}") + @sisu_make_path=v break end end #end - @@sisu_doc_makefile + @sisu_make_file_path=@sisu_make_path \ + ? "#{@sisu_make_path}/#{makefile_name}" + : nil + end + def makefile_read + if makefile + sisu_doc_makefile=IO.read(makefile, mode: 'r:utf-8') + @sisu_doc_makefile=sisu_doc_makefile.split(/\s*\n\s*\n/m) + end + @sisu_doc_makefile end self end @@ -321,7 +330,7 @@ module SiSU_Env @@noyaml=true break else - f='sisurc.yml' + f=S_CONF[:rc_yml] if FileTest.exist?("#{v}/#{f}") require 'yaml' @@sisurc_path=v @@ -1131,6 +1140,52 @@ module SiSU_Env def stub_pod @stub_pod end + def sisupod_v4(opt) + #processing_path.processing + # sisupod + # doc/ + # manifest.txt + # en/content.sst [file content] + # fr/content.sst + # _sisu + # sisu_document_make + # image@ (ln -s ../../image) + # audio@ (ln -s ../../audio) + # video@ (ln -s ../../video) + # image/ [all images for specific document gathered here] + # audio/ + # video/ + spp="#{processing_path.processing}/#{Gt[:sisupod]}" + sppc="#{spp}/doc/_sisu" + lng_dirs=[] + if FileTest.directory?(spp) \ + or FileTest.file?(spp) + FileUtils::rm_rf(spp) + end + paths=[] + flv=SiSU_Env::EnvCall.new(opt.fns).document_language_versions_found + flv[:f].each {|l| lng_dirs << l[:l] } + lng_dirs.uniq.each do |lng| + paths << "#{spp}/doc/#{lng}" + end + paths \ + << "#{spp}/image" + #<< "#{spp}/audio" \ + #<< "#{spp}/video" \ + paths.each do |x| + unless FileTest.directory?(x) + FileUtils::mkdir_p(x) + end + end + if FileTest.directory?(sppc) + pwd=Dir.pwd + Dir.chdir(sppc) + FileUtils::ln_s('../../image', 'image') + #FileUtils::ln_s('../../audio', 'audio') + #FileUtils::ln_s('../../video', 'video') + Dir.chdir(pwd) + end + end def sisupod_v3(opt) #processing_path.processing # sisupod |