summaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin/fortune.pm
blob: 8e96bdbbd1e442be73b45586f3fd276b2ea9b0e2 (plain)
  1. #!/usr/bin/perl
  2. # Include a fortune in a page
  3. package IkiWiki::Plugin::fortune;
  4. use warnings;
  5. use strict;
  6. sub import { #{{{
  7. IkiWiki::hook(type => "preprocess", id => "fortune",
  8. call => \&preprocess);
  9. } # }}}
  10. sub preprocess (@) { #{{{
  11. $ENV{PATH}="$ENV{PATH}:/usr/games:/usr/local/games";
  12. my $f = `fortune`;
  13. if ($?) {
  14. return "[[fortune failed]]";
  15. }
  16. else {
  17. return "<pre>$f</pre>\n";
  18. }
  19. } # }}}
  20. 1