<!DOCTYPE html>
<html>
{% block html_head %}
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <title>{% block html_title %}{{ customTitle(path) }}{% endblock %}</title>
  <meta name="description" content="">
  <meta name="author" content="">

  <meta name="viewport" content="width=device-width,initial-scale=1">

  <meta name="apple-mobile-web-app-title" content="{{ appTitle() }}">

  {% include '../widget/favicon.html' %}

  {{ customHeader() }}

  <!-- polyfills for IE11 -->
  <script>
    var userAgent = window.navigator.userAgent.toLowerCase();
    if (userAgent.indexOf('msie') != -1 || userAgent.indexOf('trident') != -1) {
      var scriptElement = document.createElement('script');
      scriptElement.src = '{{ webpack_asset("js/ie11-polyfill.js") }}';
      var headElement = document.getElementsByTagName('head')[0];
      headElement.appendChild(scriptElement);
    }
  </script>

  {{ cdnScriptTagsByGroup('basis') }}

  {% if local_config.env.MATHJAX %}
    <!-- Mathjax -->
    <script type="text/x-mathjax-config" async>
      MathJax.Hub.Config({
        skipStartupTypeset: true,
        extensions: ["tex2jax.js"],
        jax: ["input/TeX", "output/SVG"],
        tex2jax: {
          processEscapes: true
        },
        showMathMenu: false,
        showMathMenuMSIE: false,
        showProcessingMessages: false,
        messageStyle: "none"
      });
    </script>
    {{ cdnScriptTag('mathjax') }}
  {% endif %}

  {% if env === 'development' %}
    <script src="/dll/dll.js"></script>
    <script src="{{ webpack_asset('js/dev.js') }}" async></script>
    <!-- Browsersync -->
    <script id="__bs_script__">//<![CDATA[
      document.write("<script async src='http://HOST:3001/browser-sync/browser-sync-client.js?v=2.23.6'><\/script>".replace("HOST", location.hostname));
    //]]></script>
  {% endif %}

  <script src="{{ webpack_asset('js/vendors.js') }}" defer></script>
  <script src="{{ webpack_asset('js/commons.js') }}" defer></script>
  {% if isEnabledPlugins() %}
  <script src="{{ webpack_asset('js/plugin.js') }}" defer></script>
  {% endif %}
  {% block html_head_loading_legacy %}
  <script src="{{ webpack_asset('js/legacy.js') }}" defer></script>
  {% endblock %}
  {% block html_head_loading_app %}
  <script src="{{ webpack_asset('js/app.js') }}" defer></script>
  {% endblock %}

  <!-- styles -->
  {% block style_css_block %}
    {% if 'kibela' === layoutType() %}
      {% if env === 'development' %}
        <script src="{{ webpack_asset('styles/style.js') }}"></script>
        <script src="{{ webpack_asset('styles/theme-kibela.js') }}"></script>
      {% else %}
        <link rel="stylesheet" href="{{ webpack_asset('styles/style.css') }}">
        <link rel="stylesheet" href="{{ webpack_asset('styles/theme-kibela.css') }}">
      {% endif %}
    {% else %}
      {% if env === 'development' %}
        <script src="{{ webpack_asset('styles/style.js') }}"></script>
        <script src="{{ webpack_asset('styles/theme-' + theme() + '.js') }}"></script>
      {% else %}
        <link rel="stylesheet" href="{{ webpack_asset('styles/style.css') }}">
        <link rel="stylesheet" href="{{ webpack_asset('styles/theme-' + theme() + '.css') }}">
      {% endif %}
    {% endif %}
  {% endblock %}

  {{ cdnStyleTagsByGroup('basis') }}
  {{ cdnHighlightJsStyleTag(highlightJsStyle()) }}

  {% block html_additional_headers %}{% endblock %}

  <style>
    {{ customCss() }}
  </style>
</head>
{% endblock %}

{% block html_body %}
<body
  class="main-container content-wrapper {% block html_base_css %}{% endblock %}
      {% if !layoutType() || 'crowi' === layoutType() %}crowi{% elseif !layoutType() || 'kibela' === layoutType() %}kibela{% else %}growi{% endif %}"
  data-me="{{ user._id.toString() }}"
  data-is-admin="{{ user.admin }}"
  data-plugin-enabled="{{ isEnabledPlugins() }}"
  {% block html_base_attr %}{% endblock %}
  data-csrftoken="{{ csrf() }}"
  data-current-username="{% if user %}{{ user.username }}{% endif %}"
  data-userlang="{% if user %}{{ user.lang }}{% endif %}"
 >

<div id="wrapper">
  <!-- Navigation -->
  {% block layout_head_nav %}
  <nav class="navbar navbar-default navbar-static-top m-b-0">
    <div class="navbar-header">
      <a class="navbar-toggle hidden-sm hidden-md hidden-lg " href="javascript:void(0)" data-toggle="collapse" data-target=".navbar-collapse">
        <i class="ti-menu"></i>
      </a>
      <div class="top-left-part">
        <a class="logo" href="/">
          <b>
            <div class="logo-mark">{% include '../widget/logo.html' %}</div>
          </b>
          <span class="hidden-xs" style="color: black">
            {% set appTitle = appTitle() %}
            {% set appTitleFontSize = getAppTitleFontSize(appTitle) %}
            <span class="logo-text">
              <svg xmlns="http://www.w3.org/2000/svg">
                <text x="0" y="{{22+appTitleFontSize/2}}" font-size="{{appTitleFontSize}}">
                  {% block title %}{{ appTitle }}{% endblock %}
                </text>
              </svg>
            </span>
          </span>
        </a>
      </div>

      <ul class="nav navbar-top-links navbar-left hidden-xs">
        <li>
          <a class="open-close hidden-xs waves-effect waves-light">
            <i class="ti-menu"></i>
          </a>
        </li>
        <li>
          {% if searchConfigured() %}
          <div class="navbar-form navbar-left search-top" role="search" id="search-top"></div>
          {% endif %}
        </li>
      </ul>

      <ul class="nav navbar-top-links navbar-right pull-right">
        {% if user and user.admin %}
        <li class="nav-item-admin">
          <a href="/admin">
            <i class="icon-settings"></i><span>{{ t('Admin') }}</span>
          </a>
        </li>
        {% endif %}

        {% if user %}
        <li class="nav-item-create-page">
          <a href="#" data-target="#create-page" data-toggle="modal" class="create-page">
            <i class="icon-pencil"></i><span>{{ t('New') }}</span>
          </a>
        </li>
        <li class="dropdown">
          <a class="dropdown-toggle waves-effect waves-light" data-toggle="dropdown">
            <img src="{{ user|picture }}" class="picture img-circle" width="25" /> <span class="user-name">{{ user.name }}</span>
          </a>
          <ul class="dropdown-menu dropdown-menu-right">
            <li><a href="/user/{{ user.username }}"><i class="icon-fw icon-home"></i>{{ t('Home') }}</a></li>
            <li><a href="/me"><i class="icon-fw icon-wrench"></i>{{ t('User Settings') }}</a></li>
            <li role="separator" class="divider"></li>
            <li><a href="/trash"><i class="icon-fw icon-trash"></i>{{ t('Deleted Pages') }}</a></li>
            <li role="separator" class="divider"></li>
            <li><a href="/logout"><i class="icon-fw icon-power"></i>{{ t('Sign out') }}</a></li>
          </ul>
          <!-- /.dropdown-messages -->
        </li>
        {% else %}
        <li id="login-user"><a href="/login">Login</a></li>
        {% endif %}
        {% if config.crowi['app:confidential'] && config.crowi['app:confidential'] != '' %}
        <li class="confidential"><a href="#">{{ config.crowi['app:confidential'] }}</a></li>
        {% endif %}
      </ul>
    </div><!-- /.navbar-header -->
  </nav>
  {% include '../modal/create_page.html' %}
  {% endblock  %} {# layout_head_nav #}

  {% block sidebar %}
  <!-- Left navbar-header -->
  <div class="navbar-default sidebar hidden-print" role="navigation">
    <div class="sidebar-nav navbar-collapse slimscrollsidebar">
      <ul class="nav" id="side-menu">
        <li class="sidebar-search hidden-sm hidden-md hidden-lg">
          {% if searchConfigured() %}
          <div class="search-sidebar" role="search" id="search-sidebar"></div>
          {% endif %}
        </li>

        <li class="tbd"><a href="#">(TBD) Create /Sidebar</a></li>
      </ul>
    </div>
  </div>
  <!-- Left navbar-header end -->
  {% endblock %}

  <!-- Page Content -->
  <div id="page-wrapper">
    {% block layout_main %}
    {% endblock %} {# layout_main #}
  </div><!-- /#page-wrapper -->

</div><!-- /#wrapper -->

{% include '../modal/shortcuts.html' %}

{% block body_end %}
{% endblock %}
</body>
{% endblock %}

<script type="application/json" id="crowi-context-hydrate">
{{ local_config|json|safe }}
</script>

{% block custom_script %}
<script>
  {{ customScript() }}
</script>
{% endblock %}

</html>
