From 6811ac91f21a434fc7d967c11e1b20f33918c6ea Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Mon, 19 Mar 2012 22:07:29 -0400 Subject: v3: 3.2 branch is main (v3dv --> v3); dev (v3dv) branch directories removed * v3dv (3.2) "merged" into v3 (previously 3.1) (& removed) * conf/sisu/v3dv --> conf/sisu/v3 * data/sisu/v3dv --> data/sisu/v3 * lib/sisu/v3dv --> lib/sisu/v3 * bin/sisu* (v3dv references changed to v3) * (--dev modifier (superfluous for the time being) runs main v3 branch) --- lib/sisu/v3/html.rb | 215 ++++++++++++++++++++++++++-------------------------- 1 file changed, 108 insertions(+), 107 deletions(-) (limited to 'lib/sisu/v3/html.rb') diff --git a/lib/sisu/v3/html.rb b/lib/sisu/v3/html.rb index 85c1d602..fee51f2c 100644 --- a/lib/sisu/v3/html.rb +++ b/lib/sisu/v3/html.rb @@ -66,16 +66,16 @@ module SiSU_HTML require_relative 'html_format' # html_format.rb include SiSU_HTML_Format require_relative 'html_segments' # html_segments.rb - include SiSU_HTML_seg + include SiSU_HTML_Seg require_relative 'html_scroll' # html_scroll.rb require_relative 'html_promo' # html_promo.rb - include SiSU_HTML_promo + include SiSU_HTML_Promo require_relative 'html_tune' # html_tune.rb include SiSU_HTML_Tune class Source def initialize(opt) @opt=opt - @particulars=SiSU_Particulars::Combined_singleton.instance.get_all(opt) + @particulars=SiSU_Particulars::CombinedSingleton.instance.get_all(opt) end def read songsheet @@ -95,21 +95,21 @@ module SiSU_HTML : SiSU_Screen::Ansi.new(@opt.cmd,'HTML',tool).green_title_hi SiSU_Screen::Ansi.new(@opt.cmd,@opt.fns,"file://#{@md.file.output_path.html_seg.dir}/#{@md.file.base_filename.html_segtoc}").flow if @opt.cmd =~/[MV]/ end - SiSU_Env::Info_skin.new(@md).select + SiSU_Env::InfoSkin.new(@md).select data=nil - @tuned_file_array=SiSU_HTML::Source::Html_environment.new(@particulars).tuned_file_instructions + @tuned_file_array=SiSU_HTML::Source::HTML_Environment.new(@particulars).tuned_file_instructions data=@tuned_file_array scr_endnotes=SiSU_HTML::Source::Endnotes.new(data,@md).scroll toc=SiSU_HTML::Source::Toc.new(@md,data).songsheet - links_guide=SiSU_HTML::Source::Links_guide.new(data,@md).toc + links_guide=SiSU_HTML::Source::LinksGuide.new(data,@md).toc data=@tuned_file_array - scr_toc=SiSU_HTML::Source::Scroll_head_and_segtoc.new(@md,toc,links_guide).in_common #watch + scr_toc=SiSU_HTML::Source::ScrollHeadAndSegToc.new(@md,toc,links_guide).in_common #watch SiSU_HTML::Source::Seg.new(@md,data).songsheet data=@tuned_file_array scr=SiSU_HTML::Source::Scroll.new(@md,data,scr_endnotes).songsheet - scroll=SiSU_HTML::Source::Scroll_output.new(scr_toc,scr[:body],scr[:metadata],scr[:owner_details],scr[:tails],@md).publish + scroll=SiSU_HTML::Source::ScrollOutput.new(scr_toc,scr[:body],scr[:metadata],scr[:owner_details],scr[:tails],@md).publish SiSU_HTML::Source::Output.new(scroll,@md).scroll - rescue; SiSU_Errors::Info_error.new($!,$@,@opt.cmd,@opt.fns).error + rescue; SiSU_Errors::InfoError.new($!,$@,@opt.cmd,@opt.fns).error ensure unless @opt.cmd =~/[MV]/ #check maintenance flag texfiles=Dir["#{@env.processing_path.tune}/#{@opt.fns}*"] @@ -128,40 +128,36 @@ module SiSU_HTML end end private - class Html_environment + class HTML_Environment def initialize(particulars) @particulars=particulars @md,@env=particulars.md,particulars.env - @vz=SiSU_Env::Get_init.instance.skin - @env,@css,@symlnk=particulars.env,SiSU_Style::CSS.new,SiSU_Env::Create_system_link.new #home + @vz=SiSU_Env::GetInit.instance.skin + @env,@css,@symlnk=particulars.env,SiSU_Style::CSS.new,SiSU_Env::CreateSystemLink.new #home end def link_images @symlnk.images end - def directories - title=File.basename(@md.fns,'.rb') - end def tuned_file_instructions @tell=SiSU_Screen::Ansi.new(@md.opt.cmd) @md.opt.cmd=@md.opt.cmd.gsub(/H/,'h') - @md.file_type='html' if @md.opt.cmd =~/[hon]/ - directories + @md.file_type='html' if @md.opt.cmd =~/[hw]/ newfilename=%{#{@md.file.output_path.html_scroll.dir}/#{@md.file.base_filename.html_segtoc}} if @md.file_type =~/html/ dal_array=@particulars.dal_array # dal file drawn here @tuned_file_array=SiSU_HTML_Tune::Tune.new(dal_array,@md).songsheet @tuned_file_array end end - class Links_guide + class LinksGuide @links_guide_toc=[] def initialize(data,md) @data,@md=data,md - @links_guide_=SiSU_Env::Create_site.new(@md.opt.cmd).html_quick_ref? + @links_guide_=SiSU_Env::CreateSite.new(@md.opt.cmd).html_quick_ref? end def toc @links_guide_toc=[] if @links_guide_ - format_head_toc=SiSU_HTML_Format::Head_toc.new(@md) + format_head_toc=SiSU_HTML_Format::HeadToc.new(@md) guide_type='horzontal' #values: horizontal or vertical @links_guide_toc << format_head_toc.links_guide_open(guide_type) if defined? @md.lnk \ @@ -173,12 +169,12 @@ module SiSU_HTML end s_lnk_url,s_lnk_lnk=l[:url],l[:say] txt_obj={ lnk_url: s_lnk_url, lnk_txt: s_lnk_lnk, target: target } - lev_dob_ocn=SiSU_HTML_Format::Format_toc.new(@md,txt_obj) + lev_dob_ocn=SiSU_HTML_Format::FormatToc.new(@md,txt_obj) @links_guide_toc << lev_dob_ocn.links_guide if s_lnk_lnk end end end - format_head_toc=SiSU_HTML_Format::Head_toc.new(@md) + format_head_toc=SiSU_HTML_Format::HeadToc.new(@md) @links_guide_toc << format_head_toc.links_guide_close #(guide_type) @links_guide_toc else '' @@ -192,10 +188,10 @@ module SiSU_HTML end def scroll @scr_endnotes=[] - format_head_scroll=SiSU_HTML_Format::Head_scroll.new(@md) + format_head_scroll=SiSU_HTML_Format::HeadScroll.new(@md) @data.each do |dob| pg=dob.dup - unless pg.is =~/^code/ + unless pg.is ==:code if pg.obj =~/(?:#{Mx[:en_a_o]}|#{Mx[:en_b_o]})[\d*+]+ / endnote_array=[] if pg.obj=~/#{Mx[:en_a_o]}[\d*+].+?#{Mx[:en_a_c]}/m @@ -209,7 +205,7 @@ module SiSU_HTML end endnote_array.flatten.each do |note| txt_obj={ txt: note } - format_scroll=SiSU_HTML_Format::Format_scroll.new(@md,txt_obj) + format_scroll=SiSU_HTML_Format::FormatScroll.new(@md,txt_obj) @scr_endnotes << format_scroll.endnote_body end end @@ -218,13 +214,13 @@ module SiSU_HTML @scr_endnotes end end - class Toc def level_endnotes if @md.flag_endnotes - format_head_scroll=SiSU_HTML_Format::Head_scroll.new(@md) + format_head_scroll=SiSU_HTML_Format::HeadScroll.new(@md) @@toc[:scr] << format_head_scroll.toc_endnote end end def level_concordance - format_head_toc=SiSU_HTML_Format::Head_toc.new(@md) + format_head_toc=SiSU_HTML_Format::HeadToc.new(@md) @@toc[:seg_mini] << format_head_toc.mini_seg_concordance end def level_metadata - format_head_toc=SiSU_HTML_Format::Head_toc.new(@md) + format_head_toc=SiSU_HTML_Format::HeadToc.new(@md) @@toc[:scr] << format_head_toc.metadata @@toc[:seg] << format_head_toc.seg_metadata @@toc[:seg_mini] << format_head_toc.mini_seg_metadata end def level_word_index - format_head_toc=SiSU_HTML_Format::Head_toc.new(@d0c) + format_head_toc=SiSU_HTML_Format::HeadToc.new(@d0c) @@toc[:scr] << format_head_toc.concordance @@toc[:seg] << format_head_toc.concordance @@toc[:seg_mini] << format_head_toc.mini_concordance @@ -317,7 +313,7 @@ WOK linkname,link=dob.obj.strip,dob.ocn if link \ and link !~/#/ #% keep eye on link - p_num=SiSU_HTML_Format::Paragraph_number.new(@md,link) + p_num=SiSU_HTML_Format::ParagraphNumber.new(@md,link) end title=if dob.obj !~/Metadata/; linkname else @@ -326,7 +322,7 @@ WOK end toc={} txt_obj={ txt: title } - format_toc=SiSU_HTML_Format::Format_toc.new(@md,txt_obj) + format_toc=SiSU_HTML_Format::FormatToc.new(@md,txt_obj) toc[:seg]=if dob.name =~/^meta/ \ and dob.obj =~/Document Information/ format_toc.lev0 @@ -354,7 +350,7 @@ WOK %{#{linkname}} end txt_obj={ txt: title } - format_toc=SiSU_HTML_Format::Format_toc.new(@md,txt_obj) + format_toc=SiSU_HTML_Format::FormatToc.new(@md,txt_obj) toc[:scr]=if dob.name =~/^meta/ \ and dob.obj =~/Document Information/ format_toc.lev0 @@ -367,18 +363,18 @@ WOK linkname,ocn=dob.obj.strip,dob.ocn p_num=if ocn \ and ocn !~/#/ - SiSU_HTML_Format::Paragraph_number.new(@md,ocn) + SiSU_HTML_Format::ParagraphNumber.new(@md,ocn) else nil end txt_obj={ txt: linkname } - format_toc=SiSU_HTML_Format::Format_toc.new(@md,txt_obj) + format_toc=SiSU_HTML_Format::FormatToc.new(@md,txt_obj) toc={} toc[:seg]=format_toc.lev2 toc[:seg_mini]=format_toc.mini_lev2 if p_num title=%{#{p_num.goto}#{linkname}} txt_obj={ txt: title } - format_toc=SiSU_HTML_Format::Format_toc.new(@md,txt_obj) + format_toc=SiSU_HTML_Format::FormatToc.new(@md,txt_obj) toc[:scr]=format_toc.lev2 end toc @@ -388,18 +384,18 @@ WOK linkname,ocn=dob.obj.strip,dob.ocn p_num=if ocn \ and ocn !~/#/ - SiSU_HTML_Format::Paragraph_number.new(@md,ocn) + SiSU_HTML_Format::ParagraphNumber.new(@md,ocn) else nil end txt_obj={ txt: linkname } - format_toc=SiSU_HTML_Format::Format_toc.new(@md,txt_obj) + format_toc=SiSU_HTML_Format::FormatToc.new(@md,txt_obj) toc={} toc[:seg]=format_toc.lev3 toc[:seg_mini]=format_toc.mini_lev3 if p_num title=%{#{p_num.goto}#{linkname}} txt_obj={ txt: title } - format_toc=SiSU_HTML_Format::Format_toc.new(@md,txt_obj) + format_toc=SiSU_HTML_Format::FormatToc.new(@md,txt_obj) toc[:scr]=format_toc.lev3 end toc @@ -407,7 +403,7 @@ WOK def level_4 dob=@data linkname,ocn=dob.obj.strip,dob.ocn - p_num=SiSU_HTML_Format::Paragraph_number.new(@md,ocn) if ocn + p_num=SiSU_HTML_Format::ParagraphNumber.new(@md,ocn) if ocn if dob.ln ==4 seg_link=%{ #{dob.obj} @@ -418,8 +414,8 @@ WOK %{\\1 \\2 }) end - p_num=SiSU_HTML_Format::Paragraph_number.new(@md,ocn) if ocn - @file=SiSU_Env::SiSU_file.new(@md) if @md + p_num=SiSU_HTML_Format::ParagraphNumber.new(@md,ocn) if ocn + @file=SiSU_Env::FileOp.new(@md) if @md txt_obj=if seg_link=~/sisu_manifest\.html/ man_link=if @file.output_dir_structure.by_language_code? \ or @file.output_dir_structure.by_filetype? @@ -429,7 +425,7 @@ WOK { txt: man_link } else { txt: seg_link } end - format_toc=SiSU_HTML_Format::Format_toc.new(@md,txt_obj) + format_toc=SiSU_HTML_Format::FormatToc.new(@md,txt_obj) toc={} toc[:seg]=format_toc.lev4 toc[:seg_mini]=format_toc.mini_lev4 @@ -439,7 +435,7 @@ WOK { txt: man_link } else { txt: title } end - format_toc=SiSU_HTML_Format::Format_toc.new(@md,txt_obj) + format_toc=SiSU_HTML_Format::FormatToc.new(@md,txt_obj) toc[:scr]=format_toc.lev4 toc #end @@ -450,17 +446,17 @@ WOK toc={} if ocn \ and ocn !~/#/ - p_num=SiSU_HTML_Format::Paragraph_number.new(@md,ocn) + p_num=SiSU_HTML_Format::ParagraphNumber.new(@md,ocn) lnk_n_txt=%{ #{linkname} } txt_obj={ txt: lnk_n_txt } - format_toc=SiSU_HTML_Format::Format_toc.new(@md,txt_obj) + format_toc=SiSU_HTML_Format::FormatToc.new(@md,txt_obj) toc[:seg]=format_toc.lev5 toc[:seg_mini]=format_toc.mini_lev5 title=%{#{p_num.goto}#{linkname}} txt_obj={ txt: title } - format_toc=SiSU_HTML_Format::Format_toc.new(@md,txt_obj) + format_toc=SiSU_HTML_Format::FormatToc.new(@md,txt_obj) toc[:scr]=format_toc.lev5 end toc @@ -471,25 +467,25 @@ WOK toc={} if ocn \ and ocn !~/#/ - p_num=SiSU_HTML_Format::Paragraph_number.new(@md,ocn) + p_num=SiSU_HTML_Format::ParagraphNumber.new(@md,ocn) lnk_n_txt=%{ #{linkname} } txt_obj={ txt: lnk_n_txt } - format_toc=SiSU_HTML_Format::Format_toc.new(@md,txt_obj) + format_toc=SiSU_HTML_Format::FormatToc.new(@md,txt_obj) toc[:seg]=format_toc.lev6 toc[:seg_mini]=format_toc.mini_lev6 title=%{#{p_num.goto}#{linkname}} txt_obj={ txt: title } - format_toc=SiSU_HTML_Format::Format_toc.new(@md,txt_obj) + format_toc=SiSU_HTML_Format::FormatToc.new(@md,txt_obj) toc[:scr]=format_toc.lev6 end toc end def level_crosslink dob=@data - if dob !~/^4~!/ - dob.gsub!(/^4~!\s+(\S+)\s+(.+)/, + dob=if dob !~/^4~!/ + dob.gsub(/^4~!\s+(\S+)\s+(.+)/, %{
#{@png.crosslink_ext} @@ -498,7 +494,7 @@ WOK
}) else - dob.gsub!(/^4~!\s+(\S+)\s+(.+)/, + dob.gsub(/^4~!\s+(\S+)\s+(.+)/, %{
@@ -510,31 +506,32 @@ WOK end end end - class Scroll_head_and_segtoc < Toc + class ScrollHeadAndSegToc < Toc def initialize(md='',toc='',links_guide_toc='') @md,@toc,@links_guide_toc=md,toc,links_guide_toc - @vz=SiSU_Env::Get_init.instance.skin + @vz=SiSU_Env::GetInit.instance.skin + @make=SiSU_Env::ProcessingSettings.new(@md) end def in_common toc_shared=[] @segtoc=[] SiSU_Screen::Ansi.new(@md.opt.cmd,'Scroll & Segtoc').txt_grey if @md.opt.cmd =~/[MVv]/ - format_head_toc=SiSU_HTML_Format::Head_toc.new(@md) + format_head_toc=SiSU_HTML_Format::HeadToc.new(@md) dochead=format_head_toc.head - dochead.gsub!(/toc\.(html)/,'doc.\1') #kludge - ads=SiSU_HTML_promo::Ad.new(@md) + dochead=dochead.gsub(/toc\.(html)/,'doc.\1') #kludge + ads=SiSU_HTML_Promo::Ad.new(@md) toc_shared << dochead << ads.div.major @segtoc << format_head_toc.head << ads.div.major - toc_shared << format_head_toc.toc_head_escript if SiSU_HTML_Format::Head_toc.method_defined? :toc_head_escript - @segtoc << format_head_toc.toc_head_escript if SiSU_HTML_Format::Head_toc.method_defined? :toc_head_escript + toc_shared << format_head_toc.toc_head_escript if SiSU_HTML_Format::HeadToc.method_defined? :toc_head_escript + @segtoc << format_head_toc.toc_head_escript if SiSU_HTML_Format::HeadToc.method_defined? :toc_head_escript toc_shared << format_head_toc.scroll_head_navigation_band if defined? @md.rights.all rights=format_head_toc.rights.all - rights=SiSU_HTML_Tune::Clean_html.new(rights).clean + rights=SiSU_HTML_Tune::CleanHTML.new(rights).clean end if @md.prefix_b prefix_b=format_head_toc.notes.prefix_b - prefix_b=SiSU_HTML_Tune::Clean_html.new(prefix_b).clean + prefix_b=SiSU_HTML_Tune::CleanHTML.new(prefix_b).clean end @segtoc << format_head_toc.seg_head_navigation_band toc_shared << format_head_toc.scroll_head_title_banner_open @@ -543,14 +540,14 @@ WOK doc_title_endnote=@md.title.full.gsub(/(\*+)/,'\1') tmp_head=doc_title_endnote + "\n" txt_obj={ txt: tmp_head } - format_txt_obj=SiSU_HTML_Format::Format_text_object.new(@md,txt_obj) + format_txt_obj=SiSU_HTML_Format::FormatTextObject.new(@md,txt_obj) toc_shared << format_txt_obj.center_bold @segtoc << format_txt_obj.center_bold if defined? @md.creator.author creator_endnote=@md.creator.author.gsub(/(\*+)/,%{ \\1}) tmp_head=creator_endnote + "\n" txt_obj={ txt: tmp_head } - format_txt_obj=SiSU_HTML_Format::Format_text_object.new(@md,txt_obj) + format_txt_obj=SiSU_HTML_Format::FormatTextObject.new(@md,txt_obj) toc_shared << format_txt_obj.center_bold @segtoc << format_txt_obj.center_bold end @@ -570,8 +567,9 @@ WOK if defined? @md.prefix_b toc_shared << prefix_b end - #Table of Contents added/appended here - toc_shared << @toc[:scr] + scr_toc=if @make.build.toc? #Table of Contents added/appended here + toc_shared << @toc[:scr] + end @segtoc << @links_guide_toc @segtoc << @toc[:seg] if defined? @md.rights.all \ @@ -582,20 +580,20 @@ WOK #Segtoc tail added here @segtoc << "

\n" #bugfix sort later DEBUGNOW @segtoc << @seg_toc_band_bottom - ads=SiSU_HTML_promo::Ad.new(@md) + ads=SiSU_HTML_Promo::Ad.new(@md) @segtoc << format_head_toc.seg_navigation_tail << ads.div.close << ads.display << format_head_toc.html_close - @segtoc.flatten!.compact! - Output.new(@segtoc,@md).segtoc + @segtoc=@segtoc.flatten.compact #watch + SiSU_HTML::Source::Output.new(@segtoc,@md).segtoc @segtoc=[] @toc[:scr],@toc[:seg]=[],[] toc_shared end end - class Table < SiSU_HTML_table::Table_html + class Table < SiSU_HTML_Table::TableHTML end - class Scroll < SiSU_HTML_scroll::Scroll + class Scroll < SiSU_HTML_Scroll::Scroll end - class Scroll_output + class ScrollOutput def initialize(scr_toc,scr_body,scr_metadata,scr_owner_details,scr_tails,md) @scr_toc,@scr_body,@scr_metadata,@scr_owner_details,@scr_tails,@md=scr_toc,scr_body,scr_metadata,scr_owner_details,scr_tails,md end @@ -603,31 +601,32 @@ WOK scroll=[] hr='

' scroll << @scr_toc << '
' << hr << @scr_body << @scr_endnotes << hr << @scr_owner_details << '
' << @scr_tails - scroll.flatten!.compact! + scroll=scroll.flatten.compact #watch end end - class Seg < SiSU_HTML_seg::Seg + class Seg < SiSU_HTML_Seg::Seg end class Output def initialize(data='',md='') @data,@md=data,md - @file=SiSU_Env::SiSU_file.new(@md) + @file=SiSU_Env::FileOp.new(md) + @o_str ||=SiSU_Env::ProcessingSettings.new(md).output_dir_structure end def scroll begin @filename_html_scroll=@file.write_file.html_scroll @data.each do |para| - para.strip! - para.gsub!(/<:.+?>/,'') - para.gsub!(Xx[:html_relative2],@file.path_rel_links.html_scroll_2) - para.gsub!(Xx[:html_relative1],@file.path_rel_links.html_scroll_1) - #para.gsub!(/#{Xx[:html_relative]}/,@file.path_rel_links.html_scroll) - para.gsub!(/#{Rx[:mx_fa_clean]}/,'') + para=para.strip. + gsub(/<:.+?>/,''). + gsub(Xx[:html_relative2],@file.path_rel_links.html_scroll_2). + gsub(Xx[:html_relative1],@file.path_rel_links.html_scroll_1). + #gsub(/#{Xx[:html_relative]}/,@file.path_rel_links.html_scroll). + gsub(/#{Rx[:mx_fa_clean]}/,'') unless para =~/\A\s*\Z/ @filename_html_scroll.puts para,"\n" end end - rescue; SiSU_Errors::Info_error.new($!,$@,@md.opt.cmd,@md.fns).error + rescue; SiSU_Errors::InfoError.new($!,$@,@md.opt.cmd,@md.fns).error ensure; @filename_html_scroll.close end end @@ -635,26 +634,28 @@ WOK begin @filename_html_segtoc=@file.write_file.html_segtoc @data.each do |para| - para.strip! - para.gsub!(//,'') - para.gsub!(Xx[:html_relative2],@file.path_rel_links.html_seg_2) - para.gsub!(Xx[:html_relative1],@file.path_rel_links.html_seg_1) + para=para.strip. + gsub(//,''). + gsub(Xx[:html_relative2],@file.path_rel_links.html_seg_2). + gsub(Xx[:html_relative1],@file.path_rel_links.html_seg_1) unless para =~/\A\s*\Z/ @filename_html_segtoc.puts para,"\n" end end - rescue; SiSU_Errors::Info_error.new($!,$@,@md.opt.cmd,@md.fns).error + rescue; SiSU_Errors::InfoError.new($!,$@,@md.opt.cmd,@md.fns).error ensure @filename_html_segtoc.close - unless FileTest.file?("#{@file.output_path.html_seg.dir}/#{@md.file.base_filename.html_seg_index}") - pwd_set=Dir.pwd - idx_lnk=@file.base_filename.html_segtoc - mlnk=@file.base_filename.html_seg_index - Dir.chdir(@file.output_path.html_seg.dir) - FileUtils::rm_f(mlnk) - FileUtils::ln_s(idx_lnk, mlnk) - Dir.chdir(pwd_set) + pwd_set=Dir.pwd + idx_lnk=if @o_str.dump_or_redirect? + @file.base_filename.manifest + else + @file.base_filename.html_segtoc end + mlnk=@file.base_filename.html_seg_index + Dir.chdir(@file.output_path.html_seg.dir) + FileUtils::rm_f(mlnk) + FileUtils::ln_s(idx_lnk,mlnk) + Dir.chdir(pwd_set) end end end -- cgit v1.2.3