aboutsummaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin/repolist.pm
blob: ba7c5f0aa0e895087d9d1cba08d031cd29bc8764 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/perl
package IkiWiki::Plugin::repolist;

use warnings;
use strict;
use IkiWiki 3.00;

sub import {
	hook(type => "getsetup", id => "repolist",  call => \&getsetup);
	hook(type => "checkconfig", id => "repolist", call => \&checkconfig);
}

sub getsetup () {
	return
		plugin => {
			safe => 1,
			rebuild => undef,
			section => "web",
		},
		repositories => {
			type => "string",
			example => ["svn://svn.example.org/wiki/trunk"],
			description => "URIs of repositories containing the wiki's source",
			safe => 1,
			rebuild => undef,
		},
}

my $relvcs;

sub checkconfig () {
	if (defined $config{rcs} && $config{repositories}) {
		$relvcs=join("\n", map {
			s/"//g; # avoid quotes just in case
			qq{<link rel="vcs-$config{rcs}" href="$_" title="wiki $config{rcs} repository" />}
		} @{$config{repositories}});
		
		hook(type => "pagetemplate", id => "repolist", call => \&pagetemplate);
	}
}

sub pagetemplate (@) {
	my %params=@_;
	my $page=$params{page};
	my $template=$params{template};
	
        if (defined $relvcs && $template->query(name => "relvcs")) {
		$template->param(relvcs => $relvcs);
	}
}

1