<!DOCTYPE HTML>
<html>

<head>
    <meta charset="utf-8">

    <title>{% block title %}Voila{% endblock %}</title>
    {% block favicon %}<link id="favicon" rel="shortcut icon" type="image/x-icon" href="{{static_url("base/images/favicon.ico") }}">{% endblock %}
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    
    {% block stylesheet %}
    <!-- <link rel="stylesheet" href="{{ static_url("style/style.min.css") }}" type="text/css"/> -->
    {% endblock %}
    <!-- <link rel="stylesheet" href="{{ base_url }}custom/custom.css" type="text/css" /> -->
    <link rel="stylesheet" href="https://unpkg.com/font-awesome@4.5.0/css/font-awesome.min.css" type="text/css" />
    {% block meta %}
    {% endblock %}

</head>

<body class="{% block bodyclasses %}{% endblock %}"
 {% block params %}
  {% if logged_in and token %}
    data-jupyter-api-token="{{token | urlencode}}"
  {% endif %}
 {% endblock params %}
dir="ltr">

<noscript>
    <div id='noscript'>
      {% trans %}Voila requires JavaScript.{% endtrans %}<br>
      {% trans %}Please enable it to proceed. {% endtrans %}
  </div>
</noscript>

<div id="header">
  <div id="header-container" class="container">
  {% block login_widget %}

    <span id="login_widget">
      {% if logged_in %}
        <button id="logout" class="btn btn-sm navbar-btn">{% trans %}Logout{% endtrans %}</button>
      {% elif login_available and not logged_in %}
        <button id="login" class="btn btn-sm navbar-btn">{% trans %}Login{% endtrans %}</button>
      {% endif %}
    </span>

  {% endblock %}
  
  </div>
  <div class="header-bar"></div>

  {% block header %}
  {% endblock %}
</div>

<div id="site">
{% block site %}
{% endblock %}
</div>

{% block after_site %}
{% endblock %}

{% block script %}
{% endblock %}

<script type='text/javascript'>
  function _remove_token_from_url() {
    if (window.location.search.length <= 1) {
      return;
    }
    var search_parameters = window.location.search.slice(1).split('&');
    for (var i = 0; i < search_parameters.length; i++) {
      if (search_parameters[i].split('=')[0] === 'token') {
        // remote token from search parameters
        search_parameters.splice(i, 1);
        var new_search = '';
        if (search_parameters.length) {
          new_search = '?' + search_parameters.join('&');
        }
        var new_url = window.location.origin + 
                      window.location.pathname + 
                      new_search + 
                      window.location.hash;
        window.history.replaceState({}, "", new_url);
        return;
      }
    }
  }
  _remove_token_from_url();
</script>
</body>

</html>
