git » git-arr » commit 46640c6

views: blob: render empty blobs specially

author Eric Sunshine
2015-01-13 09:57:16 UTC
committer Alberto Bertogli
2015-01-13 19:51:45 UTC
parent c91beccdb04f0437ac6cd8f13c09117ea9766296

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>

views/blob.html +7 -1

diff --git a/views/blob.html b/views/blob.html
index 521fe74..ef20328 100644
--- a/views/blob.html
+++ b/views/blob.html
@@ -39,7 +39,13 @@
     <a href="">{{!fname.html}}</a>
 </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)}}
 % elif is_binary(blob.raw_content):
 <table class="nice blob-binary">