class Muwu::RenderHtmlPartial::Subcontents
Attributes
destination[RW]
href_helper[RW]
html_attr_id[RW]
item_depth_max[RW]
project[RW]
sections[RW]
text_root_block[RW]
text_root_blocks[RW]
text_root_name[RW]
will_render_section_numbers[RW]
Public Instance Methods
render()
click to toggle source
# File lib/muwu/render_html_partial/render_subcontents.rb, line 27 def render @destination.margin_to_zero @destination.padding_vertical(1) do write_tag_div_open render_project_title @text_root_blocks.each do |text_root_block| render_contents_element(text_root_block.sections) end write_tag_div_close end @destination.margin_to_zero end
render_contents_element(sections)
click to toggle source
# File lib/muwu/render_html_partial/render_subcontents.rb, line 41 def render_contents_element(sections) @destination.margin_indent do case @will_render_section_numbers when false render_ol(sections) when true render_table(sections) end end end
render_ol(sections)
click to toggle source
# File lib/muwu/render_html_partial/render_subcontents.rb, line 53 def render_ol(sections) write_tag_ol_open @destination.margin_indent do sections.each do |section| render_ol_li(section) end end write_tag_ol_close end
render_ol_li(section)
click to toggle source
# File lib/muwu/render_html_partial/render_subcontents.rb, line 64 def render_ol_li(section) if task_depth_is_within_range(section) case section when ManifestTask::TextReadfile write_tag_li_open render_ol_li_heading(section) write_tag_li_close_inline when ManifestTask::TextGroup write_tag_li_open @destination.margin_indent do render_ol_li_heading_and_text_item(section) end write_tag_li_close_outline end end end
render_ol_li_heading(text_item)
click to toggle source
# File lib/muwu/render_html_partial/render_subcontents.rb, line 82 def render_ol_li_heading(text_item) render_tag_a_section_heading(text_item) end
render_ol_li_heading_and_text_item(text_item)
click to toggle source
# File lib/muwu/render_html_partial/render_subcontents.rb, line 87 def render_ol_li_heading_and_text_item(text_item) render_tag_a_section_heading(text_item, trailing_line_feed: true) render_ol(text_item.sections) end
render_project_title()
click to toggle source
# File lib/muwu/render_html_partial/render_subcontents.rb, line 93 def render_project_title write_tag_h1_title end
render_table(sections)
click to toggle source
# File lib/muwu/render_html_partial/render_subcontents.rb, line 98 def render_table(sections) write_tag_table_open @destination.margin_indent do sections.each do |section| render_table_tr(section) end end write_tag_table_close end
render_table_tr(section)
click to toggle source
# File lib/muwu/render_html_partial/render_subcontents.rb, line 109 def render_table_tr(section) if task_depth_is_within_range(section) html_id = ['subcontents', @text_root_name, section.numbering.join('_')].join('_') write_tag_tr_open(html_id) @destination.margin_indent do if section.is_parent_heading render_table_tr_td_number(section) render_table_tr_td_heading_and_text_item(section) elsif section.is_not_parent_heading render_table_tr_td_number(section) render_table_tr_td_heading(section) end end write_tag_tr_close end end
render_table_tr_td_heading(text_item)
click to toggle source
# File lib/muwu/render_html_partial/render_subcontents.rb, line 127 def render_table_tr_td_heading(text_item) write_tag_td_open(attr_list: "class='heading'") render_tag_a_section_heading(text_item) write_tag_td_close_inline end
render_table_tr_td_heading_and_text_item(text_item)
click to toggle source
# File lib/muwu/render_html_partial/render_subcontents.rb, line 134 def render_table_tr_td_heading_and_text_item(text_item) write_tag_td_open(attr_list: "class='heading'") render_tag_a_section_heading(text_item, trailing_line_feed: true) @destination.margin_indent do render_table(text_item.sections) end write_tag_td_close_outline end
render_table_tr_td_number(text_item)
click to toggle source
# File lib/muwu/render_html_partial/render_subcontents.rb, line 144 def render_table_tr_td_number(text_item) write_tag_td_open(attr_list: "class='number'") render_tag_a_section_number(text_item, attr_list: "tabindex='-1'") write_tag_td_close_inline end
render_tag_a_section_heading(text_item, trailing_line_feed: false)
click to toggle source
# File lib/muwu/render_html_partial/render_subcontents.rb, line 151 def render_tag_a_section_heading(text_item, trailing_line_feed: false) href = @href_helper.to_text_item(text_item) write_tag_a_open(href) write_text_section_heading(text_item) write_tag_a_close if trailing_line_feed write_lf end end
render_tag_a_section_number(text_object, attr_list: nil)
click to toggle source
# File lib/muwu/render_html_partial/render_subcontents.rb, line 162 def render_tag_a_section_number(text_object, attr_list: nil) href = @href_helper.to_text_item(text_object) write_tag_a_open(href, attr_list: attr_list) write_text_section_number(text_object) write_tag_a_close end
write_lf()
click to toggle source
# File lib/muwu/render_html_partial/render_subcontents.rb, line 170 def write_lf @destination.write_lf end
write_tag_a_close()
click to toggle source
# File lib/muwu/render_html_partial/render_subcontents.rb, line 175 def write_tag_a_close @destination.write_inline tag_a_close end
write_tag_a_open(href_id, attr_list: nil)
click to toggle source
# File lib/muwu/render_html_partial/render_subcontents.rb, line 180 def write_tag_a_open(href_id, attr_list: nil) @destination.write_inline tag_a_open(href_id, attr_list: attr_list) end
write_tag_div_close()
click to toggle source
# File lib/muwu/render_html_partial/render_subcontents.rb, line 185 def write_tag_div_close @destination.write_line tag_div_close end
write_tag_div_open()
click to toggle source
# File lib/muwu/render_html_partial/render_subcontents.rb, line 190 def write_tag_div_open @destination.write_line tag_div_open end
write_tag_h1_title()
click to toggle source
# File lib/muwu/render_html_partial/render_subcontents.rb, line 195 def write_tag_h1_title @destination.write_line tag_h1_title end
write_tag_li_close()
click to toggle source
# File lib/muwu/render_html_partial/render_subcontents.rb, line 200 def write_tag_li_close write_tag_li_close_outline end
write_tag_li_close_inline()
click to toggle source
# File lib/muwu/render_html_partial/render_subcontents.rb, line 205 def write_tag_li_close_inline @destination.write_inline_end tag_li_close end
write_tag_li_close_outline()
click to toggle source
# File lib/muwu/render_html_partial/render_subcontents.rb, line 210 def write_tag_li_close_outline @destination.write_line tag_li_close end
write_tag_li_open()
click to toggle source
# File lib/muwu/render_html_partial/render_subcontents.rb, line 215 def write_tag_li_open @destination.write_inline_indented tag_li_open end
write_tag_ol_close()
click to toggle source
# File lib/muwu/render_html_partial/render_subcontents.rb, line 220 def write_tag_ol_close @destination.write_line tag_ol_close end
write_tag_ol_open()
click to toggle source
# File lib/muwu/render_html_partial/render_subcontents.rb, line 225 def write_tag_ol_open @destination.write_line tag_ol_open end
write_tag_table_close()
click to toggle source
# File lib/muwu/render_html_partial/render_subcontents.rb, line 230 def write_tag_table_close @destination.write_line tag_table_close end
write_tag_table_open()
click to toggle source
# File lib/muwu/render_html_partial/render_subcontents.rb, line 235 def write_tag_table_open @destination.write_line tag_table_open end
write_tag_td_close()
click to toggle source
# File lib/muwu/render_html_partial/render_subcontents.rb, line 240 def write_tag_td_close write_tag_td_close_outline end
write_tag_td_close_inline()
click to toggle source
# File lib/muwu/render_html_partial/render_subcontents.rb, line 245 def write_tag_td_close_inline @destination.write_inline_end tag_td_close end
write_tag_td_close_outline()
click to toggle source
# File lib/muwu/render_html_partial/render_subcontents.rb, line 250 def write_tag_td_close_outline @destination.write_line tag_td_close end
write_tag_td_open(attr_list: nil)
click to toggle source
# File lib/muwu/render_html_partial/render_subcontents.rb, line 255 def write_tag_td_open(attr_list: nil) @destination.write_inline_indented tag_td_open(attr_list: attr_list) end
write_tag_tr_close()
click to toggle source
# File lib/muwu/render_html_partial/render_subcontents.rb, line 260 def write_tag_tr_close @destination.write_line tag_tr_close end
write_tag_tr_open(html_id)
click to toggle source
# File lib/muwu/render_html_partial/render_subcontents.rb, line 265 def write_tag_tr_open(html_id) @destination.write_line tag_tr_open(html_id) end
write_text_section_heading(text_item)
click to toggle source
# File lib/muwu/render_html_partial/render_subcontents.rb, line 270 def write_text_section_heading(text_item) @destination.write_inline text_item.heading end
write_text_section_number(text_item)
click to toggle source
# File lib/muwu/render_html_partial/render_subcontents.rb, line 275 def write_text_section_number(text_item) @destination.write_inline text_item.numbering.join('.') end
Private Instance Methods
tag_a_close()
click to toggle source
# File lib/muwu/render_html_partial/render_subcontents.rb, line 284 def tag_a_close "</a>" end
tag_a_open(href_id, attr_list: nil)
click to toggle source
# File lib/muwu/render_html_partial/render_subcontents.rb, line 289 def tag_a_open(href_id, attr_list: nil) ["<a", "class='document_link'", "href='#{href_id}'", attr_list].compact.join(' ').concat('>') end
tag_div_close()
click to toggle source
# File lib/muwu/render_html_partial/render_subcontents.rb, line 294 def tag_div_close "</div>" end
tag_div_open()
click to toggle source
# File lib/muwu/render_html_partial/render_subcontents.rb, line 299 def tag_div_open "<div class='subcontents' data-text_root_name='#{@text_root_name}' id='#{@html_attr_id}'>" end
tag_h1_title()
click to toggle source
# File lib/muwu/render_html_partial/render_subcontents.rb, line 304 def tag_h1_title "<h1>#{@project.title}</h1>" end
tag_li_close()
click to toggle source
# File lib/muwu/render_html_partial/render_subcontents.rb, line 309 def tag_li_close "</li>" end
tag_li_open()
click to toggle source
# File lib/muwu/render_html_partial/render_subcontents.rb, line 314 def tag_li_open "<li>" end
tag_ol_close()
click to toggle source
# File lib/muwu/render_html_partial/render_subcontents.rb, line 319 def tag_ol_close "</ol>" end
tag_ol_open()
click to toggle source
# File lib/muwu/render_html_partial/render_subcontents.rb, line 324 def tag_ol_open "<ol>" end
tag_table_close()
click to toggle source
# File lib/muwu/render_html_partial/render_subcontents.rb, line 329 def tag_table_close "</table>" end
tag_table_open()
click to toggle source
# File lib/muwu/render_html_partial/render_subcontents.rb, line 334 def tag_table_open "<table class='document_links'>" end
tag_td_close()
click to toggle source
# File lib/muwu/render_html_partial/render_subcontents.rb, line 339 def tag_td_close "</td>" end
tag_td_open(attr_list: nil)
click to toggle source
# File lib/muwu/render_html_partial/render_subcontents.rb, line 344 def tag_td_open(attr_list: nil) ["<td", attr_list].compact.join(' ').concat('>') end
tag_tr_close()
click to toggle source
# File lib/muwu/render_html_partial/render_subcontents.rb, line 349 def tag_tr_close "</tr>" end
tag_tr_open(html_id)
click to toggle source
# File lib/muwu/render_html_partial/render_subcontents.rb, line 354 def tag_tr_open(html_id) "<tr id='#{html_id}'>" end
task_depth_is_within_range(text_item)
click to toggle source
# File lib/muwu/render_html_partial/render_subcontents.rb, line 359 def task_depth_is_within_range(text_item) result = nil if @item_depth_max == nil result = true elsif text_item.section_depth <= @item_depth_max result = true elsif text_item.section_depth > @item_depth_max result = false end result end