text: doctype html
  html(lang="zh-CN")
    head
      meta(charset="UTF-8")
      meta(name="viewport", content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no")
      link(type="image/x-icon", rel="icon", href="/img/favicon32.ico")
      title= site.name + '后台管理'
      //- 根据 grunt build 之后的结果引入 css 文件
      each file in assets.css
        link(href="#{staticDomain}/css/#{file}", rel="stylesheet")
    body#app
      div#container
        div(role="navigation")#header
          div.pure-menu.pure-menu-open.pure-menu-fixed.pure-menu-horizontal
            a(href="/admin").pure-menu-heading
              if site.logo
                img(src!="#{site.logo}", title="#{site.title}").img-responsive
              else
                h1 #{site.name}
            ul.nav
              li(class=(path === '/admin') ? "pure-menu-selected" : "")
                a(href="/admin") DashBorad
              li(class=(path === '/admin/sections') ? "pure-menu-selected" : "")
                a(href="/admin/sections") 节点组管理
              li(class=(path === '/admin/tags') ? "pure-menu-selected" : "")
                a(href="/admin/tags") 节点管理
              li(class=(path === '/admin/users') ? "pure-menu-selected" : "")
                a(href="/admin/users") 用户管理
              li(class=(path === '/admin/topics') ? "pure-menu-selected" : "")
                a(href="/admin/topics") 话题管理
              li(class=(path === '/admin/pages') ? "pure-menu-selected" : "")
                a(href="/admin/pages") 页面管理
            button(type="button").nav-toggle
              span.icon-bar
              span.icon-bar
              span.icon-bar
            if isAuthenticated
              div.profile.logged
                span.info
                  a(href="/user/#{currentUser.username}").gravatar
                    img(src!=gravatar(currentUser.emailHash)).img-responsive
                  a(href="/user/#{currentUser.username}").username: strong #{currentUser.nickname}
                  ul
                    li: a(href="#", rel="nofollow").logout
                      i.fa.fa-sign-out
                      | 退出
            div.nav-collapse
              ul
                li(class=(path === '/admin') ? "selected" : "")
                    a(href="/admin") DashBorad
                  li(class=(path === '/admin/sections') ? "selected" : "")
                    a(href="/admin/sections") 节点组管理
                  li(class=(path === '/admin/tags') ? "selected" : "")
                    a(href="/admin/tags") 节点管理
                  li(class=(path === '/admin/users') ? "selected" : "")
                    a(href="/admin/users") 用户管理
                  li(class=(path === '/admin/topics') ? "selected" : "")
                    a(href="/admin/topics") 话题管理
                  li(class=(path === '/admin/pages') ? "selected" : "")
                    a(href="/admin/pages") 页面管理
                if isAuthenticated
                  li(class=(path === '/user/#{currentUser.username}') ? "selected" : "")
                    a(href="/user/#{currentUser.username}") #{currentUser.nickname}
                  li: a(href="#", rel="nofollow").logout 退出
        div#main
          if err && err.global
            div.alert-global
              ul
                each error in err.errors
                  li(class=['alert', 'alert-' + (err.level || 'danger')]) #{error.message}
          block main
  
      //- 根据 grunt build 之后的结果引入 js 文件
      each file in (assets.adminjs || assets.js)
        script(src="#{staticDomain}/js/#{file}")
      //- 设置 ajax 模式下的 csrf
      script(type="text/javascript").
        $.ajaxSetup({
          dataType: 'json'
        });
        $(document).ajaxSend(function(e, xhr) {
          xhr.setRequestHeader('X-CSRF-Token', '#{csrfToken}');
        });
      block script
      //- 初始化前端模块
      script(type="text/javascript").
        ;(function() {
          ND.loadModule({
            name: 'App',
            el: '#app',
            children: ND.moduleTree.get()
          }, function(module) {
            ND.app = module;
          });
        }());
      //- 编辑器模板
      include ../tmpl/editor_wrap
      //- 全屏编辑器模板
      include ../tmpl/zenarea
      //- 前端警告框模板
      include ../tmpl/alert_danger
      //- 前端确认框模板
      include ../tmpl/confirm_dialog
  