extends ../layout

block meta
    meta(name="keywords",content="#{thread.name},#{site.name}")
    meta(name="description",content="#{thread.content.substr(0,16)}")
    link(rel='stylesheet',href="/stylesheets/github.css")

block css
    link(rel='stylesheet', href='/stylesheets/thread.css')

block title
    | #{thread.name}  

block banner

block content
      .board.single-thread
        .thread.clearfix
            .row
                .col-lg-1
                    - if (thread.lz.avatar)
                        .avatar
                            a(href="/member/#{thread.lz.id}")
                                img(src="#{thread.lz.avatar}")
                .col-lg-11
                    .contents.clearfix
                        h4.title #{thread.name}
                        .meta.clearfix
                            span.name 
                                a(href="/member/#{thread.lz.id}") #{thread.lz.nickname ? thread.lz.nickname : thread.lz.duoshuo.user_id}
                            span.cat
                                i.icon-chevron-right
                                a(href="/board/#{thread.board.url}") #{thread.board.name}
                            i.icon-time
                            != moment(thread.pubdate).fromNow()
                            - if ((user && user._id == thread.lz._id) || (user && user.type == 'admin')) 
                                a(href="/thread/#{thread.id}/edit").edit
                                    i.icon-edit
                                    |编辑
                        .entry!= marked(thread.content)
                        - if (thread.media && thread.media.length > 0)
                            .attachements
                                - each file in thread.media
                                    - var size = (file.meta.size / 1024 / 1024).toString().substr(0,4)
                                    .attachement.clearfix
                                        - if (file.type == 'image/jpeg' || file.type == 'image/png' || file.type == 'image/gif')
                                            .thumbnail.clearfix
                                                img(src="#{file.url}").thumb.pull-left
                                        - else
                                            i.icon-paperclip.other-files.pull-left.thumbnail
                                        a(href="/medias/#{file.id}",target='_blank')
                                            span.name 
                                                |#{file.name}
                                        span.download 
                                            i.icon-circle-arrow-down
                                            | #{file.count.download} 下载 
                                        span.share-count
                                            i.icon-archive
                                            | #{size} MB
        .board-meta
            i.icon-eye-open
            span.views #{thread.views} 阅读
            i.icon-comment
            span.num.ds-thread-count(data-thread-key="#{thread.id}",data-count-type="comments")
                | 加载中...
            i.icon-weibo
            span.num.ds-thread-count(data-thread-key="#{thread.id}",data-count-type="weibo_reposts")
                | 加载中...
            i.icon-tumblr
            span.num.ds-thread-count(data-thread-key="#{thread.id}",data-count-type="qqt_reposts")
                | 加载中...
            - if ((user && user._id == thread.lz._id) || (user && user.type == 'admin'))
                a(href="/thread/#{thread.id}/edit").edit
                    i.icon-edit
                    |编辑
        .comment-board
            include ../comment.jade

block sidebar
    include ../signin
    include ../widgets/search
    include ../widgets/ds-top-threads