From 2eac55e90efa6aa82f3159385f1398be4b3bf6da Mon Sep 17 00:00:00 2001 From: joey Date: Fri, 18 Aug 2006 16:18:45 +0000 Subject: [PATCH] * Add a map plugin contributed by Alessandro Dotti Contra. --- IkiWiki/Plugin/map.pm | 61 +++++++++++++++++++++++++++++++++++++++++++ Makefile.PL | 2 +- debian/changelog | 3 ++- doc/ikiwiki.setup | 2 +- doc/plugins/map.mdwn | 16 ++++++++++++ 5 files changed, 81 insertions(+), 3 deletions(-) create mode 100644 IkiWiki/Plugin/map.pm create mode 100644 doc/plugins/map.mdwn diff --git a/IkiWiki/Plugin/map.pm b/IkiWiki/Plugin/map.pm new file mode 100644 index 000000000..c65e61ac9 --- /dev/null +++ b/IkiWiki/Plugin/map.pm @@ -0,0 +1,61 @@ +#!/usr/bin/perl +# +# Produce a hyerarchical map of links. +# +# By Alessandro Dotti Contra +# +# 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 = "
\n"; + foreach my $item (sort @mapitems) { + my $depth = ($item =~ tr/\//\//) + 1; + next if exists $params{maxdepth} && $depth > $params{maxdepth}; + while ($depth < $indent) { + $indent--; + $map.="\n"; + } + while ($depth > $indent) { + $indent++; + $map.="
    \n"; + } + $map .= "
  • " + .IkiWiki::htmllink($params{page}, $params{destpage}, $item) + ."
  • \n"; + } + while ($indent > 0) { + $indent--; + $map.="
\n"; + } + $map .= "
\n"; + return $map; +} # }}} + +1 diff --git a/Makefile.PL b/Makefile.PL index 1f46e9c95..2ef99fa80 100755 --- a/Makefile.PL +++ b/Makefile.PL @@ -23,7 +23,7 @@ extra_build: --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 diff --git a/debian/changelog b/debian/changelog index d1dac85e1..787faa928 100644 --- a/debian/changelog +++ b/debian/changelog @@ -9,8 +9,9 @@ ikiwiki (1.21) UNRELEASED; urgency=low * 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 Thu, 17 Aug 2006 23:27:38 -0400 + -- Joey Hess Fri, 18 Aug 2006 12:10:37 -0400 ikiwiki (1.20) unstable; urgency=low diff --git a/doc/ikiwiki.setup b/doc/ikiwiki.setup index a0ce5a468..678dece23 100644 --- a/doc/ikiwiki.setup +++ b/doc/ikiwiki.setup @@ -81,7 +81,7 @@ use IkiWiki::Setup::Standard { # 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}], } diff --git a/doc/plugins/map.mdwn b/doc/plugins/map.mdwn new file mode 100644 index 000000000..039ed559e --- /dev/null +++ b/doc/plugins/map.mdwn @@ -0,0 +1,16 @@ +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]] -- 2.44.0