Show More
@@ -85,28 +85,18 b' def pygments_format(filename, text, forc' | |||||
85 | def filerevision_pygments(self, tmpl, 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 = fctx.path() |
|
87 | f = fctx.path() | |
88 |
|
88 | text = fctx.data() | ||
89 | rawtext = fctx.data() |
|
|||
90 | text = rawtext |
|
|||
91 |
|
||||
92 | fl = fctx.filelog() |
|
89 | fl = fctx.filelog() | |
93 | n = fctx.filenode() |
|
90 | n = fctx.filenode() | |
94 |
|
91 | |||
95 | mt = mimetypes.guess_type(f)[0] |
|
|||
96 |
|
||||
97 | # we always want hgweb.encoding |
|
|||
98 | util._encoding = self.encoding |
|
|||
99 |
|
||||
100 | if util.binary(text): |
|
92 | if util.binary(text): | |
101 | mt = mt or 'application/octet-stream' |
|
93 | mt = mimetypes.guess_type(f)[0] or 'application/octet-stream' | |
102 | text = "(binary:%s)" % mt |
|
94 | text = "(binary:%s)" % mt | |
103 |
|
||||
104 | # don't parse (binary:...) as anything |
|
95 | # don't parse (binary:...) as anything | |
105 | forcetext = True |
|
96 | forcetext = True | |
106 | else: |
|
97 | else: | |
107 | mt = mt or 'text/plain' |
|
|||
108 |
|
||||
109 | # encode to hgweb.encoding for lexers and formatter |
|
98 | # encode to hgweb.encoding for lexers and formatter | |
|
99 | util._encoding = self.encoding | |||
110 | text = util.tolocal(text) |
|
100 | text = util.tolocal(text) | |
111 | forcetext = False |
|
101 | forcetext = False | |
112 |
|
102 | |||
@@ -128,12 +118,10 b' def filerevision_pygments(self, tmpl, fc' | |||||
128 | new_header = old_header + SYNTAX_CSS |
|
118 | new_header = old_header + SYNTAX_CSS | |
129 | tmpl.cache['header'] = new_header |
|
119 | tmpl.cache['header'] = new_header | |
130 |
|
120 | |||
131 |
|
|
121 | return tmpl("filerevision", | |
132 | file=f, |
|
122 | file=f, | |
133 | path=hgweb_mod._up(f), # fixme: make public |
|
123 | path=hgweb_mod._up(f), # fixme: make public | |
134 | text=text_formatted, |
|
124 | text=text_formatted, | |
135 | raw=rawtext, |
|
|||
136 | mimetype=mt, |
|
|||
137 | rev=fctx.rev(), |
|
125 | rev=fctx.rev(), | |
138 | node=hex(fctx.node()), |
|
126 | node=hex(fctx.node()), | |
139 | author=fctx.user(), |
|
127 | author=fctx.user(), |
General Comments 0
You need to be logged in to leave comments.
Login now