]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blob - IkiWiki/Plugin/fortune.pm
web commit by http://ptecza.myopenid.com/: * Reply
[git.ikiwiki.info.git] / IkiWiki / Plugin / fortune.pm
1 #!/usr/bin/perl
2 # Include a fortune in a page
3 package IkiWiki::Plugin::fortune;
5 use warnings;
6 use strict;
7 use IkiWiki 2.00;
9 sub import { #{{{
10         hook(type => "preprocess", id => "fortune", call => \&preprocess);
11 } # }}}
13 sub preprocess (@) { #{{{
14         $ENV{PATH}="$ENV{PATH}:/usr/games:/usr/local/games";
15         my $f = `fortune 2>/dev/null`;
17         if ($?) {
18                 return "[[".gettext("fortune failed")."]]";
19         }
20         else {
21                 return "<pre>$f</pre>\n";
22         }
23 } # }}}
25 1