diff options
author | Ralph Amissah <ralph@amissah.com> | 2008-09-10 21:24:31 -0400 |
---|---|---|
committer | Ralph Amissah <ralph@amissah.com> | 2008-09-10 21:24:31 -0400 |
commit | 291080c0495f59f031bf5c0de2482f1bc7df59f2 (patch) | |
tree | 6e8a1d334be8979f5c9e77687e2ec8ee7fc633b2 /lib/sisu/v0/dal.rb | |
parent | book index, sample html file and to screen sisu markup sample added (-M flag) (diff) |
primarily on book index where (markup) provided
* book index, html, tex/pdf, xml
* texpdf no ocn if ocn is 0
* odf, plaintext, if book index? remove ... do other outputs for which not relevant
* concordance, better matches
* constants, dal special character for hardspace changed as (ruby) regx bug in replacing it in xml, odd but move on
Note: to fix html seg headers for endnotes and for index
Diffstat (limited to 'lib/sisu/v0/dal.rb')
-rw-r--r-- | lib/sisu/v0/dal.rb | 56 |
1 files changed, 49 insertions, 7 deletions
diff --git a/lib/sisu/v0/dal.rb b/lib/sisu/v0/dal.rb index a00d307b..c01c2d0a 100644 --- a/lib/sisu/v0/dal.rb +++ b/lib/sisu/v0/dal.rb @@ -87,13 +87,14 @@ module SiSU_DAL end end class Source <Instantiate - @@dal_array=[] + @@dal_array,@@html_idx_array=[],[] @@fns=nil def initialize(opt) @opt=opt @@fns||@opt.fns @my_make_fns=SiSU_Env::Create_file.new(@opt.cmd,@opt.fns) @fnm=@my_make_fns.marshal_meta + @fnm_idx_html=@my_make_fns.marshal_meta_idx_html SiSU_Env::Create_system_link.new.images @env=SiSU_Env::Info_env.new end @@ -123,6 +124,21 @@ module SiSU_DAL Instantiate.new end end + def get_idx_html #reads dal idx.html, #unless does not exist then creates first + begin + dal=[] + unless @@fns==@opt.fns + @@fns=@opt.fns + @@html_idx_array=[] + end + dal=if @@html_idx_array.empty?; read_fnm_idx_html + else @@html_idx_array.dup #check + end + rescue; SiSU_Errors::Info_error.new($!,$@,@opt.cmd,@opt.fns).error + ensure + Instantiate.new + end + end protected def create_dal dal_array=[] @@ -154,32 +170,56 @@ module SiSU_DAL else SiSU_DAL::Source.new(@opt).create_dal end end + def read_fnm_idx_html + dal=[] + dal=if FileTest.file?(@fnm_idx_html) + if RUBY_VERSION < '1.9' + File.open(@fnm_idx_html){ |f| dal=Marshal.load(f)} + else File.open(@fnm_idx_html,'r:utf-8'){ |f| dal=Marshal.load(f)} + end + else nil + #SiSU_DAL::Source.new(@opt).create_dal + end +#p dal; dal + end end class Output def initialize(md,data) @md,@data=md,data @my_make=SiSU_Env::Create_file.new(@md.cmd,@md.fns) - dir=SiSU_Env::Info_env.new(@md.fns) - @hard="#{dir.path.dal}/#{@md.fns}.meta" + @dir=SiSU_Env::Info_env.new(@md.fns) end def hard_output if @md.cmd =~/M/ filename_meta=@my_make.file_meta @data.each {|s| filename_meta.puts s.strip + "\n\n" unless s.strip.empty?} - else File.unlink(@hard) if FileTest.file?(@hard) + else + hard="#{@dir.path.dal}/#{@md.fns}.meta" + File.unlink(hard) if FileTest.file?(hard) end end def marshal marshal_meta=@my_make.marshal_meta File.open(marshal_meta,'w'){|f| Marshal.dump(@data.to_a,f)} end + def idx_html_hard_output + if @md.book_index and @md.cmd =~/M/ + filename_meta=@my_make.file_meta_idx_html + @data.each {|s| filename_meta.puts s.strip + "\n" unless s.strip.empty?} + else + hard_idx_html="#{@dir.path.dal}/#{@md.fns}.idx.html" + File.unlink(hard_idx_html) if FileTest.file?(hard_idx_html) + end + end + def idx_html_marshal + marshal_meta=@my_make.marshal_meta_idx_html + File.open(marshal_meta,'w'){|f| Marshal.dump(@data.to_a,f)} + end end class Make - #@@comment='%' @@dp=nil def initialize(md,data) @md,@data=md,data - #@@word_mode=[] @env=SiSU_Env::Info_env.new(@md.fns) @skin=SiSU_Env::Info_skin.new(@md) @dp=@@dp ||=SiSU_Env::Info_env.new.digest.pattern @@ -209,7 +249,7 @@ module SiSU_DAL data=SiSU_images::Images.new(@md,data).images data=SiSU_document_structure::Tables.new(@md,data).tables data=SiSU_numbering::Numbering.new(@md,data).numbering_song - data=SiSU_book_index::Book_index.new(@md,data,@env).indexing_song if @md.book_index + data,book_index,html_idx=SiSU_book_index::Book_index.new(@md,data,@env).indexing_song if @md.book_index data=SiSU_endnotes::Endnotes.new(@md,data,endnote_array).endnotes data=SiSU_hash::Object_digest.new(@md,data,@env).object_digest meta=SiSU_metadata::Metadata.new(@md,data).metadata @@ -218,6 +258,8 @@ module SiSU_DAL if @md.cmd =~/[mM]/ SiSU_DAL::Output.new(@md,outputdata).hard_output SiSU_DAL::Output.new(@md,outputdata).marshal + SiSU_DAL::Output.new(@md,html_idx).idx_html_hard_output + SiSU_DAL::Output.new(@md,html_idx).idx_html_marshal end reset outputdata |