Changeset - 47e54cf3047b
[Not reviewed]
default
0 3 0
Martin Vium - 12 years ago 2013-11-12 11:10:38
martinv@unity3d.com
files: preview of images
3 files changed with 23 insertions and 7 deletions:
0 comments (0 inline, 0 general)
kallithea/lib/vcs/nodes.py
Show inline comments
 
@@ -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"""
kallithea/public/css/style.css
Show inline comments
 
@@ -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;
kallithea/templates/files/files_source.html
Show inline comments
 
@@ -56,12 +56,14 @@
 
        <div class="commit">${h.urlify_commit(c.file_changeset.message,c.repo_name)}</div>
 
    </div>
 
    <div class="code-body">
 
       %if c.file.is_binary:
 
           <div style="padding:5px">
 
           ${_('Binary file (%s)') % c.file.mimetype}
 
           </div>
 
       %else:
 
        % if c.file.size < c.cut_off_limit:
 
      %if c.file.is_browser_compatible_image():
 
        <img src="${h.url('files_raw_home',repo_name=c.repo_name,revision=c.file_changeset.raw_id,f_path=c.f_path)}" class="img-preview"/>
 
      %elif c.file.is_binary:
 
        <div style="padding:5px">
 
          ${_('Binary file (%s)') % c.file.mimetype}
 
        </div>
 
      %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
 
    </div>
 
</div>
 

	
0 comments (0 inline, 0 general)