Modify

Opened 7 years ago

Last modified 4 years ago

#3203 new defect

SubWiki macro: (reversed) alphabetical sort order

Reported by: jholg@… Owned by: coderanger
Priority: normal Component: HierWikiPlugin
Severity: normal Keywords:
Cc: Trac Release: 0.11

Description

Sort order of the SubWiki macro doesn't seem to be alphabetical for me, at least not like I'm used to Python ordering strings. This can be easily enforced by using sorted().

Plus, I'd like to reverse the sort order, to have pages that contain timestamp-like parts in their name show up with the latest one on top, e.g.

  • subpages/2008-06-13
  • subpages/2008-06-11
  • ...

Patch attached that enforces alphabetical order and adds an optional 3rd argument reverse.

Btw I'm running 0.11b2 and the SubWiki macro seems to run without problems for me.

Holger

Attachments (2)

subwiki.py.patch (2.6 KB) - added by jholg@… 7 years ago.
reversible alphabetical order in SubWiki macro
hierwikiplugin_subwiki_reverse_order.diff (5.5 KB) - added by jholg 4 years ago.
optional reverse sort order parameter patch

Download all attachments as: .zip

Change History (4)

Changed 7 years ago by jholg@…

reversible alphabetical order in SubWiki macro

comment:1 Changed 4 years ago by jholg

I've adapted my patch to add an optional 'reverse' parameter to reverse sort order to r9404, respecting the new style parameter, both for the 0.11 and 0.12 macro versions. I haven't bothered with the <= 0.10 versions.

The patch also adds documentation to the previously pretty much undocumented level and style parameters:

   Inserts an alphabetic list of sub-wiki pages into the output.
    A sub-wiki page is a page that is is deeper in the hierachy than the current page.
 e.g. if the current page is People, the this will return a list of all wiki entries th
at start with "People/"

    Parameters:
    prefix: optional prefix string. If provided, only pages with names that
        start with the prefix are included in the resulting list. If this
        parameter is omitted, all pages are listed.
    level: optional, how many 'levels' to go down in hierarchy (default:
        0 i.e. unrestricted)
    style: optional output style parameter (default: 1). Possible styles:
        0: pagename, title
        1: short pagename, title
        2: title
        3: pagename
        4: short pagename
    reverse: optional boolean parameter, reverse page sorting (default: False)

Note that I've only been able to test with Trac 0.11 (0.11.7) but these are the only 0.11/0.12 differences in the patched files:

$ diff hierwikiplugin/0.11/hierwiki/macros/subwiki.py hierwikiplugin/0.12/hierwiki/macros/subwiki.py 
85,88c85
<         self.good_pages.sort()
<         # 0.11 supports Python 2.3 which has no .sort(reverse=True) keyword arg
<         if self.reverse:
<             self.good_pages.reverse()
---
>         self.good_pages.sort(reverse=self.reverse

Patch file: attachment:hierwikiplugin_subwiki_reverse_order.diff

Changed 4 years ago by jholg

optional reverse sort order parameter patch

comment:2 Changed 4 years ago by jholg

Forgot to mention that attachment:hierwikiplugin_subwiki_reverse_order.diff also fixes the erroneous parameter handling (must check for 'None' rather than None).

Add Comment

Modify Ticket

Action
as new The owner will remain coderanger.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.