<!DOCTYPE html>{# this is html5, xmlish variant #}
{% import "snippets.html" as snippets with context %}
{%- set head = snippets.head() %}
{%- set scripts = snippets.scripts() %}
{%- set stylesheets = snippets.stylesheets() %}
{%- set favicon = snippets.favicon() %}

{#- This allows child templates passing their header_search macro to the common layout (eg blog).
   If there is no header_search macro defined in child templates use the default one. #}
{%- if not header_search %}
    {%- from "utils.html" import header_search with context %}
{%- endif -%}

<html>
    <head>
        {%- block head %}
            {%- block head_meta %}
                <meta charset="utf-8">{# must be at the beginning #}
                <meta name="viewport" content="width=device-width, initial-scale=1">
                {%- if pi_refresh -%}
                    {{ '<meta http-equiv="refresh" content="%d;URL=%s">' % pi_refresh }}
                {%- endif %}
                {%- if html_head_meta %}
                    {%- for name, content in html_head_meta.items() %}
                        <meta name="{{ name }}" content="{{ content }}">
                    {%- endfor %}
                {%- endif %}
            {%- endblock -%}

            {{ head }}

            {%- block head_title %}
                <title>
                    {%- if title -%}
                        {{ title }}
                    {%- elif title_name -%}
                        {{ title_name }}
                    {%- elif headline -%}
                        {{ headline }}
                    {%- else -%}
                        {{ item_name }}
                    {%- endif %} -
                    {%- if cfg.html_pagetitle -%} {{ cfg.html_pagetitle }}{% else %} {{ cfg.sitename }}{%- endif -%}
                </title>
            {%- endblock -%}

            {%- block head_links -%}

                {%- block bootstrap_stylesheet -%}
                {%- endblock -%}

                {{ favicon }}

                {%- block theme_stylesheets %}
                    <link media="all" rel="stylesheet" href="{{ url_for('static', filename='css/normalize.css') }}">
                    <link media="all" rel="stylesheet" href="{{ url_for('static', filename='css/variables.css') }}">
                    {%- if theme_supp.variables_css() %}
                        <link media="all" rel="stylesheet" href="{{ theme_static('css/variables.css') }}">
                    {%- endif %}
                    <link media="all" rel="stylesheet" href="{{ url_for('serve.files', name='pygments', filename='css/colorful.css') }}">
                    <link media="all" rel="stylesheet" href="{{ url_for('serve.files', name='font_awesome', filename='css/all.css') }}">
                    <link media="all" rel="stylesheet" href="{{ url_for('static', filename='css/common.css') }}">
                    <link media="all" rel="stylesheet" href="{{ theme_static('css/theme.css') }}">
                    {{ stylesheets }}
                {%- endblock %}
                {%- if user.valid and user.css_url -%}
                    <link media="all" rel="stylesheet" title="{{ user.name }}'s stylesheet" href="{{ user.css_url }}">
                {%- endif -%}
                {%- if cfg.custom_css_path -%}
                    <link media="all" rel="stylesheet" href="{{ url_for('serve.files', name='wiki_local', filename='custom.css') }}">
                {%- endif -%}
            {%- endblock -%}
        {%- endblock %}
    </head>

    <body{% if body_onload %} onload="{{ body_onload }}"{% endif %} lang="{{ theme_supp.ui_lang }}" dir="{{ theme_supp.ui_dir }}">
        {%- block layout %}
            <h1>Extend this block only if you want to change layout. If you want to put content, extend layout.html and use placeholders item and content.</h1>
        {%- endblock %}

        <div id="moin-options-for-javascript">
            <input id="moin-wiki-root" value="{{ theme_supp.wiki_root }}" >
            {% block options_for_javascript %}
                {#- implement this block to pass server side options to client side javascript. -#}
            {%- endblock %}
        </div>

        {%- block body_scripts %}
            <script src="{{ url_for('serve.files', name='jquery', filename='jquery.min.js') }}"></script>
            <script src="{{ url_for('static', filename='js/jquery.i18n.min.js') }}"></script>
            <script src="{{ url_for('frontend.template', filename='dictionary.js') }}"></script>
            <script src="{{ url_for('serve.files', name='autosize', filename='jquery.autosize-min.js') }}"></script>
            <script src="{{ url_for('serve.files', name='jquery_tablesorter', filename='jquery.tablesorter.js') }}"></script>
            <script src="{{ url_for('static', filename='js/common.js') }}"></script>
            {{- scripts }}
        {%- endblock %}

    </body>
</html>
