{% extends "_base_course.html" %}

{% block title %}
    {%- if not is_canonical_lesson -%}
        {{ course.title }}: {% endif -%}
    {{ page.title }}
{%- endblock title %}

{% block style %}
    {% if page.css %}
        {{ page.css }}
    {% endif %}
{% endblock style %}

{% block extra_links %}
    {% if canonical_url is defined and canonical_url %}<link rel="canonical" href="{{ canonical_url }}" />{% endif %}
{% endblock %}

{% block breadcrumbs %}
{# Only used if course is provided #}
> <a href="{{ course.get_url() }}">{{ course.title }}</a>
{% if page.lesson.material %}
> <a href="{{ page.lesson.material.session.get_url() }}">{{ page.lesson.material.session.title }}</a>
{% endif %}
> <a href="{{ page.lesson.get_url() }}">{{ page.lesson.title }}</a>
{% if page.slug != 'index' %}
    {% if page.subtitle %}
        > {{ page.subtitle }}
    {% else %}
        > {{ page.title }}
    {% endif %}
{% endif %}
{% endblock %}

{% block warning_msg %}
  {% if error_in_fork|default(false) %}
    {% include "_using_default_page.html" %}
  {% endif %}
{% endblock %}

{% block course_content %}
    {% if solution|default(None) is not none %}
        <h1>{{ page.title }} – Řešení [{{ solution.index }}]</h1>
    {% endif %}

    {{ content }}

{% endblock %}

{% block attributions %}
    {% for a in page.attribution %}
        <p>{{ a }}</p>
    {% endfor %}
{% endblock attributions %}

{% block license %}
    <p>
        Licence:
        <a href="{{ page.license.url }}">
            {{ page.license.title }}
        </a>
    </p>
    {% if page.license_code %}
        <p>
            Licence ukázek kódu:
            <a href="{{ page.license_code.url }}">
                {{ page.license_code.title }}
            </a>
        </p>
    {% endif %}
{% endblock license %}

{%- block prev_next %}
    {%- set mat = page.lesson.material %}
    {%- if mat and not is_canonical_lesson %}


        {% call nav.prevnext() %}
            {% if page.slug != 'index' %}
                {{ nav.prev(mat.get_url(), mat.title) }}
            {% elif mat.prev %}
                {{ nav.prev(mat.prev.get_url(), mat.prev.title) }}
            {% endif %}
            {% if mat.session %}
                {{ nav.up(mat.session.get_url(), 'Lekce: ' + mat.session.title) }}
            {% endif %}
            {% if mat.next %}
                {{ nav.next(mat.next.get_url(), mat.next.title) }}
            {% elif mat.session %}
                {{ nav.next(mat.session.pages['back'].get_url(), 'Závěr lekce') }}
            {% endif %}
        {% endcall %}

        {% endif %}
        {{-'\n'}}
{%- endblock prev_next %}

{% block extra_header_items -%}
    {% if page.modules.get('katex') == '0.7.1' %}
        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.7.1/katex.min.css" integrity="sha384-wITovz90syo1dJWVh32uuETPVEtGigN07tkttEqPv+uR2SE/mbQcG7ATL28aI9H0" crossorigin="anonymous">
        {% endif %}
{%- endblock %}

{% block extra_javascript -%}
        {% if page.modules.get('katex') == '0.7.1' %}
        <script src="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.7.1/katex.min.js" integrity="sha384-/y1Nn9+QQAipbNQWU65krzJralCnuOasHncUFXGkdwntGeSvQicrYkiUBwsgUqc1" crossorigin="anonymous"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.7.1/contrib/auto-render.min.js" integrity="sha384-dq1/gEHSxPZQ7DdrM82ID4YVol9BYyU7GbWlIwnwyPzotpoc57wDw/guX8EaYGPx" crossorigin="anonymous"></script>
        <script>
          renderMathInElement(
              document.body,
              {
                  delimiters: [
                      {left: "$$", right: "$$", display: true},
                      {left: "$", right: "$", display: false}
                  ]
              }
          );
        </script>
        {% endif %}
{%- endblock %}

{% block lesson_end -%}
        {% if page.lesson.material and not is_canonical_lesson %}
        <hr class="lesson-end">

        {% if not page.course.canonical %}
            <div class="alert alert-info">
                Toto je stránka lekce z kurzu, který probíhá nebo proběhl naživo s instruktorem.
                {% if page.course.derives %}
                    {% if canonical_url %}
                        <a href="{{ canonical_url }}">Přejít na stejnou lekci v kurzu pro samouky</a>.
                    {% endif %}
                {% endif %}
            </div>
        {% endif %}
        {%- endif %}
{%- endblock %}
