<!DOCTYPE html>
<head>
  {% set double_bubble = "&#x1F5EA;" %}
  {% set empty_box = "&#x2610;" %}
  {% set checked_box = "&#x1F5F9;" %}
  <title>{{ double_bubble }} Activity since {{ since|datetime("%Y-%m-%d") }}</title>
  <style>
  body {
    font-family: sans-serif;
    max-width: 60em;
    margin: auto;
    line-height: 1.3;
  }
  ul {
    padding-left: 0;
    list-style-type: none;
  }
  .reponame {
    font-weight: bold;
    font-size: 150%;
  }
  ul.item {
    padding-left: 0em;
    margin-bottom: 1em;
  }
  ul.item > li {
    margin: .5em 0;
  }
  ul.item p {
    margin: .2em 0 0 3em;
  }
  ul.comment {
    padding-left: 3em;
  }
  .icon {
    display: inline-block;
    width: 1em;
    color: #ccc;
  }
  .icon.created, .icon.closed, .icon.merged {
    color: black;
    cursor: default;
  }
  a {
    text-decoration: none;
  }
  a:hover {
    text-decoration: underline;
  }
  .label {
    padding: .2em .5em .1em .5em;
    border-radius: 2em;
    font-size: 75%;
    opacity: .75;
    vertical-align: middle;
    white-space: nowrap;
  }
  .homerepo {
    color: #888;
  }
  </style>
<body>
<h1>Activity since {{ since|datetime("%Y-%m-%d") }}</h1>
<ul class="repo">
  {% for thing, items in results -%}
    <li>
      <span class="reponame"><a href="{{ thing.url }}">
      {%- if thing.container_kind == "repo" -%}
        {{ thing.nameWithOwner }}
      {%- elif thing.container_kind == "project" -%}
        {{ thing.title }}
      {%- elif thing.container_kind == "search" -%}
        {{ thing.query }}
      {%- endif -%}
      </a></span>
      {{ thing.container_kind }} {{ thing.kind }}
      {% if items %}
        <ul class="item">
          {% for item in items -%}
            <li class="{{ item.state|lower }}">

              {%- if item.reasonCreated -%}
                <span class="icon created" title="newly created">&Star;</span>
              {%- else -%}
                <span class="icon">&ndash;</span>
              {%- endif -%}
              {% if item.reasonMerged -%}
                <span class="icon merged" title="newly merged">&#x2713;</span>
              {%- elif item.reasonClosed -%}
              <span class="icon closed" title="newly closed">&times;</span>
              {%- else -%}
                <span class="icon">&ndash;</span>
              {%- endif -%}

              <a href="{{ item.url }}"><b>{{item.title}}</b> #{{ item.number }}</a>
              [{{ item.author.login }}]

              {% if item.labels -%}
                {%- for label in item.labels.nodes -%}
                  <span class="label" style="background: #{{label.color}}; color: {{label.color|textcolor}}">{{ label.name }}</span>
                {% endfor %}
              {%- endif -%}

              {% if item.other_repo -%}
                <span class="homerepo">{{ item.repository.nameWithOwner }}</span>
              {%- endif %}

              {%- if item.body %}<p>{{ item.body|truncate(120) }}</p>{% endif -%}

              {% if item.comments_to_show -%}
                <ul class="comment">
                  {% for comment in item.comments_to_show -%}
                    <li>
                      <a href="{{ comment.url }}" title="{{ comment.updatedAt|datetime() }}">
                        {% if comment.review_state -%}
                          {% if comment.review_state == "APPROVED" -%}
                            {{ checked_box }}
                          {% else %}
                            {{ empty_box }}
                          {% endif %}
                        {% else %}
                          {{ double_bubble }}
                        {% endif %}
                        {{ comment.author.login }}</a>{# -#}
                      {%- if comment.body %}: {{ comment.body|trim|truncate(100) }}{% endif -%}
                      {%- if comment.review_state -%}
                        &nbsp;<i>(review:&nbsp;{{ comment.review_state|lower|replace("_", " ") }})</i>
                      {% endif -%}
                    </li>
                  {% endfor -%}
                </ul>
              {% endif -%}

            </li>
          {% endfor -%}
        </ul>
      {% else %}
        <p>Nothing happening</p>
      {% endif %}
    </li>
  {% endfor -%}
</ul>
