--- /dev/null
+#!/usr/bin/perl
+#
+# Produce a hyerarchical map of links.
+#
+# By Alessandro Dotti Contra <alessandro@hyboria.org>
+#
+# Revision: 0.1
+package IkiWiki::Plugin::map;
+
+use warnings;
+use strict;
+use IkiWiki;
+
+sub import { #{{{
+ IkiWiki::hook(type => "preprocess", id => "map",
+ call => \&preprocess);
+} # }}}
+
+sub preprocess (@) { #{{{
+ my %params=@_;
+ $params{pages}="*" unless defined $params{pages};
+
+ # Needs to update whenever a page is added or removed, so
+ # register a dependency.
+ IkiWiki::add_depends($params{page}, $params{pages});
+
+ # Get all the items to map.
+ my @mapitems = ();
+ foreach my $page (keys %IkiWiki::links) {
+ if (IkiWiki::pagespec_match($page, $params{pages})) {
+ push @mapitems, $page;
+ }
+ }
+
+ # Create the map.
+ my $indent=0;
+ my $map = "<div class='map'>\n";
+ foreach my $item (sort @mapitems) {
+ my $depth = ($item =~ tr/\//\//) + 1;
+ next if exists $params{maxdepth} && $depth > $params{maxdepth};
+ while ($depth < $indent) {
+ $indent--;
+ $map.="</ul>\n";
+ }
+ while ($depth > $indent) {
+ $indent++;
+ $map.="<ul>\n";
+ }
+ $map .= "<li>"
+ .IkiWiki::htmllink($params{page}, $params{destpage}, $item)
+ ."</li>\n";
+ }
+ while ($indent > 0) {
+ $indent--;
+ $map.="</ul>\n";
+ }
+ $map .= "</div>\n";
+ return $map;
+} # }}}
+
+1
--plugin=brokenlinks --plugin=pagecount \
--plugin=orphans --plugin=haiku --plugin=meta \
--plugin=tag --plugin=polygen --plugin=pagestats \
- --plugin=fortune --plugin=aggregate
+ --plugin=fortune --plugin=aggregate --plugin=map
./mdwn2man ikiwiki 1 doc/usage.mdwn > ikiwiki.man
./mdwn2man ikiwiki-mass-rebuild 8 doc/ikiwiki-mass-rebuild.mdwn > ikiwiki-mass-rebuild.man
* Clean up yes/no parameter parsing in inline plugin.
* Implemented better cycle detection in the inline plugin; nested inlines
will now work.
+ * Add a map plugin contributed by Alessandro Dotti Contra.
- -- Joey Hess <joeyh@debian.org> Thu, 17 Aug 2006 23:27:38 -0400
+ -- Joey Hess <joeyh@debian.org> Fri, 18 Aug 2006 12:10:37 -0400
ikiwiki (1.20) unstable; urgency=low
# To add plugins, list them here.
#add_plugins => [qw{meta tag pagecount brokenlinks search smiley
# wikitext camelcase pagestats htmltidy fortune
- # sidebar}],
+ # sidebar map}],
# If you want to disable any of the default plugins, list them here.
#disable_plugins => [qw{inline htmlscrubber}],
}
--- /dev/null
+This plugin generates a hierarchical page map for the wiki. Example usage:
+
+ \[[map pages="* and !blog/*" maxdepth=2]]
+
+If the pages to include are not specified, all pages (and other files) in
+the wiki are mapped. If the maxdepth parameter is passed, only pages nested
+less than that many levels deep will be included in the map.
+
+This plugin is included in ikiwiki, but is not enabled by default.
+
+If this plugin is enabled, here is a page map for the plugins section
+of this wiki:
+
+[[map pages="plugins or plugins/*" maxdepth=3]]
+
+[[tag type/meta]]