lib/ascii_binder/engine.rb in ascii_binder-0.1.15.1 vs lib/ascii_binder/engine.rb in ascii_binder-0.1.15.2
- old
+ new
@@ -186,16 +186,17 @@
# TODO: This process of rebuilding the entire nav for every page will not scale well.
# As the doc set increases, we will need to think about refactoring this.
args[:breadcrumb_root], args[:breadcrumb_group], args[:breadcrumb_subgroup], args[:breadcrumb_topic] = extract_breadcrumbs(args)
args[:breadcrumb_subgroup_block] = ''
- args[:subtopic_shim] = ''
if args[:breadcrumb_subgroup]
args[:breadcrumb_subgroup_block] = "<li class=\"hidden-xs active\">#{args[:breadcrumb_subgroup]}</li>"
- args[:subtopic_shim] = '../'
end
+ args[:subtopic_shim] = '../' * (args[:topic_id].split('::').length - 2)
+ args[:subtopic_shim] = '' if args[:subtopic_shim].nil?
+
template_path = File.expand_path("#{docs_root_dir}/_templates/page.html.erb")
template_renderer.render(template_path, args)
end
def extract_breadcrumbs(args)
@@ -464,14 +465,10 @@
doc = without_warnings { Asciidoctor.load topic_adoc, :header_footer => false, :safe => :unsafe, :attributes => page_attrs }
article_title = doc.doctitle || topic.name
topic_html = doc.render
- dir_depth = ''
- if branch_config.dir.split('/').length > 1
- dir_depth = '../' * (branch_config.dir.split('/').length - 1)
- end
# This is logic bridges newer arbitrary-depth-tolerant code to
# older depth-limited code. Truly removing depth limitations will
# require changes to page templates in user docs repos.
breadcrumb = topic.breadcrumb
@@ -482,12 +479,13 @@
subgroup_title = nil
subgroup_id = nil
if breadcrumb.length == 3
subgroup_title = breadcrumb[1][:name]
subgroup_id = breadcrumb[1][:id]
- dir_depth = '../' + dir_depth
end
+ dir_depth = '../' * topic.breadcrumb[-1][:id].split('::').length
+ dir_depth = '' if dir_depth.nil?
preview_path = topic.preview_path(distro.id,branch_config.dir)
topic_publish_url = topic.topic_publish_url(distro.site.url,branch_config.dir)
page_args = {
@@ -506,13 +504,13 @@
:content => topic_html,
:navigation => navigation,
:group_id => group_id,
:subgroup_id => subgroup_id,
:topic_id => topic_id,
- :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",
+ :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)