Show More
@@ -82,14 +82,17 b' def pygments_format(filename, rawtext, f' | |||||
82 | return highlight(rawtext, lexer, formatter) |
|
82 | return highlight(rawtext, lexer, formatter) | |
83 |
|
83 | |||
84 |
|
84 | |||
85 | def filerevision_pygments(self, fctx): |
|
85 | def filerevision_pygments(self, tmpl, fctx): | |
86 | """Reimplement hgweb.filerevision to use syntax highlighting""" |
|
86 | """Reimplement hgweb.filerevision to use syntax highlighting""" | |
87 |
f |
|
87 | f = fctx.path() | |
88 |
|
88 | |||
89 | rawtext = fctx.data() |
|
89 | rawtext = fctx.data() | |
90 | text = rawtext |
|
90 | text = rawtext | |
91 |
|
91 | |||
92 | mt = mimetypes.guess_type(filename)[0] |
|
92 | fl = fctx.filelog() | |
|
93 | n = fctx.filenode() | |||
|
94 | ||||
|
95 | mt = mimetypes.guess_type(f)[0] | |||
93 |
|
96 | |||
94 | if util.binary(text): |
|
97 | if util.binary(text): | |
95 | mt = mt or 'application/octet-stream' |
|
98 | mt = mt or 'application/octet-stream' | |
@@ -107,36 +110,35 b' def filerevision_pygments(self, fctx):' | |||||
107 |
|
110 | |||
108 | style = self.config("web", "pygments_style", "colorful") |
|
111 | style = self.config("web", "pygments_style", "colorful") | |
109 |
|
112 | |||
110 |
text_formatted = lines(pygments_format(f |
|
113 | text_formatted = lines(pygments_format(f, text, | |
111 | forcetext=forcetext, |
|
114 | forcetext=forcetext, | |
112 | stripecount=self.stripecount, |
|
115 | stripecount=self.stripecount, | |
113 | style=style)) |
|
116 | style=style)) | |
114 |
|
117 | |||
115 | # override per-line template |
|
118 | # override per-line template | |
116 |
|
|
119 | tmpl.cache['fileline'] = '#line#' | |
117 |
|
120 | |||
118 | # append a <link ...> to the syntax highlighting css |
|
121 | # append a <link ...> to the syntax highlighting css | |
119 |
old_header = ''.join( |
|
122 | old_header = ''.join(tmpl('header')) | |
120 | if SYNTAX_CSS not in old_header: |
|
123 | if SYNTAX_CSS not in old_header: | |
121 | new_header = old_header + SYNTAX_CSS |
|
124 | new_header = old_header + SYNTAX_CSS | |
122 |
|
|
125 | tmpl.cache['header'] = new_header | |
123 |
|
126 | |||
124 |
yield |
|
127 | yield tmpl("filerevision", | |
125 |
|
|
128 | file=f, | |
126 |
|
|
129 | path=hgweb_mod._up(f), # fixme: make public | |
127 |
|
|
130 | text=text_formatted, | |
128 |
|
|
131 | raw=rawtext, | |
129 |
|
|
132 | mimetype=mt, | |
130 |
|
|
133 | rev=fctx.rev(), | |
131 |
|
|
134 | node=hex(fctx.node()), | |
132 |
|
|
135 | author=fctx.user(), | |
133 |
|
|
136 | date=fctx.date(), | |
134 |
|
|
137 | desc=fctx.description(), | |
135 |
|
|
138 | parent=self.siblings(fctx.parents()), | |
136 |
|
|
139 | child=self.siblings(fctx.children()), | |
137 |
|
|
140 | rename=self.renamelink(fl, n), | |
138 | fctx.filenode()), |
|
141 | permissions=fctx.manifest().flags(f)) | |
139 | permissions=fctx.manifest().flags(filename)) |
|
|||
140 |
|
142 | |||
141 |
|
143 | |||
142 | # monkeypatch in the new version |
|
144 | # monkeypatch in the new version |
General Comments 0
You need to be logged in to leave comments.
Login now