diff options
Diffstat (limited to 'git-hooks')
-rwxr-xr-x | git-hooks/post-receive | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/git-hooks/post-receive b/git-hooks/post-receive index f8337ad..4871122 100755 --- a/git-hooks/post-receive +++ b/git-hooks/post-receive @@ -288,7 +288,10 @@ while todotrees: linktarget = get_relative(path, tree) link.symlink_to(linktarget, target_is_directory=True) # FIXME html-escape - f.write("<li><a href=\"./{}\">{}</a></li>".format(quoted, quoted)) + f.write("<li>") + f.write("<a href=\"./{}\">{}</a>".format(quoted, quoted)) + f.write(" <span class=\"bytes\">{}</span>".format(obj.size)) + f.write("</li>") elif isinstance(obj, pygit2.Tree): todotrees.add(obj) tree = gen_dir / "trees" / str(obj.id) @@ -319,12 +322,18 @@ while todoblobs: continue with f: f.write("<!DOCTYPE html><html><head><meta charset=\"utf-8\"><title>blob</title><body>") - f.write("<a href=\"./raw.bin\">view raw</a>") + f.write("<a href=\"./raw.bin\">view raw</a> <span class=\"bytes\">") + f.write(str(b.size)) + f.write("</span>") try: text = b.data.decode("utf-8", errors="strict") lex = find_lexer(text, meta) if lex is not None: - f.write(highlight(text, lex, HtmlFormatter())) + # limit highlighting to files within 256KiB + if b.size <= (256 * 1024): + f.write(highlight(text, lex, HtmlFormatter())) + else: + f.write("<div>files larger than 256KiB may not be rendered</div>") else: # TODO maybe just write `text` (html escaped)? pass |