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 # Get all the items to map.
24 foreach my $page (keys %pagesources) {
25 if (pagespec_match($page, $params{pages}, location => $params{page})) {
26 push @mapitems, $page;
30 # Needs to update whenever a page is added or removed, so
31 # register a dependency.
32 add_depends($params{page}, $params{pages});
33 # Explicitly add all currently shown pages, to detect when pages
35 add_depends($params{page}, join(" or ", @mapitems));
40 my $map = "<div class='map'>\n";
42 foreach my $item (sort @mapitems) {
43 my $depth = ($item =~ tr/\//\//);
44 while ($depth < $indent) {
48 while ($depth > $indent) {
53 $map .= "</li>\n" if $openli;
55 .htmllink($params{page}, $params{destpage}, $item)
63 $map .= "</li></ul>\n";