+
+ # Return empty div if %mapitems is empty
+ if (!scalar(keys %mapitems)) {
+ $map .= "</div>\n";
+ return $map;
+ }
+ else { # continue populating $map
+ $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="";
+ $indent--;
+ $map .= "</li>\n";
+ if ($indent > 0) {
+ $map .= "</ul>\n";
+ }
+ }