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

if @me
    user_links = do =>
        userpage = class: "userpage", href: "/"+@me.id, text: @me.id
        logout   = class: "logout"  , href: "/.logout", text: @_("logout")
        [ userpage, logout ]
else
    user_links = do =>
        login    = class: "login"   , href: "/.login"   , text: @_("login")
        register = class: "register", href: "/.register", text: @_("register")
        [ register, login ]

global_links = do =>
    users    = class: 'users'   , href: '/.users'   , text: @_ 'users'
    projects = class: 'projects', href: '/.projects', text: @_ 'projects'
    [ users, projects ]

list_link = (link) =>
    li class: link.class, -> a href: link.href, -> link.text

div class: 'head', -> div class: 'table', ->
    div class: 'left', -> '&nbsp;'
    div class: 'center', -> div class: 'title', ->
        h1 -> a href: @project.href, -> @project.name
        span class: 'descline', -> @project.descline
        for name, url of @project.gitline
            attrs =
                class: "gitline "+name
                type: 'text'
                readonly: 'true'
                value: url
            input attrs
    div class: 'right', -> nav ->
        ul class: 'global-links', ->
            list_link link for link in global_links
        div class: 'user-links', -> ul ->
            list_link link for link in user_links
div class: 'messages', -> ul ->
    text '&nbsp;'
    for k, msgs of @flash
        for msg in msgs
            li -> span class: k, -> msg

