Edgewall Software

Ticket #7124: trac-0.11.2-wiki-macros.patch

File trac-0.11.2-wiki-macros.patch, 1.4 KB (added by marek.lukacs@…, 3 years ago)

Omit pages equals to or starting with world listed in colon separated list

  • wiki/macros.py

    diff -Nura trac.orig/wiki/macros.py trac/wiki/macros.py
    old new  
    8383       only toplevel pages will be shown, if set to 1, only immediate 
    8484       children pages will be shown, etc. If not set, or set to -1, 
    8585       all pages in the hierarchy will be shown. 
     86     - `omit=colon:separated:list`: omit pages listed in the list 
     87     - `omitstartswith=colon:separated:list`: pages starting with a string 
     88       from argument list will be omitted 
    8689    """ 
    8790 
    8891    SPLIT_RE = re.compile(r"( |/|[0-9])") 
     
    9497        minsize = max(int(kw.get('min', 2)), 2) 
    9598        depth = int(kw.get('depth', -1)) 
    9699        start = prefix and prefix.count('/') or 0 
     100        omit = kw.get('omit', '') 
     101        omit = tuple(omit and omit.split(':') or []) 
     102        omitsw = kw.get('omitstartswith', '') 
     103        omitsw = tuple(omitsw and omitsw.split(':') or []) 
    97104 
    98105        wiki = formatter.wiki 
    99106        pages = sorted([page for page in wiki.get_pages(prefix) \ 
    100                         if 'WIKI_VIEW' in formatter.perm('wiki', page)]) 
     107                        if (not omit or not page in omit) and \ 
     108                           (not omitsw or not page.startswith(omitsw)) and \ 
     109                           ('WIKI_VIEW' in formatter.perm('wiki', page))]) 
    101110 
    102111        if format != 'group': 
    103112            return tag.ul([tag.li(tag.a(wiki.format_page_name(page),