]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/commitdiff
Revert "map: don't create useless </ul><ul> sequences"
authorSimon McVittie <smcv@debian.org>
Fri, 29 Jul 2011 19:46:42 +0000 (20:46 +0100)
committerSimon McVittie <smcv@debian.org>
Sun, 24 Feb 2013 13:10:24 +0000 (13:10 +0000)
IkiWiki/Plugin/map.pm

index 38f090ff782f8799edbe074b9778477809f9d045..ce3ac1d24e93be888ca9e81f597f55d8b2f41424 100644 (file)
@@ -94,9 +94,8 @@ sub preprocess (@) {
                        if defined $common_prefix && length $common_prefix;
                my $depth = ($item =~ tr/\//\//) + 1;
                my $baseitem=IkiWiki::dirname($item);
-               my $parentbase=IkiWiki::dirname($parent);
-               while (length $parentbase && length $baseitem && $baseitem !~ /^\Q$parentbase\E(\/|$)/) {
-                       $parentbase=IkiWiki::dirname($parentbase);
+               while (length $parent && length $baseitem && $baseitem !~ /^\Q$parent\E(\/|$)/) {
+                       $parent=IkiWiki::dirname($parent);
                        last if length $addparent && $baseitem =~ /^\Q$addparent\E(\/|$)/;
                        $addparent="";
                        $indent--;
@@ -114,10 +113,14 @@ sub preprocess (@) {
                }
                my @bits=split("/", $item);
                my $p="";
-               $indent++  unless length $parent;
                $p.="/".shift(@bits) for 1..$indent;
                while ($depth > $indent) {
-                       if (@bits && !(length $parent && "/$parent" eq $p)) {
+                       $indent++;
+                       if ($indent > 1) {
+                               $map .= "<ul>\n";
+                       }
+                       if ($depth > $indent) {
+                               $p.="/".shift(@bits);
                                $addparent=$p;
                                $addparent=~s/^\///;
                                $map .= "<li>"
@@ -130,11 +133,6 @@ sub preprocess (@) {
                        else {
                                $openli=0;
                        }
-                       $indent++;
-                       $p.="/".shift(@bits) if @bits;
-                       if ($indent > 1) {
-                               $map .= "<ul>\n";
-                       }
                }
                $map .= "</li>\n" if $openli;
                $map .= "<li>"