### codetube
    Copyright (C) 2011 payload payload@lavabit.com
    Copyright (C) 2011 dodo dodo.the.last@gmail.com

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Affero General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Affero General Public License for more details.

    You should have received a copy of the GNU Affero General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>
###

unless @static
    coffeescript ->
        do require './trees'

table id: 'trees', class: 'tree', ->
    tr class: 'headline', ->
        th class: 'pre' , -> '&nbsp;'
        th class: 'name', -> @_("name")
        th class: 'date', -> @_("date")
        th class: 'size', -> @_("size")
        unless @small_tree
            th class: 'sha' , -> @_("sha")
            th class: 'message', -> @_("message")
            th class: 'author' , -> @_("author")
        th class: 'title', -> @_("tree")
    tr class: 'spaceline'
    unless @static
        tr class: 'progressbar', ->
            th -> '&nbsp;'
            th -> partial 'inc/loadingbar'
    text @lift 'tree', @partial('inc/loadingspin'), compile ->
        { basename, date, size, sha_href, sha, short_msg,
          author, filetype, href } = this
        type_img =
            src: '/.static/img/'+filetype+'.png'
            width: '16px'
            height: '16px'
        sha = sha?[..7]
        size = "#{size[...-3]}K" if +size > 1000
        href ?= ""
        tr class: 'file', ->
            td class: 'type', -> img type_img
            td class: 'name', ->
                a { href }, -> basename
                text @spinner
            td class: 'date format-date ago', -> date
            td class: 'size', -> size
            td class: 'sha'+[' last'][+!@small_tree], ->
                if sha_href then (a { sha_href }, -> sha) else sha
            unless @small_tree
                td class: 'message', -> short_msg
                td class: 'author last', ->
                    if author
                        a href: author.href, -> author.name
                    else
                        '&nbsp;'

