Ignore:
Timestamp:
03/24/05 16:50:41 (8 years ago)
Author:
hauma
Message:
  • Fancified HTML output with line breaks and indentation.
File:
1 edited

Legend:

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

    r2865 r2931  
    151151        if (hdf.getValue('trac.acl.WIKI_MODIFY', '')): 
    152152            msg += ' Click here to <a href="%s?edit=yes">edit</a>.' % env.href.wiki(name) 
    153         msg += '</strong></div>' 
     153        msg += '</strong></div>\n' 
    154154        return msg 
    155155 
    156156    html = '' 
    157     html += '<div class="wiki-toc trac-nav">' 
     157    html += '<div class="wiki-toc trac-nav">\n' 
    158158    if (hdf.getValue('trac.acl.WIKI_MODIFY', '')): 
    159         html += '<div class="edit"><a href="%s?edit=yes">edit</a></div>' % env.href.wiki(name) 
     159        html += '<div class="edit"><a href="%s?edit=yes">edit</a></div>\n' % env.href.wiki(name) 
    160160    (found, filtered) = filter(curpage, toc, 0) 
    161161    if found: 
    162         html += display(env, curpage, filtered) 
     162        html += display(env, curpage, filtered, 1) 
    163163    else: 
    164         html += display(env, curpage, toc) 
    165     html += '</div>' 
     164        html += display(env, curpage, toc, 1) 
     165    html += '</div>\n' 
    166166    return html 
    167167 
     
    189189    return (found, result) 
    190190 
    191  
    192 def display(env, curpage, toc): 
    193     html = '<ul>' 
     191def indentation(col): 
     192    return ' ' * col 
     193 
     194def display(env, curpage, toc, col): 
     195    html = '%s<ul>\n' % ( indentation(col) ) 
     196    col += 1 
    194197    for name, title, sub in toc: 
    195198        if sub == None: 
     
    198201            else: 
    199202                cls = '' 
    200             html += '<li%s>' % ( cls ) 
     203            html += '%s<li%s>' % (indentation(col), cls) 
    201204            if name == None: 
    202205                html += title 
    203206            else: 
    204207                html += '<a href="%s">%s</a>' % (env.href.wiki(name), title) 
    205             html += '</li>' 
    206         else: 
    207             html += '<li>' 
     208            html += '</li>\n' 
     209        else: 
     210            html += '%s<li>\n' % indentation(col) 
     211            col += 1 
    208212            if name == None or len(sub) > 0: 
    209                 html += '<h4>%s</h4>' % title 
    210             else: 
    211                 html += '<h4><a href="%s">%s...</a></h4>' % (env.href.wiki(name), title) 
    212             html += display(env, curpage, sub) 
    213             html += '</li>' 
    214     html += '</ul>' 
     213                html += '%s<h4>%s</h4>\n' % (indentation(col), title) 
     214            else: 
     215                html += '%s<h4><a href="%s">%s...</a></h4>\n' % (indentation(col), env.href.wiki(name), title) 
     216            if len(sub) > 0: 
     217                html += display(env, curpage, sub, col) 
     218            col -= 1 
     219            html += '%s</li>\n' % indentation(col) 
     220    col -= 1 
     221    html += '%s</ul>\n' % indentation(col) 
    215222    return html 
    216223 
Note: See TracChangeset for help on using the changeset viewer.