X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=_plugins%2Fmanual.rb;h=2a5d905b9ef590f41e33ac1f515cd1e78e53e773;hb=72b45cdd036b0cc51a55c414298315ebc105abed;hp=cde76c4b94504bfac0cfc455511f768dfef01b63;hpb=ae6efdc4a0dd1825a30a1b95b70d6a5f799713a9;p=ardour-manual-diverged
diff --git a/_plugins/manual.rb b/_plugins/manual.rb
index cde76c4..2a5d905 100644
--- a/_plugins/manual.rb
+++ b/_plugins/manual.rb
@@ -22,7 +22,7 @@ module Manual
def self.traverse(path, directory_sort = false, paths = [], key_paths = [], &block)
- entries = Dir.glob(File.join(path,'*'))
+ entries = Dir.glob(File.join(path,'*')).sort
entries.sort_by! { |e| File.directory?(e) ? 1 : 0 } if directory_sort
@@ -63,7 +63,7 @@ module Manual
end
block_given? ? block.call(h) : h
- end
+ end.compact
end
def self.extract_data(filename)
@@ -131,7 +131,13 @@ module Manual
"
#{child[:title]}"
end.uniq
- ""
+ "
+
This chapter covers the following topics:
+
+
+ "
end
end
end
@@ -177,12 +183,16 @@ module Manual
current_a = current.split('/').reject(&:empty?)
tree = Manual.traverse_data(@@data_tree) do |entry|
-
+
url = entry[:url]
url_a = url.split('/').reject(&:empty?)
+ depth = url_a.length
is_current, position, level = *process_hierarchy(current_a, url_a)
+
+ # this massively speeds up build time by not including the whole menu tree for each page
+ next if depth > 1 && current_a[0] != url_a[0]
css_classes = []
css_classes << 'active' if is_current
@@ -190,19 +200,21 @@ module Manual
css_classes << "#{position}-#{level}" if position && level
css_classes << 'other' unless is_current || position || level
- css_classes << "level-#{url_a.length}"
+ css_classes << "level-#{depth}"
css_classes = css_classes.join(' ')
if entry[:type] == 'directory'
erb = ::ERB.new <<-HTML
- <%= entry[:menu_title] %>
+ <%= entry[:menu_title] %>
-
- <%= entry[:children].join %>
-
+ <% if entry[:children].any? %>
+
+ <%= entry[:children].join %>
+
+ <% end %>
HTML
@@ -215,7 +227,7 @@ module Manual
erb = ::ERB.new <<-HTML
- <%= entry[:menu_title] %>
+ <%= entry[:menu_title] %>
@@ -224,9 +236,20 @@ module Manual
erb.result(binding)
end
end
+
+
end
- "#{tree.join}
"
+ "#{tree.join}
+ "
end