class Muwu::RenderHtmlPartialBuilder::DocumentHtmlBuilder

Attributes

renderer[RW]

Public Class Methods

build() { |builder| ... } click to toggle source
# File lib/muwu/render_html_partial_builder/render_document_html_builder.rb, line 15
def self.build
  builder = new
  yield(builder)
  builder.renderer
end
new() click to toggle source
# File lib/muwu/render_html_partial_builder/render_document_html_builder.rb, line 22
def initialize
  @renderer = RenderHtmlPartial::DocumentHtml.new
end

Public Instance Methods

build_from_manifest_document(document) click to toggle source
# File lib/muwu/render_html_partial_builder/render_document_html_builder.rb, line 27
def build_from_manifest_document(document)
  @document = document
  @project = document.project
  set_destination
  set_html_lang
  set_html_title
  set_head_css_method
  set_head_js_libraries
  set_head_js_method
  set_head_includes_metadata_tags
  set_head_metadata
  set_project
  set_tasks
  finally_set_css_filename
  finally_set_js_filename
end
finally_set_css_filename() click to toggle source
# File lib/muwu/render_html_partial_builder/render_document_html_builder.rb, line 45
def finally_set_css_filename
  if @renderer.head_css_method == :link
    @renderer.head_css_filename = @document.css_filename
  end
end
finally_set_js_filename() click to toggle source
# File lib/muwu/render_html_partial_builder/render_document_html_builder.rb, line 52
def finally_set_js_filename
  if @renderer.head_js_method == :link
    @renderer.head_js_filename = @document.js_filename
  end
end
set_destination() click to toggle source
# File lib/muwu/render_html_partial_builder/render_document_html_builder.rb, line 59
def set_destination
  @renderer.destination = @document.destination
end
set_head_css_method() click to toggle source
# File lib/muwu/render_html_partial_builder/render_document_html_builder.rb, line 86
def set_head_css_method
  @renderer.head_css_method = @document.css_include_method
end
set_head_includes_metadata_tags() click to toggle source
# File lib/muwu/render_html_partial_builder/render_document_html_builder.rb, line 74
def set_head_includes_metadata_tags
  @renderer.head_includes_metadata_tags = @project.options.html_head_includes_metadata_tags
end
set_head_js_libraries() click to toggle source
# File lib/muwu/render_html_partial_builder/render_document_html_builder.rb, line 91
def set_head_js_libraries
  @renderer.head_js_libraries = @document.js_head_libraries
end
set_head_js_method() click to toggle source
# File lib/muwu/render_html_partial_builder/render_document_html_builder.rb, line 96
def set_head_js_method
  @renderer.head_js_method = @document.js_include_method
end
set_head_metadata() click to toggle source
# File lib/muwu/render_html_partial_builder/render_document_html_builder.rb, line 79
def set_head_metadata
  if @project.options.html_head_includes_metadata_tags
    @renderer.head_metadata = SanitizerHelper::sanitize_metadata(@project.metadata)
  end
end
set_html_lang() click to toggle source
# File lib/muwu/render_html_partial_builder/render_document_html_builder.rb, line 64
def set_html_lang
  @renderer.html_lang = @project.options.html_lang
end
set_html_title() click to toggle source
# File lib/muwu/render_html_partial_builder/render_document_html_builder.rb, line 69
def set_html_title
  @renderer.html_title = determine_html_title
end
set_project() click to toggle source
# File lib/muwu/render_html_partial_builder/render_document_html_builder.rb, line 101
def set_project
  @renderer.project = @project
end
set_tasks() click to toggle source
# File lib/muwu/render_html_partial_builder/render_document_html_builder.rb, line 106
def set_tasks
  @renderer.tasks = determine_document_tasks
end

Private Instance Methods

build_contents(task) click to toggle source
# File lib/muwu/render_html_partial_builder/render_document_html_builder.rb, line 115
def build_contents(task)
  RenderHtmlPartialBuilder::ContentsBuilder.build do |b|
    b.build_from_manifest_task_contents(task)
  end
end
build_metadata(task) click to toggle source
# File lib/muwu/render_html_partial_builder/render_document_html_builder.rb, line 122
def build_metadata(task)
  RenderHtmlPartialBuilder::MetadataBuilder.build do |b|
    b.build_from_manifest_metadata(task)
  end
end
build_navigator(task) click to toggle source
# File lib/muwu/render_html_partial_builder/render_document_html_builder.rb, line 129
def build_navigator(task)
  RenderHtmlPartialBuilder::NavigatorBuilder.build do |b|
    b.build_from_manifest_task_navigator(task)
  end
end
build_subcontents(task) click to toggle source
# File lib/muwu/render_html_partial_builder/render_document_html_builder.rb, line 136
def build_subcontents(task)
  RenderHtmlPartialBuilder::SubcontentsBuilder.build do |b|
    b.build_from_manifest_task_subcontents(task)
  end
end
build_text(task) click to toggle source
# File lib/muwu/render_html_partial_builder/render_document_html_builder.rb, line 143
def build_text(task)
  RenderHtmlPartialBuilder::TextBuilder.build do |b|
    b.build_from_manifest_text(task)
  end
end
build_title(task) click to toggle source
# File lib/muwu/render_html_partial_builder/render_document_html_builder.rb, line 150
def build_title(task)
  RenderHtmlPartialBuilder::TitleBuilder.build do |b|
    b.build_from_manifest_title(task)
  end
end
determine_document_tasks() click to toggle source
# File lib/muwu/render_html_partial_builder/render_document_html_builder.rb, line 157
def determine_document_tasks
  tasks = []
  @document.tasks.each do |task|
    case task
    when ManifestTask::Contents
      tasks << build_contents(task)
      
    when ManifestTask::Metadata
      tasks << build_metadata(task)
      
    when ManifestTask::Navigator
      tasks << build_navigator(task)
      
    when ManifestTask::Subcontents
      tasks << build_subcontents(task)
      
    when ManifestTask::Text
      tasks << build_text(task)
      
    when ManifestTask::Title
      tasks << build_title(task)
    end
  end
  tasks
end
determine_html_title() click to toggle source
# File lib/muwu/render_html_partial_builder/render_document_html_builder.rb, line 184
def determine_html_title
  if @project.manifest.documents_html_count == 1
    determine_html_title_single_document
  elsif @project.manifest.documents_html_count > 1
    determine_html_title_multiple_documents
  end
end
determine_html_title_multiple_documents() click to toggle source
# File lib/muwu/render_html_partial_builder/render_document_html_builder.rb, line 193
def determine_html_title_multiple_documents
  if @document.index == 0
    return @project.title
  elsif @document.index > 0
    project_title = @project.title
    page_current = @document.index + 1
    page_last = @project.manifest.documents_html_count
    return "#{project_title} - page #{page_current} of #{page_last}"
  end
end
determine_html_title_single_document() click to toggle source
# File lib/muwu/render_html_partial_builder/render_document_html_builder.rb, line 204
def determine_html_title_single_document
  @project.title
end