Changeset 3085
- Timestamp:
- 03/24/06 17:53:30 (7 years ago)
- Location:
- trac/plugins/tracnav
- Files:
-
- 2 edited
-
setup.py (modified) (1 diff)
-
tracnav/tracnav.py (modified) (8 diffs, 1 prop)
Legend:
- Unmodified
- Added
- Removed
-
trac/plugins/tracnav/setup.py
r3084 r3085 2 2 3 3 from setuptools import setup 4 5 PACKAGE = 'TracNav' 6 VERSION = '3.90' 4 from tracnav.tracnav import __version__ as version 7 5 8 6 setup( 9 name = PACKAGE,10 version = VERSION,7 name = 'TracNav', 8 version = version, 11 9 packages = ['tracnav'], 12 10 package_data = { 'tracnav': ['htdocs/css/*.css'] }, 13 author = 'Bernhard Haumacher, Thomas Moschny', 11 author = 'Bernhard Haumacher', 12 author_email = 'haui@haumacher.de', 13 maintainer = 'Thomas Moschny', 14 maintainer_email = 'moschny@ipd.uni-karlsruhe.de', 14 15 url = 'http://svn.ipd.uka.de/trac/javaparty/wiki/TracNav', 15 16 description = 'The navigation bar for Trac', 16 entry_points={'trac.plugins': '%s = tracnav' % PACKAGE}, 17 licence = 'GPL', 17 entry_points={'trac.plugins': 'TracNav = tracnav'}, 18 keywords = 'trac toc', 19 license = 'GPL', 18 20 ) -
trac/plugins/tracnav/tracnav/tracnav.py
- Property svn:keywords changed from Id to Id LastChangedRevision
r3083 r3085 55 55 56 56 """ 57 58 __revision__ = "$Id$" 57 __id__ = '$Id$' 58 __version__ = '3.91' 59 __revision__ = '$LastChangedRevision$' 59 60 60 61 import re 61 from trac.core import Component 62 from trac.core import Component, implements 62 63 from trac.wiki.api import WikiSystem, IWikiMacroProvider 63 from trac.web.chrome import ITemplateProvider 64 from trac.web.chrome import ITemplateProvider, add_stylesheet 64 65 from trac.wiki.model import WikiPage 65 66 from trac.wiki.formatter import Formatter, OneLinerFormatter 66 from StringIO import StringIO 67 try: 68 from cStringIO import StringIO 69 except ImportError: 70 from StringIO import StringIO 71 67 72 68 73 TRACNAVHOME = "http://svn.ipd.uka.de/trac/javaparty/wiki/TracNav" … … 110 115 class TracNav(Component): 111 116 112 from trac.core import implements113 117 implements(IWikiMacroProvider, ITemplateProvider) 114 118 … … 117 121 Fetch the wiki page containing the toc, if available. 118 122 """ 119 preview = req.hdf.getValue('args.preview', "") 120 121 if preview: 122 cur_path = req.hdf.getValue('HTTP.PathInfo', '') 123 toc_path = "/wiki/" + name 124 if cur_path == toc_path: 125 return req.hdf.getValue('args.text', '') 126 127 if WikiSystem(self.env).has_page(name): 123 preview = req.args.get('preview', '') 124 curpage = req.args.get('page') 125 126 if preview and name == curpage: 127 return req.args.get('text', '') 128 elif WikiSystem(self.env).has_page(name): 128 129 return WikiPage(self.env, name).text 129 130 else: … … 159 160 160 161 def _parse_toc(self, gen, next_indent, level = 0): 162 """ 163 Construct the toc tree at the given level. 164 """ 161 165 toclist = [] 162 166 if next_indent > level: … … 193 197 Main routine of the wiki macro. 194 198 """ 195 curpage = req.hdf.getValue('wiki.page_name', "") 196 197 # split the argument to get the wiki page names to include 199 out = StringIO() 200 201 # header 202 col = 0 203 out.write('%s<div class="wiki-toc trac-nav">\n' % self.i(col)) 204 col += 1 205 out.write('%s<h2><a href="%s">TracNav</a> menu</h2>\n' % \ 206 (self.i(col), TRACNAVHOME)) 207 208 # add TOCs 209 curpage = req.args.get('page','') 198 210 names = (args or "TOC").split('|') 199 211 200 # Parsing the tocS201 tocs = []202 212 for name in names: 203 213 toc_text = self.get_toc(req, name) … … 205 215 if not toc: 206 216 toc = self.parse_toc(' * TOC "%s" is empty!' % name) 207 tocs.append((name, toc))208 209 col = 0210 html = '%s<div class="wiki-toc trac-nav">\n' % self.indentation(col)211 col += 1212 html += '%s<h2><a href="%s">TracNav</a> menu</h2>\n' % \213 (self.indentation(col), TRACNAVHOME)214 215 for name, toc in tocs:216 217 (found, filtered) = self.filter_toc(curpage, toc) 217 218 if found: 218 html += self.display_all(req, name, filtered, col)219 self.display_all(out, req, name, filtered, col) 219 220 else: 220 html += self.display_all(req, name, toc, col) 221 self.display_all(out, req, name, toc, col) 222 223 # footer 221 224 col -= 1 222 html += '%s</div>\n' % self.indentation(col)223 224 from trac.web.chrome import add_stylesheet225 out.write('%s</div>\n' % self.i(col)) 226 227 # add our stylesheet 225 228 add_stylesheet(req, 'tracnav/css/tracnav.css') 226 return html 229 230 # emit 231 return out.getvalue() 227 232 228 233 … … 251 256 252 257 253 def i ndentation(self, col):258 def i(self, col): 254 259 return ' ' * col 255 260 256 261 257 def display_all(self, req, name, toc, col): 258 preview = req.hdf.getValue('args.preview', "") 259 curpage = req.hdf.getValue('wiki.page_name', "") 260 html = '' 262 def display_all(self, out, req, name, toc, col): 263 preview = req.hdf.getValue('args.preview', '') 264 curpage = req.hdf.getValue('wiki.page_name', '') 261 265 262 266 if (not preview) and req.hdf.getValue('trac.acl.WIKI_MODIFY', ''): 263 html +='%s<div class="edit"><a href="%s?edit=yes">edit</a></div>\n' % \264 (self.i ndentation(col), self.env.href.wiki(name))265 html += '%s<ul>\n' % self.indentation(col)267 out.write('%s<div class="edit"><a href="%s?edit=yes">edit</a></div>\n' % \ 268 (self.i(col), self.env.href.wiki(name))) 269 out.write('%s<ul>\n' % self.i(col)) 266 270 col += 1 267 html += self.display(curpage, toc, 0, col)271 self.display(out, curpage, toc, 0, col) 268 272 col -= 1 269 html += '%s</ul>\n' % self.indentation(col) 270 return html 271 272 273 def display(self, curpage, toc, depth, col): 274 html = '' 273 out.write('%s</ul>\n' % self.i(col)) 274 275 276 def display(self, out, curpage, toc, depth, col): 275 277 for name, title, sub in toc: 276 278 li_style = ' style="padding-left: %dem;"' % (depth + 1) … … 280 282 else: 281 283 cls = '' 282 html +='%s<li%s%s>%s</li>\n' % \283 (self.i ndentation(col), li_style, cls, title)284 out.write('%s<li%s%s>%s</li>\n' % \ 285 (self.i(col), li_style, cls, title)) 284 286 else: 285 html += '%s<li%s>\n' % (self.indentation(col), li_style)287 out.write('%s<li%s>\n' % (self.i(col), li_style)) 286 288 col += 1 287 289 if name == None or sub: 288 html += '%s<h4>%s</h4>\n' % \ 289 (self.indentation(col), title) 290 out.write('%s<h4>%s</h4>\n' % (self.i(col), title)) 290 291 else: 291 html += '%s<h4>%s...</h4>\n' % \ 292 (self.indentation(col), title) 292 out.write('%s<h4>%s...</h4>\n' % (self.i(col), title)) 293 293 col -= 1 294 html += '%s</li>\n' % self.indentation(col)294 out.write('%s</li>\n' % self.i(col)) 295 295 if len(sub) > 0: 296 html += self.display(curpage, sub, depth + 1, col) 297 return html 296 self.display(out, curpage, sub, depth + 1, col) 298 297 299 298
Note: See TracChangeset
for help on using the changeset viewer.
