2006-07-29 23:53:57 +02:00
|
|
|
#!/usr/bin/perl
|
|
|
|
# Include a fortune in a page
|
|
|
|
package IkiWiki::Plugin::fortune;
|
|
|
|
|
|
|
|
use warnings;
|
|
|
|
use strict;
|
2007-04-27 04:55:52 +02:00
|
|
|
use IkiWiki 2.00;
|
2006-07-29 23:53:57 +02:00
|
|
|
|
|
|
|
sub import { #{{{
|
2006-09-10 00:50:27 +02:00
|
|
|
hook(type => "preprocess", id => "fortune", call => \&preprocess);
|
2006-07-29 23:53:57 +02:00
|
|
|
} # }}}
|
|
|
|
|
|
|
|
sub preprocess (@) { #{{{
|
|
|
|
$ENV{PATH}="$ENV{PATH}:/usr/games:/usr/local/games";
|
2006-11-28 19:16:04 +01:00
|
|
|
my $f = `fortune 2>/dev/null`;
|
2006-07-29 23:53:57 +02:00
|
|
|
|
|
|
|
if ($?) {
|
2006-12-29 05:38:40 +01:00
|
|
|
return "[[".gettext("fortune failed")."]]";
|
2006-07-29 23:53:57 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
return "<pre>$f</pre>\n";
|
|
|
|
}
|
|
|
|
} # }}}
|
|
|
|
|
|
|
|
1
|