X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/54d5308cd83c67e7e9c32450c776ef0dac63549f..82594b5f8907f529e3e8056282ff72acece7333f:/doc/plugins/write.mdwn?ds=inline diff --git a/doc/plugins/write.mdwn b/doc/plugins/write.mdwn index e09ca3510..f9395eb5e 100644 --- a/doc/plugins/write.mdwn +++ b/doc/plugins/write.mdwn @@ -17,21 +17,19 @@ being edited. ## Registering plugins -Plugins should, when imported, call IkiWiki::register_plugin to hook into -ikiwiki. The function takes four parameters: - -1. A method type. Use "preprocess" to register a [[PreProcessorDirective]] -2. A command name. This is the bit that will appear inside brackets in a - page. -3. A reference to a subroutine that is run when the plugin is used. +Plugins should, when imported, call IkiWiki::hook to hook into +ikiwiki's processing. The function uses named parameters, and use varies depending on the type of plugin being registered. Note that a plugin can call the function more than once to register multiple hooks. All calls to IkiWiki::hook should be passed a "type" parameter, which gives the type of hook, a "id" paramter, which should be a unique string for this plugin, and a "call" parameter, which is a reference to a function to call for the hook. ## Writing a [[PreProcessorDirective]] -For preprocessor commands, the subroutine is passed named parameters. A -"page" parameter gives the name of the page that embedded the preprocessor -command. All parameters included in the preprocessor command are included + IkiWiki::hook(type => "preprocess", id => "foo", call => \&preprocess); + +Replace "foo" with the command name that will be used inside brackers for the preprocessor directive. + +Each time the directive is processed, the referenced subroutine (`preprocess` in the example above) is called, and is passed named parameters. A +"page" parameter gives the name of the page that embedded the preprocessor directive. All parameters included in the directive are included as named parameters as well. Whatever the subroutine returns goes onto the -page in place of the command. +page in place of the directive. ## Error handing in plugins @@ -45,7 +43,7 @@ return the error message as the output of the plugin. Note that if [[HTMLSanitization]] is enabled, html in [[PreProcessorDirective]] output is sanitised, which may limit what your plugin can do. Also, the rest of the page content is not in html format at -preprocessor time. +preprocessor time. Text output by a preprocessor directive will be passed through markdown along with the rest of the page. ## Wiki configuration @@ -59,9 +57,9 @@ If your plugin needs to access data about other pages in the wiki. It can use the following hashes, using a page name as the key: * `%IkiWiki::links` lists the names of each page - that is linked to from that page in an array reference. + that a page links to, in an array reference. * `%IkiWiki::pagemtime` contains the last modification time of each page -* `%IkiWiki::pagectime` contains the creation time of each page` +* `%IkiWiki::pagectime` contains the creation time of each page * `%IkiWiki::renderedfiles` contains the name of the file rendered by a page * `%IkiWiki::pagesources` contains the name of the source file for a page. @@ -72,3 +70,13 @@ use the following hashes, using a page name as the key: Many plugins will need to add dependencies to this hash; the best way to do it is by using the IkiWiki::add_depends function, which takes as its parameters the page name and a [[GlobList]] of dependencies to add. + +## RCS plugins + +ikiwiki's support for revision control systems also uses pluggable perl +modules. These are in the `IkiWiki::RCS` namespace, for example +`IkiWiki::RCS::svn`. + +Each RCS plugin must support all the IkiWiki::rcs_* functions. +See IkiWiki::RCS::Stub for the full list of functions. It's ok if +rcs_getctime does nothing except for throwing an error.