From 09c2f33f5a1f7137d50b3638e1a3f937e0701a6e Mon Sep 17 00:00:00 2001 From: Eric Sunshine Date: Tue, 13 Jan 2015 04:57:13 -0500 Subject: blob: render binary blob summary information rather than raw content Binary blobs are currently rendered as raw data directly into the HTML output, looking much like "line noise". This is rarely, if ever, meaningful, and consumes considerable storage space since the entire raw blob content is embedded in the generated HTML file. Address this issue by instead emitting summary information about the blob, such as its classification ("binary") and its size. Other information can be added as needed. As in Git itself, a blob is considered binary if a NUL is present in the first ~8KB. Signed-off-by: Eric Sunshine Signed-off-by: Alberto Bertogli --- views/blob.html | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'views') diff --git a/views/blob.html b/views/blob.html index 1849260..4526c99 100644 --- a/views/blob.html +++ b/views/blob.html @@ -41,6 +41,14 @@ % if can_embed_image(repo, fname.unicode): {{!embed_image_blob(fname.raw, blob.raw_content)}} +% elif is_binary(blob.raw_content): + + + + +
+ binary — {{'{:,}'.format(len(blob.raw_content))}} bytes +
% elif can_markdown(repo, fname.unicode): {{!markdown_blob(blob.utf8_content)}} % elif can_colorize(blob.utf8_content): -- cgit v1.2.3