Changeset 2724
- Timestamp:
- 02/21/05 09:32:45 (8 years ago)
- File:
-
- 1 edited
-
trac/trunk/wiki-macros/JPNav.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trac/trunk/wiki-macros/JPNav.py
r2723 r2724 98 98 if (hdf.getValue('trac.acl.WIKI_MODIFY', '')): 99 99 html += '<div class="wiki-tocedit"><a href="%s?edit=yes">edit</a></div>' % env.href.wiki(name) 100 (_, subhtml) = generate(env, curpage, toc, 0) 101 html += subhtml 100 (found, filtered) = filter(curpage, toc, 0) 101 if found: 102 html += display(env, curpage, filtered) 103 else: 104 html += display(env, curpage, toc) 102 105 html += '</div>' 103 return html ;106 return html 104 107 105 108 106 def generate(env, curpage, toc, level): 107 html = '' 109 def filter(curpage, toc, level): 108 110 found = 0 111 result = [] 112 for name, title, sub in toc: 113 if sub == None: 114 if name == curpage: 115 found = 1 116 result.append((name, title, None)) 117 else: 118 (subfound, subtoc) = filter(curpage, sub, level + 1) 119 if subfound or (name == None): 120 found = 1 121 if level == 0 and name != None: 122 prepended = [(name, title, subtoc)] 123 prepended.extend(result) 124 result = prepended 125 else: 126 result.append((name, title, subtoc)) 127 else: 128 result.append((name, title, [])) 129 return (found, result) 130 131 132 def display(env, curpage, toc): 133 html = '<ul>' 109 134 for name, title, sub in toc: 110 135 if sub == None: 111 136 if name == curpage: 112 137 cls = ' class="active"' 113 found = 1114 138 else: 115 139 cls = '' … … 121 145 html += '</li>' 122 146 else: 123 (subfound, subhtml) = generate(env, curpage, sub, level + 1) 124 if subfound or (name == None): 125 menu = '' 126 menu += '<li>' 127 menu += '<h4>%s</h4>' % title 128 menu += subhtml 129 menu += '</li>' 130 found = 1 131 if level == 0 and name != None: 132 html = menu + html 133 else: 134 html += menu 147 html += '<li>' 148 if name == None: 149 html += '<h4>%s</h4>' % title 135 150 else: 136 html += '<li>'137 151 html += '<h4><a href="%s">%s...</a></h4>' % (env.href.wiki(name), title) 138 html += '</li>' 139 html = '<ul>%s</ul>' % html 140 return (found, html); 152 html += display(env, curpage, sub) 153 html += '</li>' 154 html += '</ul>' 155 return html 141 156
Note: See TracChangeset
for help on using the changeset viewer.
