{#
this template customizes all pages (classic notebook, not jupyterlab) served by the single-user server

It makes the following modifications:

- add jupyterhub control panel link to the header
- update logo url to jupyterhub
- remove `?redirects` url param that may be added by jupyterhub
#}
{% extends "templates/page.html" %}
{% block header_buttons %}
  {{ super() }}
  <span>
    <a href="{{ hub_control_panel_url }}"
       id="jupyterhub-control-panel-link"
       class="btn btn-default btn-sm navbar-btn pull-right"
       style="margin-right: 4px;
              margin-left: 2px">Control Panel</a>
  </span>
{% endblock header_buttons %}
{% block logo %}
  <img src="{{ logo_url }}" alt="Jupyter Notebook" />
{% endblock logo %}
{% block script %}
  {{ super() }}
  <script type="text/javascript">
    function _remove_redirects_param() {
      // remove ?redirects= param from URL so that
      // successful page loads don't increment the redirect loop counter
      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] === "redirects") {
          // 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_redirects_param();
  </script>
{% endblock script %}
