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