diff options
author | Ralph Amissah <ralph@amissah.com> | 2012-06-17 22:55:11 -0400 |
---|---|---|
committer | Ralph Amissah <ralph@amissah.com> | 2012-06-17 22:55:11 -0400 |
commit | 2970a5d30e3d59f60af9f96c258c84d138027e07 (patch) | |
tree | d2e972aebae388b847576ce368cf41ef80672840 | |
parent | debian/changelog (3.2.12-1) (diff) | |
parent | v3: shared_sisupod_source, common build for sisu (markup) source representations (diff) |
Merge tag 'sisu_3.3.0' into debian/sid
-rw-r--r-- | data/doc/sisu/CHANGELOG_v3 | 23 | ||||
-rw-r--r-- | data/sisu/v3/v/version.yml | 6 | ||||
-rw-r--r-- | lib/sisu/v3/constants.rb | 18 | ||||
-rw-r--r-- | lib/sisu/v3/git.rb | 50 | ||||
-rw-r--r-- | lib/sisu/v3/hub.rb | 79 | ||||
-rw-r--r-- | lib/sisu/v3/manifest.rb | 6 | ||||
-rw-r--r-- | lib/sisu/v3/options.rb | 22 | ||||
-rw-r--r-- | lib/sisu/v3/param.rb | 2 | ||||
-rw-r--r-- | lib/sisu/v3/po4a.rb | 4 | ||||
-rw-r--r-- | lib/sisu/v3/share_src.rb | 37 | ||||
-rw-r--r-- | lib/sisu/v3/shared_sisupod_source.rb | 377 | ||||
-rw-r--r-- | lib/sisu/v3/sisupod_make.rb | 305 | ||||
-rw-r--r-- | lib/sisu/v3/sysenv.rb | 118 | ||||
-rw-r--r-- | lib/sisu/v3/urls.rb | 8 |
14 files changed, 616 insertions, 439 deletions
diff --git a/data/doc/sisu/CHANGELOG_v3 b/data/doc/sisu/CHANGELOG_v3 index 3310f20e..4e9298af 100644 --- a/data/doc/sisu/CHANGELOG_v3 +++ b/data/doc/sisu/CHANGELOG_v3 @@ -13,13 +13,30 @@ Reverse Chronological: %% Development branch UNSTABLE v3 branch once stable will supersede & replace current stable v2 branch +%% 3.3.0.orig.tar.xz (2012-06-17:24/7) +http://git.sisudoc.org/?p=code/sisu.git;a=log;h=refs/tags/sisu_3.3.0 +http://git.sisudoc.org/?p=code/sisu.git;a=log;h=refs/tags/debian/sisu_3.3.0-1 +http://www.jus.uio.no/sisu/pkg/src/sisu_3.3.0.orig.tar.xz + sisu_3.3.0.orig.tar.xz + sisu_3.3.0-1.dsc + sisu_3.3.0-1.debian.tar.gz + + * v3: shared_sisupod_source, common build for sisu (markup) source representations + to be used by sisupod.txz, git, (and src) + * sisupod_make (--sisupod) + * share_source (--source) + NOTE not used git at present + * changed representation of shared sisu source, include related files in + directory rather than just markup file [reason for version bump] + NOTE there are no changes to sisu markup (only the sharing of source files) + %% 3.2.12.orig.tar.xz (2012-06-06:23/3) http://git.sisudoc.org/?p=code/sisu.git;a=log;h=refs/tags/sisu_3.2.12 http://git.sisudoc.org/?p=code/sisu.git;a=log;h=refs/tags/debian/sisu_3.2.12-1 http://www.jus.uio.no/sisu/pkg/src/sisu_3.2.12.orig.tar.xz - sisu_3.2.12.orig.tar.xz - sisu_3.2.12-1.dsc - sisu_3.2.12-1.debian.tar.gz + b65d092d99c8b0695ffe55047082f0b903090185b01874660eb35876814787bc 1689100 sisu_3.2.12.orig.tar.xz + af00de9088c0291f7afa5310bc2e4da6e43dfd8a01fa35e988f42a4e63dd4795 1389 sisu_3.2.12-1.dsc + 3005baaad8b61cca00c72f91c602e17524ee99096a103bc38282c863178d2d84 297163 sisu_3.2.12-1.debian.tar.gz * v3: hub, post bundles * sisupod_make, file selection selection for tar.xz, fix diff --git a/data/sisu/v3/v/version.yml b/data/sisu/v3/v/version.yml index 2583de45..1d8fbff1 100644 --- a/data/sisu/v3/v/version.yml +++ b/data/sisu/v3/v/version.yml @@ -1,5 +1,5 @@ --- -:version: 3.2.12 -:date_stamp: 2012w23/3 -:date: "2012-06-06" +:version: 3.3.0 +:date_stamp: 2012w24/7 +:date: "2012-06-17" :project: SiSU diff --git a/lib/sisu/v3/constants.rb b/lib/sisu/v3/constants.rb index c95178ea..2921b670 100644 --- a/lib/sisu/v3/constants.rb +++ b/lib/sisu/v3/constants.rb @@ -195,6 +195,7 @@ Px={ lv5: '.', lv6: '.', } +Px[:lng_lst_rgx]=Px[:lng_lst].join('|') Ep={ d_oebps: 'OEBPS', f_ncx: 'toc.ncx', @@ -223,16 +224,21 @@ Db={ col_info_note: 2500, } Gt={ - grotto: 'sisu:', + grotto: 'sisu_src', + git: 'sisu:', src: 'src', + pods: 'pods', + sisupod: 'sisupod', pod: 'pod', + files: 'files', + doc: 'doc', po: 'po4a/po', pot: 'po4a/pot', - image: 'mm/image', - audio: 'mm/audio', - video: 'mm/video', - conf: 'conf', - skin: 'conf/skin', #Gt[:skin: 'conf/skin/doc' + image: 'image', + audio: 'audio', + video: 'video', + conf: 'doc/_sisu', + skin: 'doc/_sisu/skin', #Gt[:skin: 'conf/skin/doc' } DISABLE={ epub: { diff --git a/lib/sisu/v3/git.rb b/lib/sisu/v3/git.rb index 313b46a9..7c0d573a 100644 --- a/lib/sisu/v3/git.rb +++ b/lib/sisu/v3/git.rb @@ -86,15 +86,15 @@ module SiSU_Git lng=(@md.opt.lng) ? (@md.opt.lng) : (@md.i18n[0]) @git_path={ fnb: git_path_fnb, - src: git_path_fnb + '/' + Gt[:src] + '/' + lng, + doc: git_path_fnb + '/' + Gt[:sisupod] + '/' + Gt[:doc] + '/' + lng, po: git_path_fnb + '/' + Gt[:po] + '/' + lng, pot: git_path_fnb + '/' + Gt[:pot], - conf: git_path_fnb + '/' + Gt[:conf], - skin: git_path_fnb + '/' + Gt[:skin], - image: git_path_fnb + '/' + Gt[:image], - audio: git_path_fnb + '/' + Gt[:audio], - video: git_path_fnb + '/' + Gt[:video], - conf: git_path_fnb + '/' + Gt[:conf] + conf: git_path_fnb + '/' + Gt[:sisupod] + '/' + Gt[:conf], + skin: git_path_fnb + '/' + Gt[:sisupod] + '/' + Gt[:skin], + image: git_path_fnb + '/' + Gt[:sisupod] + '/' + Gt[:image], + audio: git_path_fnb + '/' + Gt[:sisupod] + '/' + Gt[:audio], + video: git_path_fnb + '/' + Gt[:sisupod] + '/' + Gt[:video], + conf: git_path_fnb + '/' + Gt[:sisupod] + '/' + Gt[:conf] } SiSU_DAL::Source.new(@opt).read # -m end @@ -107,9 +107,9 @@ module SiSU_Git def read create_file_structure_git populate.sisusrc_files - if program_found? - git_commit - end + #if program_found? + # git_commit + #end unless @opt.cmd =~/q/ @opt.cmd=~/[MVvz]/ \ ? SiSU_Screen::Ansi.new(@opt.cmd,'Git path',@git_path[:fnb]).green_hi_blue @@ -123,7 +123,7 @@ module SiSU_Git end def make_dir_fnb FileUtils::mkdir_p(@git_path[:fnb]) unless FileTest.directory?(@git_path[:fnb]) - FileUtils::mkdir_p(@git_path[:src]) unless FileTest.directory?(@git_path[:src]) + FileUtils::mkdir_p(@git_path[:doc]) unless FileTest.directory?(@git_path[:doc]) FileUtils::mkdir_p(@git_path[:po]) unless FileTest.directory?(@git_path[:po]) FileUtils::mkdir_p(@git_path[:pot]) unless FileTest.directory?(@git_path[:pot]) FileUtils::mkdir_p(@git_path[:conf]) unless FileTest.directory?(@git_path[:conf]) @@ -141,14 +141,16 @@ module SiSU_Git end end def git_commit - if FileTest.directory?("#{@git_path[:fnb]}") - pwd=Dir.pwd - Dir.chdir(@git_path[:fnb]) - system(" - git add . \ - && git commit -a - ") - Dir.chdir(pwd) + if program_found? + if FileTest.directory?("#{@git_path[:fnb]}") + pwd=Dir.pwd + Dir.chdir(@git_path[:fnb]) + system(" + git add . \ + && git commit -a + ") + Dir.chdir(pwd) + end end end def populate @@ -158,12 +160,12 @@ module SiSU_Git end def copy_src_head if @opt.f_pth[:lng] - FileUtils::cp_r("#{@env.path.pwd}/#{@opt.f_pth[:lng]}/#{@opt.fns}",@git_path[:src]) + FileUtils::cp_r("#{@env.path.pwd}/#{@opt.f_pth[:lng]}/#{@opt.fns}",@git_path[:doc]) elsif @opt.fns =~/\.ssm\.sst/ ssm=@opt.fns.gsub(/\.ssm\.sst/,'.ssm') - FileUtils::cp_r("#{@env.path.pwd}/#{ssm}",@git_path[:src]) + FileUtils::cp_r("#{@env.path.pwd}/#{ssm}",@git_path[:doc]) else - FileUtils::cp_r("#{@env.path.pwd}/#{@opt.fns}",@git_path[:src]) + FileUtils::cp_r("#{@env.path.pwd}/#{@opt.fns}",@git_path[:doc]) end end def copy_related_sst_ssi @@ -177,9 +179,9 @@ module SiSU_Git end doc_import.each do |f| if @opt.f_pth[:lng] - FileUtils::cp_r("#{@env.path.pwd}/#{@opt.f_pth[:lng]}/#{f}",@git_path[:src]) + FileUtils::cp_r("#{@env.path.pwd}/#{@opt.f_pth[:lng]}/#{f}",@git_path[:doc]) else - FileUtils::cp_r("#{@env.path.pwd}/#{f}",@git_path[:src]) + FileUtils::cp_r("#{@env.path.pwd}/#{f}",@git_path[:doc]) end end end diff --git a/lib/sisu/v3/hub.rb b/lib/sisu/v3/hub.rb index d5ab7bdd..f221c9a8 100644 --- a/lib/sisu/v3/hub.rb +++ b/lib/sisu/v3/hub.rb @@ -64,12 +64,11 @@ module SiSU class OptionLoopFiles def initialize(opt) @opt=opt - @r=Px[:lng_lst].join('|') + @r=Px[:lng_lst_rgx] end def loop_files_on_given_option @opt.files.each_with_index do |fno,i| - @opt.fns=fno - @opt.fno=fno + @opt.fno,@opt.fns=fno,fno @opt.f_pth=@opt.f_pths[i] if fno !~/\.-sst$/ @opt.pth=@opt.paths[i] @@ -113,7 +112,7 @@ module SiSU end end def manifest_on_files_translated - r=Px[:lng_lst].join('|') + r=Px[:lng_lst_rgx] number_of_files={} @opt.files.each_with_index do |fns,i| fn=fns.gsub(/(?:~(?:#{@r}))?\.ss[tm]$/,'') @@ -385,14 +384,6 @@ p "#{__LINE__}:#{__FILE__}" if @opt.act[:maintenance][:set] ==:on SiSU_DAL::Source.new(@opt).read end end - if @opt.act[:share_source][:set]==:on - if @opt.fno =~/\.ssm$/ - SiSU_Screen::Ansi.new(@opt.cmd,'WARNING: share text source (--source) not available for composite files (.ssm),', 'composite (.ssm) source documents may be shared as a sisupod (--sisupod) (.txz)').warn unless @opt.cmd =~/q/ - else - requires('share_src') # -s share_src.rb - SiSU_Markup::Source.new(@opt).read - end - end if @opt.act[:qrcode][:set]==:on #% --qrcode, -Q requires('qrcode') # -Q qrcode.rb SiSU_QRcode::Source.new(@opt).read @@ -468,34 +459,66 @@ p "#{__LINE__}:#{__FILE__}" if @opt.act[:maintenance][:set] ==:on end end def post_loop_files_on_given_option_do - if @opt.act[:sisupod][:set]==:on #% --sisupod, -S make sisupod - requires('sisupod_make') # -S sisupod_make.rb + if @opt.act[:share_source][:set]==:on \ + or @opt.act[:sisupod][:set]==:on \ + or @opt.act[:git][:set]==:on begin + requires('shared_sisupod_source') OptionLoopFiles.new(@opt).loop_files_on_given_option do - SiSU_Doc::Source.new(@opt).read + SiSU_Source::SiSUpodSource.new(@opt).read + end + if @opt.act[:share_source][:set]==:on +#REDO + requires('share_src') # -s share_src.rb + begin + ensure + OptionLoopFiles.new(@opt).loop_files_on_given_option_bundle do + SiSU_Markup::Source.new(@opt).read + end + end + end + if @opt.act[:sisupod][:set]==:on #% --sisupod, -S make sisupod + requires('sisupod_make') # -S sisupod_make.rb + begin + ensure + OptionLoopFiles.new(@opt).loop_files_on_given_option_bundle do + SiSU_Doc::Source.new(@opt).sisupod_tar_xz + end + end + end + if @opt.act[:git][:set]==:on #% --git, -g sisu git + requires('git') # -g git.rb + begin + OptionLoopFiles.new(@opt).loop_files_on_given_option do + SiSU_Git::Source.new(@opt).read + end + ensure + OptionLoopFiles.new(@opt).loop_files_on_given_option_bundle do + SiSU_Git::Source.new(@opt).git_commit + end + end end ensure - OptionLoopFiles.new(@opt).loop_files_on_given_option_bundle do - SiSU_Doc::Source.new(@opt).sisupod_tar_xz + path_pod=@env.processing_path.processing_sisupod(@opt).paths + unless @opt.cmd =~/M/ + FileUtils::rm_rf("#{path_pod[:sisupod]}/*") if FileTest.directory?(path_pod[:sisupod]) + #FileUtils::rm_rf("#{path_pod[:fnb]}/*") if FileTest.directory?(path_pod[:fnb]) end end end - if @opt.act[:images][:set]==:on #% --images, -j - requires('shared_images') - OptionLoopFiles.new(@opt).loop_files_on_given_option do - SiSU_Images::Source.new(@opt).read # -j shared_images.rb - end - end if @opt.act[:po4a][:set]==:on #% --po4a, -P requires('po4a') - OptionLoopFiles.new(@opt).loop_files_on_given_option do - SiSU_Po4a::Source.new(@opt).read # -P po4a.rb + begin + OptionLoopFiles.new(@opt).loop_files_on_given_option do + SiSU_Po4a::Source.new(@opt).read # -P po4a.rb + end + ensure end end - if @opt.act[:git][:set]==:on #% --git, -g sisu git - requires('git') + if @opt.act[:images][:set]==:on #% --images, -j + requires('shared_images') OptionLoopFiles.new(@opt).loop_files_on_given_option do - SiSU_Git::Source.new(@opt).read # -g git.rb + SiSU_Images::Source.new(@opt).read # -j shared_images.rb end end if @opt.cmd =~/T/ #% -T termsheet/standard form diff --git a/lib/sisu/v3/manifest.rb b/lib/sisu/v3/manifest.rb index 092418fb..20983d7f 100644 --- a/lib/sisu/v3/manifest.rb +++ b/lib/sisu/v3/manifest.rb @@ -475,12 +475,10 @@ WOK end end def source_tests - if @md.fns =~/\.ssm\.sst$/ #% decide whether to extract and include requested/required documents - req=@md.fns + if @md.fno =~/\.ssm$/ #% decide whether to extract and include requested/required documents if FileTest.file?(@f.place_file.src.dir)==true pth=@f.output_path.src.dir - rel=@f.output_path.src.rel - #rel=@f.output_path.src.rel_sm + rel=@f.output_path.src.rel_sm url=@f.output_path.src.url id,file='Markup Composite File (SiSU source)',@f.base_filename.src summarize_sources(id,file,pth,rel,url) diff --git a/lib/sisu/v3/options.rb b/lib/sisu/v3/options.rb index c7789f3a..7aa3622d 100644 --- a/lib/sisu/v3/options.rb +++ b/lib/sisu/v3/options.rb @@ -61,16 +61,16 @@ module SiSU_Commandline require_relative 'sysenv' # sysenv.rb @@base_path=nil 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,:fncb,:lng,:lng_base,:what + 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 def initialize(a) - @cmd,@f_pth,@pth,@fno,@fns,@fnb,@fnc,@fncb,@what,@lng,@lng_base,@base_path,@base_stub,@sub_location='','','','','','','','','','','','','','' + @cmd,@f_pth,@pth,@fno,@fns,@fnb,@fnc,@fng,@fncb,@what,@lng,@lng_base,@base_path,@base_stub,@sub_location='','','','','','','','','','','','','','' @f_pths,@files,@files_mod,@paths,@mod,@act=Array.new(5){[]} @env=SiSU_Env::InfoEnv.new @lng_base=@env.language_default_set @dir_structure_by=SiSU_Env::EnvCall.new.output_dir_structure.by? @@base_path ||=Dir.pwd @base_path=@@base_path - r=Px[:lng_lst].join('|') + r=Px[:lng_lst_rgx] u=/.+?\/([^\/]+)(?:\/(?:#{r})$|$)/ @base_stub=@base_path.gsub(u,'\1') @a=sisu_glob_rules(a) @@ -139,8 +139,7 @@ module SiSU_Commandline end end end - r=Px[:lng_lst].join('|') - r=r.gsub(/\|#{@lng_base}\|/,'|') + r=Px[:lng_lst_rgx].gsub(/\|#{@lng_base}\|/,'|') @lang_regx=%r{(?:#{r})} z=if find_flag (f.length > 0) \ @@ -225,7 +224,7 @@ module SiSU_Commandline chdir #{pwd} ") Dir.chdir(pt.realpath.to_s + '/sisupod/doc') - r=Px[:lng_lst].join('|') + r=Px[:lng_lst_rgx] Dir.entries("#{fullname}/sisupod/doc").each do |d_lng| if d_lng =~/^(?:#{r})$/ Dir.chdir(pt.realpath.to_s + "/sisupod/doc/#{d_lng}") @@ -816,12 +815,21 @@ module SiSU_Commandline @lng_base end def fno - @fno=if @fno and not @fno.empty? + @fno=if @fno \ + and not @fno.empty? @fno else fns[/(.+?(?:sst|ssm))(?:\.sst)?/,1] end end + def fng + @fng=if @fng \ + and not @fng.empty? + @fng + else + fno.gsub(/(?:~(?:#{Px[:lng_lst_rgx]}))?(\.ss[tm])$/,'\1') + end + end def fns @fns end diff --git a/lib/sisu/v3/param.rb b/lib/sisu/v3/param.rb index 78e42bd4..f6084aab 100644 --- a/lib/sisu/v3/param.rb +++ b/lib/sisu/v3/param.rb @@ -1054,7 +1054,7 @@ module SiSU_Param attr_accessor :make,:env,:path,:file,:fn,:fns,:fno,:fnb,:fnn,:fnt,:fnl,:flv,:fnz,:fnstex,:ocn,:sfx_src,:pdf,:file_type,:dir_out,:dir_tex,:dir_lout,:txt_path,:site_skin,:sisu,:sisu_version,:ruby_version,:title,:subtitle,:full_title,:html_title,:subtitle_tex,:creator,:classify,:author_home,:author,:author_title,:author_nationality,:authors,:authorship,:translator,:illustrator,:prepared_by,:digitized_by,:subject,:description,:publisher,:current_publisher,:contributor,:date,:date_created,:date_issued,:date_available,:date_valid,:date_modified,:date_translated,:date_added_to_site,:date_scheme,:date_created_scheme,:date_issued_scheme,:date_available_scheme,:date_valid_scheme,:date_modified_scheme,:type,:format,:identifier,:source,:language,:language_original,:relation,:coverage,:rights,:keywords,:comments,:abstract,:cls_loc,:cls_dewey,:cls_pg,:cls_isbn,:papersize,:papersize_array,:toc,:lv1,:lv2,:lv3,:lv4,:lv5,:lv6,:lvs,:pagenew,:pagebreak,:num_top,:toc_lev_limit,:flag_endnotes,:flag_auto_endnotes,:flag_separate_endnotes,:flag_separate_endnotes_make,:markup,:markup_instruction,:markup_version,:markup_declared,:flag_tables,:vocabulary,:doc_skin,:doc_css,:yaml,:lnk,:links,: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,:filesize,:user,:home,:hostname,:pwd,:firstseg,:programs,:author_copymark,:i18n,:lang,:lang_code_insert,:en,:notes,: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,:ec,:opt,:sem_tag,:book_idx,:topic_register,:topic_register_array,:original,:writing_focus,:audio,:daisy def initialize(fns_array,opt) @env=@path,@file=@fn=@fns=@fno=@fnb=@fnn=@fnt=@fnl=@flv=@fnz=@fnstex=@ocn=@sfx_src=@pdf=@file_type=@dir_out=@dir_tex=@dir_lout=@txt_path=@make=@flag_endnotes=@flag_auto_endnotes=@flag_separate_endnotes=@flag_separate_endnotes_make=@site_skin=@sisu=@sisu_version=@ruby_version=@title=@subtitle=@full_title=@html_title=@subtitle_tex=@creator=@classify=@author_home=@author=@author_title=@author_nationality=@translator=@illustrator=@prepared_by=@digitized_by=@subject=@description=@publisher=@current_publisher=@contributor=@date=@date_created=@date_issued=@date_available=@date_valid=@date_modified=@date_translated=@date_added_to_site=@date_scheme=@date_created_scheme=@date_issued_scheme=@date_available_scheme=@date_valid_scheme=@date_modified_scheme=@type=@format=@identifier=@source=@language=@language_original=@relation=@coverage=@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_tables=@vocabulary=@doc_skin=@doc_css=@yaml=@lnk=@links=@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=@filesize=@firstseg=@programs=@author_copymark=@i18n=@lang=@lang_code_insert=@en=@notes=@dgst=@dgst_skin=@generated=@heading_seg_first=@base_program=@topic_register=@original=@writing_focus=@audio=nil - @data,@path,@fns,@opt=fns_array,opt.pth,opt.fns,opt #@data used as data + @data,@path,@fns,@fno,@opt=fns_array,opt.pth,opt.fns,opt.fno,opt #@data used as data @flag_tables,@set_header_title,@set_heading_top,@set_heading_seg,@heading_seg_first_flag,@flag_promo,@book_idx=false,false,false,false,false,false,false @seg_autoname_safe=true @daisy,@sem_tag=false,false diff --git a/lib/sisu/v3/po4a.rb b/lib/sisu/v3/po4a.rb index da066daf..7ce825ee 100644 --- a/lib/sisu/v3/po4a.rb +++ b/lib/sisu/v3/po4a.rb @@ -60,6 +60,7 @@ module SiSU_Po4a require_relative 'dal' # dal.rb require_relative 'sysenv' # sysenv.rb include SiSU_Env + require_relative 'composite' # composite.rb require_relative 'shared_metadata' # shared_metadata.rb require_relative 'po4a_set' # po4a_set.rb include SiSU_Param @@ -72,8 +73,7 @@ module SiSU_Po4a #unless @opt.fns =~/(.+?\.(?:-|ssm\.)?sst)$/ # puts "#{@opt.fns} not a processed file type" #end - r=Px[:lng_lst].join('|') - r=r.gsub(/\|en\|/,'|') + r=Px[:lng_lst_rgx].gsub(/\|en\|/,'|') @lang_regx=%r{(?:#{r})} if opt.fns =~/\S+?~#{@lang_regx}\.ss[mti]/ \ and opt.f_pth[:lng]!=@opt.lng_base diff --git a/lib/sisu/v3/share_src.rb b/lib/sisu/v3/share_src.rb index c4900f5f..2c446ecb 100644 --- a/lib/sisu/v3/share_src.rb +++ b/lib/sisu/v3/share_src.rb @@ -56,42 +56,31 @@ =end module SiSU_Markup + require_relative 'shared_sisupod_source' # shared_sisupod_source.rb + include SiSU_Source require_relative 'sysenv' # sysenv.rb include SiSU_Env pwd=Dir.pwd - class Source - def initialize(opt) + class Source < SiSU_Source::SiSUpodSource + def initialize(opt,build=nil,place=nil) + super(opt,build,place) @opt=opt - @env=SiSU_Env::InfoEnv.new(@opt.fns) - md=SiSU_Param::Parameters.new(@opt).get - @file=SiSU_Env::FileOp.new(md) - stub=@opt.fnb.gsub(/~[a-z]+$/,'') end def read unless @opt.cmd =~/q/ @opt.cmd=~/[MVvz]/ \ ? SiSU_Screen::Ansi.new(@opt.cmd,'Share Document Source!',@opt.fns).green_hi_blue : SiSU_Screen::Ansi.new(@opt.cmd,'Share Document Source!',@opt.fns).green_title_hi - SiSU_Screen::Ansi.new(@opt.cmd,"Copy sisu markup file to output directory","#{@opt.fns} -> #{@file.output_path.src.dir}").warn if @opt.cmd =~/[MVv]/ + SiSU_Screen::Ansi.new(@opt.cmd,"Copy sisu markup file to output directory","#{@opt.fno} -> #{@file.output_path.src.dir}").warn if @opt.cmd =~/[MVv]/ end - FileUtils::mkdir_p(@file.output_path.src.dir) unless FileTest.directory?(@file.output_path.src.dir) - if FileTest.directory?(@file.output_path.src.dir) - unless @opt.fns =~/\.ssm$/ - if FileTest.file?(@opt.fns) - FileUtils::cp(@opt.fns,@file.output_path.src.dir) - else STDERR.puts %{\t*WARN* did not find - "#{@opt.fns}"} - end - else - req=@opt.fns.gsub(/(.+?\.ssm)$/,'\1.sst') - file="#{@env.processing_path.composite_file}/#{@opt.fnb}.ssm.sst" - if FileTest.file?(file) - FileUtils::cp(file,"#{@file.output_path.src.dir}/#{req}") - else STDERR.puts "*WARN* did not find #{file} to copy" - end - end + if FileTest.directory?(@path_pod[:fnb]) + FileUtils::mkdir_p(@file.output_path.src.dir) unless FileTest.directory?(@file.output_path.src.dir) + v=(@opt.cmd =~/M/) ? 'v' : '' + system(%{ + rsync -a#{v} #{@path_pod[:fnb]} #{@file.output_path.sisupod.dir} + }) else - SiSU_Screen::Ansi.new(@opt.cmd,"*WARN* Output directory does not exist","#{@opt.fns} -> #{@file.output_path.src.dir}").warn if @opt.cmd =~/[MVv]/ - exit + SiSU_Screen::Ansi.new('',"#{@opt.fno} not available").blue_tab if @opt.cmd=~/[MVv]/ end end end diff --git a/lib/sisu/v3/shared_sisupod_source.rb b/lib/sisu/v3/shared_sisupod_source.rb new file mode 100644 index 00000000..2aff984c --- /dev/null +++ b/lib/sisu/v3/shared_sisupod_source.rb @@ -0,0 +1,377 @@ +# encoding: utf-8 +=begin + + * Name: SiSU + + * Description: a framework for document structuring, publishing and search + + * Author: Ralph Amissah + + * Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2007, 2008, 2009, 2010, 2011, 2012 Ralph Amissah, All Rights Reserved. + + * License: GPL 3 or later: + + SiSU, a framework for document structuring, publishing and search + + Copyright (C) Ralph Amissah + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along with + this program. If not, see <http://www.gnu.org/licenses/>. + + If you have Internet connection, the latest version of the GPL should be + available at these locations: + <http://www.fsf.org/licensing/licenses/gpl.html> + <http://www.gnu.org/licenses/gpl.html> + + <http://www.sisudoc.org/sisu/en/manifest/gpl.fsf.html> + + * SiSU uses: + * Standard SiSU markup syntax, + * Standard SiSU meta-markup syntax, and the + * Standard SiSU object citation numbering and system + + * Hompages: + <http://www.jus.uio.no/sisu> + <http://www.sisudoc.org> + + * Download: + <http://www.sisudoc.org/sisu/en/SiSU/download.html> + + * Ralph Amissah + <ralph@amissah.com> + <ralph.amissah@gmail.com> + + ** Description: create sisupod filetype and copy it to output directory! + +=end +module SiSU_Source + include SiSU_Env + class SiSUpodSource + require_relative 'sysenv' # sysenv.rb + require_relative 'particulars' # particulars.rb + def initialize(opt,build=nil,place=nil) + @opt=opt + m=/.+\/(?:src\/)?(\S+)/im + @date=SiSU_Env::InfoDate.new.dt + @env=SiSU_Env::InfoEnv.new(@opt.fns) + @ver=SiSU_Env::InfoVersion.instance.get_version + @v=(@opt.cmd =~/[VM]/) ? 'v' : '' + @particulars=SiSU_Particulars::CombinedSingleton.instance.get_all(opt) + @file=@particulars.file + @local_path="#{@file.output_path.sisupod.dir}" + processing_sisupod=@env.processing_path.processing_sisupod(@opt) + processing_sisupod.make + path_pod=processing_sisupod.paths[:sisupod] + path_pod_fnb=processing_sisupod.paths[:fnb] + FileUtils::mkdir_p(path_pod) unless FileTest.directory?(path_pod) + @path_pod={ + fnb: path_pod_fnb, + pod: path_pod, + doc: path_pod + '/' + Gt[:doc] + '/' + @opt.lng, + po: path_pod + '/' + Gt[:po] + '/' + @opt.lng, + pot: path_pod + '/' + Gt[:pot], + conf: path_pod + '/' + Gt[:conf], + skin: path_pod + '/' + Gt[:skin], + image: path_pod + '/' + Gt[:image], + audio: path_pod + '/' + Gt[:audio], + video: path_pod + '/' + Gt[:video], + conf: path_pod + '/' + Gt[:conf] + } + end + def read + unless @opt.cmd =~/q/ + @opt.cmd=~/[MVv]/ \ + ? SiSU_Screen::Ansi.new(@opt.cmd,'Assemble SiSU source',"[#{@opt.f_pth[:lng_is]}] #{@opt.fno}").green_hi_blue + : '' + end + unless @opt.fns.empty? + directories + pod_source_build #this needs to be built in case of multi-lingual for all of them, before single pass tar + end + end + def directories + SiSU_Env::InfoEnv.new.sisupod_v3(@opt) + end + def select_skin(skin='') #skin loading logic here + load "#{SiSU_lib}/defaults.rb" + @skin={} + skin_path = [ + "#{@env.path.pwd}/_sisu/skin", + "#{@env.path.home}/.sisu/skin", + '/etc/sisu/skin', + "#{@path_pod[:pod]}/external_document/skin" #CHECK + ] + sk_doc,sk_dir="#{Gt[:doc]}/#{skin}.rb","dir/skin_#{@env.stub_pwd}.rb" + skin_path.each do |v| #document skin priority 1 + if FileTest.file?("#{v}/#{sk_doc}") + @skin={ name_path: "#{v}/#{sk_doc}", type: :doc } + break + end + end + unless @skin.length > 0 + skin_path.each do |v| #directory skin priority 2 + if FileTest.file?("#{v}/#{sk_dir}") + @skin={ name_path: "#{v}/#{sk_dir}", type: :dir } + break + end + end + end + @skin + end + def images_extract(f,images) # consider using param info + rgx_image=/(?:^|[^_\\])\{(?:\s*|\~\^\s+)(\S+?\.(?:png|jpg|gif)\b)/m + if f !~/^%+\s/ \ + and f =~rgx_image + images << f.scan(rgx_image).uniq + end + images.flatten + end + def pod_source_build + @pwd=Dir.pwd + @rgx_rb_image=/["']\S*?([a-zA-Z0-9_-]+?\.(?:png|jpg|gif))["']/ + @rgx_image=/(?:^|[^_\\])\{\s*(\S+?\.(?:png|jpg|gif))/ + @rgx_skin=/^\s+:skin:\s+(\S+)/ + @rgx_doc_import=/^<<\s*(\S+?\.ss[ti])/ + file_array=IO.readlines(@opt.fno,'') + skin,images,doc_import=[],[],[] + doc_import_dir=@opt.sub_location + file_array.each do |f| #% work area + if f !~/^%+\s/ + skin << f.scan(@rgx_skin).uniq.flatten if f =~@rgx_skin + f=f.gsub(/<:=(\S+?)>/,'{ c_\1.png 14x14 }image') # embedded symbol (image) + if f !~/^%+\s/ \ + and f =~@rgx_image + images=images_extract(f,images) + end + if @opt.fno =~/\.ssm$/ + doc_import << f.scan(@rgx_doc_import) if f =~@rgx_doc_import + end + end + end + if doc_import.length > 0 + doc_import=doc_import.uniq.flatten + doc_import.each do |fn| + file_array=IO.readlines(fn,'') + file_array.each do |f| #% work area + if f !~/^%+\s/ \ + and f =~@rgx_image + images=images_extract(f,images) + end + end + end + end + docskin=nil + if skin \ + and skin.length > 0 + docskin=skin.pop.flatten.join + skin_source=select_skin(docskin) + else + skin_source=select_skin + end + docskin_place="#{@path_pod[:skin]}/#{skin_source[:type].to_s}" + FileUtils::mkdir_p(docskin_place) + if skin_source[:type] == :dir + docskin_with_path="#{docskin_place}/skin_#{@env.stub_pwd}.rb" + docskin=[docskin_with_path.gsub(/.+?\/(skin_\S+?)\.rb/,'\1')] + docskin='skin_sisupod' + end + if skin_source \ + and skin_source[:name_path] + unless skin_source[:name_path].nil? \ + or skin_source[:name_path].empty? + if FileTest.file?(skin_source[:name_path]) + FileUtils::cp(skin_source[:name_path],"#{docskin_place}/#{docskin}.rb") + skinfile_array=IO.readlines(skin_source[:name_path],'') + para_images=[] + skinfile_array.each do |f| #% work area + unless f =~/^%+ / #hmmm + images << f.scan(@rgx_rb_image).uniq if f =~@rgx_rb_image + #does not really discriminate, may duplicate images in sisu file, and may take images from default image pool + end + end + else STDERR.puts %{\t*WARN* did not find - "#{skin_source[:name_path]}" [#{__FILE__}:#{__LINE__}]} + end + end + end + #1. mapping in doc dir? + #2. need images used by skin, scan skin?? + if images \ + and images.length > 1 + images=images.flatten.uniq + images.delete_if {|x| x =~/https?:\/\// } + #images=images.sort + FileUtils::mkdir_p(@path_pod[:image]) + #unattractive hard coding ... ! + image_path='_sisu/image' + images_pwd="#{@env.path.pwd}/#{image_path}" + ##sequence copies base images, defaults used in all html outputs + #image_source_base='/usr/share/sisu/image' + #dir_pwd=Dir.pwd + #Dir.chdir(image_source_base) + #base_images=Dir.glob('*') + #base_images.each do |i| + # FileUtils::cp_r(i,"#{images_path_pod}/#{i}") + #end + #Dir.chdir(dir_pwd) + if FileTest.directory?(images_pwd) + 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}") + else STDERR.puts %{\t*WARN* did not find image - "#{images_pwd}/#{i}" [#{__FILE__}:#{__LINE__}]} + end + end + else STDERR.puts %{\t*WARN* did not find - #{images_pwd} #{@path_pod[:image]} [#{__FILE__}:#{__LINE__}]} + end + end + if doc_import.length > 0 \ + and @opt.fno =~/\.ssm$/ + doc_import.each do |f| + if FileTest.file?("#{@env.path.pwd}#{doc_import_dir}/#{f}") + FileUtils::cp("#{@env.path.pwd}#{doc_import_dir}/#{f}","#{@path_pod[:doc]}/#{f}") + else STDERR.puts %{\t*WARN* did not find image - "#{@env.path.pwd}#{doc_import_dir}/#{f}" [#{__FILE__}:#{__LINE__}]} + end + end + end + x=@env.document_language_versions_found #check multiple document language versions (param not used) + if x[:f] \ + and x[:f].length > 0 #store multiple document language versions, sisupod + x[:f].each do |f| + FileUtils::mkdir_p(@path_pod[:doc]) unless FileTest.directory?(@path_pod[:doc]) + if f[:f] =~/\~(\S{2,3})\.ss[tm]$/ + lng_f=$1 + if @opt.lng == lng_f + if @opt.fno =~/\.ssm$/ + if FileTest.file?("#{@env.path.pwd}#{doc_import_dir}/#{f[:f]}") + FileUtils::cp("#{@env.path.pwd}#{doc_import_dir}/#{f[:f]}", + "#{@path_pod[:doc]}/#{f[:n]}") + else STDERR.puts %{\t*WARN* did not find - "#{@env.path.pwd}#{doc_import_dir}/#{f[:f]}" [#{__FILE__}:#{__LINE__}]} + end + else + if FileTest.file?("#{@env.path.pwd}/#{f[:f]}") + cpy= :no + cpy=if f[:f] =~ /^#{@opt.f_pth[:lng_is]}\// \ + or f[:f] =~ /~#{@opt.f_pth[:lng_is]}\.sst/ + p "#{@env.path.pwd}/#{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 "#{@env.path.pwd}/#{f[:f]} --> #{@path_pod[:doc]}/#{f[:n]}" + :yes + else :no + end + if cpy == :yes + FileUtils::cp("#{@env.path.pwd}/#{f[:f]}", + "#{@path_pod[:doc]}/#{f[:n]}") + end + else STDERR.puts %{\t*WARN* did not find - "#{@env.path.pwd}/#{f[:f]}" [#{__FILE__}:#{__LINE__}]} + end + end + end + else + if @opt.fno =~/\.ssm$/ + if FileTest.file?("#{@env.path.pwd}#{doc_import_dir}/#{f[:f]}") + FileUtils::cp_r("#{@env.path.pwd}#{doc_import_dir}/#{f[:f]}", + "#{@path_pod[:doc]}/#{f[:n]}") + else STDERR.puts %{\t*WARN* did not find - "#{@env.path.pwd}#{doc_import_dir}/#{f[:f]}" [#{__FILE__}:#{__LINE__}]} + end + else + if FileTest.file?("#{@env.path.pwd}/#{f[:f]}") + cpy= :no + cpy=if f[:f] =~ /^#{@opt.f_pth[:lng_is]}\// \ + or f[:f] =~ /~#{@opt.f_pth[:lng_is]}\.sst/ + p "#{@env.path.pwd}/#{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 "#{@env.path.pwd}/#{f[:f]} --> #{@path_pod[:doc]}/#{f[:n]}" + :yes + else :no + end + if cpy == :yes + FileUtils::cp("#{@env.path.pwd}/#{f[:f]}", + "#{@path_pod[:doc]}/#{f[:n]}") + end + else STDERR.puts %{\t*WARN* did not find - "#{@env.path.pwd}/#{f[:f]}" [#{__FILE__}:#{__LINE__}]} + end + end + end + end + end #NB not all possibilies met, revisit, also in case of composite file may wish to add README + end + end +end +__END__ +question?: should you permit the packing of multiple documents in single .xz ? + + open @opt.fns, parse file + extract from file content: + images and copy each image from whatever image source to _sisu/sisupod/sisu/_sisu/image + skin and copy active skin from whatever source to _sisu/sisupod/sisu/_sisu/skin/doc + extract from skin images required by skin + + remove previously existing contents of _/sisu/sisupod & + make directory structure: + +v3 --> + _sisu + sisupod + doc + manifest.txt + en/content.sst [file content] + fr/content.sst + _sisu + conf + skin/ + doc [relevant skin if any other than default] + image (ln -s ../../image) + audio (ln -s ../../audio) + video (ln -s ../../video) + image [all images for specific document gathered here] + audio + video + +v2 --> + _sisu + sisupod + content.sst [file content] + filename.sst [link to content.sst] + _sisu/ + skin/ + doc [relevant skin if any other than default] + image/ [all images for specific document gathered here] + +sisu + _sisu + sisurc.yml + skin/ + dir/ + doc/ + misc/ + site/ + yaml/ + convert/ + standard_terms/ + image + processing + dal/ + tex/ + texinfo/ + tune/ + sisupod + +special case + +composite file (master), e.g. +SiSU.ssm diff --git a/lib/sisu/v3/sisupod_make.rb b/lib/sisu/v3/sisupod_make.rb index 984d807d..7b7957ab 100644 --- a/lib/sisu/v3/sisupod_make.rb +++ b/lib/sisu/v3/sisupod_make.rb @@ -56,285 +56,42 @@ =end module SiSU_Doc - include SiSU_Env - class Source - require_relative 'sysenv' # sysenv.rb + require_relative 'shared_sisupod_source' # shared_sisupod_source.rb + include SiSU_Source + require_relative 'sysenv' # sysenv.rb + include SiSU_Env + class Source < SiSU_Source::SiSUpodSource require_relative 'response' # response.rb - require_relative 'particulars' # particulars.rb - def initialize(opt) - @opt=opt - m=/.+\/(?:src\/)?(\S+)/im - @date=SiSU_Env::InfoDate.new.dt - @env=SiSU_Env::InfoEnv.new(@opt.fns) - @ver=SiSU_Env::InfoVersion.instance.get_version - @ans=SiSU_Response::Response.new - pod_path="#{@env.processing_path.processing_sisupod(@opt)}" - @v=(@opt.cmd =~/[VM]/) ? 'v' : '' - @particulars=SiSU_Particulars::CombinedSingleton.instance.get_all(opt) - @file=@particulars.file - @local_path="#{@file.output_path.sisupod.dir}" + def initialize(opt,build=nil,place=nil) + super(opt,build,place) @zipfile=@opt.fno.gsub(/(?:\~\S{2,3})?(\.ss[tm])$/,'\1') - FileUtils::mkdir_p(pod_path) unless FileTest.directory?(pod_path) - FileUtils::rm_rf("#{@env.processing_path.processing_sisupod(@opt)}/*") if FileTest.directory?("#{@env.processing_path.processing_sisupod(@opt)}") - end - def read - unless @opt.cmd =~/q/ - @opt.cmd=~/[MVv]/ \ - ? SiSU_Screen::Ansi.new(@opt.cmd,'Share SiSU Document (txz)',"[#{@opt.f_pth[:lng_is]}] #{@opt.fno}").green_hi_blue - : SiSU_Screen::Ansi.new(@opt.cmd,'Share SiSU Document (txz)',"[#{@opt.f_pth[:lng_is]}] #{@opt.fno}").green_title_hi - end - unless @opt.fns.empty? - if @opt.cmd=~/[MVv]/ - SiSU_Screen::Ansi.new(@opt.cmd,'Make sisu document (txz) and place in output directory',"#{@opt.fns} -> file://#{@file.output_path.sisupod.dir}/#{@zipfile}.txz").warn if @opt.cmd =~/[MVv]/ - end - directories - sisupod_build - #sisupod_tar_xz - else - if @opt.cmd =~/[MVv]/ - SiSU_Screen::Ansi.new(@opt.cmd,'Make (zip (txz)) of sisu work directory',"#{@env.stub_pwd}\_#{@date}.txz").warn - SiSU_Screen::Ansi.new(@opt.cmd,'').blue_tab - end - ans=@ans.response?('make sisupod of entire directory?') - if ans; sisupod_zip_directory - end - end - end - def sisupod_zip_directory - sisupod_directory="sisupod-#{@env.stub_pwd}-#{@date}.ssp" - unless File.symlink?('sisupod'); File.symlink(Dir.pwd,'sisupod') - end - re_base_dir='^sisupod/([^.][^/]*\.(ssm|ssi|sst)$|_sisu/)' - re_files='/[a-zA-Z0-9.~_-]+\.(ssm|ssi|sst|rb|css|png|jpg|gif|yaml)$' - re_ignore='/[.~_-][^/]+$' - if File.symlink?('sisupod') - info="SiSU sisupod #{@ver[:version]} directory contents #{sisupod_directory}" - system(%{ - echo "#{info}" - echo "#{info}" > sisu_zip.txt - zip -qz #{sisupod_directory} sisu_zip.txt < sisu_zip.txt - for I in `find -H sisupod -print | \ - egrep "#{re_base_dir}" | \ - egrep "#{re_files}" | \ - egrep -v "#{re_ignore}" ` - do zip #{sisupod_directory} $I - done - }) - else puts "the required systemlink 'sisupod' could not be created on the current directory: remove the file or directory named 'sisupod' within #{Dir.pwd}" - end - if @opt.cmd =~/[MVv]/ - SiSU_Screen::Ansi.new(@opt.cmd,'Share SiSU Document (tar xz)',@opt.fns).green_hi_blue - SiSU_Screen::Ansi.new(@opt.cmd,'Zipped directory (tgz)',sisupod_directory).warn - SiSU_Screen::Ansi.new('',sisupod_directory).blue_tab - end - end - def directories - SiSU_Env::InfoEnv.new.sisupod_v3(@opt) - end - def select_skin(skin='') #skin loading logic here - load "#{SiSU_lib}/defaults.rb" - @skin={} - skin_path = [ - "#{@env.path.pwd}/_sisu/skin", - "#{@env.path.home}/.sisu/skin", - '/etc/sisu/skin', - "#{@env.processing_path.processing_sisupod(@opt)}/external_document/skin" - ] - sk_doc,sk_dir="doc/#{skin}.rb","dir/skin_#{@env.stub_pwd}.rb" - skin_path.each do |v| #document skin priority 1 - if FileTest.file?("#{v}/#{sk_doc}") - @skin={ name_path: "#{v}/#{sk_doc}", type: :doc } - break - end - end - unless @skin.length > 0 - skin_path.each do |v| #directory skin priority 2 - if FileTest.file?("#{v}/#{sk_dir}") - @skin={ name_path: "#{v}/#{sk_dir}", type: :dir } - break - end - end - end - @skin - end - def images_extract(f,images) # consider using param info - rgx_image=/(?:^|[^_\\])\{(?:\s*|\~\^\s+)(\S+?\.(?:png|jpg|gif)\b)/m - if f !~/^%+\s/ \ - and f =~rgx_image - images << f.scan(rgx_image).uniq - end - images.flatten - end - def sisupod_build #see also sisupod in sysenv - @pwd=Dir.pwd - @rgx_rb_image=/["']\S*?([a-zA-Z0-9_-]+?\.(?:png|jpg|gif))["']/ - @rgx_image=/(?:^|[^_\\])\{\s*(\S+?\.(?:png|jpg|gif))/ - @rgx_skin=/^\s+:skin:\s+(\S+)/ - @rgx_doc_import=/^<<\s*(\S+?\.ss[ti])/ - file_array=IO.readlines(@opt.fno,'') - skin,images,doc_import=[],[],[] - doc_import_dir=@opt.sub_location - file_array.each do |f| #% work area - if f !~/^%+\s/ - skin << f.scan(@rgx_skin).uniq.flatten if f =~@rgx_skin - f=f.gsub(/<:=(\S+?)>/,'{ c_\1.png 14x14 }image') # embedded symbol (image) - if f !~/^%+\s/ \ - and f =~@rgx_image - images=images_extract(f,images) - end - if @opt.fno =~/\.ssm$/ - doc_import << f.scan(@rgx_doc_import) if f =~@rgx_doc_import - end - end - end - if doc_import.length > 0 - doc_import=doc_import.uniq.flatten - doc_import.each do |fn| - file_array=IO.readlines(fn,'') - file_array.each do |f| #% work area - if f !~/^%+\s/ \ - and f =~@rgx_image - images=images_extract(f,images) - end - end - end - end - docskin=nil - if skin \ - and skin.length > 0 - docskin=skin.pop.flatten.join - skin_source=select_skin(docskin) - else - skin_source=select_skin - end - docskin_place="#{@env.processing_path.processing_sisupod(@opt)}/doc/_sisu/skin/#{skin_source[:type].to_s}" - FileUtils::mkdir_p(docskin_place) - if skin_source[:type] == :dir - docskin_with_path="#{docskin_place}/skin_#{@env.stub_pwd}.rb" - docskin=[docskin_with_path.gsub(/.+?\/(skin_\S+?)\.rb/,'\1')] - docskin='skin_sisupod' - end - if skin_source \ - and skin_source[:name_path] - unless skin_source[:name_path].nil? \ - or skin_source[:name_path].empty? - if FileTest.file?(skin_source[:name_path]) - FileUtils::cp(skin_source[:name_path],"#{docskin_place}/#{docskin}.rb") - skinfile_array=IO.readlines(skin_source[:name_path],'') - para_images=[] - skinfile_array.each do |f| #% work area - unless f =~/^%+ / #hmmm - images << f.scan(@rgx_rb_image).uniq if f =~@rgx_rb_image - #does not really discriminate, may duplicate images in sisu file, and may take images from default image pool - end - end - else STDERR.puts %{\t*WARN* did not find - "#{skin_source[:name_path]}" [#{__FILE__}:#{__LINE__}]} - end - end - end - #1. mapping in doc dir? - #2. need images used by skin, scan skin?? - if images \ - and images.length > 1 - images=images.flatten.uniq - images.delete_if {|x| x =~/https?:\/\// } - #images=images.sort - path_pod="#{@env.processing_path.processing_sisupod(@opt)}" - path_pod_conf="#{@env.processing_path.processing_sisupod(@opt)}/_sisu" - images_path_pod="#{path_pod}/image" - FileUtils::mkdir_p(images_path_pod) - #unattractive hard coding ... ! - image_path='_sisu/image' - images_pwd="#{@env.path.pwd}/#{image_path}" - ##sequence copies base images, defaults used in all html outputs - #image_source_base='/usr/share/sisu/image' - #dir_pwd=Dir.pwd - #Dir.chdir(image_source_base) - #base_images=Dir.glob('*') - #base_images.each do |i| - # FileUtils::cp_r(i,"#{images_path_pod}/#{i}") - #end - #Dir.chdir(dir_pwd) - if FileTest.directory?(images_pwd) - images=images.uniq - images.each do |i| - if FileTest.file?("#{images_pwd}/#{i}") - FileUtils::cp("#{images_pwd}/#{i}","#{images_path_pod}/#{i}") if FileTest.file?("#{images_pwd}/#{i}") - else STDERR.puts %{\t*WARN* did not find image - "#{images_pwd}/#{i}" [#{__FILE__}:#{__LINE__}]} - end - end - else STDERR.puts %{\t*WARN* did not find - #{images_pwd} #{images_path_pod} [#{__FILE__}:#{__LINE__}]} - end - end - if doc_import.length > 0 \ - and @opt.fno =~/\.ssm$/ - doc_import.each do |f| - if FileTest.file?("#{@env.path.pwd}#{doc_import_dir}/#{f}") - FileUtils::cp("#{@env.path.pwd}#{doc_import_dir}/#{f}","#{@env.processing_path.processing_sisupod(@opt)}/doc/#{@opt.lng}/#{f}") - else STDERR.puts %{\t*WARN* did not find image - "#{@env.path.pwd}#{doc_import_dir}/#{f}" [#{__FILE__}:#{__LINE__}]} - end - end + @ans=SiSU_Response::Response.new + if @opt.cmd=~/[MVv]/ + SiSU_Screen::Ansi.new(@opt.cmd,'Assemble source for sisu document',"#{@opt.fns} -> file://#{@file.output_path.sisupod.dir}/#{@zipfile}.txz").warn end - x=@env.document_language_versions_found #check multiple document language versions (param not used) - if x[:f] \ - and x[:f].length > 0 #store multiple document language versions, sisupod - x[:f].each do |f| - pth="#{@env.processing_path.processing_sisupod(@opt)}/doc/#{@opt.lng}" - FileUtils::mkdir_p(pth) unless FileTest.directory?(pth) - if f[:f] =~/\~(\S{2,3})\.ss[tm]$/ - lng_f=$1 - if @opt.lng == lng_f - if @opt.fno =~/\.ssm$/ - if FileTest.file?("#{@env.path.pwd}#{doc_import_dir}/#{f[:f]}") - FileUtils::cp("#{@env.path.pwd}#{doc_import_dir}/#{f[:f]}", - "#{@env.processing_path.processing_sisupod(@opt)}/doc/#{@opt.lng}/#{f[:n]}") - else STDERR.puts %{\t*WARN* did not find - "#{@env.path.pwd}#{doc_import_dir}/#{f[:f]}" [#{__FILE__}:#{__LINE__}]} - end - else - if FileTest.file?("#{@env.path.pwd}/#{f[:f]}") - FileUtils::cp("#{@env.path.pwd}/#{f[:f]}", - "#{@env.processing_path.processing_sisupod(@opt)}/doc/#{@opt.lng}/#{f[:n]}") - else STDERR.puts %{\t*WARN* did not find - "#{@env.path.pwd}/#{f[:f]}" [#{__FILE__}:#{__LINE__}]} - end - end - end - else - if @opt.fno =~/\.ssm$/ - if FileTest.file?("#{@env.path.pwd}#{doc_import_dir}/#{f[:f]}") - FileUtils::cp_r("#{@env.path.pwd}#{doc_import_dir}/#{f[:f]}", - "#{@env.processing_path.processing_sisupod(@opt)}/doc/#{@opt.lng}/#{f[:n]}") - else STDERR.puts %{\t*WARN* did not find - "#{@env.path.pwd}#{doc_import_dir}/#{f[:f]}" [#{__FILE__}:#{__LINE__}]} - end - else - if FileTest.file?("#{@env.path.pwd}/#{f[:f]}") - FileUtils::cp("#{@env.path.pwd}/#{f[:f]}", - "#{@env.processing_path.processing_sisupod(@opt)}/doc/#{@opt.lng}/#{f[:n]}") - else STDERR.puts %{\t*WARN* did not find - "#{@env.path.pwd}/#{f[:f]}" [#{__FILE__}:#{__LINE__}]} - end - end - end - end - end #NB not all possibilies met, revisit, also in case of composite file may wish to add README end def sisupod_tar_xz - FileUtils::mkdir_p(@file.output_path.sisupod.dir) unless FileTest.directory?(@file.output_path.sisupod.dir) - tree=(@opt.cmd =~/[vVM]/ \ - && SiSU_Env::SystemCall.new.program_found?('tree')) \ - ? 'tree sisupod' - : '' - if FileTest.directory?(@env.processing_path.processing_sisupod(@opt)) - Dir.chdir("#{@env.processing_path.root_dir}/#{@env.processing_path.user}/pods/#{@opt.fns}") - system(%{ - #{tree} - tar -cJf #{@zipfile}.txz sisupod - #echo "#{@file.place_file.sisupod.dir}" - }) - FileUtils::mv("#{@zipfile}.txz",@file.place_file.sisupod.dir) - FileUtils::rm_r(Dir.glob("sisupod/*")) - Dir.chdir(@env.path.pwd) - SiSU_Screen::Ansi.new('',"#{@opt.fns}.txz").blue_tab if @opt.cmd=~/[MVv]/ - else - SiSU_Screen::Ansi.new('',"#{@opt.fns}.txz not built").blue_tab if @opt.cmd=~/[MVv]/ + begin + FileUtils::mkdir_p(@file.output_path.sisupod.dir) unless FileTest.directory?(@file.output_path.sisupod.dir) + tree=(@opt.cmd =~/[vVM]/ \ + && SiSU_Env::SystemCall.new.program_found?('tree')) \ + ? 'tree sisupod' + : '' + if FileTest.directory?(@path_pod[:fnb]) + Dir.chdir(@path_pod[:fnb]) + system(%{ + #{tree} + tar -cJf #{@zipfile}.txz sisupod + #echo "#{@file.place_file.sisupod.dir}" + }) + FileUtils::mv("#{@zipfile}.txz",@file.place_file.sisupod.dir) + Dir.chdir(@env.path.pwd) + SiSU_Screen::Ansi.new('',"#{@opt.fns}.txz").blue_tab if @opt.cmd=~/[MVv]/ + else + SiSU_Screen::Ansi.new('',"#{@opt.fns}.txz not built").blue_tab if @opt.cmd=~/[MVv]/ + end + rescue + ensure end end end diff --git a/lib/sisu/v3/sysenv.rb b/lib/sisu/v3/sysenv.rb index 5e9533a2..1527e634 100644 --- a/lib/sisu/v3/sysenv.rb +++ b/lib/sisu/v3/sysenv.rb @@ -858,7 +858,7 @@ module SiSU_Env @language=(l.nil? || l.empty?) \ ? SiSU_Env::InfoEnv.new.language_default_set : l - @r=%{(?:#{Px[:lng_lst].join('|')})} + @r=%{(?:#{Px[:lng_lst_rgx]})} @lang_info=SiSU_i18n::Languages.new end def lang_lst # from i18n @@ -1010,7 +1010,7 @@ module SiSU_Env @stub_md= @stub_pwd + '/sisu_site_metadata' pt=Pathname.new(Dir.pwd) stub=if output_dir_structure.by_language_code? - r=Px[:lng_lst].join('|') + r=Px[:lng_lst_rgx] stub=if Dir.pwd =~/.+?\/([^\/]+)(?:\/(#{r})$)/ lng=pt.split[-1].to_s lng_part='/' + lng @@ -1114,7 +1114,7 @@ module SiSU_Env # image/ [all images for specific document gathered here] # audio/ # video/ - spp="#{processing_path.processing}/sisupod" + spp="#{processing_path.processing}/#{Gt[:sisupod]}" sppc="#{spp}/doc/_sisu" lng_dirs=[] if FileTest.directory?(spp) \ @@ -1157,17 +1157,17 @@ module SiSU_Env # skin/ # doc [relevant skin if any other than default] # image [all images for specific document gathered here] - sisupod_processing_path="#{processing_path.processing}/sisupod" + sisupod_processing_path="#{processing_path.processing}/#{Gt[:sisupod]}" if FileTest.directory?(sisupod_processing_path) \ or FileTest.file?(sisupod_processing_path) FileUtils::rm_rf(sisupod_processing_path) end paths=[] paths=[ - "#{processing_path.processing}/sisupod/_sisu/skin/doc", - "#{processing_path.processing}/sisupod/_sisu/skin/dir", - "#{processing_path.processing}/sisupod/_sisu/skin/site", - "#{processing_path.processing}/sisupod/_sisu/image" + "#{processing_path.processing}/#{Gt[:sisupod]}/_sisu/skin/doc", + "#{processing_path.processing}/#{Gt[:sisupod]}/_sisu/skin/dir", + "#{processing_path.processing}/#{Gt[:sisupod]}/_sisu/skin/site", + "#{processing_path.processing}/#{Gt[:sisupod]}/_sisu/image" ] paths.each {|x| FileUtils::mkdir_p(x) unless FileTest.directory?(x) } end @@ -1882,11 +1882,11 @@ WOK "#{path.webserv}/#{images}" end def output #web/webserv output directory... subdirectory into which further subdirectories are made based on file names - r=Px[:lng_lst].join('|') + r=Px[:lng_lst_rgx] u=/.+?\/([^\/]+)(?:\/(?:#{r})$|$)/ base_stub=@sys.pwd.gsub(u,'\1') - if Dir.pwd =~/\/sisupod\/[^\/]+\/sisupod\/doc/ - "#{path.webserv}/doc" + if Dir.pwd =~/\/#{Gt[:sisupod]}\/[^\/]+\/#{Gt[:pod]}\/#{Gt[:doc]}/ + "#{path.webserv}/#{Gt[:doc]}" else "#{path.webserv}/#{base_stub}" end @@ -2011,27 +2011,40 @@ WOK : ("#{root_dir}/#{stub_pwd}") # see defaults[:processing_path] end def processing_sisupod(opt=nil) #processing directory, used/needed for sisu work files, has sub-directories (dal,tex etc) - unless FileTest.directory?(root_dir) - FileUtils::mkdir_p(root_dir) - File.chmod(0777,root_dir) - end - if usr_dir? + @opt=opt + def paths processing_path_usr="#{root_dir}/#{user}" - FileUtils::mkdir_p(processing_path_usr) unless FileTest.directory?(processing_path_usr) - File.chmod(0700,processing_path_usr) - end - sisupod_processing_path=processing_path_usr + '/pods/' + opt.fno + '/sisupod' - FileUtils::mkdir_p(sisupod_processing_path) unless FileTest.directory?(sisupod_processing_path) - sisupod_processing_path_lng=if defined? opt.lng - sisupod_processing_path + '/doc/' + opt.lng - else - sisupod_processing_path + '/doc' - end - unless FileTest.directory?(sisupod_processing_path_lng) - FileUtils::mkdir_p(sisupod_processing_path_lng) - File.chmod(0700,sisupod_processing_path_lng) + processing_path_fnb=processing_path_usr + '/' + Gt[:pods] + '/' + @opt.fng + processing_path_sisupod=processing_path_fnb + '/' + Gt[:sisupod] + { fnb: processing_path_fnb, sisupod: processing_path_sisupod } + end + def make + unless FileTest.directory?(root_dir) + FileUtils::mkdir_p(root_dir) + File.chmod(0777,root_dir) + end + if usr_dir? + processing_path_usr="#{root_dir}/#{user}" + FileUtils::mkdir_p(processing_path_usr) unless FileTest.directory?(processing_path_usr) + File.chmod(0700,processing_path_usr) + end + fn_base_bundle=paths[:fnb] + sisupod_processing_path=paths[:sisupod] + FileUtils::mkdir_p(sisupod_processing_path) unless FileTest.directory?(sisupod_processing_path) + sisupod_processing_path_lng=if defined? @opt.lng + sisupod_processing_path + '/' + Gt[:doc] + '/' + @opt.lng + else + sisupod_processing_path + '/' + Gt[:doc] + end +#p sisup od_processing_path_lng + unless FileTest.directory?(sisupod_processing_path_lng) + #puts "a processing directory (#{sisupod_processing_path_lng}) is being created for use by sisu" + FileUtils::mkdir_p(sisupod_processing_path_lng) + File.chmod(0700,sisupod_processing_path_lng) + end + sisupod_processing_path end - sisupod_processing_path + self end def processing #processing directory, used/needed for sisu work files, has sub-directories (dal,tex etc) unless FileTest.directory?(root_dir) @@ -2087,8 +2100,8 @@ WOK and not @rc['git']['dir'].nil? \ and not @rc['git']['dir'].empty? x=(@rc['git']['dir'] =~/^(?:~|home)$/) \ - ? home + '/' + 'sisu:' - : @rc['git']['dir'] + '/' + 'sisu:' + ? home + '/' + Gt[:git] + : @rc['git']['dir'] + '/' + Gt[:git] else defaults[:processing_git] end unless FileTest.directory?(pth) @@ -2672,7 +2685,7 @@ WOK end def sisupod_gen_v3(fns_pod) pwd=Dir.pwd - sisupod_processing_path="#{processing_path.processing}/sisupod" + sisupod_processing_path="#{processing_path.processing}/#{Gt[:sisupod]}" if FileTest.directory?(sisupod_processing_path) \ or FileTest.file?(sisupod_processing_path) FileUtils::rm_rf(sisupod_processing_path) @@ -2688,7 +2701,7 @@ WOK if f_pod \ && FileTest.file?(f_pod) tree=(SiSU_Env::SystemCall.new.program_found?('tree')) \ - ? "tree #{processing_path.processing}/sisupod" + ? "tree #{processing_path.processing}/#{Gt[:sisupod]}" : '' if FileTest.directory?(processing_path.processing) Dir.chdir(processing_path.processing) @@ -2703,7 +2716,7 @@ WOK end def sisupod_gen_v2(fns_pod) pwd=Dir.pwd - sisupod_processing_path="#{processing_path.processing}/sisupod" + sisupod_processing_path="#{processing_path.processing}/#{Gt[:sisupod]}" if FileTest.directory?(sisupod_processing_path) \ or FileTest.file?(sisupod_processing_path) FileUtils::rm_rf(sisupod_processing_path) @@ -3822,7 +3835,7 @@ WOK @pwd=Dir.pwd @env=SiSU_Env::InfoEnv.new pt=Pathname.new(@pwd) - r=Px[:lng_lst].join('|') + r=Px[:lng_lst_rgx] u=/.+?\/([^\/]+)(?:\/(?:#{r})$|$)/ @pwd_stub=pt.realpath.to_s[u,1] @rc=@@rc ||=GetInit.instance.sisu_yaml.rc @@ -4659,7 +4672,7 @@ WOK end end def src - @md.fns + @md.fno end def po #check (@fno.empty?) \ @@ -4710,10 +4723,8 @@ WOK "#{@md.opt.opt_act[:redirect][:inst]}/#{@md.fnb}" elsif output_dir_structure.dump? @md.opt.opt_act[:dump][:inst] - elsif output_dir_structure.by_language_code? - "#{output_path.base.dir}/#{@ft}/#{@md.opt.lng}" else - "#{output_path.base.dir}/#{@ft}" + "#{output_path.base.dir}/#{@ft}/#{@md.opt.fng}/#{Gt[:sisupod]}/#{Gt[:doc]}/#{@md.opt.lng}" end end def ab_pod @@ -4745,11 +4756,7 @@ WOK end end def ab_src - if output_dir_structure.by_language_code? - "#{output_path.base.url}/#{@ft}/#{@md.opt.lng}" - else - "#{output_path.base.url}/#{@ft}" - end + "#{output_path.base.url}/#{@ft}/#{@md.opt.fng}/#{Gt[:sisupod]}/#{Gt[:doc]}/#{@md.opt.lng}" end def ab_pod "#{output_path.base.url}/#{@ft}" @@ -4783,11 +4790,7 @@ WOK end end def ab_pod - if output_dir_structure.by_language_code? - "#{@ft}" - else - "#{@ft}" - end + "#{@ft}" end self end @@ -4811,12 +4814,13 @@ WOK end end def ab_src + locate="#{@ft}/#{@md.opt.fng}/#{Gt[:sisupod]}/#{Gt[:doc]}/#{@md.opt.lng}" if output_dir_structure.dump_or_redirect? '.' elsif output_dir_structure.by_language_code? - "#{@ft}/#{@md.opt.lng}" + "../../#{locate}" else - "#{@ft}" + "../#{locate}" end end def ab_pod @@ -4948,7 +4952,7 @@ WOK end def sisupod def ft - Gt[:src] + '/' + Gt[:pod] + Gt[:src] end def dir set_path(ft).dir.ab_pod @@ -4969,7 +4973,7 @@ WOK end def po def dir - "#{output_path.base.dir}/po4a/#{@md.fnb}/po/#{@md.opt.lng}" + "#{output_path.base.dir}/#{Gt[:src]}/#{@md.opt.fng}/po4a/po/#{@md.opt.lng}" end def url "#{output_path.base.url}/po4a/#{@md.fnb}/po/#{@md.opt.lng}" @@ -4978,7 +4982,7 @@ WOK end def pot def dir - "#{output_path.base.dir}/po4a/#{@md.fnb}/pot" + "#{output_path.base.dir}/#{Gt[:src]}/#{@md.opt.fng}/po4a/pot" end def url "#{output_path.base.url}/po4a/#{@md.fnb}/pot" @@ -5649,7 +5653,7 @@ WOK def apply if @m.respond_to?(:make) \ and @md.make.respond_to(:skin) - skin_path=unless @md.opt.f_pth[:pth] =~/\/\S+?\/sisupod\/\S+?\/sisupod\/doc/ + skin_path=unless @md.opt.f_pth[:pth] =~/\/\S+?\/#{Gt[:sisupod]}\/\S+?\/#{Gt[:pod]}\/#{Gt[:doc]}/ [ "#{@env.path.pwd}/_sisu/skin", "#{@env.path.home}/.sisu/skin", @@ -5657,7 +5661,7 @@ WOK "#{@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=/(\/\S+?\/#{Gt[:sisupod]}\/\S+?\/#{Gt[:pod]}\/#{Gt[: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" diff --git a/lib/sisu/v3/urls.rb b/lib/sisu/v3/urls.rb index 29c2f791..1dcf988f 100644 --- a/lib/sisu/v3/urls.rb +++ b/lib/sisu/v3/urls.rb @@ -90,10 +90,6 @@ module SiSU_Urls @fn=SiSU_Env::EnvCall.new(@opt.fns).lang(fn_set_lang[:c]) @m_regular=/(.+?)\.(?:(?:-|ssm\.)?sst|ssm)$/ @prog=@env.program - source=if @opt.fns =~/\.sst$/; @opt.fns - elsif @opt.fns =~/\.ssm\.sst/; "#{@fnb}.ssm.sst" - else 'not recognised file' - end @u ||= { 'b --xhtml (XHTML)'=>@fn[:xhtml], 'D[iu] --psql (DBI import/update postgresql)'=>'dbi psql', @@ -111,7 +107,7 @@ module SiSU_Urls 'p --pdf (PDF landscape)'=>@fn[:pdf_l], 'p --pdf (PDF portrait)'=>@fn[:pdf_p], 'E --profile (Ruby profiler)'=>'profile', - 's --source (sisu markup)'=>source, + 's --source (sisu markup)'=>@opt.fno, 'S --sisupod (sisupod)'=>@fn[:sisupod], 't --txt (Plain-text (endnotes))'=>@fn[:plain], 'x --xml-sax (XML sax type)'=>@fn[:sax], @@ -361,7 +357,7 @@ module SiSU_Urls end if x=~/--sisupod\b/ \ and @opt.act[:sisupod][:set]==:on - (@opt.fns =~/\.ssm\.sst$/) \ + (@opt.fno =~/\.ssm$/) \ ? y.gsub(/(?:\~\S{2,3})?(\.ssm.sst\.txz)$/,'.ssm.txz') : y.gsub(/(?:\~\S{2,3})?(\.sst\.txz)$/,'\1') show.source.pod(x,y) |