<html>
  <head>
      <meta charset="utf-8">
      <title>plone.versioncheck</title>
      <style type="text/css" media="screen">
          table {
            font-family: sans-serif;
            font-size: 80%;
            background-color: efefef;
          }
          td {
            border: none;
            padding: 0.5em;
            vertical-align: top;
          }
          thead th {
            border: none;
            padding: 0.5em;
            background-color: #ddddee;
          }
          .even {
            background-color: #efefff;
          }
          .odd {
            background-color: #ffffff;
          }
          .color-D {
            color: green;
          }
          .color-A {
            color: black;
          }
          .color-I {
            color: gray;
          }
          .color-In {
            color: orange;
          }
          .color-U {
            color: darkcyan;
          }
          .color-P {
            color: blue;
          }
          .color-O {
            color: magenta;
          }
          .color-X {
            color: red;
          }

      </style>
  </head>
  <body>
    <table>
      <thead>
        <tr>
          <th>package</th>
          <th>version</th>
          {% if rel_date %}<th>release date</th>{% endif %}
          <th>state</th>
          <th>info</th>
          <th>annotation</th>
          {% if req_by %}<th>required by</th>{% endif %}
        </tr>
      </thead>
      <tbody>
        {% for name, record in data.items() %}
        {% set outer_loop = loop %}
        {% for version in record['versions'] %}
        <tr class="{{outer_loop.cycle('odd', 'even')}}">

            {% if loop.first %}
            <td class="color-{{record['state']}}" rowspan="{{loop.length}}">{% if loop.first%}<a id="{{name}}" class="color-{{record['state']}}" href="https://pypi.org/project/{{name}}">{{name}}</a>{% endif %}</td>
            {% endif %}

            <td class="color-{{version['state']}}"><a class="color-{{version['state']}}" href="https://pypi.org/project/{{name}}/{{version['version']}}">{{version['version']}}</a></td>
            {% if rel_date %}<td class="color-{{version['state']}}">{{version['release_date']}}</td>{% endif %}
            <td class="color-{{version['state']}}">{{version['state'][0]}}</td>
            <td class="color-{{version['state']}}">{{version['description']}}</td>
            <td class="color-{{version['state']}}">{% if version['annotation'] %}{{version['annotation']}}<br />{% else %}&nbsp;{% endif %}</td>
            {% if loop.first and req_by %}
            <td rowspan="{{loop.length}}">
            {% for req in record.get('required_by', [])|sort %}
            <a href="#{{req}}">{{req}}</a>
            {% else %}
            {% if record['state'] != 'O' %}
            -/-
            {% else %}
            &nbsp;
            {% endif %}
            {% endfor %}
            </td>
            {% endif %}
        </tr>
        {% endfor %}
        {% endfor %}
      </tbody>
    </table>
  </body>
</html>
