aboutsummaryrefslogtreecommitdiff
path: root/views
diff options
context:
space:
mode:
authorEric Sunshine <sunshine@sunshineco.com>2015-01-13 10:57:14 +0100
committerAlberto Bertogli <albertito@blitiri.com.ar>2015-01-13 20:51:44 +0100
commit6f3942ce38d0417baf57188eebf9bc2075f2f59a (patch)
tree90293d87633bfa3f16ba972ffc1314370e833f6f /views
parent09c2f33f5a1f7137d50b3638e1a3f937e0701a6e (diff)
downloadgit-arr-fork-6f3942ce38d0417baf57188eebf9bc2075f2f59a.zip
blob: render hexdump(1)-style binary blob content
Raw binary blob content tends to look like "line noise" and is rarely, if ever, meaningful. A hexdump(1)-style rendering (specifically, "hexdump -C"), on the other hand, showing runs of hexadecimal byte values along with an ASCII representation of those bytes can sometimes reveal useful information about the data. (A subsequent patch will add the ability to cap the amount of data rendered in order to reduce storage space requirements.) Signed-off-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>
Diffstat (limited to 'views')
-rw-r--r--views/blob.html12
1 files changed, 10 insertions, 2 deletions
diff --git a/views/blob.html b/views/blob.html
index 4526c99..74c910a 100644
--- a/views/blob.html
+++ b/views/blob.html
@@ -42,12 +42,20 @@
% if can_embed_image(repo, fname.unicode):
{{!embed_image_blob(fname.raw, blob.raw_content)}}
% elif is_binary(blob.raw_content):
-<table class="nice">
+<table class="nice blob-binary">
<tr>
- <td>
+ <td colspan="4">
binary &mdash; {{'{:,}'.format(len(blob.raw_content))}} bytes
</td>
</tr>
+% for offset, hex1, hex2, text in hexdump(blob.raw_content):
+ <tr>
+ <td class="offset">{{offset}}</td>
+ <td><pre>{{hex1}}</pre></td>
+ <td><pre>{{hex2}}</pre></td>
+ <td><pre>{{text}}</pre></td>
+ </tr>
+% end
</table>
% elif can_markdown(repo, fname.unicode):
{{!markdown_blob(blob.utf8_content)}}