From 737714e822ef47a25845f0ed46c891a88004932c Mon Sep 17 00:00:00 2001 From: Jason Boxman Date: Thu, 29 Apr 2021 00:41:52 -0400 Subject: [PATCH 1/2] WIP --- lib/ascii_binder/engine.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/ascii_binder/engine.rb b/lib/ascii_binder/engine.rb index 43e2745..6416c84 100644 --- a/lib/ascii_binder/engine.rb +++ b/lib/ascii_binder/engine.rb @@ -464,6 +464,7 @@ def configure_and_generate_page(topic,branch_config,navigation) ]) File.open topic.source_path, 'r' do |topic_file| + relative_prefix = Pathname.new(topic_file).relative_from_path(Pathname.cwd()) doc = without_warnings { Asciidoctor.load topic_file, :header_footer => false, :safe => :unsafe, :attributes => page_attrs, :base_dir => "." } article_title = doc.doctitle || topic.name From b646543f11cc4b370f5c21f4c5466d8eb5dfdf3a Mon Sep 17 00:00:00 2001 From: Jason Boxman Date: Thu, 29 Apr 2021 01:50:36 -0400 Subject: [PATCH 2/2] Include relative path to root as attribute WIP --- lib/ascii_binder/engine.rb | 16 +++++++++++++--- lib/ascii_binder/version.rb | 2 +- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/lib/ascii_binder/engine.rb b/lib/ascii_binder/engine.rb index 6416c84..060df5f 100644 --- a/lib/ascii_binder/engine.rb +++ b/lib/ascii_binder/engine.rb @@ -464,9 +464,19 @@ def configure_and_generate_page(topic,branch_config,navigation) ]) File.open topic.source_path, 'r' do |topic_file| - relative_prefix = Pathname.new(topic_file).relative_from_path(Pathname.cwd()) - - doc = without_warnings { Asciidoctor.load topic_file, :header_footer => false, :safe => :unsafe, :attributes => page_attrs, :base_dir => "." } + relative_prefix = Pathname.pwd().relative_path_from(File.dirname(topic_file)) + #puts Pathname.pwd() + #puts topic_file.path + puts relative_prefix + #puts topic.preview_path(distro.id,branch_config.dir) + + #relative_prefix = Pathname.new(topic.preview_path(distro.id,branch_config.dir)).relative_path_from(topic_file) + #relative_prefix = Pathname.new(branch_config.dir).relative_path_from(topic_file) + #puts relative_prefix + #puts branch_config.dir + #puts topic.preview_path(distro.id,branch_config.dir) + + doc = without_warnings { Asciidoctor.load topic_file, :header_footer => false, :safe => :unsafe, :attributes => ["relative_prefix=#{relative_prefix}"].concat(page_attrs), :base_dir => "." } article_title = doc.doctitle || topic.name topic_html = doc.render diff --git a/lib/ascii_binder/version.rb b/lib/ascii_binder/version.rb index fa41e7a..a200e7f 100644 --- a/lib/ascii_binder/version.rb +++ b/lib/ascii_binder/version.rb @@ -1,3 +1,3 @@ module AsciiBinder - VERSION = "0.2.2" + VERSION = "0.2.3" end