aboutsummaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin/parentlinks.pm
diff options
context:
space:
mode:
authorintrigeri <intrigeri@boum.org>2008-07-15 16:09:40 +0200
committerintrigeri <intrigeri@boum.org>2008-07-15 16:09:40 +0200
commit486f460132434db1eaff92dcadb265011f394bf1 (patch)
treede44adf5ce1638fbda8c33567d4fc89ce07d7e2f /IkiWiki/Plugin/parentlinks.pm
parent55000fd779816fa059e51e9fd01c7e6772b8efc7 (diff)
downloadikiwiki-486f460132434db1eaff92dcadb265011f394bf1.tar
ikiwiki-486f460132434db1eaff92dcadb265011f394bf1.tar.gz
pedigree rename to parentlinks: renamed files, to start with
Signed-off-by: intrigeri <intrigeri@boum.org>
Diffstat (limited to 'IkiWiki/Plugin/parentlinks.pm')
-rw-r--r--IkiWiki/Plugin/parentlinks.pm55
1 files changed, 55 insertions, 0 deletions
diff --git a/IkiWiki/Plugin/parentlinks.pm b/IkiWiki/Plugin/parentlinks.pm
new file mode 100644
index 000000000..eb8bfa83b
--- /dev/null
+++ b/IkiWiki/Plugin/parentlinks.pm
@@ -0,0 +1,55 @@
+#!/usr/bin/perl
+# -*- cperl-indent-level: 8; -*-
+# Ikiwiki pedigree plugin.
+package IkiWiki::Plugin::pedigree;
+
+use warnings;
+use strict;
+use IkiWiki 2.00;
+
+sub import { #{{{
+ hook(type => "pagetemplate", id => "pedigree", call => \&pagetemplate);
+} # }}}
+
+sub pedigree ($) { #{{{
+ my $page=shift;
+
+ my @ret;
+ my $path="";
+ my $title=$config{wikiname};
+ my $i=0;
+ my $depth=0;
+ my $height=0;
+
+ my @pagepath=(split("/", $page));
+ my $pagedepth=@pagepath;
+ foreach my $dir (@pagepath) {
+ next if $dir eq 'index';
+ $depth=$i;
+ $height=($pagedepth - $depth);
+ push @ret, {
+ url => urlto($path, $page),
+ page => $title,
+ depth => $depth,
+ height => $height,
+ "depth_$depth" => 1,
+ "height_$height" => 1,
+ };
+ $path.="/".$dir;
+ $title=IkiWiki::pagetitle($dir);
+ $i++;
+ }
+ return @ret;
+} #}}}
+
+sub pagetemplate (@) { #{{{
+ my %params=@_;
+ my $page=$params{page};
+ my $template=$params{template};
+
+ if ($template->query(name => "pedigree")) {
+ $template->param(pedigree => [pedigree($page)]);
+ }
+} # }}}
+
+1