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