]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blob - doc/forum/Questions_about_a_new_plugin.mdwn
Questions about a new plugin
[git.ikiwiki.info.git] / doc / forum / Questions_about_a_new_plugin.mdwn
1 Hello,
2 I have a plugin in mind, but before starting to write some code, I come to you to see if something similar already exists, or if there is an easier way to do it.
4 # What I want
6 I want to be able to have several versions of the same page. For instance (this is not my usecase, but it matches exactly), let's say I am developping a software, with several versions published, and I want:
8 * the latest documentation to be available at ``http://example.com/doc``;
9 * the documentation for previous (or current version, with permanent URL) available at ``http://example.com/doc/v2_0``.
11 What I am thinking about is:
13 * my wiki has the documentation written in pages `doc/v1_0.mdwn`, `doc/v2_0.mdwn`, and so on;
14 * the `doc.mdwn` page contains nothing but code to copy metadata from the latest `doc/*mdwn` page, that is: [[plugins/meta]] information, [[plugins/tag]], and [[plugins/contrib/ymlfront]].
16 # What I have in mind
18 What I have in mind is a plugin providing a directive ``pageversion`` such that the `doc.mdwn` page contains only:
20     [[!pageversion pages="doc/* and !doc/*/*"]]
22 This would grab the latest documentation page, copy its content, and copy meta information, tags and fields.
24 # How to do it
26 I see two ways to do it, but both have big drawbacks.
28 * I could, in the ``preprocess`` function of the plugin, copy the *interesting* part of the ``%pagestate`` global variable. In pseudo-code, something like:
30       $pagestate{doc}{meta} = $pagestate{doc/v2_0}{meta};
31       $pagestate{doc}{fields} = $pagestate{doc/v2_0}{fields};
32       $pagestate{doc}{tags} = $pagestate{doc/v2_0}{tags}; # This one definitely would not work, but it is pseudo-code
34   I fear that some necessary side effects would not occur. For instance, setting date using the [[plugins/meta]] plugin [sets the page creation time at a deeper level](http://source.ikiwiki.branchable.com/?p=source.git;a=blob;f=IkiWiki/Plugin/meta.pm;h=ea099f955ac1c486cdd2baf6636e330a8eae569c;hb=HEAD#l154). Copying ``%pagestate`` would bypass this.
36 * I could, in the ``preprocess`` function, call the ``preprocess`` function for those three plugins. But this would mean guessing what the original directive arguments were, which can be tricky.
38 # My questions
40 * Does something similar already exist?
41 * Do you have any better idea about how to do it?