]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blobdiff - doc/plugins/write/tutorial.mdwn
(no commit message)
[git.ikiwiki.info.git] / doc / plugins / write / tutorial.mdwn
index 8b12fd183c01f1bec27b37bb549bf06f34a1d1be..2823c47b79047297fdbc417df99b34b91c2e2799 100644 (file)
@@ -5,9 +5,9 @@ What should the plugin do? Let's make it calculate and output the Fibonacci
 sequence. To output the next number in the sequence, all a user has to do
 is write this on a wiki page:
 
 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
+When the page is built, the [[ikiwiki/directive]] will be
 replaced by the next number in the sequence.
 
 Most of ikiwiki's plugins are written in Perl, and it's currently easiest
 replaced by the next number in the sequence.
 
 Most of ikiwiki's plugins are written in Perl, and it's currently easiest
@@ -39,16 +39,16 @@ register hooks that ikiwiki will call later.
        }
 
 This has hooked our plugin into the preprocess hook, which ikiwiki uses to
        }
 
 This has hooked our plugin into the preprocess hook, which ikiwiki uses to
-expand [[PreprocessorDirectives|ikiwiki/preprocessordirective]]. Notice
+expand preprocessor [[directives|ikiwiki/directive]]. Notice
 that "fib" has shown up again. It doesn't actually have to match the module
 name this time, but it generally will. This "fib" is telling ikiwiki what
 that "fib" has shown up again. It doesn't actually have to match the module
 name this time, but it generally will. This "fib" is telling ikiwiki what
-kind of PreprocessorDirective to handle, namely one that looks like this:
+kind of preprocessor directive 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
 
 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
-the PreprocessorDirective. So, time to write that function:
+the preprocessor directive. So, time to write that function:
 
        sub preprocess {
                my %params=@_;
 
        sub preprocess {
                my %params=@_;
@@ -98,7 +98,7 @@ And let's change the `preprocess` sub to use it:
 
 Feel free to try it out with a simple page like this:
 
 
 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:
 
 
 Looks like it works ok, doesn't it? That creates a page that lists:
 
@@ -139,7 +139,7 @@ Ok, one more enhancement. Just incrementing the numbers is pretty boring.
 It would be nice to be able to jump directly to a given point in the
 sequence:
 
 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:
 
 Just insert these lines of code inside `preprocess`, in the appropriate
 spot:
@@ -169,7 +169,7 @@ be a guard on how high it will go.
                }
                my $num=$last{$page}++;
                if ($num > 25) {
                }
                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);
        }
                }
                return fib($num);
        }
@@ -182,7 +182,7 @@ does for numbers less than 1. Or for any number that's not an integer. In
 either case, it will run forever. Here's one way to fix that:
 
                if (int($num) != $num || $num < 1) {
 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
                }
 
 As these security problems have demonstrated, even a simple input from the