summaryrefslogtreecommitdiff
path: root/doc/todo
diff options
context:
space:
mode:
authorJoey Hess <joey@kitenet.net>2008-01-12 02:05:39 -0500
committerJoey Hess <joey@kitenet.net>2008-01-12 02:05:39 -0500
commit5621ef7ea5345297fd9645f299df01fcf8177d50 (patch)
tree98a76333f2f6bcce52d53b71f5eb15e01951eea8 /doc/todo
parent9d7daa30c6c21cf514da836b58a4eaea7a945dcd (diff)
web commit by solofo: First proposal.
Diffstat (limited to 'doc/todo')
-rw-r--r--doc/todo/fortune:_select_options_via_environment.mdwn31
1 files changed, 31 insertions, 0 deletions
diff --git a/doc/todo/fortune:_select_options_via_environment.mdwn b/doc/todo/fortune:_select_options_via_environment.mdwn
new file mode 100644
index 000000000..75b48cd9c
--- /dev/null
+++ b/doc/todo/fortune:_select_options_via_environment.mdwn
@@ -0,0 +1,31 @@
+ diff -up fortune.pm.ORIG fortune.pm.MODIFIED
+ --- fortune.pm.ORIG 2008-01-11 19:07:48.000000000 +0100
+ +++ fortune.pm.MODIFIED 2008-01-12 07:58:44.000000000 +0100
+ @@ -1,5 +1,11 @@
+ #!/usr/bin/perl
+ -# Include a fortune in a page
+ +# Include a fortune in a page.
+ +# If the environment variable IKIWIKI_FORTUNE_COMMAND is defined, use it.
+ +# This allows to run e.g.:
+ +# $IKIWIKI_FORTUNE_COMMAND='fortune ~/.fortune/myfortunes' \
+ +# ikiwiki -setup ~/.ikiwiki/ikiwiki.setup
+ +# Combining this with cron could make regenerated wiki content.
+ +# This may or may not be a good thing wrt. version control.
+ package IkiWiki::Plugin::fortune;
+
+ use warnings;
+ @@ -12,7 +18,13 @@ sub import { #{{{
+
+ sub preprocess (@) { #{{{
+ $ENV{PATH}="$ENV{PATH}:/usr/games:/usr/local/games";
+ - my $f = `fortune 2>/dev/null`;
+ + my $f;
+ + if (exists ($ENV{'IKIWIKI_FORTUNE_COMMAND'})) {
+ + $f = `$ENV{'IKIWIKI_FORTUNE_COMMAND'} 2>/dev/null`
+ + }
+ + else {
+ + $f = `fortune 2>/dev/null`;
+ + }
+
+ if ($?) {
+ return "[[".gettext("fortune failed")."]]";