]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blob - IkiWiki/Plugin/repolist.pm
Merge branch 'master' of git://git.ikiwiki.info
[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                         section => "web",
19                 },
20                 repositories => {
21                         type => "string",
22                         example => ["svn://svn.example.org/wiki/trunk"],
23                         description => "URIs of repositories containing the wiki's source",
24                         safe => 1,
25                         rebuild => undef,
26                 },
27 }
29 my $relvcs;
31 sub checkconfig () {
32         if (defined $config{rcs} && $config{repositories}) {
33                 $relvcs=join("\n", map {
34                         s/"//g; # avoid quotes just in case
35                         qq{<link rel="vcs-$config{rcs}" href="$_" title="wiki $config{rcs} repository" />}
36                 } @{$config{repositories}});
37                 
38                 hook(type => "pagetemplate", id => "repolist", call => \&pagetemplate);
39         }
40 }
42 sub pagetemplate (@) {
43         my %params=@_;
44         my $page=$params{page};
45         my $template=$params{template};
46         
47         if (defined $relvcs && $template->query(name => "relvcs")) {
48                 $template->param(relvcs => $relvcs);
49         }
50 }
52 1