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
 
@@ -419,12 +419,20 @@ class FileNode(Node):
 
        """
 
        Returns True if file has binary content.
 
        """
 
        _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"""
 
        return self.name.split('.')[-1]
 

	
 
    @property
kallithea/public/css/style.css
Show inline comments
 
@@ -5119,12 +5119,18 @@ div.comment:target>.comment-wrapp {
 

	
 
.lineno:target a {
 
    border: solid 2px #ee0 !important;
 
    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;
 
    min-width: 150px;
 
    margin: 3px 6px;
 
}
kallithea/templates/files/files_source.html
Show inline comments
 
@@ -53,28 +53,30 @@
 
            </div>
 
            <div title="${c.file_changeset.author}" class="user">${h.person(c.file_changeset.author)}</div>
 
        </div>
 
        <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:
 
              ${h.pygmentize(c.file,linenos=True,anchorlinenos=True,lineanchors='L',cssclass="code-highlight")}
 
            %endif
 
        %else:
 
            ${_('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>
 

	
 
<script>
 
    $(document).ready(function(){
 
        // fake html5 history state
0 comments (0 inline, 0 general)