views: blob: render empty blobs specially

Empty (zero-length) blobs are currently rendered by 'pygments'
misleadingly as a single empty line, or, when 'pygments' is unavailable,
as "nothingness" preceding a horizontal rule. In either case, it is
somewhat difficult to glean concrete information about the blob.

Address this by instead rendering summary information about the blob: in
particular, its classification ("empty") and its size ("0 bytes"). This
is analogous to the summary information rendered for binary blobs
("binary" and size).

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>
This commit is contained in:
Eric Sunshine 2015-01-13 04:57:16 -05:00 committed by Alberto Bertogli
parent c91beccdb0
commit 46640c68b9

@ -39,7 +39,13 @@
<a href="">{{!fname.html}}</a> <a href="">{{!fname.html}}</a>
</h3> </h3>
% if can_embed_image(repo, fname.unicode): % if len(blob.raw_content) == 0:
<table class="nice">
<tr>
<td>empty &mdash; 0 bytes</td>
</tr>
</table>
% elif can_embed_image(repo, fname.unicode):
{{!embed_image_blob(fname.raw, blob.raw_content)}} {{!embed_image_blob(fname.raw, blob.raw_content)}}
% elif is_binary(blob.raw_content): % elif is_binary(blob.raw_content):
<table class="nice blob-binary"> <table class="nice blob-binary">