sequence. To output the next number in the sequence, all a user has to do
is write this on a wiki page:
- [[fib ]]
+ [[!fib ]]
When the page is built, the [[ikiwiki/PreProcessorDirective]] will be
replaced by the next number in the sequence.
name this time, but it generally will. This "fib" is telling ikiwiki what
kind of PreprocessorDirective to handle, namely one that looks like this:
- [[fib ]]
+ [[!fib ]]
Notice the `\&preprocess`? This is how you pass a reference to a function,
and the `preprocess` function is the one that ikiwiki will call to expand
Feel free to try it out with a simple page like this:
- [[fib ]], [[fib ]], [[fib ]], [[fib ]], [[fib ]]
+ [[!fib ]], [[!fib ]], [[!fib ]], [[!fib ]], [[!fib ]]
Looks like it works ok, doesn't it? That creates a page that lists:
It would be nice to be able to jump directly to a given point in the
sequence:
- \[[fib seed=20]], [[fib ]], [[fib ]]
+ \[[!fib seed=20]], [[!fib ]], [[!fib ]]
Just insert these lines of code inside `preprocess`, in the appropriate
spot:
}
my $num=$last{$page}++;
if ($num > 25) {
- return "[[fib will only calculate the first 25 numbers in the sequence]]";
+ error "can only calculate the first 25 numbers in the sequence";
}
return fib($num);
}
either case, it will run forever. Here's one way to fix that:
if (int($num) != $num || $num < 1) {
- return "[[fib positive integers only, please]]";
+ error "positive integers only, please";
}
As these security problems have demonstrated, even a simple input from the