{% extends "wiki/__base.html" %}

{% load markdownify %}
{% load wiki_extras %}


{% block title %}{{ mypage.name|make_title }}{% endblock %}


{% block mainheading %}
{{ mypage.name|make_title }}
{% endblock %}


{% block feedback %}
{% if status_key %}
<div class="mt-4 alert alert-success alert-dismissible fade show" role="alert">
    <strong>Success:</strong>
    {% if status_key == 'created' %}
    page "{{ mypage.name }}" created
    {% elif status_key == 'updated' %}
    page "{{ mypage.name }}" updated
    {% else %}
    hilarity ensued
    {% endif %}

    <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
{% endif %}
{% endblock %}


{% block content %}

<div class="wiki_content">
{{ mypage.content | markdownify | linkify | safe }}
</div>

<p class="mt-2"><a class="btn btn-secondary" style="color: white" href="{% url 'djwiki:page_edit' mypage.name %}">Edit Page</a></p>

<hr>

<!-- h4>Version History</h4>

<p>Created: {{ mypage.created }}</p>

<ul>
{% for hist in mypage.history.all %}
    <li><a href="{% url 'djwiki:page_archive' mypage.name hist.history_id %}">{{ hist.history_date|date:"M d, Y H:m"  }}</a> - {{ hist.edit_reason }}</li>
{% endfor %}
</ul -->

{% endblock %}



{% block subcontent %}

<!-- hr -->

<div class="accordion" id="accordionExample">
  <div class="accordion-item">
    <h2 class="accordion-header" id="headingOne">
      <button class="accordion-button" type="button" data-bs-toggle="collapse" data-bs-target="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
        <strong>Version History</strong>
      </button>
    </h2>
    <div id="collapseOne" class="accordion-collapse collapse show" aria-labelledby="headingOne" data-bs-parent="#accordionExample">
      <div class="accordion-body overflow-auto" style="height: 10em; padding: 0">
        <!-- ul>
        {% for hist in mypage.history.all %}
            <li>
              <a href="{% url 'djwiki:page_archive' mypage.name hist.history_id %}">{{ hist.history_date|date:"M d, Y H:i"  }}</a> -
              {{ hist.edit_reason }} -
              <a href="{% url 'djwiki:user' hist.history_user.username %}">{{ hist.history_user }}</a>
            </li>
        {% endfor %}
        </ul -->

<table class="table table-striped">
  <!-- thead>
  <tr>
    <th>Rev.</th>
    <th>Date</th>
    <th>Reason</th>
    <th>Author</th>
  </tr>
  </thead -->
  <tbody>
{% for hist in mypage.history.all %}
            <tr>
              <!-- td style="width: 100px" class="text-nowrap"><a href="{% url 'djwiki:page_archive' mypage.name hist.history_id %}">{{ hist.history_date|date:"M d, Y H:i"  }}</a></td -->
              <td style="width: 100px" class="text-nowrap"><a href="{% url 'djwiki:page_archive' mypage.name hist.history_id %}">{{ hist.history_date|date:"y-m-d H:i"  }}</a></td>
              <td>{{ hist.edit_reason }}</td>
              <td class="text-end"><a href="{% url 'djwiki:user' hist.history_user.username %}">{{ hist.history_user }}</a></td>
            </tr>
        {% endfor %}
  </tbody>
</table>
      </div>
  </div>
  <!-- div class="accordion-item">
    <h2 class="accordion-header" id="headingTwo">
      <button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo">
        Version History
      </button>
    </h2>
    <div id="collapseTwo" class="accordion-collapse collapse" aria-labelledby="headingTwo" data-bs-parent="#accordionExample">
      <div class="accordion-body">
        <strong>This is the second item's accordion body.</strong> It is hidden by default, until the collapse plugin adds the appropriate classes that we use to style each element. These classes control the overall appearance, as well as the showing and hiding via CSS transitions. You can modify any of this with custom CSS or overriding our default variables. It's also worth noting that just about any HTML can go within the <code>.accordion-body</code>, though the transition does limit overflow.
      </div>
    </div>
  </div -->
  <!-- div class="accordion-item">
    <h2 class="accordion-header" id="headingThree">
      <button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#collapseThree" aria-expanded="false" aria-controls="collapseThree">
        Accordion Item #3
      </button>
    </h2>
    <div id="collapseThree" class="accordion-collapse collapse" aria-labelledby="headingThree" data-bs-parent="#accordionExample">
      <div class="accordion-body">
        <strong>This is the third item's accordion body.</strong> It is hidden by default, until the collapse plugin adds the appropriate classes that we use to style each element. These classes control the overall appearance, as well as the showing and hiding via CSS transitions. You can modify any of this with custom CSS or overriding our default variables. It's also worth noting that just about any HTML can go within the <code>.accordion-body</code>, though the transition does limit overflow.
      </div>
    </div>
  </div -->
</div>


{% endblock %}


{% block footer %}
<!-- <a href="{% url 'djwiki:page_edit' mypage.name %}">Edit</a>
| -->
<a href="{% url 'djwiki:home' %}">Wiki Home</a>
|
<a href="{% url 'djwiki:space' mypage.space.name %}">Space:{{ mypage.space.name }}</a>
{% endblock %}
