X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/75a11e6a8d92f7ff221eb4b1270526d57ef537bc..ee5d6461b4807d035816922b7419d28279ff1706:/doc/plugins/write/tutorial.mdwn diff --git a/doc/plugins/write/tutorial.mdwn b/doc/plugins/write/tutorial.mdwn index d4b4959fa..b4705fe31 100644 --- a/doc/plugins/write/tutorial.mdwn +++ b/doc/plugins/write/tutorial.mdwn @@ -2,10 +2,10 @@ This tutorial will walk you through [[writing|write]] your first ikiwiki plugin. What should the plugin do? Let's make it calculate and output the Fibonachi -sequense. To output the next number in the sequence, all a user has to do +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, that'll be replaced by the next number in the sequence. @@ -39,12 +39,12 @@ register hooks that ikiwiki will call later. } This has hooked our plugin into the preprocess hook, which ikiwiki uses to -expand [[PreprocessorDirectives|preprocessordirectives]]. Notice that "fib" +expand [[PreprocessorDirectives|preprocessordirective]]. 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 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 @@ -66,7 +66,7 @@ Always put this as the last line in your perl modules. Perl likes it. Ok, done! If you save the plugin, you can copy it to a place your ikiwiki looks for plugins (`/usr/share/perl5/IkiWiki/Plugins/` is a good bet; see -[[plugin/install]] for the details of how to figure out where to +[[install]] for the details of how to figure out where to install it). Then configure ikiwiki to use the plugin, and you're ready to insert at least the first two numbers of the Fibonachi sequence on web pages. Behold, the power of ikiwiki! ... @@ -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: - \[[fib ]], \[[fib ]], \[[fib ]], \[[fib ]], \[[fib ]] + [[fib ]], [[fib ]], [[fib ]], [[fib ]], [[fib ]] Looks like it works ok, doesn't it? That creates a page that lists: @@ -119,7 +119,7 @@ the sequence in some cases. Obviously, using a global `$last` veriable was a bad idea. It would work ok in a more regular cgi-based wiki, which only outputs one page per run. But since ikiwiki is a wiki *compiler*, things are a bit more -complicated. It't not very hard to fix, though, if we do want the seqense +complicated. It's not very hard to fix, though, if we do want the sequence to start from 1 in every page that uses it. my %last; @@ -186,4 +186,4 @@ either case, it will run forever. Here's one way to fix that: } As these security problems have demonstrated, even a simple input from the -user needs to be checked thuroughly before being used by an ikiwiki plugin. +user needs to be checked thoroughly before being used by an ikiwiki plugin.