section map
Eric Stewart
hobix-monkey at eric-stewart.com
Mon Sep 27 20:42:25 EDT 2004
William,
I spent a good chunk of the weekend trying to get your section map
plugin working in Hobix 0.2c and finally did. I'd be happy to help
figure out why it required such modifications for my setup.
Nice work! See the modified method from your code below:
Regards,
-Eric
All the mods were within this method:
def section_list(entries, topname="top level")
counts = {}
entries.each do |path, mtime|
path = path.split('/')[0 ... -1]
if path == []
path = [""]
end
counts[path] ||= 0
counts[path] += 1
end
list = []; seen = {}
counts[[""]] ||= 0 # force the root
counts.sort.each do |path, count|
path[0 ... -1].inject("") do |s, x|
prefix = s + "/" + x
unless seen[prefix]
seen[prefix] = true
list.push [x, prefix, prefix.count('/'), 0]
end
prefix
end
leafpath = path.join('/')
seen[leafpath] = true
list.push [(path[-1] != "" ? path[-1] : topname), leafpath,
path.length, count]
end
list
end
More information about the Hobix-is-the-way
mailing list