Changeset 3071 for trac/trunk


Ignore:
Timestamp:
02/22/06 17:10:28 (7 years ago)
Author:
moschny
Message:

Apply a patch from Christophe Eymard <pwipwi.thecow@…> that
adds the ability to combine more than one wiki page to form the toc.

The CSS needs some fixing, though. Gecko-based browsers now render the
trac-nav box with page width.

Location:
trac/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trac/trunk/htdocs/tracnav.css

    r3043 r3071  
    4040} 
    4141.wiki-toc.trac-nav h4 { 
    42  margin: 0; padding: 0; 
     42 margin: 0; 
     43 padding: 0; 
    4344} 
    4445.wiki-toc.trac-nav ul > li:first-child { 
     
    4647} 
    4748.wiki-toc.trac-nav .edit { 
    48  position: absolute; 
    49  top: 2px; 
    50  right: 3px; 
    51  margin-left: 3px; 
    52  border: 0; 
     49 /* FIXME: this causes Gecko-based browsers to  
     50    stretch trac-nav box over the whole page */ 
     51 float: right; 
     52 text-align: right; 
    5353} 
    5454.wiki-toc.trac-nav .edit a { 
    55  color:blue; border-color:blue; 
     55 color: blue; 
     56 border-color: blue; 
    5657} 
  • trac/trunk/wiki-macros/TracNav.py

    r3063 r3071  
    4545== Author and license == 
    4646 
    47 Copyright 2005 
     47Copyright 2005, 2006 
    4848 *  Bernhard Haumacher (haui at haumacher.de) 
    4949 *  Thomas Moschny (moschny at ipd.uni-karlsruhe.de) 
     
    197197    preview = hdf.getValue('args.preview', "") 
    198198    curpage = hdf.getValue('wiki.page_name', "") 
    199     name = args or 'TOC' 
    200  
    201     toc = parse_toc(get_toc(hdf, env, preview, name), env) 
    202     if not toc: 
    203         toc = parse_toc(' * TOC "%s" is empty!' % name, env) 
    204  
    205     (found, filtered) = filter_toc(curpage, toc, 0) 
    206     if found: 
    207         return display_all(hdf, env, name, curpage, filtered, 0) 
    208     else: 
    209         return display_all(hdf, env, name, curpage, toc, 0) 
     199 
     200    # split the argument to get the wiki page names to include 
     201    names = (args or "TOC").split('|') 
     202 
     203    # Parsing the tocS 
     204    tocs = [] 
     205    for name in names: 
     206        toc = parse_toc(get_toc(hdf, env, preview, name), env) 
     207        if not toc: 
     208            toc = parse_toc(' * TOC "%s" is empty!' % name, env) 
     209        tocs.append((name, toc)) 
     210 
     211    col = 0 
     212    html = '%s<div class="wiki-toc trac-nav">\n' % indentation(col) 
     213    col += 1 
     214    html += '%s<h2><a href="%s">TracNav</a> menu</h2>' % \ 
     215            (indentation(col), TRACNAVHOME) 
     216 
     217    for name, toc in tocs: 
     218        (found, filtered) = filter_toc(curpage, toc, 0) 
     219        if found: 
     220            html += display_all(hdf, env, name, curpage, filtered, col) 
     221        else: 
     222            html += display_all(hdf, env, name, curpage, toc, col) 
     223    col -= 1 
     224    html += '%s</div>\n' % indentation(col) 
     225    return html 
     226 
    210227 
    211228 
     
    238255def display_all(hdf, env, name, curpage, toc, col): 
    239256    preview = hdf.getValue('args.preview', "") 
    240     html = '%s<div class="wiki-toc trac-nav">\n' % indentation(col) 
    241     col += 1 
    242     html += '%s<h2><a href="%s">TracNav</a> menu</h2>' % \ 
    243             (indentation(col), TRACNAVHOME) 
     257    html = '' 
    244258 
    245259    if (not preview) and hdf.getValue('trac.acl.WIKI_MODIFY', ''): 
     
    251265    col -= 1 
    252266    html += '%s</ul>\n' % indentation(col) 
    253     col -= 1 
    254     html += '%s</div>\n' % indentation(col) 
    255267    return html 
    256268 
Note: See TracChangeset for help on using the changeset viewer.