{% load static wagtailuserbar wagtailcore_tags wagtailsettings_tags wagtailimages_tags django_cos_tags wagtailaccessibility_tags %}
{% get_settings %}
{% tota11y %}

<!DOCTYPE html>
<html prefix="og: http://ogp.me/ns#">
  <head>
        {% block tracking %}
        {% if settings.django_cos.AnalyticsSettings.ga_tracking_id %}
            <!-- Global site tag (gtag.js) - Google Analytics -->
            <script async src="https://www.googletagmanager.com/gtag/js?id={{settings.django_cos.AnalyticsSettings.ga_tracking_id}}"></script>
            <script>
              window.dataLayer = window.dataLayer || [];
              function gtag(){dataLayer.push(arguments);}
              gtag('js', new Date());

              gtag('config', '{{settings.django_cos.AnalyticsSettings.ga_tracking_id}}');
            </script>
        {% endif %}
        {% endblock %}

        <meta charset="utf-8" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

        {# HTML SEO #}
        {% block html_seo_base %}
        <title>{% block title %}{% if self.seo_title %}{{ self.seo_title }}{% else %}{{ self.title }}{% endif %}{% endblock %}{% block title_suffix %}{% if not self.seo_title %} - {{request.site.site_name}}{% endif %}{% endblock %}</title>
        <meta name="description" content="{% block description %}{% if self.search_description %}{{ self.search_description }}{% endif %}{% endblock %}" />
        <link rel="canonical" href="{% block canonical %}{{self.get_full_url}}{% endblock %}">
        {% endblock %}
        {% block html_seo_extra %}{% endblock %}

        {# Open Graph SEO #}
        {% if settings.django_cos.SeoSettings.og_meta %}
            {% block og_seo_base %}
            <meta property="og:title" content="{% block og_title %}{% if self.seo_title %}{{self.seo_title}}{% else %}{{self.title}}{% endif %}{% endblock %}" />
            <meta property="og:description" content="{% block og_description %}{% if self.search_description %}{{ self.search_description }}{% endif %}{% endblock %}" />
            <meta property="og:site_name" content="{% block og_site_name %}{{self.get_site.site_name}}{% endblock %}" />
            <meta property="og:type" content="{% block og_type %}website{% endblock %}" />
            <meta property="og:url" content="{% block og_url %}{{self.get_full_url}}{% endblock %}" />
            <meta property="og:image" content="{% block og_image %}
                {% if self.og_image %}
                    {% image self.og_image original as og_logo %}
                    {{og_logo.url}}
                {% elif self.cover_image %}
                    {% image self.cover_image original as og_logo %}
                    {{og_logo.url}}
                {% elif settings.django_cos.LayoutSettings.logo %}
                    {% image settings.django_cos.LayoutSettings.logo original as og_logo %}
                    {{og_logo.url}}
                {% endif %}
                {% endblock %}" />
            {% endblock %}
            {% block og_seo_extra %}{% endblock %}
        {% endif %}

        {# Twitter SEO #}
        {% if settings.django_cos.SeoSettings.twitter_meta %}
            {% block twitter_seo_base %}
            <meta name="twitter:card" content="{% block twitter_card %}summary{% endblock %}" />
            {% if settings.django_cos.SocialMediaSettings.twitter %}
            <meta name="twitter:site" content="{% block twitter_site %}@{{settings.django_cos.SocialMediaSettings.twitter_handle}}{% endblock %}" />
            {% endif %}
            {% endblock %}
            {% block twitter_seo_extra %}{% endblock %}
        {% endif %}

        {% block frontend_assets %}
            {% if settings.django_cos.LayoutSettings.frontend_theme %}
            <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/4.1.3/{{settings.django_cos.LayoutSettings.frontend_theme}}/bootstrap.min.css" />
            {% else %}
            <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha256-eSi1q2PG6J7g7ib17yAaWMcrr5GrtohYChqibrV7PBE=" crossorigin="anonymous" />
            {% endif %}
        {% endblock %}

        {% block django_cos_assets %}
        <link rel="stylesheet" type="text/css" href="{% static 'css/django-cos-front.css' %}">
        {% endblock %}

        {% block custom_assets %}
            <link rel="stylesheet" type="text/css" href="{% static 'css/custom.css' %}">
        {% endblock %}

        {% block favicon %}
            {% if settings.django_cos.LayoutSettings.favicon %}
                {% image settings.django_cos.LayoutSettings.favicon fill-128x128 format-png as favicon %}
                <link rel="icon" type="image/png" href="{{favicon.url}}" />
            {% endif %}
        {% endblock %}

        {% block extra_head %}{% endblock %}
    </head>

    <body class="django_cos-{{page.content_type.model}} {% if page.get_parent %}parent-page-{{page.get_parent.id}}{% endif %} {% block body_class %}{% endblock %}" id="page-{{page.id}}">

        {% wagtailuserbar %}

        {% block ada_skip %}
            {% if settings.django_cos.ADASettings.skip_navigation %}
                <a href='#content' title='Skip Navigation'>Skip Navigation</a>
            {% endif %}
        {% endblock %}

        {% block navbar %}{% endblock %}

        <div id="content">
            {% block content %}

                {% block content_pre_body %}{% endblock %}

                {% block content_body %}
                {% include_block page.body with settings=settings %}
                {% endblock %}

                {% block content_post_body %}{% endblock %}

            {% endblock %}

            {% block index_content %}
            {% if page.index_show_subpages %}
                <ul>
                {% for child in index_paginated %}
                    <li><a href="{{child.url}}">{{child.title}}</a></li>
                {% endfor %}
                </ul>
                {% include "django_cos/includes/pagination.html" with items=index_paginated %}
            {% endif %}
            {% endblock %}
        </div>

        <div id="content-walls">
            {% block content_walls %}
                {% for content_wall in content_walls %}
                        {% include_block content_wall with settings=settings %}
                {% endfor %}
            {% endblock %}
        </div>

        {% block footer %}{% endblock %}

        {% block required_scripts %}
        <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
        {% endblock %}

        {% block frontend_scripts %}
        <script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha256-VsEqElsCHSGmnmHXGQzvoWjWwoznFSZc6hs7ARLRacQ=" crossorigin="anonymous"></script>
        {% endblock %}

        {% block django_cos_scripts %}
        <script type="text/javascript" src="{% static 'js/django-cos-front.js' %}"></script>
        {% endblock %}

        {% block custom_scripts %}
        <script type="text/javascript" src="{% static 'js/custom.js' %}"></script>
        {% endblock %}

        {# Structured data JSON-LD #}
        {% if settings.django_cos.SeoSettings.struct_meta %}
            {% block struct_seo_base %}
                {% if self.struct_org_type %}
                <script type="application/ld+json">
                    {% include "django_cos/includes/struct_data_org.json" with page=self %}
                </script>
                {% endif %}
            {% endblock %}
            {% block struct_seo_extra %}{% endblock %}
        {% endif %}
    </body>
</html>
