+
+ if (! keys %mapitems) {
+ # return empty div for empty map
+ $map .= "</div>\n";
+ return $map;
+ }
+ else {
+ $map .= "<ul>\n";
+ }
+
+ foreach my $item (sort keys %mapitems) {
+ my @linktext = (length $mapitems{$item} ? (linktext => $mapitems{$item}) : ());
+ $item=~s/^\Q$common_prefix\E\///
+ if defined $common_prefix && length $common_prefix;
+ my $depth = ($item =~ tr/\//\//) + 1;
+ my $baseitem=IkiWiki::dirname($item);
+ while (length $parent && length $baseitem && $baseitem !~ /^\Q$parent\E(\/|$)/) {
+ $parent=IkiWiki::dirname($parent);
+ last if length $addparent && $baseitem =~ /^\Q$addparent\E(\/|$)/;
+ $addparent="";
+ $map .= ($spaces x $indent) . "</li>\n";
+ if ($indent > 1) {
+ $map .= ($spaces x $indent) . "</ul><map:collapse>\n";
+ }
+ $indent--;
+ }