summaryrefslogtreecommitdiff
path: root/utils.py
diff options
context:
space:
mode:
authorEric Sunshine <sunshine@sunshineco.com>2015-01-13 10:57:11 +0100
committerAlberto Bertogli <albertito@blitiri.com.ar>2015-01-13 20:51:44 +0100
commit50c004f8a5f26ad27f03597b050f9b1a1910cc45 (patch)
tree09db1b151fd1ef6bd5525aefd4df9761d440fc80 /utils.py
parent1d79988228a9b08c86d9e595fdc1b92f7ca50424 (diff)
downloadgit-arr-fork-50c004f8a5f26ad27f03597b050f9b1a1910cc45.zip
embed_image_blob: retire reload of image blob
Historically, the 'blob' view was unconditionally handed cooked (utf8-encoded) blob content, so embed_image_blob(), which requires raw blob content, has been forced to reload the blob in raw form, which is ugly and expensive. However, now that the Blob returned by Repo.blob() is able to vend raw or cooked content, it is no longer necessary for embed_image_blob() to reload the blob to gain access to the raw content. Signed-off-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>
Diffstat (limited to 'utils.py')
-rw-r--r--utils.py10
1 files changed, 2 insertions, 8 deletions
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))