lib/ascii_binder/engine.rb in ascii_binder-0.1.10.1 vs lib/ascii_binder/engine.rb in ascii_binder-0.1.11
- old
+ new
@@ -435,25 +435,41 @@
process_topic_entity_list(branch_config,single_page_path,navigation,topic_entity.subitems,preview_path)
elsif topic_entity.is_topic?
if single_page_path.length == 0
puts " - #{topic_entity.repo_path}"
end
- configure_and_generate_page(topic_entity,branch_config,navigation)
+ if topic_entity.is_alias?
+ configure_and_generate_alias(topic_entity,branch_config)
+ else
+ configure_and_generate_page(topic_entity,branch_config,navigation)
+ end
end
end
end
+ def configure_and_generate_alias(topic,branch_config)
+ distro = branch_config.distro
+ topic_target = topic.topic_alias
+ unless valid_url?(topic_target)
+ topic_target = File.join(branch_config.branch_url_base,topic_target + ".html")
+ end
+ topic_text = alias_text(topic_target)
+ preview_path = topic.preview_path(distro.id,branch_config.dir)
+ File.write(preview_path,topic_text)
+ end
+
def configure_and_generate_page(topic,branch_config,navigation)
distro = branch_config.distro
topic_adoc = File.open(topic.source_path,'r').read
page_attrs = asciidoctor_page_attrs([
"imagesdir=#{File.join(topic.parent.source_path,'images')}",
branch_config.distro.id,
"product-title=#{branch_config.distro_name}",
"product-version=#{branch_config.name}",
- "product-author=#{branch_config.distro_author}"
+ "product-author=#{branch_config.distro_author}",
+ "repo_path=#{topic.repo_path}"
])
doc = Asciidoctor.load topic_adoc, :header_footer => false, :safe => :unsafe, :attributes => page_attrs
article_title = doc.doctitle || topic.name
@@ -500,9 +516,10 @@
:css_path => "../../#{dir_depth}#{branch_config.dir}/#{STYLESHEET_DIRNAME}/",
:javascripts_path => "../../#{dir_depth}#{branch_config.dir}/#{JAVASCRIPT_DIRNAME}/",
:images_path => "../../#{dir_depth}#{branch_config.dir}/#{IMAGE_DIRNAME}/",
:site_home_path => "../../#{dir_depth}index.html",
:template_path => template_dir,
+ :repo_path => topic.repo_path,
}
full_file_text = page(page_args)
File.write(preview_path,full_file_text)
end