Changeset 2705 for trac


Ignore:
Timestamp:
02/16/05 17:31:12 (8 years ago)
Author:
hauma
Message:
  • Fancyfication: Sort the currently active top-level category to the first position in the navigation bar.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trac/trunk/wiki-macros/JPNav.py

    r2704 r2705  
    8585    if (hdf.getValue('trac.acl.WIKI_MODIFY', '')): 
    8686        html += '<div class="wiki-tocedit"><a href="%s?edit=yes">edit</a></div>' % env.href.wiki(name) 
    87     (_, subhtml) = generate(env, curpage, toc) 
     87    (_, subhtml) = generate(env, curpage, toc, 0) 
    8888    html += subhtml 
    8989    html += '</div>' 
     
    9191 
    9292 
    93 def generate(env, curpage, toc): 
    94     html = '<ul>' 
     93def generate(env, curpage, toc, level): 
     94    html = '' 
    9595    found = 0 
    9696    for name, title, sub in toc: 
     
    105105            html += '</li>' 
    106106        else: 
    107             html += '<li>' 
    108             (subfound, subhtml) = generate(env, curpage, sub) 
     107            (subfound, subhtml) = generate(env, curpage, sub, level + 1) 
    109108            if subfound: 
    110                 html += '<h4>%s</h4>' % title 
    111                 html += subhtml 
     109                menu = '' 
     110                menu += '<li>' 
     111                menu += '<h4>%s</h4>' % title 
     112                menu += subhtml 
     113                menu += '</li>' 
    112114                found = 1 
     115                if level == 0: 
     116                    html = menu + html 
     117                else: 
     118                    html += menu 
    113119            else: 
     120                html += '<li>' 
    114121                html += '<h4><a href="%s">%s...</a></h4>' % (env.href.wiki(name), title) 
    115             html += '</li>' 
    116     html += '</ul>' 
     122                html += '</li>' 
     123    html = '<ul>%s</ul>' % html 
    117124    return (found, html); 
    118125 
Note: See TracChangeset for help on using the changeset viewer.