PageList macro returns a list in alphabetical order only

The PageList macro is often used by me to show similar named pages (e.g. meeting protocols with time stamps). Sometimes it looks better in a reverse order. So I implemented a sort order switch for the PageList macro. This is just meant as a hint and works for my personal use. Maybe someone else is interested in it, that's why I put it in here.

Usage:  [PageList(reverse,regex...)] 

If reverse, is given, the returned page list will be in reverse alphabetical order. Otherwise without reverse, it works like usual.  [PageList(regex...)] 

Btw. it should be easy to implement different sort orders, just expand the "if sortorder ==" clause to your needs.

771,772c771,775
<     def sortByPagename(self):
<         """ Sorts a list of found pages alphabetical by page name """
---
>     def sortByPagename(self, sortorder=None):
>         """ Sorts a list of found pages alphabetical by page name 
>         
>         @param sortorder: which mode to sort the list
>         """
774c777,781
<         tmp.sort()
---
>               # define different modes for sorting here e.g. reverse
>         if sortorder == "reverse":
>             tmp.sort(reverse=True)
>         else:
>             tmp.sort()

471c471
<     def _macro_PageList(self, needle):
---
>     def _macro_PageList(self, args):
475a476
>         sortorder = None
476a478,481
>         if args.find(',') == -1:
>             needle = args
>         else:
>             sortorder, needle = args.split(',', 1)
479c484
<         if not needle:
---
>         if not args or not needle:
487d491
<             
492c496
<         results.sortByPagename()
---
>         results.sortByPagename(sortorder)

This patch should be done with the current version of moin. Also it should not change the current API. At least not the order of arguments. We want also unified diffs. A similiar macro is in the extensions repo as ListPages.py (reverse is implemented as reverse of sort).


CategoryFeatureRequest

MoinMoin: FeatureRequests/PageListSortorder (last edited 2011-03-06 11:04:43 by ReimarBauer)