Class: SiSU_HTML_Seg::Output

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

Instance Method Summary collapse

Constructor Details

#initialize(md, outputfile, per, minitoc, type = '') ⇒ Output

Returns a new instance of Output.



64
65
66
67
68
69
70
71
72
73
# File 'lib/sisu/html_segments.rb', line 64

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

Instance Method Details

#outputObject



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
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
174
175
# File 'lib/sisu/html_segments.rb', line 74

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'
      =SiSU_Metadata::Summary.new(@md).html_display.
      @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} \
      <<  \
      << '</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