WOK
end
#not used -->
def level_endnotes
if @md.flag_endnotes
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::HeadToc.new(@md)
@@toc[:seg_mini] << format_head_toc.mini_seg_concordance
end
def level_metadata
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::HeadToc.new(@d0c)
@@toc[:scr] << format_head_toc.concordance
@@toc[:seg] << format_head_toc.concordance
@@toc[:seg_mini] << format_head_toc.mini_concordance
end
# <-- not used
def level_0
dob=@data
linkname,link=dob.obj.strip,dob.ocn
if link \
and link !~/#/ #% keep eye on link
SiSU_HTML_Format::ParagraphNumber.new(@md,link)
end
title=linkname
toc={}
txt_obj={ txt: title }
format_toc=SiSU_HTML_Format::FormatToc.new(@md,txt_obj)
toc[:seg]=format_toc.lev0
toc[:seg_mini]=format_toc.mini_lev0
title=if dob.ocn ==0 then linkname
else
@@toc[:scr] << '
'
%{#{linkname}}
end
txt_obj={ txt: title }
format_toc=SiSU_HTML_Format::FormatToc.new(@md,txt_obj)
toc[:scr]=format_toc.lev0
toc
end
def level_1
dob=@data
linkname,link=dob.obj.strip,dob.ocn
if link \
and link !~/#/ #% keep eye on link
SiSU_HTML_Format::ParagraphNumber.new(@md,link)
end
title=if dob.obj !~/^Metadata$/ then linkname
else
link='metadata'
%{#{linkname}}
end
toc={}
txt_obj={ txt: title }
format_toc=SiSU_HTML_Format::FormatToc.new(@md,txt_obj)
toc[:seg]=if dob.name =~/^meta/ \
and dob.obj =~/Document Information/
format_toc.lev0
else format_toc.lev1
end
toc[:seg_mini]=if dob.name =~/^meta/ \
and dob.obj =~/Document Information/
@md.concord_make \
? format_toc.mini_concord_tail
: format_toc.mini_tail
else format_toc.mini_lev1
end
title=if dob.ocn ==0
if dob.name =~/^meta/ \
and dob.obj =~/Document Information/
%{#{linkname}}
else linkname
end
else
@@toc[:scr] << '
'
%{#{linkname}}
end
txt_obj={ txt: title }
format_toc=SiSU_HTML_Format::FormatToc.new(@md,txt_obj)
toc[:scr]=if dob.obj =~/^Metadata$/ then ''
elsif txt_obj[:txt] =~//
format_toc.lev1.gsub(/|<\/a>/,'')
else format_toc.lev1
end
toc
end
def level_2
dob=@data
linkname,ocn=dob.obj.strip,dob.ocn
p_num=if ocn \
and ocn !~/#/
SiSU_HTML_Format::ParagraphNumber.new(@md,ocn)
else nil
end
txt_obj={ txt: linkname }
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::FormatToc.new(@md,txt_obj)
toc[:scr]=if txt_obj[:txt] =~//
format_toc.lev2.gsub(/|<\/a>/,'')
else format_toc.lev2
end
end
toc
end
def level_3
dob=@data
linkname,ocn=dob.obj.strip,dob.ocn
p_num=if ocn \
and ocn !~/#/
SiSU_HTML_Format::ParagraphNumber.new(@md,ocn)
else nil
end
txt_obj={ txt: linkname }
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::FormatToc.new(@md,txt_obj)
toc[:scr]=if txt_obj[:txt] =~//
format_toc.lev3.gsub(/|<\/a>/,'')
else format_toc.lev3
end
end
toc
end
def level_4
dob=@data
linkname,ocn=dob.obj.strip,dob.ocn
p_num=SiSU_HTML_Format::ParagraphNumber.new(@md,ocn) if ocn
if dob.ln ==4
fnh={
fn: dob.name,
}
f=@md.file.base_filename.html_seg(fnh)
seg_link=%{
#{dob.obj}
}
@@seg_url=dob.name
elsif dob.obj =~/\d+.\d+.\d+.\d+|\d+.\d+.\d+|\d+.\d+|\d+/
fn,hd=/^(\d+.\d+.\d+.\d+|\d+.\d+.\d+|\d+.\d+|\d+)(.*)/.match(dob.obj)[1,2]
fnh={
fn: fn,
}
f=@md.file.base_filename.html_seg(fnh)
seg_link=%{#{fn} #{hd} }
end
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?
seg_link.gsub(/sisu_manifest\.html/,"../../manifest/#{@file.base_filename.manifest}")
else seg_link
end
{ txt: man_link }
else { txt: seg_link }
end
format_toc=SiSU_HTML_Format::FormatToc.new(@md,txt_obj)
toc={}
toc[:seg]=format_toc.lev4
toc[:seg_mini]=format_toc.mini_lev4
title=%{#{p_num.goto}#{linkname}} if p_num
txt_obj=if title=~/sisu_manifest.html/
man_link=title.gsub(/sisu_manifest.html/,"../manifest/#{@file.base_filename.manifest}")
{ txt: man_link }
else { txt: title }
end
format_toc=SiSU_HTML_Format::FormatToc.new(@md,txt_obj)
toc[:scr]=format_toc.lev4
toc
#end
end
def level_5
dob=@data
linkname,ocn=dob.obj.strip,dob.ocn
toc={}
if ocn \
and ocn !~/#/
fnh={
fn: @@seg_url,
}
f=@md.file.base_filename.html_seg(fnh)
p_num=SiSU_HTML_Format::ParagraphNumber.new(@md,ocn)
lnk_n_txt=%{
#{linkname}
}
txt_obj={ txt: lnk_n_txt }
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::FormatToc.new(@md,txt_obj)
toc[:scr]=format_toc.lev5
end
toc
end
def level_6
dob=@data
linkname,ocn=dob.obj.strip,dob.ocn
toc={}
if ocn \
and ocn !~/#/
fnh={
fn: @@seg_url,
}
f=@md.file.base_filename.html_seg(fnh)
p_num=SiSU_HTML_Format::ParagraphNumber.new(@md,ocn)
lnk_n_txt=%{
#{linkname}
}
txt_obj={ txt: lnk_n_txt }
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::FormatToc.new(@md,txt_obj)
toc[:scr]=format_toc.lev6
end
toc
end
def level_crosslink
dob=@data
dob=if dob !~/^4~!/
dob.gsub(/^4~!\s+(\S+)\s+(.+)/,
%{
})
else
dob.gsub(/^4~!\s+(\S+)\s+(.+)/,
%{
})
end
end
end
class ScrollHeadAndSegToc < Toc
include SiSU_Parts_HTML
def initialize(md='',toc='',links_guide_toc='')
@md,@toc,@links_guide_toc=md,toc,links_guide_toc
@make=SiSU_Env::ProcessingSettings.new(@md)
end
def in_common
toc_shared=[]
@segtoc=[]
if (@md.opt.act[:verbose][:set]==:on \
|| @md.opt.act[:verbose_plus][:set]==:on \
|| @md.opt.act[:maintenance][:set]==:on)
SiSU_Screen::Ansi.new(
@md.opt.act[:color_state][:set],
'Scroll & Segtoc'
).txt_grey
end
format_head_toc=SiSU_HTML_Format::HeadToc.new(@md)
dochead=format_head_toc.head
dochead=dochead.gsub(/toc\.(html)/,'doc.\1') #kludge
toc_shared << dochead
@segtoc << format_head_toc.head
if @make.build.html_top_band?
toc_shared << format_head_toc.scroll_head_navigation_band
end
if defined? @md.rights.all
rights=format_head_toc.rights.all
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::CleanHTML.new(prefix_b).clean
end
if @make.build.html_top_band?
@segtoc << format_head_toc.seg_head_navigation_band
end
toc_shared << format_head_toc.scroll_head_title_banner_open
@segtoc << format_head_toc.seg_head_title_banner_open
tmp_head=nil
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::FormatTextObject.new(@md,txt_obj)
toc_shared << format_txt_obj.center_bold
@segtoc << format_txt_obj.center_bold
if defined? @md.creator.author
creator=SiSU_HTML_Tune::CleanHTML.new(@md.creator.author).clean_for_html
creator_endnote=creator.gsub(/(\*+)/,
%{ \\1})
tmp_head=creator_endnote + "\n"
txt_obj={ txt: tmp_head }
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
toc_shared << "#{the_table_close*1}\n"
@segtoc << "#{the_table_close*1}\n"
tmp_head=nil
if @md.prefix_a
tmp_head ||= %{#{@md.prefix_a}\n}
toc_shared << tmp_head.dup
@segtoc << tmp_head.dup
end
tmp_head=nil
toc_shared << @links_guide_toc
if defined? @md.rights.all #and ? @md.rights.all
toc_shared << rights
end
if defined? @md.prefix_b
toc_shared << prefix_b
end
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 \
and not @md.rights.all.empty?
@segtoc << rights
end
@segtoc << prefix_b if @md.prefix_b
#Segtoc tail added here
@segtoc << "
\n" #bugfix sort later DEBUGNOW
@segtoc << @seg_toc_band_bottom
@segtoc << format_head_toc.seg_navigation_tail << format_head_toc.html_close
@segtoc=@segtoc.flatten.compact #watch
if @md.opt.act[:html_seg][:set]==:on
SiSU_HTML::Source::Output.new(@segtoc,@md).segtoc
end
@segtoc=[]
@toc[:scr],@toc[:seg]=[],[]
toc_shared
end
end
class Table < SiSU_HTML_Table::TableHTML
end
class Scroll < SiSU_HTML_Scroll::Scroll
end
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
def publish
scroll=[]
scroll << @scr_toc << '' << @scr_body << @scr_endnotes << @scr_owner_details << '
' << @scr_tails
scroll=scroll.flatten.compact #watch
end
end
class Seg < SiSU_HTML_Seg::Seg
end
class Output
def initialize(data='',md='')
@data,@md=data,md
@file=SiSU_Env::FileOp.new(md)
@o_str ||=SiSU_Env::ProcessingSettings.new(md).output_dir_structure
end
def scroll
if @md.opt.act[:html_scroll][:set]==:on
begin
@filename_html_scroll=@file.write_file.html_scroll
@data.each do |para|
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::Rescued.new($!,$@,@md.opt.selections.str,@md.fns).location do
__LINE__.to_s + ':' + __FILE__
end
ensure
@filename_html_scroll.close
end
end
end
def segtoc
if @md.opt.act[:html_seg][:set]==:on
begin
@filename_html_segtoc=@file.write_file.html_segtoc
@data.each do |para|
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::Rescued.new($!,$@,@md.opt.selections.str,@md.fns).location do
__LINE__.to_s + ':' + __FILE__
end
ensure
@filename_html_segtoc.close
pwd_set=Dir.pwd
idx_lnk=(@o_str.dump_or_redirect?) \
? @file.base_filename.manifest
: @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)
end
end
end
end
end
end
__END__