Changeset 4432
- Timestamp:
- 10/12/08 05:45:36 (3 months ago)
- Files:
-
- includesourcepartialplugin/0.11/IncludeSource.py (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
includesourcepartialplugin/0.11/IncludeSource.py
r4406 r4432 78 78 file_name = largs[0] 79 79 rev = kwargs.get('rev', None) 80 81 if kwargs.has_key('header'): 82 header = kwargs.get('header') # user specified header 83 else: 84 href = '../browser/%s%s' % (file_name, make_rev_str(rev)) 85 header = tag.a(file_name, href=href) 86 if not header: 87 header = u'\xa0' # default value from trac.mimeview.api.py 88 89 # TODO - 'content' is default from mimeview.api.py, but it picks 90 # up text-align: center, which probably isn't the best thing if 91 # we are adding a file name in the header. There isn't an obvious 92 # replacement in the delivered CSS to pick over this for now though 93 header_class = kwargs.get('header_class', 'content') 94 80 95 src = repos.get_node(file_name, rev).get_content().read() 81 96 … … 103 118 # tweak the output here by running the genshi stream from 104 119 # src through a transformer that will make the change 105 xp = 'thead/tr/th[@class="givenlineno"]' 120 121 xpath1 = 'thead/tr/th[@class="givenlineno"]' 122 xpath2 = 'thead/tr/th[2]' # last() not supported by Genshi? 123 xpath3 = 'thead/tr/th[2]/text()' 124 106 125 # TODO - does genshi require a QName here? Seems to work w/o it 107 src = src.generate() | Transformer(xp).attr('class', 'lineno') 126 src = src.generate() | Transformer(xpath1).attr('class', 'lineno') \ 127 | Transformer(xpath2).attr('class', header_class) \ 128 | Transformer(xpath3).replace(header) 108 129 109 130 return src … … 158 179 file_name = file_name[1:] 159 180 160 rev = context.rev and '?rev=' + str(context.rev) or ''181 rev = make_rev_str(context.rev) 161 182 162 183 lineno = context.startline + lineno - 1 … … 166 187 )) 167 188 189 def make_rev_str(rev=None): 190 return rev and '?rev=' + str(rev) or '' 191
