3 # Produce a hierarchical map of links.
5 # by Alessandro Dotti Contra <alessandro@hyboria.org>
8 package IkiWiki::Plugin::map;
15 hook(type => "preprocess", id => "map", call => \&preprocess);
18 sub preprocess (@) { #{{{
20 $params{pages}="*" unless defined $params{pages};
22 # Needs to update whenever a page is added or removed, so
23 # register a dependency.
24 add_depends($params{page}, $params{pages});
26 # Get all the items to map.
28 foreach my $page (keys %links) {
29 if (pagespec_match($page, $params{pages})) {
30 push @mapitems, $page;
37 my $map = "<div class='map'>\n";
39 foreach my $item (sort @mapitems) {
40 my $depth = ($item =~ tr/\//\//);
41 while ($depth < $indent) {
45 while ($depth > $indent) {
50 $map .= "</li>\n" if $openli;
52 .htmllink($params{page}, $params{destpage}, $item) ."\n";
59 $map .= "</li></ul>\n";