### 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/>
###

{ owner, source } = @project
buttons = [{
    ###
    symbol: '⚗'
    text  : @_("Issues")
    href  : '#'},{
    symbol: 'W'
    text  : @_("Wiki")
    href  : '#'},{
    symbol: 'ℹ'
    text  : @_("Pages")
    href  : "/#{@project.owner.id}/#{@project.id}/pages/"},{
    ###
    symbol: '⌥'
    text  : @_("Source")
    href  : "/#{owner.id}/#{@project.id}/tree/"},{
    symbol: '±'
    text  : @_("Commits")
    href  : "/#{owner.id}/#{@project.id}/commits/"}]
if @me and @me.id == owner.id
    btn =
        symbol: '⚙'
        text  : @_("Settings")
        href  : "/#{owner.id}/#{@project.id}/.settings"
    buttons.push btn

coffeescript ->
    do require './branches'

div class: 'page', ->
    section class: 'header', ->
        div class: 'left', ->
            span class: 'by', -> " " + @_("by") + " "
            a class: 'owner', href: "/#{owner.id}", -> owner.name or owner.id
        div class: 'right', ->
            ul class: 'headerbtns', ->
                for btn in buttons
                    li class: 'item', -> partial 'inc/button', btn
                if @project.source.branches.length > 0
                    li class:'item', ->
                        div class:'headerbtn', id:'selectbranch', ->
                            form action: "#", -> fieldset ->
                                span class:'symbol', ->
                                    select name:'branch', id:'branch', ->
                                        for branch in @project.source.branches
                                            opts = value:branch
                                            if branch is @project.source.branch
                                                opts.selected = "selected"
                                            option opts, branch
                                label for:'branch', ->
                                    span class:'text', "branch"
    div class: 'sides', ->
        section class: 'left-side', ->
            if @project.source.empty
                partial "inc/empty_project"
            else if @blob
                if @blob.type == 'tree'
                    partial 'inc/tree'
                else
                    partial 'inc/blob'
            else if @diff
                partial 'inc/diff'
            else
                { commits } = @project.source
                partial "inc/commits", { commits }
        section class: 'right-side', ->
            unless @project.source.empty
                partial 'inc/tree', small_tree: yes

