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