]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blob - IkiWiki/Plugin/fortune.pm
po: back to the cansave hook, as the form validation is not sufficient
[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 3.00;
9 sub import {
10         hook(type => "getsetup", id => "fortune", call => \&getsetup);
11         hook(type => "preprocess", id => "fortune", call => \&preprocess);
12 }
14 sub getsetup () {
15         return
16                 plugin => {
17                         safe => 1,
18                         rebuild => undef,
19                 },
20 }
22 sub preprocess (@) {
23         $ENV{PATH}="$ENV{PATH}:/usr/games:/usr/local/games";
24         my $f = `fortune 2>/dev/null`;
26         if ($?) {
27                 error gettext("fortune failed");
28         }
29         else {
30                 return "<pre>$f</pre>\n";
31         }
32 }
34 1