{% extends "layout.html" %}

{% block title %}History for tag {{ tag.tag }}{% endblock %}

{% block head %}
  <script type="text/javascript" src="/static/js/toggle.js"></script>
  <script type="text/javascript" src="/static/js/history.js"></script>
{% endblock %}

{% block breadcrumb %}
  {{ macros.breadcrumb(breadcrumb) }}
{% endblock %}

{% block hamburger %}
  {{ macros.tagHamburger(tag, neighbours, "/history", dependencies) }}
{% endblock %}

{% block body %}
<h2>History of tag <span class="tag">{{ tag.tag }}</span></h2>
<p><a href="/tag/{{ tag.tag }}">Go back to the tag's page</a>.

<table class="table table-hover table-sm" id="history">
  <thead>
    <tr>
      <th>type</th>
      <th>time</th>
      <th>link</th>
    </tr>
  </thead>

  <tbody>
{% for change in changes %}
<tr>
  <td>
    {% if change.action == "creation" %}
      {% set infix = "blob" %}
      {% set suffix = "#L" ~ change.begin ~ "-L" ~ change.end %}
      created statement with label <span class="label">{{ change.label }}</span> in <span class="filename">{{ change.filename }}.tex</span>

    {% elif change.action == "tag" %}
      {% set infix = "commit" %}
      assigned tag <span class="tag">{{ change.tag.tag }}</span>

    {% elif change.action == "statement" %}
      {% set infix = "commit" %}
      {% set suffix = "#diff-" ~ md5(change.filename ~ ".tex") ~ "R" ~ change.begin %}
      changed the statement

    {% elif change.action == "proof" %}
      {% set infix = "commit" %}
      {% set suffix = "#diff-" ~ md5(change.filename ~ ".tex") ~ "R" ~ change.begin %}
      changed the proof

    {% elif change.action == "statement and proof" %}
      {% set infix = "commit" %}
      {% set suffix = "#diff-" ~ md5(change.filename ~ ".tex") ~ "R" ~ change.begin %}
      changed the statement and the proof

    {% elif change.action == "move file" %}
      {% set infix = "blob" %}
      moved the statement to file <span class="filename">{{ change.filename }}.tex</span>

    {% elif change.action == "label" %}
      {% set infix = "commit" %}
      {% set suffix = "#diff-" ~ md5(change.filename ~ ".tex") ~ "R" ~ change.begin %}
      changed the label to <span class="label">{{ change.label }}</span>

    {% else %}
      <strong>if you see this, something went wrong</strong>
    {% endif %}
  </td>

  <td>{{ change.commit.time }}</td>
  {% if change.action == "tag" %}
    <td><a href="https://github.com/stacks/stacks-project/{{ infix }}/{{ change.commit.hash }}" class="commit">{{ change.commit.hash[0:7] }}</a>
  {% else %}
    <td><a href="https://github.com/stacks/stacks-project/{{ infix }}/{{ change.commit.hash }}/{{ change.filename }}.tex{{ suffix }}" class="commit">{{ change.commit.hash[0:7] }}</a></td>
  {% endif %}
</tr>
<tr>
  <td colspan="3">
    <pre class="commit-message">{{ change.commit.log }}</pre>
  </td>
</tr>
{% endfor %}
  </tbody>
</table>

{% endblock %}

{% block sidebar %}
  {{ macros.tagSidebar(tag, neighbours, "/history", dependencies, filename) }}
{% endblock %}


