class SiSU_HTML::Source

Public Class Methods

new(opt) click to toggle source
# File lib/sisu/html.rb, line 76
def initialize(opt)
  @opt=opt
  @particulars=SiSU_Particulars::CombinedSingleton.instance.get_all(opt)
end

Public Instance Methods

read() click to toggle source
# File lib/sisu/html.rb, line 80
def read
  begin
    songsheet
  ensure
    SiSU_Env::CreateSite.new(@opt).cp_css
    SiSU_Env::CreateSite.new(@opt).cp_base_images
    Dir.chdir(@opt.f_pth[:pth])
  end
end
songsheet() click to toggle source
# File lib/sisu/html.rb, line 89
def songsheet
  begin
    @md=@particulars.md
    @fnb=@md.fnb
    @env=@particulars.env
    primary_output_file=(@opt.act[:html_seg][:set]==:on) \
    ? (@md.file.output_path.html_seg.dir + '/' + @md.file.base_filename.html_segtoc)
    : (@md.file.output_path.html_scroll.dir + '/' + @md.file.base_filename.html_scroll)
    unless @opt.act[:quiet][:set]==:on
      tool=(@opt.act[:verbose][:set]==:on \
      || @opt.act[:verbose_plus][:set]==:on \
      || @opt.act[:maintenance][:set]==:on) \
      ? ("#{@env.program.web_browser} file://#{primary_output_file}")
      : ("[#{@opt.f_pth[:lng_is]}] #{@opt.fno}")
      (@opt.act[:verbose][:set]==:on \
      || @opt.act[:verbose_plus][:set]==:on \
      || @opt.act[:maintenance][:set]==:on) \
      ? SiSU_Screen::Ansi.new(
          @opt.act[:color_state][:set],
          'HTML',
          tool
        ).green_hi_blue
      : SiSU_Screen::Ansi.new(
          @opt.act[:color_state][:set],
          'HTML',
          tool
        ).green_title_hi
      if (@opt.act[:verbose_plus][:set]==:on \
      || @opt.act[:maintenance][:set]==:on)
        SiSU_Screen::Ansi.new(
          @opt.act[:color_state][:set],
          @opt.fns,
          "file://#{primary_output_file}"
        ).flow
      end
    end
    data=nil
    tuned_file_array=SiSU_HTML::Source::HTML_Environment.new(@particulars).tuned_file_instructions
    data=tuned_file_array
    if @opt.act[:html_scroll][:set]==:on
      scr_endnotes=SiSU_HTML::Source::Endnotes.new(data,@md).scroll
    end
    toc=SiSU_HTML::Source::Toc.new(@md,data).songsheet
    links_guide=SiSU_HTML::Source::LinksGuide.new(data,@md).toc
    data=tuned_file_array
    scr_toc=SiSU_HTML::Source::ScrollHeadAndSegToc.new(@md,toc,links_guide).in_common #watch
    if @opt.act[:html_seg][:set]==:on
      SiSU_HTML::Source::Seg.new(@md,data).songsheet
    end
    data=tuned_file_array
    if @opt.act[:html_scroll][:set]==:on
      scr=SiSU_HTML::Source::Scroll.new(@md,data,scr_endnotes).songsheet
      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
    end
  rescue
    SiSU_Errors::Rescued.new($!,$@,@opt.selections.str,@opt.fns).location do
      __LINE__.to_s + ':' + __FILE__
    end
  ensure
    unless (@opt.act[:verbose_plus][:set]==:on \
    || @opt.act[:maintenance][:set]==:on)
      texfiles=Dir["#{@env.processing_path.tune}/#{@opt.fns}*"]
      texfiles.each do |f|
        if FileTest.file?(f)
          File.unlink(f)
        end
      end
    end
    SiSU_Env::Clear.new(@opt.selections.str,@opt.fns,@md).param_instantiate
    @@flag,@@scr,@@seg,@@seg_endnotes,@@seg_subtoc={},{},{},{},{}
    @@tracker=0
    @@seg_name,@@seg_name_x,@@seg_subtoc_array,@@seg_endnotes_array,@@tablefoot=Array.new(5){[]}
    @@filename_seg,@@seg_url,@@to_lev4,@@get_hash_to,@@get_hash_fn='','','','',''
  end
end