]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blob - IkiWiki/Plugin/repolist.pm
reorg
[git.ikiwiki.info.git] / IkiWiki / Plugin / repolist.pm
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);
11 }
13 sub getsetup () {
14         return
15                 plugin => {
16                         safe => 1,
17                         rebuild => undef,
18                 },
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,
25                 },
26 }
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}});
36                 
37                 hook(type => "pagetemplate", id => "repolist", call => \&pagetemplate);
38         }
39 }
41 sub pagetemplate (@) {
42         my %params=@_;
43         my $page=$params{page};
44         my $template=$params{template};
45         
46         if (defined $relvcs && $template->query(name => "relvcs")) {
47                 $template->param(relvcs => $relvcs);
48         }
49 }
51 1