author | Eric Sunshine
<sunshine@sunshineco.com> 2015-01-13 09:57:11 UTC |
committer | Alberto Bertogli
<albertito@blitiri.com.ar> 2015-01-13 19:51:44 UTC |
parent | 1d79988228a9b08c86d9e595fdc1b92f7ca50424 |
utils.py | +2 | -8 |
views/blob.html | +1 | -1 |
diff --git a/utils.py b/utils.py index 7223303..a68836f 100644 --- a/utils.py +++ b/utils.py @@ -98,14 +98,8 @@ def colorize_blob(fname, s): def markdown_blob(s): return markdown.markdown(s) -def embed_image_blob(repo, dirname, fname): +def embed_image_blob(fname, image_data): mimetype = mimetypes.guess_type(fname)[0] - - # Unfortunately, bottle seems to require utf-8 encoded data. - # We have to refetch the blob as raw data, because the utf-8 encoded - # version of the blob available in the bottle template discards binary data. - raw_blob = repo.blob(dirname + fname) - return '<img style="max-width:100%;" src="data:{0};base64,{1}" />'.format( \ - mimetype, base64.b64encode(raw_blob.raw_content)) + mimetype, base64.b64encode(image_data)) diff --git a/views/blob.html b/views/blob.html index f744cd9..1849260 100644 --- a/views/blob.html +++ b/views/blob.html @@ -40,7 +40,7 @@ </h3> % if can_embed_image(repo, fname.unicode): -{{!embed_image_blob(repo, dirname.raw, fname.raw)}} +{{!embed_image_blob(fname.raw, blob.raw_content)}} % elif can_markdown(repo, fname.unicode): {{!markdown_blob(blob.utf8_content)}} % elif can_colorize(blob.utf8_content):