tidy up new page_types code
[ikiwiki.git] / IkiWiki / Plugin / repolist.pm
blobf69ec398880d4b2955e6e298ddc1d37cfd9141c3
1 #!/usr/bin/perl
2 package IkiWiki::Plugin::repolist;
4 use warnings;
5 use strict;
6 use IkiWiki 3.00;
8 sub import {
9 hook(type => "getsetup", id => "repolist", call => \&getsetup);
10 hook(type => "checkconfig", id => "repolist", call => \&checkconfig);
13 sub getsetup () {
14 return
15 plugin => {
16 safe => 1,
17 rebuild => undef,
19 repositories => {
20 type => "string",
21 example => ["svn://svn.example.org/wiki/trunk"],
22 description => "URIs of repositories containing the wiki's source",
23 safe => 1,
24 rebuild => undef,
28 my $relvcs;
30 sub checkconfig () {
31 if (defined $config{rcs} && $config{repositories}) {
32 $relvcs=join("\n", map {
33 s/"//g; # avoid quotes just in case
34 qq{<link rel="vcs-$config{rcs}" href="$_" title="wiki $config{rcs} repository" />}
35 } @{$config{repositories}});
37 hook(type => "pagetemplate", id => "repolist", call => \&pagetemplate);
41 sub pagetemplate (@) {
42 my %params=@_;
43 my $page=$params{page};
44 my $template=$params{template};
46 if (defined $relvcs && $template->query(name => "relvcs")) {
47 $template->param(relvcs => $relvcs);