{%- set locale = get_locale() -%}
<!doctype html>
<html lang="{{ locale.language }}">
<head>
  <meta charset="utf-8"/>
  <title>
    {%- block page_title %}{{ config.SITE_NAME }}{% endblock page_title -%}
  </title>
  <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
  <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
  <meta name="description" content=""/>
  <meta name="author" content=""/>

  {%- assets "css" %}
    <link href="{{ ASSET_URL }}" rel="stylesheet"/>
  {%- endassets %}
  {%- block css %}{%- endblock css %}

  <!-- Le fav and touch icons -->
  <link
      rel="shortcut icon"
      type="image/png"
      href="{{ config['FAVICO_URL'] | string }}"/>
  <link
      rel="apple-touch-icon"
      type="image/png"
      href="{{ config['FAVICO_URL'] | string }}"/>

  <script>
    var require = {{ app.extensions['webassets'].requirejs_config | tojson }};
  </script>

  {%- assets "js-top" %}
    <script type="text/javascript" src="{{ ASSET_URL }}"></script>
  {%- endassets %}

  {%- set sentry_url = config.get("SENTRY_SDK_URL") %}
  {%- set sentry_dsn = config.get("SENTRY_DSN") %}
  {%- if sentry_url and sentry_dsn %}
    <script src="{{ sentry_url }}" crossorigin="anonymous"></script>
    <script>
      var dsn = {{ sentry_dsn | tojson }};
      var app_name = {{ (app.name+'_front') | tojson }};
      var server_name = {{ config.get('SERVER_NAME', 'unknown') | tojson }};

      if (typeof Sentry != "undefined") {
        Sentry.init({dsn: dsn});
        Sentry.configureScope(function (scope) {
          scope.setTag("app_name", app_name);
          scope.setTag("server_name", server_name);
        });
      }
    </script>
  {%- endif %}

  {%- block top_js %}{%- endblock top_js %}
</head>

<body {%- if body_class is defined %} class="{{ body_class }}" {% endif -%}>
{%- block body %} {#- accessibility link: see
    http://getbootstrap.com/getting-started/#accessibility #}
  <a href="#content" class="sr-only">{{ _("Skip to content") }}</a>

  <!-- navbar -->
  {% include "navbar.html" %}

  <div id="content" class="container clearfix">
    <!-- breadcrumbs -->
    {% if g.breadcrumb|length > 1 %}
      <div class="row">
        <div class="col-xs-12">{% include "breadcrumbs.html" %}</div>
      </div>
    {% endif %}

    <!-- flash messages -->
    <div class="row" id="flash-messages">
      <div class="col-xs-12">{%- include "flash-messages.html" %}</div>
    </div>

    <div class="row">
      <header class="col-xs-12">
        {% block header %} {%- endblock header %}
      </header>
    </div>

    <div class="row">
      <div class="col-xs-12">
        <div class="main-block">
          {% block main %}
            <div class="content-block">
              {% block content %} {% endblock content %}
            </div>
          {%- endblock main %}
        </div>
      </div>
    </div>
  </div>

  {%- block footer %}
    <footer>
      <div class="container">
        <div class="row">
          <div class="col-xs-12">
            <hr/>
            <p class="text-right">
              <small
              >Powered by <a href="https://www.abilian.com/">Abilian</a>
              </small>
            </p>
          </div>
        </div>
      </div>
    </footer>
  {%- endblock footer %}
{%- endblock body %}

{%- assets "js" %}
  <script type="text/javascript" src="{{ ASSET_URL }}"></script>
{%- endassets %}

{%- block js %}{%- endblock js %} {# this block should be
    used to load additional libraries #}

<!-- app init -->
<script type="text/javascript">
  {%- include "abilian_init.js" %}
</script>

{#- i18n bundles #} {%- set js_i18n_bundle = "js-i18n-" + locale.language %}
{%- if js_i18n_bundle in app.extensions['webassets'] %}
  <!-- i18n -->
  {%- assets js_i18n_bundle %}
    <script type="text/javascript" src="{{ ASSET_URL }}"></script>
  {%- endassets %}
{%- endif %}

{% block locale_js %} {% endblock locale_js %}
{#- 'abilian_init.js' will load additional libraries by writing new 'script'
    tags. We put deferred JS and inline_js in a separate script tag so that the
    code is executed after thoses libraries have been loaded. #}

<script type="text/javascript">
  {% deferredJS %}{% enddeferredJS %}

  {% block inline_js %}{% endblock inline_js %}

  {#- template can also use an 'inline_js' variable #}
  {%- set inline_js = inline_js|default(None) %}
  {%- if inline_js %}
    {{ inline_js }}
  {%- endif %}
</script>

{%- if config.TRACKING_CODE %} {{ config.TRACKING_CODE | safe }} {%- endif %}
</body>
</html>
