Show More
@@ -1812,9 +1812,24 b' def urlify_commit_message(commit_text, r' | |||
|
1812 | 1812 | return literal(newtext) |
|
1813 | 1813 | |
|
1814 | 1814 | |
|
1815 | def render_binary(repo_name, file_obj): | |
|
1816 | """ | |
|
1817 | Choose how to render a binary file | |
|
1818 | """ | |
|
1819 | filename = file_obj.name | |
|
1820 | ||
|
1821 | # images | |
|
1822 | for ext in ['*.png', '*.jpg', '*.ico', '*.gif']: | |
|
1823 | if fnmatch.fnmatch(filename, pat=ext): | |
|
1824 | alt = filename | |
|
1825 | src = url('files_raw_home', repo_name=repo_name, | |
|
1826 | revision=file_obj.commit.raw_id, f_path=file_obj.path) | |
|
1827 | return literal('<img class="rendered-binary" alt="{}" src="{}">'.format(alt, src)) | |
|
1828 | ||
|
1829 | ||
|
1815 | 1830 | def renderer_from_filename(filename, exclude=None): |
|
1816 | 1831 | """ |
|
1817 | choose a renderer based on filename | |
|
1832 | choose a renderer based on filename, this works only for text based files | |
|
1818 | 1833 | """ |
|
1819 | 1834 | |
|
1820 | 1835 | # ipython |
@@ -199,7 +199,6 b' div.diffblock {' | |||
|
199 | 199 | // BEGIN CODE-BODY STYLES |
|
200 | 200 | |
|
201 | 201 | .code-body { |
|
202 | background: white; | |
|
203 | 202 | padding: 0; |
|
204 | 203 | background-color: #ffffff; |
|
205 | 204 | position: relative; |
@@ -491,6 +490,11 b' div.codeblock {' | |||
|
491 | 490 | // to have the intended size and to scroll. Should be simplified. |
|
492 | 491 | width: 100%; |
|
493 | 492 | overflow-x: auto; |
|
493 | ||
|
494 | img.rendered-binary { | |
|
495 | height: auto; | |
|
496 | width: 100%; | |
|
497 | } | |
|
494 | 498 | } |
|
495 | 499 | } |
|
496 | 500 |
@@ -57,9 +57,14 b'' | |||
|
57 | 57 | <div id="file_history_container"></div> |
|
58 | 58 | <div class="code-body"> |
|
59 | 59 | %if c.file.is_binary: |
|
60 | <% rendered_binary = h.render_binary(c.repo_name, c.file)%> | |
|
61 | % if rendered_binary: | |
|
62 | ${rendered_binary} | |
|
63 | % else: | |
|
60 | 64 | <div> |
|
61 | 65 | ${_('Binary file (%s)') % c.file.mimetype} |
|
62 | 66 | </div> |
|
67 | % endif | |
|
63 | 68 | %else: |
|
64 | 69 | % if c.file.size < c.cut_off_limit: |
|
65 | 70 | %if c.renderer and not c.annotate: |
General Comments 0
You need to be logged in to leave comments.
Login now