]> sipb.mit.edu Git - ikiwiki.git/blobdiff - doc/plugins/write.mdwn
the rename hook can now change the list of pages to rename
[ikiwiki.git] / doc / plugins / write.mdwn
index 5ee4acb539ed15b1184a827dfb39aeb9f4c7c7cf..d024a5dd47b6fe9066ece1413ad97e241536ba11 100644 (file)
@@ -55,8 +55,8 @@ plugin, and a "call" parameter, which tells what function to call for the
 hook.
 
 An optional "last" parameter, if set to a true value, makes the hook run
-after all other hooks of its type. Useful if the hook depends on some other
-hook being run first.
+after all other hooks of its type, and an optional "first" parameter makes
+it run first. Useful if the hook depends on some other hook being run first.
 
 ## Types of hooks
 
@@ -360,14 +360,25 @@ 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.
 
-### renamepage
+### renamelink
 
-       hook(type => "renamepage", id => "foo", call => \&renamepage);
+       hook(type => "renamelink", id => "foo", call => \&renamelink);
 
 This hook is called by the [[plugins/rename]] plugin when it renames
-something. The hook is passed named parameters: `page`, `oldpage`,
-`newpage`, and `content`, and should try to modify the content to reflect
-the name change. For example, by converting links to point to the new page.
+something, once per page linking to the renamed page's old location.
+The hook is passed named parameters: `page`, `oldpage`, `newpage`, and
+`content`, and should try to modify the content of `page` to reflect
+the name change. For example, by converting links to point to the
+new page.
+
+### rename
+
+       hook(type => "rename", id => "foo", call => \&renamepages);
+
+When a page or set of pages is renamed, the referenced function is
+called, and passed a reference to an array of hashes with keys:
+`src`, `srcfile`, `dest`, `destfile`, `required`. It can modify
+the array.
 
 ### getsetup
 
@@ -696,11 +707,15 @@ This can be called when creating a new page, to determine what filename
 to save the page to. It's passed a page name, and its type, and returns
 the name of the file to create, relative to the srcdir.
 
-#### `targetpage($$)`
+#### `targetpage($$;$)`
 
 Passed a page and an extension, returns the filename that page will be
 rendered to.
 
+Optionally, a third parameter can be passed, to specify the preferred
+filename of the page. For example, `targetpage("foo", "rss", "feed")`
+will yield something like `foo/feed.rss`.
+
 ## Miscellaneous
 
 ### Internal use pages
@@ -837,8 +852,8 @@ files that were changed, in the form:
                file => # name of file that was changed
                action => # either "add", "change", or "remove"
                path => # temp file containing the new file content, only
-                       # needed for "add", and only if the file is an
-                       # attachment, not a page
+                       # needed for "add"/"change", and only if the file
+                       # is an attachment, not a page
        }
 
 The list will then be checked to make sure that each change is one that