summaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin/repolist.pm
blob: f69ec398880d4b2955e6e298ddc1d37cfd9141c3 (plain)
  1. #!/usr/bin/perl
  2. package IkiWiki::Plugin::repolist;
  3. use warnings;
  4. use strict;
  5. use IkiWiki 3.00;
  6. sub import {
  7. hook(type => "getsetup", id => "repolist", call => \&getsetup);
  8. hook(type => "checkconfig", id => "repolist", call => \&checkconfig);
  9. }
  10. sub getsetup () {
  11. return
  12. plugin => {
  13. safe => 1,
  14. rebuild => undef,
  15. },
  16. repositories => {
  17. type => "string",
  18. example => ["svn://svn.example.org/wiki/trunk"],
  19. description => "URIs of repositories containing the wiki's source",
  20. safe => 1,
  21. rebuild => undef,
  22. },
  23. }
  24. my $relvcs;
  25. sub checkconfig () {
  26. if (defined $config{rcs} && $config{repositories}) {
  27. $relvcs=join("\n", map {
  28. s/"//g; # avoid quotes just in case
  29. qq{<link rel="vcs-$config{rcs}" href="$_" title="wiki $config{rcs} repository" />}
  30. } @{$config{repositories}});
  31. hook(type => "pagetemplate", id => "repolist", call => \&pagetemplate);
  32. }
  33. }
  34. sub pagetemplate (@) {
  35. my %params=@_;
  36. my $page=$params{page};
  37. my $template=$params{template};
  38. if (defined $relvcs && $template->query(name => "relvcs")) {
  39. $template->param(relvcs => $relvcs);
  40. }
  41. }
  42. 1