]> sipb.mit.edu Git - ikiwiki.git/blobdiff - doc/plugins/write.mdwn
Merge commit 'origin/master' into prv/po
[ikiwiki.git] / doc / plugins / write.mdwn
index 1b78f5900b2de71ee10c4a4bd94f17c8c6d62bf1..857d176d5e172d6b263335f833a997e70024560f 100644 (file)
@@ -196,7 +196,6 @@ generating the page.
 
        hook(type => "pagetemplate", id => "foo", call => \&pagetemplate);
 
-
 [[Templates|wikitemplates]] are filled out for many different things in
 ikiwiki, like generating a page, or part of a blog page, or an rss feed, or
 a cgi. This hook allows modifying the variables available on those
@@ -361,6 +360,13 @@ This hook is called whenever ikiwiki normally saves its state, just before
 the state is saved. The function can save other state, modify values before
 they're saved, etc.
 
+### displaytime
+
+       hook(type => "displaytime", id => "foo", call => \&display);
+
+This hook can be registered to override the regular `displaytime` function.
+Only the last displaytime hook will be used.
+
 ### renamepage
 
        hook(type => "renamepage", id => "foo", call => \&renamepage);
@@ -428,6 +434,36 @@ describes the plugin as a whole. For example:
   and undef if a rebuild could be needed in some circumstances, but is not
   strictly required.
 
+### targetpage
+
+       hook(type => "targetpage", id => "foo", call => \&targetpage);
+
+This hook can be used to override the name of the file a page should
+be compiled into. 
+
+It should return the target filename.
+
+### tweakurlpath
+
+       hook(type => "tweakurlpath", id => "foo", call => \&tweakurlpath);
+
+This hook can be used to modify the internal urls generated by
+ikiwiki; it is run just after ikiwiki has removed the trailing
+`index.html`, in case `usedirs` is enabled.
+
+It should return the modified url.
+
+### tweakbestlink
+
+       hook(type => "tweakbestlink", id => "foo", call => \&tweakbestlink);
+
+This hook can be used to modify the page returned by `bestlink`. It is
+passed named parameters `page` and `link`. These are, respectively,
+the page where the link will appear and the link ikiwiki would choose
+as the best one, if no `tweakbestlink` hook was in effect.
+
+It should return the modified link.
+
 ## Plugin interface
 
 To import the ikiwiki plugin interface:
@@ -847,3 +883,32 @@ to a hash containing all the config items. They should also implement a
 By the way, to parse a ikiwiki setup file and populate `%config`, a
 program just needs to do something like:
 `use IkiWiki::Setup; IkiWiki::Setup::load($filename)`
+
+### Javascript
+
+Some plugins use javascript to make ikiwiki look a bit more web-2.0-ish.
+
+All javascript code should be put in `.js` files in the `javascript`
+underlay, and plugins using those files can enable use of the underlay by
+calling `add_underlay("javascript");` in their `import` function.
+
+You'll have to arrange for `<script>` tags to be added to the pages that
+use your javascript. This can be done using a `format` hook.
+
+Ikiwiki provides some utility functions in `ikiwiki.js`, for use by other
+javascript code. These include:
+
+#### `getElementsByClass(cls, node, tag)` 
+
+Returns an array of elements with the given class. The node and tag are
+optional and define what document node and element names to search.
+
+#### `hook(name, call)`
+
+The function `call` will be run as part of the hook named `name`.
+
+Note that to hook into `window.onload`, you can use the `onload' hook.
+
+#### `run_hooks(name)`
+
+Runs the hooks with the specified name.