Show More
@@ -1617,18 +1617,19 b' def render_binary(repo_name, file_obj):' | |||||
1617 | Choose how to render a binary file |
|
1617 | Choose how to render a binary file | |
1618 | """ |
|
1618 | """ | |
1619 |
|
1619 | |||
|
1620 | # unicode | |||
1620 | filename = file_obj.name |
|
1621 | filename = file_obj.name | |
1621 |
|
1622 | |||
1622 | # images |
|
1623 | # images | |
1623 | for ext in ['*.png', '*.jpg', '*.ico', '*.gif']: |
|
1624 | for ext in ['*.png', '*.jpeg', '*.jpg', '*.ico', '*.gif']: | |
1624 | if fnmatch.fnmatch(filename, pat=ext): |
|
1625 | if fnmatch.fnmatch(filename, pat=ext): | |
1625 | alt = escape(filename) |
|
|||
1626 | src = route_path( |
|
1626 | src = route_path( | |
1627 | 'repo_file_raw', repo_name=repo_name, |
|
1627 | 'repo_file_raw', repo_name=repo_name, | |
1628 | commit_id=file_obj.commit.raw_id, |
|
1628 | commit_id=file_obj.commit.raw_id, | |
1629 | f_path=file_obj.path) |
|
1629 | f_path=file_obj.path) | |
|
1630 | ||||
1630 | return literal( |
|
1631 | return literal( | |
1631 |
'<img class="rendered-binary" alt=" |
|
1632 | '<img class="rendered-binary" alt="rendered-image" src="{}">'.format(src)) | |
1632 |
|
1633 | |||
1633 |
|
1634 | |||
1634 | def renderer_from_filename(filename, exclude=None): |
|
1635 | def renderer_from_filename(filename, exclude=None): |
@@ -500,7 +500,7 b' div.codeblock {' | |||||
500 |
|
500 | |||
501 | img.rendered-binary { |
|
501 | img.rendered-binary { | |
502 | height: auto; |
|
502 | height: auto; | |
503 |
width: |
|
503 | width: auto; | |
504 | } |
|
504 | } | |
505 |
|
505 | |||
506 | .markdown-block { |
|
506 | .markdown-block { |
@@ -115,7 +115,9 b'' | |||||
115 | %if c.file.is_binary: |
|
115 | %if c.file.is_binary: | |
116 | <% rendered_binary = h.render_binary(c.repo_name, c.file)%> |
|
116 | <% rendered_binary = h.render_binary(c.repo_name, c.file)%> | |
117 | % if rendered_binary: |
|
117 | % if rendered_binary: | |
|
118 | <div class="text-center"> | |||
118 | ${rendered_binary} |
|
119 | ${rendered_binary} | |
|
120 | </div> | |||
119 | % else: |
|
121 | % else: | |
120 | <div> |
|
122 | <div> | |
121 | ${_('Binary file ({})').format(c.file.mimetype)} |
|
123 | ${_('Binary file ({})').format(c.file.mimetype)} |
General Comments 0
You need to be logged in to leave comments.
Login now