class SiSU_HTML_Seg::Output

Public Class Methods

new(md,outputfile,per,minitoc,type='') click to toggle source
# File lib/sisu/html_segments.rb, line 62
def initialize(md,outputfile,per,minitoc,type='')
  @md, @output_seg_file,@per,@minitoc,@type=
    md,outputfile,      per,minitoc,  type
  @title_banner_=SiSU_Env::CreateSite.new(@md.opt).html_seg_title_banner?
  @file=SiSU_Env::FileOp.new(@md)
  @make=SiSU_Env::ProcessingSettings.new(@md)
  @cl=(@make.build.html_minitoc?) \
  ? 'content'
  : 'content0'
end

Public Instance Methods

output() click to toggle source
# File lib/sisu/html_segments.rb, line 72
def output
  if @per.title =~/\S/
    filename_seg=[]
    if @make.build.html_top_band?
      filename_seg \
      << @per.title \
      << @per.tocband_banner
    else
      filename_seg \
      << @per.title
    end
    if @type=='endnotes'
      @per.headings=[]
      format_head_seg=SiSU_HTML_Format::HeadSeg.new(@md)
      if @title_banner_
        @per.headings \
        << format_head_seg.
          title_banner(@md.title.main,@md.title.sub,@author)
      end
      txt_obj={ txt: 'Endnotes', ocn_display: '' }
      format_seg=SiSU_HTML_Format::FormatSeg.new(@md,txt_obj)
      @per.headings \
      << format_seg.title_heading1
      filename_seg \
      << @per.heading_endnotes \
      << @minitoc << @per.headings \
      << %{\n<div class="#{@cl}">\n} \
      << @per.endnote_all \
      << '</div>' # << '</div>'
    elsif @type=='idx'
      @per.headings=[]
      format_head_seg=SiSU_HTML_Format::HeadSeg.new(@md)
      if @title_banner_
        @per.headings \
        << format_head_seg.
          title_banner(@md.title.main,@md.title.sub,@author)
      end
      txt_obj={ txt: 'Index', ocn_display: '' }
      format_seg=SiSU_HTML_Format::FormatSeg.new(@md,txt_obj)
      @per.headings << format_seg.title_heading1
      filename_seg \
      << @per.heading_idx \
      << @minitoc << @per.headings \
      << %{\n<div class="#{@cl}">\n} \
      << @per.idx \
      << '</div>' # << '</div>'
    elsif @type=='metadata'
      metadata=SiSU_Metadata::Summary.new(@md).html_display.metadata
      @per.headings=[]
      format_head_seg=SiSU_HTML_Format::HeadSeg.new(@md)
      if @title_banner_
        @per.headings \
        << format_head_seg.
          title_banner(@md.title.main,@md.title.sub,@author)
      end
      txt_obj={ txt: 'Metadata', ocn_display: '' }
      format_seg=SiSU_HTML_Format::FormatSeg.new(@md,txt_obj)
      @per.headings \
      << format_seg.title_heading1
      filename_seg \
      << @per.heading_idx \
      << @minitoc \
      << @per.headings \
      << %{\n<div class="#{@cl}">\n} \
      << metadata \
      << '</div>' # << '</div>'
    else
      if @make.build.html_top_band?
        filename_seg \
        << @minitoc \
        << @per.headings \
        << @per.main \
        << "\n</div>\n"
      else
        filename_seg \
        << @minitoc \
        << @per.main \
        << "\n</div>\n"
      end
    end
    filename_seg <<=if @make.build.html_top_band?
      @per.tail \
      << @per.tocband_bannerless \
      << @per.credits
    else
      @per.tail \
      << @per.credits
    end
    filename_seg=filename_seg.flatten.compact #watch
    filename_seg.each do |str|
      unless str =~/\A\s*\Z/
        str=str.strip.
          gsub(Xx[:html_relative2],
            @file.path_rel_links.html_seg_2).
          gsub(Xx[:html_relative1],
            @file.path_rel_links.html_seg_1)
        @output_seg_file << str
      end
    end
    @output_seg_file.close
  end
end