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