{% extends "cast/cast_base.html" %}
{% load i18n %}
{% load static %}

{% load wagtailcore_tags %}
{% load wagtailimages_tags %}
{% load wagtail_srcset_tags %}

{% if page.comments_enabled %}
  {% load comments %}
{% endif %}

{% block css %}
  {{ block.super }}
  {% if page.comments_are_enabled %}
    <link rel="stylesheet" type="text/css" href="{% static 'fluent_comments/css/ajaxcomments.css' %}" />
  {% endif %}
{% endblock css %}


{% block body_class %}template-blogpage{% endblock %}

{% block title %}{{ page.title }}{% endblock title %}

{% block content %}
  {% include "cast/post_body.html" with render_detail=True %}

  {% if page.comments_are_enabled %}
    {% render_comment_list for page %}
    {% render_comment_form for page %}
  {% endif %}


  <p><a href="{{ page.get_parent.url }}">Return to blog</a></p>

{% endblock %}

{% block javascript %}
  <!-- recent jquery is needed for fluent-comments -->
  <script
    src="https://code.jquery.com/jquery-3.6.1.slim.min.js"
    integrity="sha256-w8CvhFs7iHNVUtnSP0YKEg00p9Ih13rlL9zGqvLdePA="
    crossorigin="anonymous">
  </script>
  <script type="text/javascript" src="{% static 'fluent_comments/js/ajaxcomments.js' %}"></script>

  <!-- block.super needs to be below full jquery because otherwise jquery-slim would overwrite calls necessary for comments -->
  {{ block.super }}
  <script src="{% static 'js/cast/gallery.js' %}"></script>
  <script type="text/javascript" src="{% static 'fluent_comments/js/ajaxcomments.js' %}"></script>
  {% if page.has_audio %}
    <script src={% static 'js/cast/web-player/embed.js' %}></script>
    {% for pk, audio in page.media_lookup.audio.items %}
      <script>podlovePlayer("#audio_{{ audio.pk }}", "{{ audio.podlove_url }}");</script>
    {% endfor %}
  {% endif %}

{% endblock javascript %}
