summaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin/version.pm
blob: fc265526c15e41682efec8c7702d3a54e5efcf17 (plain)
  1. #!/usr/bin/perl
  2. # Ikiwiki version plugin.
  3. package IkiWiki::Plugin::version;
  4. use warnings;
  5. use strict;
  6. use IkiWiki 3.00;
  7. sub import {
  8. hook(type => "getsetup", id => "version", call => \&getsetup);
  9. hook(type => "needsbuild", id => "version", call => \&needsbuild);
  10. hook(type => "preprocess", id => "version", call => \&preprocess);
  11. }
  12. sub getsetup () {
  13. return
  14. plugin => {
  15. safe => 1,
  16. rebuild => undef,
  17. section => "widget",
  18. },
  19. }
  20. sub needsbuild (@) {
  21. my $needsbuild=shift;
  22. foreach my $page (keys %pagestate) {
  23. if (exists $pagestate{$page}{version}{shown}) {
  24. if ($pagestate{$page}{version}{shown} ne $IkiWiki::version) {
  25. push @$needsbuild, $pagesources{$page};
  26. }
  27. if (exists $pagesources{$page} &&
  28. grep { $_ eq $pagesources{$page} } @$needsbuild) {
  29. # remove state, will be re-added if
  30. # the version is still shown during the
  31. # rebuild
  32. delete $pagestate{$page}{version}{shown};
  33. }
  34. }
  35. }
  36. return $needsbuild;
  37. }
  38. sub preprocess (@) {
  39. my %params=@_;
  40. $pagestate{$params{destpage}}{version}{shown}=$IkiWiki::version;
  41. }
  42. 1