Contents
ForEach
Description
This macro can be thought of as a souped-up version of Include, allowing for fulltext searches to be used. It searches the wiki, and iteratively replaces its second arguments for each matching page found. During the process, any occurrence of '%%' in the second argument will be replaced by the matched page's name. If the matching pages contain a comment in the form ##priority <number>, it will be used as key to sort the pages, highest priority first. Pages with no explicit priority get the lowest priority. Pages with the same priority get sorted by page title.
Many thanks to RadomirDopieralski for his help in writing this macro.
Distribution location is at http://eu.squid-cache.org/~kinkie/moinmoin/ (Bazaar repository).
Download & Release Notes
Download |
Release Version |
Moin Version |
Release Notes |
0.8 |
1.5 |
First release. I'm seeking feedback. |
|
0.9 |
1.5 |
Modified as per ReimarBauer's suggestions. |
Usage
[[ForEach(CategorySome -title:CategorySome,\[\[Include\(%%\)\]\])]]
Usage Example
http://wiki.squid-cache.org/FrancescoChemolli/LabArea
Copyright
(C) 2008 FrancescoChemolli
License
GNU GPL v3
Bugs
Discussion
Hi,
seems you do use for indenting of one level 8 blanks (please change this to 4 blanks). To satisfy PEP8 there are on some places too much or too less blanks. You should use string substitution instead of var1 + var2 → '%s%s' % (var1, var2) or named. For 1.6/1.7 please do use the arg_parser, see HelloWorld or other 1.6 examples. May be you can use wikiutil.renderText in 1.6.
- If the page has no priority entries may be one is interested to get shown the length of the page listed or/and the last modification time stamp and/or last editor.
Indenting and concatenation changed; thanks for your suggestions regarding forward-porting.
I'm not sure I understand what you mean; by itself the ForEach macro doesn't really display anything, so what you mean could be accomplished by using other macros that accept a page path as argument and actually output something;
It could be interesting to extend the metadata framework available in MoinMoin (#pragma, #lang, #format etc) with more generic classes, such as - for instance - #meta priority X
Also, a big limitation of this macro is that the syntax for escaping included macros is ugly, but it's up to the wiki parser to correctly handle nested macros with more ease.