summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorintrigeri <intrigeri@boum.org>2008-07-15 16:25:39 +0200
committerintrigeri <intrigeri@boum.org>2008-07-15 16:25:39 +0200
commit35668b87d3247a7de6c4dbb9edd7e0d909603524 (patch)
tree80ea51c4c4aea4c141d7063249e435d45cd46cd4
parent486f460132434db1eaff92dcadb265011f394bf1 (diff)
pedigree rename to parentlinks: rename/adapt everything
* Renamed to parentlinks every single variable or function called pedigree * Removed the parentlinks function from Render.pm * Enabled the new parentlinks plugin by default * Adapted testsuite and documentation to reflate the above facts Signed-off-by: intrigeri <intrigeri@boum.org>
-rw-r--r--IkiWiki.pm3
-rw-r--r--IkiWiki/Plugin/parentlinks.pm12
-rw-r--r--IkiWiki/Render.pm18
-rw-r--r--doc/plugins/parentlinks.mdwn37
-rwxr-xr-xt/parentlinks.t13
-rw-r--r--t/parentlinks/templates/parentlinks.tmpl4
6 files changed, 40 insertions, 47 deletions
diff --git a/IkiWiki.pm b/IkiWiki.pm
index d4e19c388..bcbbabbe0 100644
--- a/IkiWiki.pm
+++ b/IkiWiki.pm
@@ -77,7 +77,8 @@ sub defaultconfig () { #{{{
adminuser => undef,
adminemail => undef,
plugin => [qw{mdwn link inline htmlscrubber passwordauth openid
- signinedit lockedit conditional recentchanges}],
+ signinedit lockedit conditional recentchanges
+ parentlinks}],
libdir => undef,
timeformat => '%c',
locale => undef,
diff --git a/IkiWiki/Plugin/parentlinks.pm b/IkiWiki/Plugin/parentlinks.pm
index eb8bfa83b..a94cd469c 100644
--- a/IkiWiki/Plugin/parentlinks.pm
+++ b/IkiWiki/Plugin/parentlinks.pm
@@ -1,17 +1,17 @@
#!/usr/bin/perl
# -*- cperl-indent-level: 8; -*-
-# Ikiwiki pedigree plugin.
-package IkiWiki::Plugin::pedigree;
+# Ikiwiki parentlinks plugin.
+package IkiWiki::Plugin::parentlinks;
use warnings;
use strict;
use IkiWiki 2.00;
sub import { #{{{
- hook(type => "pagetemplate", id => "pedigree", call => \&pagetemplate);
+ hook(type => "pagetemplate", id => "parentlinks", call => \&pagetemplate);
} # }}}
-sub pedigree ($) { #{{{
+sub parentlinks ($) { #{{{
my $page=shift;
my @ret;
@@ -47,8 +47,8 @@ sub pagetemplate (@) { #{{{
my $page=$params{page};
my $template=$params{template};
- if ($template->query(name => "pedigree")) {
- $template->param(pedigree => [pedigree($page)]);
+ if ($template->query(name => "parentlinks")) {
+ $template->param(parentlinks => [parentlinks($page)]);
}
} # }}}
diff --git a/IkiWiki/Render.pm b/IkiWiki/Render.pm
index 990fcaaa1..8a79119cd 100644
--- a/IkiWiki/Render.pm
+++ b/IkiWiki/Render.pm
@@ -47,23 +47,6 @@ sub backlinks ($) { #{{{
return @links;
} #}}}
-sub parentlinks ($) { #{{{
- my $page=shift;
-
- my @ret;
- my $pagelink="";
- my $path="";
- my $title=$config{wikiname};
-
- foreach my $dir (split("/", $page)) {
- next if $dir eq 'index';
- push @ret, { url => urlto($path, $page), page => $title };
- $path.="/".$dir;
- $title=pagetitle($dir);
- }
- return @ret;
-} #}}}
-
sub genpage ($$) { #{{{
my $page=shift;
my $content=shift;
@@ -121,7 +104,6 @@ sub genpage ($$) { #{{{
? $config{wikiname}
: pagetitle(basename($page)),
wikiname => $config{wikiname},
- parentlinks => [parentlinks($page)],
content => $content,
backlinks => $backlinks,
more_backlinks => $more_backlinks,
diff --git a/doc/plugins/parentlinks.mdwn b/doc/plugins/parentlinks.mdwn
index 15c032838..ff4139390 100644
--- a/doc/plugins/parentlinks.mdwn
+++ b/doc/plugins/parentlinks.mdwn
@@ -1,20 +1,19 @@
-[[!template id=plugin name=pedigree author="intrigeri"]]
-[[!tag type/useful]]
+[[!template id=plugin name=parentlinks core=1 author="[[intrigeri]]"]]
+[[!tag type/link]]
This plugin offers a `HTML::Template` loop that iterates over all or
-a subset of a page's parents, providing a few bonus possibilities,
-such as styling the parent links depending on their place in the path.
-One can think of pedigree as "`PARENTLINKS` on steroids".
+a subset of a page's parents. It also provides a few bonus
+possibilities, such as styling the parent links depending on their
+place in the path.
[[!toc ]]
Content
=======
-This plugin provides one template loop, called `PEDIGREE`, that
-returns the same parents list as `PARENTLINKS` would; as a bonus,
-every path element returned by the `PEDIGREE` loop has the following
-variables set:
+This plugin provides one template loop, called `PARENTLINKS`, that
+returns the list of parent pages for the current page. Every returned
+path element has the following variables set:
* `URL` (string): url to the current path element
* `PAGE` (string): title of the current path element
@@ -38,6 +37,18 @@ The `DEPTH` and `HEIGHT` variables allow the template writer to apply
general treatment, depending on one of these variables, to *every*
parent: they are counters.
+Basic usage
+-----------
+
+As in the default `page.tmpl`, one can simply display the list of
+parent pages:
+
+ <TMPL_LOOP NAME="PARENTLINKS">
+ <a href="<TMPL_VAR NAME=URL>"><TMPL_VAR NAME=PAGE></a>/
+ </TMPL_LOOP>
+ <TMPL_VAR TITLE>
+
+
Styling parents depending on their depth
----------------------------------------
@@ -45,7 +56,7 @@ Say you want the parent links to be styled depending on their depth in
the path going from the wiki root to the current page; just add the
following lines in `page.tmpl`:
- <TMPL_LOOP NAME="PEDIGREE">
+ <TMPL_LOOP NAME="PARENTLINKS">
<a href="<TMPL_VAR NAME="URL">" class="depth<TMPL_VAR NAME="DEPTH">">
<TMPL_VAR NAME="PAGE">
</a> /
@@ -60,7 +71,7 @@ Say you want to display all the parents links but the wiki homepage,
styled depending on their distance to the current page; just add the
following lines in `page.tmpl`:
- <TMPL_LOOP NAME="PEDIGREE">
+ <TMPL_LOOP NAME="PARENTLINKS">
<TMPL_IF NAME="DEPTH_0">
<TMPL_ELSE>
<a href="<TMPL_VAR NAME="URL">" class="height<TMPL_VAR NAME="HEIGHT">">
@@ -81,7 +92,7 @@ and/or CSS generated for some special path components; e.g.:
<!-- all parents, skipping mother and grand'ma, inside a common div+ul -->
<div id="oldestparents">
<ul>
- <TMPL_LOOP NAME="PEDIGREE">
+ <TMPL_LOOP NAME="PARENTLINKS">
<TMPL_IF NAME="HEIGHT_2">
<TMPL_ELSE>
<TMPL_IF NAME="HEIGHT_1">
@@ -94,7 +105,7 @@ and/or CSS generated for some special path components; e.g.:
</div>
<!-- dedicated div's for mother and grand'ma -->
- <TMPL_LOOP NAME="PEDIGREE">
+ <TMPL_LOOP NAME="PARENTLINKS">
<TMPL_IF NAME="HEIGHT_2">
<div id="grandma">
<a href="<TMPL_VAR NAME="URL">"><TMPL_VAR NAME="PAGE"></a>
diff --git a/t/parentlinks.t b/t/parentlinks.t
index 74871cfa8..593937a97 100755
--- a/t/parentlinks.t
+++ b/t/parentlinks.t
@@ -1,6 +1,6 @@
#!/usr/bin/perl
# -*- cperl-indent-level: 8; -*-
-# Testcases for the Ikiwiki pedigree plugin.
+# Testcases for the Ikiwiki parentlinks plugin.
use warnings;
use strict;
@@ -14,13 +14,12 @@ BEGIN { use_ok("IkiWiki"); }
%config=IkiWiki::defaultconfig();
$config{srcdir}=$config{destdir}="/dev/null";
$config{underlaydir}="underlays/basewiki";
-$config{templatedir}="t/pedigree/templates";
+$config{templatedir}="t/parentlinks/templates";
IkiWiki::loadplugins();
IkiWiki::checkconfig();
-ok(IkiWiki::loadplugin("pedigree"), "pedigree plugin loaded");
# Test data
-$expected{'pedigree'} =
+$expected{'parentlinks'} =
{
"" => [],
"ikiwiki" => [],
@@ -42,7 +41,7 @@ sub test_loop($$) {
my $template;
my %params;
- ok($template=template('pedigree.tmpl'), "template created");
+ ok($template=template('parentlinks.tmpl'), "template created");
ok($params{template}=$template, "params populated");
while ((my $page, my $exp) = each %{$expected}) {
@@ -53,7 +52,7 @@ sub test_loop($$) {
# manually run the plugin hook
$params{page}=$page;
$template->clear_params();
- IkiWiki::Plugin::pedigree::pagetemplate(%params);
+ IkiWiki::Plugin::parentlinks::pagetemplate(%params);
my $res=$template->param($loop);
is(scalar(@$res), $pagedepth, "$msgprefix: path length");
@@ -80,4 +79,4 @@ sub test_loop($$) {
}
# Main
-test_loop('pedigree', $expected{'pedigree'});
+test_loop('parentlinks', $expected{'parentlinks'});
diff --git a/t/parentlinks/templates/parentlinks.tmpl b/t/parentlinks/templates/parentlinks.tmpl
index 5fa25733a..3ca3b0030 100644
--- a/t/parentlinks/templates/parentlinks.tmpl
+++ b/t/parentlinks/templates/parentlinks.tmpl
@@ -1,4 +1,4 @@
-<!-- This template file only has to "use" the loops tested by pedigree.t -->
+<!-- This template file only has to "use" the loops tested by parentlinks.t -->
-<TMPL_LOOP NAME="PEDIGREE">
+<TMPL_LOOP NAME="PARENTLINKS">
</TMPL_LOOP>