diff options
author | Joey Hess <joey@kitenet.net> | 2007-12-08 17:40:50 -0500 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2007-12-08 17:40:50 -0500 |
commit | 055179cb4cc9b8bc9b204e1a9f83b1f59e13824e (patch) | |
tree | 1a48f2f93684238180b355df67f2aa48dcfb1be4 /doc/plugins | |
parent | 2fbca21390d2752a89a2e1167fe33d4d201359cf (diff) | |
download | ikiwiki-055179cb4cc9b8bc9b204e1a9f83b1f59e13824e.tar ikiwiki-055179cb4cc9b8bc9b204e1a9f83b1f59e13824e.tar.gz |
* Finally implemented a simple per-page data storage mechanism for plugins,
via the %pagestate hash.
* Use pagestate in meta to detect potential redir loops.
Diffstat (limited to 'doc/plugins')
-rw-r--r-- | doc/plugins/write.mdwn | 14 | ||||
-rw-r--r-- | doc/plugins/write/external.mdwn | 5 |
2 files changed, 19 insertions, 0 deletions
diff --git a/doc/plugins/write.mdwn b/doc/plugins/write.mdwn index 3ed0a3017..1cb26a076 100644 --- a/doc/plugins/write.mdwn +++ b/doc/plugins/write.mdwn @@ -313,6 +313,20 @@ 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. + ### Other variables If your plugin needs to access data about other pages in the wiki. It can diff --git a/doc/plugins/write/external.mdwn b/doc/plugins/write/external.mdwn index 0abc9b0a0..a1a3811dc 100644 --- a/doc/plugins/write/external.mdwn +++ b/doc/plugins/write/external.mdwn @@ -49,6 +49,11 @@ to access any such global hash. To get the "url" configuration value, call `getvar("config", "url")`. To set it, call `setvar("config", "url", "http://example.com/)`. +The `%pagestate` is a special hash with a more complex format. To access +it, external plugins can use the `getstate` and `setstate` RPCs. To access +stored state, call `getstate("page", "id", "key")`, and to store state, +call `setstate("page", "id", "key", "value")`. + ## Notes on function parameters The [[plugin_interface_documentation|write]] talks about functions that take |