summaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin/version.pm
blob: f96d2df06ce345d9939c356637e6e6d0e2d06e8b (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 (exists $pagesources{$page} &&
  19. grep { $_ eq $pagesources{$page} } @$needsbuild) {
  20. # remove state, will be re-added if
  21. # the version is still shown during the
  22. # rebuild
  23. delete $pagestate{$page}{version}{shown};
  24. }
  25. }
  26. }
  27. } # }}}
  28. sub preprocess (@) { #{{{
  29. my %params=@_;
  30. $pagestate{$params{destpage}}{version}{shown}=$IkiWiki::version;
  31. } # }}}
  32. 1