# HG changeset patch # User Martin Vium # Date 2013-11-12 11:10:38 # Node ID 47e54cf3047bcb6ecfcc8ce3e0e206ca8d4e5452 # Parent a1aa34845e9455c61aa0467051a7c0cd0e19d3a8 files: preview of images diff --git a/kallithea/lib/vcs/nodes.py b/kallithea/lib/vcs/nodes.py --- a/kallithea/lib/vcs/nodes.py +++ b/kallithea/lib/vcs/nodes.py @@ -422,6 +422,14 @@ class FileNode(Node): _bin = '\0' in self._get_content() return _bin + def is_browser_compatible_image(self): + return self.mimetype in [ + "image/gif", + "image/jpeg", + "image/png", + "image/bmp" + ] + @LazyProperty def extension(self): """Returns filenode extension""" diff --git a/kallithea/public/css/style.css b/kallithea/public/css/style.css --- a/kallithea/public/css/style.css +++ b/kallithea/public/css/style.css @@ -5122,6 +5122,12 @@ div.comment:target>.comment-wrapp { margin: -2px; } +.img-preview { + max-width: 100%; + height: auto; + margin: 5px; +} + div.prev-next-comment div.prev-comment, div.prev-next-comment div.next-comment { display: inline-block; diff --git a/kallithea/templates/files/files_source.html b/kallithea/templates/files/files_source.html --- a/kallithea/templates/files/files_source.html +++ b/kallithea/templates/files/files_source.html @@ -56,12 +56,14 @@
${h.urlify_commit(c.file_changeset.message,c.repo_name)}
- %if c.file.is_binary: -
- ${_('Binary file (%s)') % c.file.mimetype} -
- %else: - % if c.file.size < c.cut_off_limit: + %if c.file.is_browser_compatible_image(): + + %elif c.file.is_binary: +
+ ${_('Binary file (%s)') % c.file.mimetype} +
+ %else: + %if c.file.size < c.cut_off_limit: %if c.annotate: ${h.pygmentize_annotation(c.repo_name,c.file,linenos=True,anchorlinenos=True,lineanchors='L',cssclass="code-highlight")} %else: @@ -71,7 +73,7 @@ ${_('File is too big to display')} ${h.link_to(_('Show as raw'), h.url('files_raw_home',repo_name=c.repo_name,revision=c.file_changeset.raw_id,f_path=c.f_path))} %endif - %endif + %endif