{% load staticfiles %}
{% load mezzanine_api %}
{% spaceless %}
<!DOCTYPE html>
<html>
<head>
  <meta name="viewport" content="width=device-width initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <title>
    Mezzanine API Resource Documentation
  </title>
  <link href='//fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'/>
  <link href='{% static "rest_framework_swagger/css/highlight.default.css" %}' media='screen' rel='stylesheet' type='text/css'/>
  <link href='{% static "rest_framework_swagger/css/atelier-dune.light.css" %}' media='screen' rel='stylesheet' type='text/css'/>
  <link href='{% static "rest_framework_swagger/css/rest_framework_swagger.css" %}' media='screen' rel='stylesheet' type='text/css'/>
  <link href='{% static "rest_framework_swagger/css/screen.css" %}' media='screen' rel='stylesheet' type='text/css'/>
  <style media="screen" type="text/css">
      #header {
          background-color: #BD362F;
      }
      #header a#logo {
          background: transparent;
          padding: 20px 0px 20px 00px;
      }
      #django-rest-swagger  {
          background: #EE5F5B;
      }
      #header form#api_selector .input a#explore {
          background: #EE5F5B;
      }
      .swagger-ui-wrap {
          text-align: left;
      }
  </style>
</head>

<body>
  <div id='header'>
    <div class="swagger-ui-wrap">
      <a id="logo" href="http://gcushen.github.io/mezzanine-api" target="_blank">Mezzanine API</a>
      <form id='api_selector'>
        <!--<div class='input icon-btn'>
          <img id="show-wordnik-dev-icon" src="{% static 'rest_framework_swagger/images/wordnik_api.png' %}" title="Show Wordnik Developer Apis">
        </div>-->
        <div class='input' style="visibility: hidden"><input placeholder="http://example.com/api" id="input_baseUrl" name="baseUrl" type="text"/></div>
        <div class='input'><input placeholder="my oauth access token" id="input_apiKey" name="apiKey" type="text"/></div>
        <div class='input'><a id="explore" href="#">Authenticate</a></div>
      </form>
    </div>
  </div>

  <div id="django-rest-swagger">
    <div class="swagger-ui-wrap">
      You have version <b>{% get_mezzanine_api_version %}</b>. <a href="https://pypi.python.org/pypi/mezzanine-api" target="_blank">Check for updates?</a>
    </div>
  </div>

  <div id="message-bar" class="swagger-ui-wrap">
    &nbsp;
  </div>
  <div id="swagger-ui-container" class="swagger-ui-wrap">

  </div>

  <script>
    window.static_url = '{{STATIC_URL}}';
  </script>
  <script src="{% static 'rest_framework_swagger/lib/shred.bundle.js' %}" type="text/javascript"></script>
  <script src='{% static "rest_framework_swagger/lib/jquery-1.8.0.min.js" %}' type='text/javascript'></script>
  <script src='{% static "rest_framework_swagger/lib/jquery.slideto.min.js" %}' type='text/javascript'></script>
  <script src='{% static "rest_framework_swagger/lib/jquery.wiggle.min.js" %}' type='text/javascript'></script>
  <script src='{% static "rest_framework_swagger/lib/jquery.ba-bbq.min.js" %}' type='text/javascript'></script>
  <script src='{% static "rest_framework_swagger/lib/jquery.cookie.js" %}' type='text/javascript'></script>
  <script src='{% static "rest_framework_swagger/lib/handlebars-1.0.0.js" %}' type='text/javascript'></script>
  <script src='{% static "rest_framework_swagger/lib/underscore-min.js" %}' type='text/javascript'></script>
  <script src='{% static "rest_framework_swagger/lib/backbone-min.js" %}' type='text/javascript'></script>
  <script src='{% static "rest_framework_swagger/lib/swagger.js" %}' type='text/javascript'></script>
  <script src='{% static "rest_framework_swagger/swagger-ui.min.js" %}' type='text/javascript'></script>
  <script src='{% static "rest_framework_swagger/lib/highlight.8.0.pack.js" %}' type='text/javascript'></script>
  <script type="text/javascript">
    $(function () {
      window.swaggerUi = new SwaggerUi({
      url: "{{ swagger_settings.discovery_url }}",
      apiKey: "{{ swagger_settings.api_key }}",
      dom_id: "swagger-ui-container",
      supportedSubmitMethods: {{ swagger_settings.enabled_methods }},
      onComplete: function(swaggerApi, swaggerUi){
        log("Loaded SwaggerUI")
        $('pre code').each(function(i, e) {hljs.highlightBlock(e)});
      },
      onFailure: function(data) {
        log("Unable to Load SwaggerUI");
      },
      docExpansion: "{{ swagger_settings.doc_expansion }}",
    });

    $('#input_apiKey').change(function() {
      var key = $('#input_apiKey')[0].value;
      log("key: " + key);
      if(key && key.trim() != "") {
        console.log("added key " + key);
        window.authorizations.add("key", new ApiKeyAuthorization("Authorization", "{{ swagger_settings.token_type }} " + key, "header"));
      }
    })
    {% if swagger_settings.api_key %}
      window.authorizations.add("key", new ApiKeyAuthorization("Authorization", "{{ swagger_settings.token_type }} " + "{{ swagger_settings.api_key }}", "header"));
    {% endif %}
    window.swaggerUi.load();
  });

  </script>

</body>

</html>
{% endspaceless %}
