]> sipb.mit.edu Git - ikiwiki.git/blobdiff - doc/plugins/write.mdwn
cleanups
[ikiwiki.git] / doc / plugins / write.mdwn
index 3ed0a3017a9717b491264a6c146056fd7f090399..9c3a36b8fb516a72e0b3dbc01ad343348bd4173f 100644 (file)
@@ -82,11 +82,19 @@ configuration. It's called early in the startup process. The
 function is passed no values. It's ok for the function to call
 `error()` if something isn't configured right.
 
+### refresh
+
+       hook(type => "refresh", id => "foo", call => \&refresh);
+
+This hook is called just before ikiwiki scans the wiki for changed files.
+It's useful for plugins that need to create or modify a source page. The
+function is passed no values.
+
 ### needsbuild
 
        hook(type => "needsbuild", id => "foo", call => \&needsbuild);
 
-This allows a plugin the manipulate the list of files that need to be
+This allows a plugin to manipulate the list of files that need to be
 built when the wiki is refreshed. The function is passed a reference to an
 array of pages that will be rebuilt, and can modify the array, either
 adding or removing files from it.
@@ -123,7 +131,9 @@ An optional "scan" parameter, if set to a true value, makes the hook be
 called during the preliminary scan that ikiwiki makes of updated pages,
 before begining to render pages. This parameter should be set to true if
 the hook modifies data in `%links`. Note that doing so will make the hook
-be run twice per page build, so avoid doing it for expensive hooks.
+be run twice per page build, so avoid doing it for expensive hooks. (As an
+optimisation, if your preprocessor hook is called in a void contets, you
+can assume it's being run in scan mode.)
 
 Note that if the [[htmlscrubber]] is enabled, html in
 [[ikiwiki/PreProcessorDirective]] output is sanitised, which may limit what
@@ -246,10 +256,16 @@ a page can be edited using the web interface (commits from revision control
 bypass it). When a page is edited, each registered canedit hook is called
 in turn, and passed the page name, a CGI object, and a session object.
 
-If edit can proceed, the hook should return "". If the edit is not allowed
-by this hook, the hook should return an error message for the user to see.
 If the hook has no opinion about whether the edit can proceed, return
-`undef`, and the next plugin will be asked to decide.
+`undef`, and the next plugin will be asked to decide. If edit can proceed,
+the hook should return "". If the edit is not allowed by this hook, the
+hook should return an error message for the user to see, or a function 
+that can be run to log the user in or perform other action necessary for
+them to be able to edit the page.
+
+This hook should avoid directly redirecting the user to a signin page,
+since it's sometimes used to test to see which pages in a set of pages a
+user can edit.
 
 ### editcontent
 
@@ -279,10 +295,8 @@ it's a form that it needs to modify, will call various methods to
 add/remove/change fields, tweak the validation code for the fields, etc. It
 will not validate or display the form.
 
-Form validation and display can be overridden by the formbuilder hook.
-By default, ikiwiki will do a basic validation and display of the form,
-but if this hook is registered, it will stop that and let the hook take
-over.
+Just before a form is displayed to the user, the `formbuilder` hook is
+called. It can be used to validate the form, but should not display it.
 
 ### savestate
 
@@ -313,6 +327,23 @@ A plugin can access the wiki's configuration via the `%config`
 hash. The best way to understand the contents of the hash is to look at
 [[ikiwiki.setup]], which sets the hash content to configure the wiki.
 
+### %pagestate
+
+The `%pagestate` hash can be used by plugins to save state that they will need
+next time ikiwiki is run. The hash holds per-page state, so to set a value,
+use `%pagestate{$page}{$id}{$key}=$value`, and to retrieve the value,
+use `%pagestate{$page}{$id}{$key}`.
+
+`$key` can be any string you like, but `$id` must be the same as the "id"
+parameter passed to `hook()` when registering the plugin. This is so
+ikiwiki can know when to delete pagestate for plugins that are no longer
+used.
+
+When pages are deleted, ikiwiki automatically deletes their pagestate too.
+
+Note that page state does not persist across wiki rebuilds, only across
+wiki updates.
+
 ### Other variables
 
 If your plugin needs to access data about other pages in the wiki. It can
@@ -500,6 +531,19 @@ destination file, as registered by `will_render`.
 Passed a page and an extension, returns the filename that page will be
 rendered to.
 
+## Internal use pages
+
+Sometimes it's useful to put pages in the wiki without the overhead of
+having them be rendered to individual html files. Such internal use pages
+are collected together to form the RecentChanges page, for example.
+
+To make an internal use page, register a filename extension that starts
+with "_". Internal use pages cannot be edited with the web interface,
+generally shouldn't contain wikilinks or preprocessor directives (use
+either on them with extreme caution), and are not matched by regular
+PageSpecs glob patterns, but instead only by a special `internal()`
+[[ikiwiki/PageSpec]].
+
 ## RCS plugins
 
 ikiwiki's support for [[revision_control_systems|rcs]] also uses pluggable