in _plugins/page_structure.rb [59:139]
def self.sortYAMLSectionPositions(yaml)
position = Hash.new
$major = "1"
$minor = 1
yaml.each do |i|
if i.instance_of? String
position[i] = $major+"."+$minor.to_s
$minor += 1
else
defining_param = getDefiningParameterFromHash(i)
if i['section_position'] == nil
position[defining_param] = $major+"."+$minor.to_s
$minor += 1
else
position[defining_param] = i['section_position'].to_s
$major = i['section_position'].to_s
$minor = 1
end
end
end
yaml.sort!{ |x,y|
$pos_x = nil
$pos_y = nil
if x.instance_of? String
$pos_x = position[x]
else
defining_param = getDefiningParameterFromHash(x)
$pos_x = position[defining_param]
end
if y.instance_of? String
$pos_y = position[y]
else
defining_param = getDefiningParameterFromHash(y)
$pos_y = position[defining_param]
end
Gem::Version.new($pos_x.to_s) <=> Gem::Version.new($pos_y.to_s)
}
end
def self.parseChildYAMLFromParent(page)
$baseFile = Dir.pwd+"/"+(Pathname(page['path']).dirname.to_s)
$listings = Dir[$baseFile+"/*.md"]
$allPages = []
for $listing in $listings
$fileContent = IO.read($listing)
$partitionedFileContent = $fileContent.split('---');
if $partitionedFileContent.size > 2
yamlContent = YAML.load($partitionedFileContent[1])
if yamlContent != nil && yamlContent != false && yamlContent['section_type'] != nil && yamlContent['section_type'] != "default"
if yamlContent['section_type'] == nil
yamlContent['section_position'] = Integer::MAX
end
($allPages ||= []) << ChildPage.new(yamlContent, $partitionedFileContent[2..-1].join('---'))
end
end
end
$allPages = sortBySectionPositions($allPages)
$allPages
end