Class: SiSU_HTML::Source

Inherits:
Object
  • Object
show all
Defined in:
lib/sisu/html.rb

Defined Under Namespace

Classes: Endnotes, HTML_Environment, LinksGuide, Output, Scroll, ScrollHeadAndSegToc, ScrollOutput, Seg, Table, Toc

Instance Method Summary collapse

Constructor Details

#initialize(opt) ⇒ Source

Returns a new instance of Source.



78
79
80
81
# File 'lib/sisu/html.rb', line 78

def initialize(opt)
  @opt=opt
  @particulars=SiSU_Particulars::CombinedSingleton.instance.get_all(opt)
end

Instance Method Details

#readObject



82
83
84
85
86
87
88
89
90
# File 'lib/sisu/html.rb', line 82

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

#songsheetObject



91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
# File 'lib/sisu/html.rb', line 91

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