Show More
@@ -35,6 +35,12 b' def checkfctx(fctx, expr):' | |||||
35 | mctx = fileset.matchctx(ctx, subset=[fctx.path()], status=None) |
|
35 | mctx = fileset.matchctx(ctx, subset=[fctx.path()], status=None) | |
36 | return fctx.path() in fileset.getset(mctx, tree) |
|
36 | return fctx.path() in fileset.getset(mctx, tree) | |
37 |
|
37 | |||
|
38 | def pygmentize(web, field, fctx, tmpl): | |||
|
39 | style = web.config('web', 'pygments_style', 'colorful') | |||
|
40 | expr = web.config('web', 'highlightfiles', "size('<5M')") | |||
|
41 | if checkfctx(fctx, expr): | |||
|
42 | highlight.pygmentize(field, fctx, style, tmpl) | |||
|
43 | ||||
38 | def filerevision_highlight(orig, web, req, tmpl, fctx): |
|
44 | def filerevision_highlight(orig, web, req, tmpl, fctx): | |
39 | mt = ''.join(tmpl('mimetype', encoding=encoding.encoding)) |
|
45 | mt = ''.join(tmpl('mimetype', encoding=encoding.encoding)) | |
40 | # only pygmentize for mimetype containing 'html' so we both match |
|
46 | # only pygmentize for mimetype containing 'html' so we both match | |
@@ -45,20 +51,16 b' def filerevision_highlight(orig, web, re' | |||||
45 | # can't clash with the file's content-type here in case we |
|
51 | # can't clash with the file's content-type here in case we | |
46 | # pygmentize a html file |
|
52 | # pygmentize a html file | |
47 | if 'html' in mt: |
|
53 | if 'html' in mt: | |
48 | style = web.config('web', 'pygments_style', 'colorful') |
|
54 | pygmentize(web, 'fileline', fctx, tmpl) | |
49 | expr = web.config('web', 'highlightfiles', "size('<5M')") |
|
55 | ||
50 | if checkfctx(fctx, expr): |
|
|||
51 | highlight.pygmentize('fileline', fctx, style, tmpl) |
|
|||
52 | return orig(web, req, tmpl, fctx) |
|
56 | return orig(web, req, tmpl, fctx) | |
53 |
|
57 | |||
54 | def annotate_highlight(orig, web, req, tmpl): |
|
58 | def annotate_highlight(orig, web, req, tmpl): | |
55 | mt = ''.join(tmpl('mimetype', encoding=encoding.encoding)) |
|
59 | mt = ''.join(tmpl('mimetype', encoding=encoding.encoding)) | |
56 | if 'html' in mt: |
|
60 | if 'html' in mt: | |
57 | fctx = webutil.filectx(web.repo, req) |
|
61 | fctx = webutil.filectx(web.repo, req) | |
58 | style = web.config('web', 'pygments_style', 'colorful') |
|
62 | pygmentize(web, 'annotateline', fctx, tmpl) | |
59 | expr = web.config('web', 'highlightfiles', "size('<5M')") |
|
63 | ||
60 | if checkfctx(fctx, expr): |
|
|||
61 | highlight.pygmentize('annotateline', fctx, style, tmpl) |
|
|||
62 | return orig(web, req, tmpl) |
|
64 | return orig(web, req, tmpl) | |
63 |
|
65 | |||
64 | def generate_css(web, req, tmpl): |
|
66 | def generate_css(web, req, tmpl): |
General Comments 0
You need to be logged in to leave comments.
Login now